2021-04-12 04:15:02 -06:00
|
|
|
/*
|
|
|
|
Copyright 2021 Yarmo Mackenbach
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
2021-04-22 07:14:21 -06:00
|
|
|
/**
|
|
|
|
* Contains enums
|
|
|
|
* @module enums
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The proxy policy that decides how to fetch a proof
|
|
|
|
* @readonly
|
|
|
|
* @enum {string}
|
|
|
|
*/
|
2021-04-19 03:44:30 -06:00
|
|
|
const ProxyPolicy = {
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Proxy usage decision depends on environment and service provider */
|
2021-04-12 09:01:25 -06:00
|
|
|
ADAPTIVE: 'adaptive',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Always use a proxy */
|
2021-04-12 09:01:25 -06:00
|
|
|
ALWAYS: 'always',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Never use a proxy, skip a verification if a proxy is inevitable */
|
2021-07-09 15:44:52 -06:00
|
|
|
NEVER: 'never'
|
2021-04-12 09:01:25 -06:00
|
|
|
}
|
|
|
|
Object.freeze(ProxyPolicy)
|
|
|
|
|
2021-04-22 07:14:21 -06:00
|
|
|
/**
|
|
|
|
* Methods for fetching proofs
|
|
|
|
* @readonly
|
|
|
|
* @enum {string}
|
|
|
|
*/
|
2021-04-19 03:44:30 -06:00
|
|
|
const Fetcher = {
|
2022-09-30 15:39:10 -06:00
|
|
|
/** HTTP requests to ActivityPub */
|
|
|
|
ACTIVITYPUB: 'activitypub',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** DNS module from Node.js */
|
2021-04-12 07:59:21 -06:00
|
|
|
DNS: 'dns',
|
2023-03-19 02:51:45 -06:00
|
|
|
/** GraphQL over HTTP requests */
|
|
|
|
GRAPHQL: 'graphql',
|
2022-09-30 15:39:10 -06:00
|
|
|
/** Basic HTTP requests */
|
|
|
|
HTTP: 'http',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** IRC module from Node.js */
|
2021-04-12 07:59:21 -06:00
|
|
|
IRC: 'irc',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** HTTP request to Matrix API */
|
2021-04-12 07:59:21 -06:00
|
|
|
MATRIX: 'matrix',
|
2022-08-11 03:58:36 -06:00
|
|
|
/** HTTP request to Telegram API */
|
|
|
|
TELEGRAM: 'telegram',
|
2022-09-30 15:39:10 -06:00
|
|
|
/** XMPP module from Node.js */
|
|
|
|
XMPP: 'xmpp'
|
2021-04-12 07:59:21 -06:00
|
|
|
}
|
|
|
|
Object.freeze(Fetcher)
|
|
|
|
|
2023-03-12 14:43:43 -06:00
|
|
|
/**
|
|
|
|
* Entity encoding format
|
|
|
|
* @readonly
|
|
|
|
* @enum {string}
|
|
|
|
*/
|
|
|
|
const EntityEncodingFormat = {
|
|
|
|
/** No special formatting */
|
|
|
|
PLAIN: 'plain',
|
|
|
|
/** HTML encoded entities */
|
|
|
|
HTML: 'html',
|
|
|
|
/** XML encoded entities */
|
|
|
|
XML: 'xml'
|
|
|
|
}
|
|
|
|
Object.freeze(EntityEncodingFormat)
|
|
|
|
|
2021-04-22 07:14:21 -06:00
|
|
|
/**
|
|
|
|
* Levels of access restriction for proof fetching
|
|
|
|
* @readonly
|
2022-11-17 12:48:48 -07:00
|
|
|
* @enum {string}
|
2021-04-22 07:14:21 -06:00
|
|
|
*/
|
2021-04-19 03:44:30 -06:00
|
|
|
const ProofAccess = {
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Any HTTP request will work */
|
2022-11-17 12:48:48 -07:00
|
|
|
GENERIC: 'generic',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** CORS requests are denied */
|
2022-11-17 12:48:48 -07:00
|
|
|
NOCORS: 'nocors',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** HTTP requests must contain API or access tokens */
|
2022-11-17 12:48:48 -07:00
|
|
|
GRANTED: 'granted',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Not accessible by HTTP request, needs server software */
|
2022-11-17 12:48:48 -07:00
|
|
|
SERVER: 'server'
|
2021-04-12 04:15:02 -06:00
|
|
|
}
|
2021-04-12 07:59:21 -06:00
|
|
|
Object.freeze(ProofAccess)
|
2021-04-12 04:15:02 -06:00
|
|
|
|
2021-04-22 07:14:21 -06:00
|
|
|
/**
|
|
|
|
* Format of proof
|
|
|
|
* @readonly
|
|
|
|
* @enum {string}
|
|
|
|
*/
|
2021-04-19 03:44:30 -06:00
|
|
|
const ProofFormat = {
|
2021-04-22 07:14:21 -06:00
|
|
|
/** JSON format */
|
2021-04-16 02:54:28 -06:00
|
|
|
JSON: 'json',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Plaintext format */
|
2021-07-09 15:44:52 -06:00
|
|
|
TEXT: 'text'
|
2021-04-12 04:15:02 -06:00
|
|
|
}
|
2021-04-12 07:59:21 -06:00
|
|
|
Object.freeze(ProofFormat)
|
2021-04-12 04:15:02 -06:00
|
|
|
|
2021-04-22 07:14:21 -06:00
|
|
|
/**
|
|
|
|
* Format of claim
|
|
|
|
* @readonly
|
2022-11-17 12:48:48 -07:00
|
|
|
* @enum {string}
|
2021-04-22 07:14:21 -06:00
|
|
|
*/
|
2021-04-19 03:44:30 -06:00
|
|
|
const ClaimFormat = {
|
2021-04-22 07:14:21 -06:00
|
|
|
/** `openpgp4fpr:123123123` */
|
2022-11-17 12:48:48 -07:00
|
|
|
URI: 'uri',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** `123123123` */
|
2022-11-17 12:48:48 -07:00
|
|
|
FINGERPRINT: 'fingerprint'
|
2021-04-12 06:31:48 -06:00
|
|
|
}
|
2021-04-12 07:59:21 -06:00
|
|
|
Object.freeze(ClaimFormat)
|
2021-04-12 06:31:48 -06:00
|
|
|
|
2021-04-22 07:14:21 -06:00
|
|
|
/**
|
|
|
|
* How to find the claim inside the proof's JSON data
|
|
|
|
* @readonly
|
2022-11-17 12:48:48 -07:00
|
|
|
* @enum {string}
|
2021-04-22 07:14:21 -06:00
|
|
|
*/
|
2021-04-19 03:44:30 -06:00
|
|
|
const ClaimRelation = {
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Claim is somewhere in the JSON field's textual content */
|
2022-11-17 12:48:48 -07:00
|
|
|
CONTAINS: 'contains',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Claim is equal to the JSON field's textual content */
|
2022-11-17 12:48:48 -07:00
|
|
|
EQUALS: 'equals',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Claim is equal to an element of the JSON field's array of strings */
|
2022-11-17 12:48:48 -07:00
|
|
|
ONEOF: 'oneof'
|
2021-04-12 06:31:48 -06:00
|
|
|
}
|
2021-04-12 07:59:21 -06:00
|
|
|
Object.freeze(ClaimRelation)
|
2021-04-12 06:31:48 -06:00
|
|
|
|
2021-04-22 07:14:21 -06:00
|
|
|
/**
|
|
|
|
* Status of the Claim instance
|
|
|
|
* @readonly
|
|
|
|
* @enum {string}
|
|
|
|
*/
|
|
|
|
const ClaimStatus = {
|
|
|
|
/** Claim has been initialized */
|
2021-04-19 03:48:13 -06:00
|
|
|
INIT: 'init',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Claim has matched its URI to candidate claim definitions */
|
2021-04-19 03:48:13 -06:00
|
|
|
MATCHED: 'matched',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Claim has verified one or multiple candidate claim definitions */
|
2021-07-09 15:44:52 -06:00
|
|
|
VERIFIED: 'verified'
|
2021-04-19 03:48:13 -06:00
|
|
|
}
|
2021-04-22 07:14:21 -06:00
|
|
|
Object.freeze(ClaimStatus)
|
2021-04-19 03:48:13 -06:00
|
|
|
|
2021-04-12 09:01:25 -06:00
|
|
|
exports.ProxyPolicy = ProxyPolicy
|
2021-04-12 07:59:21 -06:00
|
|
|
exports.Fetcher = Fetcher
|
2023-03-12 14:43:43 -06:00
|
|
|
exports.EntityEncodingFormat = EntityEncodingFormat
|
2021-04-12 07:59:21 -06:00
|
|
|
exports.ProofAccess = ProofAccess
|
|
|
|
exports.ProofFormat = ProofFormat
|
|
|
|
exports.ClaimFormat = ClaimFormat
|
2021-04-15 02:21:56 -06:00
|
|
|
exports.ClaimRelation = ClaimRelation
|
2021-04-22 07:14:21 -06:00
|
|
|
exports.ClaimStatus = ClaimStatus
|