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 = {
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Basic HTTP requests */
|
2021-04-12 07:59:21 -06:00
|
|
|
HTTP: 'http',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** DNS module from Node.js */
|
2021-04-12 07:59:21 -06:00
|
|
|
DNS: 'dns',
|
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
|
|
|
/** XMPP module from Node.js */
|
2021-04-12 07:59:21 -06:00
|
|
|
XMPP: 'xmpp',
|
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',
|
2021-04-22 07:14:21 -06:00
|
|
|
/** HTTP request to Twitter API */
|
2021-07-09 15:44:52 -06:00
|
|
|
TWITTER: 'twitter'
|
2021-04-12 07:59:21 -06:00
|
|
|
}
|
|
|
|
Object.freeze(Fetcher)
|
|
|
|
|
2021-04-22 07:14:21 -06:00
|
|
|
/**
|
|
|
|
* Levels of access restriction for proof fetching
|
|
|
|
* @readonly
|
|
|
|
* @enum {number}
|
|
|
|
*/
|
2021-04-19 03:44:30 -06:00
|
|
|
const ProofAccess = {
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Any HTTP request will work */
|
2021-04-12 04:15:02 -06:00
|
|
|
GENERIC: 0,
|
2021-04-22 07:14:21 -06:00
|
|
|
/** CORS requests are denied */
|
2021-04-12 04:15:02 -06:00
|
|
|
NOCORS: 1,
|
2021-04-22 07:14:21 -06:00
|
|
|
/** HTTP requests must contain API or access tokens */
|
2021-04-12 04:15:02 -06:00
|
|
|
GRANTED: 2,
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Not accessible by HTTP request, needs server software */
|
2021-07-09 15:44:52 -06:00
|
|
|
SERVER: 3
|
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
|
|
|
|
* @enum {number}
|
|
|
|
*/
|
2021-04-19 03:44:30 -06:00
|
|
|
const ClaimFormat = {
|
2021-04-22 07:14:21 -06:00
|
|
|
/** `openpgp4fpr:123123123` */
|
2021-04-12 06:31:48 -06:00
|
|
|
URI: 0,
|
2021-04-22 07:14:21 -06:00
|
|
|
/** `123123123` */
|
2022-08-16 13:46:54 -06:00
|
|
|
FINGERPRINT: 1
|
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
|
|
|
|
* @enum {number}
|
|
|
|
*/
|
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 */
|
2021-04-12 06:31:48 -06:00
|
|
|
CONTAINS: 0,
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Claim is equal to the JSON field's textual content */
|
2021-04-12 06:31:48 -06:00
|
|
|
EQUALS: 1,
|
2021-04-22 07:14:21 -06:00
|
|
|
/** Claim is equal to an element of the JSON field's array of strings */
|
2021-07-09 15:44:52 -06:00
|
|
|
ONEOF: 2
|
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
|
|
|
|
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
|