@govtechsg/open-attestation
Version:
920 lines (907 loc) • 353 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('debug'), require('runtypes'), require('@ethersproject/bytes'), require('js-sha3'), require('lodash'), require('validator/lib/isUUID'), require('uuid'), require('@ethersproject/logger'), require('ajv-formats/dist/formats'), require('flatley'), require('crypto'), require('js-base64'), require('@ethersproject/wallet'), require('@govtechsg/jsonld'), require('cross-fetch'), require('@ethersproject/abstract-signer')) :
typeof define === 'function' && define.amd ? define(['exports', 'debug', 'runtypes', '@ethersproject/bytes', 'js-sha3', 'lodash', 'validator/lib/isUUID', 'uuid', '@ethersproject/logger', 'ajv-formats/dist/formats', 'flatley', 'crypto', 'js-base64', '@ethersproject/wallet', '@govtechsg/jsonld', 'cross-fetch', '@ethersproject/abstract-signer'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.openAttestation = {}, global.debug, global.runtypes, global.bytes, global.jsSha3, global.lodash, global.isUUID, global.uuid, global.logger$2, global.formats, global.flatley, global.crypto, global.jsBase64, global.wallet, global.jsonld, global.fetch, global.abstractSigner));
})(this, (function (exports, debug, runtypes, bytes, jsSha3, lodash, isUUID, uuid, logger$2, formats, flatley, crypto, jsBase64, wallet, jsonld, fetch, abstractSigner) { 'use strict';
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var debug__default = /*#__PURE__*/_interopDefaultLegacy(debug);
var isUUID__default = /*#__PURE__*/_interopDefaultLegacy(isUUID);
var formats__default = /*#__PURE__*/_interopDefaultLegacy(formats);
var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
var logger$1 = debug__default["default"]("open-attestation");
var getLogger = function (namespace) { return ({
trace: logger$1.extend("trace:".concat(namespace)),
debug: logger$1.extend("debug:".concat(namespace)),
info: logger$1.extend("info:".concat(namespace)),
warn: logger$1.extend("warn:".concat(namespace)),
error: logger$1.extend("error:".concat(namespace)),
}); };
exports.SchemaId = void 0;
(function (SchemaId) {
SchemaId["v2"] = "https://schema.openattestation.com/2.0/schema.json";
SchemaId["v3"] = "https://schema.openattestation.com/3.0/schema.json";
})(exports.SchemaId || (exports.SchemaId = {}));
var OpenAttestationHexString = runtypes.String.withConstraint(function (value) { return bytes.isHexString("0x".concat(value), 32) || "".concat(value, " has not the expected length of 32 bytes"); });
var SignatureAlgorithm = runtypes.Literal("OpenAttestationMerkleProofSignature2018");
var ProofType$1 = runtypes.Literal("OpenAttestationSignature2018");
var ProofPurpose = runtypes.Literal("assertionMethod");
var UUIDV4_LENGTH = 37;
var PRIMITIVE_TYPES = ["string", "number", "boolean", "undefined"];
/* eslint-disable no-use-before-define */
/**
* Curried function that takes (iteratee)(value),
* if value is a collection then recurse into it
* otherwise apply `iteratee` on the primitive value
*/
var recursivelyApply = function (iteratee) { return function (value) {
if (lodash.includes(PRIMITIVE_TYPES, typeof value) || value === null) {
return iteratee(value);
}
return deepMap(value, iteratee); // eslint-disable-line @typescript-eslint/no-use-before-define
}; };
/**
* Applies `iteratee` to all fields in objects, goes into arrays as well.
* Refer to test for example
*/
var deepMap = function (collection, iteratee) {
if (iteratee === void 0) { iteratee = lodash.identity; }
if (collection instanceof Array) {
return lodash.map(collection, recursivelyApply(iteratee));
}
if (typeof collection === "object") {
return lodash.mapValues(collection, recursivelyApply(iteratee));
}
return collection;
};
/* eslint-enable no-use-before-define */
// disabling this because of mutual recursion
var startsWithUuidV4 = function (input) {
if (input && typeof input === "string") {
var elements = input.split(":");
return isUUID__default["default"](elements[0], 4);
}
return false;
};
/**
* Detects the type of a value and returns a string with type annotation
*/
function primitiveToTypedString(value) {
switch (typeof value) {
case "number":
case "string":
case "boolean":
case "undefined":
return "".concat(typeof value, ":").concat(String(value));
default:
if (value === null) {
// typeof null is 'object' so we have to check for it
return "null:null";
}
throw new Error("Parsing error, value is not of primitive type: ".concat(value));
}
}
/**
* Returns an appropriately typed value given a string with type annotations, e.g: "number:5"
*/
function typedStringToPrimitive(input) {
var _a = input.split(":"), type = _a[0], valueArray = _a.slice(1);
var value = valueArray.join(":"); // just in case there are colons in the value
switch (type) {
case "number":
return Number(value);
case "string":
return String(value);
case "boolean":
return value === "true";
case "null":
return null;
case "undefined":
return undefined;
default:
throw new Error("Parsing error, type annotation not found in string: ".concat(input));
}
}
/**
* Returns a salted value using a randomly generated uuidv4 string for salt
*/
function uuidSalt(value) {
var salt = uuid.v4();
return "".concat(salt, ":").concat(primitiveToTypedString(value));
}
/**
* Value salted string in the format "salt:type:value", example: "ee7f3323-1634-4dea-8c12-f0bb83aff874:number:5"
* Returns an appropriately typed value when given a salted string with type annotation
*/
function unsalt(value) {
if (startsWithUuidV4(value)) {
var untypedValue = value.substring(UUIDV4_LENGTH).trim();
return typedStringToPrimitive(untypedValue);
}
return value;
}
// Use uuid salting method to recursively salt data
var saltData = function (data) { return deepMap(data, uuidSalt); };
var unsaltData = function (data) { return deepMap(data, unsalt); };
var IdentityProofType$1;
(function (IdentityProofType) {
IdentityProofType["DNSDid"] = "DNS-DID";
IdentityProofType["DNSTxt"] = "DNS-TXT";
IdentityProofType["Did"] = "DID";
})(IdentityProofType$1 || (IdentityProofType$1 = {}));
/**
* Proof Open Attestation method
*/
var Method;
(function (Method) {
Method["Did"] = "DID";
Method["DocumentStore"] = "DOCUMENT_STORE";
Method["TokenRegistry"] = "TOKEN_REGISTRY";
})(Method || (Method = {}));
/**
* Revocation method (if required by proof method)
*/
var RevocationType$1;
(function (RevocationType) {
RevocationType["None"] = "NONE";
RevocationType["OcspResponder"] = "OCSP_RESPONDER";
RevocationType["RevocationStore"] = "REVOCATION_STORE";
})(RevocationType$1 || (RevocationType$1 = {}));
/**
* Proof method name as explained by https://www.w3.org/TR/vc-data-model/#types
*/
var ProofType;
(function (ProofType) {
ProofType["OpenAttestationProofMethod"] = "OpenAttestationProofMethod";
})(ProofType || (ProofType = {}));
/**
* Type of renderer template
*/
var TemplateType$1;
(function (TemplateType) {
TemplateType["EmbeddedRenderer"] = "EMBEDDED_RENDERER";
})(TemplateType$1 || (TemplateType$1 = {}));
/**
* @deprecated will be removed in the next major release in favour of OpenAttestation v4.0 (more info: https://github.com/Open-Attestation/open-attestation/tree/alpha)
*/
var ObfuscationMetadata$1 = runtypes.Record({
obfuscated: runtypes.Array(OpenAttestationHexString),
});
/**
* @deprecated will be removed in the next major release in favour of OpenAttestation v4.0 (more info: https://github.com/Open-Attestation/open-attestation/tree/alpha)
*/
var VerifiableCredentialWrappedProof = runtypes.Record({
type: SignatureAlgorithm,
targetHash: runtypes.String,
merkleRoot: runtypes.String,
proofs: runtypes.Array(runtypes.String),
salts: runtypes.String,
privacy: ObfuscationMetadata$1,
proofPurpose: ProofPurpose,
});
/**
* @deprecated will be removed in the next major release in favour of OpenAttestation v4.0 (more info: https://github.com/Open-Attestation/open-attestation/tree/alpha)
*/
var VerifiableCredentialWrappedProofStrict = VerifiableCredentialWrappedProof.And(runtypes.Record({
targetHash: OpenAttestationHexString,
merkleRoot: OpenAttestationHexString,
proofs: runtypes.Array(OpenAttestationHexString),
}));
/**
* @deprecated will be removed in the next major release in favour of OpenAttestation v4.0 (more info: https://github.com/Open-Attestation/open-attestation/tree/alpha)
*/
var VerifiableCredentialSignedProof = VerifiableCredentialWrappedProof.And(runtypes.Record({
key: runtypes.String,
signature: runtypes.String,
}));
var types$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
ObfuscationMetadata: ObfuscationMetadata$1,
VerifiableCredentialWrappedProof: VerifiableCredentialWrappedProof,
VerifiableCredentialWrappedProofStrict: VerifiableCredentialWrappedProofStrict,
VerifiableCredentialSignedProof: VerifiableCredentialSignedProof,
get IdentityProofType () { return IdentityProofType$1; },
get Method () { return Method; },
get RevocationType () { return RevocationType$1; },
get ProofType () { return ProofType; },
get TemplateType () { return TemplateType$1; }
});
/**
* Type of renderer template
*/
var TemplateType;
(function (TemplateType) {
TemplateType["EmbeddedRenderer"] = "EMBEDDED_RENDERER";
})(TemplateType || (TemplateType = {}));
var IdentityProofType;
(function (IdentityProofType) {
IdentityProofType["DNSDid"] = "DNS-DID";
IdentityProofType["DNSTxt"] = "DNS-TXT";
IdentityProofType["Did"] = "DID";
})(IdentityProofType || (IdentityProofType = {}));
var RevocationType;
(function (RevocationType) {
RevocationType["None"] = "NONE";
RevocationType["OcspResponder"] = "OCSP_RESPONDER";
RevocationType["RevocationStore"] = "REVOCATION_STORE";
})(RevocationType || (RevocationType = {}));
var ObfuscationMetadata = runtypes.Partial({
obfuscatedData: runtypes.Array(OpenAttestationHexString),
});
var Proof = runtypes.Record({
type: ProofType$1,
created: runtypes.String,
proofPurpose: ProofPurpose,
verificationMethod: runtypes.String,
signature: runtypes.String,
});
var ArrayProof = runtypes.Array(Proof);
var Signature = runtypes.Record({
type: runtypes.Literal("SHA3MerkleProof"),
targetHash: runtypes.String,
merkleRoot: runtypes.String,
proof: runtypes.Array(runtypes.String),
});
var SignatureStrict = Signature.And(runtypes.Record({
targetHash: OpenAttestationHexString,
merkleRoot: OpenAttestationHexString,
proof: runtypes.Array(OpenAttestationHexString),
}));
var types = /*#__PURE__*/Object.freeze({
__proto__: null,
ObfuscationMetadata: ObfuscationMetadata,
Proof: Proof,
ArrayProof: ArrayProof,
Signature: Signature,
SignatureStrict: SignatureStrict,
get TemplateType () { return TemplateType; },
get IdentityProofType () { return IdentityProofType; },
get RevocationType () { return RevocationType; }
});
function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var compiled_schema_strict = createCommonjsModule(function (module, exports) {
exports["https://schema.openattestation.com/2.0/schema.json"] = validate10;
var schema11 = { "title": "Open Attestation Schema 2.0", "$id": "https://schema.openattestation.com/2.0/schema.json", "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "identityProofDns": { "type": "object", "properties": { "type": { "type": "string", "enum": ["DNS-TXT"] }, "location": { "type": "string", "description": "Url of the website referencing to document store" } }, "required": ["type", "location"] }, "identityProofDid": { "type": "object", "properties": { "type": { "type": "string", "enum": ["DID"] }, "key": { "type": "string", "description": "Public key associated" } }, "required": ["type", "key"] }, "identityProofDnsDid": { "type": "object", "properties": { "type": { "type": "string", "enum": ["DNS-DID"] }, "key": { "type": "string", "description": "Public key associated" }, "location": { "type": "string", "description": "Url of the website referencing to document store" } }, "required": ["type", "key", "location"] }, "identityProof": { "type": "object", "oneOf": [{ "$ref": "#/definitions/identityProofDns" }, { "$ref": "#/definitions/identityProofDnsDid" }, { "$ref": "#/definitions/identityProofDid" }] }, "issuer": { "type": "object", "properties": { "id": { "type": "string", "description": "Issuer's id, DID can be used" }, "name": { "type": "string", "description": "Issuer's name" }, "revocation": { "type": "object", "properties": { "type": { "type": "string", "enum": ["NONE", "REVOCATION_STORE", "OCSP_RESPONDER"] }, "location": { "type": "string", "description": "Smart contract address or url of certificate revocation list for Revocation Store type revocation" } } }, "identityProof": { "$ref": "#/definitions/identityProof" } }, "required": ["name", "identityProof"], "additionalProperties": true }, "documentStore": { "allOf": [{ "$ref": "#/definitions/issuer" }, { "type": "object", "properties": { "documentStore": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$", "description": "Smart contract address of document store" } }, "required": ["documentStore"] }] }, "certificateStore": { "type": "object", "properties": { "name": { "type": "string", "description": "Issuer's name" }, "certificateStore": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$", "deprecationMessage": "Use documentStore and identityProof instead of this", "description": "Smart contract address of certificate store. Same as documentStore" } }, "required": ["name", "certificateStore"], "additionalProperties": true }, "tokenRegistry": { "allOf": [{ "$ref": "#/definitions/issuer" }, { "type": "object", "properties": { "tokenRegistry": { "type": "string", "pattern": "^0x[a-fA-F0-9]{40}$", "description": "Smart contract address of token registry" } }, "required": ["tokenRegistry"] }] } }, "type": "object", "properties": { "id": { "type": "string", "description": "Internal reference, usually serial number, of this document" }, "$template": { "oneOf": [{ "type": "string" }, { "type": "object", "properties": { "name": { "type": "string", "description": "Template name to be use by template renderer to determine the template to use" }, "type": { "type": "string", "description": "Type of renderer template", "enum": ["EMBEDDED_RENDERER"] }, "url": { "type": "string", "description": "URL of a decentralised renderer to render this document" } }, "required": ["name", "type"] }] }, "documentUrl": { "type": "string", "description": "URL of the stored document" }, "issuers": { "type": "array", "items": { "type": "object", "title": "issuer", "oneOf": [{ "$ref": "#/definitions/tokenRegistry" }, { "$ref": "#/definitions/documentStore" }, { "$ref": "#/definitions/certificateStore" }, { "allOf": [{ "$ref": "#/definitions/issuer" }, { "not": { "anyOf": [{ "required": ["certificateStore"] }, { "required": ["tokenRegistry"] }, { "required": ["documentStore"] }] } }] }] }, "minItems": 1 }, "recipient": { "type": "object", "properties": { "name": { "type": "string", "description": "Recipient's name" } }, "additionalProperties": true }, "network": { "type": "object", "properties": { "chain": { "type": "string", "description": "Which blockchain being used" }, "chainId": { "type": "string", "description": "Chain ID of the network used" } }, "required": ["chain"], "additionalProperties": true }, "attachments": { "type": "array", "items": { "type": "object", "properties": { "filename": { "type": "string", "description": "Name of attachment, with appropriate extensions" }, "type": { "type": "string", "description": "Type of attachment" }, "data": { "type": "string", "description": "Base64 encoding of attachment" } }, "required": ["filename", "type", "data"], "additionalProperties": false } } }, "required": ["issuers"], "additionalProperties": true };
var schema13 = { "type": "object", "properties": { "id": { "type": "string", "description": "Issuer's id, DID can be used" }, "name": { "type": "string", "description": "Issuer's name" }, "revocation": { "type": "object", "properties": { "type": { "type": "string", "enum": ["NONE", "REVOCATION_STORE", "OCSP_RESPONDER"] }, "location": { "type": "string", "description": "Smart contract address or url of certificate revocation list for Revocation Store type revocation" } } }, "identityProof": { "$ref": "#/definitions/identityProof" } }, "required": ["name", "identityProof"], "additionalProperties": true };
var schema15 = { "type": "object", "properties": { "type": { "type": "string", "enum": ["DNS-TXT"] }, "location": { "type": "string", "description": "Url of the website referencing to document store" } }, "required": ["type", "location"] };
var schema16 = { "type": "object", "properties": { "type": { "type": "string", "enum": ["DNS-DID"] }, "key": { "type": "string", "description": "Public key associated" }, "location": { "type": "string", "description": "Url of the website referencing to document store" } }, "required": ["type", "key", "location"] };
var schema17 = { "type": "object", "properties": { "type": { "type": "string", "enum": ["DID"] }, "key": { "type": "string", "description": "Public key associated" } }, "required": ["type", "key"] };
function validate13(data, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.instancePath, instancePath = _c === void 0 ? "" : _c; _b.parentData; _b.parentDataProperty; _b.rootData;
var vErrors = null;
var errors = 0;
if (!(data && typeof data == "object" && !Array.isArray(data))) {
var err0 = { instancePath: instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
if (vErrors === null) {
vErrors = [err0];
}
else {
vErrors.push(err0);
}
errors++;
}
var _errs1 = errors;
var valid0 = false;
var passing0 = null;
var _errs2 = errors;
if (data && typeof data == "object" && !Array.isArray(data)) {
if (data.type === undefined) {
var err1 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDns/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property '" + "type" + "'" };
if (vErrors === null) {
vErrors = [err1];
}
else {
vErrors.push(err1);
}
errors++;
}
if (data.location === undefined) {
var err2 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDns/required", keyword: "required", params: { missingProperty: "location" }, message: "must have required property '" + "location" + "'" };
if (vErrors === null) {
vErrors = [err2];
}
else {
vErrors.push(err2);
}
errors++;
}
if (data.type !== undefined) {
var data0 = data.type;
if (typeof data0 !== "string") {
var err3 = { instancePath: instancePath + "/type", schemaPath: "#/definitions/identityProofDns/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err3];
}
else {
vErrors.push(err3);
}
errors++;
}
if (!(data0 === "DNS-TXT")) {
var err4 = { instancePath: instancePath + "/type", schemaPath: "#/definitions/identityProofDns/properties/type/enum", keyword: "enum", params: { allowedValues: schema15.properties.type.enum }, message: "must be equal to one of the allowed values" };
if (vErrors === null) {
vErrors = [err4];
}
else {
vErrors.push(err4);
}
errors++;
}
}
if (data.location !== undefined) {
if (typeof data.location !== "string") {
var err5 = { instancePath: instancePath + "/location", schemaPath: "#/definitions/identityProofDns/properties/location/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err5];
}
else {
vErrors.push(err5);
}
errors++;
}
}
}
else {
var err6 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDns/type", keyword: "type", params: { type: "object" }, message: "must be object" };
if (vErrors === null) {
vErrors = [err6];
}
else {
vErrors.push(err6);
}
errors++;
}
var _valid0 = _errs2 === errors;
if (_valid0) {
valid0 = true;
passing0 = 0;
}
var _errs9 = errors;
if (data && typeof data == "object" && !Array.isArray(data)) {
if (data.type === undefined) {
var err7 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDnsDid/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property '" + "type" + "'" };
if (vErrors === null) {
vErrors = [err7];
}
else {
vErrors.push(err7);
}
errors++;
}
if (data.key === undefined) {
var err8 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDnsDid/required", keyword: "required", params: { missingProperty: "key" }, message: "must have required property '" + "key" + "'" };
if (vErrors === null) {
vErrors = [err8];
}
else {
vErrors.push(err8);
}
errors++;
}
if (data.location === undefined) {
var err9 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDnsDid/required", keyword: "required", params: { missingProperty: "location" }, message: "must have required property '" + "location" + "'" };
if (vErrors === null) {
vErrors = [err9];
}
else {
vErrors.push(err9);
}
errors++;
}
if (data.type !== undefined) {
var data2 = data.type;
if (typeof data2 !== "string") {
var err10 = { instancePath: instancePath + "/type", schemaPath: "#/definitions/identityProofDnsDid/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err10];
}
else {
vErrors.push(err10);
}
errors++;
}
if (!(data2 === "DNS-DID")) {
var err11 = { instancePath: instancePath + "/type", schemaPath: "#/definitions/identityProofDnsDid/properties/type/enum", keyword: "enum", params: { allowedValues: schema16.properties.type.enum }, message: "must be equal to one of the allowed values" };
if (vErrors === null) {
vErrors = [err11];
}
else {
vErrors.push(err11);
}
errors++;
}
}
if (data.key !== undefined) {
if (typeof data.key !== "string") {
var err12 = { instancePath: instancePath + "/key", schemaPath: "#/definitions/identityProofDnsDid/properties/key/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err12];
}
else {
vErrors.push(err12);
}
errors++;
}
}
if (data.location !== undefined) {
if (typeof data.location !== "string") {
var err13 = { instancePath: instancePath + "/location", schemaPath: "#/definitions/identityProofDnsDid/properties/location/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err13];
}
else {
vErrors.push(err13);
}
errors++;
}
}
}
else {
var err14 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDnsDid/type", keyword: "type", params: { type: "object" }, message: "must be object" };
if (vErrors === null) {
vErrors = [err14];
}
else {
vErrors.push(err14);
}
errors++;
}
var _valid0 = _errs9 === errors;
if (_valid0 && valid0) {
valid0 = false;
passing0 = [passing0, 1];
}
else {
if (_valid0) {
valid0 = true;
passing0 = 1;
}
var _errs18 = errors;
if (data && typeof data == "object" && !Array.isArray(data)) {
if (data.type === undefined) {
var err15 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDid/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property '" + "type" + "'" };
if (vErrors === null) {
vErrors = [err15];
}
else {
vErrors.push(err15);
}
errors++;
}
if (data.key === undefined) {
var err16 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDid/required", keyword: "required", params: { missingProperty: "key" }, message: "must have required property '" + "key" + "'" };
if (vErrors === null) {
vErrors = [err16];
}
else {
vErrors.push(err16);
}
errors++;
}
if (data.type !== undefined) {
var data5 = data.type;
if (typeof data5 !== "string") {
var err17 = { instancePath: instancePath + "/type", schemaPath: "#/definitions/identityProofDid/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err17];
}
else {
vErrors.push(err17);
}
errors++;
}
if (!(data5 === "DID")) {
var err18 = { instancePath: instancePath + "/type", schemaPath: "#/definitions/identityProofDid/properties/type/enum", keyword: "enum", params: { allowedValues: schema17.properties.type.enum }, message: "must be equal to one of the allowed values" };
if (vErrors === null) {
vErrors = [err18];
}
else {
vErrors.push(err18);
}
errors++;
}
}
if (data.key !== undefined) {
if (typeof data.key !== "string") {
var err19 = { instancePath: instancePath + "/key", schemaPath: "#/definitions/identityProofDid/properties/key/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err19];
}
else {
vErrors.push(err19);
}
errors++;
}
}
}
else {
var err20 = { instancePath: instancePath, schemaPath: "#/definitions/identityProofDid/type", keyword: "type", params: { type: "object" }, message: "must be object" };
if (vErrors === null) {
vErrors = [err20];
}
else {
vErrors.push(err20);
}
errors++;
}
var _valid0 = _errs18 === errors;
if (_valid0 && valid0) {
valid0 = false;
passing0 = [passing0, 2];
}
else {
if (_valid0) {
valid0 = true;
passing0 = 2;
}
}
}
if (!valid0) {
var err21 = { instancePath: instancePath, schemaPath: "#/oneOf", keyword: "oneOf", params: { passingSchemas: passing0 }, message: "must match exactly one schema in oneOf" };
if (vErrors === null) {
vErrors = [err21];
}
else {
vErrors.push(err21);
}
errors++;
}
else {
errors = _errs1;
if (vErrors !== null) {
if (_errs1) {
vErrors.length = _errs1;
}
else {
vErrors = null;
}
}
}
validate13.errors = vErrors;
return errors === 0;
}
function validate12(data, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.instancePath, instancePath = _c === void 0 ? "" : _c; _b.parentData; _b.parentDataProperty; var _d = _b.rootData, rootData = _d === void 0 ? data : _d;
var vErrors = null;
var errors = 0;
if (data && typeof data == "object" && !Array.isArray(data)) {
if (data.name === undefined) {
var err0 = { instancePath: instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "name" }, message: "must have required property '" + "name" + "'" };
if (vErrors === null) {
vErrors = [err0];
}
else {
vErrors.push(err0);
}
errors++;
}
if (data.identityProof === undefined) {
var err1 = { instancePath: instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "identityProof" }, message: "must have required property '" + "identityProof" + "'" };
if (vErrors === null) {
vErrors = [err1];
}
else {
vErrors.push(err1);
}
errors++;
}
if (data.id !== undefined) {
if (typeof data.id !== "string") {
var err2 = { instancePath: instancePath + "/id", schemaPath: "#/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err2];
}
else {
vErrors.push(err2);
}
errors++;
}
}
if (data.name !== undefined) {
if (typeof data.name !== "string") {
var err3 = { instancePath: instancePath + "/name", schemaPath: "#/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err3];
}
else {
vErrors.push(err3);
}
errors++;
}
}
if (data.revocation !== undefined) {
var data2 = data.revocation;
if (data2 && typeof data2 == "object" && !Array.isArray(data2)) {
if (data2.type !== undefined) {
var data3 = data2.type;
if (typeof data3 !== "string") {
var err4 = { instancePath: instancePath + "/revocation/type", schemaPath: "#/properties/revocation/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err4];
}
else {
vErrors.push(err4);
}
errors++;
}
if (!(((data3 === "NONE") || (data3 === "REVOCATION_STORE")) || (data3 === "OCSP_RESPONDER"))) {
var err5 = { instancePath: instancePath + "/revocation/type", schemaPath: "#/properties/revocation/properties/type/enum", keyword: "enum", params: { allowedValues: schema13.properties.revocation.properties.type.enum }, message: "must be equal to one of the allowed values" };
if (vErrors === null) {
vErrors = [err5];
}
else {
vErrors.push(err5);
}
errors++;
}
}
if (data2.location !== undefined) {
if (typeof data2.location !== "string") {
var err6 = { instancePath: instancePath + "/revocation/location", schemaPath: "#/properties/revocation/properties/location/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err6];
}
else {
vErrors.push(err6);
}
errors++;
}
}
}
else {
var err7 = { instancePath: instancePath + "/revocation", schemaPath: "#/properties/revocation/type", keyword: "type", params: { type: "object" }, message: "must be object" };
if (vErrors === null) {
vErrors = [err7];
}
else {
vErrors.push(err7);
}
errors++;
}
}
if (data.identityProof !== undefined) {
if (!(validate13(data.identityProof, { instancePath: instancePath + "/identityProof", parentData: data, parentDataProperty: "identityProof", rootData: rootData }))) {
vErrors = vErrors === null ? validate13.errors : vErrors.concat(validate13.errors);
errors = vErrors.length;
}
}
}
else {
var err8 = { instancePath: instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
if (vErrors === null) {
vErrors = [err8];
}
else {
vErrors.push(err8);
}
errors++;
}
validate12.errors = vErrors;
return errors === 0;
}
var pattern0 = new RegExp("^0x[a-fA-F0-9]{40}$", "u");
function validate11(data, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.instancePath, instancePath = _c === void 0 ? "" : _c, parentData = _b.parentData, parentDataProperty = _b.parentDataProperty, _d = _b.rootData, rootData = _d === void 0 ? data : _d;
var vErrors = null;
var errors = 0;
if (!(validate12(data, { instancePath: instancePath, parentData: parentData, parentDataProperty: parentDataProperty, rootData: rootData }))) {
vErrors = vErrors === null ? validate12.errors : vErrors.concat(validate12.errors);
errors = vErrors.length;
}
if (data && typeof data == "object" && !Array.isArray(data)) {
if (data.tokenRegistry === undefined) {
var err0 = { instancePath: instancePath, schemaPath: "#/allOf/1/required", keyword: "required", params: { missingProperty: "tokenRegistry" }, message: "must have required property '" + "tokenRegistry" + "'" };
if (vErrors === null) {
vErrors = [err0];
}
else {
vErrors.push(err0);
}
errors++;
}
if (data.tokenRegistry !== undefined) {
var data0 = data.tokenRegistry;
if (typeof data0 === "string") {
if (!pattern0.test(data0)) {
var err1 = { instancePath: instancePath + "/tokenRegistry", schemaPath: "#/allOf/1/properties/tokenRegistry/pattern", keyword: "pattern", params: { pattern: "^0x[a-fA-F0-9]{40}$" }, message: "must match pattern \"" + "^0x[a-fA-F0-9]{40}$" + "\"" };
if (vErrors === null) {
vErrors = [err1];
}
else {
vErrors.push(err1);
}
errors++;
}
}
else {
var err2 = { instancePath: instancePath + "/tokenRegistry", schemaPath: "#/allOf/1/properties/tokenRegistry/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err2];
}
else {
vErrors.push(err2);
}
errors++;
}
}
}
else {
var err3 = { instancePath: instancePath, schemaPath: "#/allOf/1/type", keyword: "type", params: { type: "object" }, message: "must be object" };
if (vErrors === null) {
vErrors = [err3];
}
else {
vErrors.push(err3);
}
errors++;
}
validate11.errors = vErrors;
return errors === 0;
}
function validate17(data, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.instancePath, instancePath = _c === void 0 ? "" : _c, parentData = _b.parentData, parentDataProperty = _b.parentDataProperty, _d = _b.rootData, rootData = _d === void 0 ? data : _d;
var vErrors = null;
var errors = 0;
if (!(validate12(data, { instancePath: instancePath, parentData: parentData, parentDataProperty: parentDataProperty, rootData: rootData }))) {
vErrors = vErrors === null ? validate12.errors : vErrors.concat(validate12.errors);
errors = vErrors.length;
}
if (data && typeof data == "object" && !Array.isArray(data)) {
if (data.documentStore === undefined) {
var err0 = { instancePath: instancePath, schemaPath: "#/allOf/1/required", keyword: "required", params: { missingProperty: "documentStore" }, message: "must have required property '" + "documentStore" + "'" };
if (vErrors === null) {
vErrors = [err0];
}
else {
vErrors.push(err0);
}
errors++;
}
if (data.documentStore !== undefined) {
var data0 = data.documentStore;
if (typeof data0 === "string") {
if (!pattern0.test(data0)) {
var err1 = { instancePath: instancePath + "/documentStore", schemaPath: "#/allOf/1/properties/documentStore/pattern", keyword: "pattern", params: { pattern: "^0x[a-fA-F0-9]{40}$" }, message: "must match pattern \"" + "^0x[a-fA-F0-9]{40}$" + "\"" };
if (vErrors === null) {
vErrors = [err1];
}
else {
vErrors.push(err1);
}
errors++;
}
}
else {
var err2 = { instancePath: instancePath + "/documentStore", schemaPath: "#/allOf/1/properties/documentStore/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err2];
}
else {
vErrors.push(err2);
}
errors++;
}
}
}
else {
var err3 = { instancePath: instancePath, schemaPath: "#/allOf/1/type", keyword: "type", params: { type: "object" }, message: "must be object" };
if (vErrors === null) {
vErrors = [err3];
}
else {
vErrors.push(err3);
}
errors++;
}
validate17.errors = vErrors;
return errors === 0;
}
function validate10(data, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.instancePath, instancePath = _c === void 0 ? "" : _c; _b.parentData; _b.parentDataProperty; var _d = _b.rootData, rootData = _d === void 0 ? data : _d;
var vErrors = null;
var errors = 0;
if (data && typeof data == "object" && !Array.isArray(data)) {
if (data.issuers === undefined) {
var err0 = { instancePath: instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "issuers" }, message: "must have required property '" + "issuers" + "'" };
if (vErrors === null) {
vErrors = [err0];
}
else {
vErrors.push(err0);
}
errors++;
}
if (data.id !== undefined) {
if (typeof data.id !== "string") {
var err1 = { instancePath: instancePath + "/id", schemaPath: "#/properties/id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err1];
}
else {
vErrors.push(err1);
}
errors++;
}
}
if (data.$template !== undefined) {
var data1 = data.$template;
var _errs5 = errors;
var valid1 = false;
var passing0 = null;
var _errs6 = errors;
if (typeof data1 !== "string") {
var err2 = { instancePath: instancePath + "/$template", schemaPath: "#/properties/%24template/oneOf/0/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err2];
}
else {
vErrors.push(err2);
}
errors++;
}
var _valid0 = _errs6 === errors;
if (_valid0) {
valid1 = true;
passing0 = 0;
}
var _errs8 = errors;
if (data1 && typeof data1 == "object" && !Array.isArray(data1)) {
if (data1.name === undefined) {
var err3 = { instancePath: instancePath + "/$template", schemaPath: "#/properties/%24template/oneOf/1/required", keyword: "required", params: { missingProperty: "name" }, message: "must have required property '" + "name" + "'" };
if (vErrors === null) {
vErrors = [err3];
}
else {
vErrors.push(err3);
}
errors++;
}
if (data1.type === undefined) {
var err4 = { instancePath: instancePath + "/$template", schemaPath: "#/properties/%24template/oneOf/1/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property '" + "type" + "'" };
if (vErrors === null) {
vErrors = [err4];
}
else {
vErrors.push(err4);
}
errors++;
}
if (data1.name !== undefined) {
if (typeof data1.name !== "string") {
var err5 = { instancePath: instancePath + "/$template/name", schemaPath: "#/properties/%24template/oneOf/1/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err5];
}
else {
vErrors.push(err5);
}
errors++;
}
}
if (data1.type !== undefined) {
var data3 = data1.type;
if (typeof data3 !== "string") {
var err6 = { instancePath: instancePath + "/$template/type", schemaPath: "#/properties/%24template/oneOf/1/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
if (vErrors === null) {
vErrors = [err6];
}
else {
vErrors.push(err6);
}
errors++;
}
if (!(data3 === "EMBEDDED_RENDERER")) {
var err7 = { instancePath: instancePath + "/$template/type", schemaPath: "#/properties/%24template/oneOf/1/properties/type/enum", keyword: "enum", params: { allowedValues: schema11.properties.$template.oneOf[1].properties.type.enum }, message: "must be equal to one of the allowed values" };
if (vErrors === null) {
vErrors = [err7];
}
else {
vErrors.push(err7);
}
errors++;
}
}
if (data1.url !== undefined) {
if (typeof data1.url !== "string") {
var err8 = { instancePath: instancePath + "/$template/url", schemaPath: "#/properties/%24template/oneOf/1/properties/url/type", keyword: "type", params: { type: "string" }, me