From d90e93a7519a457032e808d05da6245b1726ca81 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Sat, 24 Aug 2024 12:28:03 +0200 Subject: [PATCH 01/21] Migrate to typedoc --- bindings/wasm/package-lock.json | 307 + bindings/wasm/package.json | 5 +- bindings/wasm/typedoc.json | 13 + test.js | 14839 ++++++++++++++++++++++++++++++ 4 files changed, 15163 insertions(+), 1 deletion(-) create mode 100644 bindings/wasm/typedoc.json create mode 100644 test.js diff --git a/bindings/wasm/package-lock.json b/bindings/wasm/package-lock.json index 37e102a1ce..7371b4e79d 100644 --- a/bindings/wasm/package-lock.json +++ b/bindings/wasm/package-lock.json @@ -29,6 +29,8 @@ "ts-node": "^10.9.1", "tsconfig-paths": "^4.1.0", "txm": "^8.1.0", + "typedoc": "^0.26.6", + "typedoc-plugin-markdown": "^4.2.5", "typescript": "^4.7.2", "wasm-opt": "^1.3.0" }, @@ -315,6 +317,16 @@ "node": ">= 8" } }, + "node_modules/@shikijs/core": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.14.1.tgz", + "integrity": "sha512-KyHIIpKNaT20FtFPFjCQB5WVSTpLR/n+jQXhWHWVUMm9MaOaG9BGOG0MSyt7yA4+Lm+4c9rTc03tt3nYzeYSfw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/hast": "^3.0.4" + } + }, "node_modules/@stablelib/binary": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", @@ -536,6 +548,16 @@ "dev": true, "peer": true }, + "node_modules/@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/unist": "*" + } + }, "node_modules/@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -3739,6 +3761,13 @@ "node": ">=10" } }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true, + "license": "MIT" + }, "node_modules/make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -4865,6 +4894,16 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/qs": { "version": "6.10.4", "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.4.tgz", @@ -5276,6 +5315,17 @@ "node": ">=8" } }, + "node_modules/shiki": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.14.1.tgz", + "integrity": "sha512-FujAN40NEejeXdzPt+3sZ3F2dx1U24BY2XTY01+MG8mbxCiA2XukXdcbyMyLAHJ/1AUUnQd1tZlvIjefWWEJeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@shikijs/core": "1.14.1", + "@types/hast": "^3.0.4" + } + }, "node_modules/side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -5986,6 +6036,123 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typedoc": { + "version": "0.26.6", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.6.tgz", + "integrity": "sha512-SfEU3SH3wHNaxhFPjaZE2kNl/NFtLNW5c1oHsg7mti7GjmUj1Roq6osBQeMd+F4kL0BoRBBr8gQAuqBlfFu8LA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "lunr": "^2.3.9", + "markdown-it": "^14.1.0", + "minimatch": "^9.0.5", + "shiki": "^1.9.1", + "yaml": "^2.4.5" + }, + "bin": { + "typedoc": "bin/typedoc" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x" + } + }, + "node_modules/typedoc-plugin-markdown": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-4.2.5.tgz", + "integrity": "sha512-ZWIfc0OqwEtQfuaqbmM1kesMi/Fhc++W+5f3TDEm1Tsi28pHSoZk4WCOm4lNuN30WtEImwAHhhXC4DIWki1DiA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "typedoc": "0.26.x" + } + }, + "node_modules/typedoc/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/typedoc/node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/typedoc/node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "uc.micro": "^2.0.0" + } + }, + "node_modules/typedoc/node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/typedoc/node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true, + "license": "MIT" + }, + "node_modules/typedoc/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/typedoc/node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true, + "license": "MIT" + }, "node_modules/typescript": { "version": "4.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", @@ -6410,6 +6577,19 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, + "node_modules/yaml": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", + "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/yargs-parser": { "version": "20.2.4", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", @@ -6696,6 +6876,15 @@ "fastq": "^1.6.0" } }, + "@shikijs/core": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.14.1.tgz", + "integrity": "sha512-KyHIIpKNaT20FtFPFjCQB5WVSTpLR/n+jQXhWHWVUMm9MaOaG9BGOG0MSyt7yA4+Lm+4c9rTc03tt3nYzeYSfw==", + "dev": true, + "requires": { + "@types/hast": "^3.0.4" + } + }, "@stablelib/binary": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", @@ -6905,6 +7094,15 @@ "dev": true, "peer": true }, + "@types/hast": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", + "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", + "dev": true, + "requires": { + "@types/unist": "*" + } + }, "@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -9317,6 +9515,12 @@ "yallist": "^4.0.0" } }, + "lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true + }, "make-error": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", @@ -10051,6 +10255,12 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true + }, "qs": { "version": "6.10.4", "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.4.tgz", @@ -10349,6 +10559,16 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, + "shiki": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.14.1.tgz", + "integrity": "sha512-FujAN40NEejeXdzPt+3sZ3F2dx1U24BY2XTY01+MG8mbxCiA2XukXdcbyMyLAHJ/1AUUnQd1tZlvIjefWWEJeA==", + "dev": true, + "requires": { + "@shikijs/core": "1.14.1", + "@types/hast": "^3.0.4" + } + }, "side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -10874,6 +11094,87 @@ "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", "dev": true }, + "typedoc": { + "version": "0.26.6", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.6.tgz", + "integrity": "sha512-SfEU3SH3wHNaxhFPjaZE2kNl/NFtLNW5c1oHsg7mti7GjmUj1Roq6osBQeMd+F4kL0BoRBBr8gQAuqBlfFu8LA==", + "dev": true, + "requires": { + "lunr": "^2.3.9", + "markdown-it": "^14.1.0", + "minimatch": "^9.0.5", + "shiki": "^1.9.1", + "yaml": "^2.4.5" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true + }, + "linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "requires": { + "uc.micro": "^2.0.0" + } + }, + "markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, + "requires": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + } + }, + "mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true + } + } + }, + "typedoc-plugin-markdown": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-4.2.5.tgz", + "integrity": "sha512-ZWIfc0OqwEtQfuaqbmM1kesMi/Fhc++W+5f3TDEm1Tsi28pHSoZk4WCOm4lNuN30WtEImwAHhhXC4DIWki1DiA==", + "dev": true, + "requires": {} + }, "typescript": { "version": "4.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", @@ -11188,6 +11489,12 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, + "yaml": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", + "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", + "dev": true + }, "yargs-parser": { "version": "20.2.4", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 8740706220..17125fb127 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -32,7 +32,8 @@ "test:unit:node": "ts-mocha -p tsconfig.node.json ./tests/*.ts --parallel --exit", "cypress": "cypress open", "fmt": "dprint fmt", - "fix_js_doc": "sed -Ei 's/\\((.*)\\)\\[\\]/\\1\\[\\]/' ./node/identity_wasm.js" + "fix_js_doc": "sed -Ei 's/\\((.*)\\)\\[\\]/\\1\\[\\]/' ./node/identity_wasm.js", + "create-api-docs": "typedoc ./node/identity_wasm.d.ts" }, "config": { "CYPRESS_VERIFY_TIMEOUT": 100000 @@ -71,6 +72,8 @@ "ts-node": "^10.9.1", "tsconfig-paths": "^4.1.0", "txm": "^8.1.0", + "typedoc": "^0.26.6", + "typedoc-plugin-markdown": "^4.2.5", "typescript": "^4.7.2", "wasm-opt": "^1.3.0" }, diff --git a/bindings/wasm/typedoc.json b/bindings/wasm/typedoc.json new file mode 100644 index 0000000000..eab9511796 --- /dev/null +++ b/bindings/wasm/typedoc.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://typedoc.org/schema.json", + "disableSources": true, + "excludePrivate": true, + "excludeInternal": true, + "excludeNotDocumented": true, + "excludeExternals": true, + "out": "./docs/api", + "externalPattern": ["lib/*.ts"], + "compilerOptions": { + "skipLibCheck": true, + } +} diff --git a/test.js b/test.js new file mode 100644 index 0000000000..a1a54c68d5 --- /dev/null +++ b/test.js @@ -0,0 +1,14839 @@ + +if (!globalThis.fetch) { + const fetch = require('node-fetch') + globalThis.Headers = fetch.Headers + globalThis.Request = fetch.Request + globalThis.Response = fetch.Response + globalThis.fetch = fetch +} +let imports = {}; +imports['__wbindgen_placeholder__'] = module.exports; +let wasm; +const { TextDecoder, TextEncoder, inspect } = require(`util`); + +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { return heap[idx]; } + +let heap_next = heap.length; + +function dropObject(idx) { + if (idx < 132) return; + heap[idx] = heap_next; + heap_next = idx; +} + +function takeObject(idx) { + const ret = getObject(idx); + dropObject(idx); + return ret; +} + +let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +let cachedUint8ArrayMemory0 = null; + +function getUint8ArrayMemory0() { + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8ArrayMemory0; +} + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); +} + +function addHeapObject(obj) { + if (heap_next === heap.length) heap.push(heap.length + 1); + const idx = heap_next; + heap_next = heap[idx]; + + heap[idx] = obj; + return idx; +} + +let WASM_VECTOR_LEN = 0; + +let cachedTextEncoder = new TextEncoder('utf-8'); + +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' + ? function (arg, view) { + return cachedTextEncoder.encodeInto(arg, view); + } + : function (arg, view) { + const buf = cachedTextEncoder.encode(arg); + view.set(buf); + return { + read: arg.length, + written: buf.length + }; + }); + +function passStringToWasm0(arg, malloc, realloc) { + + if (realloc === undefined) { + const buf = cachedTextEncoder.encode(arg); + const ptr = malloc(buf.length, 1) >>> 0; + getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); + WASM_VECTOR_LEN = buf.length; + return ptr; + } + + let len = arg.length; + let ptr = malloc(len, 1) >>> 0; + + const mem = getUint8ArrayMemory0(); + + let offset = 0; + + for (; offset < len; offset++) { + const code = arg.charCodeAt(offset); + if (code > 0x7F) break; + mem[ptr + offset] = code; + } + + if (offset !== len) { + if (offset !== 0) { + arg = arg.slice(offset); + } + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; + const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); + const ret = encodeString(arg, view); + + offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; + } + + WASM_VECTOR_LEN = offset; + return ptr; +} + +let cachedDataViewMemory0 = null; + +function getDataViewMemory0() { + if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { + cachedDataViewMemory0 = new DataView(wasm.memory.buffer); + } + return cachedDataViewMemory0; +} + +function isLikeNone(x) { + return x === undefined || x === null; +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for (let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + +const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(state => { + wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) + }); + +function makeMutClosure(arg0, arg1, dtor, f) { + const state = { a: arg0, b: arg1, cnt: 1, dtor }; + const real = (...args) => { + // First up with a closure we increment the internal reference + // count. This ensures that the Rust closure environment won't + // be deallocated while we're invoking it. + state.cnt++; + const a = state.a; + state.a = 0; + try { + return f(a, state.b, ...args); + } finally { + if (--state.cnt === 0) { + wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); + CLOSURE_DTORS.unregister(state); + } else { + state.a = a; + } + } + }; + real.original = state; + CLOSURE_DTORS.register(real, state, state); + return real; +} +function __wbg_adapter_32(arg0, arg1, arg2) { + wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hecbb567bf7d4b77d(arg0, arg1, addHeapObject(arg2)); +} + +/** +* Initializes the console error panic hook for better error messages +*/ +module.exports.start = function () { + wasm.start(); +}; + +let stack_pointer = 128; + +function addBorrowedObject(obj) { + if (stack_pointer == 1) throw new Error('out of js stack'); + heap[--stack_pointer] = obj; + return stack_pointer; +} + +function passArrayJsValueToWasm0(array, malloc) { + const ptr = malloc(array.length * 4, 4) >>> 0; + const mem = getDataViewMemory0(); + for (let i = 0; i < array.length; i++) { + mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true); + } + WASM_VECTOR_LEN = array.length; + return ptr; +} + +function getArrayJsValueFromWasm0(ptr, len) { + ptr = ptr >>> 0; + const mem = getDataViewMemory0(); + const result = []; + for (let i = ptr; i < ptr + 4 * len; i += 4) { + result.push(takeObject(mem.getUint32(i, true))); + } + return result; +} + +let cachedUint32ArrayMemory0 = null; + +function getUint32ArrayMemory0() { + if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) { + cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer); + } + return cachedUint32ArrayMemory0; +} + +function getArrayU32FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len); +} + +function _assertClass(instance, klass) { + if (!(instance instanceof klass)) { + throw new Error(`expected instance of ${klass.name}`); + } + return instance.ptr; +} + +function passArray8ToWasm0(arg, malloc) { + const ptr = malloc(arg.length * 1, 1) >>> 0; + getUint8ArrayMemory0().set(arg, ptr / 1); + WASM_VECTOR_LEN = arg.length; + return ptr; +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); +} +/** +* Verify a JWS signature secured with the `EdDSA` algorithm and curve `Ed25519`. +* +* This function is useful when one is composing a `IJwsVerifier` that delegates +* `EdDSA` verification with curve `Ed25519` to this function. +* +* # Warning +* +* This function does not check whether `alg = EdDSA` in the protected header. Callers are expected to assert this +* prior to calling the function. +* @param {JwsAlgorithm} alg +* @param {Uint8Array} signingInput +* @param {Uint8Array} decodedSignature +* @param {Jwk} publicKey +*/ +module.exports.verifyEd25519 = function (alg, signingInput, decodedSignature, publicKey) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(signingInput, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(decodedSignature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(publicKey, Jwk); + wasm.verifyEd25519(retptr, addHeapObject(alg), ptr0, len0, ptr1, len1, publicKey.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +}; + +/** +* Encode the given bytes in url-safe base64. +* @param {Uint8Array} data +* @returns {string} +*/ +module.exports.encodeB64 = function (data) { + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.encodeB64(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred2_0 = r0; + deferred2_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } +}; + +/** +* Decode the given url-safe base64-encoded slice into its raw bytes. +* @param {Uint8Array} data +* @returns {Uint8Array} +*/ +module.exports.decodeB64 = function (data) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.decodeB64(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + if (r3) { + throw takeObject(r2); + } + var v2 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v2; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } +}; + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + wasm.__wbindgen_exn_store(addHeapObject(e)); + } +} +function __wbg_adapter_813(arg0, arg1, arg2, arg3) { + wasm.wasm_bindgen__convert__closures__invoke2_mut__h58660668f6114e02(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); +} + +/** +*/ +module.exports.SerializationType = Object.freeze({ COMPACT: 0, "0": "COMPACT", JSON: 1, "1": "JSON", }); +/** +* Purpose of a {@link StatusList2021}. +*/ +module.exports.StatusPurpose = Object.freeze({ Revocation: 0, "0": "Revocation", Suspension: 1, "1": "Suspension", }); +/** +* Declares how credential subjects must relate to the presentation holder. +* +* See also the [Subject-Holder Relationship](https://www.w3.org/TR/vc-data-model/#subject-holder-relationships) section of the specification. +*/ +module.exports.SubjectHolderRelationship = Object.freeze({ + /** + * The holder must always match the subject on all credentials, regardless of their [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property. + * This variant is the default. + */ + AlwaysSubject: 0, "0": "AlwaysSubject", + /** + * The holder must match the subject only for credentials where the [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property is `true`. + */ + SubjectOnNonTransferable: 1, "1": "SubjectOnNonTransferable", + /** + * The holder is not required to have any kind of relationship to any credential subject. + */ + Any: 2, "2": "Any", +}); +/** +* Controls validation behaviour when checking whether or not a credential has been revoked by its +* [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status). +*/ +module.exports.StatusCheck = Object.freeze({ + /** + * Validate the status if supported, reject any unsupported + * [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types. + * + * Only `RevocationBitmap2022` is currently supported. + * + * This is the default. + */ + Strict: 0, "0": "Strict", + /** + * Validate the status if supported, skip any unsupported + * [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types. + */ + SkipUnsupported: 1, "1": "SkipUnsupported", + /** + * Skip all status checks. + */ + SkipAll: 2, "2": "SkipAll", +}); +/** +*/ +module.exports.ProofAlgorithm = Object.freeze({ BLS12381_SHA256: 0, "0": "BLS12381_SHA256", BLS12381_SHAKE256: 1, "1": "BLS12381_SHAKE256", SU_ES256: 2, "2": "SU_ES256", MAC_H256: 3, "3": "MAC_H256", MAC_H384: 4, "4": "MAC_H384", MAC_H512: 5, "5": "MAC_H512", MAC_K25519: 6, "6": "MAC_K25519", MAC_K448: 7, "7": "MAC_K448", MAC_H256K: 8, "8": "MAC_H256K", }); +/** +* Declares when validation should return if an error occurs. +*/ +module.exports.FailFast = Object.freeze({ + /** + * Return all errors that occur during validation. + */ + AllErrors: 0, "0": "AllErrors", + /** + * Return after the first error occurs. + */ + FirstError: 1, "1": "FirstError", +}); +/** +*/ +module.exports.StateMetadataEncoding = Object.freeze({ Json: 0, "0": "Json", }); +/** +*/ +module.exports.MethodRelationship = Object.freeze({ Authentication: 0, "0": "Authentication", AssertionMethod: 1, "1": "AssertionMethod", KeyAgreement: 2, "2": "KeyAgreement", CapabilityDelegation: 3, "3": "CapabilityDelegation", CapabilityInvocation: 4, "4": "CapabilityInvocation", }); +/** +*/ +module.exports.CredentialStatus = Object.freeze({ Revoked: 0, "0": "Revoked", Suspended: 1, "1": "Suspended", Valid: 2, "2": "Valid", }); +/** +*/ +module.exports.PayloadType = Object.freeze({ Disclosed: 0, "0": "Disclosed", Undisclosed: 1, "1": "Undisclosed", ProofMethods: 2, "2": "ProofMethods", }); +/** +*/ +module.exports.PresentationProofAlgorithm = Object.freeze({ BLS12381_SHA256_PROOF: 0, "0": "BLS12381_SHA256_PROOF", BLS12381_SHAKE256_PROOF: 1, "1": "BLS12381_SHAKE256_PROOF", SU_ES256: 2, "2": "SU_ES256", MAC_H256: 3, "3": "MAC_H256", MAC_H384: 4, "4": "MAC_H384", MAC_H512: 5, "5": "MAC_H512", MAC_K25519: 6, "6": "MAC_K25519", MAC_K448: 7, "7": "MAC_K448", MAC_H256K: 8, "8": "MAC_H256K", }); + +const CoreDIDFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_coredid_free(ptr >>> 0, 1)); +/** +* A method-agnostic Decentralized Identifier (DID). +*/ +class CoreDID { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CoreDID.prototype); + obj.__wbg_ptr = ptr; + CoreDIDFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + CoreDIDFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_coredid_free(ptr, 0); + } + /** + * Parses a {@link CoreDID} from the given `input`. + * + * ### Errors + * + * Throws an error if the input is not a valid {@link CoreDID}. + * @param {string} input + * @returns {CoreDID} + */ + static parse(input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.coredid_parse(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Set the method name of the {@link CoreDID}. + * @param {string} value + */ + setMethodName(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.coredid_setMethodName(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Validates whether a string is a valid DID method name. + * @param {string} value + * @returns {boolean} + */ + static validMethodName(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.coredid_validMethodName(ptr0, len0); + return ret !== 0; + } + /** + * Set the method-specific-id of the `DID`. + * @param {string} value + */ + setMethodId(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.coredid_setMethodId(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Validates whether a string is a valid `DID` method-id. + * @param {string} value + * @returns {boolean} + */ + static validMethodId(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.coredid_validMethodId(ptr0, len0); + return ret !== 0; + } + /** + * Returns the {@link CoreDID} scheme. + * + * E.g. + * - `"did:example:12345678" -> "did"` + * - `"did:iota:smr:12345678" -> "did"` + * @returns {string} + */ + scheme() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredid_scheme(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns the {@link CoreDID} authority: the method name and method-id. + * + * E.g. + * - `"did:example:12345678" -> "example:12345678"` + * - `"did:iota:smr:12345678" -> "iota:smr:12345678"` + * @returns {string} + */ + authority() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredid_authority(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns the {@link CoreDID} method name. + * + * E.g. + * - `"did:example:12345678" -> "example"` + * - `"did:iota:smr:12345678" -> "iota"` + * @returns {string} + */ + method() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredid_method(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns the {@link CoreDID} method-specific ID. + * + * E.g. + * - `"did:example:12345678" -> "12345678"` + * - `"did:iota:smr:12345678" -> "smr:12345678"` + * @returns {string} + */ + methodId() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredid_methodId(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Construct a new {@link DIDUrl} by joining with a relative DID Url string. + * @param {string} segment + * @returns {DIDUrl} + */ + join(segment) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(segment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.coredid_join(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DIDUrl.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Clones the {@link CoreDID} into a {@link DIDUrl}. + * @returns {DIDUrl} + */ + toUrl() { + const ret = wasm.coredid_toUrl(this.__wbg_ptr); + return DIDUrl.__wrap(ret); + } + /** + * Converts the {@link CoreDID} into a {@link DIDUrl}, consuming it. + * @returns {DIDUrl} + */ + intoUrl() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.coredid_intoUrl(ptr); + return DIDUrl.__wrap(ret); + } + /** + * Returns the {@link CoreDID} as a string. + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredid_toString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * @returns {CoreDID} + */ + toCoreDid() { + const ret = wasm.coredid_clone(this.__wbg_ptr); + return CoreDID.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredid_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {CoreDID} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredid_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {CoreDID} + */ + clone() { + const ret = wasm.coredid_clone(this.__wbg_ptr); + return CoreDID.__wrap(ret); + } +} +module.exports.CoreDID = CoreDID; + +const CoreDocumentFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_coredocument_free(ptr >>> 0, 1)); +/** +* A method-agnostic DID Document. +* +* Note: All methods that involve reading from this class may potentially raise an error +* if the object is being concurrently modified. +*/ +class CoreDocument { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CoreDocument.prototype); + obj.__wbg_ptr = ptr; + CoreDocumentFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + CoreDocumentFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_coredocument_free(ptr, 0); + } + /** + * Creates a new {@link CoreDocument} with the given properties. + * @param {ICoreDocument} values + */ + constructor(values) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_new(retptr, addHeapObject(values)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + CoreDocumentFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the DID Document `id`. + * @returns {CoreDID} + */ + id() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_id(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the DID of the document. + * + * ### Warning + * + * Changing the identifier can drastically alter the results of + * `resolve_method`, `resolve_service` and the related + * [DID URL dereferencing](https://w3c-ccg.github.io/did-resolution/#dereferencing) algorithm. + * @param {CoreDID} id + */ + setId(id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(id, CoreDID); + wasm.coredocument_setId(retptr, this.__wbg_ptr, id.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the document controllers. + * @returns {Array} + */ + controller() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_controller(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the controllers of the DID Document. + * + * Note: Duplicates will be ignored. + * Use `null` to remove all controllers. + * @param {CoreDID | CoreDID[] | null} controllers + */ + setController(controllers) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_setController(retptr, this.__wbg_ptr, addBorrowedObject(controllers)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Returns a copy of the document's `alsoKnownAs` set. + * @returns {Array} + */ + alsoKnownAs() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_alsoKnownAs(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the `alsoKnownAs` property in the DID document. + * @param {string | string[] | null} urls + */ + setAlsoKnownAs(urls) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_setAlsoKnownAs(retptr, this.__wbg_ptr, addBorrowedObject(urls)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Returns a copy of the document's `verificationMethod` set. + * @returns {VerificationMethod[]} + */ + verificationMethod() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_verificationMethod(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the document's `authentication` set. + * @returns {Array} + */ + authentication() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_authentication(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the document's `assertionMethod` set. + * @returns {Array} + */ + assertionMethod() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_assertionMethod(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the document's `keyAgreement` set. + * @returns {Array} + */ + keyAgreement() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_keyAgreement(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the document's `capabilityDelegation` set. + * @returns {Array} + */ + capabilityDelegation() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_capabilityDelegation(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the document's `capabilityInvocation` set. + * @returns {Array} + */ + capabilityInvocation() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_capabilityInvocation(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the custom DID Document properties. + * @returns {Map} + */ + properties() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_properties(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a custom property in the DID Document. + * If the value is set to `null`, the custom property will be removed. + * + * ### WARNING + * + * This method can overwrite existing properties like `id` and result in an invalid document. + * @param {string} key + * @param {any} value + */ + setPropertyUnchecked(key, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.coredocument_setPropertyUnchecked(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Returns a set of all {@link Service} in the document. + * @returns {Service[]} + */ + service() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_service(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Add a new {@link Service} to the document. + * + * Errors if there already exists a service or verification method with the same id. + * @param {Service} service + */ + insertService(service) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(service, Service); + wasm.coredocument_insertService(retptr, this.__wbg_ptr, service.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Remove a {@link Service} identified by the given {@link DIDUrl} from the document. + * + * Returns `true` if the service was removed. + * @param {DIDUrl} didUrl + * @returns {Service | undefined} + */ + removeService(didUrl) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(didUrl, DIDUrl); + wasm.coredocument_removeService(retptr, this.__wbg_ptr, didUrl.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : Service.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the first {@link Service} with an `id` property matching the provided `query`, + * if present. + * @param {DIDUrl | string} query + * @returns {Service | undefined} + */ + resolveService(query) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_resolveService(retptr, this.__wbg_ptr, addBorrowedObject(query)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : Service.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Returns a list of all {@link VerificationMethod} in the DID Document, + * whose verification relationship matches `scope`. + * + * If `scope` is not set, a list over the **embedded** methods is returned. + * @param {MethodScope | undefined} [scope] + * @returns {VerificationMethod[]} + */ + methods(scope) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_methods(retptr, this.__wbg_ptr, isLikeNone(scope) ? 0 : addHeapObject(scope)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns an array of all verification relationships. + * @returns {Array} + */ + verificationRelationships() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_verificationRelationships(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Adds a new `method` to the document in the given `scope`. + * @param {VerificationMethod} method + * @param {MethodScope} scope + */ + insertMethod(method, scope) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(method, VerificationMethod); + _assertClass(scope, MethodScope); + wasm.coredocument_insertMethod(retptr, this.__wbg_ptr, method.__wbg_ptr, scope.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Removes all references to the specified Verification Method. + * @param {DIDUrl} did + * @returns {VerificationMethod | undefined} + */ + removeMethod(did) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(did, DIDUrl); + wasm.coredocument_removeMethod(retptr, this.__wbg_ptr, did.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : VerificationMethod.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the first verification method with an `id` property + * matching the provided `query` and the verification relationship + * specified by `scope`, if present. + * @param {DIDUrl | string} query + * @param {MethodScope | undefined} [scope] + * @returns {VerificationMethod | undefined} + */ + resolveMethod(query, scope) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_resolveMethod(retptr, this.__wbg_ptr, addBorrowedObject(query), isLikeNone(scope) ? 0 : addHeapObject(scope)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : VerificationMethod.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Attaches the relationship to the given method, if the method exists. + * + * Note: The method needs to be in the set of verification methods, + * so it cannot be an embedded one. + * @param {DIDUrl} didUrl + * @param {MethodRelationship} relationship + * @returns {boolean} + */ + attachMethodRelationship(didUrl, relationship) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(didUrl, DIDUrl); + wasm.coredocument_attachMethodRelationship(retptr, this.__wbg_ptr, didUrl.__wbg_ptr, relationship); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Detaches the given relationship from the given method, if the method exists. + * @param {DIDUrl} didUrl + * @param {MethodRelationship} relationship + * @returns {boolean} + */ + detachMethodRelationship(didUrl, relationship) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(didUrl, DIDUrl); + wasm.coredocument_detachMethodRelationship(retptr, this.__wbg_ptr, didUrl.__wbg_ptr, relationship); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Decodes and verifies the provided JWS according to the passed `options` and `signatureVerifier`. + * If no `signatureVerifier` argument is provided a default verifier will be used that is (only) capable of + * verifying EdDSA signatures. + * + * Regardless of which options are passed the following conditions must be met in order for a verification attempt to + * take place. + * - The JWS must be encoded according to the JWS compact serialization. + * - The `kid` value in the protected header must be an identifier of a verification method in this DID document, + * or set explicitly in the `options`. + * @param {Jws} jws + * @param {JwsVerificationOptions} options + * @param {IJwsVerifier} signatureVerifier + * @param {string | undefined} [detachedPayload] + * @returns {DecodedJws} + */ + verifyJws(jws, options, signatureVerifier, detachedPayload) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(jws, Jws); + _assertClass(options, JwsVerificationOptions); + var ptr0 = isLikeNone(detachedPayload) ? 0 : passStringToWasm0(detachedPayload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.coredocument_verifyJws(retptr, this.__wbg_ptr, jws.__wbg_ptr, options.__wbg_ptr, addHeapObject(signatureVerifier), ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DecodedJws.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, + * revoke all specified `indices`. + * @param {DIDUrl | string} serviceQuery + * @param {number | number[]} indices + */ + revokeCredentials(serviceQuery, indices) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_revokeCredentials(retptr, this.__wbg_ptr, addBorrowedObject(serviceQuery), addHeapObject(indices)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, + * unrevoke all specified `indices`. + * @param {DIDUrl | string} serviceQuery + * @param {number | number[]} indices + */ + unrevokeCredentials(serviceQuery, indices) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_unrevokeCredentials(retptr, this.__wbg_ptr, addBorrowedObject(serviceQuery), addHeapObject(indices)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the {@link CoreDocument}. + * @returns {CoreDocument} + */ + clone() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_clone(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDocument.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * ### Warning + * This is for internal use only. Do not rely on or call this method. + * @returns {CoreDocument} + */ + _shallowCloneInternal() { + const ret = wasm.coredocument__shallowCloneInternal(this.__wbg_ptr); + return CoreDocument.__wrap(ret); + } + /** + * ### Warning + * This is for internal use only. Do not rely on or call this method. + * @returns {number} + */ + _strongCountInternal() { + const ret = wasm.coredocument__strongCountInternal(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Serializes to a plain JS representation. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a plain JS representation. + * @param {any} json + * @returns {CoreDocument} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.coredocument_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDocument.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Generate new key material in the given `storage` and insert a new verification method with the corresponding + * public key material into the DID document. + * + * - If no fragment is given the `kid` of the generated JWK is used, if it is set, otherwise an error is returned. + * - The `keyType` must be compatible with the given `storage`. `Storage`s are expected to export key type constants + * for that use case. + * + * The fragment of the generated method is returned. + * @param {Storage} storage + * @param {string} keyType + * @param {JwsAlgorithm} alg + * @param {string | undefined} fragment + * @param {MethodScope} scope + * @returns {Promise} + */ + generateMethod(storage, keyType, alg, fragment, scope) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(keyType, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + var ptr1 = isLikeNone(fragment) ? 0 : passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + _assertClass(scope, MethodScope); + var ptr2 = scope.__destroy_into_raw(); + wasm.coredocument_generateMethod(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, addHeapObject(alg), ptr1, len1, ptr2); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Remove the method identified by the `fragment` from the document and delete the corresponding key material in + * the `storage`. + * @param {Storage} storage + * @param {DIDUrl} id + * @returns {Promise} + */ + purgeMethod(storage, id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + _assertClass(id, DIDUrl); + wasm.coredocument_purgeMethod(retptr, this.__wbg_ptr, storage.__wbg_ptr, id.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sign the `payload` according to `options` with the storage backed private key corresponding to the public key + * material in the verification method identified by the given `fragment. + * + * Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. + * See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). + * @param {Storage} storage + * @param {string} fragment + * @param {string} payload + * @param {JwsSignatureOptions} options + * @returns {Promise} + */ + createJws(storage, fragment, payload, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(options, JwsSignatureOptions); + wasm.coredocument_createJws(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, ptr1, len1, options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Produces a JWT where the payload is produced from the given `credential` + * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). + * + * Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` + * of the method identified by `fragment` and the JWS signature will be produced by the corresponding + * private key backed by the `storage` in accordance with the passed `options`. + * + * The `custom_claims` can be used to set additional claims on the resulting JWT. + * @param {Storage} storage + * @param {string} fragment + * @param {Credential} credential + * @param {JwsSignatureOptions} options + * @param {Record | undefined} [custom_claims] + * @returns {Promise} + */ + createCredentialJwt(storage, fragment, credential, options, custom_claims) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(credential, Credential); + _assertClass(options, JwsSignatureOptions); + wasm.coredocument_createCredentialJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, credential.__wbg_ptr, options.__wbg_ptr, isLikeNone(custom_claims) ? 0 : addHeapObject(custom_claims)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Produces a JWT where the payload is produced from the given presentation. + * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). + * + * Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` + * of the method identified by `fragment` and the JWS signature will be produced by the corresponding + * private key backed by the `storage` in accordance with the passed `options`. + * @param {Storage} storage + * @param {string} fragment + * @param {Presentation} presentation + * @param {JwsSignatureOptions} signature_options + * @param {JwtPresentationOptions} presentation_options + * @returns {Promise} + */ + createPresentationJwt(storage, fragment, presentation, signature_options, presentation_options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(presentation, Presentation); + _assertClass(signature_options, JwsSignatureOptions); + _assertClass(presentation_options, JwtPresentationOptions); + wasm.coredocument_createPresentationJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, presentation.__wbg_ptr, signature_options.__wbg_ptr, presentation_options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.CoreDocument = CoreDocument; + +const CredentialFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_credential_free(ptr >>> 0, 1)); +/** +*/ +class Credential { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Credential.prototype); + obj.__wbg_ptr = ptr; + CredentialFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + CredentialFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_credential_free(ptr, 0); + } + /** + * Returns the base JSON-LD context. + * @returns {string} + */ + static BaseContext() { + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_BaseContext(retptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + var ptr1 = r0; + var len1 = r1; + if (r3) { + ptr1 = 0; len1 = 0; + throw takeObject(r2); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } + } + /** + * Returns the base type. + * @returns {string} + */ + static BaseType() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_BaseType(retptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Constructs a new {@link Credential}. + * @param {ICredential} values + */ + constructor(values) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_new(retptr, addHeapObject(values)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + CredentialFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {IDomainLinkageCredential} values + * @returns {Credential} + */ + static createDomainLinkageCredential(values) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_createDomainLinkageCredential(retptr, addHeapObject(values)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Credential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the JSON-LD context(s) applicable to the {@link Credential}. + * @returns {Array>} + */ + context() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_context(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the unique `URI` identifying the {@link Credential} . + * @returns {string | undefined} + */ + id() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_id(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the URIs defining the type of the {@link Credential}. + * @returns {Array} + */ + type() { + const ret = wasm.credential_type(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns a copy of the {@link Credential} subject(s). + * @returns {Array} + */ + credentialSubject() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_credentialSubject(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the issuer of the {@link Credential}. + * @returns {string | Issuer} + */ + issuer() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_issuer(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the timestamp of when the {@link Credential} becomes valid. + * @returns {Timestamp} + */ + issuanceDate() { + const ret = wasm.credential_issuanceDate(this.__wbg_ptr); + return Timestamp.__wrap(ret); + } + /** + * Returns a copy of the timestamp of when the {@link Credential} should no longer be considered valid. + * @returns {Timestamp | undefined} + */ + expirationDate() { + const ret = wasm.credential_expirationDate(this.__wbg_ptr); + return ret === 0 ? undefined : Timestamp.__wrap(ret); + } + /** + * Returns a copy of the information used to determine the current status of the {@link Credential}. + * @returns {Array} + */ + credentialStatus() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_credentialStatus(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the information used to assist in the enforcement of a specific {@link Credential} structure. + * @returns {Array} + */ + credentialSchema() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_credentialSchema(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the service(s) used to refresh an expired {@link Credential}. + * @returns {Array} + */ + refreshService() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_refreshService(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the terms-of-use specified by the {@link Credential} issuer. + * @returns {Array} + */ + termsOfUse() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_termsOfUse(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the human-readable evidence used to support the claims within the {@link Credential}. + * @returns {Array} + */ + evidence() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_evidence(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns whether or not the {@link Credential} must only be contained within a {@link Presentation} + * with a proof issued from the {@link Credential} subject. + * @returns {boolean | undefined} + */ + nonTransferable() { + const ret = wasm.credential_nonTransferable(this.__wbg_ptr); + return ret === 0xFFFFFF ? undefined : ret !== 0; + } + /** + * Optional cryptographic proof, unrelated to JWT. + * @returns {Proof | undefined} + */ + proof() { + const ret = wasm.credential_proof(this.__wbg_ptr); + return ret === 0 ? undefined : Proof.__wrap(ret); + } + /** + * Returns a copy of the miscellaneous properties on the {@link Credential}. + * @returns {Map} + */ + properties() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_properties(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the `proof` property of the {@link Credential}. + * + * Note that this proof is not related to JWT. + * @param {Proof | undefined} [proof] + */ + setProof(proof) { + let ptr0 = 0; + if (!isLikeNone(proof)) { + _assertClass(proof, Proof); + ptr0 = proof.__destroy_into_raw(); + } + wasm.credential_setProof(this.__wbg_ptr, ptr0); + } + /** + * Serializes the `Credential` as a JWT claims set + * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). + * + * The resulting object can be used as the payload of a JWS when issuing the credential. + * @param {Record | undefined} [custom_claims] + * @returns {Record} + */ + toJwtClaims(custom_claims) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_toJwtClaims(retptr, this.__wbg_ptr, isLikeNone(custom_claims) ? 0 : addHeapObject(custom_claims)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Credential} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.credential_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Credential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {Credential} + */ + clone() { + const ret = wasm.credential_clone(this.__wbg_ptr); + return Credential.__wrap(ret); + } +} +module.exports.Credential = Credential; + +const CustomMethodDataFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_custommethoddata_free(ptr >>> 0, 1)); +/** +* A custom verification method data format. +*/ +class CustomMethodData { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(CustomMethodData.prototype); + obj.__wbg_ptr = ptr; + CustomMethodDataFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + CustomMethodDataFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_custommethoddata_free(ptr, 0); + } + /** + * @param {string} name + * @param {any} data + */ + constructor(name, data) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.custommethoddata_new(retptr, ptr0, len0, addHeapObject(data)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + CustomMethodDataFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deep clones the object. + * @returns {CustomMethodData} + */ + clone() { + const ret = wasm.custommethoddata_clone(this.__wbg_ptr); + return CustomMethodData.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.custommethoddata_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {CustomMethodData} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.custommethoddata_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CustomMethodData.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.CustomMethodData = CustomMethodData; + +const DIDUrlFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_didurl_free(ptr >>> 0, 1)); +/** +* A method agnostic DID Url. +*/ +class DIDUrl { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(DIDUrl.prototype); + obj.__wbg_ptr = ptr; + DIDUrlFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + DIDUrlFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_didurl_free(ptr, 0); + } + /** + * Parses a {@link DIDUrl} from the input string. + * @param {string} input + * @returns {DIDUrl} + */ + static parse(input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.didurl_parse(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DIDUrl.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Return a copy of the {@link CoreDID} section of the {@link DIDUrl}. + * @returns {CoreDID} + */ + did() { + const ret = wasm.didurl_did(this.__wbg_ptr); + return CoreDID.__wrap(ret); + } + /** + * Return a copy of the relative DID Url as a string, including only the path, query, and fragment. + * @returns {string} + */ + urlStr() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.didurl_urlStr(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the {@link DIDUrl} method fragment, if any. Excludes the leading '#'. + * @returns {string | undefined} + */ + fragment() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.didurl_fragment(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the `fragment` component of the {@link DIDUrl}. + * @param {string | undefined} [value] + */ + setFragment(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + var ptr0 = isLikeNone(value) ? 0 : passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.didurl_setFragment(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the {@link DIDUrl} path. + * @returns {string | undefined} + */ + path() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.didurl_path(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the `path` component of the {@link DIDUrl}. + * @param {string | undefined} [value] + */ + setPath(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + var ptr0 = isLikeNone(value) ? 0 : passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.didurl_setPath(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the {@link DIDUrl} method query, if any. Excludes the leading '?'. + * @returns {string | undefined} + */ + query() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.didurl_query(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the `query` component of the {@link DIDUrl}. + * @param {string | undefined} [value] + */ + setQuery(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + var ptr0 = isLikeNone(value) ? 0 : passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.didurl_setQuery(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Append a string representing a path, query, and/or fragment, returning a new {@link DIDUrl}. + * + * Must begin with a valid delimiter character: '/', '?', '#'. Overwrites the existing URL + * segment and any following segments in order of path, query, then fragment. + * + * I.e. + * - joining a path will clear the query and fragment. + * - joining a query will clear the fragment. + * - joining a fragment will only overwrite the fragment. + * @param {string} segment + * @returns {DIDUrl} + */ + join(segment) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(segment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.didurl_join(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DIDUrl.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the {@link DIDUrl} as a string. + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.didurl_toString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.didurl_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {DIDUrl} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.didurl_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DIDUrl.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {DIDUrl} + */ + clone() { + const ret = wasm.didurl_clone(this.__wbg_ptr); + return DIDUrl.__wrap(ret); + } +} +module.exports.DIDUrl = DIDUrl; + +const DecodedJptCredentialFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_decodedjptcredential_free(ptr >>> 0, 1)); +/** +*/ +class DecodedJptCredential { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(DecodedJptCredential.prototype); + obj.__wbg_ptr = ptr; + DecodedJptCredentialFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + DecodedJptCredentialFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_decodedjptcredential_free(ptr, 0); + } + /** + * Deep clones the object. + * @returns {DecodedJptCredential} + */ + clone() { + const ret = wasm.decodedjptcredential_clone(this.__wbg_ptr); + return DecodedJptCredential.__wrap(ret); + } + /** + * Returns the {@link Credential} embedded into this JPT. + * @returns {Credential} + */ + credential() { + const ret = wasm.decodedjptcredential_credential(this.__wbg_ptr); + return Credential.__wrap(ret); + } + /** + * Returns the custom claims parsed from the JPT. + * @returns {Map} + */ + customClaims() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.decodedjptcredential_customClaims(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {JwpIssued} + */ + decodedJwp() { + const ret = wasm.decodedjptcredential_decodedJwp(this.__wbg_ptr); + return JwpIssued.__wrap(ret); + } +} +module.exports.DecodedJptCredential = DecodedJptCredential; + +const DecodedJptPresentationFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_decodedjptpresentation_free(ptr >>> 0, 1)); +/** +*/ +class DecodedJptPresentation { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(DecodedJptPresentation.prototype); + obj.__wbg_ptr = ptr; + DecodedJptPresentationFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + DecodedJptPresentationFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_decodedjptpresentation_free(ptr, 0); + } + /** + * Deep clones the object. + * @returns {DecodedJptPresentation} + */ + clone() { + const ret = wasm.decodedjptpresentation_clone(this.__wbg_ptr); + return DecodedJptPresentation.__wrap(ret); + } + /** + * Returns the {@link Credential} embedded into this JPT. + * @returns {Credential} + */ + credential() { + const ret = wasm.decodedjptpresentation_credential(this.__wbg_ptr); + return Credential.__wrap(ret); + } + /** + * Returns the custom claims parsed from the JPT. + * @returns {Map} + */ + customClaims() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.decodedjptpresentation_customClaims(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the `aud` property parsed from the JWT claims. + * @returns {string | undefined} + */ + aud() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.decodedjptpresentation_aud(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.DecodedJptPresentation = DecodedJptPresentation; + +const DecodedJwsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_decodedjws_free(ptr >>> 0, 1)); +/** +* A cryptographically verified decoded token from a JWS. +* +* Contains the decoded headers and the raw claims. +*/ +class DecodedJws { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(DecodedJws.prototype); + obj.__wbg_ptr = ptr; + DecodedJwsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + DecodedJwsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_decodedjws_free(ptr, 0); + } + /** + * Returns a copy of the parsed claims represented as a string. + * + * # Errors + * An error is thrown if the claims cannot be represented as a string. + * + * This error can only occur if the Token was decoded from a detached payload. + * @returns {string} + */ + claims() { + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.decodedjws_claims(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + var ptr1 = r0; + var len1 = r1; + if (r3) { + ptr1 = 0; len1 = 0; + throw takeObject(r2); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } + } + /** + * Return a copy of the parsed claims represented as an array of bytes. + * @returns {Uint8Array} + */ + claimsBytes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.decodedjws_claimsBytes(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the protected header. + * @returns {JwsHeader} + */ + protectedHeader() { + const ret = wasm.decodedjws_protectedHeader(this.__wbg_ptr); + return JwsHeader.__wrap(ret); + } + /** + * Deep clones the object. + * @returns {DecodedJws} + */ + clone() { + const ret = wasm.decodedjws_clone(this.__wbg_ptr); + return DecodedJws.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.decodedjws_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.DecodedJws = DecodedJws; + +const DecodedJwtCredentialFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_decodedjwtcredential_free(ptr >>> 0, 1)); +/** +* A cryptographically verified and decoded Credential. +* +* Note that having an instance of this type only means the JWS it was constructed from was verified. +* It does not imply anything about a potentially present proof property on the credential itself. +*/ +class DecodedJwtCredential { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(DecodedJwtCredential.prototype); + obj.__wbg_ptr = ptr; + DecodedJwtCredentialFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + DecodedJwtCredentialFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_decodedjwtcredential_free(ptr, 0); + } + /** + * Returns a copy of the credential parsed to the [Verifiable Credentials Data model](https://www.w3.org/TR/vc-data-model/). + * @returns {Credential} + */ + credential() { + const ret = wasm.decodedjwtcredential_credential(this.__wbg_ptr); + return Credential.__wrap(ret); + } + /** + * Returns a copy of the protected header parsed from the decoded JWS. + * @returns {JwsHeader} + */ + protectedHeader() { + const ret = wasm.decodedjwtcredential_protectedHeader(this.__wbg_ptr); + return JwsHeader.__wrap(ret); + } + /** + * The custom claims parsed from the JWT. + * @returns {Record | undefined} + */ + customClaims() { + const ret = wasm.decodedjwtcredential_customClaims(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Consumes the object and returns the decoded credential. + * + * ### Warning + * + * This destroys the {@link DecodedJwtCredential} object. + * @returns {Credential} + */ + intoCredential() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.decodedjwtcredential_intoCredential(ptr); + return Credential.__wrap(ret); + } +} +module.exports.DecodedJwtCredential = DecodedJwtCredential; + +const DecodedJwtPresentationFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_decodedjwtpresentation_free(ptr >>> 0, 1)); +/** +* A cryptographically verified and decoded presentation. +* +* Note that having an instance of this type only means the JWS it was constructed from was verified. +* It does not imply anything about a potentially present proof property on the presentation itself. +*/ +class DecodedJwtPresentation { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(DecodedJwtPresentation.prototype); + obj.__wbg_ptr = ptr; + DecodedJwtPresentationFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + DecodedJwtPresentationFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_decodedjwtpresentation_free(ptr, 0); + } + /** + * @returns {Presentation} + */ + presentation() { + const ret = wasm.decodedjwtpresentation_presentation(this.__wbg_ptr); + return Presentation.__wrap(ret); + } + /** + * Returns a copy of the protected header parsed from the decoded JWS. + * @returns {JwsHeader} + */ + protectedHeader() { + const ret = wasm.decodedjwtpresentation_protectedHeader(this.__wbg_ptr); + return JwsHeader.__wrap(ret); + } + /** + * Consumes the object and returns the decoded presentation. + * + * ### Warning + * This destroys the {@link DecodedJwtPresentation} object. + * @returns {Presentation} + */ + intoPresentation() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.decodedjwtpresentation_intoPresentation(ptr); + return Presentation.__wrap(ret); + } + /** + * The expiration date parsed from the JWT claims. + * @returns {Timestamp | undefined} + */ + expirationDate() { + const ret = wasm.decodedjwtpresentation_expirationDate(this.__wbg_ptr); + return ret === 0 ? undefined : Timestamp.__wrap(ret); + } + /** + * The issuance date parsed from the JWT claims. + * @returns {Timestamp | undefined} + */ + issuanceDate() { + const ret = wasm.decodedjwtpresentation_issuanceDate(this.__wbg_ptr); + return ret === 0 ? undefined : Timestamp.__wrap(ret); + } + /** + * The `aud` property parsed from JWT claims. + * @returns {string | undefined} + */ + audience() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.decodedjwtpresentation_audience(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * The custom claims parsed from the JWT. + * @returns {Record | undefined} + */ + customClaims() { + const ret = wasm.decodedjwtpresentation_customClaims(this.__wbg_ptr); + return takeObject(ret); + } +} +module.exports.DecodedJwtPresentation = DecodedJwtPresentation; + +const DisclosureFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_disclosure_free(ptr >>> 0, 1)); +/** +* Represents an elements constructing a disclosure. +* Object properties and array elements disclosures are supported. +* +* See: https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-disclosures +*/ +class Disclosure { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Disclosure.prototype); + obj.__wbg_ptr = ptr; + DisclosureFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + DisclosureFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_disclosure_free(ptr, 0); + } + /** + * @param {string} salt + * @param {string | undefined} claim_name + * @param {any} claim_value + */ + constructor(salt, claim_name, claim_value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + var ptr1 = isLikeNone(claim_name) ? 0 : passStringToWasm0(claim_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.disclosure_new(retptr, ptr0, len0, ptr1, len1, addHeapObject(claim_value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + DisclosureFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Parses a Base64 encoded disclosure into a `Disclosure`. + * + * ## Error + * + * Returns an `InvalidDisclosure` if input is not a valid disclosure. + * @param {string} disclosure + * @returns {Disclosure} + */ + static parse(disclosure) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(disclosure, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.disclosure_parse(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Disclosure.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the base64url-encoded string. + * @returns {string} + */ + disclosure() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.disclosure_disclosure(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the base64url-encoded string. + * @returns {string} + */ + toEncodedString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.disclosure_disclosure(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the base64url-encoded string. + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.disclosure_disclosure(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the salt value. + * @returns {string} + */ + salt() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.disclosure_salt(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the claim name, optional for array elements. + * @returns {string | undefined} + */ + claimName() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.disclosure_claimName(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the claim Value which can be of any type. + * @returns {any} + */ + claimValue() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.disclosure_claimValue(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.disclosure_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Disclosure} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.disclosure_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Disclosure.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.Disclosure = Disclosure; + +const DomainLinkageConfigurationFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_domainlinkageconfiguration_free(ptr >>> 0, 1)); +/** +* DID Configuration Resource which contains Domain Linkage Credentials. +* It can be placed in an origin's `.well-known` directory to prove linkage between the origin and a DID. +* See: +* +* Note: +* - Only the [JSON Web Token Proof Format](https://identity.foundation/.well-known/resources/did-configuration/#json-web-token-proof-format) +*/ +class DomainLinkageConfiguration { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(DomainLinkageConfiguration.prototype); + obj.__wbg_ptr = ptr; + DomainLinkageConfigurationFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + DomainLinkageConfigurationFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_domainlinkageconfiguration_free(ptr, 0); + } + /** + * Constructs a new {@link DomainLinkageConfiguration}. + * @param {Array} linkedDids + */ + constructor(linkedDids) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.domainlinkageconfiguration_new(retptr, addBorrowedObject(linkedDids)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + DomainLinkageConfigurationFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * List of the Domain Linkage Credentials. + * @returns {Array} + */ + linkedDids() { + const ret = wasm.domainlinkageconfiguration_linkedDids(this.__wbg_ptr); + return takeObject(ret); + } + /** + * List of the issuers of the Domain Linkage Credentials. + * @returns {Array} + */ + issuers() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.domainlinkageconfiguration_issuers(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.domainlinkageconfiguration_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {DomainLinkageConfiguration} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.domainlinkageconfiguration_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DomainLinkageConfiguration.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {DomainLinkageConfiguration} + */ + clone() { + const ret = wasm.domainlinkageconfiguration_clone(this.__wbg_ptr); + return DomainLinkageConfiguration.__wrap(ret); + } +} +module.exports.DomainLinkageConfiguration = DomainLinkageConfiguration; + +const DurationFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_duration_free(ptr >>> 0, 1)); +/** +* A span of time. +*/ +class Duration { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Duration.prototype); + obj.__wbg_ptr = ptr; + DurationFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + DurationFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_duration_free(ptr, 0); + } + /** + * Create a new {@link Duration} with the given number of seconds. + * @param {number} seconds + * @returns {Duration} + */ + static seconds(seconds) { + const ret = wasm.duration_seconds(seconds); + return Duration.__wrap(ret); + } + /** + * Create a new {@link Duration} with the given number of minutes. + * @param {number} minutes + * @returns {Duration} + */ + static minutes(minutes) { + const ret = wasm.duration_minutes(minutes); + return Duration.__wrap(ret); + } + /** + * Create a new {@link Duration} with the given number of hours. + * @param {number} hours + * @returns {Duration} + */ + static hours(hours) { + const ret = wasm.duration_hours(hours); + return Duration.__wrap(ret); + } + /** + * Create a new {@link Duration} with the given number of days. + * @param {number} days + * @returns {Duration} + */ + static days(days) { + const ret = wasm.duration_days(days); + return Duration.__wrap(ret); + } + /** + * Create a new {@link Duration} with the given number of weeks. + * @param {number} weeks + * @returns {Duration} + */ + static weeks(weeks) { + const ret = wasm.duration_weeks(weeks); + return Duration.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.duration_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Duration} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.duration_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Duration.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.Duration = Duration; + +const EdDSAJwsVerifierFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_eddsajwsverifier_free(ptr >>> 0, 1)); +/** +* An implementor of `IJwsVerifier` that can handle the +* `EdDSA` algorithm. +*/ +class EdDSAJwsVerifier { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + EdDSAJwsVerifierFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_eddsajwsverifier_free(ptr, 0); + } + /** + * Constructs an EdDSAJwsVerifier. + */ + constructor() { + const ret = wasm.eddsajwsverifier_new(); + this.__wbg_ptr = ret >>> 0; + EdDSAJwsVerifierFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Verify a JWS signature secured with the `EdDSA` algorithm. + * Only the `Ed25519` curve is supported for now. + * + * This function is useful when one is building an `IJwsVerifier` that extends the default provided by + * the IOTA Identity Framework. + * + * # Warning + * + * This function does not check whether `alg = EdDSA` in the protected header. Callers are expected to assert this + * prior to calling the function. + * @param {JwsAlgorithm} alg + * @param {Uint8Array} signingInput + * @param {Uint8Array} decodedSignature + * @param {Jwk} publicKey + */ + verify(alg, signingInput, decodedSignature, publicKey) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(signingInput, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArray8ToWasm0(decodedSignature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(publicKey, Jwk); + wasm.eddsajwsverifier_verify(retptr, this.__wbg_ptr, addHeapObject(alg), ptr0, len0, ptr1, len1, publicKey.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.EdDSAJwsVerifier = EdDSAJwsVerifier; + +const IotaDIDFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_iotadid_free(ptr >>> 0, 1)); +/** +* A DID conforming to the IOTA DID method specification. +* +* @typicalname did +*/ +class IotaDID { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(IotaDID.prototype); + obj.__wbg_ptr = ptr; + IotaDIDFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + METHOD: this.METHOD, + DEFAULT_NETWORK: this.DEFAULT_NETWORK, + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IotaDIDFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_iotadid_free(ptr, 0); + } + /** + * The IOTA DID method name (`"iota"`). + * @returns {string} + */ + static get METHOD() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_static_default_network(retptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * The default Tangle network (`"iota"`). + * @returns {string} + */ + static get DEFAULT_NETWORK() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_static_default_network(retptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Constructs a new {@link IotaDID} from a byte representation of the tag and the given + * network name. + * + * See also {@link IotaDID.placeholder}. + * @param {Uint8Array} bytes + * @param {string} network + */ + constructor(bytes, network) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.iotadid_new(retptr, ptr0, len0, ptr1, len1); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + IotaDIDFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Constructs a new {@link IotaDID} from a hex representation of an Alias Id and the given + * network name. + * @param {string} aliasId + * @param {string} network + * @returns {IotaDID} + */ + static fromAliasId(aliasId, network) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(aliasId, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + wasm.iotadid_fromAliasId(retptr, ptr0, len0, ptr1, len1); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Creates a new placeholder {@link IotaDID} with the given network name. + * + * E.g. `did:iota:smr:0x0000000000000000000000000000000000000000000000000000000000000000`. + * @param {string} network + * @returns {IotaDID} + */ + static placeholder(network) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.iotadid_placeholder(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Parses a {@link IotaDID} from the input string. + * @param {string} input + * @returns {IotaDID} + */ + static parse(input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.iotadid_parse(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the Tangle network name of the {@link IotaDID}. + * @returns {string} + */ + network() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_network(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the unique tag of the {@link IotaDID}. + * @returns {string} + */ + tag() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_tag(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns the DID represented as a {@link CoreDID}. + * @returns {CoreDID} + */ + toCoreDid() { + const ret = wasm.iotadid_toCoreDid(this.__wbg_ptr); + return CoreDID.__wrap(ret); + } + /** + * Returns the `DID` scheme. + * + * E.g. + * - `"did:example:12345678" -> "did"` + * - `"did:iota:main:12345678" -> "did"` + * @returns {string} + */ + scheme() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_scheme(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns the `DID` authority: the method name and method-id. + * + * E.g. + * - `"did:example:12345678" -> "example:12345678"` + * - `"did:iota:main:12345678" -> "iota:main:12345678"` + * @returns {string} + */ + authority() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_authority(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns the `DID` method name. + * + * E.g. + * - `"did:example:12345678" -> "example"` + * - `"did:iota:main:12345678" -> "iota"` + * @returns {string} + */ + method() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_method(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns the `DID` method-specific ID. + * + * E.g. + * - `"did:example:12345678" -> "12345678"` + * - `"did:iota:main:12345678" -> "main:12345678"` + * @returns {string} + */ + methodId() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_methodId(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Construct a new {@link DIDUrl} by joining with a relative DID Url string. + * @param {string} segment + * @returns {DIDUrl} + */ + join(segment) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(segment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.iotadid_join(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DIDUrl.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Clones the `DID` into a {@link DIDUrl}. + * @returns {DIDUrl} + */ + toUrl() { + const ret = wasm.iotadid_toUrl(this.__wbg_ptr); + return DIDUrl.__wrap(ret); + } + /** + * Returns the hex-encoded AliasId with a '0x' prefix, from the DID tag. + * @returns {string} + */ + toAliasId() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_toAliasId(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Converts the `DID` into a {@link DIDUrl}, consuming it. + * @returns {DIDUrl} + */ + intoUrl() { + const ptr = this.__destroy_into_raw(); + const ret = wasm.iotadid_intoUrl(ptr); + return DIDUrl.__wrap(ret); + } + /** + * Returns the `DID` as a string. + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_toString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {IotaDID} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadid_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {IotaDID} + */ + clone() { + const ret = wasm.iotadid_clone(this.__wbg_ptr); + return IotaDID.__wrap(ret); + } +} +module.exports.IotaDID = IotaDID; + +const IotaDocumentFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_iotadocument_free(ptr >>> 0, 1)); +/** +* A DID Document adhering to the IOTA DID method specification. +* +* Note: All methods that involve reading from this class may potentially raise an error +* if the object is being concurrently modified. +*/ +class IotaDocument { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(IotaDocument.prototype); + obj.__wbg_ptr = ptr; + IotaDocumentFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IotaDocumentFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_iotadocument_free(ptr, 0); + } + /** + * Constructs an empty IOTA DID Document with a {@link IotaDID.placeholder} identifier + * for the given `network`. + * @param {string} network + */ + constructor(network) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.iotadocument_new(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + IotaDocumentFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Constructs an empty DID Document with the given identifier. + * @param {IotaDID} id + * @returns {IotaDocument} + */ + static newWithId(id) { + _assertClass(id, IotaDID); + const ret = wasm.iotadocument_newWithId(id.__wbg_ptr); + return IotaDocument.__wrap(ret); + } + /** + * Returns a copy of the DID Document `id`. + * @returns {IotaDID} + */ + id() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_id(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the list of document controllers. + * + * NOTE: controllers are determined by the `state_controller` unlock condition of the output + * during resolution and are omitted when publishing. + * @returns {IotaDID[]} + */ + controller() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_controller(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the controllers of the document. + * + * Note: Duplicates will be ignored. + * Use `null` to remove all controllers. + * @param {IotaDID[] | null} controller + */ + setController(controller) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_setController(retptr, this.__wbg_ptr, addBorrowedObject(controller)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Returns a copy of the document's `alsoKnownAs` set. + * @returns {Array} + */ + alsoKnownAs() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_alsoKnownAs(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the `alsoKnownAs` property in the DID document. + * @param {string | string[] | null} urls + */ + setAlsoKnownAs(urls) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_setAlsoKnownAs(retptr, this.__wbg_ptr, addBorrowedObject(urls)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Returns a copy of the custom DID Document properties. + * @returns {Map} + */ + properties() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_properties(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a custom property in the DID Document. + * If the value is set to `null`, the custom property will be removed. + * + * ### WARNING + * + * This method can overwrite existing properties like `id` and result in an invalid document. + * @param {string} key + * @param {any} value + */ + setPropertyUnchecked(key, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.iotadocument_setPropertyUnchecked(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Return a set of all {@link Service} in the document. + * @returns {Service[]} + */ + service() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_service(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Add a new {@link Service} to the document. + * + * Returns `true` if the service was added. + * @param {Service} service + */ + insertService(service) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(service, Service); + wasm.iotadocument_insertService(retptr, this.__wbg_ptr, service.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Remove a {@link Service} identified by the given {@link DIDUrl} from the document. + * + * Returns `true` if a service was removed. + * @param {DIDUrl} did + * @returns {Service | undefined} + */ + removeService(did) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(did, DIDUrl); + wasm.iotadocument_removeService(retptr, this.__wbg_ptr, did.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : Service.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the first {@link Service} with an `id` property matching the provided `query`, + * if present. + * @param {DIDUrl | string} query + * @returns {Service | undefined} + */ + resolveService(query) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_resolveService(retptr, this.__wbg_ptr, addBorrowedObject(query)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : Service.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Returns a list of all {@link VerificationMethod} in the DID Document, + * whose verification relationship matches `scope`. + * + * If `scope` is not set, a list over the **embedded** methods is returned. + * @param {MethodScope | undefined} [scope] + * @returns {VerificationMethod[]} + */ + methods(scope) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_methods(retptr, this.__wbg_ptr, isLikeNone(scope) ? 0 : addHeapObject(scope)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Adds a new `method` to the document in the given `scope`. + * @param {VerificationMethod} method + * @param {MethodScope} scope + */ + insertMethod(method, scope) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(method, VerificationMethod); + _assertClass(scope, MethodScope); + wasm.iotadocument_insertMethod(retptr, this.__wbg_ptr, method.__wbg_ptr, scope.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Removes all references to the specified Verification Method. + * @param {DIDUrl} did + * @returns {VerificationMethod | undefined} + */ + removeMethod(did) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(did, DIDUrl); + wasm.iotadocument_removeMethod(retptr, this.__wbg_ptr, did.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : VerificationMethod.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the first verification method with an `id` property + * matching the provided `query` and the verification relationship + * specified by `scope`, if present. + * @param {DIDUrl | string} query + * @param {MethodScope | undefined} [scope] + * @returns {VerificationMethod | undefined} + */ + resolveMethod(query, scope) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_resolveMethod(retptr, this.__wbg_ptr, addBorrowedObject(query), isLikeNone(scope) ? 0 : addHeapObject(scope)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : VerificationMethod.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Attaches the relationship to the given method, if the method exists. + * + * Note: The method needs to be in the set of verification methods, + * so it cannot be an embedded one. + * @param {DIDUrl} didUrl + * @param {MethodRelationship} relationship + * @returns {boolean} + */ + attachMethodRelationship(didUrl, relationship) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(didUrl, DIDUrl); + wasm.iotadocument_attachMethodRelationship(retptr, this.__wbg_ptr, didUrl.__wbg_ptr, relationship); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Detaches the given relationship from the given method, if the method exists. + * @param {DIDUrl} didUrl + * @param {MethodRelationship} relationship + * @returns {boolean} + */ + detachMethodRelationship(didUrl, relationship) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(didUrl, DIDUrl); + wasm.iotadocument_detachMethodRelationship(retptr, this.__wbg_ptr, didUrl.__wbg_ptr, relationship); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Decodes and verifies the provided JWS according to the passed `options` and `signatureVerifier`. + * If no `signatureVerifier` argument is provided a default verifier will be used that is (only) capable of + * verifying EdDSA signatures. + * + * Regardless of which options are passed the following conditions must be met in order for a verification attempt to + * take place. + * - The JWS must be encoded according to the JWS compact serialization. + * - The `kid` value in the protected header must be an identifier of a verification method in this DID document. + * @param {Jws} jws + * @param {JwsVerificationOptions} options + * @param {IJwsVerifier} signatureVerifier + * @param {string | undefined} [detachedPayload] + * @returns {DecodedJws} + */ + verifyJws(jws, options, signatureVerifier, detachedPayload) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(jws, Jws); + _assertClass(options, JwsVerificationOptions); + var ptr0 = isLikeNone(detachedPayload) ? 0 : passStringToWasm0(detachedPayload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.iotadocument_verifyJws(retptr, this.__wbg_ptr, jws.__wbg_ptr, options.__wbg_ptr, addHeapObject(signatureVerifier), ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DecodedJws.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes the document for inclusion in an Alias Output's state metadata + * with the default {@link StateMetadataEncoding}. + * @returns {Uint8Array} + */ + pack() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_pack(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes the document for inclusion in an Alias Output's state metadata. + * @param {StateMetadataEncoding} encoding + * @returns {Uint8Array} + */ + packWithEncoding(encoding) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_packWithEncoding(retptr, this.__wbg_ptr, encoding); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes the document from an Alias Output. + * + * If `allowEmpty` is true, this will return an empty DID document marked as `deactivated` + * if `stateMetadata` is empty. + * + * The `tokenSupply` must be equal to the token supply of the network the DID is associated with. + * + * NOTE: `did` is required since it is omitted from the serialized DID Document and + * cannot be inferred from the state metadata. It also indicates the network, which is not + * encoded in the `AliasId` alone. + * @param {IotaDID} did + * @param {AliasOutputBuilderParams} aliasOutput + * @param {boolean} allowEmpty + * @returns {IotaDocument} + */ + static unpackFromOutput(did, aliasOutput, allowEmpty) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(did, IotaDID); + wasm.iotadocument_unpackFromOutput(retptr, did.__wbg_ptr, addHeapObject(aliasOutput), allowEmpty); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDocument.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns all DID documents of the Alias Outputs contained in the block's transaction payload + * outputs, if any. + * + * Errors if any Alias Output does not contain a valid or empty DID Document. + * @param {string} network + * @param {Block} block + * @returns {IotaDocument[]} + */ + static unpackFromBlock(network, block) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.iotadocument_unpackFromBlock(retptr, ptr0, len0, addBorrowedObject(block)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Returns a copy of the metadata associated with this document. + * + * NOTE: Copies all the metadata. See also `metadataCreated`, `metadataUpdated`, + * `metadataPreviousMessageId`, `metadataProof` if only a subset of the metadata required. + * @returns {IotaDocumentMetadata} + */ + metadata() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_metadata(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDocumentMetadata.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the timestamp of when the DID document was created. + * @returns {Timestamp | undefined} + */ + metadataCreated() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_metadataCreated(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : Timestamp.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the timestamp of when the DID document was created. + * @param {Timestamp | undefined} timestamp + */ + setMetadataCreated(timestamp) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_setMetadataCreated(retptr, this.__wbg_ptr, addHeapObject(timestamp)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the timestamp of the last DID document update. + * @returns {Timestamp | undefined} + */ + metadataUpdated() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_metadataUpdated(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0 ? undefined : Timestamp.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the timestamp of the last DID document update. + * @param {Timestamp | undefined} timestamp + */ + setMetadataUpdated(timestamp) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_setMetadataUpdated(retptr, this.__wbg_ptr, addHeapObject(timestamp)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the deactivated status of the DID document. + * @returns {boolean | undefined} + */ + metadataDeactivated() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_metadataDeactivated(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 === 0xFFFFFF ? undefined : r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the deactivated status of the DID document. + * @param {boolean | undefined} [deactivated] + */ + setMetadataDeactivated(deactivated) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_setMetadataDeactivated(retptr, this.__wbg_ptr, isLikeNone(deactivated) ? 0xFFFFFF : deactivated ? 1 : 0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the Bech32-encoded state controller address, if present. + * @returns {string | undefined} + */ + metadataStateControllerAddress() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_metadataStateControllerAddress(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + if (r3) { + throw takeObject(r2); + } + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the Bech32-encoded governor address, if present. + * @returns {string | undefined} + */ + metadataGovernorAddress() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_metadataGovernorAddress(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + if (r3) { + throw takeObject(r2); + } + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a custom property in the document metadata. + * If the value is set to `null`, the custom property will be removed. + * @param {string} key + * @param {any} value + */ + setMetadataPropertyUnchecked(key, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.iotadocument_setMetadataPropertyUnchecked(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, + * revoke all specified `indices`. + * @param {DIDUrl | string} serviceQuery + * @param {number | number[]} indices + */ + revokeCredentials(serviceQuery, indices) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_revokeCredentials(retptr, this.__wbg_ptr, addBorrowedObject(serviceQuery), addHeapObject(indices)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, + * unrevoke all specified `indices`. + * @param {DIDUrl | string} serviceQuery + * @param {number | number[]} indices + */ + unrevokeCredentials(serviceQuery, indices) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_unrevokeCredentials(retptr, this.__wbg_ptr, addBorrowedObject(serviceQuery), addHeapObject(indices)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Returns a deep clone of the {@link IotaDocument}. + * @returns {IotaDocument} + */ + clone() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_clone(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDocument.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * ### Warning + * This is for internal use only. Do not rely on or call this method. + * @returns {IotaDocument} + */ + _shallowCloneInternal() { + const ret = wasm.iotadocument__shallowCloneInternal(this.__wbg_ptr); + return IotaDocument.__wrap(ret); + } + /** + * ### Warning + * This is for internal use only. Do not rely on or call this method. + * @returns {number} + */ + _strongCountInternal() { + const ret = wasm.iotadocument__strongCountInternal(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Serializes to a plain JS representation. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a plain JS representation. + * @param {any} json + * @returns {IotaDocument} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDocument.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Transforms the {@link IotaDocument} to its {@link CoreDocument} representation. + * @returns {CoreDocument} + */ + toCoreDocument() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocument_toCoreDocument(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDocument.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Generate new key material in the given `storage` and insert a new verification method with the corresponding + * public key material into the DID document. + * + * - If no fragment is given the `kid` of the generated JWK is used, if it is set, otherwise an error is returned. + * - The `keyType` must be compatible with the given `storage`. `Storage`s are expected to export key type constants + * for that use case. + * + * The fragment of the generated method is returned. + * @param {Storage} storage + * @param {string} keyType + * @param {JwsAlgorithm} alg + * @param {string | undefined} fragment + * @param {MethodScope} scope + * @returns {Promise} + */ + generateMethod(storage, keyType, alg, fragment, scope) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(keyType, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + var ptr1 = isLikeNone(fragment) ? 0 : passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + _assertClass(scope, MethodScope); + var ptr2 = scope.__destroy_into_raw(); + wasm.iotadocument_generateMethod(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, addHeapObject(alg), ptr1, len1, ptr2); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Remove the method identified by the given fragment from the document and delete the corresponding key material in + * the given `storage`. + * @param {Storage} storage + * @param {DIDUrl} id + * @returns {Promise} + */ + purgeMethod(storage, id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + _assertClass(id, DIDUrl); + wasm.iotadocument_purgeMethod(retptr, this.__wbg_ptr, storage.__wbg_ptr, id.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sign the `payload` according to `options` with the storage backed private key corresponding to the public key + * material in the verification method identified by the given `fragment. + * + * Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. + * See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). + * + * @deprecated Use `createJws()` instead. + * @param {Storage} storage + * @param {string} fragment + * @param {string} payload + * @param {JwsSignatureOptions} options + * @returns {Promise} + */ + createJwt(storage, fragment, payload, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(options, JwsSignatureOptions); + wasm.iotadocument_createJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, ptr1, len1, options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sign the `payload` according to `options` with the storage backed private key corresponding to the public key + * material in the verification method identified by the given `fragment. + * + * Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. + * See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). + * @param {Storage} storage + * @param {string} fragment + * @param {string} payload + * @param {JwsSignatureOptions} options + * @returns {Promise} + */ + createJws(storage, fragment, payload, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(options, JwsSignatureOptions); + wasm.iotadocument_createJws(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, ptr1, len1, options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Produces a JWS where the payload is produced from the given `credential` + * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). + * + * Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` + * of the method identified by `fragment` and the JWS signature will be produced by the corresponding + * private key backed by the `storage` in accordance with the passed `options`. + * + * The `custom_claims` can be used to set additional claims on the resulting JWT. + * @param {Storage} storage + * @param {string} fragment + * @param {Credential} credential + * @param {JwsSignatureOptions} options + * @param {Record | undefined} [custom_claims] + * @returns {Promise} + */ + createCredentialJwt(storage, fragment, credential, options, custom_claims) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(credential, Credential); + _assertClass(options, JwsSignatureOptions); + wasm.iotadocument_createCredentialJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, credential.__wbg_ptr, options.__wbg_ptr, isLikeNone(custom_claims) ? 0 : addHeapObject(custom_claims)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Produces a JWT where the payload is produced from the given presentation. + * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). + * + * Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` + * of the method identified by `fragment` and the JWS signature will be produced by the corresponding + * private key backed by the `storage` in accordance with the passed `options`. + * @param {Storage} storage + * @param {string} fragment + * @param {Presentation} presentation + * @param {JwsSignatureOptions} signature_options + * @param {JwtPresentationOptions} presentation_options + * @returns {Promise} + */ + createPresentationJwt(storage, fragment, presentation, signature_options, presentation_options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(presentation, Presentation); + _assertClass(signature_options, JwsSignatureOptions); + _assertClass(presentation_options, JwtPresentationOptions); + wasm.iotadocument_createPresentationJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, presentation.__wbg_ptr, signature_options.__wbg_ptr, presentation_options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Storage} storage + * @param {ProofAlgorithm} alg + * @param {string | undefined} fragment + * @param {MethodScope} scope + * @returns {Promise} + */ + generateMethodJwp(storage, alg, fragment, scope) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + var ptr0 = isLikeNone(fragment) ? 0 : passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + _assertClass(scope, MethodScope); + var ptr1 = scope.__destroy_into_raw(); + wasm.iotadocument_generateMethodJwp(retptr, this.__wbg_ptr, storage.__wbg_ptr, alg, ptr0, len0, ptr1); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Storage} storage + * @param {string} fragment + * @param {JptClaims} jpt_claims + * @param {JwpCredentialOptions} options + * @returns {Promise} + */ + createIssuedJwp(storage, fragment, jpt_claims, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(storage, Storage); + const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(options, JwpCredentialOptions); + var ptr1 = options.__destroy_into_raw(); + wasm.iotadocument_createIssuedJwp(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, addHeapObject(jpt_claims), ptr1); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {SelectiveDisclosurePresentation} presentation + * @param {string} method_id + * @param {JwpPresentationOptions} options + * @returns {Promise} + */ + createPresentedJwp(presentation, method_id, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(presentation, SelectiveDisclosurePresentation); + var ptr0 = presentation.__destroy_into_raw(); + const ptr1 = passStringToWasm0(method_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(options, JwpPresentationOptions); + var ptr2 = options.__destroy_into_raw(); + wasm.iotadocument_createPresentedJwp(retptr, this.__wbg_ptr, ptr0, ptr1, len1, ptr2); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Credential} credential + * @param {Storage} storage + * @param {string} fragment + * @param {JwpCredentialOptions} options + * @param {Map | undefined} [custom_claims] + * @returns {Promise} + */ + createCredentialJpt(credential, storage, fragment, options, custom_claims) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + var ptr0 = credential.__destroy_into_raw(); + _assertClass(storage, Storage); + const ptr1 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(options, JwpCredentialOptions); + var ptr2 = options.__destroy_into_raw(); + wasm.iotadocument_createCredentialJpt(retptr, this.__wbg_ptr, ptr0, storage.__wbg_ptr, ptr1, len1, ptr2, isLikeNone(custom_claims) ? 0 : addHeapObject(custom_claims)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {SelectiveDisclosurePresentation} presentation + * @param {string} method_id + * @param {JwpPresentationOptions} options + * @returns {Promise} + */ + createPresentationJpt(presentation, method_id, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(presentation, SelectiveDisclosurePresentation); + var ptr0 = presentation.__destroy_into_raw(); + const ptr1 = passStringToWasm0(method_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(options, JwpPresentationOptions); + var ptr2 = options.__destroy_into_raw(); + wasm.iotadocument_createPresentationJpt(retptr, this.__wbg_ptr, ptr0, ptr1, len1, ptr2); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.IotaDocument = IotaDocument; + +const IotaDocumentMetadataFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_iotadocumentmetadata_free(ptr >>> 0, 1)); +/** +* Additional attributes related to an IOTA DID Document. +*/ +class IotaDocumentMetadata { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(IotaDocumentMetadata.prototype); + obj.__wbg_ptr = ptr; + IotaDocumentMetadataFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IotaDocumentMetadataFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_iotadocumentmetadata_free(ptr, 0); + } + /** + * Returns a copy of the timestamp of when the DID document was created. + * @returns {Timestamp | undefined} + */ + created() { + const ret = wasm.iotadocumentmetadata_created(this.__wbg_ptr); + return ret === 0 ? undefined : Timestamp.__wrap(ret); + } + /** + * Returns a copy of the timestamp of the last DID document update. + * @returns {Timestamp | undefined} + */ + updated() { + const ret = wasm.iotadocumentmetadata_updated(this.__wbg_ptr); + return ret === 0 ? undefined : Timestamp.__wrap(ret); + } + /** + * Returns a copy of the deactivated status of the DID document. + * @returns {boolean | undefined} + */ + deactivated() { + const ret = wasm.iotadocumentmetadata_deactivated(this.__wbg_ptr); + return ret === 0xFFFFFF ? undefined : ret !== 0; + } + /** + * Returns a copy of the Bech32-encoded state controller address, if present. + * @returns {string | undefined} + */ + stateControllerAddress() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocumentmetadata_stateControllerAddress(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the Bech32-encoded governor address, if present. + * @returns {string | undefined} + */ + governorAddress() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocumentmetadata_governorAddress(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the custom metadata properties. + * @returns {Map} + */ + properties() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocumentmetadata_properties(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocumentmetadata_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {IotaDocumentMetadata} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.iotadocumentmetadata_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return IotaDocumentMetadata.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {IotaDocumentMetadata} + */ + clone() { + const ret = wasm.iotadocumentmetadata_clone(this.__wbg_ptr); + return IotaDocumentMetadata.__wrap(ret); + } +} +module.exports.IotaDocumentMetadata = IotaDocumentMetadata; + +const IotaIdentityClientExtFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_iotaidentityclientext_free(ptr >>> 0, 1)); +/** +* An extension interface that provides helper functions for publication +* and resolution of DID documents in Alias Outputs. +*/ +class IotaIdentityClientExt { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IotaIdentityClientExtFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_iotaidentityclientext_free(ptr, 0); + } + /** + * Create a DID with a new Alias Output containing the given `document`. + * + * The `address` will be set as the state controller and governor unlock conditions. + * The minimum required token deposit amount will be set according to the given + * `rent_structure`, which will be fetched from the node if not provided. + * The returned Alias Output can be further customised before publication, if desired. + * + * NOTE: this does *not* publish the Alias Output. + * @param {IIotaIdentityClient} client + * @param {Address} address + * @param {IotaDocument} document + * @param {IRent | undefined} [rentStructure] + * @returns {Promise} + */ + static newDidOutput(client, address, document, rentStructure) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(document, IotaDocument); + wasm.iotaidentityclientext_newDidOutput(retptr, addHeapObject(client), addHeapObject(address), document.__wbg_ptr, isLikeNone(rentStructure) ? 0 : addHeapObject(rentStructure)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Fetches the associated Alias Output and updates it with `document` in its state metadata. + * The storage deposit on the output is left unchanged. If the size of the document increased, + * the amount should be increased manually. + * + * NOTE: this does *not* publish the updated Alias Output. + * @param {IIotaIdentityClient} client + * @param {IotaDocument} document + * @returns {Promise} + */ + static updateDidOutput(client, document) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(document, IotaDocument); + wasm.iotaidentityclientext_updateDidOutput(retptr, addHeapObject(client), document.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Removes the DID document from the state metadata of its Alias Output, + * effectively deactivating it. The storage deposit on the output is left unchanged, + * and should be reallocated manually. + * + * Deactivating does not destroy the output. Hence, it can be re-activated by publishing + * an update containing a DID document. + * + * NOTE: this does *not* publish the updated Alias Output. + * @param {IIotaIdentityClient} client + * @param {IotaDID} did + * @returns {Promise} + */ + static deactivateDidOutput(client, did) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(did, IotaDID); + wasm.iotaidentityclientext_deactivateDidOutput(retptr, addHeapObject(client), did.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Resolve a {@link IotaDocument}. Returns an empty, deactivated document if the state metadata + * of the Alias Output is empty. + * @param {IIotaIdentityClient} client + * @param {IotaDID} did + * @returns {Promise} + */ + static resolveDid(client, did) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(did, IotaDID); + wasm.iotaidentityclientext_resolveDid(retptr, addHeapObject(client), did.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Fetches the `IAliasOutput` associated with the given DID. + * @param {IIotaIdentityClient} client + * @param {IotaDID} did + * @returns {Promise} + */ + static resolveDidOutput(client, did) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(did, IotaDID); + wasm.iotaidentityclientext_resolveDidOutput(retptr, addHeapObject(client), did.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.IotaIdentityClientExt = IotaIdentityClientExt; + +const IssuerProtectedHeaderFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_issuerprotectedheader_free(ptr >>> 0, 1)); +/** +*/ +class IssuerProtectedHeader { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(IssuerProtectedHeader.prototype); + obj.__wbg_ptr = ptr; + IssuerProtectedHeaderFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + typ: this.typ, + alg: this.alg, + kid: this.kid, + cid: this.cid, + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + IssuerProtectedHeaderFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_issuerprotectedheader_free(ptr, 0); + } + /** + * JWP type (JPT). + * @returns {string | undefined} + */ + get typ() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_issuerprotectedheader_typ(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * JWP type (JPT). + * @param {string | undefined} [arg0] + */ + set typ(arg0) { + var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_issuerprotectedheader_typ(this.__wbg_ptr, ptr0, len0); + } + /** + * Algorithm used for the JWP. + * @returns {ProofAlgorithm} + */ + get alg() { + const ret = wasm.__wbg_get_issuerprotectedheader_alg(this.__wbg_ptr); + return ret; + } + /** + * Algorithm used for the JWP. + * @param {ProofAlgorithm} arg0 + */ + set alg(arg0) { + wasm.__wbg_set_issuerprotectedheader_alg(this.__wbg_ptr, arg0); + } + /** + * ID for the key used for the JWP. + * @returns {string | undefined} + */ + get kid() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_issuerprotectedheader_kid(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * ID for the key used for the JWP. + * @param {string | undefined} [arg0] + */ + set kid(arg0) { + var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_issuerprotectedheader_kid(this.__wbg_ptr, ptr0, len0); + } + /** + * Not handled for now. Will be used in the future to resolve external claims + * @returns {string | undefined} + */ + get cid() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_issuerprotectedheader_cid(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Not handled for now. Will be used in the future to resolve external claims + * @param {string | undefined} [arg0] + */ + set cid(arg0) { + var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_issuerprotectedheader_cid(this.__wbg_ptr, ptr0, len0); + } + /** + * @returns {(string)[]} + */ + claims() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.issuerprotectedheader_claims(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var v1 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4, 4); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.IssuerProtectedHeader = IssuerProtectedHeader; + +const JptFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jpt_free(ptr >>> 0, 1)); +/** +* A JSON Proof Token (JPT). +*/ +class Jpt { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Jpt.prototype); + obj.__wbg_ptr = ptr; + JptFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JptFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jpt_free(ptr, 0); + } + /** + * Creates a new {@link Jpt}. + * @param {string} jpt_string + */ + constructor(jpt_string) { + const ptr0 = passStringToWasm0(jpt_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.jpt_new(ptr0, len0); + this.__wbg_ptr = ret >>> 0; + JptFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jpt_toString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Deep clones the object. + * @returns {Jpt} + */ + clone() { + const ret = wasm.jpt_clone(this.__wbg_ptr); + return Jpt.__wrap(ret); + } +} +module.exports.Jpt = Jpt; + +const JptCredentialValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jptcredentialvalidationoptions_free(ptr >>> 0, 1)); +/** +* Options to declare validation criteria for {@link Jpt}. +*/ +class JptCredentialValidationOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JptCredentialValidationOptions.prototype); + obj.__wbg_ptr = ptr; + JptCredentialValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JptCredentialValidationOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jptcredentialvalidationoptions_free(ptr, 0); + } + /** + * Deep clones the object. + * @returns {JptCredentialValidationOptions} + */ + clone() { + const ret = wasm.jptcredentialvalidationoptions_clone(this.__wbg_ptr); + return JptCredentialValidationOptions.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jptcredentialvalidationoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JptCredentialValidationOptions} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jptcredentialvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JptCredentialValidationOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Creates a new default istance. + * @param {IJptCredentialValidationOptions | undefined} [opts] + */ + constructor(opts) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jptcredentialvalidationoptions_new(retptr, isLikeNone(opts) ? 0 : addHeapObject(opts)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + JptCredentialValidationOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.JptCredentialValidationOptions = JptCredentialValidationOptions; + +const JptCredentialValidatorFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jptcredentialvalidator_free(ptr >>> 0, 1)); +/** +*/ +class JptCredentialValidator { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JptCredentialValidatorFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jptcredentialvalidator_free(ptr, 0); + } + /** + * @param {Jpt} credential_jpt + * @param {CoreDocument | IToCoreDocument} issuer + * @param {JptCredentialValidationOptions} options + * @param {FailFast} fail_fast + * @returns {DecodedJptCredential} + */ + static validate(credential_jpt, issuer, options, fail_fast) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential_jpt, Jpt); + _assertClass(options, JptCredentialValidationOptions); + wasm.jptcredentialvalidator_validate(retptr, credential_jpt.__wbg_ptr, addBorrowedObject(issuer), options.__wbg_ptr, fail_fast); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DecodedJptCredential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.JptCredentialValidator = JptCredentialValidator; + +const JptCredentialValidatorUtilsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jptcredentialvalidatorutils_free(ptr >>> 0, 1)); +/** +* Utility functions for validating JPT credentials. +*/ +class JptCredentialValidatorUtils { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JptCredentialValidatorUtilsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jptcredentialvalidatorutils_free(ptr, 0); + } + /** + */ + constructor() { + const ret = wasm.jptcredentialvalidatorutils_new(); + this.__wbg_ptr = ret >>> 0; + JptCredentialValidatorUtilsFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Utility for extracting the issuer field of a {@link Credential} as a DID. + * # Errors + * Fails if the issuer field is not a valid DID. + * @param {Credential} credential + * @returns {CoreDID} + */ + static extractIssuer(credential) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + wasm.jptcredentialvalidatorutils_extractIssuer(retptr, credential.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Utility for extracting the issuer field of a credential in JPT representation as DID. + * # Errors + * If the JPT decoding fails or the issuer field is not a valid DID. + * @param {Jpt} credential + * @returns {CoreDID} + */ + static extractIssuerFromIssuedJpt(credential) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Jpt); + wasm.jptcredentialvalidatorutils_extractIssuerFromIssuedJpt(retptr, credential.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {Credential} credential + * @param {Timestamp | undefined} validity_timeframe + * @param {StatusCheck} status_check + */ + static checkTimeframesWithValidityTimeframe2024(credential, validity_timeframe, status_check) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + let ptr0 = 0; + if (!isLikeNone(validity_timeframe)) { + _assertClass(validity_timeframe, Timestamp); + ptr0 = validity_timeframe.__destroy_into_raw(); + } + wasm.jptcredentialvalidatorutils_checkTimeframesWithValidityTimeframe2024(retptr, credential.__wbg_ptr, ptr0, status_check); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Checks whether the credential status has been revoked. + * + * Only supports `RevocationTimeframe2024`. + * @param {Credential} credential + * @param {CoreDocument | IToCoreDocument} issuer + * @param {StatusCheck} status_check + */ + static checkRevocationWithValidityTimeframe2024(credential, issuer, status_check) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + wasm.jptcredentialvalidatorutils_checkRevocationWithValidityTimeframe2024(retptr, credential.__wbg_ptr, addBorrowedObject(issuer), status_check); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Checks whether the credential status has been revoked or the timeframe interval is INVALID + * + * Only supports `RevocationTimeframe2024`. + * @param {Credential} credential + * @param {CoreDocument | IToCoreDocument} issuer + * @param {Timestamp | undefined} validity_timeframe + * @param {StatusCheck} status_check + */ + static checkTimeframesAndRevocationWithValidityTimeframe2024(credential, issuer, validity_timeframe, status_check) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + let ptr0 = 0; + if (!isLikeNone(validity_timeframe)) { + _assertClass(validity_timeframe, Timestamp); + ptr0 = validity_timeframe.__destroy_into_raw(); + } + wasm.jptcredentialvalidatorutils_checkTimeframesAndRevocationWithValidityTimeframe2024(retptr, credential.__wbg_ptr, addBorrowedObject(issuer), ptr0, status_check); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.JptCredentialValidatorUtils = JptCredentialValidatorUtils; + +const JptPresentationValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jptpresentationvalidationoptions_free(ptr >>> 0, 1)); +/** +* Options to declare validation criteria for a {@link Jpt} presentation. +*/ +class JptPresentationValidationOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JptPresentationValidationOptions.prototype); + obj.__wbg_ptr = ptr; + JptPresentationValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JptPresentationValidationOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jptpresentationvalidationoptions_free(ptr, 0); + } + /** + * Deep clones the object. + * @returns {JptPresentationValidationOptions} + */ + clone() { + const ret = wasm.jptpresentationvalidationoptions_clone(this.__wbg_ptr); + return JptPresentationValidationOptions.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jptpresentationvalidationoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JptPresentationValidationOptions} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jptpresentationvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JptPresentationValidationOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * @param {IJptPresentationValidationOptions | undefined} [opts] + */ + constructor(opts) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jptpresentationvalidationoptions_new(retptr, isLikeNone(opts) ? 0 : addHeapObject(opts)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + JptPresentationValidationOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.JptPresentationValidationOptions = JptPresentationValidationOptions; + +const JptPresentationValidatorFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jptpresentationvalidator_free(ptr >>> 0, 1)); +/** +*/ +class JptPresentationValidator { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JptPresentationValidatorFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jptpresentationvalidator_free(ptr, 0); + } + /** + * Decodes and validates a Presented {@link Credential} issued as a JPT (JWP Presented Form). A + * {@link DecodedJptPresentation} is returned upon success. + * + * The following properties are validated according to `options`: + * - the holder's proof on the JWP, + * - the expiration date, + * - the issuance date, + * - the semantic structure. + * @param {Jpt} presentation_jpt + * @param {CoreDocument | IToCoreDocument} issuer + * @param {JptPresentationValidationOptions} options + * @param {FailFast} fail_fast + * @returns {DecodedJptPresentation} + */ + static validate(presentation_jpt, issuer, options, fail_fast) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(presentation_jpt, Jpt); + _assertClass(options, JptPresentationValidationOptions); + wasm.jptpresentationvalidator_validate(retptr, presentation_jpt.__wbg_ptr, addBorrowedObject(issuer), options.__wbg_ptr, fail_fast); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DecodedJptPresentation.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.JptPresentationValidator = JptPresentationValidator; + +const JptPresentationValidatorUtilsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jptpresentationvalidatorutils_free(ptr >>> 0, 1)); +/** +* Utility functions for verifying JPT presentations. +*/ +class JptPresentationValidatorUtils { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JptPresentationValidatorUtilsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jptpresentationvalidatorutils_free(ptr, 0); + } + /** + * Utility for extracting the issuer field of a credential in JPT representation as DID. + * # Errors + * If the JPT decoding fails or the issuer field is not a valid DID. + * @param {Jpt} presentation + * @returns {CoreDID} + */ + static extractIssuerFromPresentedJpt(presentation) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(presentation, Jpt); + wasm.jptpresentationvalidatorutils_extractIssuerFromPresentedJpt(retptr, presentation.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Check timeframe interval in credentialStatus with `RevocationTimeframeStatus`. + * @param {Credential} credential + * @param {Timestamp | undefined} validity_timeframe + * @param {StatusCheck} status_check + */ + static checkTimeframesWithValidityTimeframe2024(credential, validity_timeframe, status_check) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + let ptr0 = 0; + if (!isLikeNone(validity_timeframe)) { + _assertClass(validity_timeframe, Timestamp); + ptr0 = validity_timeframe.__destroy_into_raw(); + } + wasm.jptpresentationvalidatorutils_checkTimeframesWithValidityTimeframe2024(retptr, credential.__wbg_ptr, ptr0, status_check); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.JptPresentationValidatorUtils = JptPresentationValidatorUtils; + +const JwkFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwk_free(ptr >>> 0, 1)); +/** +*/ +class Jwk { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Jwk.prototype); + obj.__wbg_ptr = ptr; + JwkFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwkFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwk_free(ptr, 0); + } + /** + * @param {IJwkParams} jwk + */ + constructor(jwk) { + const ret = wasm.jwk_new(addHeapObject(jwk)); + this.__wbg_ptr = ret >>> 0; + JwkFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Returns the value for the key type parameter (kty). + * @returns {JwkType} + */ + kty() { + const ret = wasm.jwk_kty(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns the value for the use property (use). + * @returns {JwkUse | undefined} + */ + use() { + const ret = wasm.jwk_use(this.__wbg_ptr); + return takeObject(ret); + } + /** + * @returns {Array} + */ + keyOps() { + const ret = wasm.jwk_keyOps(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns the value for the algorithm property (alg). + * @returns {JwsAlgorithm | undefined} + */ + alg() { + const ret = wasm.jwk_alg(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns the value of the key ID property (kid). + * @returns {string | undefined} + */ + kid() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_kid(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the X.509 URL property (x5u). + * @returns {string | undefined} + */ + x5u() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_x5u(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the X.509 certificate chain property (x5c). + * @returns {Array} + */ + x5c() { + const ret = wasm.jwk_x5c(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns the value of the X.509 certificate SHA-1 thumbprint property (x5t). + * @returns {string | undefined} + */ + x5t() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_x5t(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the X.509 certificate SHA-256 thumbprint property (x5t#S256). + * @returns {string | undefined} + */ + x5t256() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_x5t256(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * If this JWK is of kty EC, returns those parameters. + * @returns {JwkParamsEc | undefined} + */ + paramsEc() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_paramsEc(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * If this JWK is of kty OKP, returns those parameters. + * @returns {JwkParamsOkp | undefined} + */ + paramsOkp() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_paramsOkp(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * If this JWK is of kty OCT, returns those parameters. + * @returns {JwkParamsOct | undefined} + */ + paramsOct() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_paramsOct(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * If this JWK is of kty RSA, returns those parameters. + * @returns {JwkParamsRsa | undefined} + */ + paramsRsa() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_paramsRsa(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a clone of the {@link Jwk} with _all_ private key components unset. + * Nothing is returned when `kty = oct` as this key type is not considered public by this library. + * @returns {Jwk | undefined} + */ + toPublic() { + const ret = wasm.jwk_toPublic(this.__wbg_ptr); + return ret === 0 ? undefined : Jwk.__wrap(ret); + } + /** + * Returns `true` if _all_ private key components of the key are unset, `false` otherwise. + * @returns {boolean} + */ + isPublic() { + const ret = wasm.jwk_isPublic(this.__wbg_ptr); + return ret !== 0; + } + /** + * Returns `true` if _all_ private key components of the key are set, `false` otherwise. + * @returns {boolean} + */ + isPrivate() { + const ret = wasm.jwk_isPrivate(this.__wbg_ptr); + return ret !== 0; + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Jwk} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwk_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Jwk.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {Jwk} + */ + clone() { + const ret = wasm.jwk_clone(this.__wbg_ptr); + return Jwk.__wrap(ret); + } +} +module.exports.Jwk = Jwk; + +const JwkGenOutputFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwkgenoutput_free(ptr >>> 0, 1)); +/** +* The result of a key generation in `JwkStorage`. +*/ +class JwkGenOutput { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwkGenOutput.prototype); + obj.__wbg_ptr = ptr; + JwkGenOutputFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwkGenOutputFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwkgenoutput_free(ptr, 0); + } + /** + * @param {string} key_id + * @param {Jwk} jwk + */ + constructor(key_id, jwk) { + const ptr0 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(jwk, Jwk); + const ret = wasm.jwkgenoutput_new(ptr0, len0, jwk.__wbg_ptr); + this.__wbg_ptr = ret >>> 0; + JwkGenOutputFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Returns the generated public {@link Jwk}. + * @returns {Jwk} + */ + jwk() { + const ret = wasm.jwkgenoutput_jwk(this.__wbg_ptr); + return Jwk.__wrap(ret); + } + /** + * Returns the key id of the generated {@link Jwk}. + * @returns {string} + */ + keyId() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwkgenoutput_keyId(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwkgenoutput_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JwkGenOutput} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwkgenoutput_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwkGenOutput.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {JwkGenOutput} + */ + clone() { + const ret = wasm.jwkgenoutput_clone(this.__wbg_ptr); + return JwkGenOutput.__wrap(ret); + } +} +module.exports.JwkGenOutput = JwkGenOutput; + +const JwkStorageFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwkstorage_free(ptr >>> 0, 1)); + +class JwkStorage { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwkStorageFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwkstorage_free(ptr, 0); + } + /** + * Generates a new BBS+ keypair. + * @param {ProofAlgorithm} alg + * @returns {Promise} + */ + generateBBS(alg) { + const ret = wasm.jwkstorage_generateBBS(this.__wbg_ptr, alg); + return takeObject(ret); + } + /** + * @param {string} key_id + * @param {(Uint8Array)[]} data + * @param {Jwk} public_key + * @param {Uint8Array | undefined} [header] + * @returns {Promise} + */ + signBBS(key_id, data, public_key, header) { + const ptr0 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passArrayJsValueToWasm0(data, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(public_key, Jwk); + var ptr2 = public_key.__destroy_into_raw(); + var ptr3 = isLikeNone(header) ? 0 : passArray8ToWasm0(header, wasm.__wbindgen_malloc); + var len3 = WASM_VECTOR_LEN; + const ret = wasm.jwkstorage_signBBS(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, ptr3, len3); + return takeObject(ret); + } + /** + * @param {string} key_id + * @param {Jwk} public_key + * @param {Uint8Array} signature + * @param {ProofUpdateCtx} ctx + * @returns {Promise} + */ + updateBBSSignature(key_id, public_key, signature, ctx) { + const ptr0 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(public_key, Jwk); + const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); + const len1 = WASM_VECTOR_LEN; + _assertClass(ctx, ProofUpdateCtx); + var ptr2 = ctx.__destroy_into_raw(); + const ret = wasm.jwkstorage_updateBBSSignature(this.__wbg_ptr, ptr0, len0, public_key.__wbg_ptr, ptr1, len1, ptr2); + return takeObject(ret); + } +} +module.exports.JwkStorage = JwkStorage; + +const JwpCredentialOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwpcredentialoptions_free(ptr >>> 0, 1)); +/** +*/ +class JwpCredentialOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwpCredentialOptions.prototype); + obj.__wbg_ptr = ptr; + JwpCredentialOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + kid: this.kid, + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwpCredentialOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwpcredentialoptions_free(ptr, 0); + } + /** + * @returns {string | undefined} + */ + get kid() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_jwpcredentialoptions_kid(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {string | undefined} [arg0] + */ + set kid(arg0) { + var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_jwpcredentialoptions_kid(this.__wbg_ptr, ptr0, len0); + } + /** + */ + constructor() { + const ret = wasm.jwpcredentialoptions_new(); + this.__wbg_ptr = ret >>> 0; + JwpCredentialOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * @param {any} value + * @returns {JwpCredentialOptions} + */ + static fromJSON(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwpcredentialoptions_fromJSON(retptr, addHeapObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwpCredentialOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwpcredentialoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.JwpCredentialOptions = JwpCredentialOptions; + +const JwpIssuedFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwpissued_free(ptr >>> 0, 1)); +/** +*/ +class JwpIssued { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwpIssued.prototype); + obj.__wbg_ptr = ptr; + JwpIssuedFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwpIssuedFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwpissued_free(ptr, 0); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwpissued_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JwpIssued} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwpissued_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwpIssued.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {JwpIssued} + */ + clone() { + const ret = wasm.jwpissued_clone(this.__wbg_ptr); + return JwpIssued.__wrap(ret); + } + /** + * @param {SerializationType} serialization + * @returns {string} + */ + encode(serialization) { + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwpissued_encode(retptr, this.__wbg_ptr, serialization); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + var ptr1 = r0; + var len1 = r1; + if (r3) { + ptr1 = 0; len1 = 0; + throw takeObject(r2); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } + } + /** + * @param {Uint8Array} proof + */ + setProof(proof) { + const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwpissued_setProof(this.__wbg_ptr, ptr0, len0); + } + /** + * @returns {Uint8Array} + */ + getProof() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwpissued_getProof(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Payloads} + */ + getPayloads() { + const ret = wasm.jwpissued_getPayloads(this.__wbg_ptr); + return Payloads.__wrap(ret); + } + /** + * @param {Payloads} payloads + */ + setPayloads(payloads) { + _assertClass(payloads, Payloads); + var ptr0 = payloads.__destroy_into_raw(); + wasm.jwpissued_setPayloads(this.__wbg_ptr, ptr0); + } + /** + * @returns {IssuerProtectedHeader} + */ + getIssuerProtectedHeader() { + const ret = wasm.jwpissued_getIssuerProtectedHeader(this.__wbg_ptr); + return IssuerProtectedHeader.__wrap(ret); + } +} +module.exports.JwpIssued = JwpIssued; + +const JwpPresentationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwppresentationoptions_free(ptr >>> 0, 1)); +/** +* Options to be set in the JWT claims of a verifiable presentation. +*/ +class JwpPresentationOptions { + + toJSON() { + return { + audience: this.audience, + nonce: this.nonce, + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwpPresentationOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwppresentationoptions_free(ptr, 0); + } + /** + * Sets the audience for presentation (`aud` property in JWP Presentation Header). + * @returns {string | undefined} + */ + get audience() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_jwpcredentialoptions_kid(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the audience for presentation (`aud` property in JWP Presentation Header). + * @param {string | undefined} [arg0] + */ + set audience(arg0) { + var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_jwpcredentialoptions_kid(this.__wbg_ptr, ptr0, len0); + } + /** + * The nonce to be placed in the Presentation Protected Header. + * @returns {string | undefined} + */ + get nonce() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_issuerprotectedheader_typ(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * The nonce to be placed in the Presentation Protected Header. + * @param {string | undefined} [arg0] + */ + set nonce(arg0) { + var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_issuerprotectedheader_typ(this.__wbg_ptr, ptr0, len0); + } + /** + */ + constructor() { + const ret = wasm.jwppresentationoptions_new(); + this.__wbg_ptr = ret >>> 0; + JwpPresentationOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } +} +module.exports.JwpPresentationOptions = JwpPresentationOptions; + +const JwpVerificationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwpverificationoptions_free(ptr >>> 0, 1)); +/** +*/ +class JwpVerificationOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwpVerificationOptions.prototype); + obj.__wbg_ptr = ptr; + JwpVerificationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwpVerificationOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwpverificationoptions_free(ptr, 0); + } + /** + * Deep clones the object. + * @returns {JwpVerificationOptions} + */ + clone() { + const ret = wasm.jwpverificationoptions_clone(this.__wbg_ptr); + return JwpVerificationOptions.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwpverificationoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JwpVerificationOptions} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwpverificationoptions_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwpVerificationOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * @param {IJwpVerificationOptions | undefined} [opts] + * @returns {JwpVerificationOptions} + */ + static new(opts) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwpverificationoptions_new(retptr, isLikeNone(opts) ? 0 : addHeapObject(opts)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwpVerificationOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.JwpVerificationOptions = JwpVerificationOptions; + +const JwsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jws_free(ptr >>> 0, 1)); +/** +* A wrapper around a JSON Web Signature (JWS). +*/ +class Jws { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Jws.prototype); + obj.__wbg_ptr = ptr; + JwsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jws_free(ptr, 0); + } + /** + * Creates a new {@link Jws} from the given string. + * @param {string} jws_string + */ + constructor(jws_string) { + const ptr0 = passStringToWasm0(jws_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.jws_constructor(ptr0, len0); + this.__wbg_ptr = ret >>> 0; + JwsFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Returns a clone of the JWS string. + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jws_toString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } +} +module.exports.Jws = Jws; + +const JwsHeaderFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwsheader_free(ptr >>> 0, 1)); +/** +*/ +class JwsHeader { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwsHeader.prototype); + obj.__wbg_ptr = ptr; + JwsHeaderFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwsHeaderFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwsheader_free(ptr, 0); + } + /** + * Create a new empty {@link JwsHeader}. + */ + constructor() { + const ret = wasm.jwsheader_new(); + this.__wbg_ptr = ret >>> 0; + JwsHeaderFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Returns the value for the algorithm claim (alg). + * @returns {JwsAlgorithm | undefined} + */ + alg() { + const ret = wasm.jwsheader_alg(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Sets a value for the algorithm claim (alg). + * @param {JwsAlgorithm} value + */ + setAlg(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_setAlg(retptr, this.__wbg_ptr, addHeapObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the base64url-encode payload claim (b64). + * @returns {boolean | undefined} + */ + b64() { + const ret = wasm.jwsheader_b64(this.__wbg_ptr); + return ret === 0xFFFFFF ? undefined : ret !== 0; + } + /** + * Sets a value for the base64url-encode payload claim (b64). + * @param {boolean} value + */ + setB64(value) { + wasm.jwsheader_setB64(this.__wbg_ptr, value); + } + /** + * Additional header parameters. + * @returns {Record | undefined} + */ + custom() { + const ret = wasm.jwsheader_custom(this.__wbg_ptr); + return takeObject(ret); + } + /** + * @param {string} claim + * @returns {boolean} + */ + has(claim) { + const ptr0 = passStringToWasm0(claim, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.jwsheader_has(this.__wbg_ptr, ptr0, len0); + return ret !== 0; + } + /** + * Returns `true` if none of the fields are set in both `self` and `other`. + * @param {JwsHeader} other + * @returns {boolean} + */ + isDisjoint(other) { + _assertClass(other, JwsHeader); + const ret = wasm.jwsheader_isDisjoint(this.__wbg_ptr, other.__wbg_ptr); + return ret !== 0; + } + /** + * Returns the value of the JWK Set URL claim (jku). + * @returns {string | undefined} + */ + jku() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_jku(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a value for the JWK Set URL claim (jku). + * @param {string} value + */ + setJku(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsheader_setJku(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the JWK claim (jwk). + * @returns {Jwk | undefined} + */ + jwk() { + const ret = wasm.jwsheader_jwk(this.__wbg_ptr); + return ret === 0 ? undefined : Jwk.__wrap(ret); + } + /** + * Sets a value for the JWK claim (jwk). + * @param {Jwk} value + */ + setJwk(value) { + _assertClass(value, Jwk); + wasm.jwsheader_setJwk(this.__wbg_ptr, value.__wbg_ptr); + } + /** + * Returns the value of the key ID claim (kid). + * @returns {string | undefined} + */ + kid() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_kid(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a value for the key ID claim (kid). + * @param {string} value + */ + setKid(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsheader_setKid(this.__wbg_ptr, ptr0, len0); + } + /** + * Returns the value of the X.509 URL claim (x5u). + * @returns {string | undefined} + */ + x5u() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_x5u(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a value for the X.509 URL claim (x5u). + * @param {string} value + */ + setX5u(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsheader_setX5u(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the X.509 certificate chain claim (x5c). + * @returns {Array} + */ + x5c() { + const ret = wasm.jwsheader_crit(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Sets values for the X.509 certificate chain claim (x5c). + * @param {Array} value + */ + setX5c(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_setX5c(retptr, this.__wbg_ptr, addHeapObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the X.509 certificate SHA-1 thumbprint claim (x5t). + * @returns {string | undefined} + */ + x5t() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_x5t(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a value for the X.509 certificate SHA-1 thumbprint claim (x5t). + * @param {string} value + */ + setX5t(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsheader_setX5t(this.__wbg_ptr, ptr0, len0); + } + /** + * Returns the value of the X.509 certificate SHA-256 thumbprint claim + * (x5t#S256). + * @returns {string | undefined} + */ + x5tS256() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_x5tS256(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a value for the X.509 certificate SHA-256 thumbprint claim + * (x5t#S256). + * @param {string} value + */ + setX5tS256(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsheader_setX5tS256(this.__wbg_ptr, ptr0, len0); + } + /** + * Returns the value of the token type claim (typ). + * @returns {string | undefined} + */ + typ() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_typ(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a value for the token type claim (typ). + * @param {string} value + */ + setTyp(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsheader_setTyp(this.__wbg_ptr, ptr0, len0); + } + /** + * Returns the value of the content type claim (cty). + * @returns {string | undefined} + */ + cty() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_cty(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a value for the content type claim (cty). + * @param {string} value + */ + setCty(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsheader_setCty(this.__wbg_ptr, ptr0, len0); + } + /** + * Returns the value of the critical claim (crit). + * @returns {Array} + */ + crit() { + const ret = wasm.jwsheader_crit(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Sets values for the critical claim (crit). + * @param {Array} value + */ + setCrit(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_setCrit(retptr, this.__wbg_ptr, addHeapObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the url claim (url). + * @returns {string | undefined} + */ + url() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_url(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a value for the url claim (url). + * @param {string} value + */ + setUrl(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsheader_setUrl(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the nonce claim (nonce). + * @returns {string | undefined} + */ + nonce() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_nonce(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets a value for the nonce claim (nonce). + * @param {string} value + */ + setNonce(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsheader_setNonce(this.__wbg_ptr, ptr0, len0); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JwsHeader} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsheader_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwsHeader.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {JwsHeader} + */ + clone() { + const ret = wasm.jwsheader_clone(this.__wbg_ptr); + return JwsHeader.__wrap(ret); + } +} +module.exports.JwsHeader = JwsHeader; + +const JwsSignatureOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwssignatureoptions_free(ptr >>> 0, 1)); +/** +*/ +class JwsSignatureOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwsSignatureOptions.prototype); + obj.__wbg_ptr = ptr; + JwsSignatureOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwsSignatureOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwssignatureoptions_free(ptr, 0); + } + /** + * @param {IJwsSignatureOptions | undefined} [options] + */ + constructor(options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwssignatureoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + JwsSignatureOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Replace the value of the `attachJwk` field. + * @param {boolean} value + */ + setAttachJwk(value) { + wasm.jwssignatureoptions_setAttachJwk(this.__wbg_ptr, value); + } + /** + * Replace the value of the `b64` field. + * @param {boolean} value + */ + setB64(value) { + wasm.jwssignatureoptions_setB64(this.__wbg_ptr, value); + } + /** + * Replace the value of the `typ` field. + * @param {string} value + */ + setTyp(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwssignatureoptions_setTyp(this.__wbg_ptr, ptr0, len0); + } + /** + * Replace the value of the `cty` field. + * @param {string} value + */ + setCty(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwssignatureoptions_setCty(this.__wbg_ptr, ptr0, len0); + } + /** + * Replace the value of the `url` field. + * @param {string} value + */ + serUrl(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwssignatureoptions_serUrl(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Replace the value of the `nonce` field. + * @param {string} value + */ + setNonce(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwssignatureoptions_setNonce(this.__wbg_ptr, ptr0, len0); + } + /** + * Replace the value of the `kid` field. + * @param {string} value + */ + setKid(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwssignatureoptions_setKid(this.__wbg_ptr, ptr0, len0); + } + /** + * Replace the value of the `detached_payload` field. + * @param {boolean} value + */ + setDetachedPayload(value) { + wasm.jwssignatureoptions_setDetachedPayload(this.__wbg_ptr, value); + } + /** + * Add additional header parameters. + * @param {Record} value + */ + setCustomHeaderParameters(value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwssignatureoptions_setCustomHeaderParameters(retptr, this.__wbg_ptr, addHeapObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwssignatureoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JwsSignatureOptions} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwssignatureoptions_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwsSignatureOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {JwsSignatureOptions} + */ + clone() { + const ret = wasm.jwssignatureoptions_clone(this.__wbg_ptr); + return JwsSignatureOptions.__wrap(ret); + } +} +module.exports.JwsSignatureOptions = JwsSignatureOptions; + +const JwsVerificationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwsverificationoptions_free(ptr >>> 0, 1)); +/** +*/ +class JwsVerificationOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwsVerificationOptions.prototype); + obj.__wbg_ptr = ptr; + JwsVerificationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwsVerificationOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwsverificationoptions_free(ptr, 0); + } + /** + * Creates a new {@link JwsVerificationOptions} from the given fields. + * @param {IJwsVerificationOptions | undefined} [options] + */ + constructor(options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsverificationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + JwsVerificationOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Set the expected value for the `nonce` parameter of the protected header. + * @param {string} value + */ + setNonce(value) { + const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwsverificationoptions_setNonce(this.__wbg_ptr, ptr0, len0); + } + /** + * Set the scope of the verification methods that may be used to verify the given JWS. + * @param {MethodScope} value + */ + setMethodScope(value) { + _assertClass(value, MethodScope); + wasm.jwsverificationoptions_setMethodScope(this.__wbg_ptr, value.__wbg_ptr); + } + /** + * Set the DID URl of the method, whose JWK should be used to verify the JWS. + * @param {DIDUrl} value + */ + setMethodId(value) { + _assertClass(value, DIDUrl); + wasm.jwsverificationoptions_setMethodId(this.__wbg_ptr, value.__wbg_ptr); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsverificationoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JwsVerificationOptions} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwsverificationoptions_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwsVerificationOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {JwsVerificationOptions} + */ + clone() { + const ret = wasm.jwsverificationoptions_clone(this.__wbg_ptr); + return JwsVerificationOptions.__wrap(ret); + } +} +module.exports.JwsVerificationOptions = JwsVerificationOptions; + +const JwtFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwt_free(ptr >>> 0, 1)); +/** +* A wrapper around a JSON Web Token (JWK). +*/ +class Jwt { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Jwt.prototype); + obj.__wbg_ptr = ptr; + JwtFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwtFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwt_free(ptr, 0); + } + /** + * Creates a new {@link Jwt} from the given string. + * @param {string} jwt_string + */ + constructor(jwt_string) { + const ptr0 = passStringToWasm0(jwt_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.jwt_constructor(ptr0, len0); + this.__wbg_ptr = ret >>> 0; + JwtFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Returns a clone of the JWT string. + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwt_toString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwt_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Jwt} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwt_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Jwt.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {Jwt} + */ + clone() { + const ret = wasm.jwt_clone(this.__wbg_ptr); + return Jwt.__wrap(ret); + } +} +module.exports.Jwt = Jwt; + +const JwtCredentialValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwtcredentialvalidationoptions_free(ptr >>> 0, 1)); +/** +* Options to declare validation criteria when validating credentials. +*/ +class JwtCredentialValidationOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwtCredentialValidationOptions.prototype); + obj.__wbg_ptr = ptr; + JwtCredentialValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwtCredentialValidationOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwtcredentialvalidationoptions_free(ptr, 0); + } + /** + * @param {IJwtCredentialValidationOptions | undefined} [options] + */ + constructor(options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwtcredentialvalidationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + JwtCredentialValidationOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwtcredentialvalidationoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JwtCredentialValidationOptions} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwtcredentialvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwtCredentialValidationOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {JwtCredentialValidationOptions} + */ + clone() { + const ret = wasm.jwtcredentialvalidationoptions_clone(this.__wbg_ptr); + return JwtCredentialValidationOptions.__wrap(ret); + } +} +module.exports.JwtCredentialValidationOptions = JwtCredentialValidationOptions; + +const JwtCredentialValidatorFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwtcredentialvalidator_free(ptr >>> 0, 1)); +/** +* A type for decoding and validating {@link Credential}. +*/ +class JwtCredentialValidator { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwtCredentialValidatorFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwtcredentialvalidator_free(ptr, 0); + } + /** + * Creates a new {@link JwtCredentialValidator}. If a `signatureVerifier` is provided it will be used when + * verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` + * algorithm will be used. + * @param {IJwsVerifier} signatureVerifier + */ + constructor(signatureVerifier) { + const ret = wasm.jwtcredentialvalidator_new(addHeapObject(signatureVerifier)); + this.__wbg_ptr = ret >>> 0; + JwtCredentialValidatorFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Decodes and validates a {@link Credential} issued as a JWS. A {@link DecodedJwtCredential} is returned upon + * success. + * + * The following properties are validated according to `options`: + * - the issuer's signature on the JWS, + * - the expiration date, + * - the issuance date, + * - the semantic structure. + * + * # Warning + * The lack of an error returned from this method is in of itself not enough to conclude that the credential can be + * trusted. This section contains more information on additional checks that should be carried out before and after + * calling this method. + * + * ## The state of the issuer's DID Document + * The caller must ensure that `issuer` represents an up-to-date DID Document. + * + * ## Properties that are not validated + * There are many properties defined in [The Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/) that are **not** validated, such as: + * `proof`, `credentialStatus`, `type`, `credentialSchema`, `refreshService` **and more**. + * These should be manually checked after validation, according to your requirements. + * + * # Errors + * An error is returned whenever a validated condition is not satisfied. + * @param {Jwt} credential_jwt + * @param {CoreDocument | IToCoreDocument} issuer + * @param {JwtCredentialValidationOptions} options + * @param {FailFast} fail_fast + * @returns {DecodedJwtCredential} + */ + validate(credential_jwt, issuer, options, fail_fast) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential_jwt, Jwt); + _assertClass(options, JwtCredentialValidationOptions); + wasm.jwtcredentialvalidator_validate(retptr, this.__wbg_ptr, credential_jwt.__wbg_ptr, addBorrowedObject(issuer), options.__wbg_ptr, fail_fast); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DecodedJwtCredential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Decode and verify the JWS signature of a {@link Credential} issued as a JWT using the DID Document of a trusted + * issuer. + * + * A {@link DecodedJwtCredential} is returned upon success. + * + * # Warning + * The caller must ensure that the DID Documents of the trusted issuers are up-to-date. + * + * ## Proofs + * Only the JWS signature is verified. If the {@link Credential} contains a `proof` property this will not be + * verified by this method. + * + * # Errors + * This method immediately returns an error if + * the credential issuer' url cannot be parsed to a DID belonging to one of the trusted issuers. Otherwise an attempt + * to verify the credential's signature will be made and an error is returned upon failure. + * @param {Jwt} credential + * @param {Array} trustedIssuers + * @param {JwsVerificationOptions} options + * @returns {DecodedJwtCredential} + */ + verifySignature(credential, trustedIssuers, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Jwt); + _assertClass(options, JwsVerificationOptions); + wasm.jwtcredentialvalidator_verifySignature(retptr, this.__wbg_ptr, credential.__wbg_ptr, addBorrowedObject(trustedIssuers), options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DecodedJwtCredential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Validate that the credential expires on or after the specified timestamp. + * @param {Credential} credential + * @param {Timestamp} timestamp + */ + static checkExpiresOnOrAfter(credential, timestamp) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + _assertClass(timestamp, Timestamp); + wasm.jwtcredentialvalidator_checkExpiresOnOrAfter(retptr, credential.__wbg_ptr, timestamp.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Validate that the credential is issued on or before the specified timestamp. + * @param {Credential} credential + * @param {Timestamp} timestamp + */ + static checkIssuedOnOrBefore(credential, timestamp) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + _assertClass(timestamp, Timestamp); + wasm.jwtcredentialvalidator_checkIssuedOnOrBefore(retptr, credential.__wbg_ptr, timestamp.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Validate that the relationship between the `holder` and the credential subjects is in accordance with + * `relationship`. The `holder` parameter is expected to be the URL of the holder. + * @param {Credential} credential + * @param {string} holder + * @param {SubjectHolderRelationship} relationship + */ + static checkSubjectHolderRelationship(credential, holder, relationship) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + const ptr0 = passStringToWasm0(holder, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.jwtcredentialvalidator_checkSubjectHolderRelationship(retptr, credential.__wbg_ptr, ptr0, len0, relationship); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Checks whether the credential status has been revoked. + * + * Only supports `RevocationBitmap2022`. + * @param {Credential} credential + * @param {Array} trustedIssuers + * @param {StatusCheck} statusCheck + */ + static checkStatus(credential, trustedIssuers, statusCheck) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + wasm.jwtcredentialvalidator_checkStatus(retptr, credential.__wbg_ptr, addBorrowedObject(trustedIssuers), statusCheck); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Checks wheter the credential status has been revoked using `StatusList2021`. + * @param {Credential} credential + * @param {StatusList2021Credential} status_list + * @param {StatusCheck} status_check + */ + static checkStatusWithStatusList2021(credential, status_list, status_check) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + _assertClass(status_list, StatusList2021Credential); + wasm.jwtcredentialvalidator_checkStatusWithStatusList2021(retptr, credential.__wbg_ptr, status_list.__wbg_ptr, status_check); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Utility for extracting the issuer field of a {@link Credential} as a DID. + * + * ### Errors + * + * Fails if the issuer field is not a valid DID. + * @param {Credential} credential + * @returns {CoreDID} + */ + static extractIssuer(credential) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + wasm.jwtcredentialvalidator_extractIssuer(retptr, credential.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Utility for extracting the issuer field of a credential in JWT representation as DID. + * + * # Errors + * + * If the JWT decoding fails or the issuer field is not a valid DID. + * @param {Jwt} credential + * @returns {CoreDID} + */ + static extractIssuerFromJwt(credential) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Jwt); + wasm.jwtcredentialvalidator_extractIssuerFromJwt(retptr, credential.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.JwtCredentialValidator = JwtCredentialValidator; + +const JwtDomainLinkageValidatorFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwtdomainlinkagevalidator_free(ptr >>> 0, 1)); +/** +* A validator for a Domain Linkage Configuration and Credentials. +*/ +class JwtDomainLinkageValidator { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwtDomainLinkageValidatorFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwtdomainlinkagevalidator_free(ptr, 0); + } + /** + * Creates a new {@link JwtDomainLinkageValidator}. If a `signatureVerifier` is provided it will be used when + * verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` + * algorithm will be used. + * @param {IJwsVerifier} signatureVerifier + */ + constructor(signatureVerifier) { + const ret = wasm.jwtdomainlinkagevalidator_new(addHeapObject(signatureVerifier)); + this.__wbg_ptr = ret >>> 0; + JwtDomainLinkageValidatorFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Validates the linkage between a domain and a DID. + * {@link DomainLinkageConfiguration} is validated according to [DID Configuration Resource Verification](https://identity.foundation/.well-known/resources/did-configuration/#did-configuration-resource-verification). + * + * Linkage is valid if no error is thrown. + * + * # Note: + * - Only the [JSON Web Token Proof Format](https://identity.foundation/.well-known/resources/did-configuration/#json-web-token-proof-format) + * is supported. + * - Only the Credential issued by `issuer` is verified. + * + * # Errors + * + * - Semantic structure of `configuration` is invalid. + * - `configuration` includes multiple credentials issued by `issuer`. + * - Validation of the matched Domain Linkage Credential fails. + * @param {CoreDocument | IToCoreDocument} issuer + * @param {DomainLinkageConfiguration} configuration + * @param {string} domain + * @param {JwtCredentialValidationOptions} options + */ + validateLinkage(issuer, configuration, domain, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(configuration, DomainLinkageConfiguration); + const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(options, JwtCredentialValidationOptions); + wasm.jwtdomainlinkagevalidator_validateLinkage(retptr, this.__wbg_ptr, addBorrowedObject(issuer), configuration.__wbg_ptr, ptr0, len0, options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Validates a [Domain Linkage Credential](https://identity.foundation/.well-known/resources/did-configuration/#domain-linkage-credential). + * + * Error will be thrown in case the validation fails. + * @param {CoreDocument | IToCoreDocument} issuer + * @param {Jwt} credentialJwt + * @param {string} domain + * @param {JwtCredentialValidationOptions} options + */ + validateCredential(issuer, credentialJwt, domain, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credentialJwt, Jwt); + const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(options, JwtCredentialValidationOptions); + wasm.jwtdomainlinkagevalidator_validateCredential(retptr, this.__wbg_ptr, addBorrowedObject(issuer), credentialJwt.__wbg_ptr, ptr0, len0, options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.JwtDomainLinkageValidator = JwtDomainLinkageValidator; + +const JwtPresentationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwtpresentationoptions_free(ptr >>> 0, 1)); +/** +*/ +class JwtPresentationOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwtPresentationOptions.prototype); + obj.__wbg_ptr = ptr; + JwtPresentationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwtPresentationOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwtpresentationoptions_free(ptr, 0); + } + /** + * Creates a new {@link JwtPresentationOptions} from the given fields. + * + * Throws an error if any of the options are invalid. + * @param {IJwtPresentationOptions | undefined} [options] + */ + constructor(options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwtpresentationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + JwtPresentationOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwtpresentationoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JwtPresentationOptions} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwtpresentationoptions_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwtPresentationOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {JwtPresentationOptions} + */ + clone() { + const ret = wasm.jwtpresentationoptions_clone(this.__wbg_ptr); + return JwtPresentationOptions.__wrap(ret); + } +} +module.exports.JwtPresentationOptions = JwtPresentationOptions; + +const JwtPresentationValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwtpresentationvalidationoptions_free(ptr >>> 0, 1)); +/** +* Options to declare validation criteria when validating presentation. +*/ +class JwtPresentationValidationOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(JwtPresentationValidationOptions.prototype); + obj.__wbg_ptr = ptr; + JwtPresentationValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwtPresentationValidationOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwtpresentationvalidationoptions_free(ptr, 0); + } + /** + * Creates a new {@link JwtPresentationValidationOptions} from the given fields. + * + * Throws an error if any of the options are invalid. + * @param {IJwtPresentationValidationOptions | undefined} [options] + */ + constructor(options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwtpresentationvalidationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + JwtPresentationValidationOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwtpresentationvalidationoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {JwtPresentationValidationOptions} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.jwtpresentationvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return JwtPresentationValidationOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {JwtPresentationValidationOptions} + */ + clone() { + const ret = wasm.jwtpresentationvalidationoptions_clone(this.__wbg_ptr); + return JwtPresentationValidationOptions.__wrap(ret); + } +} +module.exports.JwtPresentationValidationOptions = JwtPresentationValidationOptions; + +const JwtPresentationValidatorFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_jwtpresentationvalidator_free(ptr >>> 0, 1)); +/** +*/ +class JwtPresentationValidator { + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + JwtPresentationValidatorFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_jwtpresentationvalidator_free(ptr, 0); + } + /** + * Creates a new {@link JwtPresentationValidator}. If a `signatureVerifier` is provided it will be used when + * verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` + * algorithm will be used. + * @param {IJwsVerifier} signatureVerifier + */ + constructor(signatureVerifier) { + const ret = wasm.jwtpresentationvalidator_new(addHeapObject(signatureVerifier)); + this.__wbg_ptr = ret >>> 0; + JwtPresentationValidatorFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Validates a {@link Presentation} encoded as a {@link Jwt}. + * + * The following properties are validated according to `options`: + * - the JWT can be decoded into a semantically valid presentation. + * - the expiration and issuance date contained in the JWT claims. + * - the holder's signature. + * + * Validation is done with respect to the properties set in `options`. + * + * # Warning + * + * * This method does NOT validate the constituent credentials and therefore also not the relationship between the + * credentials' subjects and the presentation holder. This can be done with {@link JwtCredentialValidationOptions}. + * * The lack of an error returned from this method is in of itself not enough to conclude that the presentation can + * be trusted. This section contains more information on additional checks that should be carried out before and + * after calling this method. + * + * ## The state of the supplied DID Documents. + * + * The caller must ensure that the DID Documents in `holder` are up-to-date. + * + * # Errors + * + * An error is returned whenever a validated condition is not satisfied or when decoding fails. + * @param {Jwt} presentationJwt + * @param {CoreDocument | IToCoreDocument} holder + * @param {JwtPresentationValidationOptions} validation_options + * @returns {DecodedJwtPresentation} + */ + validate(presentationJwt, holder, validation_options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(presentationJwt, Jwt); + _assertClass(validation_options, JwtPresentationValidationOptions); + wasm.jwtpresentationvalidator_validate(retptr, this.__wbg_ptr, presentationJwt.__wbg_ptr, addBorrowedObject(holder), validation_options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DecodedJwtPresentation.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Validates the semantic structure of the {@link Presentation}. + * @param {Presentation} presentation + */ + static checkStructure(presentation) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(presentation, Presentation); + wasm.jwtpresentationvalidator_checkStructure(retptr, presentation.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Attempt to extract the holder of the presentation. + * + * # Errors: + * * If deserialization/decoding of the presentation fails. + * * If the holder can't be parsed as DIDs. + * @param {Jwt} presentation + * @returns {CoreDID} + */ + static extractHolder(presentation) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(presentation, Jwt); + wasm.jwtpresentationvalidator_extractHolder(retptr, presentation.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CoreDID.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.JwtPresentationValidator = JwtPresentationValidator; + +const KeyBindingJWTValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_keybindingjwtvalidationoptions_free(ptr >>> 0, 1)); +/** +* Options to declare validation criteria when validating credentials. +*/ +class KeyBindingJWTValidationOptions { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(KeyBindingJWTValidationOptions.prototype); + obj.__wbg_ptr = ptr; + KeyBindingJWTValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + KeyBindingJWTValidationOptionsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_keybindingjwtvalidationoptions_free(ptr, 0); + } + /** + * @param {IKeyBindingJWTValidationOptions | undefined} [options] + */ + constructor(options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtvalidationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + KeyBindingJWTValidationOptionsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtvalidationoptions_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {KeyBindingJWTValidationOptions} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return KeyBindingJWTValidationOptions.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {KeyBindingJWTValidationOptions} + */ + clone() { + const ret = wasm.keybindingjwtvalidationoptions_clone(this.__wbg_ptr); + return KeyBindingJWTValidationOptions.__wrap(ret); + } +} +module.exports.KeyBindingJWTValidationOptions = KeyBindingJWTValidationOptions; + +const KeyBindingJwtClaimsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_keybindingjwtclaims_free(ptr >>> 0, 1)); +/** +* Claims set for key binding JWT. +*/ +class KeyBindingJwtClaims { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(KeyBindingJwtClaims.prototype); + obj.__wbg_ptr = ptr; + KeyBindingJwtClaimsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + KeyBindingJwtClaimsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_keybindingjwtclaims_free(ptr, 0); + } + /** + * Creates a new [`KeyBindingJwtClaims`]. + * When `issued_at` is left as None, it will automatically default to the current time. + * + * # Error + * When `issued_at` is set to `None` and the system returns time earlier than `SystemTime::UNIX_EPOCH`. + * @param {string} jwt + * @param {Array} disclosures + * @param {string} nonce + * @param {string} aud + * @param {Timestamp | undefined} [issued_at] + * @param {Record | undefined} [custom_properties] + */ + constructor(jwt, disclosures, nonce, aud, issued_at, custom_properties) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ptr1 = passStringToWasm0(nonce, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + const ptr2 = passStringToWasm0(aud, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len2 = WASM_VECTOR_LEN; + let ptr3 = 0; + if (!isLikeNone(issued_at)) { + _assertClass(issued_at, Timestamp); + ptr3 = issued_at.__destroy_into_raw(); + } + wasm.keybindingjwtclaims_new(retptr, ptr0, len0, addHeapObject(disclosures), ptr1, len1, ptr2, len2, ptr3, isLikeNone(custom_properties) ? 0 : addHeapObject(custom_properties)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + KeyBindingJwtClaimsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a string representation of the claims. + * @returns {string} + */ + toString() { + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtclaims_toString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + var ptr1 = r0; + var len1 = r1; + if (r3) { + ptr1 = 0; len1 = 0; + throw takeObject(r2); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } + } + /** + * Returns a copy of the issued at `iat` property. + * @returns {bigint} + */ + iat() { + const ret = wasm.keybindingjwtclaims_iat(this.__wbg_ptr); + return ret; + } + /** + * Returns a copy of the audience `aud` property. + * @returns {string} + */ + aud() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtclaims_aud(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the `nonce` property. + * @returns {string} + */ + nonce() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtclaims_nonce(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the `sd_hash` property. + * @returns {string} + */ + sdHash() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtclaims_sdHash(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the custom properties. + * @returns {Record} + */ + customProperties() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtclaims_customProperties(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the value of the `typ` property of the JWT header according to + * https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-key-binding-jwt + * @returns {string} + */ + static keyBindingJwtHeaderTyp() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtclaims_keyBindingJwtHeaderTyp(retptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtclaims_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {KeyBindingJwtClaims} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.keybindingjwtclaims_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return KeyBindingJwtClaims.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {KeyBindingJwtClaims} + */ + clone() { + const ret = wasm.keybindingjwtclaims_clone(this.__wbg_ptr); + return KeyBindingJwtClaims.__wrap(ret); + } +} +module.exports.KeyBindingJwtClaims = KeyBindingJwtClaims; + +const LinkedDomainServiceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_linkeddomainservice_free(ptr >>> 0, 1)); +/** +*/ +class LinkedDomainService { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(LinkedDomainService.prototype); + obj.__wbg_ptr = ptr; + LinkedDomainServiceFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + LinkedDomainServiceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_linkeddomainservice_free(ptr, 0); + } + /** + * Constructs a new {@link LinkedDomainService} that wraps a spec compliant [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint). + * + * Domain URLs must include the `https` scheme in order to pass the domain linkage validation. + * @param {ILinkedDomainService} options + */ + constructor(options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.linkeddomainservice_new(retptr, addHeapObject(options)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + LinkedDomainServiceFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the domains contained in the Linked Domain Service. + * @returns {Array} + */ + domains() { + const ret = wasm.linkeddomainservice_domains(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns the inner service which can be added to a DID Document. + * @returns {Service} + */ + toService() { + const ret = wasm.linkeddomainservice_toService(this.__wbg_ptr); + return Service.__wrap(ret); + } + /** + * Creates a new {@link LinkedDomainService} from a {@link Service}. + * + * # Error + * + * Errors if `service` is not a valid Linked Domain Service. + * @param {Service} service + * @returns {LinkedDomainService} + */ + static fromService(service) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(service, Service); + wasm.linkeddomainservice_fromService(retptr, service.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return LinkedDomainService.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns `true` if a {@link Service} is a valid Linked Domain Service. + * @param {Service} service + * @returns {boolean} + */ + static isValid(service) { + _assertClass(service, Service); + const ret = wasm.linkeddomainservice_isValid(service.__wbg_ptr); + return ret !== 0; + } + /** + * Deep clones the object. + * @returns {LinkedDomainService} + */ + clone() { + const ret = wasm.linkeddomainservice_clone(this.__wbg_ptr); + return LinkedDomainService.__wrap(ret); + } +} +module.exports.LinkedDomainService = LinkedDomainService; + +const MethodDataFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_methoddata_free(ptr >>> 0, 1)); +/** +* Supported verification method data formats. +*/ +class MethodData { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(MethodData.prototype); + obj.__wbg_ptr = ptr; + MethodDataFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + MethodDataFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_methoddata_free(ptr, 0); + } + /** + * Creates a new {@link MethodData} variant with Base58-BTC encoded content. + * @param {Uint8Array} data + * @returns {MethodData} + */ + static newBase58(data) { + const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.methoddata_newBase58(ptr0, len0); + return MethodData.__wrap(ret); + } + /** + * Creates a new {@link MethodData} variant with Multibase-encoded content. + * @param {Uint8Array} data + * @returns {MethodData} + */ + static newMultibase(data) { + const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.methoddata_newMultibase(ptr0, len0); + return MethodData.__wrap(ret); + } + /** + * Creates a new {@link MethodData} variant consisting of the given `key`. + * + * ### Errors + * An error is thrown if the given `key` contains any private components. + * @param {Jwk} key + * @returns {MethodData} + */ + static newJwk(key) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(key, Jwk); + wasm.methoddata_newJwk(retptr, key.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return MethodData.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Creates a new custom {@link MethodData}. + * @param {string} name + * @param {any} data + * @returns {MethodData} + */ + static newCustom(name, data) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.methoddata_newCustom(retptr, ptr0, len0, addHeapObject(data)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return MethodData.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the wrapped custom method data format is `Custom`. + * @returns {CustomMethodData} + */ + tryCustom() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methoddata_tryCustom(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return CustomMethodData.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a `Uint8Array` containing the decoded bytes of the {@link MethodData}. + * + * This is generally a public key identified by a {@link MethodData} value. + * + * ### Errors + * Decoding can fail if {@link MethodData} has invalid content or cannot be + * represented as a vector of bytes. + * @returns {Uint8Array} + */ + tryDecode() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methoddata_tryDecode(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the wrapped {@link Jwk} if the format is `PublicKeyJwk`. + * @returns {Jwk} + */ + tryPublicKeyJwk() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methoddata_tryPublicKeyJwk(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Jwk.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methoddata_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {MethodData} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methoddata_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return MethodData.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {MethodData} + */ + clone() { + const ret = wasm.methoddata_clone(this.__wbg_ptr); + return MethodData.__wrap(ret); + } +} +module.exports.MethodData = MethodData; + +const MethodDigestFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_methoddigest_free(ptr >>> 0, 1)); +/** +* Unique identifier of a {@link VerificationMethod}. +* +* NOTE: +* This class does not have a JSON representation, +* use the methods `pack` and `unpack` instead. +*/ +class MethodDigest { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(MethodDigest.prototype); + obj.__wbg_ptr = ptr; + MethodDigestFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + MethodDigestFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_methoddigest_free(ptr, 0); + } + /** + * @param {VerificationMethod} verification_method + */ + constructor(verification_method) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(verification_method, VerificationMethod); + wasm.methoddigest_new(retptr, verification_method.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + MethodDigestFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Packs {@link MethodDigest} into bytes. + * @returns {Uint8Array} + */ + pack() { + const ret = wasm.methoddigest_pack(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Unpacks bytes into {@link MethodDigest}. + * @param {Uint8Array} bytes + * @returns {MethodDigest} + */ + static unpack(bytes) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methoddigest_unpack(retptr, addBorrowedObject(bytes)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return MethodDigest.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {MethodDigest} + */ + clone() { + const ret = wasm.methoddigest_clone(this.__wbg_ptr); + return MethodDigest.__wrap(ret); + } +} +module.exports.MethodDigest = MethodDigest; + +const MethodScopeFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_methodscope_free(ptr >>> 0, 1)); +/** +* Supported verification method types. +*/ +class MethodScope { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(MethodScope.prototype); + obj.__wbg_ptr = ptr; + MethodScopeFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + MethodScopeFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_methodscope_free(ptr, 0); + } + /** + * @returns {MethodScope} + */ + static VerificationMethod() { + const ret = wasm.methodscope_VerificationMethod(); + return MethodScope.__wrap(ret); + } + /** + * @returns {MethodScope} + */ + static Authentication() { + const ret = wasm.methodscope_Authentication(); + return MethodScope.__wrap(ret); + } + /** + * @returns {MethodScope} + */ + static AssertionMethod() { + const ret = wasm.methodscope_AssertionMethod(); + return MethodScope.__wrap(ret); + } + /** + * @returns {MethodScope} + */ + static KeyAgreement() { + const ret = wasm.methodscope_KeyAgreement(); + return MethodScope.__wrap(ret); + } + /** + * @returns {MethodScope} + */ + static CapabilityDelegation() { + const ret = wasm.methodscope_CapabilityDelegation(); + return MethodScope.__wrap(ret); + } + /** + * @returns {MethodScope} + */ + static CapabilityInvocation() { + const ret = wasm.methodscope_CapabilityInvocation(); + return MethodScope.__wrap(ret); + } + /** + * Returns the {@link MethodScope} as a string. + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methodscope_toString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methodscope_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {MethodScope} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methodscope_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return MethodScope.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {MethodScope} + */ + clone() { + const ret = wasm.methodscope_clone(this.__wbg_ptr); + return MethodScope.__wrap(ret); + } +} +module.exports.MethodScope = MethodScope; + +const MethodTypeFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_methodtype_free(ptr >>> 0, 1)); +/** +* Supported verification method types. +*/ +class MethodType { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(MethodType.prototype); + obj.__wbg_ptr = ptr; + MethodTypeFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + MethodTypeFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_methodtype_free(ptr, 0); + } + /** + * @returns {MethodType} + */ + static Ed25519VerificationKey2018() { + const ret = wasm.methodtype_Ed25519VerificationKey2018(); + return MethodType.__wrap(ret); + } + /** + * @returns {MethodType} + */ + static X25519KeyAgreementKey2019() { + const ret = wasm.methodtype_X25519KeyAgreementKey2019(); + return MethodType.__wrap(ret); + } + /** + * @deprecated Use {@link JsonWebKey2020} instead. + */ + static JsonWebKey() { + const ret = wasm.methodtype_JsonWebKey(); + return MethodType.__wrap(ret); + } + /** + * A verification method for use with JWT verification as prescribed by the {@link Jwk} + * in the `publicKeyJwk` entry. + * @returns {MethodType} + */ + static JsonWebKey2020() { + const ret = wasm.methodtype_JsonWebKey2020(); + return MethodType.__wrap(ret); + } + /** + * A custom method. + * @param {string} type_ + * @returns {MethodType} + */ + static custom(type_) { + const ptr0 = passStringToWasm0(type_, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.methodtype_custom(ptr0, len0); + return MethodType.__wrap(ret); + } + /** + * Returns the {@link MethodType} as a string. + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methodtype_toString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methodtype_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {MethodType} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.methodtype_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return MethodType.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {MethodType} + */ + clone() { + const ret = wasm.methodtype_clone(this.__wbg_ptr); + return MethodType.__wrap(ret); + } +} +module.exports.MethodType = MethodType; + +const PayloadEntryFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_payloadentry_free(ptr >>> 0, 1)); +/** +*/ +class PayloadEntry { + + static __unwrap(jsValue) { + if (!(jsValue instanceof PayloadEntry)) { + return 0; + } + return jsValue.__destroy_into_raw(); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + PayloadEntryFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_payloadentry_free(ptr, 0); + } + /** + * @returns {PayloadType} + */ + get 1() { + const ret = wasm.__wbg_get_payloadentry_1(this.__wbg_ptr); + return ret; + } + /** + * @param {PayloadType} arg0 + */ + set 1(arg0) { + wasm.__wbg_set_payloadentry_1(this.__wbg_ptr, arg0); + } + /** + * @param {any} value + */ + set value(value) { + wasm.payloadentry_set_value(this.__wbg_ptr, addHeapObject(value)); + } + /** + * @returns {any} + */ + get value() { + const ret = wasm.payloadentry_value(this.__wbg_ptr); + return takeObject(ret); + } +} +module.exports.PayloadEntry = PayloadEntry; + +const PayloadsFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_payloads_free(ptr >>> 0, 1)); +/** +*/ +class Payloads { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Payloads.prototype); + obj.__wbg_ptr = ptr; + PayloadsFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + PayloadsFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_payloads_free(ptr, 0); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.payloads_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Payloads} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.payloads_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Payloads.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {Payloads} + */ + clone() { + const ret = wasm.payloads_clone(this.__wbg_ptr); + return Payloads.__wrap(ret); + } + /** + * @param {(PayloadEntry)[]} entries + */ + constructor(entries) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArrayJsValueToWasm0(entries, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.payloads_new(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + PayloadsFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @param {any[]} values + * @returns {Payloads} + */ + static newFromValues(values) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.payloads_newFromValues(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Payloads.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {any[]} + */ + getValues() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.payloads_getValues(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4, 4); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint32Array} + */ + getUndisclosedIndexes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.payloads_getUndisclosedIndexes(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var v1 = getArrayU32FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4, 4); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Uint32Array} + */ + getDisclosedIndexes() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.payloads_getDisclosedIndexes(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var v1 = getArrayU32FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4, 4); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {any[]} + */ + getUndisclosedPayloads() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.payloads_getUndisclosedPayloads(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + if (r3) { + throw takeObject(r2); + } + var v1 = getArrayJsValueFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 4, 4); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {Payloads} + */ + getDisclosedPayloads() { + const ret = wasm.payloads_getDisclosedPayloads(this.__wbg_ptr); + return Payloads.__wrap(ret); + } + /** + * @param {number} index + */ + setUndisclosed(index) { + wasm.payloads_setUndisclosed(this.__wbg_ptr, index); + } + /** + * @param {number} index + * @param {any} value + * @returns {any} + */ + replacePayloadAtIndex(index, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.payloads_replacePayloadAtIndex(retptr, this.__wbg_ptr, index, addHeapObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.Payloads = Payloads; + +const PresentationFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_presentation_free(ptr >>> 0, 1)); +/** +*/ +class Presentation { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Presentation.prototype); + obj.__wbg_ptr = ptr; + PresentationFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + PresentationFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_presentation_free(ptr, 0); + } + /** + * Returns the base JSON-LD context. + * @returns {string} + */ + static BaseContext() { + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_BaseContext(retptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + var ptr1 = r0; + var len1 = r1; + if (r3) { + ptr1 = 0; len1 = 0; + throw takeObject(r2); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } + } + /** + * Returns the base type. + * @returns {string} + */ + static BaseType() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_BaseType(retptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Constructs a new presentation. + * @param {IPresentation} values + */ + constructor(values) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_new(retptr, addHeapObject(values)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + PresentationFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the JSON-LD context(s) applicable to the presentation. + * @returns {Array>} + */ + context() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_context(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the unique `URI` identifying the presentation. + * @returns {string | undefined} + */ + id() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_id(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the URIs defining the type of the presentation. + * @returns {Array} + */ + type() { + const ret = wasm.presentation_type(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns the JWT credentials expressing the claims of the presentation. + * @returns {Array} + */ + verifiableCredential() { + const ret = wasm.presentation_verifiableCredential(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns a copy of the URI of the entity that generated the presentation. + * @returns {string} + */ + holder() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_holder(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns a copy of the service(s) used to refresh an expired {@link Credential} in the presentation. + * @returns {Array} + */ + refreshService() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_refreshService(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the terms-of-use specified by the presentation holder + * @returns {Array} + */ + termsOfUse() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_termsOfUse(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Optional cryptographic proof, unrelated to JWT. + * @returns {Proof | undefined} + */ + proof() { + const ret = wasm.presentation_proof(this.__wbg_ptr); + return ret === 0 ? undefined : Proof.__wrap(ret); + } + /** + * Sets the proof property of the {@link Presentation}. + * + * Note that this proof is not related to JWT. + * @param {Proof | undefined} [proof] + */ + setProof(proof) { + let ptr0 = 0; + if (!isLikeNone(proof)) { + _assertClass(proof, Proof); + ptr0 = proof.__destroy_into_raw(); + } + wasm.presentation_setProof(this.__wbg_ptr, ptr0); + } + /** + * Returns a copy of the miscellaneous properties on the presentation. + * @returns {Map} + */ + properties() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_properties(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Presentation} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.presentation_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Presentation.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {Presentation} + */ + clone() { + const ret = wasm.presentation_clone(this.__wbg_ptr); + return Presentation.__wrap(ret); + } +} +module.exports.Presentation = Presentation; + +const PresentationProtectedHeaderFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_presentationprotectedheader_free(ptr >>> 0, 1)); +/** +*/ +class PresentationProtectedHeader { + + toJSON() { + return { + alg: this.alg, + kid: this.kid, + aud: this.aud, + nonce: this.nonce, + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + PresentationProtectedHeaderFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_presentationprotectedheader_free(ptr, 0); + } + /** + * @returns {PresentationProofAlgorithm} + */ + get alg() { + const ret = wasm.__wbg_get_presentationprotectedheader_alg(this.__wbg_ptr); + return ret; + } + /** + * @param {PresentationProofAlgorithm} arg0 + */ + set alg(arg0) { + wasm.__wbg_set_presentationprotectedheader_alg(this.__wbg_ptr, arg0); + } + /** + * ID for the key used for the JWP. + * @returns {string | undefined} + */ + get kid() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_presentationprotectedheader_kid(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * ID for the key used for the JWP. + * @param {string | undefined} [arg0] + */ + set kid(arg0) { + var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_presentationprotectedheader_kid(this.__wbg_ptr, ptr0, len0); + } + /** + * Who have received the JPT. + * @returns {string | undefined} + */ + get aud() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_presentationprotectedheader_aud(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Who have received the JPT. + * @param {string | undefined} [arg0] + */ + set aud(arg0) { + var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_presentationprotectedheader_aud(this.__wbg_ptr, ptr0, len0); + } + /** + * For replay attacks. + * @returns {string | undefined} + */ + get nonce() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_presentationprotectedheader_nonce(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * For replay attacks. + * @param {string | undefined} [arg0] + */ + set nonce(arg0) { + var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_presentationprotectedheader_nonce(this.__wbg_ptr, ptr0, len0); + } +} +module.exports.PresentationProtectedHeader = PresentationProtectedHeader; + +const ProofFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_proof_free(ptr >>> 0, 1)); +/** +* Represents a cryptographic proof that can be used to validate verifiable credentials and +* presentations. +* +* This representation does not inherently implement any standard; instead, it +* can be utilized to implement standards or user-defined proofs. The presence of the +* `type` field is necessary to accommodate different types of cryptographic proofs. +* +* Note that this proof is not related to JWT and can be used in combination or as an alternative +* to it. +*/ +class Proof { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Proof.prototype); + obj.__wbg_ptr = ptr; + ProofFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + ProofFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proof_free(ptr, 0); + } + /** + * @param {string} type_ + * @param {any} properties + */ + constructor(type_, properties) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(type_, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.proof_constructor(retptr, ptr0, len0, addHeapObject(properties)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + ProofFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the type of proof. + * @returns {string} + */ + type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.proof_type(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns the properties of the proof. + * @returns {any} + */ + properties() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.proof_properties(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.proof_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Proof} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.proof_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Proof.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {Proof} + */ + clone() { + const ret = wasm.proof_clone(this.__wbg_ptr); + return Proof.__wrap(ret); + } +} +module.exports.Proof = Proof; + +const ProofUpdateCtxFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_proofupdatectx_free(ptr >>> 0, 1)); +/** +*/ +class ProofUpdateCtx { + + toJSON() { + return { + old_start_validity_timeframe: this.old_start_validity_timeframe, + new_start_validity_timeframe: this.new_start_validity_timeframe, + old_end_validity_timeframe: this.old_end_validity_timeframe, + new_end_validity_timeframe: this.new_end_validity_timeframe, + index_start_validity_timeframe: this.index_start_validity_timeframe, + index_end_validity_timeframe: this.index_end_validity_timeframe, + number_of_signed_messages: this.number_of_signed_messages, + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + ProofUpdateCtxFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_proofupdatectx_free(ptr, 0); + } + /** + * Old `startValidityTimeframe` value + * @returns {Uint8Array} + */ + get old_start_validity_timeframe() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_proofupdatectx_old_start_validity_timeframe(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Old `startValidityTimeframe` value + * @param {Uint8Array} arg0 + */ + set old_start_validity_timeframe(arg0) { + const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_proofupdatectx_old_start_validity_timeframe(this.__wbg_ptr, ptr0, len0); + } + /** + * New `startValidityTimeframe` value to be signed + * @returns {Uint8Array} + */ + get new_start_validity_timeframe() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_proofupdatectx_new_start_validity_timeframe(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * New `startValidityTimeframe` value to be signed + * @param {Uint8Array} arg0 + */ + set new_start_validity_timeframe(arg0) { + const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_proofupdatectx_new_start_validity_timeframe(this.__wbg_ptr, ptr0, len0); + } + /** + * Old `endValidityTimeframe` value + * @returns {Uint8Array} + */ + get old_end_validity_timeframe() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_proofupdatectx_old_end_validity_timeframe(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Old `endValidityTimeframe` value + * @param {Uint8Array} arg0 + */ + set old_end_validity_timeframe(arg0) { + const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_proofupdatectx_old_end_validity_timeframe(this.__wbg_ptr, ptr0, len0); + } + /** + * New `endValidityTimeframe` value to be signed + * @returns {Uint8Array} + */ + get new_end_validity_timeframe() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.__wbg_get_proofupdatectx_new_end_validity_timeframe(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var v1 = getArrayU8FromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * New `endValidityTimeframe` value to be signed + * @param {Uint8Array} arg0 + */ + set new_end_validity_timeframe(arg0) { + const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc); + const len0 = WASM_VECTOR_LEN; + wasm.__wbg_set_proofupdatectx_new_end_validity_timeframe(this.__wbg_ptr, ptr0, len0); + } + /** + * Index of `startValidityTimeframe` claim inside the array of Claims + * @returns {number} + */ + get index_start_validity_timeframe() { + const ret = wasm.__wbg_get_proofupdatectx_index_start_validity_timeframe(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Index of `startValidityTimeframe` claim inside the array of Claims + * @param {number} arg0 + */ + set index_start_validity_timeframe(arg0) { + wasm.__wbg_set_proofupdatectx_index_start_validity_timeframe(this.__wbg_ptr, arg0); + } + /** + * Index of `endValidityTimeframe` claim inside the array of Claims + * @returns {number} + */ + get index_end_validity_timeframe() { + const ret = wasm.__wbg_get_proofupdatectx_index_end_validity_timeframe(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Index of `endValidityTimeframe` claim inside the array of Claims + * @param {number} arg0 + */ + set index_end_validity_timeframe(arg0) { + wasm.__wbg_set_proofupdatectx_index_end_validity_timeframe(this.__wbg_ptr, arg0); + } + /** + * Number of signed messages, number of payloads in a JWP + * @returns {number} + */ + get number_of_signed_messages() { + const ret = wasm.__wbg_get_proofupdatectx_number_of_signed_messages(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Number of signed messages, number of payloads in a JWP + * @param {number} arg0 + */ + set number_of_signed_messages(arg0) { + wasm.__wbg_set_proofupdatectx_number_of_signed_messages(this.__wbg_ptr, arg0); + } +} +module.exports.ProofUpdateCtx = ProofUpdateCtx; + +const ResolverFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_resolver_free(ptr >>> 0, 1)); +/** +* Convenience type for resolving DID documents from different DID methods. +* +* Also provides methods for resolving DID Documents associated with +* verifiable {@link Credential}s and {@link Presentation}s. +* +* # Configuration +* +* The resolver will only be able to resolve DID documents for methods it has been configured for in the constructor. +*/ +class Resolver { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + ResolverFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_resolver_free(ptr, 0); + } + /** + * Constructs a new {@link Resolver}. + * + * # Errors + * If both a `client` is given and the `handlers` map contains the "iota" key the construction process + * will throw an error because the handler for the "iota" method then becomes ambiguous. + * @param {ResolverConfig} config + */ + constructor(config) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.resolver_new(retptr, addHeapObject(config)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + ResolverFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Fetches the DID Document of the given DID. + * + * ### Errors + * + * Errors if the resolver has not been configured to handle the method + * corresponding to the given DID or the resolution process itself fails. + * @param {string} did + * @returns {Promise} + */ + resolve(did) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(did, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.resolver_resolve(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Concurrently fetches the DID Documents of the multiple given DIDs. + * + * # Errors + * * If the resolver has not been configured to handle the method of any of the given DIDs. + * * If the resolution process of any DID fails. + * + * ## Note + * * The order of the documents in the returned array matches that in `dids`. + * * If `dids` contains duplicates, these will be resolved only once and the resolved document + * is copied into the returned array to match the order of `dids`. + * @param {Array} dids + * @returns {Promise>} + */ + resolveMultiple(dids) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.resolver_resolveMultiple(retptr, this.__wbg_ptr, addHeapObject(dids)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.Resolver = Resolver; + +const RevocationBitmapFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_revocationbitmap_free(ptr >>> 0, 1)); +/** +* A compressed bitmap for managing credential revocation. +*/ +class RevocationBitmap { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(RevocationBitmap.prototype); + obj.__wbg_ptr = ptr; + RevocationBitmapFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + RevocationBitmapFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationbitmap_free(ptr, 0); + } + /** + * Creates a new {@link RevocationBitmap} instance. + */ + constructor() { + const ret = wasm.revocationbitmap_new(); + this.__wbg_ptr = ret >>> 0; + RevocationBitmapFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * The name of the service type. + * @returns {string} + */ + static type() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.revocationbitmap_type(retptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns `true` if the credential at the given `index` is revoked. + * @param {number} index + * @returns {boolean} + */ + isRevoked(index) { + const ret = wasm.revocationbitmap_isRevoked(this.__wbg_ptr, index); + return ret !== 0; + } + /** + * Mark the given index as revoked. + * + * Returns true if the index was absent from the set. + * @param {number} index + * @returns {boolean} + */ + revoke(index) { + const ret = wasm.revocationbitmap_revoke(this.__wbg_ptr, index); + return ret !== 0; + } + /** + * Mark the index as not revoked. + * + * Returns true if the index was present in the set. + * @param {number} index + * @returns {boolean} + */ + unrevoke(index) { + const ret = wasm.revocationbitmap_unrevoke(this.__wbg_ptr, index); + return ret !== 0; + } + /** + * Returns the number of revoked credentials. + * @returns {number} + */ + len() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.revocationbitmap_len(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 >>> 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Return a `Service` with: + * - the service's id set to `serviceId`, + * - of type `RevocationBitmap2022`, + * - and with the bitmap embedded in a data url in the service's endpoint. + * @param {DIDUrl} serviceId + * @returns {Service} + */ + toService(serviceId) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(serviceId, DIDUrl); + wasm.revocationbitmap_toService(retptr, this.__wbg_ptr, serviceId.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Service.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Try to construct a {@link RevocationBitmap} from a service + * if it is a valid Revocation Bitmap Service. + * @param {Service} service + * @returns {RevocationBitmap} + */ + static fromEndpoint(service) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(service, Service); + wasm.revocationbitmap_fromEndpoint(retptr, service.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return RevocationBitmap.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.RevocationBitmap = RevocationBitmap; + +const RevocationTimeframeStatusFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_revocationtimeframestatus_free(ptr >>> 0, 1)); +/** +* Information used to determine the current status of a {@link Credential}. +*/ +class RevocationTimeframeStatus { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(RevocationTimeframeStatus.prototype); + obj.__wbg_ptr = ptr; + RevocationTimeframeStatusFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + RevocationTimeframeStatusFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_revocationtimeframestatus_free(ptr, 0); + } + /** + * Deep clones the object. + * @returns {RevocationTimeframeStatus} + */ + clone() { + const ret = wasm.revocationtimeframestatus_clone(this.__wbg_ptr); + return RevocationTimeframeStatus.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.revocationtimeframestatus_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {RevocationTimeframeStatus} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.revocationtimeframestatus_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return RevocationTimeframeStatus.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Creates a new `RevocationTimeframeStatus`. + * @param {string} id + * @param {number} index + * @param {Duration} duration + * @param {Timestamp | undefined} [start_validity] + */ + constructor(id, index, duration, start_validity) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + _assertClass(duration, Duration); + var ptr1 = duration.__destroy_into_raw(); + let ptr2 = 0; + if (!isLikeNone(start_validity)) { + _assertClass(start_validity, Timestamp); + ptr2 = start_validity.__destroy_into_raw(); + } + wasm.revocationtimeframestatus_new(retptr, ptr0, len0, index, ptr1, ptr2); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + RevocationTimeframeStatusFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Get startValidityTimeframe value. + * @returns {Timestamp} + */ + startValidityTimeframe() { + const ret = wasm.revocationtimeframestatus_startValidityTimeframe(this.__wbg_ptr); + return Timestamp.__wrap(ret); + } + /** + * Get endValidityTimeframe value. + * @returns {Timestamp} + */ + endValidityTimeframe() { + const ret = wasm.revocationtimeframestatus_endValidityTimeframe(this.__wbg_ptr); + return Timestamp.__wrap(ret); + } + /** + * Return the URL fo the `RevocationBitmapStatus`. + * @returns {string} + */ + id() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.revocationtimeframestatus_id(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Return the index of the credential in the issuer's revocation bitmap + * @returns {number | undefined} + */ + index() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.revocationtimeframestatus_index(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + return r0 === 0 ? undefined : r1 >>> 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.RevocationTimeframeStatus = RevocationTimeframeStatus; + +const SdJwtFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_sdjwt_free(ptr >>> 0, 1)); +/** +* Representation of an SD-JWT of the format +* `~~~...~~`. +*/ +class SdJwt { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(SdJwt.prototype); + obj.__wbg_ptr = ptr; + SdJwtFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + SdJwtFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_sdjwt_free(ptr, 0); + } + /** + * Creates a new `SdJwt` from its components. + * @param {string} jwt + * @param {Array} disclosures + * @param {string | undefined} [key_binding_jwt] + */ + constructor(jwt, disclosures, key_binding_jwt) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + var ptr1 = isLikeNone(key_binding_jwt) ? 0 : passStringToWasm0(key_binding_jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.sdjwt_new(retptr, ptr0, len0, addHeapObject(disclosures), ptr1, len1); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + SdJwtFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes the components into the final SD-JWT. + * @returns {string} + */ + presentation() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdjwt_presentation(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Parses an SD-JWT into its components as [`SdJwt`]. + * + * ## Error + * Returns `DeserializationError` if parsing fails. + * @param {string} sd_jwt + * @returns {SdJwt} + */ + static parse(sd_jwt) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(sd_jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.sdjwt_parse(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return SdJwt.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes the components into the final SD-JWT. + * @returns {string} + */ + toString() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdjwt_presentation(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * The JWT part. + * @returns {string} + */ + jwt() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdjwt_jwt(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * The disclosures part. + * @returns {Array} + */ + disclosures() { + const ret = wasm.sdjwt_disclosures(this.__wbg_ptr); + return takeObject(ret); + } + /** + * The optional key binding JWT. + * @returns {string | undefined} + */ + keyBindingJwt() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdjwt_keyBindingJwt(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + let v1; + if (r0 !== 0) { + v1 = getStringFromWasm0(r0, r1).slice(); + wasm.__wbindgen_free(r0, r1 * 1, 1); + } + return v1; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deep clones the object. + * @returns {SdJwt} + */ + clone() { + const ret = wasm.sdjwt_clone(this.__wbg_ptr); + return SdJwt.__wrap(ret); + } +} +module.exports.SdJwt = SdJwt; + +const SdJwtCredentialValidatorFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_sdjwtcredentialvalidator_free(ptr >>> 0, 1)); +/** +* A type for decoding and validating {@link Credential}. +*/ +class SdJwtCredentialValidator { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + SdJwtCredentialValidatorFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_sdjwtcredentialvalidator_free(ptr, 0); + } + /** + * Creates a new `SdJwtCredentialValidator`. If a `signatureVerifier` is provided it will be used when + * verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` + * algorithm will be used. + * @param {IJwsVerifier} signatureVerifier + */ + constructor(signatureVerifier) { + const ret = wasm.sdjwtcredentialvalidator_new(addHeapObject(signatureVerifier)); + this.__wbg_ptr = ret >>> 0; + SdJwtCredentialValidatorFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Decodes and validates a `Credential` issued as an SD-JWT. A `DecodedJwtCredential` is returned upon success. + * The credential is constructed by replacing disclosures following the + * [`Selective Disclosure for JWTs (SD-JWT)`](https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html) standard. + * + * The following properties are validated according to `options`: + * - the issuer's signature on the JWS, + * - the expiration date, + * - the issuance date, + * - the semantic structure. + * + * # Warning + * * The key binding JWT is not validated. If needed, it must be validated separately using + * `SdJwtValidator::validate_key_binding_jwt`. + * * The lack of an error returned from this method is in of itself not enough to conclude that the credential can be + * trusted. This section contains more information on additional checks that should be carried out before and after + * calling this method. + * + * ## The state of the issuer's DID Document + * The caller must ensure that `issuer` represents an up-to-date DID Document. + * + * ## Properties that are not validated + * There are many properties defined in [The Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/) that are **not** validated, such as: + * `proof`, `credentialStatus`, `type`, `credentialSchema`, `refreshService` **and more**. + * These should be manually checked after validation, according to your requirements. + * + * # Errors + * An error is returned whenever a validated condition is not satisfied. + * @param {SdJwt} sd_jwt + * @param {CoreDocument | IToCoreDocument} issuer + * @param {JwtCredentialValidationOptions} options + * @param {FailFast} fail_fast + * @returns {DecodedJwtCredential} + */ + validateCredential(sd_jwt, issuer, options, fail_fast) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sd_jwt, SdJwt); + _assertClass(options, JwtCredentialValidationOptions); + wasm.sdjwtcredentialvalidator_validateCredential(retptr, this.__wbg_ptr, sd_jwt.__wbg_ptr, addBorrowedObject(issuer), options.__wbg_ptr, fail_fast); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DecodedJwtCredential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Decode and verify the JWS signature of a `Credential` issued as an SD-JWT using the DID Document of a trusted + * issuer and replaces the disclosures. + * + * A `DecodedJwtCredential` is returned upon success. + * + * # Warning + * The caller must ensure that the DID Documents of the trusted issuers are up-to-date. + * + * ## Proofs + * Only the JWS signature is verified. If the `Credential` contains a `proof` property this will not be verified + * by this method. + * + * # Errors + * * If the issuer' URL cannot be parsed. + * * If Signature verification fails. + * * If SD decoding fails. + * @param {SdJwt} credential + * @param {Array} trustedIssuers + * @param {JwsVerificationOptions} options + * @returns {DecodedJwtCredential} + */ + verifySignature(credential, trustedIssuers, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, SdJwt); + _assertClass(options, JwsVerificationOptions); + wasm.sdjwtcredentialvalidator_verifySignature(retptr, this.__wbg_ptr, credential.__wbg_ptr, addBorrowedObject(trustedIssuers), options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return DecodedJwtCredential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Validates a Key Binding JWT (KB-JWT) according to `https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-key-binding-jwt`. + * The Validation process includes: + * * Signature validation using public key materials defined in the `holder` document. + * * `typ` value in KB-JWT header. + * * `sd_hash` claim value in the KB-JWT claim. + * * Optional `nonce`, `aud` and issuance date validation. + * @param {SdJwt} sdJwt + * @param {CoreDocument | IToCoreDocument} holder + * @param {KeyBindingJWTValidationOptions} options + * @returns {KeyBindingJwtClaims} + */ + validateKeyBindingJwt(sdJwt, holder, options) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(sdJwt, SdJwt); + _assertClass(options, KeyBindingJWTValidationOptions); + wasm.sdjwtcredentialvalidator_validateKeyBindingJwt(retptr, this.__wbg_ptr, sdJwt.__wbg_ptr, addBorrowedObject(holder), options.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return KeyBindingJwtClaims.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.SdJwtCredentialValidator = SdJwtCredentialValidator; + +const SdObjectDecoderFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_sdobjectdecoder_free(ptr >>> 0, 1)); +/** +* Substitutes digests in an SD-JWT object by their corresponding plaintext values provided by disclosures. +*/ +class SdObjectDecoder { + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + SdObjectDecoderFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_sdobjectdecoder_free(ptr, 0); + } + /** + * Creates a new `SdObjectDecoder` with `sha-256` hasher. + */ + constructor() { + const ret = wasm.sdobjectdecoder_new(); + this.__wbg_ptr = ret >>> 0; + SdObjectDecoderFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Decodes an SD-JWT `object` containing by Substituting the digests with their corresponding + * plaintext values provided by `disclosures`. + * + * ## Notes + * * Claims like `exp` or `iat` are not validated in the process of decoding. + * * `_sd_alg` property will be removed if present. + * @param {Record} object + * @param {Array} disclosures + * @returns {Record} + */ + decode(object, disclosures) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdobjectdecoder_decode(retptr, this.__wbg_ptr, addHeapObject(object), addHeapObject(disclosures)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.SdObjectDecoder = SdObjectDecoder; + +const SdObjectEncoderFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_sdobjectencoder_free(ptr >>> 0, 1)); +/** +* Transforms a JSON object into an SD-JWT object by substituting selected values +* with their corresponding disclosure digests. +* +* Note: digests are created using the sha-256 algorithm. +*/ +class SdObjectEncoder { + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + SdObjectEncoderFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_sdobjectencoder_free(ptr, 0); + } + /** + * Creates a new `SdObjectEncoder` with `sha-256` hash function. + * @param {any} object + */ + constructor(object) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdobjectencoder_new(retptr, addBorrowedObject(object)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + SdObjectEncoderFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Substitutes a value with the digest of its disclosure. + * If no salt is provided, the disclosure will be created with a random salt value. + * + * `path` indicates the pointer to the value that will be concealed using the syntax of + * [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901). + * + * For the following object: + * + * ``` + * { + * "id": "did:value", + * "claim1": { + * "abc": true + * }, + * "claim2": ["val_1", "val_2"] + * } + * ``` + * + * Path "/id" conceals `"id": "did:value"` + * Path "/claim1/abc" conceals `"abc": true` + * Path "/claim2/0" conceals `val_1` + * ``` + * + * ## Errors + * * `InvalidPath` if pointer is invalid. + * * `DataTypeMismatch` if existing SD format is invalid. + * @param {string} path + * @param {string | undefined} [salt] + * @returns {Disclosure} + */ + conceal(path, salt) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + var ptr1 = isLikeNone(salt) ? 0 : passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.sdobjectencoder_conceal(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Disclosure.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Adds the `_sd_alg` property to the top level of the object, with + * its value set to "sha-256". + */ + addSdAlgProperty() { + wasm.sdobjectencoder_addSdAlgProperty(this.__wbg_ptr); + } + /** + * Returns the modified object as a string. + * @returns {string} + */ + encodeToString() { + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdobjectencoder_encodeToString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + var ptr1 = r0; + var len1 = r1; + if (r3) { + ptr1 = 0; len1 = 0; + throw takeObject(r2); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } + } + /** + * Returns the modified object as a string. + * @returns {string} + */ + toString() { + let deferred2_0; + let deferred2_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdobjectencoder_encodeToString(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); + var ptr1 = r0; + var len1 = r1; + if (r3) { + ptr1 = 0; len1 = 0; + throw takeObject(r2); + } + deferred2_0 = ptr1; + deferred2_1 = len1; + return getStringFromWasm0(ptr1, len1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); + } + } + /** + * Returns the modified object. + * @returns {Record} + */ + encodeToObject() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdobjectencoder_encodeToObject(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the modified object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.sdobjectencoder_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Adds a decoy digest to the specified path. + * If path is an empty slice, decoys will be added to the top level. + * @param {string} path + * @param {number} number_of_decoys + */ + addDecoys(path, number_of_decoys) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.sdobjectencoder_addDecoys(retptr, this.__wbg_ptr, ptr0, len0, number_of_decoys); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.SdObjectEncoder = SdObjectEncoder; + +const SelectiveDisclosurePresentationFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_selectivedisclosurepresentation_free(ptr >>> 0, 1)); +/** +* Used to construct a JwpPresentedBuilder and handle the selective disclosure of attributes +* - @context MUST NOT be blinded +* - id MUST be blinded +* - type MUST NOT be blinded +* - issuer MUST NOT be blinded +* - issuanceDate MUST be blinded (if Timeframe Revocation mechanism is used) +* - expirationDate MUST be blinded (if Timeframe Revocation mechanism is used) +* - credentialSubject (User have to choose which attribute must be blinded) +* - credentialSchema MUST NOT be blinded +* - credentialStatus MUST NOT be blinded +* - refreshService MUST NOT be blinded (probably will be used for Timeslot Revocation mechanism) +* - termsOfUse NO reason to use it in ZK VC (will be in any case blinded) +* - evidence (User have to choose which attribute must be blinded) +*/ +class SelectiveDisclosurePresentation { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + SelectiveDisclosurePresentationFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_selectivedisclosurepresentation_free(ptr, 0); + } + /** + * Initialize a presentation starting from an Issued JWP. + * The properties `jti`, `nbf`, `issuanceDate`, `expirationDate` and `termsOfUse` are concealed by default. + * @param {JwpIssued} issued_jwp + */ + constructor(issued_jwp) { + _assertClass(issued_jwp, JwpIssued); + var ptr0 = issued_jwp.__destroy_into_raw(); + const ret = wasm.selectivedisclosurepresentation_new(ptr0); + this.__wbg_ptr = ret >>> 0; + SelectiveDisclosurePresentationFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Selectively disclose "credentialSubject" attributes. + * # Example + * ``` + * { + * "id": 1234, + * "name": "Alice", + * "mainCourses": ["Object-oriented Programming", "Mathematics"], + * "degree": { + * "type": "BachelorDegree", + * "name": "Bachelor of Science and Arts", + * }, + * "GPA": "4.0", + * } + * ``` + * If you want to undisclose for example the Mathematics course and the name of the degree: + * ``` + * undisclose_subject("mainCourses[1]"); + * undisclose_subject("degree.name"); + * ``` + * @param {string} path + */ + concealInSubject(path) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.selectivedisclosurepresentation_concealInSubject(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Undiscloses "evidence" attributes. + * @param {string} path + */ + concealInEvidence(path) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.selectivedisclosurepresentation_concealInEvidence(retptr, this.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets presentation protected header. + * @param {PresentationProtectedHeader} header + */ + setPresentationHeader(header) { + _assertClass(header, PresentationProtectedHeader); + var ptr0 = header.__destroy_into_raw(); + wasm.selectivedisclosurepresentation_setPresentationHeader(this.__wbg_ptr, ptr0); + } +} +module.exports.SelectiveDisclosurePresentation = SelectiveDisclosurePresentation; + +const ServiceFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_service_free(ptr >>> 0, 1)); +/** +* A DID Document Service used to enable trusted interactions associated with a DID subject. +*/ +class Service { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Service.prototype); + obj.__wbg_ptr = ptr; + ServiceFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + ServiceFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_service_free(ptr, 0); + } + /** + * @param {IService} service + */ + constructor(service) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.service_new(retptr, addHeapObject(service)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + ServiceFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the {@link Service} id. + * @returns {DIDUrl} + */ + id() { + const ret = wasm.service_id(this.__wbg_ptr); + return DIDUrl.__wrap(ret); + } + /** + * Returns a copy of the {@link Service} type. + * @returns {Array} + */ + type() { + const ret = wasm.service_type(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns a copy of the {@link Service} endpoint. + * @returns {string | string[] | Map} + */ + serviceEndpoint() { + const ret = wasm.service_serviceEndpoint(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Returns a copy of the custom properties on the {@link Service}. + * @returns {Map} + */ + properties() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.service_properties(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.service_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Service} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.service_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Service.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {Service} + */ + clone() { + const ret = wasm.service_clone(this.__wbg_ptr); + return Service.__wrap(ret); + } +} +module.exports.Service = Service; + +const StatusList2021Finalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_statuslist2021_free(ptr >>> 0, 1)); +/** +* StatusList2021 data structure as described in [W3C's VC status list 2021](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/). +*/ +class StatusList2021 { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(StatusList2021.prototype); + obj.__wbg_ptr = ptr; + StatusList2021Finalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + StatusList2021Finalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_statuslist2021_free(ptr, 0); + } + /** + * Deep clones the object. + * @returns {StatusList2021} + */ + clone() { + const ret = wasm.statuslist2021_clone(this.__wbg_ptr); + return StatusList2021.__wrap(ret); + } + /** + * Creates a new {@link StatusList2021} of `size` entries. + * @param {number | undefined} [size] + */ + constructor(size) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021_new(retptr, !isLikeNone(size), isLikeNone(size) ? 0 : size); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + StatusList2021Finalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the number of entries in this {@link StatusList2021}. + * @returns {number} + */ + len() { + const ret = wasm.statuslist2021_len(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Returns whether the entry at `index` is set. + * @param {number} index + * @returns {boolean} + */ + get(index) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021_get(retptr, this.__wbg_ptr, index); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0 !== 0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the value of the `index`-th entry. + * @param {number} index + * @param {boolean} value + */ + set(index, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021_set(retptr, this.__wbg_ptr, index, value); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Encodes this {@link StatusList2021} into its compressed + * base64 string representation. + * @returns {string} + */ + intoEncodedStr() { + let deferred1_0; + let deferred1_1; + try { + const ptr = this.__destroy_into_raw(); + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021_intoEncodedStr(retptr, ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Attempts to decode a {@link StatusList2021} from a string. + * @param {string} s + * @returns {StatusList2021} + */ + static fromEncodedStr(s) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.statuslist2021_fromEncodedStr(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return StatusList2021.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.StatusList2021 = StatusList2021; + +const StatusList2021CredentialFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_statuslist2021credential_free(ptr >>> 0, 1)); +/** +* A parsed [StatusList2021Credential](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/#statuslist2021credential). +*/ +class StatusList2021Credential { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(StatusList2021Credential.prototype); + obj.__wbg_ptr = ptr; + StatusList2021CredentialFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + StatusList2021CredentialFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_statuslist2021credential_free(ptr, 0); + } + /** + * Creates a new {@link StatusList2021Credential}. + * @param {Credential} credential + */ + constructor(credential) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + var ptr0 = credential.__destroy_into_raw(); + wasm.statuslist2021credential_new(retptr, ptr0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + StatusList2021CredentialFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {string} + */ + id() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021credential_id(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Sets the given credential's status using the `index`-th entry of this status list. + * Returns the created `credentialStatus`. + * @param {Credential} credential + * @param {number} index + * @param {boolean} revoked_or_suspended + * @returns {StatusList2021Entry} + */ + setCredentialStatus(credential, index, revoked_or_suspended) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(credential, Credential); + wasm.statuslist2021credential_setCredentialStatus(retptr, this.__wbg_ptr, credential.__wbg_ptr, index, revoked_or_suspended); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return StatusList2021Entry.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns the {@link StatusPurpose} of this {@link StatusList2021Credential}. + * @returns {StatusPurpose} + */ + purpose() { + const ret = wasm.statuslist2021credential_purpose(this.__wbg_ptr); + return ret; + } + /** + * Returns the state of the `index`-th entry, if any. + * @param {number} index + * @returns {CredentialStatus} + */ + entry(index) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021credential_entry(retptr, this.__wbg_ptr, index); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return r0; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {StatusList2021Credential} + */ + clone() { + const ret = wasm.statuslist2021credential_clone(this.__wbg_ptr); + return StatusList2021Credential.__wrap(ret); + } + /** + * @param {any} json + * @returns {StatusList2021Credential} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021credential_fromJSON(retptr, addHeapObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return StatusList2021Credential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021credential_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.StatusList2021Credential = StatusList2021Credential; + +const StatusList2021CredentialBuilderFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_statuslist2021credentialbuilder_free(ptr >>> 0, 1)); +/** +* Builder type to construct valid {@link StatusList2021Credential} istances. +*/ +class StatusList2021CredentialBuilder { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(StatusList2021CredentialBuilder.prototype); + obj.__wbg_ptr = ptr; + StatusList2021CredentialBuilderFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + StatusList2021CredentialBuilderFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_statuslist2021credentialbuilder_free(ptr, 0); + } + /** + * Creates a new {@link StatusList2021CredentialBuilder}. + * @param {StatusList2021 | undefined} [status_list] + */ + constructor(status_list) { + let ptr0 = 0; + if (!isLikeNone(status_list)) { + _assertClass(status_list, StatusList2021); + ptr0 = status_list.__destroy_into_raw(); + } + const ret = wasm.statuslist2021credentialbuilder_new(ptr0); + this.__wbg_ptr = ret >>> 0; + StatusList2021CredentialBuilderFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Sets the purpose of the {@link StatusList2021Credential} that is being created. + * @param {StatusPurpose} purpose + * @returns {StatusList2021CredentialBuilder} + */ + purpose(purpose) { + const ptr = this.__destroy_into_raw(); + const ret = wasm.statuslist2021credentialbuilder_purpose(ptr, purpose); + return StatusList2021CredentialBuilder.__wrap(ret); + } + /** + * Sets `credentialSubject.id`. + * @param {string} id + * @returns {StatusList2021CredentialBuilder} + */ + subjectId(id) { + try { + const ptr = this.__destroy_into_raw(); + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.statuslist2021credentialbuilder_subjectId(retptr, ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return StatusList2021CredentialBuilder.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the expiration date of the credential. + * @param {Timestamp} time + * @returns {StatusList2021CredentialBuilder} + */ + expirationDate(time) { + const ptr = this.__destroy_into_raw(); + _assertClass(time, Timestamp); + var ptr0 = time.__destroy_into_raw(); + const ret = wasm.statuslist2021credentialbuilder_expirationDate(ptr, ptr0); + return StatusList2021CredentialBuilder.__wrap(ret); + } + /** + * Sets the issuer of the credential. + * @param {string} issuer + * @returns {StatusList2021CredentialBuilder} + */ + issuer(issuer) { + try { + const ptr = this.__destroy_into_raw(); + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(issuer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.statuslist2021credentialbuilder_issuer(retptr, ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return StatusList2021CredentialBuilder.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Sets the context of the credential. + * @param {string} context + * @returns {StatusList2021CredentialBuilder} + */ + context(context) { + try { + const ptr = this.__destroy_into_raw(); + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(context, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.statuslist2021credentialbuilder_context(retptr, ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return StatusList2021CredentialBuilder.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Adds a credential type. + * @param {string} t + * @returns {StatusList2021CredentialBuilder} + */ + type(t) { + const ptr = this.__destroy_into_raw(); + const ptr0 = passStringToWasm0(t, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + const ret = wasm.statuslist2021credentialbuilder_type(ptr, ptr0, len0); + return StatusList2021CredentialBuilder.__wrap(ret); + } + /** + * Adds a credential's proof. + * @param {Proof} proof + * @returns {StatusList2021CredentialBuilder} + */ + proof(proof) { + const ptr = this.__destroy_into_raw(); + _assertClass(proof, Proof); + var ptr0 = proof.__destroy_into_raw(); + const ret = wasm.statuslist2021credentialbuilder_proof(ptr, ptr0); + return StatusList2021CredentialBuilder.__wrap(ret); + } + /** + * Attempts to build a valid {@link StatusList2021Credential} with the previously provided data. + * @returns {StatusList2021Credential} + */ + build() { + try { + const ptr = this.__destroy_into_raw(); + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021credentialbuilder_build(retptr, ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return StatusList2021Credential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } +} +module.exports.StatusList2021CredentialBuilder = StatusList2021CredentialBuilder; + +const StatusList2021EntryFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_statuslist2021entry_free(ptr >>> 0, 1)); +/** +* [StatusList2021Entry](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/#statuslist2021entry) implementation. +*/ +class StatusList2021Entry { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(StatusList2021Entry.prototype); + obj.__wbg_ptr = ptr; + StatusList2021EntryFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + StatusList2021EntryFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_statuslist2021entry_free(ptr, 0); + } + /** + * Creates a new {@link StatusList2021Entry}. + * @param {string} status_list + * @param {StatusPurpose} purpose + * @param {number} index + * @param {string | undefined} [id] + */ + constructor(status_list, purpose, index, id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(status_list, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + var ptr1 = isLikeNone(id) ? 0 : passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + wasm.statuslist2021entry_new(retptr, ptr0, len0, purpose, index, ptr1, len1); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + StatusList2021EntryFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns this `credentialStatus`'s `id`. + * @returns {string} + */ + id() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021entry_id(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Returns the purpose of this entry. + * @returns {StatusPurpose} + */ + purpose() { + const ret = wasm.statuslist2021entry_purpose(this.__wbg_ptr); + return ret; + } + /** + * Returns the index of this entry. + * @returns {number} + */ + index() { + const ret = wasm.statuslist2021entry_index(this.__wbg_ptr); + return ret >>> 0; + } + /** + * Returns the referenced {@link StatusList2021Credential}'s url. + * @returns {string} + */ + statusListCredential() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021entry_statusListCredential(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Downcasts {@link this} to {@link Status} + * @returns {Status} + */ + toStatus() { + try { + const ptr = this.__destroy_into_raw(); + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021entry_toStatus(retptr, ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deep clones the object. + * @returns {StatusList2021Entry} + */ + clone() { + const ret = wasm.statuslist2021entry_clone(this.__wbg_ptr); + return StatusList2021Entry.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021entry_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {StatusList2021Entry} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.statuslist2021entry_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return StatusList2021Entry.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.StatusList2021Entry = StatusList2021Entry; + +const StorageFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_storage_free(ptr >>> 0, 1)); +/** +* A type wrapping a `JwkStorage` and `KeyIdStorage` that should always be used together when +* working with storage backed DID documents. +*/ +class Storage { + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + StorageFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_storage_free(ptr, 0); + } + /** + * Constructs a new `Storage`. + * @param {JwkStorage} jwkStorage + * @param {KeyIdStorage} keyIdStorage + */ + constructor(jwkStorage, keyIdStorage) { + const ret = wasm.storage_new(addHeapObject(jwkStorage), addHeapObject(keyIdStorage)); + this.__wbg_ptr = ret >>> 0; + StorageFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Obtain the wrapped `KeyIdStorage`. + * @returns {KeyIdStorage} + */ + keyIdStorage() { + const ret = wasm.storage_keyIdStorage(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Obtain the wrapped `JwkStorage`. + * @returns {JwkStorage} + */ + keyStorage() { + const ret = wasm.storage_keyStorage(this.__wbg_ptr); + return takeObject(ret); + } +} +module.exports.Storage = Storage; + +const TimestampFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_timestamp_free(ptr >>> 0, 1)); +/** +*/ +class Timestamp { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(Timestamp.prototype); + obj.__wbg_ptr = ptr; + TimestampFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + TimestampFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_timestamp_free(ptr, 0); + } + /** + * Creates a new {@link Timestamp} with the current date and time. + */ + constructor() { + const ret = wasm.timestamp_new(); + this.__wbg_ptr = ret >>> 0; + TimestampFinalization.register(this, this.__wbg_ptr, this); + return this; + } + /** + * Parses a {@link Timestamp} from the provided input string. + * @param {string} input + * @returns {Timestamp} + */ + static parse(input) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.timestamp_parse(retptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Timestamp.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Creates a new {@link Timestamp} with the current date and time. + * @returns {Timestamp} + */ + static nowUTC() { + const ret = wasm.timestamp_new(); + return Timestamp.__wrap(ret); + } + /** + * Returns the {@link Timestamp} as an RFC 3339 `String`. + * @returns {string} + */ + toRFC3339() { + let deferred1_0; + let deferred1_1; + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.timestamp_toRFC3339(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + deferred1_0 = r0; + deferred1_1 = r1; + return getStringFromWasm0(r0, r1); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } + } + /** + * Computes `self + duration` + * + * Returns `null` if the operation leads to a timestamp not in the valid range for [RFC 3339](https://tools.ietf.org/html/rfc3339). + * @param {Duration} duration + * @returns {Timestamp | undefined} + */ + checkedAdd(duration) { + _assertClass(duration, Duration); + const ret = wasm.timestamp_checkedAdd(this.__wbg_ptr, duration.__wbg_ptr); + return ret === 0 ? undefined : Timestamp.__wrap(ret); + } + /** + * Computes `self - duration` + * + * Returns `null` if the operation leads to a timestamp not in the valid range for [RFC 3339](https://tools.ietf.org/html/rfc3339). + * @param {Duration} duration + * @returns {Timestamp | undefined} + */ + checkedSub(duration) { + _assertClass(duration, Duration); + const ret = wasm.timestamp_checkedSub(this.__wbg_ptr, duration.__wbg_ptr); + return ret === 0 ? undefined : Timestamp.__wrap(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.timestamp_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {Timestamp} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.timestamp_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return Timestamp.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } +} +module.exports.Timestamp = Timestamp; + +const UnknownCredentialFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_unknowncredential_free(ptr >>> 0, 1)); +/** +*/ +class UnknownCredential { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(UnknownCredential.prototype); + obj.__wbg_ptr = ptr; + UnknownCredentialFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + UnknownCredentialFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_unknowncredential_free(ptr, 0); + } + /** + * Returns a {@link Jwt} if the credential is of type string, `undefined` otherwise. + * @returns {Jwt | undefined} + */ + tryIntoJwt() { + const ret = wasm.unknowncredential_tryIntoJwt(this.__wbg_ptr); + return ret === 0 ? undefined : Jwt.__wrap(ret); + } + /** + * Returns a {@link Credential} if the credential is of said type, `undefined` otherwise. + * @returns {Credential | undefined} + */ + tryIntoCredential() { + const ret = wasm.unknowncredential_tryIntoCredential(this.__wbg_ptr); + return ret === 0 ? undefined : Credential.__wrap(ret); + } + /** + * Returns the contained value as an Object, if it can be converted, `undefined` otherwise. + * @returns {Record | undefined} + */ + tryIntoRaw() { + const ret = wasm.unknowncredential_tryIntoRaw(this.__wbg_ptr); + return takeObject(ret); + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.unknowncredential_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {UnknownCredential} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.unknowncredential_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return UnknownCredential.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {UnknownCredential} + */ + clone() { + const ret = wasm.unknowncredential_clone(this.__wbg_ptr); + return UnknownCredential.__wrap(ret); + } +} +module.exports.UnknownCredential = UnknownCredential; + +const VerificationMethodFinalization = (typeof FinalizationRegistry === 'undefined') + ? { register: () => { }, unregister: () => { } } + : new FinalizationRegistry(ptr => wasm.__wbg_verificationmethod_free(ptr >>> 0, 1)); +/** +* A DID Document Verification Method. +*/ +class VerificationMethod { + + static __wrap(ptr) { + ptr = ptr >>> 0; + const obj = Object.create(VerificationMethod.prototype); + obj.__wbg_ptr = ptr; + VerificationMethodFinalization.register(obj, obj.__wbg_ptr, obj); + return obj; + } + + toJSON() { + return { + }; + } + + toString() { + return JSON.stringify(this); + } + + [inspect.custom]() { + return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); + } + + __destroy_into_raw() { + const ptr = this.__wbg_ptr; + this.__wbg_ptr = 0; + VerificationMethodFinalization.unregister(this); + return ptr; + } + + free() { + const ptr = this.__destroy_into_raw(); + wasm.__wbg_verificationmethod_free(ptr, 0); + } + /** + * Creates a new {@link VerificationMethod} from the given `did` and {@link Jwk}. If `fragment` is not given + * the `kid` value of the given `key` will be used, if present, otherwise an error is returned. + * + * ### Recommendations + * The following recommendations are essentially taken from the `publicKeyJwk` description from the [DID specification](https://www.w3.org/TR/did-core/#dfn-publickeyjwk): + * - It is recommended that verification methods that use `Jwks` to represent their public keys use the value of + * `kid` as their fragment identifier. This is + * done automatically if `None` is passed in as the fragment. + * - It is recommended that {@link Jwk} kid values are set to the public key fingerprint. + * @param {CoreDID | IToCoreDID} did + * @param {Jwk} key + * @param {string | undefined} [fragment] + * @returns {VerificationMethod} + */ + static newFromJwk(did, key, fragment) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(key, Jwk); + var ptr0 = isLikeNone(fragment) ? 0 : passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len0 = WASM_VECTOR_LEN; + wasm.verificationmethod_newFromJwk(retptr, addBorrowedObject(did), key.__wbg_ptr, ptr0, len0); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return VerificationMethod.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Create a custom {@link VerificationMethod}. + * @param {DIDUrl} id + * @param {CoreDID} controller + * @param {MethodType} type_ + * @param {MethodData} data + */ + constructor(id, controller, type_, data) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(id, DIDUrl); + _assertClass(controller, CoreDID); + _assertClass(type_, MethodType); + _assertClass(data, MethodData); + wasm.verificationmethod_new(retptr, id.__wbg_ptr, controller.__wbg_ptr, type_.__wbg_ptr, data.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + this.__wbg_ptr = r0 >>> 0; + VerificationMethodFinalization.register(this, this.__wbg_ptr, this); + return this; + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the {@link DIDUrl} of the {@link VerificationMethod}'s `id`. + * @returns {DIDUrl} + */ + id() { + const ret = wasm.verificationmethod_id(this.__wbg_ptr); + return DIDUrl.__wrap(ret); + } + /** + * Sets the id of the {@link VerificationMethod}. + * @param {DIDUrl} id + */ + setId(id) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + _assertClass(id, DIDUrl); + wasm.verificationmethod_setId(retptr, this.__wbg_ptr, id.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Returns a copy of the `controller` `DID` of the {@link VerificationMethod}. + * @returns {CoreDID} + */ + controller() { + const ret = wasm.verificationmethod_controller(this.__wbg_ptr); + return CoreDID.__wrap(ret); + } + /** + * Sets the `controller` `DID` of the {@link VerificationMethod} object. + * @param {CoreDID} did + */ + setController(did) { + _assertClass(did, CoreDID); + wasm.verificationmethod_setController(this.__wbg_ptr, did.__wbg_ptr); + } + /** + * Returns a copy of the {@link VerificationMethod} type. + * @returns {MethodType} + */ + type() { + const ret = wasm.verificationmethod_type(this.__wbg_ptr); + return MethodType.__wrap(ret); + } + /** + * Sets the {@link VerificationMethod} type. + * @param {MethodType} type_ + */ + setType(type_) { + _assertClass(type_, MethodType); + wasm.verificationmethod_setType(this.__wbg_ptr, type_.__wbg_ptr); + } + /** + * Returns a copy of the {@link VerificationMethod} public key data. + * @returns {MethodData} + */ + data() { + const ret = wasm.verificationmethod_data(this.__wbg_ptr); + return MethodData.__wrap(ret); + } + /** + * Sets {@link VerificationMethod} public key data. + * @param {MethodData} data + */ + setData(data) { + _assertClass(data, MethodData); + wasm.verificationmethod_setData(this.__wbg_ptr, data.__wbg_ptr); + } + /** + * Get custom properties of the Verification Method. + * @returns {Map} + */ + properties() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.verificationmethod_properties(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Adds a custom property to the Verification Method. + * If the value is set to `null`, the custom property will be removed. + * + * ### WARNING + * This method can overwrite existing properties like `id` and result + * in an invalid Verification Method. + * @param {string} key + * @param {any} value + */ + setPropertyUnchecked(key, value) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len0 = WASM_VECTOR_LEN; + wasm.verificationmethod_setPropertyUnchecked(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(value)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + if (r1) { + throw takeObject(r0); + } + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Serializes this to a JSON object. + * @returns {any} + */ + toJSON() { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.verificationmethod_toJSON(retptr, this.__wbg_ptr); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return takeObject(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + } + } + /** + * Deserializes an instance from a JSON object. + * @param {any} json + * @returns {VerificationMethod} + */ + static fromJSON(json) { + try { + const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); + wasm.verificationmethod_fromJSON(retptr, addBorrowedObject(json)); + var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); + var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); + var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); + if (r2) { + throw takeObject(r1); + } + return VerificationMethod.__wrap(r0); + } finally { + wasm.__wbindgen_add_to_stack_pointer(16); + heap[stack_pointer++] = undefined; + } + } + /** + * Deep clones the object. + * @returns {VerificationMethod} + */ + clone() { + const ret = wasm.verificationmethod_clone(this.__wbg_ptr); + return VerificationMethod.__wrap(ret); + } +} +module.exports.VerificationMethod = VerificationMethod; + +module.exports.__wbg_service_new = function (arg0) { + const ret = Service.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbindgen_object_drop_ref = function (arg0) { + takeObject(arg0); +}; + +module.exports.__wbg_verificationmethod_new = function (arg0) { + const ret = VerificationMethod.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_jwt_new = function (arg0) { + const ret = Jwt.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_unknowncredential_new = function (arg0) { + const ret = UnknownCredential.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_jpt_new = function (arg0) { + const ret = Jpt.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_iotadocument_new = function (arg0) { + const ret = IotaDocument.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_coredid_new = function (arg0) { + const ret = CoreDID.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_jws_new = function (arg0) { + const ret = Jws.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_iotadid_new = function (arg0) { + const ret = IotaDID.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_didurl_new = function (arg0) { + const ret = DIDUrl.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_jwkgenoutput_new = function (arg0) { + const ret = JwkGenOutput.__wrap(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbg_payloadentry_unwrap = function (arg0) { + const ret = PayloadEntry.__unwrap(takeObject(arg0)); + return ret; +}; + +module.exports.__wbindgen_string_new = function (arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); + return addHeapObject(ret); +}; + +module.exports.__wbindgen_object_clone_ref = function (arg0) { + const ret = getObject(arg0); + return addHeapObject(ret); +}; + +module.exports.__wbindgen_error_new = function (arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbg_generate_7a89d14c93c6da18 = function (arg0, arg1, arg2, arg3, arg4) { + let deferred0_0; + let deferred0_1; + let deferred1_0; + let deferred1_1; + try { + deferred0_0 = arg1; + deferred0_1 = arg2; + deferred1_0 = arg3; + deferred1_1 = arg4; + const ret = getObject(arg0).generate(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); + return addHeapObject(ret); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); + } +}; + +module.exports.__wbg_insert_da8b50c74383af0d = function (arg0, arg1) { + const ret = getObject(arg0).insert(Jwk.__wrap(arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbg_sign_421bfbd38dd4553a = function (arg0, arg1, arg2, arg3, arg4, arg5) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg1; + deferred0_1 = arg2; + var v1 = getArrayU8FromWasm0(arg3, arg4).slice(); + wasm.__wbindgen_free(arg3, arg4 * 1, 1); + const ret = getObject(arg0).sign(getStringFromWasm0(arg1, arg2), v1, Jwk.__wrap(arg5)); + return addHeapObject(ret); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } +}; + +module.exports.__wbg_delete_2ee32e53cb78797f = function (arg0, arg1, arg2) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg1; + deferred0_1 = arg2; + const ret = getObject(arg0).delete(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } +}; + +module.exports.__wbg_getkey_7593da5ee7e5f5f0 = function (arg0, arg1, arg2) { + const ret = getObject(arg0)._get_key(getStringFromWasm0(arg1, arg2)); + let ptr1 = 0; + if (!isLikeNone(ret)) { + _assertClass(ret, Jwk); + ptr1 = ret.__destroy_into_raw(); + } + return ptr1; +}; + +module.exports.__wbindgen_is_string = function (arg0) { + const ret = typeof (getObject(arg0)) === 'string'; + return ret; +}; + +module.exports.__wbg_client_9b83f75e2726d87f = function (arg0) { + const ret = getObject(arg0).client; + return isLikeNone(ret) ? 0 : addHeapObject(ret); +}; + +module.exports.__wbg_handlers_faa84e527a39cdf8 = function (arg0) { + const ret = getObject(arg0).handlers; + return isLikeNone(ret) ? 0 : addHeapObject(ret); +}; + +module.exports.__wbindgen_json_parse = function (arg0, arg1) { + const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbindgen_json_serialize = function (arg0, arg1) { + const obj = getObject(arg1); + const ret = JSON.stringify(obj === undefined ? null : obj); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); +}; + +module.exports.__wbg_getAliasOutput_cec17fa4c27f521a = function (arg0, arg1, arg2) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg1; + deferred0_1 = arg2; + const ret = getObject(arg0).getAliasOutput(getStringFromWasm0(arg1, arg2)); + return addHeapObject(ret); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } +}; + +module.exports.__wbg_getProtocolParameters_c2d053891e679b55 = function (arg0) { + const ret = getObject(arg0).getProtocolParameters(); + return addHeapObject(ret); +}; + +module.exports.__wbg_insertKeyId_99b1ef8ced0ab42e = function (arg0, arg1, arg2, arg3) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg2; + deferred0_1 = arg3; + const ret = getObject(arg0).insertKeyId(MethodDigest.__wrap(arg1), getStringFromWasm0(arg2, arg3)); + return addHeapObject(ret); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } +}; + +module.exports.__wbg_getKeyId_5b3b70e12f7e53aa = function (arg0, arg1) { + const ret = getObject(arg0).getKeyId(MethodDigest.__wrap(arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbg_deleteKeyId_e47ce8f9b5a1d684 = function (arg0, arg1) { + const ret = getObject(arg0).deleteKeyId(MethodDigest.__wrap(arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbg_verify_0b54d052c343c289 = function () { + return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg1; + deferred0_1 = arg2; + var v1 = getArrayU8FromWasm0(arg3, arg4).slice(); + wasm.__wbindgen_free(arg3, arg4 * 1, 1); + var v2 = getArrayU8FromWasm0(arg5, arg6).slice(); + wasm.__wbindgen_free(arg5, arg6 * 1, 1); + getObject(arg0).verify(getStringFromWasm0(arg1, arg2), v1, v2, Jwk.__wrap(arg7)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } + }, arguments) +}; + +module.exports.__wbindgen_string_get = function (arg0, arg1) { + const obj = getObject(arg1); + const ret = typeof (obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); +}; + +module.exports.__wbg_maybeGetIotaDocumentInternal_fd250ef4074a0c1e = function (arg0) { + const ret = _maybeGetIotaDocumentInternal(getObject(arg0)); + let ptr1 = 0; + if (!isLikeNone(ret)) { + _assertClass(ret, IotaDocument); + ptr1 = ret.__destroy_into_raw(); + } + return ptr1; +}; + +module.exports.__wbg_getCoreDocumentInternal_e937cd8649fc1d76 = function (arg0) { + const ret = _getCoreDocumentInternal(getObject(arg0)); + _assertClass(ret, CoreDocument); + var ptr1 = ret.__destroy_into_raw(); + return ptr1; +}; + +module.exports.__wbg_id_81f123397a43f160 = function (arg0) { + const ret = getObject(arg0).id; + return addHeapObject(ret); +}; + +module.exports.__wbg_type_a6d92648720e7f8b = function (arg0) { + const ret = getObject(arg0).type; + return addHeapObject(ret); +}; + +module.exports.__wbg_serviceEndpoint_3133f0c11b566fad = function (arg0) { + const ret = getObject(arg0).serviceEndpoint; + return addHeapObject(ret); +}; + +module.exports.__wbg_properties_4246821a1cd87560 = function (arg0) { + const ret = getObject(arg0).properties; + return addHeapObject(ret); +}; + +module.exports.__wbg_getCoreDidCloneInternal_9d05a6ed9c0bc653 = function (arg0) { + const ret = _getCoreDidCloneInternal(getObject(arg0)); + _assertClass(ret, CoreDID); + var ptr1 = ret.__destroy_into_raw(); + return ptr1; +}; + +module.exports.__wbg_new_abda76e883ba8a5f = function () { + const ret = new Error(); + return addHeapObject(ret); +}; + +module.exports.__wbg_stack_658279fe44541cf6 = function (arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); +}; + +module.exports.__wbg_error_f851667af71bcfc6 = function (arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } +}; + +module.exports.__wbg_queueMicrotask_12a30234db4045d3 = function (arg0) { + queueMicrotask(getObject(arg0)); +}; + +module.exports.__wbg_queueMicrotask_48421b3cc9052b68 = function (arg0) { + const ret = getObject(arg0).queueMicrotask; + return addHeapObject(ret); +}; + +module.exports.__wbindgen_is_function = function (arg0) { + const ret = typeof (getObject(arg0)) === 'function'; + return ret; +}; + +module.exports.__wbindgen_cb_drop = function (arg0) { + const obj = takeObject(arg0).original; + if (obj.cnt-- == 1) { + obj.a = 0; + return true; + } + const ret = false; + return ret; +}; + +module.exports.__wbg_crypto_1d1f22824a6a080c = function (arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); +}; + +module.exports.__wbindgen_is_object = function (arg0) { + const val = getObject(arg0); + const ret = typeof (val) === 'object' && val !== null; + return ret; +}; + +module.exports.__wbg_process_4a72847cc503995b = function (arg0) { + const ret = getObject(arg0).process; + return addHeapObject(ret); +}; + +module.exports.__wbg_versions_f686565e586dd935 = function (arg0) { + const ret = getObject(arg0).versions; + return addHeapObject(ret); +}; + +module.exports.__wbg_node_104a2ff8d6ea03a2 = function (arg0) { + const ret = getObject(arg0).node; + return addHeapObject(ret); +}; + +module.exports.__wbg_require_cca90b1a94a0255b = function () { + return handleError(function () { + const ret = module.require; + return addHeapObject(ret); + }, arguments) +}; + +module.exports.__wbg_msCrypto_eb05e62b530a1508 = function (arg0) { + const ret = getObject(arg0).msCrypto; + return addHeapObject(ret); +}; + +module.exports.__wbg_randomFillSync_5c9c955aa56b6049 = function () { + return handleError(function (arg0, arg1) { + getObject(arg0).randomFillSync(takeObject(arg1)); + }, arguments) +}; + +module.exports.__wbg_getRandomValues_3aa56aa6edec874c = function () { + return handleError(function (arg0, arg1) { + getObject(arg0).getRandomValues(getObject(arg1)); + }, arguments) +}; + +module.exports.__wbg_get_3baa728f9d58d3f6 = function (arg0, arg1) { + const ret = getObject(arg0)[arg1 >>> 0]; + return addHeapObject(ret); +}; + +module.exports.__wbg_length_ae22078168b726f5 = function (arg0) { + const ret = getObject(arg0).length; + return ret; +}; + +module.exports.__wbg_new_a220cf903aa02ca2 = function () { + const ret = new Array(); + return addHeapObject(ret); +}; + +module.exports.__wbg_newnoargs_76313bd6ff35d0f2 = function (arg0, arg1) { + const ret = new Function(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbg_new_8608a2b51a5f6737 = function () { + const ret = new Map(); + return addHeapObject(ret); +}; + +module.exports.__wbg_next_f9cb570345655b9a = function () { + return handleError(function (arg0) { + const ret = getObject(arg0).next(); + return addHeapObject(ret); + }, arguments) +}; + +module.exports.__wbg_done_bfda7aa8f252b39f = function (arg0) { + const ret = getObject(arg0).done; + return ret; +}; + +module.exports.__wbg_value_6d39332ab4788d86 = function (arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); +}; + +module.exports.__wbg_call_1084a111329e68ce = function () { + return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); + return addHeapObject(ret); + }, arguments) +}; + +module.exports.__wbg_self_3093d5d1f7bcb682 = function () { + return handleError(function () { + const ret = self.self; + return addHeapObject(ret); + }, arguments) +}; + +module.exports.__wbg_window_3bcfc4d31bc012f8 = function () { + return handleError(function () { + const ret = window.window; + return addHeapObject(ret); + }, arguments) +}; + +module.exports.__wbg_globalThis_86b222e13bdf32ed = function () { + return handleError(function () { + const ret = globalThis.globalThis; + return addHeapObject(ret); + }, arguments) +}; + +module.exports.__wbg_global_e5a3fe56f8be9485 = function () { + return handleError(function () { + const ret = global.global; + return addHeapObject(ret); + }, arguments) +}; + +module.exports.__wbindgen_is_undefined = function (arg0) { + const ret = getObject(arg0) === undefined; + return ret; +}; + +module.exports.__wbg_from_0791d740a9d37830 = function (arg0) { + const ret = Array.from(getObject(arg0)); + return addHeapObject(ret); +}; + +module.exports.__wbg_isArray_8364a5371e9737d8 = function (arg0) { + const ret = Array.isArray(getObject(arg0)); + return ret; +}; + +module.exports.__wbg_push_37c89022f34c01ca = function (arg0, arg1) { + const ret = getObject(arg0).push(getObject(arg1)); + return ret; +}; + +module.exports.__wbg_instanceof_Error_69bde193b0cc95e3 = function (arg0) { + let result; + try { + result = getObject(arg0) instanceof Error; + } catch (_) { + result = false; + } + const ret = result; + return ret; +}; + +module.exports.__wbg_new_796382978dfd4fb0 = function (arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbg_setname_ef058a4c6ff7e6d4 = function (arg0, arg1, arg2) { + getObject(arg0).name = getStringFromWasm0(arg1, arg2); +}; + +module.exports.__wbg_toString_9d18e102ca933e68 = function (arg0) { + const ret = getObject(arg0).toString(); + return addHeapObject(ret); +}; + +module.exports.__wbg_call_89af060b4e1523f2 = function () { + return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) +}; + +module.exports.__wbg_instanceof_Map_763ce0e95960d55e = function (arg0) { + let result; + try { + result = getObject(arg0) instanceof Map; + } catch (_) { + result = false; + } + const ret = result; + return ret; +}; + +module.exports.__wbg_get_5a402b270e32a550 = function (arg0, arg1) { + const ret = getObject(arg0).get(getObject(arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbg_set_49185437f0ab06f8 = function (arg0, arg1, arg2) { + const ret = getObject(arg0).set(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); +}; + +module.exports.__wbg_keys_2a4853eb6ff523cf = function (arg0) { + const ret = getObject(arg0).keys(); + return addHeapObject(ret); +}; + +module.exports.__wbg_now_b7a162010a9e75b4 = function () { + const ret = Date.now(); + return ret; +}; + +module.exports.__wbg_fromEntries_623a5958a8dd4673 = function () { + return handleError(function (arg0) { + const ret = Object.fromEntries(getObject(arg0)); + return addHeapObject(ret); + }, arguments) +}; + +module.exports.__wbg_new_b85e72ed1bfd57f9 = function (arg0, arg1) { + try { + var state0 = { a: arg0, b: arg1 }; + var cb0 = (arg0, arg1) => { + const a = state0.a; + state0.a = 0; + try { + return __wbg_adapter_813(a, state0.b, arg0, arg1); + } finally { + state0.a = a; + } + }; + const ret = new Promise(cb0); + return addHeapObject(ret); + } finally { + state0.a = state0.b = 0; + } +}; + +module.exports.__wbg_resolve_570458cb99d56a43 = function (arg0) { + const ret = Promise.resolve(getObject(arg0)); + return addHeapObject(ret); +}; + +module.exports.__wbg_then_95e6edc0f89b73b1 = function (arg0, arg1) { + const ret = getObject(arg0).then(getObject(arg1)); + return addHeapObject(ret); +}; + +module.exports.__wbg_then_876bb3c633745cc6 = function (arg0, arg1, arg2) { + const ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); +}; + +module.exports.__wbg_buffer_b7b08af79b0b0974 = function (arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); +}; + +module.exports.__wbg_newwithbyteoffsetandlength_8a2cb9ca96b27ec9 = function (arg0, arg1, arg2) { + const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); +}; + +module.exports.__wbg_new_ea1883e1e5e86686 = function (arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); +}; + +module.exports.__wbg_set_d1e79e2388520f18 = function (arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); +}; + +module.exports.__wbg_length_8339fcf5d8ecd12e = function (arg0) { + const ret = getObject(arg0).length; + return ret; +}; + +module.exports.__wbg_instanceof_Uint8Array_247a91427532499e = function (arg0) { + let result; + try { + result = getObject(arg0) instanceof Uint8Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; +}; + +module.exports.__wbg_newwithlength_ec548f448387c968 = function (arg0) { + const ret = new Uint8Array(arg0 >>> 0); + return addHeapObject(ret); +}; + +module.exports.__wbg_subarray_7c2e3576afe181d1 = function (arg0, arg1, arg2) { + const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); + return addHeapObject(ret); +}; + +module.exports.__wbindgen_debug_string = function (arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); +}; + +module.exports.__wbindgen_throw = function (arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); +}; + +module.exports.__wbindgen_memory = function () { + const ret = wasm.memory; + return addHeapObject(ret); +}; + +module.exports.__wbindgen_closure_wrapper4915 = function (arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 557, __wbg_adapter_32); + return addHeapObject(ret); +}; + +const path = require('path').join(__dirname, 'identity_wasm_bg.wasm'); +const bytes = require('fs').readFileSync(path); + +const wasmModule = new WebAssembly.Module(bytes); +const wasmInstance = new WebAssembly.Instance(wasmModule, imports); +wasm = wasmInstance.exports; +module.exports.__wasm = wasm; + +wasm.__wbindgen_start(); + From 6409ccc21ec83f69df873584bed2b8b81648f3f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eike=20Ha=C3=9F?= Date: Tue, 27 Aug 2024 10:15:30 +0200 Subject: [PATCH 02/21] extend config --- bindings/wasm/package.json | 2 +- bindings/wasm/typedoc.json | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 17125fb127..210b936c29 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -33,7 +33,7 @@ "cypress": "cypress open", "fmt": "dprint fmt", "fix_js_doc": "sed -Ei 's/\\((.*)\\)\\[\\]/\\1\\[\\]/' ./node/identity_wasm.js", - "create-api-docs": "typedoc ./node/identity_wasm.d.ts" + "create-api-docs": "typedoc" }, "config": { "CYPRESS_VERIFY_TIMEOUT": 100000 diff --git a/bindings/wasm/typedoc.json b/bindings/wasm/typedoc.json index eab9511796..168a8d7be1 100644 --- a/bindings/wasm/typedoc.json +++ b/bindings/wasm/typedoc.json @@ -5,8 +5,12 @@ "excludeInternal": true, "excludeNotDocumented": true, "excludeExternals": true, + "entryPoints": ["./lib/"], + "exclude": ["./lib/jose"], + "entryPointStrategy": "expand", + "tsconfig": "./lib/tsconfig.json", "out": "./docs/api", - "externalPattern": ["lib/*.ts"], + // "externalPattern": ["lib/*.ts"], "compilerOptions": { "skipLibCheck": true, } From 16be6671800ca3f3ca1a0e66186a067f7903b6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eike=20Ha=C3=9F?= Date: Tue, 27 Aug 2024 10:15:30 +0200 Subject: [PATCH 03/21] extend config --- bindings/wasm/package.json | 2 +- bindings/wasm/typedoc.json | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 17125fb127..210b936c29 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -33,7 +33,7 @@ "cypress": "cypress open", "fmt": "dprint fmt", "fix_js_doc": "sed -Ei 's/\\((.*)\\)\\[\\]/\\1\\[\\]/' ./node/identity_wasm.js", - "create-api-docs": "typedoc ./node/identity_wasm.d.ts" + "create-api-docs": "typedoc" }, "config": { "CYPRESS_VERIFY_TIMEOUT": 100000 diff --git a/bindings/wasm/typedoc.json b/bindings/wasm/typedoc.json index eab9511796..05e940cf33 100644 --- a/bindings/wasm/typedoc.json +++ b/bindings/wasm/typedoc.json @@ -5,9 +5,12 @@ "excludeInternal": true, "excludeNotDocumented": true, "excludeExternals": true, + "entryPoints": ["./lib/"], + "entryPointStrategy": "expand", + "tsconfig": "./lib/tsconfig.json", "out": "./docs/api", - "externalPattern": ["lib/*.ts"], + // "externalPattern": ["lib/*.ts"], "compilerOptions": { "skipLibCheck": true, } -} +} \ No newline at end of file From d71ca91996e6a7dc5117a323a48a89d2855d14f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eike=20Ha=C3=9F?= Date: Wed, 28 Aug 2024 09:50:35 +0200 Subject: [PATCH 04/21] rework docs build --- .gitignore | 2 + bindings/wasm/docs/api-reference.md | 7680 --------------------------- bindings/wasm/tsconfig.typedoc.json | 4 + bindings/wasm/typedoc.json | 4 +- 4 files changed, 8 insertions(+), 7682 deletions(-) delete mode 100644 bindings/wasm/docs/api-reference.md create mode 100644 bindings/wasm/tsconfig.typedoc.json diff --git a/.gitignore b/.gitignore index 5a33dbab25..52f081d501 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ index.html *.hodl.* !/bindings/wasm/static/index.html + +docs diff --git a/bindings/wasm/docs/api-reference.md b/bindings/wasm/docs/api-reference.md deleted file mode 100644 index db03dc07ec..0000000000 --- a/bindings/wasm/docs/api-reference.md +++ /dev/null @@ -1,7680 +0,0 @@ -## Classes - -
-
CoreDID
-

A method-agnostic Decentralized Identifier (DID).

-
-
CoreDocument
-

A method-agnostic DID Document.

-

Note: All methods that involve reading from this class may potentially raise an error -if the object is being concurrently modified.

-
-
Credential
-
-
CustomMethodData
-

A custom verification method data format.

-
-
DIDUrl
-

A method agnostic DID Url.

-
-
DecodedJptCredential
-
-
DecodedJptPresentation
-
-
DecodedJws
-

A cryptographically verified decoded token from a JWS.

-

Contains the decoded headers and the raw claims.

-
-
DecodedJwtCredential
-

A cryptographically verified and decoded Credential.

-

Note that having an instance of this type only means the JWS it was constructed from was verified. -It does not imply anything about a potentially present proof property on the credential itself.

-
-
DecodedJwtPresentation
-

A cryptographically verified and decoded presentation.

-

Note that having an instance of this type only means the JWS it was constructed from was verified. -It does not imply anything about a potentially present proof property on the presentation itself.

-
-
Disclosure
-

Represents an elements constructing a disclosure. -Object properties and array elements disclosures are supported.

-

See: https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-disclosures

-
-
DomainLinkageConfiguration
-

DID Configuration Resource which contains Domain Linkage Credentials. -It can be placed in an origin's .well-known directory to prove linkage between the origin and a DID. -See: https://identity.foundation/.well-known/resources/did-configuration/#did-configuration-resource

-

Note:

- -
-
Duration
-

A span of time.

-
-
EdDSAJwsVerifier
-

An implementor of IJwsVerifier that can handle the -EdDSA algorithm.

-
-
IotaDID
-

A DID conforming to the IOTA DID method specification.

-
-
IotaDocument
-

A DID Document adhering to the IOTA DID method specification.

-

Note: All methods that involve reading from this class may potentially raise an error -if the object is being concurrently modified.

-
-
IotaDocumentMetadata
-

Additional attributes related to an IOTA DID Document.

-
-
IotaIdentityClientExt
-

An extension interface that provides helper functions for publication -and resolution of DID documents in Alias Outputs.

-
-
IssuerProtectedHeader
-
-
Jpt
-

A JSON Proof Token (JPT).

-
-
JptCredentialValidationOptions
-

Options to declare validation criteria for Jpt.

-
-
JptCredentialValidator
-
-
JptCredentialValidatorUtils
-

Utility functions for validating JPT credentials.

-
-
JptPresentationValidationOptions
-

Options to declare validation criteria for a Jpt presentation.

-
-
JptPresentationValidator
-
-
JptPresentationValidatorUtils
-

Utility functions for verifying JPT presentations.

-
-
Jwk
-
-
JwkGenOutput
-

The result of a key generation in JwkStorage.

-
-
JwpCredentialOptions
-
-
JwpIssued
-
-
JwpPresentationOptions
-

Options to be set in the JWT claims of a verifiable presentation.

-
-
JwpVerificationOptions
-
-
Jws
-

A wrapper around a JSON Web Signature (JWS).

-
-
JwsHeader
-
-
JwsSignatureOptions
-
-
JwsVerificationOptions
-
-
Jwt
-

A wrapper around a JSON Web Token (JWK).

-
-
JwtCredentialValidationOptions
-

Options to declare validation criteria when validating credentials.

-
-
JwtCredentialValidator
-

A type for decoding and validating Credential.

-
-
JwtDomainLinkageValidator
-

A validator for a Domain Linkage Configuration and Credentials.

-
-
JwtPresentationOptions
-
-
JwtPresentationValidationOptions
-

Options to declare validation criteria when validating presentation.

-
-
JwtPresentationValidator
-
-
KeyBindingJWTValidationOptions
-

Options to declare validation criteria when validating credentials.

-
-
KeyBindingJwtClaims
-

Claims set for key binding JWT.

-
-
LinkedDomainService
-
-
MethodData
-

Supported verification method data formats.

-
-
MethodDigest
-

Unique identifier of a VerificationMethod.

-

NOTE: -This class does not have a JSON representation, -use the methods pack and unpack instead.

-
-
MethodScope
-

Supported verification method types.

-
-
MethodType
-

Supported verification method types.

-
-
PayloadEntry
-
-
Payloads
-
-
Presentation
-
-
PresentationProtectedHeader
-
-
Proof
-

Represents a cryptographic proof that can be used to validate verifiable credentials and -presentations.

-

This representation does not inherently implement any standard; instead, it -can be utilized to implement standards or user-defined proofs. The presence of the -type field is necessary to accommodate different types of cryptographic proofs.

-

Note that this proof is not related to JWT and can be used in combination or as an alternative -to it.

-
-
ProofUpdateCtx
-
-
Resolver
-

Convenience type for resolving DID documents from different DID methods.

-

Also provides methods for resolving DID Documents associated with -verifiable Credentials and Presentations.

-

Configuration

-

The resolver will only be able to resolve DID documents for methods it has been configured for in the constructor.

-
-
RevocationBitmap
-

A compressed bitmap for managing credential revocation.

-
-
RevocationTimeframeStatus
-

Information used to determine the current status of a Credential.

-
-
SdJwt
-

Representation of an SD-JWT of the format -<Issuer-signed JWT>~<Disclosure 1>~<Disclosure 2>~...~<Disclosure N>~<optional KB-JWT>.

-
-
SdJwtCredentialValidator
-

A type for decoding and validating Credential.

-
-
SdObjectDecoder
-

Substitutes digests in an SD-JWT object by their corresponding plaintext values provided by disclosures.

-
-
SdObjectEncoder
-

Transforms a JSON object into an SD-JWT object by substituting selected values -with their corresponding disclosure digests.

-

Note: digests are created using the sha-256 algorithm.

-
-
SelectiveDisclosurePresentation
-

Used to construct a JwpPresentedBuilder and handle the selective disclosure of attributes

-
    -
  • @context MUST NOT be blinded
  • -
  • id MUST be blinded
  • -
  • type MUST NOT be blinded
  • -
  • issuer MUST NOT be blinded
  • -
  • issuanceDate MUST be blinded (if Timeframe Revocation mechanism is used)
  • -
  • expirationDate MUST be blinded (if Timeframe Revocation mechanism is used)
  • -
  • credentialSubject (User have to choose which attribute must be blinded)
  • -
  • credentialSchema MUST NOT be blinded
  • -
  • credentialStatus MUST NOT be blinded
  • -
  • refreshService MUST NOT be blinded (probably will be used for Timeslot Revocation mechanism)
  • -
  • termsOfUse NO reason to use it in ZK VC (will be in any case blinded)
  • -
  • evidence (User have to choose which attribute must be blinded)
  • -
-
-
Service
-

A DID Document Service used to enable trusted interactions associated with a DID subject.

-
-
StatusList2021
-

StatusList2021 data structure as described in W3C's VC status list 2021.

-
-
StatusList2021Credential
-

A parsed StatusList2021Credential.

-
-
StatusList2021CredentialBuilder
-

Builder type to construct valid StatusList2021Credential istances.

-
-
StatusList2021Entry
-

StatusList2021Entry implementation.

-
-
Storage
-

A type wrapping a JwkStorage and KeyIdStorage that should always be used together when -working with storage backed DID documents.

-
-
Timestamp
-
-
UnknownCredential
-
-
VerificationMethod
-

A DID Document Verification Method.

-
-
- -## Members - -
-
PresentationProofAlgorithm
-
-
ProofAlgorithm
-
-
StatusCheck
-

Controls validation behaviour when checking whether or not a credential has been revoked by its -credentialStatus.

-
-
Strict
-

Validate the status if supported, reject any unsupported -credentialStatus types.

-

Only RevocationBitmap2022 is currently supported.

-

This is the default.

-
-
SkipUnsupported
-

Validate the status if supported, skip any unsupported -credentialStatus types.

-
-
SkipAll
-

Skip all status checks.

-
-
SerializationType
-
-
MethodRelationship
-
-
SubjectHolderRelationship
-

Declares how credential subjects must relate to the presentation holder.

-

See also the Subject-Holder Relationship section of the specification.

-
-
AlwaysSubject
-

The holder must always match the subject on all credentials, regardless of their nonTransferable property. -This variant is the default.

-
-
SubjectOnNonTransferable
-

The holder must match the subject only for credentials where the nonTransferable property is true.

-
-
Any
-

The holder is not required to have any kind of relationship to any credential subject.

-
-
CredentialStatus
-
-
StatusPurpose
-

Purpose of a StatusList2021.

-
-
StateMetadataEncoding
-
-
FailFast
-

Declares when validation should return if an error occurs.

-
-
AllErrors
-

Return all errors that occur during validation.

-
-
FirstError
-

Return after the first error occurs.

-
-
PayloadType
-
-
MethodRelationship
-
-
CredentialStatus
-
-
StatusCheck
-

Controls validation behaviour when checking whether or not a credential has been revoked by its -credentialStatus.

-
-
Strict
-

Validate the status if supported, reject any unsupported -credentialStatus types.

-

Only RevocationBitmap2022 is currently supported.

-

This is the default.

-
-
SkipUnsupported
-

Validate the status if supported, skip any unsupported -credentialStatus types.

-
-
SkipAll
-

Skip all status checks.

-
-
- -## Functions - -
-
verifyEd25519(alg, signingInput, decodedSignature, publicKey)
-

Verify a JWS signature secured with the EdDSA algorithm and curve Ed25519.

-

This function is useful when one is composing a IJwsVerifier that delegates -EdDSA verification with curve Ed25519 to this function.

-

Warning

-

This function does not check whether alg = EdDSA in the protected header. Callers are expected to assert this -prior to calling the function.

-
-
start()
-

Initializes the console error panic hook for better error messages

-
-
encodeB64(data) ⇒ string
-

Encode the given bytes in url-safe base64.

-
-
decodeB64(data) ⇒ Uint8Array
-

Decode the given url-safe base64-encoded slice into its raw bytes.

-
-
start()
-

Initializes the console error panic hook for better error messages

-
-
- - - -## CoreDID -A method-agnostic Decentralized Identifier (DID). - -**Kind**: global class - -* [CoreDID](#CoreDID) - * _instance_ - * [.setMethodName(value)](#CoreDID+setMethodName) - * [.setMethodId(value)](#CoreDID+setMethodId) - * [.scheme()](#CoreDID+scheme) ⇒ string - * [.authority()](#CoreDID+authority) ⇒ string - * [.method()](#CoreDID+method) ⇒ string - * [.methodId()](#CoreDID+methodId) ⇒ string - * [.join(segment)](#CoreDID+join) ⇒ [DIDUrl](#DIDUrl) - * [.toUrl()](#CoreDID+toUrl) ⇒ [DIDUrl](#DIDUrl) - * [.intoUrl()](#CoreDID+intoUrl) ⇒ [DIDUrl](#DIDUrl) - * [.toString()](#CoreDID+toString) ⇒ string - * [.toCoreDid()](#CoreDID+toCoreDid) ⇒ [CoreDID](#CoreDID) - * [.toJSON()](#CoreDID+toJSON) ⇒ any - * [.clone()](#CoreDID+clone) ⇒ [CoreDID](#CoreDID) - * _static_ - * [.parse(input)](#CoreDID.parse) ⇒ [CoreDID](#CoreDID) - * [.validMethodName(value)](#CoreDID.validMethodName) ⇒ boolean - * [.validMethodId(value)](#CoreDID.validMethodId) ⇒ boolean - * [.fromJSON(json)](#CoreDID.fromJSON) ⇒ [CoreDID](#CoreDID) - - - -### coreDID.setMethodName(value) -Set the method name of the [CoreDID](#CoreDID). - -**Kind**: instance method of [CoreDID](#CoreDID) - -| Param | Type | -| --- | --- | -| value | string | - - - -### coreDID.setMethodId(value) -Set the method-specific-id of the `DID`. - -**Kind**: instance method of [CoreDID](#CoreDID) - -| Param | Type | -| --- | --- | -| value | string | - - - -### coreDID.scheme() ⇒ string -Returns the [CoreDID](#CoreDID) scheme. - -E.g. -- `"did:example:12345678" -> "did"` -- `"did:iota:smr:12345678" -> "did"` - -**Kind**: instance method of [CoreDID](#CoreDID) - - -### coreDID.authority() ⇒ string -Returns the [CoreDID](#CoreDID) authority: the method name and method-id. - -E.g. -- `"did:example:12345678" -> "example:12345678"` -- `"did:iota:smr:12345678" -> "iota:smr:12345678"` - -**Kind**: instance method of [CoreDID](#CoreDID) - - -### coreDID.method() ⇒ string -Returns the [CoreDID](#CoreDID) method name. - -E.g. -- `"did:example:12345678" -> "example"` -- `"did:iota:smr:12345678" -> "iota"` - -**Kind**: instance method of [CoreDID](#CoreDID) - - -### coreDID.methodId() ⇒ string -Returns the [CoreDID](#CoreDID) method-specific ID. - -E.g. -- `"did:example:12345678" -> "12345678"` -- `"did:iota:smr:12345678" -> "smr:12345678"` - -**Kind**: instance method of [CoreDID](#CoreDID) - - -### coreDID.join(segment) ⇒ [DIDUrl](#DIDUrl) -Construct a new [DIDUrl](#DIDUrl) by joining with a relative DID Url string. - -**Kind**: instance method of [CoreDID](#CoreDID) - -| Param | Type | -| --- | --- | -| segment | string | - - - -### coreDID.toUrl() ⇒ [DIDUrl](#DIDUrl) -Clones the [CoreDID](#CoreDID) into a [DIDUrl](#DIDUrl). - -**Kind**: instance method of [CoreDID](#CoreDID) - - -### coreDID.intoUrl() ⇒ [DIDUrl](#DIDUrl) -Converts the [CoreDID](#CoreDID) into a [DIDUrl](#DIDUrl), consuming it. - -**Kind**: instance method of [CoreDID](#CoreDID) - - -### coreDID.toString() ⇒ string -Returns the [CoreDID](#CoreDID) as a string. - -**Kind**: instance method of [CoreDID](#CoreDID) - - -### coreDID.toCoreDid() ⇒ [CoreDID](#CoreDID) -**Kind**: instance method of [CoreDID](#CoreDID) - - -### coreDID.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [CoreDID](#CoreDID) - - -### coreDID.clone() ⇒ [CoreDID](#CoreDID) -Deep clones the object. - -**Kind**: instance method of [CoreDID](#CoreDID) - - -### CoreDID.parse(input) ⇒ [CoreDID](#CoreDID) -Parses a [CoreDID](#CoreDID) from the given `input`. - -### Errors - -Throws an error if the input is not a valid [CoreDID](#CoreDID). - -**Kind**: static method of [CoreDID](#CoreDID) - -| Param | Type | -| --- | --- | -| input | string | - - - -### CoreDID.validMethodName(value) ⇒ boolean -Validates whether a string is a valid DID method name. - -**Kind**: static method of [CoreDID](#CoreDID) - -| Param | Type | -| --- | --- | -| value | string | - - - -### CoreDID.validMethodId(value) ⇒ boolean -Validates whether a string is a valid `DID` method-id. - -**Kind**: static method of [CoreDID](#CoreDID) - -| Param | Type | -| --- | --- | -| value | string | - - - -### CoreDID.fromJSON(json) ⇒ [CoreDID](#CoreDID) -Deserializes an instance from a JSON object. - -**Kind**: static method of [CoreDID](#CoreDID) - -| Param | Type | -| --- | --- | -| json | any | - - - -## CoreDocument -A method-agnostic DID Document. - -Note: All methods that involve reading from this class may potentially raise an error -if the object is being concurrently modified. - -**Kind**: global class - -* [CoreDocument](#CoreDocument) - * [new CoreDocument(values)](#new_CoreDocument_new) - * _instance_ - * [.id()](#CoreDocument+id) ⇒ [CoreDID](#CoreDID) - * [.setId(id)](#CoreDocument+setId) - * [.controller()](#CoreDocument+controller) ⇒ [Array.<CoreDID>](#CoreDID) - * [.setController(controllers)](#CoreDocument+setController) - * [.alsoKnownAs()](#CoreDocument+alsoKnownAs) ⇒ Array.<string> - * [.setAlsoKnownAs(urls)](#CoreDocument+setAlsoKnownAs) - * [.verificationMethod()](#CoreDocument+verificationMethod) ⇒ [Array.<VerificationMethod>](#VerificationMethod) - * [.authentication()](#CoreDocument+authentication) ⇒ Array.<(DIDUrl\|VerificationMethod)> - * [.assertionMethod()](#CoreDocument+assertionMethod) ⇒ Array.<(DIDUrl\|VerificationMethod)> - * [.keyAgreement()](#CoreDocument+keyAgreement) ⇒ Array.<(DIDUrl\|VerificationMethod)> - * [.capabilityDelegation()](#CoreDocument+capabilityDelegation) ⇒ Array.<(DIDUrl\|VerificationMethod)> - * [.capabilityInvocation()](#CoreDocument+capabilityInvocation) ⇒ Array.<(DIDUrl\|VerificationMethod)> - * [.properties()](#CoreDocument+properties) ⇒ Map.<string, any> - * [.setPropertyUnchecked(key, value)](#CoreDocument+setPropertyUnchecked) - * [.service()](#CoreDocument+service) ⇒ [Array.<Service>](#Service) - * [.insertService(service)](#CoreDocument+insertService) - * [.removeService(didUrl)](#CoreDocument+removeService) ⇒ [Service](#Service) \| undefined - * [.resolveService(query)](#CoreDocument+resolveService) ⇒ [Service](#Service) \| undefined - * [.methods([scope])](#CoreDocument+methods) ⇒ [Array.<VerificationMethod>](#VerificationMethod) - * [.verificationRelationships()](#CoreDocument+verificationRelationships) ⇒ Array.<(DIDUrl\|VerificationMethod)> - * [.insertMethod(method, scope)](#CoreDocument+insertMethod) - * [.removeMethod(did)](#CoreDocument+removeMethod) ⇒ [VerificationMethod](#VerificationMethod) \| undefined - * [.resolveMethod(query, [scope])](#CoreDocument+resolveMethod) ⇒ [VerificationMethod](#VerificationMethod) \| undefined - * [.attachMethodRelationship(didUrl, relationship)](#CoreDocument+attachMethodRelationship) ⇒ boolean - * [.detachMethodRelationship(didUrl, relationship)](#CoreDocument+detachMethodRelationship) ⇒ boolean - * [.verifyJws(jws, options, signatureVerifier, [detachedPayload])](#CoreDocument+verifyJws) ⇒ [DecodedJws](#DecodedJws) - * [.revokeCredentials(serviceQuery, indices)](#CoreDocument+revokeCredentials) - * [.unrevokeCredentials(serviceQuery, indices)](#CoreDocument+unrevokeCredentials) - * [.clone()](#CoreDocument+clone) ⇒ [CoreDocument](#CoreDocument) - * [._shallowCloneInternal()](#CoreDocument+_shallowCloneInternal) ⇒ [CoreDocument](#CoreDocument) - * [._strongCountInternal()](#CoreDocument+_strongCountInternal) ⇒ number - * [.toJSON()](#CoreDocument+toJSON) ⇒ any - * [.generateMethod(storage, keyType, alg, fragment, scope)](#CoreDocument+generateMethod) ⇒ Promise.<string> - * [.purgeMethod(storage, id)](#CoreDocument+purgeMethod) ⇒ Promise.<void> - * [.createJws(storage, fragment, payload, options)](#CoreDocument+createJws) ⇒ [Promise.<Jws>](#Jws) - * [.createCredentialJwt(storage, fragment, credential, options, [custom_claims])](#CoreDocument+createCredentialJwt) ⇒ [Promise.<Jwt>](#Jwt) - * [.createPresentationJwt(storage, fragment, presentation, signature_options, presentation_options)](#CoreDocument+createPresentationJwt) ⇒ [Promise.<Jwt>](#Jwt) - * _static_ - * [.fromJSON(json)](#CoreDocument.fromJSON) ⇒ [CoreDocument](#CoreDocument) - - - -### new CoreDocument(values) -Creates a new [CoreDocument](#CoreDocument) with the given properties. - - -| Param | Type | -| --- | --- | -| values | ICoreDocument | - - - -### coreDocument.id() ⇒ [CoreDID](#CoreDID) -Returns a copy of the DID Document `id`. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.setId(id) -Sets the DID of the document. - -### Warning - -Changing the identifier can drastically alter the results of -`resolve_method`, `resolve_service` and the related -[DID URL dereferencing](https://w3c-ccg.github.io/did-resolution/#dereferencing) algorithm. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| id | [CoreDID](#CoreDID) | - - - -### coreDocument.controller() ⇒ [Array.<CoreDID>](#CoreDID) -Returns a copy of the document controllers. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.setController(controllers) -Sets the controllers of the DID Document. - -Note: Duplicates will be ignored. -Use `null` to remove all controllers. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| controllers | [CoreDID](#CoreDID) \| [Array.<CoreDID>](#CoreDID) \| null | - - - -### coreDocument.alsoKnownAs() ⇒ Array.<string> -Returns a copy of the document's `alsoKnownAs` set. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.setAlsoKnownAs(urls) -Sets the `alsoKnownAs` property in the DID document. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| urls | string \| Array.<string> \| null | - - - -### coreDocument.verificationMethod() ⇒ [Array.<VerificationMethod>](#VerificationMethod) -Returns a copy of the document's `verificationMethod` set. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.authentication() ⇒ Array.<(DIDUrl\|VerificationMethod)> -Returns a copy of the document's `authentication` set. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.assertionMethod() ⇒ Array.<(DIDUrl\|VerificationMethod)> -Returns a copy of the document's `assertionMethod` set. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.keyAgreement() ⇒ Array.<(DIDUrl\|VerificationMethod)> -Returns a copy of the document's `keyAgreement` set. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.capabilityDelegation() ⇒ Array.<(DIDUrl\|VerificationMethod)> -Returns a copy of the document's `capabilityDelegation` set. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.capabilityInvocation() ⇒ Array.<(DIDUrl\|VerificationMethod)> -Returns a copy of the document's `capabilityInvocation` set. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.properties() ⇒ Map.<string, any> -Returns a copy of the custom DID Document properties. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.setPropertyUnchecked(key, value) -Sets a custom property in the DID Document. -If the value is set to `null`, the custom property will be removed. - -### WARNING - -This method can overwrite existing properties like `id` and result in an invalid document. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| key | string | -| value | any | - - - -### coreDocument.service() ⇒ [Array.<Service>](#Service) -Returns a set of all [Service](#Service) in the document. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.insertService(service) -Add a new [Service](#Service) to the document. - -Errors if there already exists a service or verification method with the same id. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| service | [Service](#Service) | - - - -### coreDocument.removeService(didUrl) ⇒ [Service](#Service) \| undefined -Remove a [Service](#Service) identified by the given [DIDUrl](#DIDUrl) from the document. - -Returns `true` if the service was removed. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| didUrl | [DIDUrl](#DIDUrl) | - - - -### coreDocument.resolveService(query) ⇒ [Service](#Service) \| undefined -Returns the first [Service](#Service) with an `id` property matching the provided `query`, -if present. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| query | [DIDUrl](#DIDUrl) \| string | - - - -### coreDocument.methods([scope]) ⇒ [Array.<VerificationMethod>](#VerificationMethod) -Returns a list of all [VerificationMethod](#VerificationMethod) in the DID Document, -whose verification relationship matches `scope`. - -If `scope` is not set, a list over the **embedded** methods is returned. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| [scope] | [MethodScope](#MethodScope) \| undefined | - - - -### coreDocument.verificationRelationships() ⇒ Array.<(DIDUrl\|VerificationMethod)> -Returns an array of all verification relationships. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.insertMethod(method, scope) -Adds a new `method` to the document in the given `scope`. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| method | [VerificationMethod](#VerificationMethod) | -| scope | [MethodScope](#MethodScope) | - - - -### coreDocument.removeMethod(did) ⇒ [VerificationMethod](#VerificationMethod) \| undefined -Removes all references to the specified Verification Method. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| did | [DIDUrl](#DIDUrl) | - - - -### coreDocument.resolveMethod(query, [scope]) ⇒ [VerificationMethod](#VerificationMethod) \| undefined -Returns a copy of the first verification method with an `id` property -matching the provided `query` and the verification relationship -specified by `scope`, if present. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| query | [DIDUrl](#DIDUrl) \| string | -| [scope] | [MethodScope](#MethodScope) \| undefined | - - - -### coreDocument.attachMethodRelationship(didUrl, relationship) ⇒ boolean -Attaches the relationship to the given method, if the method exists. - -Note: The method needs to be in the set of verification methods, -so it cannot be an embedded one. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| didUrl | [DIDUrl](#DIDUrl) | -| relationship | [MethodRelationship](#MethodRelationship) | - - - -### coreDocument.detachMethodRelationship(didUrl, relationship) ⇒ boolean -Detaches the given relationship from the given method, if the method exists. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| didUrl | [DIDUrl](#DIDUrl) | -| relationship | [MethodRelationship](#MethodRelationship) | - - - -### coreDocument.verifyJws(jws, options, signatureVerifier, [detachedPayload]) ⇒ [DecodedJws](#DecodedJws) -Decodes and verifies the provided JWS according to the passed `options` and `signatureVerifier`. - If no `signatureVerifier` argument is provided a default verifier will be used that is (only) capable of -verifying EdDSA signatures. - -Regardless of which options are passed the following conditions must be met in order for a verification attempt to -take place. -- The JWS must be encoded according to the JWS compact serialization. -- The `kid` value in the protected header must be an identifier of a verification method in this DID document, -or set explicitly in the `options`. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| jws | [Jws](#Jws) | -| options | [JwsVerificationOptions](#JwsVerificationOptions) | -| signatureVerifier | IJwsVerifier | -| [detachedPayload] | string \| undefined | - - - -### coreDocument.revokeCredentials(serviceQuery, indices) -If the document has a [RevocationBitmap](#RevocationBitmap) service identified by `serviceQuery`, -revoke all specified `indices`. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| serviceQuery | [DIDUrl](#DIDUrl) \| string | -| indices | number \| Array.<number> | - - - -### coreDocument.unrevokeCredentials(serviceQuery, indices) -If the document has a [RevocationBitmap](#RevocationBitmap) service identified by `serviceQuery`, -unrevoke all specified `indices`. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| serviceQuery | [DIDUrl](#DIDUrl) \| string | -| indices | number \| Array.<number> | - - - -### coreDocument.clone() ⇒ [CoreDocument](#CoreDocument) -Deep clones the [CoreDocument](#CoreDocument). - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.\_shallowCloneInternal() ⇒ [CoreDocument](#CoreDocument) -### Warning -This is for internal use only. Do not rely on or call this method. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.\_strongCountInternal() ⇒ number -### Warning -This is for internal use only. Do not rely on or call this method. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.toJSON() ⇒ any -Serializes to a plain JS representation. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - - -### coreDocument.generateMethod(storage, keyType, alg, fragment, scope) ⇒ Promise.<string> -Generate new key material in the given `storage` and insert a new verification method with the corresponding -public key material into the DID document. - -- If no fragment is given the `kid` of the generated JWK is used, if it is set, otherwise an error is returned. -- The `keyType` must be compatible with the given `storage`. `Storage`s are expected to export key type constants -for that use case. - -The fragment of the generated method is returned. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| keyType | string | -| alg | JwsAlgorithm | -| fragment | string \| undefined | -| scope | [MethodScope](#MethodScope) | - - - -### coreDocument.purgeMethod(storage, id) ⇒ Promise.<void> -Remove the method identified by the `fragment` from the document and delete the corresponding key material in -the `storage`. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| id | [DIDUrl](#DIDUrl) | - - - -### coreDocument.createJws(storage, fragment, payload, options) ⇒ [Promise.<Jws>](#Jws) -Sign the `payload` according to `options` with the storage backed private key corresponding to the public key -material in the verification method identified by the given `fragment. - -Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. -See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| fragment | string | -| payload | string | -| options | [JwsSignatureOptions](#JwsSignatureOptions) | - - - -### coreDocument.createCredentialJwt(storage, fragment, credential, options, [custom_claims]) ⇒ [Promise.<Jwt>](#Jwt) -Produces a JWT where the payload is produced from the given `credential` -in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - -Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` -of the method identified by `fragment` and the JWS signature will be produced by the corresponding -private key backed by the `storage` in accordance with the passed `options`. - -The `custom_claims` can be used to set additional claims on the resulting JWT. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| fragment | string | -| credential | [Credential](#Credential) | -| options | [JwsSignatureOptions](#JwsSignatureOptions) | -| [custom_claims] | Record.<string, any> \| undefined | - - - -### coreDocument.createPresentationJwt(storage, fragment, presentation, signature_options, presentation_options) ⇒ [Promise.<Jwt>](#Jwt) -Produces a JWT where the payload is produced from the given presentation. -in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - -Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` -of the method identified by `fragment` and the JWS signature will be produced by the corresponding -private key backed by the `storage` in accordance with the passed `options`. - -**Kind**: instance method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| fragment | string | -| presentation | [Presentation](#Presentation) | -| signature_options | [JwsSignatureOptions](#JwsSignatureOptions) | -| presentation_options | [JwtPresentationOptions](#JwtPresentationOptions) | - - - -### CoreDocument.fromJSON(json) ⇒ [CoreDocument](#CoreDocument) -Deserializes an instance from a plain JS representation. - -**Kind**: static method of [CoreDocument](#CoreDocument) - -| Param | Type | -| --- | --- | -| json | any | - - - -## Credential -**Kind**: global class - -* [Credential](#Credential) - * [new Credential(values)](#new_Credential_new) - * _instance_ - * [.context()](#Credential+context) ⇒ Array.<(string\|Record.<string, any>)> - * [.id()](#Credential+id) ⇒ string \| undefined - * [.type()](#Credential+type) ⇒ Array.<string> - * [.credentialSubject()](#Credential+credentialSubject) ⇒ Array.<Subject> - * [.issuer()](#Credential+issuer) ⇒ string \| Issuer - * [.issuanceDate()](#Credential+issuanceDate) ⇒ [Timestamp](#Timestamp) - * [.expirationDate()](#Credential+expirationDate) ⇒ [Timestamp](#Timestamp) \| undefined - * [.credentialStatus()](#Credential+credentialStatus) ⇒ Array.<Status> - * [.credentialSchema()](#Credential+credentialSchema) ⇒ Array.<Schema> - * [.refreshService()](#Credential+refreshService) ⇒ Array.<RefreshService> - * [.termsOfUse()](#Credential+termsOfUse) ⇒ Array.<Policy> - * [.evidence()](#Credential+evidence) ⇒ Array.<Evidence> - * [.nonTransferable()](#Credential+nonTransferable) ⇒ boolean \| undefined - * [.proof()](#Credential+proof) ⇒ [Proof](#Proof) \| undefined - * [.properties()](#Credential+properties) ⇒ Map.<string, any> - * [.setProof([proof])](#Credential+setProof) - * [.toJwtClaims([custom_claims])](#Credential+toJwtClaims) ⇒ Record.<string, any> - * [.toJSON()](#Credential+toJSON) ⇒ any - * [.clone()](#Credential+clone) ⇒ [Credential](#Credential) - * _static_ - * [.BaseContext()](#Credential.BaseContext) ⇒ string - * [.BaseType()](#Credential.BaseType) ⇒ string - * [.createDomainLinkageCredential(values)](#Credential.createDomainLinkageCredential) ⇒ [Credential](#Credential) - * [.fromJSON(json)](#Credential.fromJSON) ⇒ [Credential](#Credential) - - - -### new Credential(values) -Constructs a new [Credential](#Credential). - - -| Param | Type | -| --- | --- | -| values | ICredential | - - - -### credential.context() ⇒ Array.<(string\|Record.<string, any>)> -Returns a copy of the JSON-LD context(s) applicable to the [Credential](#Credential). - -**Kind**: instance method of [Credential](#Credential) - - -### credential.id() ⇒ string \| undefined -Returns a copy of the unique `URI` identifying the [Credential](#Credential) . - -**Kind**: instance method of [Credential](#Credential) - - -### credential.type() ⇒ Array.<string> -Returns a copy of the URIs defining the type of the [Credential](#Credential). - -**Kind**: instance method of [Credential](#Credential) - - -### credential.credentialSubject() ⇒ Array.<Subject> -Returns a copy of the [Credential](#Credential) subject(s). - -**Kind**: instance method of [Credential](#Credential) - - -### credential.issuer() ⇒ string \| Issuer -Returns a copy of the issuer of the [Credential](#Credential). - -**Kind**: instance method of [Credential](#Credential) - - -### credential.issuanceDate() ⇒ [Timestamp](#Timestamp) -Returns a copy of the timestamp of when the [Credential](#Credential) becomes valid. - -**Kind**: instance method of [Credential](#Credential) - - -### credential.expirationDate() ⇒ [Timestamp](#Timestamp) \| undefined -Returns a copy of the timestamp of when the [Credential](#Credential) should no longer be considered valid. - -**Kind**: instance method of [Credential](#Credential) - - -### credential.credentialStatus() ⇒ Array.<Status> -Returns a copy of the information used to determine the current status of the [Credential](#Credential). - -**Kind**: instance method of [Credential](#Credential) - - -### credential.credentialSchema() ⇒ Array.<Schema> -Returns a copy of the information used to assist in the enforcement of a specific [Credential](#Credential) structure. - -**Kind**: instance method of [Credential](#Credential) - - -### credential.refreshService() ⇒ Array.<RefreshService> -Returns a copy of the service(s) used to refresh an expired [Credential](#Credential). - -**Kind**: instance method of [Credential](#Credential) - - -### credential.termsOfUse() ⇒ Array.<Policy> -Returns a copy of the terms-of-use specified by the [Credential](#Credential) issuer. - -**Kind**: instance method of [Credential](#Credential) - - -### credential.evidence() ⇒ Array.<Evidence> -Returns a copy of the human-readable evidence used to support the claims within the [Credential](#Credential). - -**Kind**: instance method of [Credential](#Credential) - - -### credential.nonTransferable() ⇒ boolean \| undefined -Returns whether or not the [Credential](#Credential) must only be contained within a [Presentation](#Presentation) -with a proof issued from the [Credential](#Credential) subject. - -**Kind**: instance method of [Credential](#Credential) - - -### credential.proof() ⇒ [Proof](#Proof) \| undefined -Optional cryptographic proof, unrelated to JWT. - -**Kind**: instance method of [Credential](#Credential) - - -### credential.properties() ⇒ Map.<string, any> -Returns a copy of the miscellaneous properties on the [Credential](#Credential). - -**Kind**: instance method of [Credential](#Credential) - - -### credential.setProof([proof]) -Sets the `proof` property of the [Credential](#Credential). - -Note that this proof is not related to JWT. - -**Kind**: instance method of [Credential](#Credential) - -| Param | Type | -| --- | --- | -| [proof] | [Proof](#Proof) \| undefined | - - - -### credential.toJwtClaims([custom_claims]) ⇒ Record.<string, any> -Serializes the `Credential` as a JWT claims set -in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - -The resulting object can be used as the payload of a JWS when issuing the credential. - -**Kind**: instance method of [Credential](#Credential) - -| Param | Type | -| --- | --- | -| [custom_claims] | Record.<string, any> \| undefined | - - - -### credential.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Credential](#Credential) - - -### credential.clone() ⇒ [Credential](#Credential) -Deep clones the object. - -**Kind**: instance method of [Credential](#Credential) - - -### Credential.BaseContext() ⇒ string -Returns the base JSON-LD context. - -**Kind**: static method of [Credential](#Credential) - - -### Credential.BaseType() ⇒ string -Returns the base type. - -**Kind**: static method of [Credential](#Credential) - - -### Credential.createDomainLinkageCredential(values) ⇒ [Credential](#Credential) -**Kind**: static method of [Credential](#Credential) - -| Param | Type | -| --- | --- | -| values | IDomainLinkageCredential | - - - -### Credential.fromJSON(json) ⇒ [Credential](#Credential) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Credential](#Credential) - -| Param | Type | -| --- | --- | -| json | any | - - - -## CustomMethodData -A custom verification method data format. - -**Kind**: global class - -* [CustomMethodData](#CustomMethodData) - * [new CustomMethodData(name, data)](#new_CustomMethodData_new) - * _instance_ - * [.clone()](#CustomMethodData+clone) ⇒ [CustomMethodData](#CustomMethodData) - * [.toJSON()](#CustomMethodData+toJSON) ⇒ any - * _static_ - * [.fromJSON(json)](#CustomMethodData.fromJSON) ⇒ [CustomMethodData](#CustomMethodData) - - - -### new CustomMethodData(name, data) - -| Param | Type | -| --- | --- | -| name | string | -| data | any | - - - -### customMethodData.clone() ⇒ [CustomMethodData](#CustomMethodData) -Deep clones the object. - -**Kind**: instance method of [CustomMethodData](#CustomMethodData) - - -### customMethodData.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [CustomMethodData](#CustomMethodData) - - -### CustomMethodData.fromJSON(json) ⇒ [CustomMethodData](#CustomMethodData) -Deserializes an instance from a JSON object. - -**Kind**: static method of [CustomMethodData](#CustomMethodData) - -| Param | Type | -| --- | --- | -| json | any | - - - -## DIDUrl -A method agnostic DID Url. - -**Kind**: global class - -* [DIDUrl](#DIDUrl) - * _instance_ - * [.did()](#DIDUrl+did) ⇒ [CoreDID](#CoreDID) - * [.urlStr()](#DIDUrl+urlStr) ⇒ string - * [.fragment()](#DIDUrl+fragment) ⇒ string \| undefined - * [.setFragment([value])](#DIDUrl+setFragment) - * [.path()](#DIDUrl+path) ⇒ string \| undefined - * [.setPath([value])](#DIDUrl+setPath) - * [.query()](#DIDUrl+query) ⇒ string \| undefined - * [.setQuery([value])](#DIDUrl+setQuery) - * [.join(segment)](#DIDUrl+join) ⇒ [DIDUrl](#DIDUrl) - * [.toString()](#DIDUrl+toString) ⇒ string - * [.toJSON()](#DIDUrl+toJSON) ⇒ any - * [.clone()](#DIDUrl+clone) ⇒ [DIDUrl](#DIDUrl) - * _static_ - * [.parse(input)](#DIDUrl.parse) ⇒ [DIDUrl](#DIDUrl) - * [.fromJSON(json)](#DIDUrl.fromJSON) ⇒ [DIDUrl](#DIDUrl) - - - -### didUrl.did() ⇒ [CoreDID](#CoreDID) -Return a copy of the [CoreDID](#CoreDID) section of the [DIDUrl](#DIDUrl). - -**Kind**: instance method of [DIDUrl](#DIDUrl) - - -### didUrl.urlStr() ⇒ string -Return a copy of the relative DID Url as a string, including only the path, query, and fragment. - -**Kind**: instance method of [DIDUrl](#DIDUrl) - - -### didUrl.fragment() ⇒ string \| undefined -Returns a copy of the [DIDUrl](#DIDUrl) method fragment, if any. Excludes the leading '#'. - -**Kind**: instance method of [DIDUrl](#DIDUrl) - - -### didUrl.setFragment([value]) -Sets the `fragment` component of the [DIDUrl](#DIDUrl). - -**Kind**: instance method of [DIDUrl](#DIDUrl) - -| Param | Type | -| --- | --- | -| [value] | string \| undefined | - - - -### didUrl.path() ⇒ string \| undefined -Returns a copy of the [DIDUrl](#DIDUrl) path. - -**Kind**: instance method of [DIDUrl](#DIDUrl) - - -### didUrl.setPath([value]) -Sets the `path` component of the [DIDUrl](#DIDUrl). - -**Kind**: instance method of [DIDUrl](#DIDUrl) - -| Param | Type | -| --- | --- | -| [value] | string \| undefined | - - - -### didUrl.query() ⇒ string \| undefined -Returns a copy of the [DIDUrl](#DIDUrl) method query, if any. Excludes the leading '?'. - -**Kind**: instance method of [DIDUrl](#DIDUrl) - - -### didUrl.setQuery([value]) -Sets the `query` component of the [DIDUrl](#DIDUrl). - -**Kind**: instance method of [DIDUrl](#DIDUrl) - -| Param | Type | -| --- | --- | -| [value] | string \| undefined | - - - -### didUrl.join(segment) ⇒ [DIDUrl](#DIDUrl) -Append a string representing a path, query, and/or fragment, returning a new [DIDUrl](#DIDUrl). - -Must begin with a valid delimiter character: '/', '?', '#'. Overwrites the existing URL -segment and any following segments in order of path, query, then fragment. - -I.e. -- joining a path will clear the query and fragment. -- joining a query will clear the fragment. -- joining a fragment will only overwrite the fragment. - -**Kind**: instance method of [DIDUrl](#DIDUrl) - -| Param | Type | -| --- | --- | -| segment | string | - - - -### didUrl.toString() ⇒ string -Returns the [DIDUrl](#DIDUrl) as a string. - -**Kind**: instance method of [DIDUrl](#DIDUrl) - - -### didUrl.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [DIDUrl](#DIDUrl) - - -### didUrl.clone() ⇒ [DIDUrl](#DIDUrl) -Deep clones the object. - -**Kind**: instance method of [DIDUrl](#DIDUrl) - - -### DIDUrl.parse(input) ⇒ [DIDUrl](#DIDUrl) -Parses a [DIDUrl](#DIDUrl) from the input string. - -**Kind**: static method of [DIDUrl](#DIDUrl) - -| Param | Type | -| --- | --- | -| input | string | - - - -### DIDUrl.fromJSON(json) ⇒ [DIDUrl](#DIDUrl) -Deserializes an instance from a JSON object. - -**Kind**: static method of [DIDUrl](#DIDUrl) - -| Param | Type | -| --- | --- | -| json | any | - - - -## DecodedJptCredential -**Kind**: global class - -* [DecodedJptCredential](#DecodedJptCredential) - * [.clone()](#DecodedJptCredential+clone) ⇒ [DecodedJptCredential](#DecodedJptCredential) - * [.credential()](#DecodedJptCredential+credential) ⇒ [Credential](#Credential) - * [.customClaims()](#DecodedJptCredential+customClaims) ⇒ Map.<string, any> - * [.decodedJwp()](#DecodedJptCredential+decodedJwp) ⇒ [JwpIssued](#JwpIssued) - - - -### decodedJptCredential.clone() ⇒ [DecodedJptCredential](#DecodedJptCredential) -Deep clones the object. - -**Kind**: instance method of [DecodedJptCredential](#DecodedJptCredential) - - -### decodedJptCredential.credential() ⇒ [Credential](#Credential) -Returns the [Credential](#Credential) embedded into this JPT. - -**Kind**: instance method of [DecodedJptCredential](#DecodedJptCredential) - - -### decodedJptCredential.customClaims() ⇒ Map.<string, any> -Returns the custom claims parsed from the JPT. - -**Kind**: instance method of [DecodedJptCredential](#DecodedJptCredential) - - -### decodedJptCredential.decodedJwp() ⇒ [JwpIssued](#JwpIssued) -**Kind**: instance method of [DecodedJptCredential](#DecodedJptCredential) - - -## DecodedJptPresentation -**Kind**: global class - -* [DecodedJptPresentation](#DecodedJptPresentation) - * [.clone()](#DecodedJptPresentation+clone) ⇒ [DecodedJptPresentation](#DecodedJptPresentation) - * [.credential()](#DecodedJptPresentation+credential) ⇒ [Credential](#Credential) - * [.customClaims()](#DecodedJptPresentation+customClaims) ⇒ Map.<string, any> - * [.aud()](#DecodedJptPresentation+aud) ⇒ string \| undefined - - - -### decodedJptPresentation.clone() ⇒ [DecodedJptPresentation](#DecodedJptPresentation) -Deep clones the object. - -**Kind**: instance method of [DecodedJptPresentation](#DecodedJptPresentation) - - -### decodedJptPresentation.credential() ⇒ [Credential](#Credential) -Returns the [Credential](#Credential) embedded into this JPT. - -**Kind**: instance method of [DecodedJptPresentation](#DecodedJptPresentation) - - -### decodedJptPresentation.customClaims() ⇒ Map.<string, any> -Returns the custom claims parsed from the JPT. - -**Kind**: instance method of [DecodedJptPresentation](#DecodedJptPresentation) - - -### decodedJptPresentation.aud() ⇒ string \| undefined -Returns the `aud` property parsed from the JWT claims. - -**Kind**: instance method of [DecodedJptPresentation](#DecodedJptPresentation) - - -## DecodedJws -A cryptographically verified decoded token from a JWS. - -Contains the decoded headers and the raw claims. - -**Kind**: global class - -* [DecodedJws](#DecodedJws) - * [.claims()](#DecodedJws+claims) ⇒ string - * [.claimsBytes()](#DecodedJws+claimsBytes) ⇒ Uint8Array - * [.protectedHeader()](#DecodedJws+protectedHeader) ⇒ [JwsHeader](#JwsHeader) - * [.clone()](#DecodedJws+clone) ⇒ [DecodedJws](#DecodedJws) - * [.toJSON()](#DecodedJws+toJSON) ⇒ any - - - -### decodedJws.claims() ⇒ string -Returns a copy of the parsed claims represented as a string. - -# Errors -An error is thrown if the claims cannot be represented as a string. - -This error can only occur if the Token was decoded from a detached payload. - -**Kind**: instance method of [DecodedJws](#DecodedJws) - - -### decodedJws.claimsBytes() ⇒ Uint8Array -Return a copy of the parsed claims represented as an array of bytes. - -**Kind**: instance method of [DecodedJws](#DecodedJws) - - -### decodedJws.protectedHeader() ⇒ [JwsHeader](#JwsHeader) -Returns a copy of the protected header. - -**Kind**: instance method of [DecodedJws](#DecodedJws) - - -### decodedJws.clone() ⇒ [DecodedJws](#DecodedJws) -Deep clones the object. - -**Kind**: instance method of [DecodedJws](#DecodedJws) - - -### decodedJws.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [DecodedJws](#DecodedJws) - - -## DecodedJwtCredential -A cryptographically verified and decoded Credential. - -Note that having an instance of this type only means the JWS it was constructed from was verified. -It does not imply anything about a potentially present proof property on the credential itself. - -**Kind**: global class - -* [DecodedJwtCredential](#DecodedJwtCredential) - * [.credential()](#DecodedJwtCredential+credential) ⇒ [Credential](#Credential) - * [.protectedHeader()](#DecodedJwtCredential+protectedHeader) ⇒ [JwsHeader](#JwsHeader) - * [.customClaims()](#DecodedJwtCredential+customClaims) ⇒ Record.<string, any> \| undefined - * [.intoCredential()](#DecodedJwtCredential+intoCredential) ⇒ [Credential](#Credential) - - - -### decodedJwtCredential.credential() ⇒ [Credential](#Credential) -Returns a copy of the credential parsed to the [Verifiable Credentials Data model](https://www.w3.org/TR/vc-data-model/). - -**Kind**: instance method of [DecodedJwtCredential](#DecodedJwtCredential) - - -### decodedJwtCredential.protectedHeader() ⇒ [JwsHeader](#JwsHeader) -Returns a copy of the protected header parsed from the decoded JWS. - -**Kind**: instance method of [DecodedJwtCredential](#DecodedJwtCredential) - - -### decodedJwtCredential.customClaims() ⇒ Record.<string, any> \| undefined -The custom claims parsed from the JWT. - -**Kind**: instance method of [DecodedJwtCredential](#DecodedJwtCredential) - - -### decodedJwtCredential.intoCredential() ⇒ [Credential](#Credential) -Consumes the object and returns the decoded credential. - -### Warning - -This destroys the [DecodedJwtCredential](#DecodedJwtCredential) object. - -**Kind**: instance method of [DecodedJwtCredential](#DecodedJwtCredential) - - -## DecodedJwtPresentation -A cryptographically verified and decoded presentation. - -Note that having an instance of this type only means the JWS it was constructed from was verified. -It does not imply anything about a potentially present proof property on the presentation itself. - -**Kind**: global class - -* [DecodedJwtPresentation](#DecodedJwtPresentation) - * [.presentation()](#DecodedJwtPresentation+presentation) ⇒ [Presentation](#Presentation) - * [.protectedHeader()](#DecodedJwtPresentation+protectedHeader) ⇒ [JwsHeader](#JwsHeader) - * [.intoPresentation()](#DecodedJwtPresentation+intoPresentation) ⇒ [Presentation](#Presentation) - * [.expirationDate()](#DecodedJwtPresentation+expirationDate) ⇒ [Timestamp](#Timestamp) \| undefined - * [.issuanceDate()](#DecodedJwtPresentation+issuanceDate) ⇒ [Timestamp](#Timestamp) \| undefined - * [.audience()](#DecodedJwtPresentation+audience) ⇒ string \| undefined - * [.customClaims()](#DecodedJwtPresentation+customClaims) ⇒ Record.<string, any> \| undefined - - - -### decodedJwtPresentation.presentation() ⇒ [Presentation](#Presentation) -**Kind**: instance method of [DecodedJwtPresentation](#DecodedJwtPresentation) - - -### decodedJwtPresentation.protectedHeader() ⇒ [JwsHeader](#JwsHeader) -Returns a copy of the protected header parsed from the decoded JWS. - -**Kind**: instance method of [DecodedJwtPresentation](#DecodedJwtPresentation) - - -### decodedJwtPresentation.intoPresentation() ⇒ [Presentation](#Presentation) -Consumes the object and returns the decoded presentation. - -### Warning -This destroys the [DecodedJwtPresentation](#DecodedJwtPresentation) object. - -**Kind**: instance method of [DecodedJwtPresentation](#DecodedJwtPresentation) - - -### decodedJwtPresentation.expirationDate() ⇒ [Timestamp](#Timestamp) \| undefined -The expiration date parsed from the JWT claims. - -**Kind**: instance method of [DecodedJwtPresentation](#DecodedJwtPresentation) - - -### decodedJwtPresentation.issuanceDate() ⇒ [Timestamp](#Timestamp) \| undefined -The issuance date parsed from the JWT claims. - -**Kind**: instance method of [DecodedJwtPresentation](#DecodedJwtPresentation) - - -### decodedJwtPresentation.audience() ⇒ string \| undefined -The `aud` property parsed from JWT claims. - -**Kind**: instance method of [DecodedJwtPresentation](#DecodedJwtPresentation) - - -### decodedJwtPresentation.customClaims() ⇒ Record.<string, any> \| undefined -The custom claims parsed from the JWT. - -**Kind**: instance method of [DecodedJwtPresentation](#DecodedJwtPresentation) - - -## Disclosure -Represents an elements constructing a disclosure. -Object properties and array elements disclosures are supported. - -See: https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-disclosures - -**Kind**: global class - -* [Disclosure](#Disclosure) - * [new Disclosure(salt, claim_name, claim_value)](#new_Disclosure_new) - * _instance_ - * [.disclosure()](#Disclosure+disclosure) ⇒ string - * [.toEncodedString()](#Disclosure+toEncodedString) ⇒ string - * [.toString()](#Disclosure+toString) ⇒ string - * [.salt()](#Disclosure+salt) ⇒ string - * [.claimName()](#Disclosure+claimName) ⇒ string \| undefined - * [.claimValue()](#Disclosure+claimValue) ⇒ any - * [.toJSON()](#Disclosure+toJSON) ⇒ any - * _static_ - * [.parse(disclosure)](#Disclosure.parse) ⇒ [Disclosure](#Disclosure) - * [.fromJSON(json)](#Disclosure.fromJSON) ⇒ [Disclosure](#Disclosure) - - - -### new Disclosure(salt, claim_name, claim_value) - -| Param | Type | -| --- | --- | -| salt | string | -| claim_name | string \| undefined | -| claim_value | any | - - - -### disclosure.disclosure() ⇒ string -Returns a copy of the base64url-encoded string. - -**Kind**: instance method of [Disclosure](#Disclosure) - - -### disclosure.toEncodedString() ⇒ string -Returns a copy of the base64url-encoded string. - -**Kind**: instance method of [Disclosure](#Disclosure) - - -### disclosure.toString() ⇒ string -Returns a copy of the base64url-encoded string. - -**Kind**: instance method of [Disclosure](#Disclosure) - - -### disclosure.salt() ⇒ string -Returns a copy of the salt value. - -**Kind**: instance method of [Disclosure](#Disclosure) - - -### disclosure.claimName() ⇒ string \| undefined -Returns a copy of the claim name, optional for array elements. - -**Kind**: instance method of [Disclosure](#Disclosure) - - -### disclosure.claimValue() ⇒ any -Returns a copy of the claim Value which can be of any type. - -**Kind**: instance method of [Disclosure](#Disclosure) - - -### disclosure.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Disclosure](#Disclosure) - - -### Disclosure.parse(disclosure) ⇒ [Disclosure](#Disclosure) -Parses a Base64 encoded disclosure into a `Disclosure`. - -## Error - -Returns an `InvalidDisclosure` if input is not a valid disclosure. - -**Kind**: static method of [Disclosure](#Disclosure) - -| Param | Type | -| --- | --- | -| disclosure | string | - - - -### Disclosure.fromJSON(json) ⇒ [Disclosure](#Disclosure) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Disclosure](#Disclosure) - -| Param | Type | -| --- | --- | -| json | any | - - - -## DomainLinkageConfiguration -DID Configuration Resource which contains Domain Linkage Credentials. -It can be placed in an origin's `.well-known` directory to prove linkage between the origin and a DID. -See: - -Note: -- Only the [JSON Web Token Proof Format](https://identity.foundation/.well-known/resources/did-configuration/#json-web-token-proof-format) - -**Kind**: global class - -* [DomainLinkageConfiguration](#DomainLinkageConfiguration) - * [new DomainLinkageConfiguration(linkedDids)](#new_DomainLinkageConfiguration_new) - * _instance_ - * [.linkedDids()](#DomainLinkageConfiguration+linkedDids) ⇒ [Array.<Jwt>](#Jwt) - * [.issuers()](#DomainLinkageConfiguration+issuers) ⇒ [Array.<CoreDID>](#CoreDID) - * [.toJSON()](#DomainLinkageConfiguration+toJSON) ⇒ any - * [.clone()](#DomainLinkageConfiguration+clone) ⇒ [DomainLinkageConfiguration](#DomainLinkageConfiguration) - * _static_ - * [.fromJSON(json)](#DomainLinkageConfiguration.fromJSON) ⇒ [DomainLinkageConfiguration](#DomainLinkageConfiguration) - - - -### new DomainLinkageConfiguration(linkedDids) -Constructs a new [DomainLinkageConfiguration](#DomainLinkageConfiguration). - - -| Param | Type | -| --- | --- | -| linkedDids | [Array.<Jwt>](#Jwt) | - - - -### domainLinkageConfiguration.linkedDids() ⇒ [Array.<Jwt>](#Jwt) -List of the Domain Linkage Credentials. - -**Kind**: instance method of [DomainLinkageConfiguration](#DomainLinkageConfiguration) - - -### domainLinkageConfiguration.issuers() ⇒ [Array.<CoreDID>](#CoreDID) -List of the issuers of the Domain Linkage Credentials. - -**Kind**: instance method of [DomainLinkageConfiguration](#DomainLinkageConfiguration) - - -### domainLinkageConfiguration.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [DomainLinkageConfiguration](#DomainLinkageConfiguration) - - -### domainLinkageConfiguration.clone() ⇒ [DomainLinkageConfiguration](#DomainLinkageConfiguration) -Deep clones the object. - -**Kind**: instance method of [DomainLinkageConfiguration](#DomainLinkageConfiguration) - - -### DomainLinkageConfiguration.fromJSON(json) ⇒ [DomainLinkageConfiguration](#DomainLinkageConfiguration) -Deserializes an instance from a JSON object. - -**Kind**: static method of [DomainLinkageConfiguration](#DomainLinkageConfiguration) - -| Param | Type | -| --- | --- | -| json | any | - - - -## Duration -A span of time. - -**Kind**: global class - -* [Duration](#Duration) - * _instance_ - * [.toJSON()](#Duration+toJSON) ⇒ any - * _static_ - * [.seconds(seconds)](#Duration.seconds) ⇒ [Duration](#Duration) - * [.minutes(minutes)](#Duration.minutes) ⇒ [Duration](#Duration) - * [.hours(hours)](#Duration.hours) ⇒ [Duration](#Duration) - * [.days(days)](#Duration.days) ⇒ [Duration](#Duration) - * [.weeks(weeks)](#Duration.weeks) ⇒ [Duration](#Duration) - * [.fromJSON(json)](#Duration.fromJSON) ⇒ [Duration](#Duration) - - - -### duration.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Duration](#Duration) - - -### Duration.seconds(seconds) ⇒ [Duration](#Duration) -Create a new [Duration](#Duration) with the given number of seconds. - -**Kind**: static method of [Duration](#Duration) - -| Param | Type | -| --- | --- | -| seconds | number | - - - -### Duration.minutes(minutes) ⇒ [Duration](#Duration) -Create a new [Duration](#Duration) with the given number of minutes. - -**Kind**: static method of [Duration](#Duration) - -| Param | Type | -| --- | --- | -| minutes | number | - - - -### Duration.hours(hours) ⇒ [Duration](#Duration) -Create a new [Duration](#Duration) with the given number of hours. - -**Kind**: static method of [Duration](#Duration) - -| Param | Type | -| --- | --- | -| hours | number | - - - -### Duration.days(days) ⇒ [Duration](#Duration) -Create a new [Duration](#Duration) with the given number of days. - -**Kind**: static method of [Duration](#Duration) - -| Param | Type | -| --- | --- | -| days | number | - - - -### Duration.weeks(weeks) ⇒ [Duration](#Duration) -Create a new [Duration](#Duration) with the given number of weeks. - -**Kind**: static method of [Duration](#Duration) - -| Param | Type | -| --- | --- | -| weeks | number | - - - -### Duration.fromJSON(json) ⇒ [Duration](#Duration) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Duration](#Duration) - -| Param | Type | -| --- | --- | -| json | any | - - - -## EdDSAJwsVerifier -An implementor of `IJwsVerifier` that can handle the -`EdDSA` algorithm. - -**Kind**: global class - -* [EdDSAJwsVerifier](#EdDSAJwsVerifier) - * [new EdDSAJwsVerifier()](#new_EdDSAJwsVerifier_new) - * [.verify(alg, signingInput, decodedSignature, publicKey)](#EdDSAJwsVerifier+verify) - - - -### new EdDSAJwsVerifier() -Constructs an EdDSAJwsVerifier. - - - -### edDSAJwsVerifier.verify(alg, signingInput, decodedSignature, publicKey) -Verify a JWS signature secured with the `EdDSA` algorithm. -Only the `Ed25519` curve is supported for now. - -This function is useful when one is building an `IJwsVerifier` that extends the default provided by -the IOTA Identity Framework. - -# Warning - -This function does not check whether `alg = EdDSA` in the protected header. Callers are expected to assert this -prior to calling the function. - -**Kind**: instance method of [EdDSAJwsVerifier](#EdDSAJwsVerifier) - -| Param | Type | -| --- | --- | -| alg | JwsAlgorithm | -| signingInput | Uint8Array | -| decodedSignature | Uint8Array | -| publicKey | [Jwk](#Jwk) | - - - -## IotaDID -A DID conforming to the IOTA DID method specification. - -**Kind**: global class - -* [IotaDID](#IotaDID) - * [new IotaDID(bytes, network)](#new_IotaDID_new) - * _instance_ - * [.network()](#IotaDID+network) ⇒ string - * [.tag()](#IotaDID+tag) ⇒ string - * [.toCoreDid()](#IotaDID+toCoreDid) ⇒ [CoreDID](#CoreDID) - * [.scheme()](#IotaDID+scheme) ⇒ string - * [.authority()](#IotaDID+authority) ⇒ string - * [.method()](#IotaDID+method) ⇒ string - * [.methodId()](#IotaDID+methodId) ⇒ string - * [.join(segment)](#IotaDID+join) ⇒ [DIDUrl](#DIDUrl) - * [.toUrl()](#IotaDID+toUrl) ⇒ [DIDUrl](#DIDUrl) - * [.toAliasId()](#IotaDID+toAliasId) ⇒ string - * [.intoUrl()](#IotaDID+intoUrl) ⇒ [DIDUrl](#DIDUrl) - * [.toString()](#IotaDID+toString) ⇒ string - * [.toJSON()](#IotaDID+toJSON) ⇒ any - * [.clone()](#IotaDID+clone) ⇒ [IotaDID](#IotaDID) - * _static_ - * [.METHOD](#IotaDID.METHOD) ⇒ string - * [.DEFAULT_NETWORK](#IotaDID.DEFAULT_NETWORK) ⇒ string - * [.fromAliasId(aliasId, network)](#IotaDID.fromAliasId) ⇒ [IotaDID](#IotaDID) - * [.placeholder(network)](#IotaDID.placeholder) ⇒ [IotaDID](#IotaDID) - * [.parse(input)](#IotaDID.parse) ⇒ [IotaDID](#IotaDID) - * [.fromJSON(json)](#IotaDID.fromJSON) ⇒ [IotaDID](#IotaDID) - - - -### new IotaDID(bytes, network) -Constructs a new [IotaDID](#IotaDID) from a byte representation of the tag and the given -network name. - -See also [placeholder](#IotaDID.placeholder). - - -| Param | Type | -| --- | --- | -| bytes | Uint8Array | -| network | string | - - - -### did.network() ⇒ string -Returns the Tangle network name of the [IotaDID](#IotaDID). - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.tag() ⇒ string -Returns a copy of the unique tag of the [IotaDID](#IotaDID). - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.toCoreDid() ⇒ [CoreDID](#CoreDID) -Returns the DID represented as a [CoreDID](#CoreDID). - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.scheme() ⇒ string -Returns the `DID` scheme. - -E.g. -- `"did:example:12345678" -> "did"` -- `"did:iota:main:12345678" -> "did"` - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.authority() ⇒ string -Returns the `DID` authority: the method name and method-id. - -E.g. -- `"did:example:12345678" -> "example:12345678"` -- `"did:iota:main:12345678" -> "iota:main:12345678"` - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.method() ⇒ string -Returns the `DID` method name. - -E.g. -- `"did:example:12345678" -> "example"` -- `"did:iota:main:12345678" -> "iota"` - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.methodId() ⇒ string -Returns the `DID` method-specific ID. - -E.g. -- `"did:example:12345678" -> "12345678"` -- `"did:iota:main:12345678" -> "main:12345678"` - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.join(segment) ⇒ [DIDUrl](#DIDUrl) -Construct a new [DIDUrl](#DIDUrl) by joining with a relative DID Url string. - -**Kind**: instance method of [IotaDID](#IotaDID) - -| Param | Type | -| --- | --- | -| segment | string | - - - -### did.toUrl() ⇒ [DIDUrl](#DIDUrl) -Clones the `DID` into a [DIDUrl](#DIDUrl). - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.toAliasId() ⇒ string -Returns the hex-encoded AliasId with a '0x' prefix, from the DID tag. - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.intoUrl() ⇒ [DIDUrl](#DIDUrl) -Converts the `DID` into a [DIDUrl](#DIDUrl), consuming it. - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.toString() ⇒ string -Returns the `DID` as a string. - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### did.clone() ⇒ [IotaDID](#IotaDID) -Deep clones the object. - -**Kind**: instance method of [IotaDID](#IotaDID) - - -### IotaDID.METHOD ⇒ string -The IOTA DID method name (`"iota"`). - -**Kind**: static property of [IotaDID](#IotaDID) - - -### IotaDID.DEFAULT\_NETWORK ⇒ string -The default Tangle network (`"iota"`). - -**Kind**: static property of [IotaDID](#IotaDID) - - -### IotaDID.fromAliasId(aliasId, network) ⇒ [IotaDID](#IotaDID) -Constructs a new [IotaDID](#IotaDID) from a hex representation of an Alias Id and the given -network name. - -**Kind**: static method of [IotaDID](#IotaDID) - -| Param | Type | -| --- | --- | -| aliasId | string | -| network | string | - - - -### IotaDID.placeholder(network) ⇒ [IotaDID](#IotaDID) -Creates a new placeholder [IotaDID](#IotaDID) with the given network name. - -E.g. `did:iota:smr:0x0000000000000000000000000000000000000000000000000000000000000000`. - -**Kind**: static method of [IotaDID](#IotaDID) - -| Param | Type | -| --- | --- | -| network | string | - - - -### IotaDID.parse(input) ⇒ [IotaDID](#IotaDID) -Parses a [IotaDID](#IotaDID) from the input string. - -**Kind**: static method of [IotaDID](#IotaDID) - -| Param | Type | -| --- | --- | -| input | string | - - - -### IotaDID.fromJSON(json) ⇒ [IotaDID](#IotaDID) -Deserializes an instance from a JSON object. - -**Kind**: static method of [IotaDID](#IotaDID) - -| Param | Type | -| --- | --- | -| json | any | - - - -## IotaDocument -A DID Document adhering to the IOTA DID method specification. - -Note: All methods that involve reading from this class may potentially raise an error -if the object is being concurrently modified. - -**Kind**: global class - -* [IotaDocument](#IotaDocument) - * [new IotaDocument(network)](#new_IotaDocument_new) - * _instance_ - * [.id()](#IotaDocument+id) ⇒ [IotaDID](#IotaDID) - * [.controller()](#IotaDocument+controller) ⇒ [Array.<IotaDID>](#IotaDID) - * [.setController(controller)](#IotaDocument+setController) - * [.alsoKnownAs()](#IotaDocument+alsoKnownAs) ⇒ Array.<string> - * [.setAlsoKnownAs(urls)](#IotaDocument+setAlsoKnownAs) - * [.properties()](#IotaDocument+properties) ⇒ Map.<string, any> - * [.setPropertyUnchecked(key, value)](#IotaDocument+setPropertyUnchecked) - * [.service()](#IotaDocument+service) ⇒ [Array.<Service>](#Service) - * [.insertService(service)](#IotaDocument+insertService) - * [.removeService(did)](#IotaDocument+removeService) ⇒ [Service](#Service) \| undefined - * [.resolveService(query)](#IotaDocument+resolveService) ⇒ [Service](#Service) \| undefined - * [.methods([scope])](#IotaDocument+methods) ⇒ [Array.<VerificationMethod>](#VerificationMethod) - * [.insertMethod(method, scope)](#IotaDocument+insertMethod) - * [.removeMethod(did)](#IotaDocument+removeMethod) ⇒ [VerificationMethod](#VerificationMethod) \| undefined - * [.resolveMethod(query, [scope])](#IotaDocument+resolveMethod) ⇒ [VerificationMethod](#VerificationMethod) \| undefined - * [.attachMethodRelationship(didUrl, relationship)](#IotaDocument+attachMethodRelationship) ⇒ boolean - * [.detachMethodRelationship(didUrl, relationship)](#IotaDocument+detachMethodRelationship) ⇒ boolean - * [.verifyJws(jws, options, signatureVerifier, [detachedPayload])](#IotaDocument+verifyJws) ⇒ [DecodedJws](#DecodedJws) - * [.pack()](#IotaDocument+pack) ⇒ Uint8Array - * [.packWithEncoding(encoding)](#IotaDocument+packWithEncoding) ⇒ Uint8Array - * [.metadata()](#IotaDocument+metadata) ⇒ [IotaDocumentMetadata](#IotaDocumentMetadata) - * [.metadataCreated()](#IotaDocument+metadataCreated) ⇒ [Timestamp](#Timestamp) \| undefined - * [.setMetadataCreated(timestamp)](#IotaDocument+setMetadataCreated) - * [.metadataUpdated()](#IotaDocument+metadataUpdated) ⇒ [Timestamp](#Timestamp) \| undefined - * [.setMetadataUpdated(timestamp)](#IotaDocument+setMetadataUpdated) - * [.metadataDeactivated()](#IotaDocument+metadataDeactivated) ⇒ boolean \| undefined - * [.setMetadataDeactivated([deactivated])](#IotaDocument+setMetadataDeactivated) - * [.metadataStateControllerAddress()](#IotaDocument+metadataStateControllerAddress) ⇒ string \| undefined - * [.metadataGovernorAddress()](#IotaDocument+metadataGovernorAddress) ⇒ string \| undefined - * [.setMetadataPropertyUnchecked(key, value)](#IotaDocument+setMetadataPropertyUnchecked) - * [.revokeCredentials(serviceQuery, indices)](#IotaDocument+revokeCredentials) - * [.unrevokeCredentials(serviceQuery, indices)](#IotaDocument+unrevokeCredentials) - * [.clone()](#IotaDocument+clone) ⇒ [IotaDocument](#IotaDocument) - * [._shallowCloneInternal()](#IotaDocument+_shallowCloneInternal) ⇒ [IotaDocument](#IotaDocument) - * [._strongCountInternal()](#IotaDocument+_strongCountInternal) ⇒ number - * [.toJSON()](#IotaDocument+toJSON) ⇒ any - * [.toCoreDocument()](#IotaDocument+toCoreDocument) ⇒ [CoreDocument](#CoreDocument) - * [.generateMethod(storage, keyType, alg, fragment, scope)](#IotaDocument+generateMethod) ⇒ Promise.<string> - * [.purgeMethod(storage, id)](#IotaDocument+purgeMethod) ⇒ Promise.<void> - * ~~[.createJwt(storage, fragment, payload, options)](#IotaDocument+createJwt) ⇒ [Promise.<Jws>](#Jws)~~ - * [.createJws(storage, fragment, payload, options)](#IotaDocument+createJws) ⇒ [Promise.<Jws>](#Jws) - * [.createCredentialJwt(storage, fragment, credential, options, [custom_claims])](#IotaDocument+createCredentialJwt) ⇒ [Promise.<Jwt>](#Jwt) - * [.createPresentationJwt(storage, fragment, presentation, signature_options, presentation_options)](#IotaDocument+createPresentationJwt) ⇒ [Promise.<Jwt>](#Jwt) - * [.generateMethodJwp(storage, alg, fragment, scope)](#IotaDocument+generateMethodJwp) ⇒ Promise.<string> - * [.createIssuedJwp(storage, fragment, jpt_claims, options)](#IotaDocument+createIssuedJwp) ⇒ Promise.<string> - * [.createPresentedJwp(presentation, method_id, options)](#IotaDocument+createPresentedJwp) ⇒ Promise.<string> - * [.createCredentialJpt(credential, storage, fragment, options, [custom_claims])](#IotaDocument+createCredentialJpt) ⇒ [Promise.<Jpt>](#Jpt) - * [.createPresentationJpt(presentation, method_id, options)](#IotaDocument+createPresentationJpt) ⇒ [Promise.<Jpt>](#Jpt) - * _static_ - * [.newWithId(id)](#IotaDocument.newWithId) ⇒ [IotaDocument](#IotaDocument) - * [.unpackFromOutput(did, aliasOutput, allowEmpty)](#IotaDocument.unpackFromOutput) ⇒ [IotaDocument](#IotaDocument) - * [.unpackFromBlock(network, block)](#IotaDocument.unpackFromBlock) ⇒ [Array.<IotaDocument>](#IotaDocument) - * [.fromJSON(json)](#IotaDocument.fromJSON) ⇒ [IotaDocument](#IotaDocument) - - - -### new IotaDocument(network) -Constructs an empty IOTA DID Document with a [placeholder](#IotaDID.placeholder) identifier -for the given `network`. - - -| Param | Type | -| --- | --- | -| network | string | - - - -### iotaDocument.id() ⇒ [IotaDID](#IotaDID) -Returns a copy of the DID Document `id`. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.controller() ⇒ [Array.<IotaDID>](#IotaDID) -Returns a copy of the list of document controllers. - -NOTE: controllers are determined by the `state_controller` unlock condition of the output -during resolution and are omitted when publishing. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.setController(controller) -Sets the controllers of the document. - -Note: Duplicates will be ignored. -Use `null` to remove all controllers. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| controller | [Array.<IotaDID>](#IotaDID) \| null | - - - -### iotaDocument.alsoKnownAs() ⇒ Array.<string> -Returns a copy of the document's `alsoKnownAs` set. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.setAlsoKnownAs(urls) -Sets the `alsoKnownAs` property in the DID document. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| urls | string \| Array.<string> \| null | - - - -### iotaDocument.properties() ⇒ Map.<string, any> -Returns a copy of the custom DID Document properties. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.setPropertyUnchecked(key, value) -Sets a custom property in the DID Document. -If the value is set to `null`, the custom property will be removed. - -### WARNING - -This method can overwrite existing properties like `id` and result in an invalid document. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| key | string | -| value | any | - - - -### iotaDocument.service() ⇒ [Array.<Service>](#Service) -Return a set of all [Service](#Service) in the document. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.insertService(service) -Add a new [Service](#Service) to the document. - -Returns `true` if the service was added. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| service | [Service](#Service) | - - - -### iotaDocument.removeService(did) ⇒ [Service](#Service) \| undefined -Remove a [Service](#Service) identified by the given [DIDUrl](#DIDUrl) from the document. - -Returns `true` if a service was removed. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| did | [DIDUrl](#DIDUrl) | - - - -### iotaDocument.resolveService(query) ⇒ [Service](#Service) \| undefined -Returns the first [Service](#Service) with an `id` property matching the provided `query`, -if present. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| query | [DIDUrl](#DIDUrl) \| string | - - - -### iotaDocument.methods([scope]) ⇒ [Array.<VerificationMethod>](#VerificationMethod) -Returns a list of all [VerificationMethod](#VerificationMethod) in the DID Document, -whose verification relationship matches `scope`. - -If `scope` is not set, a list over the **embedded** methods is returned. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| [scope] | [MethodScope](#MethodScope) \| undefined | - - - -### iotaDocument.insertMethod(method, scope) -Adds a new `method` to the document in the given `scope`. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| method | [VerificationMethod](#VerificationMethod) | -| scope | [MethodScope](#MethodScope) | - - - -### iotaDocument.removeMethod(did) ⇒ [VerificationMethod](#VerificationMethod) \| undefined -Removes all references to the specified Verification Method. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| did | [DIDUrl](#DIDUrl) | - - - -### iotaDocument.resolveMethod(query, [scope]) ⇒ [VerificationMethod](#VerificationMethod) \| undefined -Returns a copy of the first verification method with an `id` property -matching the provided `query` and the verification relationship -specified by `scope`, if present. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| query | [DIDUrl](#DIDUrl) \| string | -| [scope] | [MethodScope](#MethodScope) \| undefined | - - - -### iotaDocument.attachMethodRelationship(didUrl, relationship) ⇒ boolean -Attaches the relationship to the given method, if the method exists. - -Note: The method needs to be in the set of verification methods, -so it cannot be an embedded one. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| didUrl | [DIDUrl](#DIDUrl) | -| relationship | [MethodRelationship](#MethodRelationship) | - - - -### iotaDocument.detachMethodRelationship(didUrl, relationship) ⇒ boolean -Detaches the given relationship from the given method, if the method exists. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| didUrl | [DIDUrl](#DIDUrl) | -| relationship | [MethodRelationship](#MethodRelationship) | - - - -### iotaDocument.verifyJws(jws, options, signatureVerifier, [detachedPayload]) ⇒ [DecodedJws](#DecodedJws) -Decodes and verifies the provided JWS according to the passed `options` and `signatureVerifier`. - If no `signatureVerifier` argument is provided a default verifier will be used that is (only) capable of -verifying EdDSA signatures. - -Regardless of which options are passed the following conditions must be met in order for a verification attempt to -take place. -- The JWS must be encoded according to the JWS compact serialization. -- The `kid` value in the protected header must be an identifier of a verification method in this DID document. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| jws | [Jws](#Jws) | -| options | [JwsVerificationOptions](#JwsVerificationOptions) | -| signatureVerifier | IJwsVerifier | -| [detachedPayload] | string \| undefined | - - - -### iotaDocument.pack() ⇒ Uint8Array -Serializes the document for inclusion in an Alias Output's state metadata -with the default [StateMetadataEncoding](#StateMetadataEncoding). - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.packWithEncoding(encoding) ⇒ Uint8Array -Serializes the document for inclusion in an Alias Output's state metadata. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| encoding | [StateMetadataEncoding](#StateMetadataEncoding) | - - - -### iotaDocument.metadata() ⇒ [IotaDocumentMetadata](#IotaDocumentMetadata) -Returns a copy of the metadata associated with this document. - -NOTE: Copies all the metadata. See also `metadataCreated`, `metadataUpdated`, -`metadataPreviousMessageId`, `metadataProof` if only a subset of the metadata required. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.metadataCreated() ⇒ [Timestamp](#Timestamp) \| undefined -Returns a copy of the timestamp of when the DID document was created. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.setMetadataCreated(timestamp) -Sets the timestamp of when the DID document was created. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| timestamp | [Timestamp](#Timestamp) \| undefined | - - - -### iotaDocument.metadataUpdated() ⇒ [Timestamp](#Timestamp) \| undefined -Returns a copy of the timestamp of the last DID document update. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.setMetadataUpdated(timestamp) -Sets the timestamp of the last DID document update. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| timestamp | [Timestamp](#Timestamp) \| undefined | - - - -### iotaDocument.metadataDeactivated() ⇒ boolean \| undefined -Returns a copy of the deactivated status of the DID document. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.setMetadataDeactivated([deactivated]) -Sets the deactivated status of the DID document. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| [deactivated] | boolean \| undefined | - - - -### iotaDocument.metadataStateControllerAddress() ⇒ string \| undefined -Returns a copy of the Bech32-encoded state controller address, if present. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.metadataGovernorAddress() ⇒ string \| undefined -Returns a copy of the Bech32-encoded governor address, if present. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.setMetadataPropertyUnchecked(key, value) -Sets a custom property in the document metadata. -If the value is set to `null`, the custom property will be removed. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| key | string | -| value | any | - - - -### iotaDocument.revokeCredentials(serviceQuery, indices) -If the document has a [RevocationBitmap](#RevocationBitmap) service identified by `serviceQuery`, -revoke all specified `indices`. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| serviceQuery | [DIDUrl](#DIDUrl) \| string | -| indices | number \| Array.<number> | - - - -### iotaDocument.unrevokeCredentials(serviceQuery, indices) -If the document has a [RevocationBitmap](#RevocationBitmap) service identified by `serviceQuery`, -unrevoke all specified `indices`. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| serviceQuery | [DIDUrl](#DIDUrl) \| string | -| indices | number \| Array.<number> | - - - -### iotaDocument.clone() ⇒ [IotaDocument](#IotaDocument) -Returns a deep clone of the [IotaDocument](#IotaDocument). - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.\_shallowCloneInternal() ⇒ [IotaDocument](#IotaDocument) -### Warning -This is for internal use only. Do not rely on or call this method. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.\_strongCountInternal() ⇒ number -### Warning -This is for internal use only. Do not rely on or call this method. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.toJSON() ⇒ any -Serializes to a plain JS representation. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.toCoreDocument() ⇒ [CoreDocument](#CoreDocument) -Transforms the [IotaDocument](#IotaDocument) to its [CoreDocument](#CoreDocument) representation. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - - -### iotaDocument.generateMethod(storage, keyType, alg, fragment, scope) ⇒ Promise.<string> -Generate new key material in the given `storage` and insert a new verification method with the corresponding -public key material into the DID document. - -- If no fragment is given the `kid` of the generated JWK is used, if it is set, otherwise an error is returned. -- The `keyType` must be compatible with the given `storage`. `Storage`s are expected to export key type constants -for that use case. - -The fragment of the generated method is returned. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| keyType | string | -| alg | JwsAlgorithm | -| fragment | string \| undefined | -| scope | [MethodScope](#MethodScope) | - - - -### iotaDocument.purgeMethod(storage, id) ⇒ Promise.<void> -Remove the method identified by the given fragment from the document and delete the corresponding key material in -the given `storage`. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| id | [DIDUrl](#DIDUrl) | - - - -### ~~iotaDocument.createJwt(storage, fragment, payload, options) ⇒ [Promise.<Jws>](#Jws)~~ -***Deprecated*** - -Sign the `payload` according to `options` with the storage backed private key corresponding to the public key -material in the verification method identified by the given `fragment. - -Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. -See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| fragment | string | -| payload | string | -| options | [JwsSignatureOptions](#JwsSignatureOptions) | - - - -### iotaDocument.createJws(storage, fragment, payload, options) ⇒ [Promise.<Jws>](#Jws) -Sign the `payload` according to `options` with the storage backed private key corresponding to the public key -material in the verification method identified by the given `fragment. - -Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. -See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| fragment | string | -| payload | string | -| options | [JwsSignatureOptions](#JwsSignatureOptions) | - - - -### iotaDocument.createCredentialJwt(storage, fragment, credential, options, [custom_claims]) ⇒ [Promise.<Jwt>](#Jwt) -Produces a JWS where the payload is produced from the given `credential` -in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - -Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` -of the method identified by `fragment` and the JWS signature will be produced by the corresponding -private key backed by the `storage` in accordance with the passed `options`. - -The `custom_claims` can be used to set additional claims on the resulting JWT. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| fragment | string | -| credential | [Credential](#Credential) | -| options | [JwsSignatureOptions](#JwsSignatureOptions) | -| [custom_claims] | Record.<string, any> \| undefined | - - - -### iotaDocument.createPresentationJwt(storage, fragment, presentation, signature_options, presentation_options) ⇒ [Promise.<Jwt>](#Jwt) -Produces a JWT where the payload is produced from the given presentation. -in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - -Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` -of the method identified by `fragment` and the JWS signature will be produced by the corresponding -private key backed by the `storage` in accordance with the passed `options`. - -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| fragment | string | -| presentation | [Presentation](#Presentation) | -| signature_options | [JwsSignatureOptions](#JwsSignatureOptions) | -| presentation_options | [JwtPresentationOptions](#JwtPresentationOptions) | - - - -### iotaDocument.generateMethodJwp(storage, alg, fragment, scope) ⇒ Promise.<string> -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| alg | [ProofAlgorithm](#ProofAlgorithm) | -| fragment | string \| undefined | -| scope | [MethodScope](#MethodScope) | - - - -### iotaDocument.createIssuedJwp(storage, fragment, jpt_claims, options) ⇒ Promise.<string> -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| storage | [Storage](#Storage) | -| fragment | string | -| jpt_claims | JptClaims | -| options | [JwpCredentialOptions](#JwpCredentialOptions) | - - - -### iotaDocument.createPresentedJwp(presentation, method_id, options) ⇒ Promise.<string> -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| presentation | [SelectiveDisclosurePresentation](#SelectiveDisclosurePresentation) | -| method_id | string | -| options | [JwpPresentationOptions](#JwpPresentationOptions) | - - - -### iotaDocument.createCredentialJpt(credential, storage, fragment, options, [custom_claims]) ⇒ [Promise.<Jpt>](#Jpt) -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| storage | [Storage](#Storage) | -| fragment | string | -| options | [JwpCredentialOptions](#JwpCredentialOptions) | -| [custom_claims] | Map.<string, any> \| undefined | - - - -### iotaDocument.createPresentationJpt(presentation, method_id, options) ⇒ [Promise.<Jpt>](#Jpt) -**Kind**: instance method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| presentation | [SelectiveDisclosurePresentation](#SelectiveDisclosurePresentation) | -| method_id | string | -| options | [JwpPresentationOptions](#JwpPresentationOptions) | - - - -### IotaDocument.newWithId(id) ⇒ [IotaDocument](#IotaDocument) -Constructs an empty DID Document with the given identifier. - -**Kind**: static method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| id | [IotaDID](#IotaDID) | - - - -### IotaDocument.unpackFromOutput(did, aliasOutput, allowEmpty) ⇒ [IotaDocument](#IotaDocument) -Deserializes the document from an Alias Output. - -If `allowEmpty` is true, this will return an empty DID document marked as `deactivated` -if `stateMetadata` is empty. - -The `tokenSupply` must be equal to the token supply of the network the DID is associated with. - -NOTE: `did` is required since it is omitted from the serialized DID Document and -cannot be inferred from the state metadata. It also indicates the network, which is not -encoded in the `AliasId` alone. - -**Kind**: static method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| did | [IotaDID](#IotaDID) | -| aliasOutput | AliasOutputBuilderParams | -| allowEmpty | boolean | - - - -### IotaDocument.unpackFromBlock(network, block) ⇒ [Array.<IotaDocument>](#IotaDocument) -Returns all DID documents of the Alias Outputs contained in the block's transaction payload -outputs, if any. - -Errors if any Alias Output does not contain a valid or empty DID Document. - -**Kind**: static method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| network | string | -| block | Block | - - - -### IotaDocument.fromJSON(json) ⇒ [IotaDocument](#IotaDocument) -Deserializes an instance from a plain JS representation. - -**Kind**: static method of [IotaDocument](#IotaDocument) - -| Param | Type | -| --- | --- | -| json | any | - - - -## IotaDocumentMetadata -Additional attributes related to an IOTA DID Document. - -**Kind**: global class - -* [IotaDocumentMetadata](#IotaDocumentMetadata) - * _instance_ - * [.created()](#IotaDocumentMetadata+created) ⇒ [Timestamp](#Timestamp) \| undefined - * [.updated()](#IotaDocumentMetadata+updated) ⇒ [Timestamp](#Timestamp) \| undefined - * [.deactivated()](#IotaDocumentMetadata+deactivated) ⇒ boolean \| undefined - * [.stateControllerAddress()](#IotaDocumentMetadata+stateControllerAddress) ⇒ string \| undefined - * [.governorAddress()](#IotaDocumentMetadata+governorAddress) ⇒ string \| undefined - * [.properties()](#IotaDocumentMetadata+properties) ⇒ Map.<string, any> - * [.toJSON()](#IotaDocumentMetadata+toJSON) ⇒ any - * [.clone()](#IotaDocumentMetadata+clone) ⇒ [IotaDocumentMetadata](#IotaDocumentMetadata) - * _static_ - * [.fromJSON(json)](#IotaDocumentMetadata.fromJSON) ⇒ [IotaDocumentMetadata](#IotaDocumentMetadata) - - - -### iotaDocumentMetadata.created() ⇒ [Timestamp](#Timestamp) \| undefined -Returns a copy of the timestamp of when the DID document was created. - -**Kind**: instance method of [IotaDocumentMetadata](#IotaDocumentMetadata) - - -### iotaDocumentMetadata.updated() ⇒ [Timestamp](#Timestamp) \| undefined -Returns a copy of the timestamp of the last DID document update. - -**Kind**: instance method of [IotaDocumentMetadata](#IotaDocumentMetadata) - - -### iotaDocumentMetadata.deactivated() ⇒ boolean \| undefined -Returns a copy of the deactivated status of the DID document. - -**Kind**: instance method of [IotaDocumentMetadata](#IotaDocumentMetadata) - - -### iotaDocumentMetadata.stateControllerAddress() ⇒ string \| undefined -Returns a copy of the Bech32-encoded state controller address, if present. - -**Kind**: instance method of [IotaDocumentMetadata](#IotaDocumentMetadata) - - -### iotaDocumentMetadata.governorAddress() ⇒ string \| undefined -Returns a copy of the Bech32-encoded governor address, if present. - -**Kind**: instance method of [IotaDocumentMetadata](#IotaDocumentMetadata) - - -### iotaDocumentMetadata.properties() ⇒ Map.<string, any> -Returns a copy of the custom metadata properties. - -**Kind**: instance method of [IotaDocumentMetadata](#IotaDocumentMetadata) - - -### iotaDocumentMetadata.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [IotaDocumentMetadata](#IotaDocumentMetadata) - - -### iotaDocumentMetadata.clone() ⇒ [IotaDocumentMetadata](#IotaDocumentMetadata) -Deep clones the object. - -**Kind**: instance method of [IotaDocumentMetadata](#IotaDocumentMetadata) - - -### IotaDocumentMetadata.fromJSON(json) ⇒ [IotaDocumentMetadata](#IotaDocumentMetadata) -Deserializes an instance from a JSON object. - -**Kind**: static method of [IotaDocumentMetadata](#IotaDocumentMetadata) - -| Param | Type | -| --- | --- | -| json | any | - - - -## IotaIdentityClientExt -An extension interface that provides helper functions for publication -and resolution of DID documents in Alias Outputs. - -**Kind**: global class - -* [IotaIdentityClientExt](#IotaIdentityClientExt) - * [.newDidOutput(client, address, document, [rentStructure])](#IotaIdentityClientExt.newDidOutput) ⇒ Promise.<AliasOutputBuilderParams> - * [.updateDidOutput(client, document)](#IotaIdentityClientExt.updateDidOutput) ⇒ Promise.<AliasOutputBuilderParams> - * [.deactivateDidOutput(client, did)](#IotaIdentityClientExt.deactivateDidOutput) ⇒ Promise.<AliasOutputBuilderParams> - * [.resolveDid(client, did)](#IotaIdentityClientExt.resolveDid) ⇒ [Promise.<IotaDocument>](#IotaDocument) - * [.resolveDidOutput(client, did)](#IotaIdentityClientExt.resolveDidOutput) ⇒ Promise.<AliasOutputBuilderParams> - - - -### IotaIdentityClientExt.newDidOutput(client, address, document, [rentStructure]) ⇒ Promise.<AliasOutputBuilderParams> -Create a DID with a new Alias Output containing the given `document`. - -The `address` will be set as the state controller and governor unlock conditions. -The minimum required token deposit amount will be set according to the given -`rent_structure`, which will be fetched from the node if not provided. -The returned Alias Output can be further customised before publication, if desired. - -NOTE: this does *not* publish the Alias Output. - -**Kind**: static method of [IotaIdentityClientExt](#IotaIdentityClientExt) - -| Param | Type | -| --- | --- | -| client | IIotaIdentityClient | -| address | Address | -| document | [IotaDocument](#IotaDocument) | -| [rentStructure] | IRent \| undefined | - - - -### IotaIdentityClientExt.updateDidOutput(client, document) ⇒ Promise.<AliasOutputBuilderParams> -Fetches the associated Alias Output and updates it with `document` in its state metadata. -The storage deposit on the output is left unchanged. If the size of the document increased, -the amount should be increased manually. - -NOTE: this does *not* publish the updated Alias Output. - -**Kind**: static method of [IotaIdentityClientExt](#IotaIdentityClientExt) - -| Param | Type | -| --- | --- | -| client | IIotaIdentityClient | -| document | [IotaDocument](#IotaDocument) | - - - -### IotaIdentityClientExt.deactivateDidOutput(client, did) ⇒ Promise.<AliasOutputBuilderParams> -Removes the DID document from the state metadata of its Alias Output, -effectively deactivating it. The storage deposit on the output is left unchanged, -and should be reallocated manually. - -Deactivating does not destroy the output. Hence, it can be re-activated by publishing -an update containing a DID document. - -NOTE: this does *not* publish the updated Alias Output. - -**Kind**: static method of [IotaIdentityClientExt](#IotaIdentityClientExt) - -| Param | Type | -| --- | --- | -| client | IIotaIdentityClient | -| did | [IotaDID](#IotaDID) | - - - -### IotaIdentityClientExt.resolveDid(client, did) ⇒ [Promise.<IotaDocument>](#IotaDocument) -Resolve a [IotaDocument](#IotaDocument). Returns an empty, deactivated document if the state metadata -of the Alias Output is empty. - -**Kind**: static method of [IotaIdentityClientExt](#IotaIdentityClientExt) - -| Param | Type | -| --- | --- | -| client | IIotaIdentityClient | -| did | [IotaDID](#IotaDID) | - - - -### IotaIdentityClientExt.resolveDidOutput(client, did) ⇒ Promise.<AliasOutputBuilderParams> -Fetches the `IAliasOutput` associated with the given DID. - -**Kind**: static method of [IotaIdentityClientExt](#IotaIdentityClientExt) - -| Param | Type | -| --- | --- | -| client | IIotaIdentityClient | -| did | [IotaDID](#IotaDID) | - - - -## IssuerProtectedHeader -**Kind**: global class - -* [IssuerProtectedHeader](#IssuerProtectedHeader) - * [.typ](#IssuerProtectedHeader+typ) ⇒ string \| undefined - * [.typ](#IssuerProtectedHeader+typ) - * [.alg](#IssuerProtectedHeader+alg) ⇒ [ProofAlgorithm](#ProofAlgorithm) - * [.alg](#IssuerProtectedHeader+alg) - * [.kid](#IssuerProtectedHeader+kid) ⇒ string \| undefined - * [.kid](#IssuerProtectedHeader+kid) - * [.cid](#IssuerProtectedHeader+cid) ⇒ string \| undefined - * [.cid](#IssuerProtectedHeader+cid) - * [.claims()](#IssuerProtectedHeader+claims) ⇒ Array.<string> - - - -### issuerProtectedHeader.typ ⇒ string \| undefined -JWP type (JPT). - -**Kind**: instance property of [IssuerProtectedHeader](#IssuerProtectedHeader) - - -### issuerProtectedHeader.typ -JWP type (JPT). - -**Kind**: instance property of [IssuerProtectedHeader](#IssuerProtectedHeader) - -| Param | Type | -| --- | --- | -| [arg0] | string \| undefined | - - - -### issuerProtectedHeader.alg ⇒ [ProofAlgorithm](#ProofAlgorithm) -Algorithm used for the JWP. - -**Kind**: instance property of [IssuerProtectedHeader](#IssuerProtectedHeader) - - -### issuerProtectedHeader.alg -Algorithm used for the JWP. - -**Kind**: instance property of [IssuerProtectedHeader](#IssuerProtectedHeader) - -| Param | Type | -| --- | --- | -| arg0 | [ProofAlgorithm](#ProofAlgorithm) | - - - -### issuerProtectedHeader.kid ⇒ string \| undefined -ID for the key used for the JWP. - -**Kind**: instance property of [IssuerProtectedHeader](#IssuerProtectedHeader) - - -### issuerProtectedHeader.kid -ID for the key used for the JWP. - -**Kind**: instance property of [IssuerProtectedHeader](#IssuerProtectedHeader) - -| Param | Type | -| --- | --- | -| [arg0] | string \| undefined | - - - -### issuerProtectedHeader.cid ⇒ string \| undefined -Not handled for now. Will be used in the future to resolve external claims - -**Kind**: instance property of [IssuerProtectedHeader](#IssuerProtectedHeader) - - -### issuerProtectedHeader.cid -Not handled for now. Will be used in the future to resolve external claims - -**Kind**: instance property of [IssuerProtectedHeader](#IssuerProtectedHeader) - -| Param | Type | -| --- | --- | -| [arg0] | string \| undefined | - - - -### issuerProtectedHeader.claims() ⇒ Array.<string> -**Kind**: instance method of [IssuerProtectedHeader](#IssuerProtectedHeader) - - -## Jpt -A JSON Proof Token (JPT). - -**Kind**: global class - -* [Jpt](#Jpt) - * [new Jpt(jpt_string)](#new_Jpt_new) - * [.toString()](#Jpt+toString) ⇒ string - * [.clone()](#Jpt+clone) ⇒ [Jpt](#Jpt) - - - -### new Jpt(jpt_string) -Creates a new [Jpt](#Jpt). - - -| Param | Type | -| --- | --- | -| jpt_string | string | - - - -### jpt.toString() ⇒ string -**Kind**: instance method of [Jpt](#Jpt) - - -### jpt.clone() ⇒ [Jpt](#Jpt) -Deep clones the object. - -**Kind**: instance method of [Jpt](#Jpt) - - -## JptCredentialValidationOptions -Options to declare validation criteria for [Jpt](#Jpt). - -**Kind**: global class - -* [JptCredentialValidationOptions](#JptCredentialValidationOptions) - * [new JptCredentialValidationOptions([opts])](#new_JptCredentialValidationOptions_new) - * _instance_ - * [.clone()](#JptCredentialValidationOptions+clone) ⇒ [JptCredentialValidationOptions](#JptCredentialValidationOptions) - * [.toJSON()](#JptCredentialValidationOptions+toJSON) ⇒ any - * _static_ - * [.fromJSON(json)](#JptCredentialValidationOptions.fromJSON) ⇒ [JptCredentialValidationOptions](#JptCredentialValidationOptions) - - - -### new JptCredentialValidationOptions([opts]) -Creates a new default istance. - - -| Param | Type | -| --- | --- | -| [opts] | IJptCredentialValidationOptions \| undefined | - - - -### jptCredentialValidationOptions.clone() ⇒ [JptCredentialValidationOptions](#JptCredentialValidationOptions) -Deep clones the object. - -**Kind**: instance method of [JptCredentialValidationOptions](#JptCredentialValidationOptions) - - -### jptCredentialValidationOptions.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JptCredentialValidationOptions](#JptCredentialValidationOptions) - - -### JptCredentialValidationOptions.fromJSON(json) ⇒ [JptCredentialValidationOptions](#JptCredentialValidationOptions) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JptCredentialValidationOptions](#JptCredentialValidationOptions) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JptCredentialValidator -**Kind**: global class - - -### JptCredentialValidator.validate(credential_jpt, issuer, options, fail_fast) ⇒ [DecodedJptCredential](#DecodedJptCredential) -**Kind**: static method of [JptCredentialValidator](#JptCredentialValidator) - -| Param | Type | -| --- | --- | -| credential_jpt | [Jpt](#Jpt) | -| issuer | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| options | [JptCredentialValidationOptions](#JptCredentialValidationOptions) | -| fail_fast | [FailFast](#FailFast) | - - - -## JptCredentialValidatorUtils -Utility functions for validating JPT credentials. - -**Kind**: global class - -* [JptCredentialValidatorUtils](#JptCredentialValidatorUtils) - * [.extractIssuer(credential)](#JptCredentialValidatorUtils.extractIssuer) ⇒ [CoreDID](#CoreDID) - * [.extractIssuerFromIssuedJpt(credential)](#JptCredentialValidatorUtils.extractIssuerFromIssuedJpt) ⇒ [CoreDID](#CoreDID) - * [.checkTimeframesWithValidityTimeframe2024(credential, validity_timeframe, status_check)](#JptCredentialValidatorUtils.checkTimeframesWithValidityTimeframe2024) - * [.checkRevocationWithValidityTimeframe2024(credential, issuer, status_check)](#JptCredentialValidatorUtils.checkRevocationWithValidityTimeframe2024) - * [.checkTimeframesAndRevocationWithValidityTimeframe2024(credential, issuer, validity_timeframe, status_check)](#JptCredentialValidatorUtils.checkTimeframesAndRevocationWithValidityTimeframe2024) - - - -### JptCredentialValidatorUtils.extractIssuer(credential) ⇒ [CoreDID](#CoreDID) -Utility for extracting the issuer field of a [`Credential`](`Credential`) as a DID. -# Errors -Fails if the issuer field is not a valid DID. - -**Kind**: static method of [JptCredentialValidatorUtils](#JptCredentialValidatorUtils) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | - - - -### JptCredentialValidatorUtils.extractIssuerFromIssuedJpt(credential) ⇒ [CoreDID](#CoreDID) -Utility for extracting the issuer field of a credential in JPT representation as DID. -# Errors -If the JPT decoding fails or the issuer field is not a valid DID. - -**Kind**: static method of [JptCredentialValidatorUtils](#JptCredentialValidatorUtils) - -| Param | Type | -| --- | --- | -| credential | [Jpt](#Jpt) | - - - -### JptCredentialValidatorUtils.checkTimeframesWithValidityTimeframe2024(credential, validity_timeframe, status_check) -**Kind**: static method of [JptCredentialValidatorUtils](#JptCredentialValidatorUtils) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| validity_timeframe | [Timestamp](#Timestamp) \| undefined | -| status_check | [StatusCheck](#StatusCheck) | - - - -### JptCredentialValidatorUtils.checkRevocationWithValidityTimeframe2024(credential, issuer, status_check) -Checks whether the credential status has been revoked. - -Only supports `RevocationTimeframe2024`. - -**Kind**: static method of [JptCredentialValidatorUtils](#JptCredentialValidatorUtils) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| issuer | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| status_check | [StatusCheck](#StatusCheck) | - - - -### JptCredentialValidatorUtils.checkTimeframesAndRevocationWithValidityTimeframe2024(credential, issuer, validity_timeframe, status_check) -Checks whether the credential status has been revoked or the timeframe interval is INVALID - -Only supports `RevocationTimeframe2024`. - -**Kind**: static method of [JptCredentialValidatorUtils](#JptCredentialValidatorUtils) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| issuer | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| validity_timeframe | [Timestamp](#Timestamp) \| undefined | -| status_check | [StatusCheck](#StatusCheck) | - - - -## JptPresentationValidationOptions -Options to declare validation criteria for a [Jpt](#Jpt) presentation. - -**Kind**: global class - -* [JptPresentationValidationOptions](#JptPresentationValidationOptions) - * [new JptPresentationValidationOptions([opts])](#new_JptPresentationValidationOptions_new) - * _instance_ - * [.clone()](#JptPresentationValidationOptions+clone) ⇒ [JptPresentationValidationOptions](#JptPresentationValidationOptions) - * [.toJSON()](#JptPresentationValidationOptions+toJSON) ⇒ any - * _static_ - * [.fromJSON(json)](#JptPresentationValidationOptions.fromJSON) ⇒ [JptPresentationValidationOptions](#JptPresentationValidationOptions) - - - -### new JptPresentationValidationOptions([opts]) - -| Param | Type | -| --- | --- | -| [opts] | IJptPresentationValidationOptions \| undefined | - - - -### jptPresentationValidationOptions.clone() ⇒ [JptPresentationValidationOptions](#JptPresentationValidationOptions) -Deep clones the object. - -**Kind**: instance method of [JptPresentationValidationOptions](#JptPresentationValidationOptions) - - -### jptPresentationValidationOptions.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JptPresentationValidationOptions](#JptPresentationValidationOptions) - - -### JptPresentationValidationOptions.fromJSON(json) ⇒ [JptPresentationValidationOptions](#JptPresentationValidationOptions) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JptPresentationValidationOptions](#JptPresentationValidationOptions) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JptPresentationValidator -**Kind**: global class - - -### JptPresentationValidator.validate(presentation_jpt, issuer, options, fail_fast) ⇒ [DecodedJptPresentation](#DecodedJptPresentation) -Decodes and validates a Presented [Credential](#Credential) issued as a JPT (JWP Presented Form). A -[DecodedJptPresentation](#DecodedJptPresentation) is returned upon success. - -The following properties are validated according to `options`: -- the holder's proof on the JWP, -- the expiration date, -- the issuance date, -- the semantic structure. - -**Kind**: static method of [JptPresentationValidator](#JptPresentationValidator) - -| Param | Type | -| --- | --- | -| presentation_jpt | [Jpt](#Jpt) | -| issuer | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| options | [JptPresentationValidationOptions](#JptPresentationValidationOptions) | -| fail_fast | [FailFast](#FailFast) | - - - -## JptPresentationValidatorUtils -Utility functions for verifying JPT presentations. - -**Kind**: global class - -* [JptPresentationValidatorUtils](#JptPresentationValidatorUtils) - * [.extractIssuerFromPresentedJpt(presentation)](#JptPresentationValidatorUtils.extractIssuerFromPresentedJpt) ⇒ [CoreDID](#CoreDID) - * [.checkTimeframesWithValidityTimeframe2024(credential, validity_timeframe, status_check)](#JptPresentationValidatorUtils.checkTimeframesWithValidityTimeframe2024) - - - -### JptPresentationValidatorUtils.extractIssuerFromPresentedJpt(presentation) ⇒ [CoreDID](#CoreDID) -Utility for extracting the issuer field of a credential in JPT representation as DID. -# Errors -If the JPT decoding fails or the issuer field is not a valid DID. - -**Kind**: static method of [JptPresentationValidatorUtils](#JptPresentationValidatorUtils) - -| Param | Type | -| --- | --- | -| presentation | [Jpt](#Jpt) | - - - -### JptPresentationValidatorUtils.checkTimeframesWithValidityTimeframe2024(credential, validity_timeframe, status_check) -Check timeframe interval in credentialStatus with `RevocationTimeframeStatus`. - -**Kind**: static method of [JptPresentationValidatorUtils](#JptPresentationValidatorUtils) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| validity_timeframe | [Timestamp](#Timestamp) \| undefined | -| status_check | [StatusCheck](#StatusCheck) | - - - -## Jwk -**Kind**: global class - -* [Jwk](#Jwk) - * [new Jwk(jwk)](#new_Jwk_new) - * _instance_ - * [.kty()](#Jwk+kty) ⇒ JwkType - * [.use()](#Jwk+use) ⇒ JwkUse \| undefined - * [.keyOps()](#Jwk+keyOps) ⇒ Array.<JwkOperation> - * [.alg()](#Jwk+alg) ⇒ JwsAlgorithm \| undefined - * [.kid()](#Jwk+kid) ⇒ string \| undefined - * [.x5u()](#Jwk+x5u) ⇒ string \| undefined - * [.x5c()](#Jwk+x5c) ⇒ Array.<string> - * [.x5t()](#Jwk+x5t) ⇒ string \| undefined - * [.x5t256()](#Jwk+x5t256) ⇒ string \| undefined - * [.paramsEc()](#Jwk+paramsEc) ⇒ JwkParamsEc \| undefined - * [.paramsOkp()](#Jwk+paramsOkp) ⇒ JwkParamsOkp \| undefined - * [.paramsOct()](#Jwk+paramsOct) ⇒ JwkParamsOct \| undefined - * [.paramsRsa()](#Jwk+paramsRsa) ⇒ JwkParamsRsa \| undefined - * [.toPublic()](#Jwk+toPublic) ⇒ [Jwk](#Jwk) \| undefined - * [.isPublic()](#Jwk+isPublic) ⇒ boolean - * [.isPrivate()](#Jwk+isPrivate) ⇒ boolean - * [.toJSON()](#Jwk+toJSON) ⇒ any - * [.clone()](#Jwk+clone) ⇒ [Jwk](#Jwk) - * _static_ - * [.fromJSON(json)](#Jwk.fromJSON) ⇒ [Jwk](#Jwk) - - - -### new Jwk(jwk) - -| Param | Type | -| --- | --- | -| jwk | IJwkParams | - - - -### jwk.kty() ⇒ JwkType -Returns the value for the key type parameter (kty). - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.use() ⇒ JwkUse \| undefined -Returns the value for the use property (use). - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.keyOps() ⇒ Array.<JwkOperation> -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.alg() ⇒ JwsAlgorithm \| undefined -Returns the value for the algorithm property (alg). - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.kid() ⇒ string \| undefined -Returns the value of the key ID property (kid). - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.x5u() ⇒ string \| undefined -Returns the value of the X.509 URL property (x5u). - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.x5c() ⇒ Array.<string> -Returns the value of the X.509 certificate chain property (x5c). - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.x5t() ⇒ string \| undefined -Returns the value of the X.509 certificate SHA-1 thumbprint property (x5t). - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.x5t256() ⇒ string \| undefined -Returns the value of the X.509 certificate SHA-256 thumbprint property (x5t#S256). - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.paramsEc() ⇒ JwkParamsEc \| undefined -If this JWK is of kty EC, returns those parameters. - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.paramsOkp() ⇒ JwkParamsOkp \| undefined -If this JWK is of kty OKP, returns those parameters. - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.paramsOct() ⇒ JwkParamsOct \| undefined -If this JWK is of kty OCT, returns those parameters. - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.paramsRsa() ⇒ JwkParamsRsa \| undefined -If this JWK is of kty RSA, returns those parameters. - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.toPublic() ⇒ [Jwk](#Jwk) \| undefined -Returns a clone of the [Jwk](#Jwk) with _all_ private key components unset. -Nothing is returned when `kty = oct` as this key type is not considered public by this library. - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.isPublic() ⇒ boolean -Returns `true` if _all_ private key components of the key are unset, `false` otherwise. - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.isPrivate() ⇒ boolean -Returns `true` if _all_ private key components of the key are set, `false` otherwise. - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Jwk](#Jwk) - - -### jwk.clone() ⇒ [Jwk](#Jwk) -Deep clones the object. - -**Kind**: instance method of [Jwk](#Jwk) - - -### Jwk.fromJSON(json) ⇒ [Jwk](#Jwk) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Jwk](#Jwk) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JwkGenOutput -The result of a key generation in `JwkStorage`. - -**Kind**: global class - -* [JwkGenOutput](#JwkGenOutput) - * [new JwkGenOutput(key_id, jwk)](#new_JwkGenOutput_new) - * _instance_ - * [.jwk()](#JwkGenOutput+jwk) ⇒ [Jwk](#Jwk) - * [.keyId()](#JwkGenOutput+keyId) ⇒ string - * [.toJSON()](#JwkGenOutput+toJSON) ⇒ any - * [.clone()](#JwkGenOutput+clone) ⇒ [JwkGenOutput](#JwkGenOutput) - * _static_ - * [.fromJSON(json)](#JwkGenOutput.fromJSON) ⇒ [JwkGenOutput](#JwkGenOutput) - - - -### new JwkGenOutput(key_id, jwk) - -| Param | Type | -| --- | --- | -| key_id | string | -| jwk | [Jwk](#Jwk) | - - - -### jwkGenOutput.jwk() ⇒ [Jwk](#Jwk) -Returns the generated public [Jwk](#Jwk). - -**Kind**: instance method of [JwkGenOutput](#JwkGenOutput) - - -### jwkGenOutput.keyId() ⇒ string -Returns the key id of the generated [Jwk](#Jwk). - -**Kind**: instance method of [JwkGenOutput](#JwkGenOutput) - - -### jwkGenOutput.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JwkGenOutput](#JwkGenOutput) - - -### jwkGenOutput.clone() ⇒ [JwkGenOutput](#JwkGenOutput) -Deep clones the object. - -**Kind**: instance method of [JwkGenOutput](#JwkGenOutput) - - -### JwkGenOutput.fromJSON(json) ⇒ [JwkGenOutput](#JwkGenOutput) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JwkGenOutput](#JwkGenOutput) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JwpCredentialOptions -**Kind**: global class - -* [JwpCredentialOptions](#JwpCredentialOptions) - * _instance_ - * [.kid](#JwpCredentialOptions+kid) ⇒ string \| undefined - * [.kid](#JwpCredentialOptions+kid) - * [.toJSON()](#JwpCredentialOptions+toJSON) ⇒ any - * _static_ - * [.fromJSON(value)](#JwpCredentialOptions.fromJSON) ⇒ [JwpCredentialOptions](#JwpCredentialOptions) - - - -### jwpCredentialOptions.kid ⇒ string \| undefined -**Kind**: instance property of [JwpCredentialOptions](#JwpCredentialOptions) - - -### jwpCredentialOptions.kid -**Kind**: instance property of [JwpCredentialOptions](#JwpCredentialOptions) - -| Param | Type | -| --- | --- | -| [arg0] | string \| undefined | - - - -### jwpCredentialOptions.toJSON() ⇒ any -**Kind**: instance method of [JwpCredentialOptions](#JwpCredentialOptions) - - -### JwpCredentialOptions.fromJSON(value) ⇒ [JwpCredentialOptions](#JwpCredentialOptions) -**Kind**: static method of [JwpCredentialOptions](#JwpCredentialOptions) - -| Param | Type | -| --- | --- | -| value | any | - - - -## JwpIssued -**Kind**: global class - -* [JwpIssued](#JwpIssued) - * _instance_ - * [.toJSON()](#JwpIssued+toJSON) ⇒ any - * [.clone()](#JwpIssued+clone) ⇒ [JwpIssued](#JwpIssued) - * [.encode(serialization)](#JwpIssued+encode) ⇒ string - * [.setProof(proof)](#JwpIssued+setProof) - * [.getProof()](#JwpIssued+getProof) ⇒ Uint8Array - * [.getPayloads()](#JwpIssued+getPayloads) ⇒ [Payloads](#Payloads) - * [.setPayloads(payloads)](#JwpIssued+setPayloads) - * [.getIssuerProtectedHeader()](#JwpIssued+getIssuerProtectedHeader) ⇒ [IssuerProtectedHeader](#IssuerProtectedHeader) - * _static_ - * [.fromJSON(json)](#JwpIssued.fromJSON) ⇒ [JwpIssued](#JwpIssued) - - - -### jwpIssued.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JwpIssued](#JwpIssued) - - -### jwpIssued.clone() ⇒ [JwpIssued](#JwpIssued) -Deep clones the object. - -**Kind**: instance method of [JwpIssued](#JwpIssued) - - -### jwpIssued.encode(serialization) ⇒ string -**Kind**: instance method of [JwpIssued](#JwpIssued) - -| Param | Type | -| --- | --- | -| serialization | [SerializationType](#SerializationType) | - - - -### jwpIssued.setProof(proof) -**Kind**: instance method of [JwpIssued](#JwpIssued) - -| Param | Type | -| --- | --- | -| proof | Uint8Array | - - - -### jwpIssued.getProof() ⇒ Uint8Array -**Kind**: instance method of [JwpIssued](#JwpIssued) - - -### jwpIssued.getPayloads() ⇒ [Payloads](#Payloads) -**Kind**: instance method of [JwpIssued](#JwpIssued) - - -### jwpIssued.setPayloads(payloads) -**Kind**: instance method of [JwpIssued](#JwpIssued) - -| Param | Type | -| --- | --- | -| payloads | [Payloads](#Payloads) | - - - -### jwpIssued.getIssuerProtectedHeader() ⇒ [IssuerProtectedHeader](#IssuerProtectedHeader) -**Kind**: instance method of [JwpIssued](#JwpIssued) - - -### JwpIssued.fromJSON(json) ⇒ [JwpIssued](#JwpIssued) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JwpIssued](#JwpIssued) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JwpPresentationOptions -Options to be set in the JWT claims of a verifiable presentation. - -**Kind**: global class - -* [JwpPresentationOptions](#JwpPresentationOptions) - * [.audience](#JwpPresentationOptions+audience) ⇒ string \| undefined - * [.audience](#JwpPresentationOptions+audience) - * [.nonce](#JwpPresentationOptions+nonce) ⇒ string \| undefined - * [.nonce](#JwpPresentationOptions+nonce) - - - -### jwpPresentationOptions.audience ⇒ string \| undefined -Sets the audience for presentation (`aud` property in JWP Presentation Header). - -**Kind**: instance property of [JwpPresentationOptions](#JwpPresentationOptions) - - -### jwpPresentationOptions.audience -Sets the audience for presentation (`aud` property in JWP Presentation Header). - -**Kind**: instance property of [JwpPresentationOptions](#JwpPresentationOptions) - -| Param | Type | -| --- | --- | -| [arg0] | string \| undefined | - - - -### jwpPresentationOptions.nonce ⇒ string \| undefined -The nonce to be placed in the Presentation Protected Header. - -**Kind**: instance property of [JwpPresentationOptions](#JwpPresentationOptions) - - -### jwpPresentationOptions.nonce -The nonce to be placed in the Presentation Protected Header. - -**Kind**: instance property of [JwpPresentationOptions](#JwpPresentationOptions) - -| Param | Type | -| --- | --- | -| [arg0] | string \| undefined | - - - -## JwpVerificationOptions -**Kind**: global class - -* [JwpVerificationOptions](#JwpVerificationOptions) - * _instance_ - * [.clone()](#JwpVerificationOptions+clone) ⇒ [JwpVerificationOptions](#JwpVerificationOptions) - * [.toJSON()](#JwpVerificationOptions+toJSON) ⇒ any - * _static_ - * [.fromJSON(json)](#JwpVerificationOptions.fromJSON) ⇒ [JwpVerificationOptions](#JwpVerificationOptions) - * [.new([opts])](#JwpVerificationOptions.new) ⇒ [JwpVerificationOptions](#JwpVerificationOptions) - - - -### jwpVerificationOptions.clone() ⇒ [JwpVerificationOptions](#JwpVerificationOptions) -Deep clones the object. - -**Kind**: instance method of [JwpVerificationOptions](#JwpVerificationOptions) - - -### jwpVerificationOptions.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JwpVerificationOptions](#JwpVerificationOptions) - - -### JwpVerificationOptions.fromJSON(json) ⇒ [JwpVerificationOptions](#JwpVerificationOptions) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JwpVerificationOptions](#JwpVerificationOptions) - -| Param | Type | -| --- | --- | -| json | any | - - - -### JwpVerificationOptions.new([opts]) ⇒ [JwpVerificationOptions](#JwpVerificationOptions) -**Kind**: static method of [JwpVerificationOptions](#JwpVerificationOptions) - -| Param | Type | -| --- | --- | -| [opts] | IJwpVerificationOptions \| undefined | - - - -## Jws -A wrapper around a JSON Web Signature (JWS). - -**Kind**: global class - -* [Jws](#Jws) - * [new Jws(jws_string)](#new_Jws_new) - * [.toString()](#Jws+toString) ⇒ string - - - -### new Jws(jws_string) -Creates a new [Jws](#Jws) from the given string. - - -| Param | Type | -| --- | --- | -| jws_string | string | - - - -### jws.toString() ⇒ string -Returns a clone of the JWS string. - -**Kind**: instance method of [Jws](#Jws) - - -## JwsHeader -**Kind**: global class - -* [JwsHeader](#JwsHeader) - * [new JwsHeader()](#new_JwsHeader_new) - * _instance_ - * [.alg()](#JwsHeader+alg) ⇒ JwsAlgorithm \| undefined - * [.setAlg(value)](#JwsHeader+setAlg) - * [.b64()](#JwsHeader+b64) ⇒ boolean \| undefined - * [.setB64(value)](#JwsHeader+setB64) - * [.custom()](#JwsHeader+custom) ⇒ Record.<string, any> \| undefined - * [.has(claim)](#JwsHeader+has) ⇒ boolean - * [.isDisjoint(other)](#JwsHeader+isDisjoint) ⇒ boolean - * [.jku()](#JwsHeader+jku) ⇒ string \| undefined - * [.setJku(value)](#JwsHeader+setJku) - * [.jwk()](#JwsHeader+jwk) ⇒ [Jwk](#Jwk) \| undefined - * [.setJwk(value)](#JwsHeader+setJwk) - * [.kid()](#JwsHeader+kid) ⇒ string \| undefined - * [.setKid(value)](#JwsHeader+setKid) - * [.x5u()](#JwsHeader+x5u) ⇒ string \| undefined - * [.setX5u(value)](#JwsHeader+setX5u) - * [.x5c()](#JwsHeader+x5c) ⇒ Array.<string> - * [.setX5c(value)](#JwsHeader+setX5c) - * [.x5t()](#JwsHeader+x5t) ⇒ string \| undefined - * [.setX5t(value)](#JwsHeader+setX5t) - * [.x5tS256()](#JwsHeader+x5tS256) ⇒ string \| undefined - * [.setX5tS256(value)](#JwsHeader+setX5tS256) - * [.typ()](#JwsHeader+typ) ⇒ string \| undefined - * [.setTyp(value)](#JwsHeader+setTyp) - * [.cty()](#JwsHeader+cty) ⇒ string \| undefined - * [.setCty(value)](#JwsHeader+setCty) - * [.crit()](#JwsHeader+crit) ⇒ Array.<string> - * [.setCrit(value)](#JwsHeader+setCrit) - * [.url()](#JwsHeader+url) ⇒ string \| undefined - * [.setUrl(value)](#JwsHeader+setUrl) - * [.nonce()](#JwsHeader+nonce) ⇒ string \| undefined - * [.setNonce(value)](#JwsHeader+setNonce) - * [.toJSON()](#JwsHeader+toJSON) ⇒ any - * [.clone()](#JwsHeader+clone) ⇒ [JwsHeader](#JwsHeader) - * _static_ - * [.fromJSON(json)](#JwsHeader.fromJSON) ⇒ [JwsHeader](#JwsHeader) - - - -### new JwsHeader() -Create a new empty [JwsHeader](#JwsHeader). - - - -### jwsHeader.alg() ⇒ JwsAlgorithm \| undefined -Returns the value for the algorithm claim (alg). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setAlg(value) -Sets a value for the algorithm claim (alg). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | JwsAlgorithm | - - - -### jwsHeader.b64() ⇒ boolean \| undefined -Returns the value of the base64url-encode payload claim (b64). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setB64(value) -Sets a value for the base64url-encode payload claim (b64). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | boolean | - - - -### jwsHeader.custom() ⇒ Record.<string, any> \| undefined -Additional header parameters. - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.has(claim) ⇒ boolean -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| claim | string | - - - -### jwsHeader.isDisjoint(other) ⇒ boolean -Returns `true` if none of the fields are set in both `self` and `other`. - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| other | [JwsHeader](#JwsHeader) | - - - -### jwsHeader.jku() ⇒ string \| undefined -Returns the value of the JWK Set URL claim (jku). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setJku(value) -Sets a value for the JWK Set URL claim (jku). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsHeader.jwk() ⇒ [Jwk](#Jwk) \| undefined -Returns the value of the JWK claim (jwk). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setJwk(value) -Sets a value for the JWK claim (jwk). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | [Jwk](#Jwk) | - - - -### jwsHeader.kid() ⇒ string \| undefined -Returns the value of the key ID claim (kid). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setKid(value) -Sets a value for the key ID claim (kid). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsHeader.x5u() ⇒ string \| undefined -Returns the value of the X.509 URL claim (x5u). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setX5u(value) -Sets a value for the X.509 URL claim (x5u). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsHeader.x5c() ⇒ Array.<string> -Returns the value of the X.509 certificate chain claim (x5c). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setX5c(value) -Sets values for the X.509 certificate chain claim (x5c). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | Array.<string> | - - - -### jwsHeader.x5t() ⇒ string \| undefined -Returns the value of the X.509 certificate SHA-1 thumbprint claim (x5t). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setX5t(value) -Sets a value for the X.509 certificate SHA-1 thumbprint claim (x5t). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsHeader.x5tS256() ⇒ string \| undefined -Returns the value of the X.509 certificate SHA-256 thumbprint claim -(x5t#S256). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setX5tS256(value) -Sets a value for the X.509 certificate SHA-256 thumbprint claim -(x5t#S256). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsHeader.typ() ⇒ string \| undefined -Returns the value of the token type claim (typ). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setTyp(value) -Sets a value for the token type claim (typ). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsHeader.cty() ⇒ string \| undefined -Returns the value of the content type claim (cty). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setCty(value) -Sets a value for the content type claim (cty). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsHeader.crit() ⇒ Array.<string> -Returns the value of the critical claim (crit). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setCrit(value) -Sets values for the critical claim (crit). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | Array.<string> | - - - -### jwsHeader.url() ⇒ string \| undefined -Returns the value of the url claim (url). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setUrl(value) -Sets a value for the url claim (url). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsHeader.nonce() ⇒ string \| undefined -Returns the value of the nonce claim (nonce). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.setNonce(value) -Sets a value for the nonce claim (nonce). - -**Kind**: instance method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsHeader.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### jwsHeader.clone() ⇒ [JwsHeader](#JwsHeader) -Deep clones the object. - -**Kind**: instance method of [JwsHeader](#JwsHeader) - - -### JwsHeader.fromJSON(json) ⇒ [JwsHeader](#JwsHeader) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JwsHeader](#JwsHeader) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JwsSignatureOptions -**Kind**: global class - -* [JwsSignatureOptions](#JwsSignatureOptions) - * [new JwsSignatureOptions([options])](#new_JwsSignatureOptions_new) - * _instance_ - * [.setAttachJwk(value)](#JwsSignatureOptions+setAttachJwk) - * [.setB64(value)](#JwsSignatureOptions+setB64) - * [.setTyp(value)](#JwsSignatureOptions+setTyp) - * [.setCty(value)](#JwsSignatureOptions+setCty) - * [.serUrl(value)](#JwsSignatureOptions+serUrl) - * [.setNonce(value)](#JwsSignatureOptions+setNonce) - * [.setKid(value)](#JwsSignatureOptions+setKid) - * [.setDetachedPayload(value)](#JwsSignatureOptions+setDetachedPayload) - * [.setCustomHeaderParameters(value)](#JwsSignatureOptions+setCustomHeaderParameters) - * [.toJSON()](#JwsSignatureOptions+toJSON) ⇒ any - * [.clone()](#JwsSignatureOptions+clone) ⇒ [JwsSignatureOptions](#JwsSignatureOptions) - * _static_ - * [.fromJSON(json)](#JwsSignatureOptions.fromJSON) ⇒ [JwsSignatureOptions](#JwsSignatureOptions) - - - -### new JwsSignatureOptions([options]) - -| Param | Type | -| --- | --- | -| [options] | IJwsSignatureOptions \| undefined | - - - -### jwsSignatureOptions.setAttachJwk(value) -Replace the value of the `attachJwk` field. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| value | boolean | - - - -### jwsSignatureOptions.setB64(value) -Replace the value of the `b64` field. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| value | boolean | - - - -### jwsSignatureOptions.setTyp(value) -Replace the value of the `typ` field. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsSignatureOptions.setCty(value) -Replace the value of the `cty` field. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsSignatureOptions.serUrl(value) -Replace the value of the `url` field. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsSignatureOptions.setNonce(value) -Replace the value of the `nonce` field. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsSignatureOptions.setKid(value) -Replace the value of the `kid` field. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsSignatureOptions.setDetachedPayload(value) -Replace the value of the `detached_payload` field. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| value | boolean | - - - -### jwsSignatureOptions.setCustomHeaderParameters(value) -Add additional header parameters. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| value | Record.<string, any> | - - - -### jwsSignatureOptions.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - - -### jwsSignatureOptions.clone() ⇒ [JwsSignatureOptions](#JwsSignatureOptions) -Deep clones the object. - -**Kind**: instance method of [JwsSignatureOptions](#JwsSignatureOptions) - - -### JwsSignatureOptions.fromJSON(json) ⇒ [JwsSignatureOptions](#JwsSignatureOptions) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JwsSignatureOptions](#JwsSignatureOptions) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JwsVerificationOptions -**Kind**: global class - -* [JwsVerificationOptions](#JwsVerificationOptions) - * [new JwsVerificationOptions([options])](#new_JwsVerificationOptions_new) - * _instance_ - * [.setNonce(value)](#JwsVerificationOptions+setNonce) - * [.setMethodScope(value)](#JwsVerificationOptions+setMethodScope) - * [.setMethodId(value)](#JwsVerificationOptions+setMethodId) - * [.toJSON()](#JwsVerificationOptions+toJSON) ⇒ any - * [.clone()](#JwsVerificationOptions+clone) ⇒ [JwsVerificationOptions](#JwsVerificationOptions) - * _static_ - * [.fromJSON(json)](#JwsVerificationOptions.fromJSON) ⇒ [JwsVerificationOptions](#JwsVerificationOptions) - - - -### new JwsVerificationOptions([options]) -Creates a new [JwsVerificationOptions](#JwsVerificationOptions) from the given fields. - - -| Param | Type | -| --- | --- | -| [options] | IJwsVerificationOptions \| undefined | - - - -### jwsVerificationOptions.setNonce(value) -Set the expected value for the `nonce` parameter of the protected header. - -**Kind**: instance method of [JwsVerificationOptions](#JwsVerificationOptions) - -| Param | Type | -| --- | --- | -| value | string | - - - -### jwsVerificationOptions.setMethodScope(value) -Set the scope of the verification methods that may be used to verify the given JWS. - -**Kind**: instance method of [JwsVerificationOptions](#JwsVerificationOptions) - -| Param | Type | -| --- | --- | -| value | [MethodScope](#MethodScope) | - - - -### jwsVerificationOptions.setMethodId(value) -Set the DID URl of the method, whose JWK should be used to verify the JWS. - -**Kind**: instance method of [JwsVerificationOptions](#JwsVerificationOptions) - -| Param | Type | -| --- | --- | -| value | [DIDUrl](#DIDUrl) | - - - -### jwsVerificationOptions.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JwsVerificationOptions](#JwsVerificationOptions) - - -### jwsVerificationOptions.clone() ⇒ [JwsVerificationOptions](#JwsVerificationOptions) -Deep clones the object. - -**Kind**: instance method of [JwsVerificationOptions](#JwsVerificationOptions) - - -### JwsVerificationOptions.fromJSON(json) ⇒ [JwsVerificationOptions](#JwsVerificationOptions) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JwsVerificationOptions](#JwsVerificationOptions) - -| Param | Type | -| --- | --- | -| json | any | - - - -## Jwt -A wrapper around a JSON Web Token (JWK). - -**Kind**: global class - -* [Jwt](#Jwt) - * [new Jwt(jwt_string)](#new_Jwt_new) - * _instance_ - * [.toString()](#Jwt+toString) ⇒ string - * [.toJSON()](#Jwt+toJSON) ⇒ any - * [.clone()](#Jwt+clone) ⇒ [Jwt](#Jwt) - * _static_ - * [.fromJSON(json)](#Jwt.fromJSON) ⇒ [Jwt](#Jwt) - - - -### new Jwt(jwt_string) -Creates a new [Jwt](#Jwt) from the given string. - - -| Param | Type | -| --- | --- | -| jwt_string | string | - - - -### jwt.toString() ⇒ string -Returns a clone of the JWT string. - -**Kind**: instance method of [Jwt](#Jwt) - - -### jwt.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Jwt](#Jwt) - - -### jwt.clone() ⇒ [Jwt](#Jwt) -Deep clones the object. - -**Kind**: instance method of [Jwt](#Jwt) - - -### Jwt.fromJSON(json) ⇒ [Jwt](#Jwt) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Jwt](#Jwt) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JwtCredentialValidationOptions -Options to declare validation criteria when validating credentials. - -**Kind**: global class - -* [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) - * [new JwtCredentialValidationOptions([options])](#new_JwtCredentialValidationOptions_new) - * _instance_ - * [.toJSON()](#JwtCredentialValidationOptions+toJSON) ⇒ any - * [.clone()](#JwtCredentialValidationOptions+clone) ⇒ [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) - * _static_ - * [.fromJSON(json)](#JwtCredentialValidationOptions.fromJSON) ⇒ [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) - - - -### new JwtCredentialValidationOptions([options]) - -| Param | Type | -| --- | --- | -| [options] | IJwtCredentialValidationOptions \| undefined | - - - -### jwtCredentialValidationOptions.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) - - -### jwtCredentialValidationOptions.clone() ⇒ [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) -Deep clones the object. - -**Kind**: instance method of [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) - - -### JwtCredentialValidationOptions.fromJSON(json) ⇒ [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JwtCredentialValidator -A type for decoding and validating [Credential](#Credential). - -**Kind**: global class - -* [JwtCredentialValidator](#JwtCredentialValidator) - * [new JwtCredentialValidator(signatureVerifier)](#new_JwtCredentialValidator_new) - * _instance_ - * [.validate(credential_jwt, issuer, options, fail_fast)](#JwtCredentialValidator+validate) ⇒ [DecodedJwtCredential](#DecodedJwtCredential) - * [.verifySignature(credential, trustedIssuers, options)](#JwtCredentialValidator+verifySignature) ⇒ [DecodedJwtCredential](#DecodedJwtCredential) - * _static_ - * [.checkExpiresOnOrAfter(credential, timestamp)](#JwtCredentialValidator.checkExpiresOnOrAfter) - * [.checkIssuedOnOrBefore(credential, timestamp)](#JwtCredentialValidator.checkIssuedOnOrBefore) - * [.checkSubjectHolderRelationship(credential, holder, relationship)](#JwtCredentialValidator.checkSubjectHolderRelationship) - * [.checkStatus(credential, trustedIssuers, statusCheck)](#JwtCredentialValidator.checkStatus) - * [.checkStatusWithStatusList2021(credential, status_list, status_check)](#JwtCredentialValidator.checkStatusWithStatusList2021) - * [.extractIssuer(credential)](#JwtCredentialValidator.extractIssuer) ⇒ [CoreDID](#CoreDID) - * [.extractIssuerFromJwt(credential)](#JwtCredentialValidator.extractIssuerFromJwt) ⇒ [CoreDID](#CoreDID) - - - -### new JwtCredentialValidator(signatureVerifier) -Creates a new [JwtCredentialValidator](#JwtCredentialValidator). If a `signatureVerifier` is provided it will be used when -verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` -algorithm will be used. - - -| Param | Type | -| --- | --- | -| signatureVerifier | IJwsVerifier | - - - -### jwtCredentialValidator.validate(credential_jwt, issuer, options, fail_fast) ⇒ [DecodedJwtCredential](#DecodedJwtCredential) -Decodes and validates a [Credential](#Credential) issued as a JWS. A [DecodedJwtCredential](#DecodedJwtCredential) is returned upon -success. - -The following properties are validated according to `options`: -- the issuer's signature on the JWS, -- the expiration date, -- the issuance date, -- the semantic structure. - -# Warning -The lack of an error returned from this method is in of itself not enough to conclude that the credential can be -trusted. This section contains more information on additional checks that should be carried out before and after -calling this method. - -## The state of the issuer's DID Document -The caller must ensure that `issuer` represents an up-to-date DID Document. - -## Properties that are not validated - There are many properties defined in [The Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/) that are **not** validated, such as: -`proof`, `credentialStatus`, `type`, `credentialSchema`, `refreshService` **and more**. -These should be manually checked after validation, according to your requirements. - -# Errors -An error is returned whenever a validated condition is not satisfied. - -**Kind**: instance method of [JwtCredentialValidator](#JwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential_jwt | [Jwt](#Jwt) | -| issuer | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| options | [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) | -| fail_fast | [FailFast](#FailFast) | - - - -### jwtCredentialValidator.verifySignature(credential, trustedIssuers, options) ⇒ [DecodedJwtCredential](#DecodedJwtCredential) -Decode and verify the JWS signature of a [Credential](#Credential) issued as a JWT using the DID Document of a trusted -issuer. - -A [DecodedJwtCredential](#DecodedJwtCredential) is returned upon success. - -# Warning -The caller must ensure that the DID Documents of the trusted issuers are up-to-date. - -## Proofs - Only the JWS signature is verified. If the [Credential](#Credential) contains a `proof` property this will not be -verified by this method. - -# Errors -This method immediately returns an error if -the credential issuer' url cannot be parsed to a DID belonging to one of the trusted issuers. Otherwise an attempt -to verify the credential's signature will be made and an error is returned upon failure. - -**Kind**: instance method of [JwtCredentialValidator](#JwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential | [Jwt](#Jwt) | -| trustedIssuers | Array.<(CoreDocument\|IToCoreDocument)> | -| options | [JwsVerificationOptions](#JwsVerificationOptions) | - - - -### JwtCredentialValidator.checkExpiresOnOrAfter(credential, timestamp) -Validate that the credential expires on or after the specified timestamp. - -**Kind**: static method of [JwtCredentialValidator](#JwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| timestamp | [Timestamp](#Timestamp) | - - - -### JwtCredentialValidator.checkIssuedOnOrBefore(credential, timestamp) -Validate that the credential is issued on or before the specified timestamp. - -**Kind**: static method of [JwtCredentialValidator](#JwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| timestamp | [Timestamp](#Timestamp) | - - - -### JwtCredentialValidator.checkSubjectHolderRelationship(credential, holder, relationship) -Validate that the relationship between the `holder` and the credential subjects is in accordance with -`relationship`. The `holder` parameter is expected to be the URL of the holder. - -**Kind**: static method of [JwtCredentialValidator](#JwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| holder | string | -| relationship | [SubjectHolderRelationship](#SubjectHolderRelationship) | - - - -### JwtCredentialValidator.checkStatus(credential, trustedIssuers, statusCheck) -Checks whether the credential status has been revoked. - -Only supports `RevocationBitmap2022`. - -**Kind**: static method of [JwtCredentialValidator](#JwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| trustedIssuers | Array.<(CoreDocument\|IToCoreDocument)> | -| statusCheck | [StatusCheck](#StatusCheck) | - - - -### JwtCredentialValidator.checkStatusWithStatusList2021(credential, status_list, status_check) -Checks wheter the credential status has been revoked using `StatusList2021`. - -**Kind**: static method of [JwtCredentialValidator](#JwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| status_list | [StatusList2021Credential](#StatusList2021Credential) | -| status_check | [StatusCheck](#StatusCheck) | - - - -### JwtCredentialValidator.extractIssuer(credential) ⇒ [CoreDID](#CoreDID) -Utility for extracting the issuer field of a [Credential](#Credential) as a DID. - -### Errors - -Fails if the issuer field is not a valid DID. - -**Kind**: static method of [JwtCredentialValidator](#JwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | - - - -### JwtCredentialValidator.extractIssuerFromJwt(credential) ⇒ [CoreDID](#CoreDID) -Utility for extracting the issuer field of a credential in JWT representation as DID. - -# Errors - -If the JWT decoding fails or the issuer field is not a valid DID. - -**Kind**: static method of [JwtCredentialValidator](#JwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential | [Jwt](#Jwt) | - - - -## JwtDomainLinkageValidator -A validator for a Domain Linkage Configuration and Credentials. - -**Kind**: global class - -* [JwtDomainLinkageValidator](#JwtDomainLinkageValidator) - * [new JwtDomainLinkageValidator(signatureVerifier)](#new_JwtDomainLinkageValidator_new) - * [.validateLinkage(issuer, configuration, domain, options)](#JwtDomainLinkageValidator+validateLinkage) - * [.validateCredential(issuer, credentialJwt, domain, options)](#JwtDomainLinkageValidator+validateCredential) - - - -### new JwtDomainLinkageValidator(signatureVerifier) -Creates a new [JwtDomainLinkageValidator](#JwtDomainLinkageValidator). If a `signatureVerifier` is provided it will be used when -verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` -algorithm will be used. - - -| Param | Type | -| --- | --- | -| signatureVerifier | IJwsVerifier | - - - -### jwtDomainLinkageValidator.validateLinkage(issuer, configuration, domain, options) -Validates the linkage between a domain and a DID. -[DomainLinkageConfiguration](#DomainLinkageConfiguration) is validated according to [DID Configuration Resource Verification](https://identity.foundation/.well-known/resources/did-configuration/#did-configuration-resource-verification). - -Linkage is valid if no error is thrown. - -# Note: -- Only the [JSON Web Token Proof Format](https://identity.foundation/.well-known/resources/did-configuration/#json-web-token-proof-format) - is supported. -- Only the Credential issued by `issuer` is verified. - -# Errors - - - Semantic structure of `configuration` is invalid. - - `configuration` includes multiple credentials issued by `issuer`. - - Validation of the matched Domain Linkage Credential fails. - -**Kind**: instance method of [JwtDomainLinkageValidator](#JwtDomainLinkageValidator) - -| Param | Type | -| --- | --- | -| issuer | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| configuration | [DomainLinkageConfiguration](#DomainLinkageConfiguration) | -| domain | string | -| options | [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) | - - - -### jwtDomainLinkageValidator.validateCredential(issuer, credentialJwt, domain, options) -Validates a [Domain Linkage Credential](https://identity.foundation/.well-known/resources/did-configuration/#domain-linkage-credential). - -Error will be thrown in case the validation fails. - -**Kind**: instance method of [JwtDomainLinkageValidator](#JwtDomainLinkageValidator) - -| Param | Type | -| --- | --- | -| issuer | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| credentialJwt | [Jwt](#Jwt) | -| domain | string | -| options | [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) | - - - -## JwtPresentationOptions -**Kind**: global class - -* [JwtPresentationOptions](#JwtPresentationOptions) - * [new JwtPresentationOptions([options])](#new_JwtPresentationOptions_new) - * _instance_ - * [.toJSON()](#JwtPresentationOptions+toJSON) ⇒ any - * [.clone()](#JwtPresentationOptions+clone) ⇒ [JwtPresentationOptions](#JwtPresentationOptions) - * _static_ - * [.fromJSON(json)](#JwtPresentationOptions.fromJSON) ⇒ [JwtPresentationOptions](#JwtPresentationOptions) - - - -### new JwtPresentationOptions([options]) -Creates a new [JwtPresentationOptions](#JwtPresentationOptions) from the given fields. - -Throws an error if any of the options are invalid. - - -| Param | Type | -| --- | --- | -| [options] | IJwtPresentationOptions \| undefined | - - - -### jwtPresentationOptions.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JwtPresentationOptions](#JwtPresentationOptions) - - -### jwtPresentationOptions.clone() ⇒ [JwtPresentationOptions](#JwtPresentationOptions) -Deep clones the object. - -**Kind**: instance method of [JwtPresentationOptions](#JwtPresentationOptions) - - -### JwtPresentationOptions.fromJSON(json) ⇒ [JwtPresentationOptions](#JwtPresentationOptions) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JwtPresentationOptions](#JwtPresentationOptions) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JwtPresentationValidationOptions -Options to declare validation criteria when validating presentation. - -**Kind**: global class - -* [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) - * [new JwtPresentationValidationOptions([options])](#new_JwtPresentationValidationOptions_new) - * _instance_ - * [.toJSON()](#JwtPresentationValidationOptions+toJSON) ⇒ any - * [.clone()](#JwtPresentationValidationOptions+clone) ⇒ [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) - * _static_ - * [.fromJSON(json)](#JwtPresentationValidationOptions.fromJSON) ⇒ [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) - - - -### new JwtPresentationValidationOptions([options]) -Creates a new [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) from the given fields. - -Throws an error if any of the options are invalid. - - -| Param | Type | -| --- | --- | -| [options] | IJwtPresentationValidationOptions \| undefined | - - - -### jwtPresentationValidationOptions.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) - - -### jwtPresentationValidationOptions.clone() ⇒ [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) -Deep clones the object. - -**Kind**: instance method of [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) - - -### JwtPresentationValidationOptions.fromJSON(json) ⇒ [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) -Deserializes an instance from a JSON object. - -**Kind**: static method of [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) - -| Param | Type | -| --- | --- | -| json | any | - - - -## JwtPresentationValidator -**Kind**: global class - -* [JwtPresentationValidator](#JwtPresentationValidator) - * [new JwtPresentationValidator(signatureVerifier)](#new_JwtPresentationValidator_new) - * _instance_ - * [.validate(presentationJwt, holder, validation_options)](#JwtPresentationValidator+validate) ⇒ [DecodedJwtPresentation](#DecodedJwtPresentation) - * _static_ - * [.checkStructure(presentation)](#JwtPresentationValidator.checkStructure) - * [.extractHolder(presentation)](#JwtPresentationValidator.extractHolder) ⇒ [CoreDID](#CoreDID) - - - -### new JwtPresentationValidator(signatureVerifier) -Creates a new [JwtPresentationValidator](#JwtPresentationValidator). If a `signatureVerifier` is provided it will be used when -verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` -algorithm will be used. - - -| Param | Type | -| --- | --- | -| signatureVerifier | IJwsVerifier | - - - -### jwtPresentationValidator.validate(presentationJwt, holder, validation_options) ⇒ [DecodedJwtPresentation](#DecodedJwtPresentation) -Validates a [Presentation](#Presentation) encoded as a [Jwt](#Jwt). - -The following properties are validated according to `options`: -- the JWT can be decoded into a semantically valid presentation. -- the expiration and issuance date contained in the JWT claims. -- the holder's signature. - -Validation is done with respect to the properties set in `options`. - -# Warning - -* This method does NOT validate the constituent credentials and therefore also not the relationship between the -credentials' subjects and the presentation holder. This can be done with [JwtCredentialValidationOptions](#JwtCredentialValidationOptions). -* The lack of an error returned from this method is in of itself not enough to conclude that the presentation can -be trusted. This section contains more information on additional checks that should be carried out before and -after calling this method. - -## The state of the supplied DID Documents. - -The caller must ensure that the DID Documents in `holder` are up-to-date. - -# Errors - -An error is returned whenever a validated condition is not satisfied or when decoding fails. - -**Kind**: instance method of [JwtPresentationValidator](#JwtPresentationValidator) - -| Param | Type | -| --- | --- | -| presentationJwt | [Jwt](#Jwt) | -| holder | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| validation_options | [JwtPresentationValidationOptions](#JwtPresentationValidationOptions) | - - - -### JwtPresentationValidator.checkStructure(presentation) -Validates the semantic structure of the [Presentation](#Presentation). - -**Kind**: static method of [JwtPresentationValidator](#JwtPresentationValidator) - -| Param | Type | -| --- | --- | -| presentation | [Presentation](#Presentation) | - - - -### JwtPresentationValidator.extractHolder(presentation) ⇒ [CoreDID](#CoreDID) -Attempt to extract the holder of the presentation. - -# Errors: -* If deserialization/decoding of the presentation fails. -* If the holder can't be parsed as DIDs. - -**Kind**: static method of [JwtPresentationValidator](#JwtPresentationValidator) - -| Param | Type | -| --- | --- | -| presentation | [Jwt](#Jwt) | - - - -## KeyBindingJWTValidationOptions -Options to declare validation criteria when validating credentials. - -**Kind**: global class - -* [KeyBindingJWTValidationOptions](#KeyBindingJWTValidationOptions) - * [new KeyBindingJWTValidationOptions([options])](#new_KeyBindingJWTValidationOptions_new) - * _instance_ - * [.toJSON()](#KeyBindingJWTValidationOptions+toJSON) ⇒ any - * [.clone()](#KeyBindingJWTValidationOptions+clone) ⇒ [KeyBindingJWTValidationOptions](#KeyBindingJWTValidationOptions) - * _static_ - * [.fromJSON(json)](#KeyBindingJWTValidationOptions.fromJSON) ⇒ [KeyBindingJWTValidationOptions](#KeyBindingJWTValidationOptions) - - - -### new KeyBindingJWTValidationOptions([options]) - -| Param | Type | -| --- | --- | -| [options] | IKeyBindingJWTValidationOptions \| undefined | - - - -### keyBindingJWTValidationOptions.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [KeyBindingJWTValidationOptions](#KeyBindingJWTValidationOptions) - - -### keyBindingJWTValidationOptions.clone() ⇒ [KeyBindingJWTValidationOptions](#KeyBindingJWTValidationOptions) -Deep clones the object. - -**Kind**: instance method of [KeyBindingJWTValidationOptions](#KeyBindingJWTValidationOptions) - - -### KeyBindingJWTValidationOptions.fromJSON(json) ⇒ [KeyBindingJWTValidationOptions](#KeyBindingJWTValidationOptions) -Deserializes an instance from a JSON object. - -**Kind**: static method of [KeyBindingJWTValidationOptions](#KeyBindingJWTValidationOptions) - -| Param | Type | -| --- | --- | -| json | any | - - - -## KeyBindingJwtClaims -Claims set for key binding JWT. - -**Kind**: global class - -* [KeyBindingJwtClaims](#KeyBindingJwtClaims) - * [new KeyBindingJwtClaims(jwt, disclosures, nonce, aud, [issued_at], [custom_properties])](#new_KeyBindingJwtClaims_new) - * _instance_ - * [.toString()](#KeyBindingJwtClaims+toString) ⇒ string - * [.iat()](#KeyBindingJwtClaims+iat) ⇒ bigint - * [.aud()](#KeyBindingJwtClaims+aud) ⇒ string - * [.nonce()](#KeyBindingJwtClaims+nonce) ⇒ string - * [.sdHash()](#KeyBindingJwtClaims+sdHash) ⇒ string - * [.customProperties()](#KeyBindingJwtClaims+customProperties) ⇒ Record.<string, any> - * [.toJSON()](#KeyBindingJwtClaims+toJSON) ⇒ any - * [.clone()](#KeyBindingJwtClaims+clone) ⇒ [KeyBindingJwtClaims](#KeyBindingJwtClaims) - * _static_ - * [.keyBindingJwtHeaderTyp()](#KeyBindingJwtClaims.keyBindingJwtHeaderTyp) ⇒ string - * [.fromJSON(json)](#KeyBindingJwtClaims.fromJSON) ⇒ [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - - -### new KeyBindingJwtClaims(jwt, disclosures, nonce, aud, [issued_at], [custom_properties]) -Creates a new [`KeyBindingJwtClaims`]. -When `issued_at` is left as None, it will automatically default to the current time. - -# Error -When `issued_at` is set to `None` and the system returns time earlier than `SystemTime::UNIX_EPOCH`. - - -| Param | Type | -| --- | --- | -| jwt | string | -| disclosures | Array.<string> | -| nonce | string | -| aud | string | -| [issued_at] | [Timestamp](#Timestamp) \| undefined | -| [custom_properties] | Record.<string, any> \| undefined | - - - -### keyBindingJwtClaims.toString() ⇒ string -Returns a string representation of the claims. - -**Kind**: instance method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - -### keyBindingJwtClaims.iat() ⇒ bigint -Returns a copy of the issued at `iat` property. - -**Kind**: instance method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - -### keyBindingJwtClaims.aud() ⇒ string -Returns a copy of the audience `aud` property. - -**Kind**: instance method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - -### keyBindingJwtClaims.nonce() ⇒ string -Returns a copy of the `nonce` property. - -**Kind**: instance method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - -### keyBindingJwtClaims.sdHash() ⇒ string -Returns a copy of the `sd_hash` property. - -**Kind**: instance method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - -### keyBindingJwtClaims.customProperties() ⇒ Record.<string, any> -Returns a copy of the custom properties. - -**Kind**: instance method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - -### keyBindingJwtClaims.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - -### keyBindingJwtClaims.clone() ⇒ [KeyBindingJwtClaims](#KeyBindingJwtClaims) -Deep clones the object. - -**Kind**: instance method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - -### KeyBindingJwtClaims.keyBindingJwtHeaderTyp() ⇒ string -Returns the value of the `typ` property of the JWT header according to -https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-key-binding-jwt - -**Kind**: static method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - -### KeyBindingJwtClaims.fromJSON(json) ⇒ [KeyBindingJwtClaims](#KeyBindingJwtClaims) -Deserializes an instance from a JSON object. - -**Kind**: static method of [KeyBindingJwtClaims](#KeyBindingJwtClaims) - -| Param | Type | -| --- | --- | -| json | any | - - - -## LinkedDomainService -**Kind**: global class - -* [LinkedDomainService](#LinkedDomainService) - * [new LinkedDomainService(options)](#new_LinkedDomainService_new) - * _instance_ - * [.domains()](#LinkedDomainService+domains) ⇒ Array.<string> - * [.toService()](#LinkedDomainService+toService) ⇒ [Service](#Service) - * [.clone()](#LinkedDomainService+clone) ⇒ [LinkedDomainService](#LinkedDomainService) - * _static_ - * [.fromService(service)](#LinkedDomainService.fromService) ⇒ [LinkedDomainService](#LinkedDomainService) - * [.isValid(service)](#LinkedDomainService.isValid) ⇒ boolean - - - -### new LinkedDomainService(options) -Constructs a new [LinkedDomainService](#LinkedDomainService) that wraps a spec compliant [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint). - -Domain URLs must include the `https` scheme in order to pass the domain linkage validation. - - -| Param | Type | -| --- | --- | -| options | ILinkedDomainService | - - - -### linkedDomainService.domains() ⇒ Array.<string> -Returns the domains contained in the Linked Domain Service. - -**Kind**: instance method of [LinkedDomainService](#LinkedDomainService) - - -### linkedDomainService.toService() ⇒ [Service](#Service) -Returns the inner service which can be added to a DID Document. - -**Kind**: instance method of [LinkedDomainService](#LinkedDomainService) - - -### linkedDomainService.clone() ⇒ [LinkedDomainService](#LinkedDomainService) -Deep clones the object. - -**Kind**: instance method of [LinkedDomainService](#LinkedDomainService) - - -### LinkedDomainService.fromService(service) ⇒ [LinkedDomainService](#LinkedDomainService) -Creates a new [LinkedDomainService](#LinkedDomainService) from a [Service](#Service). - -# Error - -Errors if `service` is not a valid Linked Domain Service. - -**Kind**: static method of [LinkedDomainService](#LinkedDomainService) - -| Param | Type | -| --- | --- | -| service | [Service](#Service) | - - - -### LinkedDomainService.isValid(service) ⇒ boolean -Returns `true` if a [Service](#Service) is a valid Linked Domain Service. - -**Kind**: static method of [LinkedDomainService](#LinkedDomainService) - -| Param | Type | -| --- | --- | -| service | [Service](#Service) | - - - -## MethodData -Supported verification method data formats. - -**Kind**: global class - -* [MethodData](#MethodData) - * _instance_ - * [.tryCustom()](#MethodData+tryCustom) ⇒ [CustomMethodData](#CustomMethodData) - * [.tryDecode()](#MethodData+tryDecode) ⇒ Uint8Array - * [.tryPublicKeyJwk()](#MethodData+tryPublicKeyJwk) ⇒ [Jwk](#Jwk) - * [.toJSON()](#MethodData+toJSON) ⇒ any - * [.clone()](#MethodData+clone) ⇒ [MethodData](#MethodData) - * _static_ - * [.newBase58(data)](#MethodData.newBase58) ⇒ [MethodData](#MethodData) - * [.newMultibase(data)](#MethodData.newMultibase) ⇒ [MethodData](#MethodData) - * [.newJwk(key)](#MethodData.newJwk) ⇒ [MethodData](#MethodData) - * [.newCustom(name, data)](#MethodData.newCustom) ⇒ [MethodData](#MethodData) - * [.fromJSON(json)](#MethodData.fromJSON) ⇒ [MethodData](#MethodData) - - - -### methodData.tryCustom() ⇒ [CustomMethodData](#CustomMethodData) -Returns the wrapped custom method data format is `Custom`. - -**Kind**: instance method of [MethodData](#MethodData) - - -### methodData.tryDecode() ⇒ Uint8Array -Returns a `Uint8Array` containing the decoded bytes of the [MethodData](#MethodData). - -This is generally a public key identified by a [MethodData](#MethodData) value. - -### Errors -Decoding can fail if [MethodData](#MethodData) has invalid content or cannot be -represented as a vector of bytes. - -**Kind**: instance method of [MethodData](#MethodData) - - -### methodData.tryPublicKeyJwk() ⇒ [Jwk](#Jwk) -Returns the wrapped [Jwk](#Jwk) if the format is `PublicKeyJwk`. - -**Kind**: instance method of [MethodData](#MethodData) - - -### methodData.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [MethodData](#MethodData) - - -### methodData.clone() ⇒ [MethodData](#MethodData) -Deep clones the object. - -**Kind**: instance method of [MethodData](#MethodData) - - -### MethodData.newBase58(data) ⇒ [MethodData](#MethodData) -Creates a new [MethodData](#MethodData) variant with Base58-BTC encoded content. - -**Kind**: static method of [MethodData](#MethodData) - -| Param | Type | -| --- | --- | -| data | Uint8Array | - - - -### MethodData.newMultibase(data) ⇒ [MethodData](#MethodData) -Creates a new [MethodData](#MethodData) variant with Multibase-encoded content. - -**Kind**: static method of [MethodData](#MethodData) - -| Param | Type | -| --- | --- | -| data | Uint8Array | - - - -### MethodData.newJwk(key) ⇒ [MethodData](#MethodData) -Creates a new [MethodData](#MethodData) variant consisting of the given `key`. - -### Errors -An error is thrown if the given `key` contains any private components. - -**Kind**: static method of [MethodData](#MethodData) - -| Param | Type | -| --- | --- | -| key | [Jwk](#Jwk) | - - - -### MethodData.newCustom(name, data) ⇒ [MethodData](#MethodData) -Creates a new custom [MethodData](#MethodData). - -**Kind**: static method of [MethodData](#MethodData) - -| Param | Type | -| --- | --- | -| name | string | -| data | any | - - - -### MethodData.fromJSON(json) ⇒ [MethodData](#MethodData) -Deserializes an instance from a JSON object. - -**Kind**: static method of [MethodData](#MethodData) - -| Param | Type | -| --- | --- | -| json | any | - - - -## MethodDigest -Unique identifier of a [VerificationMethod](#VerificationMethod). - -NOTE: -This class does not have a JSON representation, -use the methods `pack` and `unpack` instead. - -**Kind**: global class - -* [MethodDigest](#MethodDigest) - * [new MethodDigest(verification_method)](#new_MethodDigest_new) - * _instance_ - * [.pack()](#MethodDigest+pack) ⇒ Uint8Array - * [.clone()](#MethodDigest+clone) ⇒ [MethodDigest](#MethodDigest) - * _static_ - * [.unpack(bytes)](#MethodDigest.unpack) ⇒ [MethodDigest](#MethodDigest) - - - -### new MethodDigest(verification_method) - -| Param | Type | -| --- | --- | -| verification_method | [VerificationMethod](#VerificationMethod) | - - - -### methodDigest.pack() ⇒ Uint8Array -Packs [MethodDigest](#MethodDigest) into bytes. - -**Kind**: instance method of [MethodDigest](#MethodDigest) - - -### methodDigest.clone() ⇒ [MethodDigest](#MethodDigest) -Deep clones the object. - -**Kind**: instance method of [MethodDigest](#MethodDigest) - - -### MethodDigest.unpack(bytes) ⇒ [MethodDigest](#MethodDigest) -Unpacks bytes into [MethodDigest](#MethodDigest). - -**Kind**: static method of [MethodDigest](#MethodDigest) - -| Param | Type | -| --- | --- | -| bytes | Uint8Array | - - - -## MethodScope -Supported verification method types. - -**Kind**: global class - -* [MethodScope](#MethodScope) - * _instance_ - * [.toString()](#MethodScope+toString) ⇒ string - * [.toJSON()](#MethodScope+toJSON) ⇒ any - * [.clone()](#MethodScope+clone) ⇒ [MethodScope](#MethodScope) - * _static_ - * [.VerificationMethod()](#MethodScope.VerificationMethod) ⇒ [MethodScope](#MethodScope) - * [.Authentication()](#MethodScope.Authentication) ⇒ [MethodScope](#MethodScope) - * [.AssertionMethod()](#MethodScope.AssertionMethod) ⇒ [MethodScope](#MethodScope) - * [.KeyAgreement()](#MethodScope.KeyAgreement) ⇒ [MethodScope](#MethodScope) - * [.CapabilityDelegation()](#MethodScope.CapabilityDelegation) ⇒ [MethodScope](#MethodScope) - * [.CapabilityInvocation()](#MethodScope.CapabilityInvocation) ⇒ [MethodScope](#MethodScope) - * [.fromJSON(json)](#MethodScope.fromJSON) ⇒ [MethodScope](#MethodScope) - - - -### methodScope.toString() ⇒ string -Returns the [MethodScope](#MethodScope) as a string. - -**Kind**: instance method of [MethodScope](#MethodScope) - - -### methodScope.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [MethodScope](#MethodScope) - - -### methodScope.clone() ⇒ [MethodScope](#MethodScope) -Deep clones the object. - -**Kind**: instance method of [MethodScope](#MethodScope) - - -### MethodScope.VerificationMethod() ⇒ [MethodScope](#MethodScope) -**Kind**: static method of [MethodScope](#MethodScope) - - -### MethodScope.Authentication() ⇒ [MethodScope](#MethodScope) -**Kind**: static method of [MethodScope](#MethodScope) - - -### MethodScope.AssertionMethod() ⇒ [MethodScope](#MethodScope) -**Kind**: static method of [MethodScope](#MethodScope) - - -### MethodScope.KeyAgreement() ⇒ [MethodScope](#MethodScope) -**Kind**: static method of [MethodScope](#MethodScope) - - -### MethodScope.CapabilityDelegation() ⇒ [MethodScope](#MethodScope) -**Kind**: static method of [MethodScope](#MethodScope) - - -### MethodScope.CapabilityInvocation() ⇒ [MethodScope](#MethodScope) -**Kind**: static method of [MethodScope](#MethodScope) - - -### MethodScope.fromJSON(json) ⇒ [MethodScope](#MethodScope) -Deserializes an instance from a JSON object. - -**Kind**: static method of [MethodScope](#MethodScope) - -| Param | Type | -| --- | --- | -| json | any | - - - -## MethodType -Supported verification method types. - -**Kind**: global class - -* [MethodType](#MethodType) - * _instance_ - * [.toString()](#MethodType+toString) ⇒ string - * [.toJSON()](#MethodType+toJSON) ⇒ any - * [.clone()](#MethodType+clone) ⇒ [MethodType](#MethodType) - * _static_ - * [.Ed25519VerificationKey2018()](#MethodType.Ed25519VerificationKey2018) ⇒ [MethodType](#MethodType) - * [.X25519KeyAgreementKey2019()](#MethodType.X25519KeyAgreementKey2019) ⇒ [MethodType](#MethodType) - * [.JsonWebKey()](#MethodType.JsonWebKey) ⇒ [MethodType](#MethodType) - * [.custom(type_)](#MethodType.custom) ⇒ [MethodType](#MethodType) - * [.fromJSON(json)](#MethodType.fromJSON) ⇒ [MethodType](#MethodType) - - - -### methodType.toString() ⇒ string -Returns the [MethodType](#MethodType) as a string. - -**Kind**: instance method of [MethodType](#MethodType) - - -### methodType.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [MethodType](#MethodType) - - -### methodType.clone() ⇒ [MethodType](#MethodType) -Deep clones the object. - -**Kind**: instance method of [MethodType](#MethodType) - - -### MethodType.Ed25519VerificationKey2018() ⇒ [MethodType](#MethodType) -**Kind**: static method of [MethodType](#MethodType) - - -### MethodType.X25519KeyAgreementKey2019() ⇒ [MethodType](#MethodType) -**Kind**: static method of [MethodType](#MethodType) - - -### MethodType.JsonWebKey() ⇒ [MethodType](#MethodType) -A verification method for use with JWT verification as prescribed by the [Jwk](#Jwk) -in the `publicKeyJwk` entry. - -**Kind**: static method of [MethodType](#MethodType) - - -### MethodType.custom(type_) ⇒ [MethodType](#MethodType) -A custom method. - -**Kind**: static method of [MethodType](#MethodType) - -| Param | Type | -| --- | --- | -| type_ | string | - - - -### MethodType.fromJSON(json) ⇒ [MethodType](#MethodType) -Deserializes an instance from a JSON object. - -**Kind**: static method of [MethodType](#MethodType) - -| Param | Type | -| --- | --- | -| json | any | - - - -## PayloadEntry -**Kind**: global class - -* [PayloadEntry](#PayloadEntry) - * [.1](#PayloadEntry+1) ⇒ [PayloadType](#PayloadType) - * [.1](#PayloadEntry+1) - * [.value](#PayloadEntry+value) - * [.value](#PayloadEntry+value) ⇒ any - - - -### payloadEntry.1 ⇒ [PayloadType](#PayloadType) -**Kind**: instance property of [PayloadEntry](#PayloadEntry) - - -### payloadEntry.1 -**Kind**: instance property of [PayloadEntry](#PayloadEntry) - -| Param | Type | -| --- | --- | -| arg0 | [PayloadType](#PayloadType) | - - - -### payloadEntry.value -**Kind**: instance property of [PayloadEntry](#PayloadEntry) - -| Param | Type | -| --- | --- | -| value | any | - - - -### payloadEntry.value ⇒ any -**Kind**: instance property of [PayloadEntry](#PayloadEntry) - - -## Payloads -**Kind**: global class - -* [Payloads](#Payloads) - * [new Payloads(entries)](#new_Payloads_new) - * _instance_ - * [.toJSON()](#Payloads+toJSON) ⇒ any - * [.clone()](#Payloads+clone) ⇒ [Payloads](#Payloads) - * [.getValues()](#Payloads+getValues) ⇒ Array.<any> - * [.getUndisclosedIndexes()](#Payloads+getUndisclosedIndexes) ⇒ Uint32Array - * [.getDisclosedIndexes()](#Payloads+getDisclosedIndexes) ⇒ Uint32Array - * [.getUndisclosedPayloads()](#Payloads+getUndisclosedPayloads) ⇒ Array.<any> - * [.getDisclosedPayloads()](#Payloads+getDisclosedPayloads) ⇒ [Payloads](#Payloads) - * [.setUndisclosed(index)](#Payloads+setUndisclosed) - * [.replacePayloadAtIndex(index, value)](#Payloads+replacePayloadAtIndex) ⇒ any - * _static_ - * [.fromJSON(json)](#Payloads.fromJSON) ⇒ [Payloads](#Payloads) - * [.newFromValues(values)](#Payloads.newFromValues) ⇒ [Payloads](#Payloads) - - - -### new Payloads(entries) - -| Param | Type | -| --- | --- | -| entries | [Array.<PayloadEntry>](#PayloadEntry) | - - - -### payloads.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Payloads](#Payloads) - - -### payloads.clone() ⇒ [Payloads](#Payloads) -Deep clones the object. - -**Kind**: instance method of [Payloads](#Payloads) - - -### payloads.getValues() ⇒ Array.<any> -**Kind**: instance method of [Payloads](#Payloads) - - -### payloads.getUndisclosedIndexes() ⇒ Uint32Array -**Kind**: instance method of [Payloads](#Payloads) - - -### payloads.getDisclosedIndexes() ⇒ Uint32Array -**Kind**: instance method of [Payloads](#Payloads) - - -### payloads.getUndisclosedPayloads() ⇒ Array.<any> -**Kind**: instance method of [Payloads](#Payloads) - - -### payloads.getDisclosedPayloads() ⇒ [Payloads](#Payloads) -**Kind**: instance method of [Payloads](#Payloads) - - -### payloads.setUndisclosed(index) -**Kind**: instance method of [Payloads](#Payloads) - -| Param | Type | -| --- | --- | -| index | number | - - - -### payloads.replacePayloadAtIndex(index, value) ⇒ any -**Kind**: instance method of [Payloads](#Payloads) - -| Param | Type | -| --- | --- | -| index | number | -| value | any | - - - -### Payloads.fromJSON(json) ⇒ [Payloads](#Payloads) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Payloads](#Payloads) - -| Param | Type | -| --- | --- | -| json | any | - - - -### Payloads.newFromValues(values) ⇒ [Payloads](#Payloads) -**Kind**: static method of [Payloads](#Payloads) - -| Param | Type | -| --- | --- | -| values | Array.<any> | - - - -## Presentation -**Kind**: global class - -* [Presentation](#Presentation) - * [new Presentation(values)](#new_Presentation_new) - * _instance_ - * [.context()](#Presentation+context) ⇒ Array.<(string\|Record.<string, any>)> - * [.id()](#Presentation+id) ⇒ string \| undefined - * [.type()](#Presentation+type) ⇒ Array.<string> - * [.verifiableCredential()](#Presentation+verifiableCredential) ⇒ [Array.<UnknownCredential>](#UnknownCredential) - * [.holder()](#Presentation+holder) ⇒ string - * [.refreshService()](#Presentation+refreshService) ⇒ Array.<RefreshService> - * [.termsOfUse()](#Presentation+termsOfUse) ⇒ Array.<Policy> - * [.proof()](#Presentation+proof) ⇒ [Proof](#Proof) \| undefined - * [.setProof([proof])](#Presentation+setProof) - * [.properties()](#Presentation+properties) ⇒ Map.<string, any> - * [.toJSON()](#Presentation+toJSON) ⇒ any - * [.clone()](#Presentation+clone) ⇒ [Presentation](#Presentation) - * _static_ - * [.BaseContext()](#Presentation.BaseContext) ⇒ string - * [.BaseType()](#Presentation.BaseType) ⇒ string - * [.fromJSON(json)](#Presentation.fromJSON) ⇒ [Presentation](#Presentation) - - - -### new Presentation(values) -Constructs a new presentation. - - -| Param | Type | -| --- | --- | -| values | IPresentation | - - - -### presentation.context() ⇒ Array.<(string\|Record.<string, any>)> -Returns a copy of the JSON-LD context(s) applicable to the presentation. - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.id() ⇒ string \| undefined -Returns a copy of the unique `URI` identifying the presentation. - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.type() ⇒ Array.<string> -Returns a copy of the URIs defining the type of the presentation. - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.verifiableCredential() ⇒ [Array.<UnknownCredential>](#UnknownCredential) -Returns the JWT credentials expressing the claims of the presentation. - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.holder() ⇒ string -Returns a copy of the URI of the entity that generated the presentation. - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.refreshService() ⇒ Array.<RefreshService> -Returns a copy of the service(s) used to refresh an expired [Credential](#Credential) in the presentation. - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.termsOfUse() ⇒ Array.<Policy> -Returns a copy of the terms-of-use specified by the presentation holder - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.proof() ⇒ [Proof](#Proof) \| undefined -Optional cryptographic proof, unrelated to JWT. - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.setProof([proof]) -Sets the proof property of the [Presentation](#Presentation). - -Note that this proof is not related to JWT. - -**Kind**: instance method of [Presentation](#Presentation) - -| Param | Type | -| --- | --- | -| [proof] | [Proof](#Proof) \| undefined | - - - -### presentation.properties() ⇒ Map.<string, any> -Returns a copy of the miscellaneous properties on the presentation. - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Presentation](#Presentation) - - -### presentation.clone() ⇒ [Presentation](#Presentation) -Deep clones the object. - -**Kind**: instance method of [Presentation](#Presentation) - - -### Presentation.BaseContext() ⇒ string -Returns the base JSON-LD context. - -**Kind**: static method of [Presentation](#Presentation) - - -### Presentation.BaseType() ⇒ string -Returns the base type. - -**Kind**: static method of [Presentation](#Presentation) - - -### Presentation.fromJSON(json) ⇒ [Presentation](#Presentation) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Presentation](#Presentation) - -| Param | Type | -| --- | --- | -| json | any | - - - -## PresentationProtectedHeader -**Kind**: global class - -* [PresentationProtectedHeader](#PresentationProtectedHeader) - * [.alg](#PresentationProtectedHeader+alg) ⇒ [PresentationProofAlgorithm](#PresentationProofAlgorithm) - * [.alg](#PresentationProtectedHeader+alg) - * [.kid](#PresentationProtectedHeader+kid) ⇒ string \| undefined - * [.kid](#PresentationProtectedHeader+kid) - * [.aud](#PresentationProtectedHeader+aud) ⇒ string \| undefined - * [.aud](#PresentationProtectedHeader+aud) - * [.nonce](#PresentationProtectedHeader+nonce) ⇒ string \| undefined - * [.nonce](#PresentationProtectedHeader+nonce) - - - -### presentationProtectedHeader.alg ⇒ [PresentationProofAlgorithm](#PresentationProofAlgorithm) -**Kind**: instance property of [PresentationProtectedHeader](#PresentationProtectedHeader) - - -### presentationProtectedHeader.alg -**Kind**: instance property of [PresentationProtectedHeader](#PresentationProtectedHeader) - -| Param | Type | -| --- | --- | -| arg0 | [PresentationProofAlgorithm](#PresentationProofAlgorithm) | - - - -### presentationProtectedHeader.kid ⇒ string \| undefined -ID for the key used for the JWP. - -**Kind**: instance property of [PresentationProtectedHeader](#PresentationProtectedHeader) - - -### presentationProtectedHeader.kid -ID for the key used for the JWP. - -**Kind**: instance property of [PresentationProtectedHeader](#PresentationProtectedHeader) - -| Param | Type | -| --- | --- | -| [arg0] | string \| undefined | - - - -### presentationProtectedHeader.aud ⇒ string \| undefined -Who have received the JPT. - -**Kind**: instance property of [PresentationProtectedHeader](#PresentationProtectedHeader) - - -### presentationProtectedHeader.aud -Who have received the JPT. - -**Kind**: instance property of [PresentationProtectedHeader](#PresentationProtectedHeader) - -| Param | Type | -| --- | --- | -| [arg0] | string \| undefined | - - - -### presentationProtectedHeader.nonce ⇒ string \| undefined -For replay attacks. - -**Kind**: instance property of [PresentationProtectedHeader](#PresentationProtectedHeader) - - -### presentationProtectedHeader.nonce -For replay attacks. - -**Kind**: instance property of [PresentationProtectedHeader](#PresentationProtectedHeader) - -| Param | Type | -| --- | --- | -| [arg0] | string \| undefined | - - - -## Proof -Represents a cryptographic proof that can be used to validate verifiable credentials and -presentations. - -This representation does not inherently implement any standard; instead, it -can be utilized to implement standards or user-defined proofs. The presence of the -`type` field is necessary to accommodate different types of cryptographic proofs. - -Note that this proof is not related to JWT and can be used in combination or as an alternative -to it. - -**Kind**: global class - -* [Proof](#Proof) - * [new Proof(type_, properties)](#new_Proof_new) - * _instance_ - * [.type()](#Proof+type) ⇒ string - * [.properties()](#Proof+properties) ⇒ any - * [.toJSON()](#Proof+toJSON) ⇒ any - * [.clone()](#Proof+clone) ⇒ [Proof](#Proof) - * _static_ - * [.fromJSON(json)](#Proof.fromJSON) ⇒ [Proof](#Proof) - - - -### new Proof(type_, properties) - -| Param | Type | -| --- | --- | -| type_ | string | -| properties | any | - - - -### proof.type() ⇒ string -Returns the type of proof. - -**Kind**: instance method of [Proof](#Proof) - - -### proof.properties() ⇒ any -Returns the properties of the proof. - -**Kind**: instance method of [Proof](#Proof) - - -### proof.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Proof](#Proof) - - -### proof.clone() ⇒ [Proof](#Proof) -Deep clones the object. - -**Kind**: instance method of [Proof](#Proof) - - -### Proof.fromJSON(json) ⇒ [Proof](#Proof) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Proof](#Proof) - -| Param | Type | -| --- | --- | -| json | any | - - - -## ProofUpdateCtx -**Kind**: global class - -* [ProofUpdateCtx](#ProofUpdateCtx) - * [.old_start_validity_timeframe](#ProofUpdateCtx+old_start_validity_timeframe) ⇒ Uint8Array - * [.old_start_validity_timeframe](#ProofUpdateCtx+old_start_validity_timeframe) - * [.new_start_validity_timeframe](#ProofUpdateCtx+new_start_validity_timeframe) ⇒ Uint8Array - * [.new_start_validity_timeframe](#ProofUpdateCtx+new_start_validity_timeframe) - * [.old_end_validity_timeframe](#ProofUpdateCtx+old_end_validity_timeframe) ⇒ Uint8Array - * [.old_end_validity_timeframe](#ProofUpdateCtx+old_end_validity_timeframe) - * [.new_end_validity_timeframe](#ProofUpdateCtx+new_end_validity_timeframe) ⇒ Uint8Array - * [.new_end_validity_timeframe](#ProofUpdateCtx+new_end_validity_timeframe) - * [.index_start_validity_timeframe](#ProofUpdateCtx+index_start_validity_timeframe) ⇒ number - * [.index_start_validity_timeframe](#ProofUpdateCtx+index_start_validity_timeframe) - * [.index_end_validity_timeframe](#ProofUpdateCtx+index_end_validity_timeframe) ⇒ number - * [.index_end_validity_timeframe](#ProofUpdateCtx+index_end_validity_timeframe) - * [.number_of_signed_messages](#ProofUpdateCtx+number_of_signed_messages) ⇒ number - * [.number_of_signed_messages](#ProofUpdateCtx+number_of_signed_messages) - - - -### proofUpdateCtx.old\_start\_validity\_timeframe ⇒ Uint8Array -Old `startValidityTimeframe` value - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - - -### proofUpdateCtx.old\_start\_validity\_timeframe -Old `startValidityTimeframe` value - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - -| Param | Type | -| --- | --- | -| arg0 | Uint8Array | - - - -### proofUpdateCtx.new\_start\_validity\_timeframe ⇒ Uint8Array -New `startValidityTimeframe` value to be signed - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - - -### proofUpdateCtx.new\_start\_validity\_timeframe -New `startValidityTimeframe` value to be signed - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - -| Param | Type | -| --- | --- | -| arg0 | Uint8Array | - - - -### proofUpdateCtx.old\_end\_validity\_timeframe ⇒ Uint8Array -Old `endValidityTimeframe` value - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - - -### proofUpdateCtx.old\_end\_validity\_timeframe -Old `endValidityTimeframe` value - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - -| Param | Type | -| --- | --- | -| arg0 | Uint8Array | - - - -### proofUpdateCtx.new\_end\_validity\_timeframe ⇒ Uint8Array -New `endValidityTimeframe` value to be signed - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - - -### proofUpdateCtx.new\_end\_validity\_timeframe -New `endValidityTimeframe` value to be signed - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - -| Param | Type | -| --- | --- | -| arg0 | Uint8Array | - - - -### proofUpdateCtx.index\_start\_validity\_timeframe ⇒ number -Index of `startValidityTimeframe` claim inside the array of Claims - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - - -### proofUpdateCtx.index\_start\_validity\_timeframe -Index of `startValidityTimeframe` claim inside the array of Claims - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - -| Param | Type | -| --- | --- | -| arg0 | number | - - - -### proofUpdateCtx.index\_end\_validity\_timeframe ⇒ number -Index of `endValidityTimeframe` claim inside the array of Claims - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - - -### proofUpdateCtx.index\_end\_validity\_timeframe -Index of `endValidityTimeframe` claim inside the array of Claims - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - -| Param | Type | -| --- | --- | -| arg0 | number | - - - -### proofUpdateCtx.number\_of\_signed\_messages ⇒ number -Number of signed messages, number of payloads in a JWP - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - - -### proofUpdateCtx.number\_of\_signed\_messages -Number of signed messages, number of payloads in a JWP - -**Kind**: instance property of [ProofUpdateCtx](#ProofUpdateCtx) - -| Param | Type | -| --- | --- | -| arg0 | number | - - - -## Resolver -Convenience type for resolving DID documents from different DID methods. - -Also provides methods for resolving DID Documents associated with -verifiable [Credential](#Credential)s and [Presentation](#Presentation)s. - -# Configuration - -The resolver will only be able to resolve DID documents for methods it has been configured for in the constructor. - -**Kind**: global class - -* [Resolver](#Resolver) - * [new Resolver(config)](#new_Resolver_new) - * [.resolve(did)](#Resolver+resolve) ⇒ Promise.<(CoreDocument\|IToCoreDocument)> - * [.resolveMultiple(dids)](#Resolver+resolveMultiple) ⇒ Promise.<Array.<(CoreDocument\|IToCoreDocument)>> - - - -### new Resolver(config) -Constructs a new [Resolver](#Resolver). - -# Errors -If both a `client` is given and the `handlers` map contains the "iota" key the construction process -will throw an error because the handler for the "iota" method then becomes ambiguous. - - -| Param | Type | -| --- | --- | -| config | ResolverConfig | - - - -### resolver.resolve(did) ⇒ Promise.<(CoreDocument\|IToCoreDocument)> -Fetches the DID Document of the given DID. - -### Errors - -Errors if the resolver has not been configured to handle the method -corresponding to the given DID or the resolution process itself fails. - -**Kind**: instance method of [Resolver](#Resolver) - -| Param | Type | -| --- | --- | -| did | string | - - - -### resolver.resolveMultiple(dids) ⇒ Promise.<Array.<(CoreDocument\|IToCoreDocument)>> -Concurrently fetches the DID Documents of the multiple given DIDs. - -# Errors -* If the resolver has not been configured to handle the method of any of the given DIDs. -* If the resolution process of any DID fails. - -## Note -* The order of the documents in the returned array matches that in `dids`. -* If `dids` contains duplicates, these will be resolved only once and the resolved document -is copied into the returned array to match the order of `dids`. - -**Kind**: instance method of [Resolver](#Resolver) - -| Param | Type | -| --- | --- | -| dids | Array.<string> | - - - -## RevocationBitmap -A compressed bitmap for managing credential revocation. - -**Kind**: global class - -* [RevocationBitmap](#RevocationBitmap) - * [new RevocationBitmap()](#new_RevocationBitmap_new) - * _instance_ - * [.isRevoked(index)](#RevocationBitmap+isRevoked) ⇒ boolean - * [.revoke(index)](#RevocationBitmap+revoke) ⇒ boolean - * [.unrevoke(index)](#RevocationBitmap+unrevoke) ⇒ boolean - * [.len()](#RevocationBitmap+len) ⇒ number - * [.toService(serviceId)](#RevocationBitmap+toService) ⇒ [Service](#Service) - * _static_ - * [.type()](#RevocationBitmap.type) ⇒ string - * [.fromEndpoint(service)](#RevocationBitmap.fromEndpoint) ⇒ [RevocationBitmap](#RevocationBitmap) - - - -### new RevocationBitmap() -Creates a new [RevocationBitmap](#RevocationBitmap) instance. - - - -### revocationBitmap.isRevoked(index) ⇒ boolean -Returns `true` if the credential at the given `index` is revoked. - -**Kind**: instance method of [RevocationBitmap](#RevocationBitmap) - -| Param | Type | -| --- | --- | -| index | number | - - - -### revocationBitmap.revoke(index) ⇒ boolean -Mark the given index as revoked. - -Returns true if the index was absent from the set. - -**Kind**: instance method of [RevocationBitmap](#RevocationBitmap) - -| Param | Type | -| --- | --- | -| index | number | - - - -### revocationBitmap.unrevoke(index) ⇒ boolean -Mark the index as not revoked. - -Returns true if the index was present in the set. - -**Kind**: instance method of [RevocationBitmap](#RevocationBitmap) - -| Param | Type | -| --- | --- | -| index | number | - - - -### revocationBitmap.len() ⇒ number -Returns the number of revoked credentials. - -**Kind**: instance method of [RevocationBitmap](#RevocationBitmap) - - -### revocationBitmap.toService(serviceId) ⇒ [Service](#Service) -Return a `Service` with: -- the service's id set to `serviceId`, -- of type `RevocationBitmap2022`, -- and with the bitmap embedded in a data url in the service's endpoint. - -**Kind**: instance method of [RevocationBitmap](#RevocationBitmap) - -| Param | Type | -| --- | --- | -| serviceId | [DIDUrl](#DIDUrl) | - - - -### RevocationBitmap.type() ⇒ string -The name of the service type. - -**Kind**: static method of [RevocationBitmap](#RevocationBitmap) - - -### RevocationBitmap.fromEndpoint(service) ⇒ [RevocationBitmap](#RevocationBitmap) -Try to construct a [RevocationBitmap](#RevocationBitmap) from a service -if it is a valid Revocation Bitmap Service. - -**Kind**: static method of [RevocationBitmap](#RevocationBitmap) - -| Param | Type | -| --- | --- | -| service | [Service](#Service) | - - - -## RevocationTimeframeStatus -Information used to determine the current status of a [Credential](#Credential). - -**Kind**: global class - -* [RevocationTimeframeStatus](#RevocationTimeframeStatus) - * [new RevocationTimeframeStatus(id, index, duration, [start_validity])](#new_RevocationTimeframeStatus_new) - * _instance_ - * [.clone()](#RevocationTimeframeStatus+clone) ⇒ [RevocationTimeframeStatus](#RevocationTimeframeStatus) - * [.toJSON()](#RevocationTimeframeStatus+toJSON) ⇒ any - * [.startValidityTimeframe()](#RevocationTimeframeStatus+startValidityTimeframe) ⇒ [Timestamp](#Timestamp) - * [.endValidityTimeframe()](#RevocationTimeframeStatus+endValidityTimeframe) ⇒ [Timestamp](#Timestamp) - * [.id()](#RevocationTimeframeStatus+id) ⇒ string - * [.index()](#RevocationTimeframeStatus+index) ⇒ number \| undefined - * _static_ - * [.fromJSON(json)](#RevocationTimeframeStatus.fromJSON) ⇒ [RevocationTimeframeStatus](#RevocationTimeframeStatus) - - - -### new RevocationTimeframeStatus(id, index, duration, [start_validity]) -Creates a new `RevocationTimeframeStatus`. - - -| Param | Type | -| --- | --- | -| id | string | -| index | number | -| duration | [Duration](#Duration) | -| [start_validity] | [Timestamp](#Timestamp) \| undefined | - - - -### revocationTimeframeStatus.clone() ⇒ [RevocationTimeframeStatus](#RevocationTimeframeStatus) -Deep clones the object. - -**Kind**: instance method of [RevocationTimeframeStatus](#RevocationTimeframeStatus) - - -### revocationTimeframeStatus.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [RevocationTimeframeStatus](#RevocationTimeframeStatus) - - -### revocationTimeframeStatus.startValidityTimeframe() ⇒ [Timestamp](#Timestamp) -Get startValidityTimeframe value. - -**Kind**: instance method of [RevocationTimeframeStatus](#RevocationTimeframeStatus) - - -### revocationTimeframeStatus.endValidityTimeframe() ⇒ [Timestamp](#Timestamp) -Get endValidityTimeframe value. - -**Kind**: instance method of [RevocationTimeframeStatus](#RevocationTimeframeStatus) - - -### revocationTimeframeStatus.id() ⇒ string -Return the URL fo the `RevocationBitmapStatus`. - -**Kind**: instance method of [RevocationTimeframeStatus](#RevocationTimeframeStatus) - - -### revocationTimeframeStatus.index() ⇒ number \| undefined -Return the index of the credential in the issuer's revocation bitmap - -**Kind**: instance method of [RevocationTimeframeStatus](#RevocationTimeframeStatus) - - -### RevocationTimeframeStatus.fromJSON(json) ⇒ [RevocationTimeframeStatus](#RevocationTimeframeStatus) -Deserializes an instance from a JSON object. - -**Kind**: static method of [RevocationTimeframeStatus](#RevocationTimeframeStatus) - -| Param | Type | -| --- | --- | -| json | any | - - - -## SdJwt -Representation of an SD-JWT of the format -`~~~...~~`. - -**Kind**: global class - -* [SdJwt](#SdJwt) - * [new SdJwt(jwt, disclosures, [key_binding_jwt])](#new_SdJwt_new) - * _instance_ - * [.presentation()](#SdJwt+presentation) ⇒ string - * [.toString()](#SdJwt+toString) ⇒ string - * [.jwt()](#SdJwt+jwt) ⇒ string - * [.disclosures()](#SdJwt+disclosures) ⇒ Array.<string> - * [.keyBindingJwt()](#SdJwt+keyBindingJwt) ⇒ string \| undefined - * [.clone()](#SdJwt+clone) ⇒ [SdJwt](#SdJwt) - * _static_ - * [.parse(sd_jwt)](#SdJwt.parse) ⇒ [SdJwt](#SdJwt) - - - -### new SdJwt(jwt, disclosures, [key_binding_jwt]) -Creates a new `SdJwt` from its components. - - -| Param | Type | -| --- | --- | -| jwt | string | -| disclosures | Array.<string> | -| [key_binding_jwt] | string \| undefined | - - - -### sdJwt.presentation() ⇒ string -Serializes the components into the final SD-JWT. - -**Kind**: instance method of [SdJwt](#SdJwt) - - -### sdJwt.toString() ⇒ string -Serializes the components into the final SD-JWT. - -**Kind**: instance method of [SdJwt](#SdJwt) - - -### sdJwt.jwt() ⇒ string -The JWT part. - -**Kind**: instance method of [SdJwt](#SdJwt) - - -### sdJwt.disclosures() ⇒ Array.<string> -The disclosures part. - -**Kind**: instance method of [SdJwt](#SdJwt) - - -### sdJwt.keyBindingJwt() ⇒ string \| undefined -The optional key binding JWT. - -**Kind**: instance method of [SdJwt](#SdJwt) - - -### sdJwt.clone() ⇒ [SdJwt](#SdJwt) -Deep clones the object. - -**Kind**: instance method of [SdJwt](#SdJwt) - - -### SdJwt.parse(sd_jwt) ⇒ [SdJwt](#SdJwt) -Parses an SD-JWT into its components as [`SdJwt`]. - -## Error -Returns `DeserializationError` if parsing fails. - -**Kind**: static method of [SdJwt](#SdJwt) - -| Param | Type | -| --- | --- | -| sd_jwt | string | - - - -## SdJwtCredentialValidator -A type for decoding and validating [Credential](#Credential). - -**Kind**: global class - -* [SdJwtCredentialValidator](#SdJwtCredentialValidator) - * [new SdJwtCredentialValidator(signatureVerifier)](#new_SdJwtCredentialValidator_new) - * [.validateCredential(sd_jwt, issuer, options, fail_fast)](#SdJwtCredentialValidator+validateCredential) ⇒ [DecodedJwtCredential](#DecodedJwtCredential) - * [.verifySignature(credential, trustedIssuers, options)](#SdJwtCredentialValidator+verifySignature) ⇒ [DecodedJwtCredential](#DecodedJwtCredential) - * [.validateKeyBindingJwt(sdJwt, holder, options)](#SdJwtCredentialValidator+validateKeyBindingJwt) ⇒ [KeyBindingJwtClaims](#KeyBindingJwtClaims) - - - -### new SdJwtCredentialValidator(signatureVerifier) -Creates a new `SdJwtCredentialValidator`. If a `signatureVerifier` is provided it will be used when -verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` -algorithm will be used. - - -| Param | Type | -| --- | --- | -| signatureVerifier | IJwsVerifier | - - - -### sdJwtCredentialValidator.validateCredential(sd_jwt, issuer, options, fail_fast) ⇒ [DecodedJwtCredential](#DecodedJwtCredential) -Decodes and validates a `Credential` issued as an SD-JWT. A `DecodedJwtCredential` is returned upon success. -The credential is constructed by replacing disclosures following the -[`Selective Disclosure for JWTs (SD-JWT)`](https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html) standard. - -The following properties are validated according to `options`: -- the issuer's signature on the JWS, -- the expiration date, -- the issuance date, -- the semantic structure. - -# Warning -* The key binding JWT is not validated. If needed, it must be validated separately using -`SdJwtValidator::validate_key_binding_jwt`. -* The lack of an error returned from this method is in of itself not enough to conclude that the credential can be -trusted. This section contains more information on additional checks that should be carried out before and after -calling this method. - -## The state of the issuer's DID Document -The caller must ensure that `issuer` represents an up-to-date DID Document. - -## Properties that are not validated - There are many properties defined in [The Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/) that are **not** validated, such as: -`proof`, `credentialStatus`, `type`, `credentialSchema`, `refreshService` **and more**. -These should be manually checked after validation, according to your requirements. - -# Errors -An error is returned whenever a validated condition is not satisfied. - -**Kind**: instance method of [SdJwtCredentialValidator](#SdJwtCredentialValidator) - -| Param | Type | -| --- | --- | -| sd_jwt | [SdJwt](#SdJwt) | -| issuer | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| options | [JwtCredentialValidationOptions](#JwtCredentialValidationOptions) | -| fail_fast | [FailFast](#FailFast) | - - - -### sdJwtCredentialValidator.verifySignature(credential, trustedIssuers, options) ⇒ [DecodedJwtCredential](#DecodedJwtCredential) -Decode and verify the JWS signature of a `Credential` issued as an SD-JWT using the DID Document of a trusted -issuer and replaces the disclosures. - -A `DecodedJwtCredential` is returned upon success. - -# Warning -The caller must ensure that the DID Documents of the trusted issuers are up-to-date. - -## Proofs - Only the JWS signature is verified. If the `Credential` contains a `proof` property this will not be verified -by this method. - -# Errors -* If the issuer' URL cannot be parsed. -* If Signature verification fails. -* If SD decoding fails. - -**Kind**: instance method of [SdJwtCredentialValidator](#SdJwtCredentialValidator) - -| Param | Type | -| --- | --- | -| credential | [SdJwt](#SdJwt) | -| trustedIssuers | Array.<(CoreDocument\|IToCoreDocument)> | -| options | [JwsVerificationOptions](#JwsVerificationOptions) | - - - -### sdJwtCredentialValidator.validateKeyBindingJwt(sdJwt, holder, options) ⇒ [KeyBindingJwtClaims](#KeyBindingJwtClaims) -Validates a Key Binding JWT (KB-JWT) according to `https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-key-binding-jwt`. -The Validation process includes: - * Signature validation using public key materials defined in the `holder` document. - * `typ` value in KB-JWT header. - * `sd_hash` claim value in the KB-JWT claim. - * Optional `nonce`, `aud` and issuance date validation. - -**Kind**: instance method of [SdJwtCredentialValidator](#SdJwtCredentialValidator) - -| Param | Type | -| --- | --- | -| sdJwt | [SdJwt](#SdJwt) | -| holder | [CoreDocument](#CoreDocument) \| IToCoreDocument | -| options | [KeyBindingJWTValidationOptions](#KeyBindingJWTValidationOptions) | - - - -## SdObjectDecoder -Substitutes digests in an SD-JWT object by their corresponding plaintext values provided by disclosures. - -**Kind**: global class - -* [SdObjectDecoder](#SdObjectDecoder) - * [new SdObjectDecoder()](#new_SdObjectDecoder_new) - * [.decode(object, disclosures)](#SdObjectDecoder+decode) ⇒ Record.<string, any> - - - -### new SdObjectDecoder() -Creates a new `SdObjectDecoder` with `sha-256` hasher. - - - -### sdObjectDecoder.decode(object, disclosures) ⇒ Record.<string, any> -Decodes an SD-JWT `object` containing by Substituting the digests with their corresponding -plaintext values provided by `disclosures`. - -## Notes -* Claims like `exp` or `iat` are not validated in the process of decoding. -* `_sd_alg` property will be removed if present. - -**Kind**: instance method of [SdObjectDecoder](#SdObjectDecoder) - -| Param | Type | -| --- | --- | -| object | Record.<string, any> | -| disclosures | Array.<string> | - - - -## SdObjectEncoder -Transforms a JSON object into an SD-JWT object by substituting selected values -with their corresponding disclosure digests. - -Note: digests are created using the sha-256 algorithm. - -**Kind**: global class - -* [SdObjectEncoder](#SdObjectEncoder) - * [new SdObjectEncoder(object)](#new_SdObjectEncoder_new) - * [.conceal(path, [salt])](#SdObjectEncoder+conceal) ⇒ [Disclosure](#Disclosure) - * [.addSdAlgProperty()](#SdObjectEncoder+addSdAlgProperty) - * [.encodeToString()](#SdObjectEncoder+encodeToString) ⇒ string - * [.toString()](#SdObjectEncoder+toString) ⇒ string - * [.encodeToObject()](#SdObjectEncoder+encodeToObject) ⇒ Record.<string, any> - * [.toJSON()](#SdObjectEncoder+toJSON) ⇒ any - * [.addDecoys(path, number_of_decoys)](#SdObjectEncoder+addDecoys) - - - -### new SdObjectEncoder(object) -Creates a new `SdObjectEncoder` with `sha-256` hash function. - - -| Param | Type | -| --- | --- | -| object | any | - - - -### sdObjectEncoder.conceal(path, [salt]) ⇒ [Disclosure](#Disclosure) -Substitutes a value with the digest of its disclosure. -If no salt is provided, the disclosure will be created with a random salt value. - -`path` indicates the pointer to the value that will be concealed using the syntax of -[JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901). - -For the following object: - - ``` -{ - "id": "did:value", - "claim1": { - "abc": true - }, - "claim2": ["val_1", "val_2"] -} -``` - -Path "/id" conceals `"id": "did:value"` -Path "/claim1/abc" conceals `"abc": true` -Path "/claim2/0" conceals `val_1` -``` - -## Errors -* `InvalidPath` if pointer is invalid. -* `DataTypeMismatch` if existing SD format is invalid. - -**Kind**: instance method of [SdObjectEncoder](#SdObjectEncoder) - -| Param | Type | -| --- | --- | -| path | string | -| [salt] | string \| undefined | - - - -### sdObjectEncoder.addSdAlgProperty() -Adds the `_sd_alg` property to the top level of the object, with -its value set to "sha-256". - -**Kind**: instance method of [SdObjectEncoder](#SdObjectEncoder) - - -### sdObjectEncoder.encodeToString() ⇒ string -Returns the modified object as a string. - -**Kind**: instance method of [SdObjectEncoder](#SdObjectEncoder) - - -### sdObjectEncoder.toString() ⇒ string -Returns the modified object as a string. - -**Kind**: instance method of [SdObjectEncoder](#SdObjectEncoder) - - -### sdObjectEncoder.encodeToObject() ⇒ Record.<string, any> -Returns the modified object. - -**Kind**: instance method of [SdObjectEncoder](#SdObjectEncoder) - - -### sdObjectEncoder.toJSON() ⇒ any -Returns the modified object. - -**Kind**: instance method of [SdObjectEncoder](#SdObjectEncoder) - - -### sdObjectEncoder.addDecoys(path, number_of_decoys) -Adds a decoy digest to the specified path. -If path is an empty slice, decoys will be added to the top level. - -**Kind**: instance method of [SdObjectEncoder](#SdObjectEncoder) - -| Param | Type | -| --- | --- | -| path | string | -| number_of_decoys | number | - - - -## SelectiveDisclosurePresentation -Used to construct a JwpPresentedBuilder and handle the selective disclosure of attributes -- @context MUST NOT be blinded -- id MUST be blinded -- type MUST NOT be blinded -- issuer MUST NOT be blinded -- issuanceDate MUST be blinded (if Timeframe Revocation mechanism is used) -- expirationDate MUST be blinded (if Timeframe Revocation mechanism is used) -- credentialSubject (User have to choose which attribute must be blinded) -- credentialSchema MUST NOT be blinded -- credentialStatus MUST NOT be blinded -- refreshService MUST NOT be blinded (probably will be used for Timeslot Revocation mechanism) -- termsOfUse NO reason to use it in ZK VC (will be in any case blinded) -- evidence (User have to choose which attribute must be blinded) - -**Kind**: global class - -* [SelectiveDisclosurePresentation](#SelectiveDisclosurePresentation) - * [new SelectiveDisclosurePresentation(issued_jwp)](#new_SelectiveDisclosurePresentation_new) - * [.concealInSubject(path)](#SelectiveDisclosurePresentation+concealInSubject) - * [.concealInEvidence(path)](#SelectiveDisclosurePresentation+concealInEvidence) - * [.setPresentationHeader(header)](#SelectiveDisclosurePresentation+setPresentationHeader) - - - -### new SelectiveDisclosurePresentation(issued_jwp) -Initialize a presentation starting from an Issued JWP. -The properties `jti`, `nbf`, `issuanceDate`, `expirationDate` and `termsOfUse` are concealed by default. - - -| Param | Type | -| --- | --- | -| issued_jwp | [JwpIssued](#JwpIssued) | - - - -### selectiveDisclosurePresentation.concealInSubject(path) -Selectively disclose "credentialSubject" attributes. -# Example -``` -{ - "id": 1234, - "name": "Alice", - "mainCourses": ["Object-oriented Programming", "Mathematics"], - "degree": { - "type": "BachelorDegree", - "name": "Bachelor of Science and Arts", - }, - "GPA": "4.0", -} -``` -If you want to undisclose for example the Mathematics course and the name of the degree: -``` -undisclose_subject("mainCourses[1]"); -undisclose_subject("degree.name"); -``` - -**Kind**: instance method of [SelectiveDisclosurePresentation](#SelectiveDisclosurePresentation) - -| Param | Type | -| --- | --- | -| path | string | - - - -### selectiveDisclosurePresentation.concealInEvidence(path) -Undiscloses "evidence" attributes. - -**Kind**: instance method of [SelectiveDisclosurePresentation](#SelectiveDisclosurePresentation) - -| Param | Type | -| --- | --- | -| path | string | - - - -### selectiveDisclosurePresentation.setPresentationHeader(header) -Sets presentation protected header. - -**Kind**: instance method of [SelectiveDisclosurePresentation](#SelectiveDisclosurePresentation) - -| Param | Type | -| --- | --- | -| header | [PresentationProtectedHeader](#PresentationProtectedHeader) | - - - -## Service -A DID Document Service used to enable trusted interactions associated with a DID subject. - -**Kind**: global class - -* [Service](#Service) - * [new Service(service)](#new_Service_new) - * _instance_ - * [.id()](#Service+id) ⇒ [DIDUrl](#DIDUrl) - * [.type()](#Service+type) ⇒ Array.<string> - * [.serviceEndpoint()](#Service+serviceEndpoint) ⇒ string \| Array.<string> \| Map.<string, Array.<string>> - * [.properties()](#Service+properties) ⇒ Map.<string, any> - * [.toJSON()](#Service+toJSON) ⇒ any - * [.clone()](#Service+clone) ⇒ [Service](#Service) - * _static_ - * [.fromJSON(json)](#Service.fromJSON) ⇒ [Service](#Service) - - - -### new Service(service) - -| Param | Type | -| --- | --- | -| service | IService | - - - -### service.id() ⇒ [DIDUrl](#DIDUrl) -Returns a copy of the [Service](#Service) id. - -**Kind**: instance method of [Service](#Service) - - -### service.type() ⇒ Array.<string> -Returns a copy of the [Service](#Service) type. - -**Kind**: instance method of [Service](#Service) - - -### service.serviceEndpoint() ⇒ string \| Array.<string> \| Map.<string, Array.<string>> -Returns a copy of the [Service](#Service) endpoint. - -**Kind**: instance method of [Service](#Service) - - -### service.properties() ⇒ Map.<string, any> -Returns a copy of the custom properties on the [Service](#Service). - -**Kind**: instance method of [Service](#Service) - - -### service.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Service](#Service) - - -### service.clone() ⇒ [Service](#Service) -Deep clones the object. - -**Kind**: instance method of [Service](#Service) - - -### Service.fromJSON(json) ⇒ [Service](#Service) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Service](#Service) - -| Param | Type | -| --- | --- | -| json | any | - - - -## StatusList2021 -StatusList2021 data structure as described in [W3C's VC status list 2021](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/). - -**Kind**: global class - -* [StatusList2021](#StatusList2021) - * [new StatusList2021([size])](#new_StatusList2021_new) - * _instance_ - * [.clone()](#StatusList2021+clone) ⇒ [StatusList2021](#StatusList2021) - * [.len()](#StatusList2021+len) ⇒ number - * [.get(index)](#StatusList2021+get) ⇒ boolean - * [.set(index, value)](#StatusList2021+set) - * [.intoEncodedStr()](#StatusList2021+intoEncodedStr) ⇒ string - * _static_ - * [.fromEncodedStr(s)](#StatusList2021.fromEncodedStr) ⇒ [StatusList2021](#StatusList2021) - - - -### new StatusList2021([size]) -Creates a new [StatusList2021](#StatusList2021) of `size` entries. - - -| Param | Type | -| --- | --- | -| [size] | number \| undefined | - - - -### statusList2021.clone() ⇒ [StatusList2021](#StatusList2021) -Deep clones the object. - -**Kind**: instance method of [StatusList2021](#StatusList2021) - - -### statusList2021.len() ⇒ number -Returns the number of entries in this [StatusList2021](#StatusList2021). - -**Kind**: instance method of [StatusList2021](#StatusList2021) - - -### statusList2021.get(index) ⇒ boolean -Returns whether the entry at `index` is set. - -**Kind**: instance method of [StatusList2021](#StatusList2021) - -| Param | Type | -| --- | --- | -| index | number | - - - -### statusList2021.set(index, value) -Sets the value of the `index`-th entry. - -**Kind**: instance method of [StatusList2021](#StatusList2021) - -| Param | Type | -| --- | --- | -| index | number | -| value | boolean | - - - -### statusList2021.intoEncodedStr() ⇒ string -Encodes this [StatusList2021](#StatusList2021) into its compressed -base64 string representation. - -**Kind**: instance method of [StatusList2021](#StatusList2021) - - -### StatusList2021.fromEncodedStr(s) ⇒ [StatusList2021](#StatusList2021) -Attempts to decode a [StatusList2021](#StatusList2021) from a string. - -**Kind**: static method of [StatusList2021](#StatusList2021) - -| Param | Type | -| --- | --- | -| s | string | - - - -## StatusList2021Credential -A parsed [StatusList2021Credential](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/#statuslist2021credential). - -**Kind**: global class - -* [StatusList2021Credential](#StatusList2021Credential) - * [new StatusList2021Credential(credential)](#new_StatusList2021Credential_new) - * _instance_ - * [.id()](#StatusList2021Credential+id) ⇒ string - * [.setCredentialStatus(credential, index, revoked_or_suspended)](#StatusList2021Credential+setCredentialStatus) ⇒ [StatusList2021Entry](#StatusList2021Entry) - * [.purpose()](#StatusList2021Credential+purpose) ⇒ [StatusPurpose](#StatusPurpose) - * [.entry(index)](#StatusList2021Credential+entry) ⇒ [CredentialStatus](#CredentialStatus) - * [.clone()](#StatusList2021Credential+clone) ⇒ [StatusList2021Credential](#StatusList2021Credential) - * [.toJSON()](#StatusList2021Credential+toJSON) ⇒ any - * _static_ - * [.fromJSON(json)](#StatusList2021Credential.fromJSON) ⇒ [StatusList2021Credential](#StatusList2021Credential) - - - -### new StatusList2021Credential(credential) -Creates a new [StatusList2021Credential](#StatusList2021Credential). - - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | - - - -### statusList2021Credential.id() ⇒ string -**Kind**: instance method of [StatusList2021Credential](#StatusList2021Credential) - - -### statusList2021Credential.setCredentialStatus(credential, index, revoked_or_suspended) ⇒ [StatusList2021Entry](#StatusList2021Entry) -Sets the given credential's status using the `index`-th entry of this status list. -Returns the created `credentialStatus`. - -**Kind**: instance method of [StatusList2021Credential](#StatusList2021Credential) - -| Param | Type | -| --- | --- | -| credential | [Credential](#Credential) | -| index | number | -| revoked_or_suspended | boolean | - - - -### statusList2021Credential.purpose() ⇒ [StatusPurpose](#StatusPurpose) -Returns the [StatusPurpose](#StatusPurpose) of this [StatusList2021Credential](#StatusList2021Credential). - -**Kind**: instance method of [StatusList2021Credential](#StatusList2021Credential) - - -### statusList2021Credential.entry(index) ⇒ [CredentialStatus](#CredentialStatus) -Returns the state of the `index`-th entry, if any. - -**Kind**: instance method of [StatusList2021Credential](#StatusList2021Credential) - -| Param | Type | -| --- | --- | -| index | number | - - - -### statusList2021Credential.clone() ⇒ [StatusList2021Credential](#StatusList2021Credential) -**Kind**: instance method of [StatusList2021Credential](#StatusList2021Credential) - - -### statusList2021Credential.toJSON() ⇒ any -**Kind**: instance method of [StatusList2021Credential](#StatusList2021Credential) - - -### StatusList2021Credential.fromJSON(json) ⇒ [StatusList2021Credential](#StatusList2021Credential) -**Kind**: static method of [StatusList2021Credential](#StatusList2021Credential) - -| Param | Type | -| --- | --- | -| json | any | - - - -## StatusList2021CredentialBuilder -Builder type to construct valid [StatusList2021Credential](#StatusList2021Credential) istances. - -**Kind**: global class - -* [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - * [new StatusList2021CredentialBuilder([status_list])](#new_StatusList2021CredentialBuilder_new) - * [.purpose(purpose)](#StatusList2021CredentialBuilder+purpose) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - * [.subjectId(id)](#StatusList2021CredentialBuilder+subjectId) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - * [.expirationDate(time)](#StatusList2021CredentialBuilder+expirationDate) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - * [.issuer(issuer)](#StatusList2021CredentialBuilder+issuer) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - * [.context(context)](#StatusList2021CredentialBuilder+context) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - * [.type(t)](#StatusList2021CredentialBuilder+type) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - * [.proof(proof)](#StatusList2021CredentialBuilder+proof) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - * [.build()](#StatusList2021CredentialBuilder+build) ⇒ [StatusList2021Credential](#StatusList2021Credential) - - - -### new StatusList2021CredentialBuilder([status_list]) -Creates a new [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder). - - -| Param | Type | -| --- | --- | -| [status_list] | [StatusList2021](#StatusList2021) \| undefined | - - - -### statusList2021CredentialBuilder.purpose(purpose) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) -Sets the purpose of the [StatusList2021Credential](#StatusList2021Credential) that is being created. - -**Kind**: instance method of [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - -| Param | Type | -| --- | --- | -| purpose | [StatusPurpose](#StatusPurpose) | - - - -### statusList2021CredentialBuilder.subjectId(id) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) -Sets `credentialSubject.id`. - -**Kind**: instance method of [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - -| Param | Type | -| --- | --- | -| id | string | - - - -### statusList2021CredentialBuilder.expirationDate(time) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) -Sets the expiration date of the credential. - -**Kind**: instance method of [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - -| Param | Type | -| --- | --- | -| time | [Timestamp](#Timestamp) | - - - -### statusList2021CredentialBuilder.issuer(issuer) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) -Sets the issuer of the credential. - -**Kind**: instance method of [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - -| Param | Type | -| --- | --- | -| issuer | string | - - - -### statusList2021CredentialBuilder.context(context) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) -Sets the context of the credential. - -**Kind**: instance method of [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - -| Param | Type | -| --- | --- | -| context | string | - - - -### statusList2021CredentialBuilder.type(t) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) -Adds a credential type. - -**Kind**: instance method of [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - -| Param | Type | -| --- | --- | -| t | string | - - - -### statusList2021CredentialBuilder.proof(proof) ⇒ [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) -Adds a credential's proof. - -**Kind**: instance method of [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - -| Param | Type | -| --- | --- | -| proof | [Proof](#Proof) | - - - -### statusList2021CredentialBuilder.build() ⇒ [StatusList2021Credential](#StatusList2021Credential) -Attempts to build a valid [StatusList2021Credential](#StatusList2021Credential) with the previously provided data. - -**Kind**: instance method of [StatusList2021CredentialBuilder](#StatusList2021CredentialBuilder) - - -## StatusList2021Entry -[StatusList2021Entry](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/#statuslist2021entry) implementation. - -**Kind**: global class - -* [StatusList2021Entry](#StatusList2021Entry) - * [new StatusList2021Entry(status_list, purpose, index, [id])](#new_StatusList2021Entry_new) - * _instance_ - * [.id()](#StatusList2021Entry+id) ⇒ string - * [.purpose()](#StatusList2021Entry+purpose) ⇒ [StatusPurpose](#StatusPurpose) - * [.index()](#StatusList2021Entry+index) ⇒ number - * [.statusListCredential()](#StatusList2021Entry+statusListCredential) ⇒ string - * [.toStatus()](#StatusList2021Entry+toStatus) ⇒ Status - * [.clone()](#StatusList2021Entry+clone) ⇒ [StatusList2021Entry](#StatusList2021Entry) - * [.toJSON()](#StatusList2021Entry+toJSON) ⇒ any - * _static_ - * [.fromJSON(json)](#StatusList2021Entry.fromJSON) ⇒ [StatusList2021Entry](#StatusList2021Entry) - - - -### new StatusList2021Entry(status_list, purpose, index, [id]) -Creates a new [StatusList2021Entry](#StatusList2021Entry). - - -| Param | Type | -| --- | --- | -| status_list | string | -| purpose | [StatusPurpose](#StatusPurpose) | -| index | number | -| [id] | string \| undefined | - - - -### statusList2021Entry.id() ⇒ string -Returns this `credentialStatus`'s `id`. - -**Kind**: instance method of [StatusList2021Entry](#StatusList2021Entry) - - -### statusList2021Entry.purpose() ⇒ [StatusPurpose](#StatusPurpose) -Returns the purpose of this entry. - -**Kind**: instance method of [StatusList2021Entry](#StatusList2021Entry) - - -### statusList2021Entry.index() ⇒ number -Returns the index of this entry. - -**Kind**: instance method of [StatusList2021Entry](#StatusList2021Entry) - - -### statusList2021Entry.statusListCredential() ⇒ string -Returns the referenced [StatusList2021Credential](#StatusList2021Credential)'s url. - -**Kind**: instance method of [StatusList2021Entry](#StatusList2021Entry) - - -### statusList2021Entry.toStatus() ⇒ Status -Downcasts [this](this) to [Status](Status) - -**Kind**: instance method of [StatusList2021Entry](#StatusList2021Entry) - - -### statusList2021Entry.clone() ⇒ [StatusList2021Entry](#StatusList2021Entry) -Deep clones the object. - -**Kind**: instance method of [StatusList2021Entry](#StatusList2021Entry) - - -### statusList2021Entry.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [StatusList2021Entry](#StatusList2021Entry) - - -### StatusList2021Entry.fromJSON(json) ⇒ [StatusList2021Entry](#StatusList2021Entry) -Deserializes an instance from a JSON object. - -**Kind**: static method of [StatusList2021Entry](#StatusList2021Entry) - -| Param | Type | -| --- | --- | -| json | any | - - - -## Storage -A type wrapping a `JwkStorage` and `KeyIdStorage` that should always be used together when -working with storage backed DID documents. - -**Kind**: global class - -* [Storage](#Storage) - * [new Storage(jwkStorage, keyIdStorage)](#new_Storage_new) - * [.keyIdStorage()](#Storage+keyIdStorage) ⇒ KeyIdStorage - * [.keyStorage()](#Storage+keyStorage) ⇒ JwkStorage - - - -### new Storage(jwkStorage, keyIdStorage) -Constructs a new `Storage`. - - -| Param | Type | -| --- | --- | -| jwkStorage | JwkStorage | -| keyIdStorage | KeyIdStorage | - - - -### storage.keyIdStorage() ⇒ KeyIdStorage -Obtain the wrapped `KeyIdStorage`. - -**Kind**: instance method of [Storage](#Storage) - - -### storage.keyStorage() ⇒ JwkStorage -Obtain the wrapped `JwkStorage`. - -**Kind**: instance method of [Storage](#Storage) - - -## Timestamp -**Kind**: global class - -* [Timestamp](#Timestamp) - * [new Timestamp()](#new_Timestamp_new) - * _instance_ - * [.toRFC3339()](#Timestamp+toRFC3339) ⇒ string - * [.checkedAdd(duration)](#Timestamp+checkedAdd) ⇒ [Timestamp](#Timestamp) \| undefined - * [.checkedSub(duration)](#Timestamp+checkedSub) ⇒ [Timestamp](#Timestamp) \| undefined - * [.toJSON()](#Timestamp+toJSON) ⇒ any - * _static_ - * [.parse(input)](#Timestamp.parse) ⇒ [Timestamp](#Timestamp) - * [.nowUTC()](#Timestamp.nowUTC) ⇒ [Timestamp](#Timestamp) - * [.fromJSON(json)](#Timestamp.fromJSON) ⇒ [Timestamp](#Timestamp) - - - -### new Timestamp() -Creates a new [Timestamp](#Timestamp) with the current date and time. - - - -### timestamp.toRFC3339() ⇒ string -Returns the [Timestamp](#Timestamp) as an RFC 3339 `String`. - -**Kind**: instance method of [Timestamp](#Timestamp) - - -### timestamp.checkedAdd(duration) ⇒ [Timestamp](#Timestamp) \| undefined -Computes `self + duration` - -Returns `null` if the operation leads to a timestamp not in the valid range for [RFC 3339](https://tools.ietf.org/html/rfc3339). - -**Kind**: instance method of [Timestamp](#Timestamp) - -| Param | Type | -| --- | --- | -| duration | [Duration](#Duration) | - - - -### timestamp.checkedSub(duration) ⇒ [Timestamp](#Timestamp) \| undefined -Computes `self - duration` - -Returns `null` if the operation leads to a timestamp not in the valid range for [RFC 3339](https://tools.ietf.org/html/rfc3339). - -**Kind**: instance method of [Timestamp](#Timestamp) - -| Param | Type | -| --- | --- | -| duration | [Duration](#Duration) | - - - -### timestamp.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [Timestamp](#Timestamp) - - -### Timestamp.parse(input) ⇒ [Timestamp](#Timestamp) -Parses a [Timestamp](#Timestamp) from the provided input string. - -**Kind**: static method of [Timestamp](#Timestamp) - -| Param | Type | -| --- | --- | -| input | string | - - - -### Timestamp.nowUTC() ⇒ [Timestamp](#Timestamp) -Creates a new [Timestamp](#Timestamp) with the current date and time. - -**Kind**: static method of [Timestamp](#Timestamp) - - -### Timestamp.fromJSON(json) ⇒ [Timestamp](#Timestamp) -Deserializes an instance from a JSON object. - -**Kind**: static method of [Timestamp](#Timestamp) - -| Param | Type | -| --- | --- | -| json | any | - - - -## UnknownCredential -**Kind**: global class - -* [UnknownCredential](#UnknownCredential) - * _instance_ - * [.tryIntoJwt()](#UnknownCredential+tryIntoJwt) ⇒ [Jwt](#Jwt) \| undefined - * [.tryIntoCredential()](#UnknownCredential+tryIntoCredential) ⇒ [Credential](#Credential) \| undefined - * [.tryIntoRaw()](#UnknownCredential+tryIntoRaw) ⇒ Record.<string, any> \| undefined - * [.toJSON()](#UnknownCredential+toJSON) ⇒ any - * [.clone()](#UnknownCredential+clone) ⇒ [UnknownCredential](#UnknownCredential) - * _static_ - * [.fromJSON(json)](#UnknownCredential.fromJSON) ⇒ [UnknownCredential](#UnknownCredential) - - - -### unknownCredential.tryIntoJwt() ⇒ [Jwt](#Jwt) \| undefined -Returns a [Jwt](#Jwt) if the credential is of type string, `undefined` otherwise. - -**Kind**: instance method of [UnknownCredential](#UnknownCredential) - - -### unknownCredential.tryIntoCredential() ⇒ [Credential](#Credential) \| undefined -Returns a [Credential](#Credential) if the credential is of said type, `undefined` otherwise. - -**Kind**: instance method of [UnknownCredential](#UnknownCredential) - - -### unknownCredential.tryIntoRaw() ⇒ Record.<string, any> \| undefined -Returns the contained value as an Object, if it can be converted, `undefined` otherwise. - -**Kind**: instance method of [UnknownCredential](#UnknownCredential) - - -### unknownCredential.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [UnknownCredential](#UnknownCredential) - - -### unknownCredential.clone() ⇒ [UnknownCredential](#UnknownCredential) -Deep clones the object. - -**Kind**: instance method of [UnknownCredential](#UnknownCredential) - - -### UnknownCredential.fromJSON(json) ⇒ [UnknownCredential](#UnknownCredential) -Deserializes an instance from a JSON object. - -**Kind**: static method of [UnknownCredential](#UnknownCredential) - -| Param | Type | -| --- | --- | -| json | any | - - - -## VerificationMethod -A DID Document Verification Method. - -**Kind**: global class - -* [VerificationMethod](#VerificationMethod) - * [new VerificationMethod(id, controller, type_, data)](#new_VerificationMethod_new) - * _instance_ - * [.id()](#VerificationMethod+id) ⇒ [DIDUrl](#DIDUrl) - * [.setId(id)](#VerificationMethod+setId) - * [.controller()](#VerificationMethod+controller) ⇒ [CoreDID](#CoreDID) - * [.setController(did)](#VerificationMethod+setController) - * [.type()](#VerificationMethod+type) ⇒ [MethodType](#MethodType) - * [.setType(type_)](#VerificationMethod+setType) - * [.data()](#VerificationMethod+data) ⇒ [MethodData](#MethodData) - * [.setData(data)](#VerificationMethod+setData) - * [.properties()](#VerificationMethod+properties) ⇒ Map.<string, any> - * [.setPropertyUnchecked(key, value)](#VerificationMethod+setPropertyUnchecked) - * [.toJSON()](#VerificationMethod+toJSON) ⇒ any - * [.clone()](#VerificationMethod+clone) ⇒ [VerificationMethod](#VerificationMethod) - * _static_ - * [.newFromJwk(did, key, [fragment])](#VerificationMethod.newFromJwk) ⇒ [VerificationMethod](#VerificationMethod) - * [.fromJSON(json)](#VerificationMethod.fromJSON) ⇒ [VerificationMethod](#VerificationMethod) - - - -### new VerificationMethod(id, controller, type_, data) -Create a custom [VerificationMethod](#VerificationMethod). - - -| Param | Type | -| --- | --- | -| id | [DIDUrl](#DIDUrl) | -| controller | [CoreDID](#CoreDID) | -| type_ | [MethodType](#MethodType) | -| data | [MethodData](#MethodData) | - - - -### verificationMethod.id() ⇒ [DIDUrl](#DIDUrl) -Returns a copy of the [DIDUrl](#DIDUrl) of the [VerificationMethod](#VerificationMethod)'s `id`. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - - -### verificationMethod.setId(id) -Sets the id of the [VerificationMethod](#VerificationMethod). - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - -| Param | Type | -| --- | --- | -| id | [DIDUrl](#DIDUrl) | - - - -### verificationMethod.controller() ⇒ [CoreDID](#CoreDID) -Returns a copy of the `controller` `DID` of the [VerificationMethod](#VerificationMethod). - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - - -### verificationMethod.setController(did) -Sets the `controller` `DID` of the [VerificationMethod](#VerificationMethod) object. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - -| Param | Type | -| --- | --- | -| did | [CoreDID](#CoreDID) | - - - -### verificationMethod.type() ⇒ [MethodType](#MethodType) -Returns a copy of the [VerificationMethod](#VerificationMethod) type. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - - -### verificationMethod.setType(type_) -Sets the [VerificationMethod](#VerificationMethod) type. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - -| Param | Type | -| --- | --- | -| type_ | [MethodType](#MethodType) | - - - -### verificationMethod.data() ⇒ [MethodData](#MethodData) -Returns a copy of the [VerificationMethod](#VerificationMethod) public key data. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - - -### verificationMethod.setData(data) -Sets [VerificationMethod](#VerificationMethod) public key data. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - -| Param | Type | -| --- | --- | -| data | [MethodData](#MethodData) | - - - -### verificationMethod.properties() ⇒ Map.<string, any> -Get custom properties of the Verification Method. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - - -### verificationMethod.setPropertyUnchecked(key, value) -Adds a custom property to the Verification Method. -If the value is set to `null`, the custom property will be removed. - -### WARNING -This method can overwrite existing properties like `id` and result -in an invalid Verification Method. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - -| Param | Type | -| --- | --- | -| key | string | -| value | any | - - - -### verificationMethod.toJSON() ⇒ any -Serializes this to a JSON object. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - - -### verificationMethod.clone() ⇒ [VerificationMethod](#VerificationMethod) -Deep clones the object. - -**Kind**: instance method of [VerificationMethod](#VerificationMethod) - - -### VerificationMethod.newFromJwk(did, key, [fragment]) ⇒ [VerificationMethod](#VerificationMethod) -Creates a new [VerificationMethod](#VerificationMethod) from the given `did` and [Jwk](#Jwk). If `fragment` is not given -the `kid` value of the given `key` will be used, if present, otherwise an error is returned. - -### Recommendations -The following recommendations are essentially taken from the `publicKeyJwk` description from the [DID specification](https://www.w3.org/TR/did-core/#dfn-publickeyjwk): -- It is recommended that verification methods that use `Jwks` to represent their public keys use the value of - `kid` as their fragment identifier. This is -done automatically if `None` is passed in as the fragment. -- It is recommended that [Jwk](#Jwk) kid values are set to the public key fingerprint. - -**Kind**: static method of [VerificationMethod](#VerificationMethod) - -| Param | Type | -| --- | --- | -| did | [CoreDID](#CoreDID) \| IToCoreDID | -| key | [Jwk](#Jwk) | -| [fragment] | string \| undefined | - - - -### VerificationMethod.fromJSON(json) ⇒ [VerificationMethod](#VerificationMethod) -Deserializes an instance from a JSON object. - -**Kind**: static method of [VerificationMethod](#VerificationMethod) - -| Param | Type | -| --- | --- | -| json | any | - - -**Kind**: global variable - - -## StatusCheck -Controls validation behaviour when checking whether or not a credential has been revoked by its -[`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status). - -**Kind**: global variable - - -## Strict -Validate the status if supported, reject any unsupported -[`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types. - -Only `RevocationBitmap2022` is currently supported. - -This is the default. - -**Kind**: global variable - - -## SkipUnsupported -Validate the status if supported, skip any unsupported -[`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types. - -**Kind**: global variable - - -## SkipAll -Skip all status checks. - -**Kind**: global variable - - -## SerializationType -**Kind**: global variable - - -## MethodRelationship -**Kind**: global variable - - -## SubjectHolderRelationship -Declares how credential subjects must relate to the presentation holder. - -See also the [Subject-Holder Relationship](https://www.w3.org/TR/vc-data-model/#subject-holder-relationships) section of the specification. - -**Kind**: global variable - - -## AlwaysSubject -The holder must always match the subject on all credentials, regardless of their [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property. -This variant is the default. - -**Kind**: global variable - - -## SubjectOnNonTransferable -The holder must match the subject only for credentials where the [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property is `true`. - -**Kind**: global variable - - -## Any -The holder is not required to have any kind of relationship to any credential subject. - -## StateMetadataEncoding -**Kind**: global variable - - -## StateMetadataEncoding -**Kind**: global variable - - -## FailFast -Declares when validation should return if an error occurs. - -**Kind**: global variable - - -## AllErrors -Return all errors that occur during validation. - -**Kind**: global variable - - -## FirstError -Return after the first error occurs. - -**Kind**: global variable - -**Kind**: global variable - - -## verifyEd25519(alg, signingInput, decodedSignature, publicKey) -Verify a JWS signature secured with the `EdDSA` algorithm and curve `Ed25519`. - -This function is useful when one is composing a `IJwsVerifier` that delegates -`EdDSA` verification with curve `Ed25519` to this function. - -# Warning - -This function does not check whether `alg = EdDSA` in the protected header. Callers are expected to assert this -prior to calling the function. - -**Kind**: global function - -| Param | Type | -| --- | --- | -| alg | JwsAlgorithm | -| signingInput | Uint8Array | -| decodedSignature | Uint8Array | -| publicKey | [Jwk](#Jwk) | - - - -## start() -Initializes the console error panic hook for better error messages - -**Kind**: global function - - -## encodeB64(data) ⇒ string -Encode the given bytes in url-safe base64. - -**Kind**: global function - -| Param | Type | -| --- | --- | -| data | Uint8Array | - - - -## decodeB64(data) ⇒ Uint8Array -Decode the given url-safe base64-encoded slice into its raw bytes. - -**Kind**: global function - -| Param | Type | -| --- | --- | -| data | Uint8Array | - - - -## start() -Initializes the console error panic hook for better error messages - -**Kind**: global function diff --git a/bindings/wasm/tsconfig.typedoc.json b/bindings/wasm/tsconfig.typedoc.json new file mode 100644 index 0000000000..02841974ec --- /dev/null +++ b/bindings/wasm/tsconfig.typedoc.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.node.json", + "include": ["node/**/*"] +} diff --git a/bindings/wasm/typedoc.json b/bindings/wasm/typedoc.json index 05e940cf33..b383d21269 100644 --- a/bindings/wasm/typedoc.json +++ b/bindings/wasm/typedoc.json @@ -5,9 +5,9 @@ "excludeInternal": true, "excludeNotDocumented": true, "excludeExternals": true, - "entryPoints": ["./lib/"], + "entryPoints": ["./node/"], "entryPointStrategy": "expand", - "tsconfig": "./lib/tsconfig.json", + "tsconfig": "./tsconfig.typedoc.json", "out": "./docs/api", // "externalPattern": ["lib/*.ts"], "compilerOptions": { From 268317b12390187a30f45b2b8f6c5fb1eb4ae51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eike=20Ha=C3=9F?= Date: Wed, 28 Aug 2024 10:40:13 +0200 Subject: [PATCH 05/21] use typedoc for docs --- bindings/wasm/package.json | 5 +- test.js | 14839 ----------------------------------- 2 files changed, 2 insertions(+), 14842 deletions(-) delete mode 100644 test.js diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 210b936c29..0cf571ad8f 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -15,7 +15,7 @@ "bundle:web": "wasm-bindgen target/wasm32-unknown-unknown/release/identity_wasm.wasm --typescript --weak-refs --target web --out-dir web && node ./build/web && tsc --project ./lib/tsconfig.web.json && node ./build/replace_paths ./lib/tsconfig.web.json web", "build:nodejs": "npm run build:src && npm run bundle:nodejs && wasm-opt -O node/identity_wasm_bg.wasm -o node/identity_wasm_bg.wasm", "build:web": "npm run build:src && npm run bundle:web && wasm-opt -O web/identity_wasm_bg.wasm -o web/identity_wasm_bg.wasm", - "build:docs": "npm run fix_js_doc && node ./build/docs", + "build:docs": "typedoc", "build:examples:web": "tsc --project ./examples/tsconfig.web.json && node ./build/replace_paths ./examples/tsconfig.web.json ./examples/dist resolve", "build": "npm run build:web && npm run build:nodejs && npm run build:docs", "example:node": "ts-node --project tsconfig.node.json -r tsconfig-paths/register ./examples/src/main.ts", @@ -32,8 +32,7 @@ "test:unit:node": "ts-mocha -p tsconfig.node.json ./tests/*.ts --parallel --exit", "cypress": "cypress open", "fmt": "dprint fmt", - "fix_js_doc": "sed -Ei 's/\\((.*)\\)\\[\\]/\\1\\[\\]/' ./node/identity_wasm.js", - "create-api-docs": "typedoc" + "fix_js_doc": "sed -Ei 's/\\((.*)\\)\\[\\]/\\1\\[\\]/' ./node/identity_wasm.js" }, "config": { "CYPRESS_VERIFY_TIMEOUT": 100000 diff --git a/test.js b/test.js deleted file mode 100644 index a1a54c68d5..0000000000 --- a/test.js +++ /dev/null @@ -1,14839 +0,0 @@ - -if (!globalThis.fetch) { - const fetch = require('node-fetch') - globalThis.Headers = fetch.Headers - globalThis.Request = fetch.Request - globalThis.Response = fetch.Response - globalThis.fetch = fetch -} -let imports = {}; -imports['__wbindgen_placeholder__'] = module.exports; -let wasm; -const { TextDecoder, TextEncoder, inspect } = require(`util`); - -const heap = new Array(128).fill(undefined); - -heap.push(undefined, null, true, false); - -function getObject(idx) { return heap[idx]; } - -let heap_next = heap.length; - -function dropObject(idx) { - if (idx < 132) return; - heap[idx] = heap_next; - heap_next = idx; -} - -function takeObject(idx) { - const ret = getObject(idx); - dropObject(idx); - return ret; -} - -let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -let cachedUint8ArrayMemory0 = null; - -function getUint8ArrayMemory0() { - if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { - cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8ArrayMemory0; -} - -function getStringFromWasm0(ptr, len) { - ptr = ptr >>> 0; - return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); -} - -function addHeapObject(obj) { - if (heap_next === heap.length) heap.push(heap.length + 1); - const idx = heap_next; - heap_next = heap[idx]; - - heap[idx] = obj; - return idx; -} - -let WASM_VECTOR_LEN = 0; - -let cachedTextEncoder = new TextEncoder('utf-8'); - -const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' - ? function (arg, view) { - return cachedTextEncoder.encodeInto(arg, view); - } - : function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; - }); - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length, 1) >>> 0; - getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len, 1) >>> 0; - - const mem = getUint8ArrayMemory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; - const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - ptr = realloc(ptr, len, offset, 1) >>> 0; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -let cachedDataViewMemory0 = null; - -function getDataViewMemory0() { - if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { - cachedDataViewMemory0 = new DataView(wasm.memory.buffer); - } - return cachedDataViewMemory0; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -function debugString(val) { - // primitive types - const type = typeof val; - if (type == 'number' || type == 'boolean' || val == null) { - return `${val}`; - } - if (type == 'string') { - return `"${val}"`; - } - if (type == 'symbol') { - const description = val.description; - if (description == null) { - return 'Symbol'; - } else { - return `Symbol(${description})`; - } - } - if (type == 'function') { - const name = val.name; - if (typeof name == 'string' && name.length > 0) { - return `Function(${name})`; - } else { - return 'Function'; - } - } - // objects - if (Array.isArray(val)) { - const length = val.length; - let debug = '['; - if (length > 0) { - debug += debugString(val[0]); - } - for (let i = 1; i < length; i++) { - debug += ', ' + debugString(val[i]); - } - debug += ']'; - return debug; - } - // Test for built-in - const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); - let className; - if (builtInMatches.length > 1) { - className = builtInMatches[1]; - } else { - // Failed to match the standard '[object ClassName]' - return toString.call(val); - } - if (className == 'Object') { - // we're a user defined class or Object - // JSON.stringify avoids problems with cycles, and is generally much - // easier than looping through ownProperties of `val`. - try { - return 'Object(' + JSON.stringify(val) + ')'; - } catch (_) { - return 'Object'; - } - } - // errors - if (val instanceof Error) { - return `${val.name}: ${val.message}\n${val.stack}`; - } - // TODO we could test for more things here, like `Set`s and `Map`s. - return className; -} - -const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(state => { - wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b) - }); - -function makeMutClosure(arg0, arg1, dtor, f) { - const state = { a: arg0, b: arg1, cnt: 1, dtor }; - const real = (...args) => { - // First up with a closure we increment the internal reference - // count. This ensures that the Rust closure environment won't - // be deallocated while we're invoking it. - state.cnt++; - const a = state.a; - state.a = 0; - try { - return f(a, state.b, ...args); - } finally { - if (--state.cnt === 0) { - wasm.__wbindgen_export_2.get(state.dtor)(a, state.b); - CLOSURE_DTORS.unregister(state); - } else { - state.a = a; - } - } - }; - real.original = state; - CLOSURE_DTORS.register(real, state, state); - return real; -} -function __wbg_adapter_32(arg0, arg1, arg2) { - wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hecbb567bf7d4b77d(arg0, arg1, addHeapObject(arg2)); -} - -/** -* Initializes the console error panic hook for better error messages -*/ -module.exports.start = function () { - wasm.start(); -}; - -let stack_pointer = 128; - -function addBorrowedObject(obj) { - if (stack_pointer == 1) throw new Error('out of js stack'); - heap[--stack_pointer] = obj; - return stack_pointer; -} - -function passArrayJsValueToWasm0(array, malloc) { - const ptr = malloc(array.length * 4, 4) >>> 0; - const mem = getDataViewMemory0(); - for (let i = 0; i < array.length; i++) { - mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true); - } - WASM_VECTOR_LEN = array.length; - return ptr; -} - -function getArrayJsValueFromWasm0(ptr, len) { - ptr = ptr >>> 0; - const mem = getDataViewMemory0(); - const result = []; - for (let i = ptr; i < ptr + 4 * len; i += 4) { - result.push(takeObject(mem.getUint32(i, true))); - } - return result; -} - -let cachedUint32ArrayMemory0 = null; - -function getUint32ArrayMemory0() { - if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) { - cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer); - } - return cachedUint32ArrayMemory0; -} - -function getArrayU32FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len); -} - -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); - } - return instance.ptr; -} - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1, 1) >>> 0; - getUint8ArrayMemory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} - -function getArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); -} -/** -* Verify a JWS signature secured with the `EdDSA` algorithm and curve `Ed25519`. -* -* This function is useful when one is composing a `IJwsVerifier` that delegates -* `EdDSA` verification with curve `Ed25519` to this function. -* -* # Warning -* -* This function does not check whether `alg = EdDSA` in the protected header. Callers are expected to assert this -* prior to calling the function. -* @param {JwsAlgorithm} alg -* @param {Uint8Array} signingInput -* @param {Uint8Array} decodedSignature -* @param {Jwk} publicKey -*/ -module.exports.verifyEd25519 = function (alg, signingInput, decodedSignature, publicKey) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(signingInput, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(decodedSignature, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(publicKey, Jwk); - wasm.verifyEd25519(retptr, addHeapObject(alg), ptr0, len0, ptr1, len1, publicKey.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -/** -* Encode the given bytes in url-safe base64. -* @param {Uint8Array} data -* @returns {string} -*/ -module.exports.encodeB64 = function (data) { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.encodeB64(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred2_0 = r0; - deferred2_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } -}; - -/** -* Decode the given url-safe base64-encoded slice into its raw bytes. -* @param {Uint8Array} data -* @returns {Uint8Array} -*/ -module.exports.decodeB64 = function (data) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.decodeB64(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - var v2 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v2; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } -}; - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - wasm.__wbindgen_exn_store(addHeapObject(e)); - } -} -function __wbg_adapter_813(arg0, arg1, arg2, arg3) { - wasm.wasm_bindgen__convert__closures__invoke2_mut__h58660668f6114e02(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3)); -} - -/** -*/ -module.exports.SerializationType = Object.freeze({ COMPACT: 0, "0": "COMPACT", JSON: 1, "1": "JSON", }); -/** -* Purpose of a {@link StatusList2021}. -*/ -module.exports.StatusPurpose = Object.freeze({ Revocation: 0, "0": "Revocation", Suspension: 1, "1": "Suspension", }); -/** -* Declares how credential subjects must relate to the presentation holder. -* -* See also the [Subject-Holder Relationship](https://www.w3.org/TR/vc-data-model/#subject-holder-relationships) section of the specification. -*/ -module.exports.SubjectHolderRelationship = Object.freeze({ - /** - * The holder must always match the subject on all credentials, regardless of their [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property. - * This variant is the default. - */ - AlwaysSubject: 0, "0": "AlwaysSubject", - /** - * The holder must match the subject only for credentials where the [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property is `true`. - */ - SubjectOnNonTransferable: 1, "1": "SubjectOnNonTransferable", - /** - * The holder is not required to have any kind of relationship to any credential subject. - */ - Any: 2, "2": "Any", -}); -/** -* Controls validation behaviour when checking whether or not a credential has been revoked by its -* [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status). -*/ -module.exports.StatusCheck = Object.freeze({ - /** - * Validate the status if supported, reject any unsupported - * [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types. - * - * Only `RevocationBitmap2022` is currently supported. - * - * This is the default. - */ - Strict: 0, "0": "Strict", - /** - * Validate the status if supported, skip any unsupported - * [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types. - */ - SkipUnsupported: 1, "1": "SkipUnsupported", - /** - * Skip all status checks. - */ - SkipAll: 2, "2": "SkipAll", -}); -/** -*/ -module.exports.ProofAlgorithm = Object.freeze({ BLS12381_SHA256: 0, "0": "BLS12381_SHA256", BLS12381_SHAKE256: 1, "1": "BLS12381_SHAKE256", SU_ES256: 2, "2": "SU_ES256", MAC_H256: 3, "3": "MAC_H256", MAC_H384: 4, "4": "MAC_H384", MAC_H512: 5, "5": "MAC_H512", MAC_K25519: 6, "6": "MAC_K25519", MAC_K448: 7, "7": "MAC_K448", MAC_H256K: 8, "8": "MAC_H256K", }); -/** -* Declares when validation should return if an error occurs. -*/ -module.exports.FailFast = Object.freeze({ - /** - * Return all errors that occur during validation. - */ - AllErrors: 0, "0": "AllErrors", - /** - * Return after the first error occurs. - */ - FirstError: 1, "1": "FirstError", -}); -/** -*/ -module.exports.StateMetadataEncoding = Object.freeze({ Json: 0, "0": "Json", }); -/** -*/ -module.exports.MethodRelationship = Object.freeze({ Authentication: 0, "0": "Authentication", AssertionMethod: 1, "1": "AssertionMethod", KeyAgreement: 2, "2": "KeyAgreement", CapabilityDelegation: 3, "3": "CapabilityDelegation", CapabilityInvocation: 4, "4": "CapabilityInvocation", }); -/** -*/ -module.exports.CredentialStatus = Object.freeze({ Revoked: 0, "0": "Revoked", Suspended: 1, "1": "Suspended", Valid: 2, "2": "Valid", }); -/** -*/ -module.exports.PayloadType = Object.freeze({ Disclosed: 0, "0": "Disclosed", Undisclosed: 1, "1": "Undisclosed", ProofMethods: 2, "2": "ProofMethods", }); -/** -*/ -module.exports.PresentationProofAlgorithm = Object.freeze({ BLS12381_SHA256_PROOF: 0, "0": "BLS12381_SHA256_PROOF", BLS12381_SHAKE256_PROOF: 1, "1": "BLS12381_SHAKE256_PROOF", SU_ES256: 2, "2": "SU_ES256", MAC_H256: 3, "3": "MAC_H256", MAC_H384: 4, "4": "MAC_H384", MAC_H512: 5, "5": "MAC_H512", MAC_K25519: 6, "6": "MAC_K25519", MAC_K448: 7, "7": "MAC_K448", MAC_H256K: 8, "8": "MAC_H256K", }); - -const CoreDIDFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_coredid_free(ptr >>> 0, 1)); -/** -* A method-agnostic Decentralized Identifier (DID). -*/ -class CoreDID { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(CoreDID.prototype); - obj.__wbg_ptr = ptr; - CoreDIDFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CoreDIDFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_coredid_free(ptr, 0); - } - /** - * Parses a {@link CoreDID} from the given `input`. - * - * ### Errors - * - * Throws an error if the input is not a valid {@link CoreDID}. - * @param {string} input - * @returns {CoreDID} - */ - static parse(input) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.coredid_parse(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Set the method name of the {@link CoreDID}. - * @param {string} value - */ - setMethodName(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.coredid_setMethodName(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Validates whether a string is a valid DID method name. - * @param {string} value - * @returns {boolean} - */ - static validMethodName(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.coredid_validMethodName(ptr0, len0); - return ret !== 0; - } - /** - * Set the method-specific-id of the `DID`. - * @param {string} value - */ - setMethodId(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.coredid_setMethodId(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Validates whether a string is a valid `DID` method-id. - * @param {string} value - * @returns {boolean} - */ - static validMethodId(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.coredid_validMethodId(ptr0, len0); - return ret !== 0; - } - /** - * Returns the {@link CoreDID} scheme. - * - * E.g. - * - `"did:example:12345678" -> "did"` - * - `"did:iota:smr:12345678" -> "did"` - * @returns {string} - */ - scheme() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredid_scheme(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns the {@link CoreDID} authority: the method name and method-id. - * - * E.g. - * - `"did:example:12345678" -> "example:12345678"` - * - `"did:iota:smr:12345678" -> "iota:smr:12345678"` - * @returns {string} - */ - authority() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredid_authority(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns the {@link CoreDID} method name. - * - * E.g. - * - `"did:example:12345678" -> "example"` - * - `"did:iota:smr:12345678" -> "iota"` - * @returns {string} - */ - method() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredid_method(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns the {@link CoreDID} method-specific ID. - * - * E.g. - * - `"did:example:12345678" -> "12345678"` - * - `"did:iota:smr:12345678" -> "smr:12345678"` - * @returns {string} - */ - methodId() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredid_methodId(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Construct a new {@link DIDUrl} by joining with a relative DID Url string. - * @param {string} segment - * @returns {DIDUrl} - */ - join(segment) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(segment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.coredid_join(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DIDUrl.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Clones the {@link CoreDID} into a {@link DIDUrl}. - * @returns {DIDUrl} - */ - toUrl() { - const ret = wasm.coredid_toUrl(this.__wbg_ptr); - return DIDUrl.__wrap(ret); - } - /** - * Converts the {@link CoreDID} into a {@link DIDUrl}, consuming it. - * @returns {DIDUrl} - */ - intoUrl() { - const ptr = this.__destroy_into_raw(); - const ret = wasm.coredid_intoUrl(ptr); - return DIDUrl.__wrap(ret); - } - /** - * Returns the {@link CoreDID} as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredid_toString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * @returns {CoreDID} - */ - toCoreDid() { - const ret = wasm.coredid_clone(this.__wbg_ptr); - return CoreDID.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredid_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {CoreDID} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredid_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {CoreDID} - */ - clone() { - const ret = wasm.coredid_clone(this.__wbg_ptr); - return CoreDID.__wrap(ret); - } -} -module.exports.CoreDID = CoreDID; - -const CoreDocumentFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_coredocument_free(ptr >>> 0, 1)); -/** -* A method-agnostic DID Document. -* -* Note: All methods that involve reading from this class may potentially raise an error -* if the object is being concurrently modified. -*/ -class CoreDocument { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(CoreDocument.prototype); - obj.__wbg_ptr = ptr; - CoreDocumentFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CoreDocumentFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_coredocument_free(ptr, 0); - } - /** - * Creates a new {@link CoreDocument} with the given properties. - * @param {ICoreDocument} values - */ - constructor(values) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_new(retptr, addHeapObject(values)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - CoreDocumentFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the DID Document `id`. - * @returns {CoreDID} - */ - id() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_id(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the DID of the document. - * - * ### Warning - * - * Changing the identifier can drastically alter the results of - * `resolve_method`, `resolve_service` and the related - * [DID URL dereferencing](https://w3c-ccg.github.io/did-resolution/#dereferencing) algorithm. - * @param {CoreDID} id - */ - setId(id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(id, CoreDID); - wasm.coredocument_setId(retptr, this.__wbg_ptr, id.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the document controllers. - * @returns {Array} - */ - controller() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_controller(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the controllers of the DID Document. - * - * Note: Duplicates will be ignored. - * Use `null` to remove all controllers. - * @param {CoreDID | CoreDID[] | null} controllers - */ - setController(controllers) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_setController(retptr, this.__wbg_ptr, addBorrowedObject(controllers)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Returns a copy of the document's `alsoKnownAs` set. - * @returns {Array} - */ - alsoKnownAs() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_alsoKnownAs(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the `alsoKnownAs` property in the DID document. - * @param {string | string[] | null} urls - */ - setAlsoKnownAs(urls) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_setAlsoKnownAs(retptr, this.__wbg_ptr, addBorrowedObject(urls)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Returns a copy of the document's `verificationMethod` set. - * @returns {VerificationMethod[]} - */ - verificationMethod() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_verificationMethod(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the document's `authentication` set. - * @returns {Array} - */ - authentication() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_authentication(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the document's `assertionMethod` set. - * @returns {Array} - */ - assertionMethod() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_assertionMethod(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the document's `keyAgreement` set. - * @returns {Array} - */ - keyAgreement() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_keyAgreement(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the document's `capabilityDelegation` set. - * @returns {Array} - */ - capabilityDelegation() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_capabilityDelegation(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the document's `capabilityInvocation` set. - * @returns {Array} - */ - capabilityInvocation() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_capabilityInvocation(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the custom DID Document properties. - * @returns {Map} - */ - properties() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_properties(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a custom property in the DID Document. - * If the value is set to `null`, the custom property will be removed. - * - * ### WARNING - * - * This method can overwrite existing properties like `id` and result in an invalid document. - * @param {string} key - * @param {any} value - */ - setPropertyUnchecked(key, value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.coredocument_setPropertyUnchecked(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Returns a set of all {@link Service} in the document. - * @returns {Service[]} - */ - service() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_service(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Add a new {@link Service} to the document. - * - * Errors if there already exists a service or verification method with the same id. - * @param {Service} service - */ - insertService(service) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(service, Service); - wasm.coredocument_insertService(retptr, this.__wbg_ptr, service.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Remove a {@link Service} identified by the given {@link DIDUrl} from the document. - * - * Returns `true` if the service was removed. - * @param {DIDUrl} didUrl - * @returns {Service | undefined} - */ - removeService(didUrl) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(didUrl, DIDUrl); - wasm.coredocument_removeService(retptr, this.__wbg_ptr, didUrl.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : Service.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the first {@link Service} with an `id` property matching the provided `query`, - * if present. - * @param {DIDUrl | string} query - * @returns {Service | undefined} - */ - resolveService(query) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_resolveService(retptr, this.__wbg_ptr, addBorrowedObject(query)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : Service.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Returns a list of all {@link VerificationMethod} in the DID Document, - * whose verification relationship matches `scope`. - * - * If `scope` is not set, a list over the **embedded** methods is returned. - * @param {MethodScope | undefined} [scope] - * @returns {VerificationMethod[]} - */ - methods(scope) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_methods(retptr, this.__wbg_ptr, isLikeNone(scope) ? 0 : addHeapObject(scope)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns an array of all verification relationships. - * @returns {Array} - */ - verificationRelationships() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_verificationRelationships(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Adds a new `method` to the document in the given `scope`. - * @param {VerificationMethod} method - * @param {MethodScope} scope - */ - insertMethod(method, scope) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(method, VerificationMethod); - _assertClass(scope, MethodScope); - wasm.coredocument_insertMethod(retptr, this.__wbg_ptr, method.__wbg_ptr, scope.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Removes all references to the specified Verification Method. - * @param {DIDUrl} did - * @returns {VerificationMethod | undefined} - */ - removeMethod(did) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(did, DIDUrl); - wasm.coredocument_removeMethod(retptr, this.__wbg_ptr, did.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : VerificationMethod.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the first verification method with an `id` property - * matching the provided `query` and the verification relationship - * specified by `scope`, if present. - * @param {DIDUrl | string} query - * @param {MethodScope | undefined} [scope] - * @returns {VerificationMethod | undefined} - */ - resolveMethod(query, scope) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_resolveMethod(retptr, this.__wbg_ptr, addBorrowedObject(query), isLikeNone(scope) ? 0 : addHeapObject(scope)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : VerificationMethod.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Attaches the relationship to the given method, if the method exists. - * - * Note: The method needs to be in the set of verification methods, - * so it cannot be an embedded one. - * @param {DIDUrl} didUrl - * @param {MethodRelationship} relationship - * @returns {boolean} - */ - attachMethodRelationship(didUrl, relationship) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(didUrl, DIDUrl); - wasm.coredocument_attachMethodRelationship(retptr, this.__wbg_ptr, didUrl.__wbg_ptr, relationship); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 !== 0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Detaches the given relationship from the given method, if the method exists. - * @param {DIDUrl} didUrl - * @param {MethodRelationship} relationship - * @returns {boolean} - */ - detachMethodRelationship(didUrl, relationship) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(didUrl, DIDUrl); - wasm.coredocument_detachMethodRelationship(retptr, this.__wbg_ptr, didUrl.__wbg_ptr, relationship); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 !== 0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Decodes and verifies the provided JWS according to the passed `options` and `signatureVerifier`. - * If no `signatureVerifier` argument is provided a default verifier will be used that is (only) capable of - * verifying EdDSA signatures. - * - * Regardless of which options are passed the following conditions must be met in order for a verification attempt to - * take place. - * - The JWS must be encoded according to the JWS compact serialization. - * - The `kid` value in the protected header must be an identifier of a verification method in this DID document, - * or set explicitly in the `options`. - * @param {Jws} jws - * @param {JwsVerificationOptions} options - * @param {IJwsVerifier} signatureVerifier - * @param {string | undefined} [detachedPayload] - * @returns {DecodedJws} - */ - verifyJws(jws, options, signatureVerifier, detachedPayload) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(jws, Jws); - _assertClass(options, JwsVerificationOptions); - var ptr0 = isLikeNone(detachedPayload) ? 0 : passStringToWasm0(detachedPayload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.coredocument_verifyJws(retptr, this.__wbg_ptr, jws.__wbg_ptr, options.__wbg_ptr, addHeapObject(signatureVerifier), ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DecodedJws.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, - * revoke all specified `indices`. - * @param {DIDUrl | string} serviceQuery - * @param {number | number[]} indices - */ - revokeCredentials(serviceQuery, indices) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_revokeCredentials(retptr, this.__wbg_ptr, addBorrowedObject(serviceQuery), addHeapObject(indices)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, - * unrevoke all specified `indices`. - * @param {DIDUrl | string} serviceQuery - * @param {number | number[]} indices - */ - unrevokeCredentials(serviceQuery, indices) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_unrevokeCredentials(retptr, this.__wbg_ptr, addBorrowedObject(serviceQuery), addHeapObject(indices)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the {@link CoreDocument}. - * @returns {CoreDocument} - */ - clone() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_clone(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDocument.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * ### Warning - * This is for internal use only. Do not rely on or call this method. - * @returns {CoreDocument} - */ - _shallowCloneInternal() { - const ret = wasm.coredocument__shallowCloneInternal(this.__wbg_ptr); - return CoreDocument.__wrap(ret); - } - /** - * ### Warning - * This is for internal use only. Do not rely on or call this method. - * @returns {number} - */ - _strongCountInternal() { - const ret = wasm.coredocument__strongCountInternal(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Serializes to a plain JS representation. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a plain JS representation. - * @param {any} json - * @returns {CoreDocument} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.coredocument_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDocument.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Generate new key material in the given `storage` and insert a new verification method with the corresponding - * public key material into the DID document. - * - * - If no fragment is given the `kid` of the generated JWK is used, if it is set, otherwise an error is returned. - * - The `keyType` must be compatible with the given `storage`. `Storage`s are expected to export key type constants - * for that use case. - * - * The fragment of the generated method is returned. - * @param {Storage} storage - * @param {string} keyType - * @param {JwsAlgorithm} alg - * @param {string | undefined} fragment - * @param {MethodScope} scope - * @returns {Promise} - */ - generateMethod(storage, keyType, alg, fragment, scope) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(keyType, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(fragment) ? 0 : passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - _assertClass(scope, MethodScope); - var ptr2 = scope.__destroy_into_raw(); - wasm.coredocument_generateMethod(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, addHeapObject(alg), ptr1, len1, ptr2); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Remove the method identified by the `fragment` from the document and delete the corresponding key material in - * the `storage`. - * @param {Storage} storage - * @param {DIDUrl} id - * @returns {Promise} - */ - purgeMethod(storage, id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - _assertClass(id, DIDUrl); - wasm.coredocument_purgeMethod(retptr, this.__wbg_ptr, storage.__wbg_ptr, id.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sign the `payload` according to `options` with the storage backed private key corresponding to the public key - * material in the verification method identified by the given `fragment. - * - * Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. - * See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). - * @param {Storage} storage - * @param {string} fragment - * @param {string} payload - * @param {JwsSignatureOptions} options - * @returns {Promise} - */ - createJws(storage, fragment, payload, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(options, JwsSignatureOptions); - wasm.coredocument_createJws(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, ptr1, len1, options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Produces a JWT where the payload is produced from the given `credential` - * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - * - * Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` - * of the method identified by `fragment` and the JWS signature will be produced by the corresponding - * private key backed by the `storage` in accordance with the passed `options`. - * - * The `custom_claims` can be used to set additional claims on the resulting JWT. - * @param {Storage} storage - * @param {string} fragment - * @param {Credential} credential - * @param {JwsSignatureOptions} options - * @param {Record | undefined} [custom_claims] - * @returns {Promise} - */ - createCredentialJwt(storage, fragment, credential, options, custom_claims) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(credential, Credential); - _assertClass(options, JwsSignatureOptions); - wasm.coredocument_createCredentialJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, credential.__wbg_ptr, options.__wbg_ptr, isLikeNone(custom_claims) ? 0 : addHeapObject(custom_claims)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Produces a JWT where the payload is produced from the given presentation. - * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - * - * Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` - * of the method identified by `fragment` and the JWS signature will be produced by the corresponding - * private key backed by the `storage` in accordance with the passed `options`. - * @param {Storage} storage - * @param {string} fragment - * @param {Presentation} presentation - * @param {JwsSignatureOptions} signature_options - * @param {JwtPresentationOptions} presentation_options - * @returns {Promise} - */ - createPresentationJwt(storage, fragment, presentation, signature_options, presentation_options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(presentation, Presentation); - _assertClass(signature_options, JwsSignatureOptions); - _assertClass(presentation_options, JwtPresentationOptions); - wasm.coredocument_createPresentationJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, presentation.__wbg_ptr, signature_options.__wbg_ptr, presentation_options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.CoreDocument = CoreDocument; - -const CredentialFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_credential_free(ptr >>> 0, 1)); -/** -*/ -class Credential { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Credential.prototype); - obj.__wbg_ptr = ptr; - CredentialFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CredentialFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_credential_free(ptr, 0); - } - /** - * Returns the base JSON-LD context. - * @returns {string} - */ - static BaseContext() { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_BaseContext(retptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - var ptr1 = r0; - var len1 = r1; - if (r3) { - ptr1 = 0; len1 = 0; - throw takeObject(r2); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Returns the base type. - * @returns {string} - */ - static BaseType() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_BaseType(retptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Constructs a new {@link Credential}. - * @param {ICredential} values - */ - constructor(values) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_new(retptr, addHeapObject(values)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - CredentialFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @param {IDomainLinkageCredential} values - * @returns {Credential} - */ - static createDomainLinkageCredential(values) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_createDomainLinkageCredential(retptr, addHeapObject(values)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Credential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the JSON-LD context(s) applicable to the {@link Credential}. - * @returns {Array>} - */ - context() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_context(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the unique `URI` identifying the {@link Credential} . - * @returns {string | undefined} - */ - id() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_id(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the URIs defining the type of the {@link Credential}. - * @returns {Array} - */ - type() { - const ret = wasm.credential_type(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns a copy of the {@link Credential} subject(s). - * @returns {Array} - */ - credentialSubject() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_credentialSubject(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the issuer of the {@link Credential}. - * @returns {string | Issuer} - */ - issuer() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_issuer(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the timestamp of when the {@link Credential} becomes valid. - * @returns {Timestamp} - */ - issuanceDate() { - const ret = wasm.credential_issuanceDate(this.__wbg_ptr); - return Timestamp.__wrap(ret); - } - /** - * Returns a copy of the timestamp of when the {@link Credential} should no longer be considered valid. - * @returns {Timestamp | undefined} - */ - expirationDate() { - const ret = wasm.credential_expirationDate(this.__wbg_ptr); - return ret === 0 ? undefined : Timestamp.__wrap(ret); - } - /** - * Returns a copy of the information used to determine the current status of the {@link Credential}. - * @returns {Array} - */ - credentialStatus() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_credentialStatus(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the information used to assist in the enforcement of a specific {@link Credential} structure. - * @returns {Array} - */ - credentialSchema() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_credentialSchema(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the service(s) used to refresh an expired {@link Credential}. - * @returns {Array} - */ - refreshService() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_refreshService(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the terms-of-use specified by the {@link Credential} issuer. - * @returns {Array} - */ - termsOfUse() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_termsOfUse(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the human-readable evidence used to support the claims within the {@link Credential}. - * @returns {Array} - */ - evidence() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_evidence(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns whether or not the {@link Credential} must only be contained within a {@link Presentation} - * with a proof issued from the {@link Credential} subject. - * @returns {boolean | undefined} - */ - nonTransferable() { - const ret = wasm.credential_nonTransferable(this.__wbg_ptr); - return ret === 0xFFFFFF ? undefined : ret !== 0; - } - /** - * Optional cryptographic proof, unrelated to JWT. - * @returns {Proof | undefined} - */ - proof() { - const ret = wasm.credential_proof(this.__wbg_ptr); - return ret === 0 ? undefined : Proof.__wrap(ret); - } - /** - * Returns a copy of the miscellaneous properties on the {@link Credential}. - * @returns {Map} - */ - properties() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_properties(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the `proof` property of the {@link Credential}. - * - * Note that this proof is not related to JWT. - * @param {Proof | undefined} [proof] - */ - setProof(proof) { - let ptr0 = 0; - if (!isLikeNone(proof)) { - _assertClass(proof, Proof); - ptr0 = proof.__destroy_into_raw(); - } - wasm.credential_setProof(this.__wbg_ptr, ptr0); - } - /** - * Serializes the `Credential` as a JWT claims set - * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - * - * The resulting object can be used as the payload of a JWS when issuing the credential. - * @param {Record | undefined} [custom_claims] - * @returns {Record} - */ - toJwtClaims(custom_claims) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_toJwtClaims(retptr, this.__wbg_ptr, isLikeNone(custom_claims) ? 0 : addHeapObject(custom_claims)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Credential} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.credential_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Credential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {Credential} - */ - clone() { - const ret = wasm.credential_clone(this.__wbg_ptr); - return Credential.__wrap(ret); - } -} -module.exports.Credential = Credential; - -const CustomMethodDataFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_custommethoddata_free(ptr >>> 0, 1)); -/** -* A custom verification method data format. -*/ -class CustomMethodData { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(CustomMethodData.prototype); - obj.__wbg_ptr = ptr; - CustomMethodDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - CustomMethodDataFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_custommethoddata_free(ptr, 0); - } - /** - * @param {string} name - * @param {any} data - */ - constructor(name, data) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.custommethoddata_new(retptr, ptr0, len0, addHeapObject(data)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - CustomMethodDataFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deep clones the object. - * @returns {CustomMethodData} - */ - clone() { - const ret = wasm.custommethoddata_clone(this.__wbg_ptr); - return CustomMethodData.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.custommethoddata_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {CustomMethodData} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.custommethoddata_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CustomMethodData.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.CustomMethodData = CustomMethodData; - -const DIDUrlFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_didurl_free(ptr >>> 0, 1)); -/** -* A method agnostic DID Url. -*/ -class DIDUrl { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(DIDUrl.prototype); - obj.__wbg_ptr = ptr; - DIDUrlFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DIDUrlFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_didurl_free(ptr, 0); - } - /** - * Parses a {@link DIDUrl} from the input string. - * @param {string} input - * @returns {DIDUrl} - */ - static parse(input) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.didurl_parse(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DIDUrl.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return a copy of the {@link CoreDID} section of the {@link DIDUrl}. - * @returns {CoreDID} - */ - did() { - const ret = wasm.didurl_did(this.__wbg_ptr); - return CoreDID.__wrap(ret); - } - /** - * Return a copy of the relative DID Url as a string, including only the path, query, and fragment. - * @returns {string} - */ - urlStr() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.didurl_urlStr(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the {@link DIDUrl} method fragment, if any. Excludes the leading '#'. - * @returns {string | undefined} - */ - fragment() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.didurl_fragment(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the `fragment` component of the {@link DIDUrl}. - * @param {string | undefined} [value] - */ - setFragment(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - var ptr0 = isLikeNone(value) ? 0 : passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.didurl_setFragment(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the {@link DIDUrl} path. - * @returns {string | undefined} - */ - path() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.didurl_path(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the `path` component of the {@link DIDUrl}. - * @param {string | undefined} [value] - */ - setPath(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - var ptr0 = isLikeNone(value) ? 0 : passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.didurl_setPath(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the {@link DIDUrl} method query, if any. Excludes the leading '?'. - * @returns {string | undefined} - */ - query() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.didurl_query(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the `query` component of the {@link DIDUrl}. - * @param {string | undefined} [value] - */ - setQuery(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - var ptr0 = isLikeNone(value) ? 0 : passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.didurl_setQuery(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Append a string representing a path, query, and/or fragment, returning a new {@link DIDUrl}. - * - * Must begin with a valid delimiter character: '/', '?', '#'. Overwrites the existing URL - * segment and any following segments in order of path, query, then fragment. - * - * I.e. - * - joining a path will clear the query and fragment. - * - joining a query will clear the fragment. - * - joining a fragment will only overwrite the fragment. - * @param {string} segment - * @returns {DIDUrl} - */ - join(segment) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(segment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.didurl_join(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DIDUrl.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the {@link DIDUrl} as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.didurl_toString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.didurl_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {DIDUrl} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.didurl_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DIDUrl.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {DIDUrl} - */ - clone() { - const ret = wasm.didurl_clone(this.__wbg_ptr); - return DIDUrl.__wrap(ret); - } -} -module.exports.DIDUrl = DIDUrl; - -const DecodedJptCredentialFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_decodedjptcredential_free(ptr >>> 0, 1)); -/** -*/ -class DecodedJptCredential { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(DecodedJptCredential.prototype); - obj.__wbg_ptr = ptr; - DecodedJptCredentialFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecodedJptCredentialFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decodedjptcredential_free(ptr, 0); - } - /** - * Deep clones the object. - * @returns {DecodedJptCredential} - */ - clone() { - const ret = wasm.decodedjptcredential_clone(this.__wbg_ptr); - return DecodedJptCredential.__wrap(ret); - } - /** - * Returns the {@link Credential} embedded into this JPT. - * @returns {Credential} - */ - credential() { - const ret = wasm.decodedjptcredential_credential(this.__wbg_ptr); - return Credential.__wrap(ret); - } - /** - * Returns the custom claims parsed from the JPT. - * @returns {Map} - */ - customClaims() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.decodedjptcredential_customClaims(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {JwpIssued} - */ - decodedJwp() { - const ret = wasm.decodedjptcredential_decodedJwp(this.__wbg_ptr); - return JwpIssued.__wrap(ret); - } -} -module.exports.DecodedJptCredential = DecodedJptCredential; - -const DecodedJptPresentationFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_decodedjptpresentation_free(ptr >>> 0, 1)); -/** -*/ -class DecodedJptPresentation { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(DecodedJptPresentation.prototype); - obj.__wbg_ptr = ptr; - DecodedJptPresentationFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecodedJptPresentationFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decodedjptpresentation_free(ptr, 0); - } - /** - * Deep clones the object. - * @returns {DecodedJptPresentation} - */ - clone() { - const ret = wasm.decodedjptpresentation_clone(this.__wbg_ptr); - return DecodedJptPresentation.__wrap(ret); - } - /** - * Returns the {@link Credential} embedded into this JPT. - * @returns {Credential} - */ - credential() { - const ret = wasm.decodedjptpresentation_credential(this.__wbg_ptr); - return Credential.__wrap(ret); - } - /** - * Returns the custom claims parsed from the JPT. - * @returns {Map} - */ - customClaims() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.decodedjptpresentation_customClaims(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the `aud` property parsed from the JWT claims. - * @returns {string | undefined} - */ - aud() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.decodedjptpresentation_aud(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.DecodedJptPresentation = DecodedJptPresentation; - -const DecodedJwsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_decodedjws_free(ptr >>> 0, 1)); -/** -* A cryptographically verified decoded token from a JWS. -* -* Contains the decoded headers and the raw claims. -*/ -class DecodedJws { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(DecodedJws.prototype); - obj.__wbg_ptr = ptr; - DecodedJwsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecodedJwsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decodedjws_free(ptr, 0); - } - /** - * Returns a copy of the parsed claims represented as a string. - * - * # Errors - * An error is thrown if the claims cannot be represented as a string. - * - * This error can only occur if the Token was decoded from a detached payload. - * @returns {string} - */ - claims() { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.decodedjws_claims(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - var ptr1 = r0; - var len1 = r1; - if (r3) { - ptr1 = 0; len1 = 0; - throw takeObject(r2); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Return a copy of the parsed claims represented as an array of bytes. - * @returns {Uint8Array} - */ - claimsBytes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.decodedjws_claimsBytes(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the protected header. - * @returns {JwsHeader} - */ - protectedHeader() { - const ret = wasm.decodedjws_protectedHeader(this.__wbg_ptr); - return JwsHeader.__wrap(ret); - } - /** - * Deep clones the object. - * @returns {DecodedJws} - */ - clone() { - const ret = wasm.decodedjws_clone(this.__wbg_ptr); - return DecodedJws.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.decodedjws_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.DecodedJws = DecodedJws; - -const DecodedJwtCredentialFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_decodedjwtcredential_free(ptr >>> 0, 1)); -/** -* A cryptographically verified and decoded Credential. -* -* Note that having an instance of this type only means the JWS it was constructed from was verified. -* It does not imply anything about a potentially present proof property on the credential itself. -*/ -class DecodedJwtCredential { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(DecodedJwtCredential.prototype); - obj.__wbg_ptr = ptr; - DecodedJwtCredentialFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecodedJwtCredentialFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decodedjwtcredential_free(ptr, 0); - } - /** - * Returns a copy of the credential parsed to the [Verifiable Credentials Data model](https://www.w3.org/TR/vc-data-model/). - * @returns {Credential} - */ - credential() { - const ret = wasm.decodedjwtcredential_credential(this.__wbg_ptr); - return Credential.__wrap(ret); - } - /** - * Returns a copy of the protected header parsed from the decoded JWS. - * @returns {JwsHeader} - */ - protectedHeader() { - const ret = wasm.decodedjwtcredential_protectedHeader(this.__wbg_ptr); - return JwsHeader.__wrap(ret); - } - /** - * The custom claims parsed from the JWT. - * @returns {Record | undefined} - */ - customClaims() { - const ret = wasm.decodedjwtcredential_customClaims(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Consumes the object and returns the decoded credential. - * - * ### Warning - * - * This destroys the {@link DecodedJwtCredential} object. - * @returns {Credential} - */ - intoCredential() { - const ptr = this.__destroy_into_raw(); - const ret = wasm.decodedjwtcredential_intoCredential(ptr); - return Credential.__wrap(ret); - } -} -module.exports.DecodedJwtCredential = DecodedJwtCredential; - -const DecodedJwtPresentationFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_decodedjwtpresentation_free(ptr >>> 0, 1)); -/** -* A cryptographically verified and decoded presentation. -* -* Note that having an instance of this type only means the JWS it was constructed from was verified. -* It does not imply anything about a potentially present proof property on the presentation itself. -*/ -class DecodedJwtPresentation { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(DecodedJwtPresentation.prototype); - obj.__wbg_ptr = ptr; - DecodedJwtPresentationFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DecodedJwtPresentationFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_decodedjwtpresentation_free(ptr, 0); - } - /** - * @returns {Presentation} - */ - presentation() { - const ret = wasm.decodedjwtpresentation_presentation(this.__wbg_ptr); - return Presentation.__wrap(ret); - } - /** - * Returns a copy of the protected header parsed from the decoded JWS. - * @returns {JwsHeader} - */ - protectedHeader() { - const ret = wasm.decodedjwtpresentation_protectedHeader(this.__wbg_ptr); - return JwsHeader.__wrap(ret); - } - /** - * Consumes the object and returns the decoded presentation. - * - * ### Warning - * This destroys the {@link DecodedJwtPresentation} object. - * @returns {Presentation} - */ - intoPresentation() { - const ptr = this.__destroy_into_raw(); - const ret = wasm.decodedjwtpresentation_intoPresentation(ptr); - return Presentation.__wrap(ret); - } - /** - * The expiration date parsed from the JWT claims. - * @returns {Timestamp | undefined} - */ - expirationDate() { - const ret = wasm.decodedjwtpresentation_expirationDate(this.__wbg_ptr); - return ret === 0 ? undefined : Timestamp.__wrap(ret); - } - /** - * The issuance date parsed from the JWT claims. - * @returns {Timestamp | undefined} - */ - issuanceDate() { - const ret = wasm.decodedjwtpresentation_issuanceDate(this.__wbg_ptr); - return ret === 0 ? undefined : Timestamp.__wrap(ret); - } - /** - * The `aud` property parsed from JWT claims. - * @returns {string | undefined} - */ - audience() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.decodedjwtpresentation_audience(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * The custom claims parsed from the JWT. - * @returns {Record | undefined} - */ - customClaims() { - const ret = wasm.decodedjwtpresentation_customClaims(this.__wbg_ptr); - return takeObject(ret); - } -} -module.exports.DecodedJwtPresentation = DecodedJwtPresentation; - -const DisclosureFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_disclosure_free(ptr >>> 0, 1)); -/** -* Represents an elements constructing a disclosure. -* Object properties and array elements disclosures are supported. -* -* See: https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-disclosures -*/ -class Disclosure { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Disclosure.prototype); - obj.__wbg_ptr = ptr; - DisclosureFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DisclosureFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_disclosure_free(ptr, 0); - } - /** - * @param {string} salt - * @param {string | undefined} claim_name - * @param {any} claim_value - */ - constructor(salt, claim_name, claim_value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(claim_name) ? 0 : passStringToWasm0(claim_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - wasm.disclosure_new(retptr, ptr0, len0, ptr1, len1, addHeapObject(claim_value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - DisclosureFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Parses a Base64 encoded disclosure into a `Disclosure`. - * - * ## Error - * - * Returns an `InvalidDisclosure` if input is not a valid disclosure. - * @param {string} disclosure - * @returns {Disclosure} - */ - static parse(disclosure) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(disclosure, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.disclosure_parse(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Disclosure.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the base64url-encoded string. - * @returns {string} - */ - disclosure() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.disclosure_disclosure(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the base64url-encoded string. - * @returns {string} - */ - toEncodedString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.disclosure_disclosure(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the base64url-encoded string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.disclosure_disclosure(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the salt value. - * @returns {string} - */ - salt() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.disclosure_salt(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the claim name, optional for array elements. - * @returns {string | undefined} - */ - claimName() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.disclosure_claimName(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the claim Value which can be of any type. - * @returns {any} - */ - claimValue() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.disclosure_claimValue(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.disclosure_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Disclosure} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.disclosure_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Disclosure.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.Disclosure = Disclosure; - -const DomainLinkageConfigurationFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_domainlinkageconfiguration_free(ptr >>> 0, 1)); -/** -* DID Configuration Resource which contains Domain Linkage Credentials. -* It can be placed in an origin's `.well-known` directory to prove linkage between the origin and a DID. -* See: -* -* Note: -* - Only the [JSON Web Token Proof Format](https://identity.foundation/.well-known/resources/did-configuration/#json-web-token-proof-format) -*/ -class DomainLinkageConfiguration { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(DomainLinkageConfiguration.prototype); - obj.__wbg_ptr = ptr; - DomainLinkageConfigurationFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DomainLinkageConfigurationFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_domainlinkageconfiguration_free(ptr, 0); - } - /** - * Constructs a new {@link DomainLinkageConfiguration}. - * @param {Array} linkedDids - */ - constructor(linkedDids) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.domainlinkageconfiguration_new(retptr, addBorrowedObject(linkedDids)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - DomainLinkageConfigurationFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * List of the Domain Linkage Credentials. - * @returns {Array} - */ - linkedDids() { - const ret = wasm.domainlinkageconfiguration_linkedDids(this.__wbg_ptr); - return takeObject(ret); - } - /** - * List of the issuers of the Domain Linkage Credentials. - * @returns {Array} - */ - issuers() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.domainlinkageconfiguration_issuers(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.domainlinkageconfiguration_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {DomainLinkageConfiguration} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.domainlinkageconfiguration_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DomainLinkageConfiguration.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {DomainLinkageConfiguration} - */ - clone() { - const ret = wasm.domainlinkageconfiguration_clone(this.__wbg_ptr); - return DomainLinkageConfiguration.__wrap(ret); - } -} -module.exports.DomainLinkageConfiguration = DomainLinkageConfiguration; - -const DurationFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_duration_free(ptr >>> 0, 1)); -/** -* A span of time. -*/ -class Duration { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Duration.prototype); - obj.__wbg_ptr = ptr; - DurationFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - DurationFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_duration_free(ptr, 0); - } - /** - * Create a new {@link Duration} with the given number of seconds. - * @param {number} seconds - * @returns {Duration} - */ - static seconds(seconds) { - const ret = wasm.duration_seconds(seconds); - return Duration.__wrap(ret); - } - /** - * Create a new {@link Duration} with the given number of minutes. - * @param {number} minutes - * @returns {Duration} - */ - static minutes(minutes) { - const ret = wasm.duration_minutes(minutes); - return Duration.__wrap(ret); - } - /** - * Create a new {@link Duration} with the given number of hours. - * @param {number} hours - * @returns {Duration} - */ - static hours(hours) { - const ret = wasm.duration_hours(hours); - return Duration.__wrap(ret); - } - /** - * Create a new {@link Duration} with the given number of days. - * @param {number} days - * @returns {Duration} - */ - static days(days) { - const ret = wasm.duration_days(days); - return Duration.__wrap(ret); - } - /** - * Create a new {@link Duration} with the given number of weeks. - * @param {number} weeks - * @returns {Duration} - */ - static weeks(weeks) { - const ret = wasm.duration_weeks(weeks); - return Duration.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.duration_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Duration} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.duration_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Duration.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.Duration = Duration; - -const EdDSAJwsVerifierFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_eddsajwsverifier_free(ptr >>> 0, 1)); -/** -* An implementor of `IJwsVerifier` that can handle the -* `EdDSA` algorithm. -*/ -class EdDSAJwsVerifier { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - EdDSAJwsVerifierFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_eddsajwsverifier_free(ptr, 0); - } - /** - * Constructs an EdDSAJwsVerifier. - */ - constructor() { - const ret = wasm.eddsajwsverifier_new(); - this.__wbg_ptr = ret >>> 0; - EdDSAJwsVerifierFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Verify a JWS signature secured with the `EdDSA` algorithm. - * Only the `Ed25519` curve is supported for now. - * - * This function is useful when one is building an `IJwsVerifier` that extends the default provided by - * the IOTA Identity Framework. - * - * # Warning - * - * This function does not check whether `alg = EdDSA` in the protected header. Callers are expected to assert this - * prior to calling the function. - * @param {JwsAlgorithm} alg - * @param {Uint8Array} signingInput - * @param {Uint8Array} decodedSignature - * @param {Jwk} publicKey - */ - verify(alg, signingInput, decodedSignature, publicKey) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(signingInput, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArray8ToWasm0(decodedSignature, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(publicKey, Jwk); - wasm.eddsajwsverifier_verify(retptr, this.__wbg_ptr, addHeapObject(alg), ptr0, len0, ptr1, len1, publicKey.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.EdDSAJwsVerifier = EdDSAJwsVerifier; - -const IotaDIDFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_iotadid_free(ptr >>> 0, 1)); -/** -* A DID conforming to the IOTA DID method specification. -* -* @typicalname did -*/ -class IotaDID { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(IotaDID.prototype); - obj.__wbg_ptr = ptr; - IotaDIDFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - METHOD: this.METHOD, - DEFAULT_NETWORK: this.DEFAULT_NETWORK, - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - IotaDIDFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_iotadid_free(ptr, 0); - } - /** - * The IOTA DID method name (`"iota"`). - * @returns {string} - */ - static get METHOD() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_static_default_network(retptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The default Tangle network (`"iota"`). - * @returns {string} - */ - static get DEFAULT_NETWORK() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_static_default_network(retptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Constructs a new {@link IotaDID} from a byte representation of the tag and the given - * network name. - * - * See also {@link IotaDID.placeholder}. - * @param {Uint8Array} bytes - * @param {string} network - */ - constructor(bytes, network) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - wasm.iotadid_new(retptr, ptr0, len0, ptr1, len1); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - IotaDIDFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Constructs a new {@link IotaDID} from a hex representation of an Alias Id and the given - * network name. - * @param {string} aliasId - * @param {string} network - * @returns {IotaDID} - */ - static fromAliasId(aliasId, network) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(aliasId, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - wasm.iotadid_fromAliasId(retptr, ptr0, len0, ptr1, len1); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Creates a new placeholder {@link IotaDID} with the given network name. - * - * E.g. `did:iota:smr:0x0000000000000000000000000000000000000000000000000000000000000000`. - * @param {string} network - * @returns {IotaDID} - */ - static placeholder(network) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.iotadid_placeholder(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Parses a {@link IotaDID} from the input string. - * @param {string} input - * @returns {IotaDID} - */ - static parse(input) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.iotadid_parse(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the Tangle network name of the {@link IotaDID}. - * @returns {string} - */ - network() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_network(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the unique tag of the {@link IotaDID}. - * @returns {string} - */ - tag() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_tag(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns the DID represented as a {@link CoreDID}. - * @returns {CoreDID} - */ - toCoreDid() { - const ret = wasm.iotadid_toCoreDid(this.__wbg_ptr); - return CoreDID.__wrap(ret); - } - /** - * Returns the `DID` scheme. - * - * E.g. - * - `"did:example:12345678" -> "did"` - * - `"did:iota:main:12345678" -> "did"` - * @returns {string} - */ - scheme() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_scheme(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns the `DID` authority: the method name and method-id. - * - * E.g. - * - `"did:example:12345678" -> "example:12345678"` - * - `"did:iota:main:12345678" -> "iota:main:12345678"` - * @returns {string} - */ - authority() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_authority(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns the `DID` method name. - * - * E.g. - * - `"did:example:12345678" -> "example"` - * - `"did:iota:main:12345678" -> "iota"` - * @returns {string} - */ - method() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_method(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns the `DID` method-specific ID. - * - * E.g. - * - `"did:example:12345678" -> "12345678"` - * - `"did:iota:main:12345678" -> "main:12345678"` - * @returns {string} - */ - methodId() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_methodId(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Construct a new {@link DIDUrl} by joining with a relative DID Url string. - * @param {string} segment - * @returns {DIDUrl} - */ - join(segment) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(segment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.iotadid_join(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DIDUrl.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Clones the `DID` into a {@link DIDUrl}. - * @returns {DIDUrl} - */ - toUrl() { - const ret = wasm.iotadid_toUrl(this.__wbg_ptr); - return DIDUrl.__wrap(ret); - } - /** - * Returns the hex-encoded AliasId with a '0x' prefix, from the DID tag. - * @returns {string} - */ - toAliasId() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_toAliasId(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Converts the `DID` into a {@link DIDUrl}, consuming it. - * @returns {DIDUrl} - */ - intoUrl() { - const ptr = this.__destroy_into_raw(); - const ret = wasm.iotadid_intoUrl(ptr); - return DIDUrl.__wrap(ret); - } - /** - * Returns the `DID` as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_toString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {IotaDID} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadid_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {IotaDID} - */ - clone() { - const ret = wasm.iotadid_clone(this.__wbg_ptr); - return IotaDID.__wrap(ret); - } -} -module.exports.IotaDID = IotaDID; - -const IotaDocumentFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_iotadocument_free(ptr >>> 0, 1)); -/** -* A DID Document adhering to the IOTA DID method specification. -* -* Note: All methods that involve reading from this class may potentially raise an error -* if the object is being concurrently modified. -*/ -class IotaDocument { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(IotaDocument.prototype); - obj.__wbg_ptr = ptr; - IotaDocumentFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - IotaDocumentFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_iotadocument_free(ptr, 0); - } - /** - * Constructs an empty IOTA DID Document with a {@link IotaDID.placeholder} identifier - * for the given `network`. - * @param {string} network - */ - constructor(network) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.iotadocument_new(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - IotaDocumentFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Constructs an empty DID Document with the given identifier. - * @param {IotaDID} id - * @returns {IotaDocument} - */ - static newWithId(id) { - _assertClass(id, IotaDID); - const ret = wasm.iotadocument_newWithId(id.__wbg_ptr); - return IotaDocument.__wrap(ret); - } - /** - * Returns a copy of the DID Document `id`. - * @returns {IotaDID} - */ - id() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_id(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the list of document controllers. - * - * NOTE: controllers are determined by the `state_controller` unlock condition of the output - * during resolution and are omitted when publishing. - * @returns {IotaDID[]} - */ - controller() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_controller(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the controllers of the document. - * - * Note: Duplicates will be ignored. - * Use `null` to remove all controllers. - * @param {IotaDID[] | null} controller - */ - setController(controller) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_setController(retptr, this.__wbg_ptr, addBorrowedObject(controller)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Returns a copy of the document's `alsoKnownAs` set. - * @returns {Array} - */ - alsoKnownAs() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_alsoKnownAs(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the `alsoKnownAs` property in the DID document. - * @param {string | string[] | null} urls - */ - setAlsoKnownAs(urls) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_setAlsoKnownAs(retptr, this.__wbg_ptr, addBorrowedObject(urls)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Returns a copy of the custom DID Document properties. - * @returns {Map} - */ - properties() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_properties(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a custom property in the DID Document. - * If the value is set to `null`, the custom property will be removed. - * - * ### WARNING - * - * This method can overwrite existing properties like `id` and result in an invalid document. - * @param {string} key - * @param {any} value - */ - setPropertyUnchecked(key, value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.iotadocument_setPropertyUnchecked(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Return a set of all {@link Service} in the document. - * @returns {Service[]} - */ - service() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_service(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Add a new {@link Service} to the document. - * - * Returns `true` if the service was added. - * @param {Service} service - */ - insertService(service) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(service, Service); - wasm.iotadocument_insertService(retptr, this.__wbg_ptr, service.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Remove a {@link Service} identified by the given {@link DIDUrl} from the document. - * - * Returns `true` if a service was removed. - * @param {DIDUrl} did - * @returns {Service | undefined} - */ - removeService(did) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(did, DIDUrl); - wasm.iotadocument_removeService(retptr, this.__wbg_ptr, did.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : Service.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the first {@link Service} with an `id` property matching the provided `query`, - * if present. - * @param {DIDUrl | string} query - * @returns {Service | undefined} - */ - resolveService(query) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_resolveService(retptr, this.__wbg_ptr, addBorrowedObject(query)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : Service.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Returns a list of all {@link VerificationMethod} in the DID Document, - * whose verification relationship matches `scope`. - * - * If `scope` is not set, a list over the **embedded** methods is returned. - * @param {MethodScope | undefined} [scope] - * @returns {VerificationMethod[]} - */ - methods(scope) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_methods(retptr, this.__wbg_ptr, isLikeNone(scope) ? 0 : addHeapObject(scope)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Adds a new `method` to the document in the given `scope`. - * @param {VerificationMethod} method - * @param {MethodScope} scope - */ - insertMethod(method, scope) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(method, VerificationMethod); - _assertClass(scope, MethodScope); - wasm.iotadocument_insertMethod(retptr, this.__wbg_ptr, method.__wbg_ptr, scope.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Removes all references to the specified Verification Method. - * @param {DIDUrl} did - * @returns {VerificationMethod | undefined} - */ - removeMethod(did) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(did, DIDUrl); - wasm.iotadocument_removeMethod(retptr, this.__wbg_ptr, did.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : VerificationMethod.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the first verification method with an `id` property - * matching the provided `query` and the verification relationship - * specified by `scope`, if present. - * @param {DIDUrl | string} query - * @param {MethodScope | undefined} [scope] - * @returns {VerificationMethod | undefined} - */ - resolveMethod(query, scope) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_resolveMethod(retptr, this.__wbg_ptr, addBorrowedObject(query), isLikeNone(scope) ? 0 : addHeapObject(scope)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : VerificationMethod.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Attaches the relationship to the given method, if the method exists. - * - * Note: The method needs to be in the set of verification methods, - * so it cannot be an embedded one. - * @param {DIDUrl} didUrl - * @param {MethodRelationship} relationship - * @returns {boolean} - */ - attachMethodRelationship(didUrl, relationship) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(didUrl, DIDUrl); - wasm.iotadocument_attachMethodRelationship(retptr, this.__wbg_ptr, didUrl.__wbg_ptr, relationship); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 !== 0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Detaches the given relationship from the given method, if the method exists. - * @param {DIDUrl} didUrl - * @param {MethodRelationship} relationship - * @returns {boolean} - */ - detachMethodRelationship(didUrl, relationship) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(didUrl, DIDUrl); - wasm.iotadocument_detachMethodRelationship(retptr, this.__wbg_ptr, didUrl.__wbg_ptr, relationship); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 !== 0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Decodes and verifies the provided JWS according to the passed `options` and `signatureVerifier`. - * If no `signatureVerifier` argument is provided a default verifier will be used that is (only) capable of - * verifying EdDSA signatures. - * - * Regardless of which options are passed the following conditions must be met in order for a verification attempt to - * take place. - * - The JWS must be encoded according to the JWS compact serialization. - * - The `kid` value in the protected header must be an identifier of a verification method in this DID document. - * @param {Jws} jws - * @param {JwsVerificationOptions} options - * @param {IJwsVerifier} signatureVerifier - * @param {string | undefined} [detachedPayload] - * @returns {DecodedJws} - */ - verifyJws(jws, options, signatureVerifier, detachedPayload) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(jws, Jws); - _assertClass(options, JwsVerificationOptions); - var ptr0 = isLikeNone(detachedPayload) ? 0 : passStringToWasm0(detachedPayload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.iotadocument_verifyJws(retptr, this.__wbg_ptr, jws.__wbg_ptr, options.__wbg_ptr, addHeapObject(signatureVerifier), ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DecodedJws.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes the document for inclusion in an Alias Output's state metadata - * with the default {@link StateMetadataEncoding}. - * @returns {Uint8Array} - */ - pack() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_pack(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes the document for inclusion in an Alias Output's state metadata. - * @param {StateMetadataEncoding} encoding - * @returns {Uint8Array} - */ - packWithEncoding(encoding) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_packWithEncoding(retptr, this.__wbg_ptr, encoding); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes the document from an Alias Output. - * - * If `allowEmpty` is true, this will return an empty DID document marked as `deactivated` - * if `stateMetadata` is empty. - * - * The `tokenSupply` must be equal to the token supply of the network the DID is associated with. - * - * NOTE: `did` is required since it is omitted from the serialized DID Document and - * cannot be inferred from the state metadata. It also indicates the network, which is not - * encoded in the `AliasId` alone. - * @param {IotaDID} did - * @param {AliasOutputBuilderParams} aliasOutput - * @param {boolean} allowEmpty - * @returns {IotaDocument} - */ - static unpackFromOutput(did, aliasOutput, allowEmpty) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(did, IotaDID); - wasm.iotadocument_unpackFromOutput(retptr, did.__wbg_ptr, addHeapObject(aliasOutput), allowEmpty); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDocument.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns all DID documents of the Alias Outputs contained in the block's transaction payload - * outputs, if any. - * - * Errors if any Alias Output does not contain a valid or empty DID Document. - * @param {string} network - * @param {Block} block - * @returns {IotaDocument[]} - */ - static unpackFromBlock(network, block) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(network, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.iotadocument_unpackFromBlock(retptr, ptr0, len0, addBorrowedObject(block)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Returns a copy of the metadata associated with this document. - * - * NOTE: Copies all the metadata. See also `metadataCreated`, `metadataUpdated`, - * `metadataPreviousMessageId`, `metadataProof` if only a subset of the metadata required. - * @returns {IotaDocumentMetadata} - */ - metadata() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_metadata(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDocumentMetadata.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the timestamp of when the DID document was created. - * @returns {Timestamp | undefined} - */ - metadataCreated() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_metadataCreated(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : Timestamp.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the timestamp of when the DID document was created. - * @param {Timestamp | undefined} timestamp - */ - setMetadataCreated(timestamp) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_setMetadataCreated(retptr, this.__wbg_ptr, addHeapObject(timestamp)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the timestamp of the last DID document update. - * @returns {Timestamp | undefined} - */ - metadataUpdated() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_metadataUpdated(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0 ? undefined : Timestamp.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the timestamp of the last DID document update. - * @param {Timestamp | undefined} timestamp - */ - setMetadataUpdated(timestamp) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_setMetadataUpdated(retptr, this.__wbg_ptr, addHeapObject(timestamp)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the deactivated status of the DID document. - * @returns {boolean | undefined} - */ - metadataDeactivated() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_metadataDeactivated(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 === 0xFFFFFF ? undefined : r0 !== 0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the deactivated status of the DID document. - * @param {boolean | undefined} [deactivated] - */ - setMetadataDeactivated(deactivated) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_setMetadataDeactivated(retptr, this.__wbg_ptr, isLikeNone(deactivated) ? 0xFFFFFF : deactivated ? 1 : 0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the Bech32-encoded state controller address, if present. - * @returns {string | undefined} - */ - metadataStateControllerAddress() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_metadataStateControllerAddress(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the Bech32-encoded governor address, if present. - * @returns {string | undefined} - */ - metadataGovernorAddress() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_metadataGovernorAddress(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a custom property in the document metadata. - * If the value is set to `null`, the custom property will be removed. - * @param {string} key - * @param {any} value - */ - setMetadataPropertyUnchecked(key, value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.iotadocument_setMetadataPropertyUnchecked(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, - * revoke all specified `indices`. - * @param {DIDUrl | string} serviceQuery - * @param {number | number[]} indices - */ - revokeCredentials(serviceQuery, indices) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_revokeCredentials(retptr, this.__wbg_ptr, addBorrowedObject(serviceQuery), addHeapObject(indices)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * If the document has a {@link RevocationBitmap} service identified by `serviceQuery`, - * unrevoke all specified `indices`. - * @param {DIDUrl | string} serviceQuery - * @param {number | number[]} indices - */ - unrevokeCredentials(serviceQuery, indices) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_unrevokeCredentials(retptr, this.__wbg_ptr, addBorrowedObject(serviceQuery), addHeapObject(indices)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Returns a deep clone of the {@link IotaDocument}. - * @returns {IotaDocument} - */ - clone() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_clone(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDocument.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * ### Warning - * This is for internal use only. Do not rely on or call this method. - * @returns {IotaDocument} - */ - _shallowCloneInternal() { - const ret = wasm.iotadocument__shallowCloneInternal(this.__wbg_ptr); - return IotaDocument.__wrap(ret); - } - /** - * ### Warning - * This is for internal use only. Do not rely on or call this method. - * @returns {number} - */ - _strongCountInternal() { - const ret = wasm.iotadocument__strongCountInternal(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Serializes to a plain JS representation. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a plain JS representation. - * @param {any} json - * @returns {IotaDocument} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDocument.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Transforms the {@link IotaDocument} to its {@link CoreDocument} representation. - * @returns {CoreDocument} - */ - toCoreDocument() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocument_toCoreDocument(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDocument.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Generate new key material in the given `storage` and insert a new verification method with the corresponding - * public key material into the DID document. - * - * - If no fragment is given the `kid` of the generated JWK is used, if it is set, otherwise an error is returned. - * - The `keyType` must be compatible with the given `storage`. `Storage`s are expected to export key type constants - * for that use case. - * - * The fragment of the generated method is returned. - * @param {Storage} storage - * @param {string} keyType - * @param {JwsAlgorithm} alg - * @param {string | undefined} fragment - * @param {MethodScope} scope - * @returns {Promise} - */ - generateMethod(storage, keyType, alg, fragment, scope) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(keyType, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(fragment) ? 0 : passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - _assertClass(scope, MethodScope); - var ptr2 = scope.__destroy_into_raw(); - wasm.iotadocument_generateMethod(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, addHeapObject(alg), ptr1, len1, ptr2); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Remove the method identified by the given fragment from the document and delete the corresponding key material in - * the given `storage`. - * @param {Storage} storage - * @param {DIDUrl} id - * @returns {Promise} - */ - purgeMethod(storage, id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - _assertClass(id, DIDUrl); - wasm.iotadocument_purgeMethod(retptr, this.__wbg_ptr, storage.__wbg_ptr, id.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sign the `payload` according to `options` with the storage backed private key corresponding to the public key - * material in the verification method identified by the given `fragment. - * - * Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. - * See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). - * - * @deprecated Use `createJws()` instead. - * @param {Storage} storage - * @param {string} fragment - * @param {string} payload - * @param {JwsSignatureOptions} options - * @returns {Promise} - */ - createJwt(storage, fragment, payload, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(options, JwsSignatureOptions); - wasm.iotadocument_createJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, ptr1, len1, options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sign the `payload` according to `options` with the storage backed private key corresponding to the public key - * material in the verification method identified by the given `fragment. - * - * Upon success a string representing a JWS encoded according to the Compact JWS Serialization format is returned. - * See [RFC7515 section 3.1](https://www.rfc-editor.org/rfc/rfc7515#section-3.1). - * @param {Storage} storage - * @param {string} fragment - * @param {string} payload - * @param {JwsSignatureOptions} options - * @returns {Promise} - */ - createJws(storage, fragment, payload, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(payload, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(options, JwsSignatureOptions); - wasm.iotadocument_createJws(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, ptr1, len1, options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Produces a JWS where the payload is produced from the given `credential` - * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - * - * Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` - * of the method identified by `fragment` and the JWS signature will be produced by the corresponding - * private key backed by the `storage` in accordance with the passed `options`. - * - * The `custom_claims` can be used to set additional claims on the resulting JWT. - * @param {Storage} storage - * @param {string} fragment - * @param {Credential} credential - * @param {JwsSignatureOptions} options - * @param {Record | undefined} [custom_claims] - * @returns {Promise} - */ - createCredentialJwt(storage, fragment, credential, options, custom_claims) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(credential, Credential); - _assertClass(options, JwsSignatureOptions); - wasm.iotadocument_createCredentialJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, credential.__wbg_ptr, options.__wbg_ptr, isLikeNone(custom_claims) ? 0 : addHeapObject(custom_claims)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Produces a JWT where the payload is produced from the given presentation. - * in accordance with [VC Data Model v1.1](https://www.w3.org/TR/vc-data-model/#json-web-token). - * - * Unless the `kid` is explicitly set in the options, the `kid` in the protected header is the `id` - * of the method identified by `fragment` and the JWS signature will be produced by the corresponding - * private key backed by the `storage` in accordance with the passed `options`. - * @param {Storage} storage - * @param {string} fragment - * @param {Presentation} presentation - * @param {JwsSignatureOptions} signature_options - * @param {JwtPresentationOptions} presentation_options - * @returns {Promise} - */ - createPresentationJwt(storage, fragment, presentation, signature_options, presentation_options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(presentation, Presentation); - _assertClass(signature_options, JwsSignatureOptions); - _assertClass(presentation_options, JwtPresentationOptions); - wasm.iotadocument_createPresentationJwt(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, presentation.__wbg_ptr, signature_options.__wbg_ptr, presentation_options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @param {Storage} storage - * @param {ProofAlgorithm} alg - * @param {string | undefined} fragment - * @param {MethodScope} scope - * @returns {Promise} - */ - generateMethodJwp(storage, alg, fragment, scope) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - var ptr0 = isLikeNone(fragment) ? 0 : passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - _assertClass(scope, MethodScope); - var ptr1 = scope.__destroy_into_raw(); - wasm.iotadocument_generateMethodJwp(retptr, this.__wbg_ptr, storage.__wbg_ptr, alg, ptr0, len0, ptr1); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @param {Storage} storage - * @param {string} fragment - * @param {JptClaims} jpt_claims - * @param {JwpCredentialOptions} options - * @returns {Promise} - */ - createIssuedJwp(storage, fragment, jpt_claims, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(storage, Storage); - const ptr0 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(options, JwpCredentialOptions); - var ptr1 = options.__destroy_into_raw(); - wasm.iotadocument_createIssuedJwp(retptr, this.__wbg_ptr, storage.__wbg_ptr, ptr0, len0, addHeapObject(jpt_claims), ptr1); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @param {SelectiveDisclosurePresentation} presentation - * @param {string} method_id - * @param {JwpPresentationOptions} options - * @returns {Promise} - */ - createPresentedJwp(presentation, method_id, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(presentation, SelectiveDisclosurePresentation); - var ptr0 = presentation.__destroy_into_raw(); - const ptr1 = passStringToWasm0(method_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(options, JwpPresentationOptions); - var ptr2 = options.__destroy_into_raw(); - wasm.iotadocument_createPresentedJwp(retptr, this.__wbg_ptr, ptr0, ptr1, len1, ptr2); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @param {Credential} credential - * @param {Storage} storage - * @param {string} fragment - * @param {JwpCredentialOptions} options - * @param {Map | undefined} [custom_claims] - * @returns {Promise} - */ - createCredentialJpt(credential, storage, fragment, options, custom_claims) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - var ptr0 = credential.__destroy_into_raw(); - _assertClass(storage, Storage); - const ptr1 = passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(options, JwpCredentialOptions); - var ptr2 = options.__destroy_into_raw(); - wasm.iotadocument_createCredentialJpt(retptr, this.__wbg_ptr, ptr0, storage.__wbg_ptr, ptr1, len1, ptr2, isLikeNone(custom_claims) ? 0 : addHeapObject(custom_claims)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @param {SelectiveDisclosurePresentation} presentation - * @param {string} method_id - * @param {JwpPresentationOptions} options - * @returns {Promise} - */ - createPresentationJpt(presentation, method_id, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(presentation, SelectiveDisclosurePresentation); - var ptr0 = presentation.__destroy_into_raw(); - const ptr1 = passStringToWasm0(method_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(options, JwpPresentationOptions); - var ptr2 = options.__destroy_into_raw(); - wasm.iotadocument_createPresentationJpt(retptr, this.__wbg_ptr, ptr0, ptr1, len1, ptr2); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.IotaDocument = IotaDocument; - -const IotaDocumentMetadataFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_iotadocumentmetadata_free(ptr >>> 0, 1)); -/** -* Additional attributes related to an IOTA DID Document. -*/ -class IotaDocumentMetadata { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(IotaDocumentMetadata.prototype); - obj.__wbg_ptr = ptr; - IotaDocumentMetadataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - IotaDocumentMetadataFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_iotadocumentmetadata_free(ptr, 0); - } - /** - * Returns a copy of the timestamp of when the DID document was created. - * @returns {Timestamp | undefined} - */ - created() { - const ret = wasm.iotadocumentmetadata_created(this.__wbg_ptr); - return ret === 0 ? undefined : Timestamp.__wrap(ret); - } - /** - * Returns a copy of the timestamp of the last DID document update. - * @returns {Timestamp | undefined} - */ - updated() { - const ret = wasm.iotadocumentmetadata_updated(this.__wbg_ptr); - return ret === 0 ? undefined : Timestamp.__wrap(ret); - } - /** - * Returns a copy of the deactivated status of the DID document. - * @returns {boolean | undefined} - */ - deactivated() { - const ret = wasm.iotadocumentmetadata_deactivated(this.__wbg_ptr); - return ret === 0xFFFFFF ? undefined : ret !== 0; - } - /** - * Returns a copy of the Bech32-encoded state controller address, if present. - * @returns {string | undefined} - */ - stateControllerAddress() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocumentmetadata_stateControllerAddress(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the Bech32-encoded governor address, if present. - * @returns {string | undefined} - */ - governorAddress() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocumentmetadata_governorAddress(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the custom metadata properties. - * @returns {Map} - */ - properties() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocumentmetadata_properties(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocumentmetadata_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {IotaDocumentMetadata} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.iotadocumentmetadata_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return IotaDocumentMetadata.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {IotaDocumentMetadata} - */ - clone() { - const ret = wasm.iotadocumentmetadata_clone(this.__wbg_ptr); - return IotaDocumentMetadata.__wrap(ret); - } -} -module.exports.IotaDocumentMetadata = IotaDocumentMetadata; - -const IotaIdentityClientExtFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_iotaidentityclientext_free(ptr >>> 0, 1)); -/** -* An extension interface that provides helper functions for publication -* and resolution of DID documents in Alias Outputs. -*/ -class IotaIdentityClientExt { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - IotaIdentityClientExtFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_iotaidentityclientext_free(ptr, 0); - } - /** - * Create a DID with a new Alias Output containing the given `document`. - * - * The `address` will be set as the state controller and governor unlock conditions. - * The minimum required token deposit amount will be set according to the given - * `rent_structure`, which will be fetched from the node if not provided. - * The returned Alias Output can be further customised before publication, if desired. - * - * NOTE: this does *not* publish the Alias Output. - * @param {IIotaIdentityClient} client - * @param {Address} address - * @param {IotaDocument} document - * @param {IRent | undefined} [rentStructure] - * @returns {Promise} - */ - static newDidOutput(client, address, document, rentStructure) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(document, IotaDocument); - wasm.iotaidentityclientext_newDidOutput(retptr, addHeapObject(client), addHeapObject(address), document.__wbg_ptr, isLikeNone(rentStructure) ? 0 : addHeapObject(rentStructure)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Fetches the associated Alias Output and updates it with `document` in its state metadata. - * The storage deposit on the output is left unchanged. If the size of the document increased, - * the amount should be increased manually. - * - * NOTE: this does *not* publish the updated Alias Output. - * @param {IIotaIdentityClient} client - * @param {IotaDocument} document - * @returns {Promise} - */ - static updateDidOutput(client, document) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(document, IotaDocument); - wasm.iotaidentityclientext_updateDidOutput(retptr, addHeapObject(client), document.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Removes the DID document from the state metadata of its Alias Output, - * effectively deactivating it. The storage deposit on the output is left unchanged, - * and should be reallocated manually. - * - * Deactivating does not destroy the output. Hence, it can be re-activated by publishing - * an update containing a DID document. - * - * NOTE: this does *not* publish the updated Alias Output. - * @param {IIotaIdentityClient} client - * @param {IotaDID} did - * @returns {Promise} - */ - static deactivateDidOutput(client, did) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(did, IotaDID); - wasm.iotaidentityclientext_deactivateDidOutput(retptr, addHeapObject(client), did.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Resolve a {@link IotaDocument}. Returns an empty, deactivated document if the state metadata - * of the Alias Output is empty. - * @param {IIotaIdentityClient} client - * @param {IotaDID} did - * @returns {Promise} - */ - static resolveDid(client, did) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(did, IotaDID); - wasm.iotaidentityclientext_resolveDid(retptr, addHeapObject(client), did.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Fetches the `IAliasOutput` associated with the given DID. - * @param {IIotaIdentityClient} client - * @param {IotaDID} did - * @returns {Promise} - */ - static resolveDidOutput(client, did) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(did, IotaDID); - wasm.iotaidentityclientext_resolveDidOutput(retptr, addHeapObject(client), did.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.IotaIdentityClientExt = IotaIdentityClientExt; - -const IssuerProtectedHeaderFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_issuerprotectedheader_free(ptr >>> 0, 1)); -/** -*/ -class IssuerProtectedHeader { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(IssuerProtectedHeader.prototype); - obj.__wbg_ptr = ptr; - IssuerProtectedHeaderFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - typ: this.typ, - alg: this.alg, - kid: this.kid, - cid: this.cid, - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - IssuerProtectedHeaderFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_issuerprotectedheader_free(ptr, 0); - } - /** - * JWP type (JPT). - * @returns {string | undefined} - */ - get typ() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_issuerprotectedheader_typ(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * JWP type (JPT). - * @param {string | undefined} [arg0] - */ - set typ(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_issuerprotectedheader_typ(this.__wbg_ptr, ptr0, len0); - } - /** - * Algorithm used for the JWP. - * @returns {ProofAlgorithm} - */ - get alg() { - const ret = wasm.__wbg_get_issuerprotectedheader_alg(this.__wbg_ptr); - return ret; - } - /** - * Algorithm used for the JWP. - * @param {ProofAlgorithm} arg0 - */ - set alg(arg0) { - wasm.__wbg_set_issuerprotectedheader_alg(this.__wbg_ptr, arg0); - } - /** - * ID for the key used for the JWP. - * @returns {string | undefined} - */ - get kid() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_issuerprotectedheader_kid(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * ID for the key used for the JWP. - * @param {string | undefined} [arg0] - */ - set kid(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_issuerprotectedheader_kid(this.__wbg_ptr, ptr0, len0); - } - /** - * Not handled for now. Will be used in the future to resolve external claims - * @returns {string | undefined} - */ - get cid() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_issuerprotectedheader_cid(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Not handled for now. Will be used in the future to resolve external claims - * @param {string | undefined} [arg0] - */ - set cid(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_issuerprotectedheader_cid(this.__wbg_ptr, ptr0, len0); - } - /** - * @returns {(string)[]} - */ - claims() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.issuerprotectedheader_claims(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v1 = getArrayJsValueFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 4, 4); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.IssuerProtectedHeader = IssuerProtectedHeader; - -const JptFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jpt_free(ptr >>> 0, 1)); -/** -* A JSON Proof Token (JPT). -*/ -class Jpt { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Jpt.prototype); - obj.__wbg_ptr = ptr; - JptFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JptFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jpt_free(ptr, 0); - } - /** - * Creates a new {@link Jpt}. - * @param {string} jpt_string - */ - constructor(jpt_string) { - const ptr0 = passStringToWasm0(jpt_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.jpt_new(ptr0, len0); - this.__wbg_ptr = ret >>> 0; - JptFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jpt_toString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Deep clones the object. - * @returns {Jpt} - */ - clone() { - const ret = wasm.jpt_clone(this.__wbg_ptr); - return Jpt.__wrap(ret); - } -} -module.exports.Jpt = Jpt; - -const JptCredentialValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jptcredentialvalidationoptions_free(ptr >>> 0, 1)); -/** -* Options to declare validation criteria for {@link Jpt}. -*/ -class JptCredentialValidationOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JptCredentialValidationOptions.prototype); - obj.__wbg_ptr = ptr; - JptCredentialValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JptCredentialValidationOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jptcredentialvalidationoptions_free(ptr, 0); - } - /** - * Deep clones the object. - * @returns {JptCredentialValidationOptions} - */ - clone() { - const ret = wasm.jptcredentialvalidationoptions_clone(this.__wbg_ptr); - return JptCredentialValidationOptions.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jptcredentialvalidationoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JptCredentialValidationOptions} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jptcredentialvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JptCredentialValidationOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Creates a new default istance. - * @param {IJptCredentialValidationOptions | undefined} [opts] - */ - constructor(opts) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jptcredentialvalidationoptions_new(retptr, isLikeNone(opts) ? 0 : addHeapObject(opts)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - JptCredentialValidationOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.JptCredentialValidationOptions = JptCredentialValidationOptions; - -const JptCredentialValidatorFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jptcredentialvalidator_free(ptr >>> 0, 1)); -/** -*/ -class JptCredentialValidator { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JptCredentialValidatorFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jptcredentialvalidator_free(ptr, 0); - } - /** - * @param {Jpt} credential_jpt - * @param {CoreDocument | IToCoreDocument} issuer - * @param {JptCredentialValidationOptions} options - * @param {FailFast} fail_fast - * @returns {DecodedJptCredential} - */ - static validate(credential_jpt, issuer, options, fail_fast) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential_jpt, Jpt); - _assertClass(options, JptCredentialValidationOptions); - wasm.jptcredentialvalidator_validate(retptr, credential_jpt.__wbg_ptr, addBorrowedObject(issuer), options.__wbg_ptr, fail_fast); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DecodedJptCredential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.JptCredentialValidator = JptCredentialValidator; - -const JptCredentialValidatorUtilsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jptcredentialvalidatorutils_free(ptr >>> 0, 1)); -/** -* Utility functions for validating JPT credentials. -*/ -class JptCredentialValidatorUtils { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JptCredentialValidatorUtilsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jptcredentialvalidatorutils_free(ptr, 0); - } - /** - */ - constructor() { - const ret = wasm.jptcredentialvalidatorutils_new(); - this.__wbg_ptr = ret >>> 0; - JptCredentialValidatorUtilsFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Utility for extracting the issuer field of a {@link Credential} as a DID. - * # Errors - * Fails if the issuer field is not a valid DID. - * @param {Credential} credential - * @returns {CoreDID} - */ - static extractIssuer(credential) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - wasm.jptcredentialvalidatorutils_extractIssuer(retptr, credential.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Utility for extracting the issuer field of a credential in JPT representation as DID. - * # Errors - * If the JPT decoding fails or the issuer field is not a valid DID. - * @param {Jpt} credential - * @returns {CoreDID} - */ - static extractIssuerFromIssuedJpt(credential) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Jpt); - wasm.jptcredentialvalidatorutils_extractIssuerFromIssuedJpt(retptr, credential.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @param {Credential} credential - * @param {Timestamp | undefined} validity_timeframe - * @param {StatusCheck} status_check - */ - static checkTimeframesWithValidityTimeframe2024(credential, validity_timeframe, status_check) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - let ptr0 = 0; - if (!isLikeNone(validity_timeframe)) { - _assertClass(validity_timeframe, Timestamp); - ptr0 = validity_timeframe.__destroy_into_raw(); - } - wasm.jptcredentialvalidatorutils_checkTimeframesWithValidityTimeframe2024(retptr, credential.__wbg_ptr, ptr0, status_check); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Checks whether the credential status has been revoked. - * - * Only supports `RevocationTimeframe2024`. - * @param {Credential} credential - * @param {CoreDocument | IToCoreDocument} issuer - * @param {StatusCheck} status_check - */ - static checkRevocationWithValidityTimeframe2024(credential, issuer, status_check) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - wasm.jptcredentialvalidatorutils_checkRevocationWithValidityTimeframe2024(retptr, credential.__wbg_ptr, addBorrowedObject(issuer), status_check); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Checks whether the credential status has been revoked or the timeframe interval is INVALID - * - * Only supports `RevocationTimeframe2024`. - * @param {Credential} credential - * @param {CoreDocument | IToCoreDocument} issuer - * @param {Timestamp | undefined} validity_timeframe - * @param {StatusCheck} status_check - */ - static checkTimeframesAndRevocationWithValidityTimeframe2024(credential, issuer, validity_timeframe, status_check) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - let ptr0 = 0; - if (!isLikeNone(validity_timeframe)) { - _assertClass(validity_timeframe, Timestamp); - ptr0 = validity_timeframe.__destroy_into_raw(); - } - wasm.jptcredentialvalidatorutils_checkTimeframesAndRevocationWithValidityTimeframe2024(retptr, credential.__wbg_ptr, addBorrowedObject(issuer), ptr0, status_check); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.JptCredentialValidatorUtils = JptCredentialValidatorUtils; - -const JptPresentationValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jptpresentationvalidationoptions_free(ptr >>> 0, 1)); -/** -* Options to declare validation criteria for a {@link Jpt} presentation. -*/ -class JptPresentationValidationOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JptPresentationValidationOptions.prototype); - obj.__wbg_ptr = ptr; - JptPresentationValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JptPresentationValidationOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jptpresentationvalidationoptions_free(ptr, 0); - } - /** - * Deep clones the object. - * @returns {JptPresentationValidationOptions} - */ - clone() { - const ret = wasm.jptpresentationvalidationoptions_clone(this.__wbg_ptr); - return JptPresentationValidationOptions.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jptpresentationvalidationoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JptPresentationValidationOptions} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jptpresentationvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JptPresentationValidationOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * @param {IJptPresentationValidationOptions | undefined} [opts] - */ - constructor(opts) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jptpresentationvalidationoptions_new(retptr, isLikeNone(opts) ? 0 : addHeapObject(opts)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - JptPresentationValidationOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.JptPresentationValidationOptions = JptPresentationValidationOptions; - -const JptPresentationValidatorFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jptpresentationvalidator_free(ptr >>> 0, 1)); -/** -*/ -class JptPresentationValidator { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JptPresentationValidatorFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jptpresentationvalidator_free(ptr, 0); - } - /** - * Decodes and validates a Presented {@link Credential} issued as a JPT (JWP Presented Form). A - * {@link DecodedJptPresentation} is returned upon success. - * - * The following properties are validated according to `options`: - * - the holder's proof on the JWP, - * - the expiration date, - * - the issuance date, - * - the semantic structure. - * @param {Jpt} presentation_jpt - * @param {CoreDocument | IToCoreDocument} issuer - * @param {JptPresentationValidationOptions} options - * @param {FailFast} fail_fast - * @returns {DecodedJptPresentation} - */ - static validate(presentation_jpt, issuer, options, fail_fast) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(presentation_jpt, Jpt); - _assertClass(options, JptPresentationValidationOptions); - wasm.jptpresentationvalidator_validate(retptr, presentation_jpt.__wbg_ptr, addBorrowedObject(issuer), options.__wbg_ptr, fail_fast); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DecodedJptPresentation.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.JptPresentationValidator = JptPresentationValidator; - -const JptPresentationValidatorUtilsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jptpresentationvalidatorutils_free(ptr >>> 0, 1)); -/** -* Utility functions for verifying JPT presentations. -*/ -class JptPresentationValidatorUtils { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JptPresentationValidatorUtilsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jptpresentationvalidatorutils_free(ptr, 0); - } - /** - * Utility for extracting the issuer field of a credential in JPT representation as DID. - * # Errors - * If the JPT decoding fails or the issuer field is not a valid DID. - * @param {Jpt} presentation - * @returns {CoreDID} - */ - static extractIssuerFromPresentedJpt(presentation) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(presentation, Jpt); - wasm.jptpresentationvalidatorutils_extractIssuerFromPresentedJpt(retptr, presentation.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Check timeframe interval in credentialStatus with `RevocationTimeframeStatus`. - * @param {Credential} credential - * @param {Timestamp | undefined} validity_timeframe - * @param {StatusCheck} status_check - */ - static checkTimeframesWithValidityTimeframe2024(credential, validity_timeframe, status_check) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - let ptr0 = 0; - if (!isLikeNone(validity_timeframe)) { - _assertClass(validity_timeframe, Timestamp); - ptr0 = validity_timeframe.__destroy_into_raw(); - } - wasm.jptpresentationvalidatorutils_checkTimeframesWithValidityTimeframe2024(retptr, credential.__wbg_ptr, ptr0, status_check); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.JptPresentationValidatorUtils = JptPresentationValidatorUtils; - -const JwkFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwk_free(ptr >>> 0, 1)); -/** -*/ -class Jwk { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Jwk.prototype); - obj.__wbg_ptr = ptr; - JwkFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwkFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwk_free(ptr, 0); - } - /** - * @param {IJwkParams} jwk - */ - constructor(jwk) { - const ret = wasm.jwk_new(addHeapObject(jwk)); - this.__wbg_ptr = ret >>> 0; - JwkFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the value for the key type parameter (kty). - * @returns {JwkType} - */ - kty() { - const ret = wasm.jwk_kty(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns the value for the use property (use). - * @returns {JwkUse | undefined} - */ - use() { - const ret = wasm.jwk_use(this.__wbg_ptr); - return takeObject(ret); - } - /** - * @returns {Array} - */ - keyOps() { - const ret = wasm.jwk_keyOps(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns the value for the algorithm property (alg). - * @returns {JwsAlgorithm | undefined} - */ - alg() { - const ret = wasm.jwk_alg(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns the value of the key ID property (kid). - * @returns {string | undefined} - */ - kid() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_kid(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the X.509 URL property (x5u). - * @returns {string | undefined} - */ - x5u() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_x5u(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the X.509 certificate chain property (x5c). - * @returns {Array} - */ - x5c() { - const ret = wasm.jwk_x5c(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns the value of the X.509 certificate SHA-1 thumbprint property (x5t). - * @returns {string | undefined} - */ - x5t() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_x5t(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the X.509 certificate SHA-256 thumbprint property (x5t#S256). - * @returns {string | undefined} - */ - x5t256() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_x5t256(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * If this JWK is of kty EC, returns those parameters. - * @returns {JwkParamsEc | undefined} - */ - paramsEc() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_paramsEc(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * If this JWK is of kty OKP, returns those parameters. - * @returns {JwkParamsOkp | undefined} - */ - paramsOkp() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_paramsOkp(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * If this JWK is of kty OCT, returns those parameters. - * @returns {JwkParamsOct | undefined} - */ - paramsOct() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_paramsOct(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * If this JWK is of kty RSA, returns those parameters. - * @returns {JwkParamsRsa | undefined} - */ - paramsRsa() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_paramsRsa(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a clone of the {@link Jwk} with _all_ private key components unset. - * Nothing is returned when `kty = oct` as this key type is not considered public by this library. - * @returns {Jwk | undefined} - */ - toPublic() { - const ret = wasm.jwk_toPublic(this.__wbg_ptr); - return ret === 0 ? undefined : Jwk.__wrap(ret); - } - /** - * Returns `true` if _all_ private key components of the key are unset, `false` otherwise. - * @returns {boolean} - */ - isPublic() { - const ret = wasm.jwk_isPublic(this.__wbg_ptr); - return ret !== 0; - } - /** - * Returns `true` if _all_ private key components of the key are set, `false` otherwise. - * @returns {boolean} - */ - isPrivate() { - const ret = wasm.jwk_isPrivate(this.__wbg_ptr); - return ret !== 0; - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Jwk} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwk_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Jwk.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {Jwk} - */ - clone() { - const ret = wasm.jwk_clone(this.__wbg_ptr); - return Jwk.__wrap(ret); - } -} -module.exports.Jwk = Jwk; - -const JwkGenOutputFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwkgenoutput_free(ptr >>> 0, 1)); -/** -* The result of a key generation in `JwkStorage`. -*/ -class JwkGenOutput { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwkGenOutput.prototype); - obj.__wbg_ptr = ptr; - JwkGenOutputFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwkGenOutputFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwkgenoutput_free(ptr, 0); - } - /** - * @param {string} key_id - * @param {Jwk} jwk - */ - constructor(key_id, jwk) { - const ptr0 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(jwk, Jwk); - const ret = wasm.jwkgenoutput_new(ptr0, len0, jwk.__wbg_ptr); - this.__wbg_ptr = ret >>> 0; - JwkGenOutputFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the generated public {@link Jwk}. - * @returns {Jwk} - */ - jwk() { - const ret = wasm.jwkgenoutput_jwk(this.__wbg_ptr); - return Jwk.__wrap(ret); - } - /** - * Returns the key id of the generated {@link Jwk}. - * @returns {string} - */ - keyId() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwkgenoutput_keyId(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwkgenoutput_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JwkGenOutput} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwkgenoutput_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwkGenOutput.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {JwkGenOutput} - */ - clone() { - const ret = wasm.jwkgenoutput_clone(this.__wbg_ptr); - return JwkGenOutput.__wrap(ret); - } -} -module.exports.JwkGenOutput = JwkGenOutput; - -const JwkStorageFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwkstorage_free(ptr >>> 0, 1)); - -class JwkStorage { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwkStorageFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwkstorage_free(ptr, 0); - } - /** - * Generates a new BBS+ keypair. - * @param {ProofAlgorithm} alg - * @returns {Promise} - */ - generateBBS(alg) { - const ret = wasm.jwkstorage_generateBBS(this.__wbg_ptr, alg); - return takeObject(ret); - } - /** - * @param {string} key_id - * @param {(Uint8Array)[]} data - * @param {Jwk} public_key - * @param {Uint8Array | undefined} [header] - * @returns {Promise} - */ - signBBS(key_id, data, public_key, header) { - const ptr0 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passArrayJsValueToWasm0(data, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(public_key, Jwk); - var ptr2 = public_key.__destroy_into_raw(); - var ptr3 = isLikeNone(header) ? 0 : passArray8ToWasm0(header, wasm.__wbindgen_malloc); - var len3 = WASM_VECTOR_LEN; - const ret = wasm.jwkstorage_signBBS(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, ptr3, len3); - return takeObject(ret); - } - /** - * @param {string} key_id - * @param {Jwk} public_key - * @param {Uint8Array} signature - * @param {ProofUpdateCtx} ctx - * @returns {Promise} - */ - updateBBSSignature(key_id, public_key, signature, ctx) { - const ptr0 = passStringToWasm0(key_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(public_key, Jwk); - const ptr1 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc); - const len1 = WASM_VECTOR_LEN; - _assertClass(ctx, ProofUpdateCtx); - var ptr2 = ctx.__destroy_into_raw(); - const ret = wasm.jwkstorage_updateBBSSignature(this.__wbg_ptr, ptr0, len0, public_key.__wbg_ptr, ptr1, len1, ptr2); - return takeObject(ret); - } -} -module.exports.JwkStorage = JwkStorage; - -const JwpCredentialOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwpcredentialoptions_free(ptr >>> 0, 1)); -/** -*/ -class JwpCredentialOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwpCredentialOptions.prototype); - obj.__wbg_ptr = ptr; - JwpCredentialOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - kid: this.kid, - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwpCredentialOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwpcredentialoptions_free(ptr, 0); - } - /** - * @returns {string | undefined} - */ - get kid() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_jwpcredentialoptions_kid(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @param {string | undefined} [arg0] - */ - set kid(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_jwpcredentialoptions_kid(this.__wbg_ptr, ptr0, len0); - } - /** - */ - constructor() { - const ret = wasm.jwpcredentialoptions_new(); - this.__wbg_ptr = ret >>> 0; - JwpCredentialOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * @param {any} value - * @returns {JwpCredentialOptions} - */ - static fromJSON(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwpcredentialoptions_fromJSON(retptr, addHeapObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwpCredentialOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwpcredentialoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.JwpCredentialOptions = JwpCredentialOptions; - -const JwpIssuedFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwpissued_free(ptr >>> 0, 1)); -/** -*/ -class JwpIssued { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwpIssued.prototype); - obj.__wbg_ptr = ptr; - JwpIssuedFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwpIssuedFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwpissued_free(ptr, 0); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwpissued_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JwpIssued} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwpissued_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwpIssued.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {JwpIssued} - */ - clone() { - const ret = wasm.jwpissued_clone(this.__wbg_ptr); - return JwpIssued.__wrap(ret); - } - /** - * @param {SerializationType} serialization - * @returns {string} - */ - encode(serialization) { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwpissued_encode(retptr, this.__wbg_ptr, serialization); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - var ptr1 = r0; - var len1 = r1; - if (r3) { - ptr1 = 0; len1 = 0; - throw takeObject(r2); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * @param {Uint8Array} proof - */ - setProof(proof) { - const ptr0 = passArray8ToWasm0(proof, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwpissued_setProof(this.__wbg_ptr, ptr0, len0); - } - /** - * @returns {Uint8Array} - */ - getProof() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwpissued_getProof(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {Payloads} - */ - getPayloads() { - const ret = wasm.jwpissued_getPayloads(this.__wbg_ptr); - return Payloads.__wrap(ret); - } - /** - * @param {Payloads} payloads - */ - setPayloads(payloads) { - _assertClass(payloads, Payloads); - var ptr0 = payloads.__destroy_into_raw(); - wasm.jwpissued_setPayloads(this.__wbg_ptr, ptr0); - } - /** - * @returns {IssuerProtectedHeader} - */ - getIssuerProtectedHeader() { - const ret = wasm.jwpissued_getIssuerProtectedHeader(this.__wbg_ptr); - return IssuerProtectedHeader.__wrap(ret); - } -} -module.exports.JwpIssued = JwpIssued; - -const JwpPresentationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwppresentationoptions_free(ptr >>> 0, 1)); -/** -* Options to be set in the JWT claims of a verifiable presentation. -*/ -class JwpPresentationOptions { - - toJSON() { - return { - audience: this.audience, - nonce: this.nonce, - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwpPresentationOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwppresentationoptions_free(ptr, 0); - } - /** - * Sets the audience for presentation (`aud` property in JWP Presentation Header). - * @returns {string | undefined} - */ - get audience() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_jwpcredentialoptions_kid(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the audience for presentation (`aud` property in JWP Presentation Header). - * @param {string | undefined} [arg0] - */ - set audience(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_jwpcredentialoptions_kid(this.__wbg_ptr, ptr0, len0); - } - /** - * The nonce to be placed in the Presentation Protected Header. - * @returns {string | undefined} - */ - get nonce() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_issuerprotectedheader_typ(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * The nonce to be placed in the Presentation Protected Header. - * @param {string | undefined} [arg0] - */ - set nonce(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_issuerprotectedheader_typ(this.__wbg_ptr, ptr0, len0); - } - /** - */ - constructor() { - const ret = wasm.jwppresentationoptions_new(); - this.__wbg_ptr = ret >>> 0; - JwpPresentationOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } -} -module.exports.JwpPresentationOptions = JwpPresentationOptions; - -const JwpVerificationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwpverificationoptions_free(ptr >>> 0, 1)); -/** -*/ -class JwpVerificationOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwpVerificationOptions.prototype); - obj.__wbg_ptr = ptr; - JwpVerificationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwpVerificationOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwpverificationoptions_free(ptr, 0); - } - /** - * Deep clones the object. - * @returns {JwpVerificationOptions} - */ - clone() { - const ret = wasm.jwpverificationoptions_clone(this.__wbg_ptr); - return JwpVerificationOptions.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwpverificationoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JwpVerificationOptions} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwpverificationoptions_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwpVerificationOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * @param {IJwpVerificationOptions | undefined} [opts] - * @returns {JwpVerificationOptions} - */ - static new(opts) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwpverificationoptions_new(retptr, isLikeNone(opts) ? 0 : addHeapObject(opts)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwpVerificationOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.JwpVerificationOptions = JwpVerificationOptions; - -const JwsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jws_free(ptr >>> 0, 1)); -/** -* A wrapper around a JSON Web Signature (JWS). -*/ -class Jws { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Jws.prototype); - obj.__wbg_ptr = ptr; - JwsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jws_free(ptr, 0); - } - /** - * Creates a new {@link Jws} from the given string. - * @param {string} jws_string - */ - constructor(jws_string) { - const ptr0 = passStringToWasm0(jws_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.jws_constructor(ptr0, len0); - this.__wbg_ptr = ret >>> 0; - JwsFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns a clone of the JWS string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jws_toString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } -} -module.exports.Jws = Jws; - -const JwsHeaderFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwsheader_free(ptr >>> 0, 1)); -/** -*/ -class JwsHeader { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwsHeader.prototype); - obj.__wbg_ptr = ptr; - JwsHeaderFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwsHeaderFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwsheader_free(ptr, 0); - } - /** - * Create a new empty {@link JwsHeader}. - */ - constructor() { - const ret = wasm.jwsheader_new(); - this.__wbg_ptr = ret >>> 0; - JwsHeaderFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns the value for the algorithm claim (alg). - * @returns {JwsAlgorithm | undefined} - */ - alg() { - const ret = wasm.jwsheader_alg(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Sets a value for the algorithm claim (alg). - * @param {JwsAlgorithm} value - */ - setAlg(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_setAlg(retptr, this.__wbg_ptr, addHeapObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the base64url-encode payload claim (b64). - * @returns {boolean | undefined} - */ - b64() { - const ret = wasm.jwsheader_b64(this.__wbg_ptr); - return ret === 0xFFFFFF ? undefined : ret !== 0; - } - /** - * Sets a value for the base64url-encode payload claim (b64). - * @param {boolean} value - */ - setB64(value) { - wasm.jwsheader_setB64(this.__wbg_ptr, value); - } - /** - * Additional header parameters. - * @returns {Record | undefined} - */ - custom() { - const ret = wasm.jwsheader_custom(this.__wbg_ptr); - return takeObject(ret); - } - /** - * @param {string} claim - * @returns {boolean} - */ - has(claim) { - const ptr0 = passStringToWasm0(claim, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.jwsheader_has(this.__wbg_ptr, ptr0, len0); - return ret !== 0; - } - /** - * Returns `true` if none of the fields are set in both `self` and `other`. - * @param {JwsHeader} other - * @returns {boolean} - */ - isDisjoint(other) { - _assertClass(other, JwsHeader); - const ret = wasm.jwsheader_isDisjoint(this.__wbg_ptr, other.__wbg_ptr); - return ret !== 0; - } - /** - * Returns the value of the JWK Set URL claim (jku). - * @returns {string | undefined} - */ - jku() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_jku(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a value for the JWK Set URL claim (jku). - * @param {string} value - */ - setJku(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsheader_setJku(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the JWK claim (jwk). - * @returns {Jwk | undefined} - */ - jwk() { - const ret = wasm.jwsheader_jwk(this.__wbg_ptr); - return ret === 0 ? undefined : Jwk.__wrap(ret); - } - /** - * Sets a value for the JWK claim (jwk). - * @param {Jwk} value - */ - setJwk(value) { - _assertClass(value, Jwk); - wasm.jwsheader_setJwk(this.__wbg_ptr, value.__wbg_ptr); - } - /** - * Returns the value of the key ID claim (kid). - * @returns {string | undefined} - */ - kid() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_kid(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a value for the key ID claim (kid). - * @param {string} value - */ - setKid(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsheader_setKid(this.__wbg_ptr, ptr0, len0); - } - /** - * Returns the value of the X.509 URL claim (x5u). - * @returns {string | undefined} - */ - x5u() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_x5u(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a value for the X.509 URL claim (x5u). - * @param {string} value - */ - setX5u(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsheader_setX5u(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the X.509 certificate chain claim (x5c). - * @returns {Array} - */ - x5c() { - const ret = wasm.jwsheader_crit(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Sets values for the X.509 certificate chain claim (x5c). - * @param {Array} value - */ - setX5c(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_setX5c(retptr, this.__wbg_ptr, addHeapObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the X.509 certificate SHA-1 thumbprint claim (x5t). - * @returns {string | undefined} - */ - x5t() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_x5t(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a value for the X.509 certificate SHA-1 thumbprint claim (x5t). - * @param {string} value - */ - setX5t(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsheader_setX5t(this.__wbg_ptr, ptr0, len0); - } - /** - * Returns the value of the X.509 certificate SHA-256 thumbprint claim - * (x5t#S256). - * @returns {string | undefined} - */ - x5tS256() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_x5tS256(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a value for the X.509 certificate SHA-256 thumbprint claim - * (x5t#S256). - * @param {string} value - */ - setX5tS256(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsheader_setX5tS256(this.__wbg_ptr, ptr0, len0); - } - /** - * Returns the value of the token type claim (typ). - * @returns {string | undefined} - */ - typ() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_typ(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a value for the token type claim (typ). - * @param {string} value - */ - setTyp(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsheader_setTyp(this.__wbg_ptr, ptr0, len0); - } - /** - * Returns the value of the content type claim (cty). - * @returns {string | undefined} - */ - cty() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_cty(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a value for the content type claim (cty). - * @param {string} value - */ - setCty(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsheader_setCty(this.__wbg_ptr, ptr0, len0); - } - /** - * Returns the value of the critical claim (crit). - * @returns {Array} - */ - crit() { - const ret = wasm.jwsheader_crit(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Sets values for the critical claim (crit). - * @param {Array} value - */ - setCrit(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_setCrit(retptr, this.__wbg_ptr, addHeapObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the url claim (url). - * @returns {string | undefined} - */ - url() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_url(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a value for the url claim (url). - * @param {string} value - */ - setUrl(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsheader_setUrl(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the nonce claim (nonce). - * @returns {string | undefined} - */ - nonce() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_nonce(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets a value for the nonce claim (nonce). - * @param {string} value - */ - setNonce(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsheader_setNonce(this.__wbg_ptr, ptr0, len0); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JwsHeader} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsheader_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwsHeader.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {JwsHeader} - */ - clone() { - const ret = wasm.jwsheader_clone(this.__wbg_ptr); - return JwsHeader.__wrap(ret); - } -} -module.exports.JwsHeader = JwsHeader; - -const JwsSignatureOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwssignatureoptions_free(ptr >>> 0, 1)); -/** -*/ -class JwsSignatureOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwsSignatureOptions.prototype); - obj.__wbg_ptr = ptr; - JwsSignatureOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwsSignatureOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwssignatureoptions_free(ptr, 0); - } - /** - * @param {IJwsSignatureOptions | undefined} [options] - */ - constructor(options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwssignatureoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - JwsSignatureOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Replace the value of the `attachJwk` field. - * @param {boolean} value - */ - setAttachJwk(value) { - wasm.jwssignatureoptions_setAttachJwk(this.__wbg_ptr, value); - } - /** - * Replace the value of the `b64` field. - * @param {boolean} value - */ - setB64(value) { - wasm.jwssignatureoptions_setB64(this.__wbg_ptr, value); - } - /** - * Replace the value of the `typ` field. - * @param {string} value - */ - setTyp(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwssignatureoptions_setTyp(this.__wbg_ptr, ptr0, len0); - } - /** - * Replace the value of the `cty` field. - * @param {string} value - */ - setCty(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwssignatureoptions_setCty(this.__wbg_ptr, ptr0, len0); - } - /** - * Replace the value of the `url` field. - * @param {string} value - */ - serUrl(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwssignatureoptions_serUrl(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Replace the value of the `nonce` field. - * @param {string} value - */ - setNonce(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwssignatureoptions_setNonce(this.__wbg_ptr, ptr0, len0); - } - /** - * Replace the value of the `kid` field. - * @param {string} value - */ - setKid(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwssignatureoptions_setKid(this.__wbg_ptr, ptr0, len0); - } - /** - * Replace the value of the `detached_payload` field. - * @param {boolean} value - */ - setDetachedPayload(value) { - wasm.jwssignatureoptions_setDetachedPayload(this.__wbg_ptr, value); - } - /** - * Add additional header parameters. - * @param {Record} value - */ - setCustomHeaderParameters(value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwssignatureoptions_setCustomHeaderParameters(retptr, this.__wbg_ptr, addHeapObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwssignatureoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JwsSignatureOptions} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwssignatureoptions_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwsSignatureOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {JwsSignatureOptions} - */ - clone() { - const ret = wasm.jwssignatureoptions_clone(this.__wbg_ptr); - return JwsSignatureOptions.__wrap(ret); - } -} -module.exports.JwsSignatureOptions = JwsSignatureOptions; - -const JwsVerificationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwsverificationoptions_free(ptr >>> 0, 1)); -/** -*/ -class JwsVerificationOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwsVerificationOptions.prototype); - obj.__wbg_ptr = ptr; - JwsVerificationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwsVerificationOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwsverificationoptions_free(ptr, 0); - } - /** - * Creates a new {@link JwsVerificationOptions} from the given fields. - * @param {IJwsVerificationOptions | undefined} [options] - */ - constructor(options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsverificationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - JwsVerificationOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Set the expected value for the `nonce` parameter of the protected header. - * @param {string} value - */ - setNonce(value) { - const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwsverificationoptions_setNonce(this.__wbg_ptr, ptr0, len0); - } - /** - * Set the scope of the verification methods that may be used to verify the given JWS. - * @param {MethodScope} value - */ - setMethodScope(value) { - _assertClass(value, MethodScope); - wasm.jwsverificationoptions_setMethodScope(this.__wbg_ptr, value.__wbg_ptr); - } - /** - * Set the DID URl of the method, whose JWK should be used to verify the JWS. - * @param {DIDUrl} value - */ - setMethodId(value) { - _assertClass(value, DIDUrl); - wasm.jwsverificationoptions_setMethodId(this.__wbg_ptr, value.__wbg_ptr); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsverificationoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JwsVerificationOptions} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwsverificationoptions_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwsVerificationOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {JwsVerificationOptions} - */ - clone() { - const ret = wasm.jwsverificationoptions_clone(this.__wbg_ptr); - return JwsVerificationOptions.__wrap(ret); - } -} -module.exports.JwsVerificationOptions = JwsVerificationOptions; - -const JwtFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwt_free(ptr >>> 0, 1)); -/** -* A wrapper around a JSON Web Token (JWK). -*/ -class Jwt { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Jwt.prototype); - obj.__wbg_ptr = ptr; - JwtFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwtFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwt_free(ptr, 0); - } - /** - * Creates a new {@link Jwt} from the given string. - * @param {string} jwt_string - */ - constructor(jwt_string) { - const ptr0 = passStringToWasm0(jwt_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.jwt_constructor(ptr0, len0); - this.__wbg_ptr = ret >>> 0; - JwtFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Returns a clone of the JWT string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwt_toString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwt_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Jwt} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwt_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Jwt.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {Jwt} - */ - clone() { - const ret = wasm.jwt_clone(this.__wbg_ptr); - return Jwt.__wrap(ret); - } -} -module.exports.Jwt = Jwt; - -const JwtCredentialValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwtcredentialvalidationoptions_free(ptr >>> 0, 1)); -/** -* Options to declare validation criteria when validating credentials. -*/ -class JwtCredentialValidationOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwtCredentialValidationOptions.prototype); - obj.__wbg_ptr = ptr; - JwtCredentialValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwtCredentialValidationOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwtcredentialvalidationoptions_free(ptr, 0); - } - /** - * @param {IJwtCredentialValidationOptions | undefined} [options] - */ - constructor(options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwtcredentialvalidationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - JwtCredentialValidationOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwtcredentialvalidationoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JwtCredentialValidationOptions} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwtcredentialvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwtCredentialValidationOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {JwtCredentialValidationOptions} - */ - clone() { - const ret = wasm.jwtcredentialvalidationoptions_clone(this.__wbg_ptr); - return JwtCredentialValidationOptions.__wrap(ret); - } -} -module.exports.JwtCredentialValidationOptions = JwtCredentialValidationOptions; - -const JwtCredentialValidatorFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwtcredentialvalidator_free(ptr >>> 0, 1)); -/** -* A type for decoding and validating {@link Credential}. -*/ -class JwtCredentialValidator { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwtCredentialValidatorFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwtcredentialvalidator_free(ptr, 0); - } - /** - * Creates a new {@link JwtCredentialValidator}. If a `signatureVerifier` is provided it will be used when - * verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` - * algorithm will be used. - * @param {IJwsVerifier} signatureVerifier - */ - constructor(signatureVerifier) { - const ret = wasm.jwtcredentialvalidator_new(addHeapObject(signatureVerifier)); - this.__wbg_ptr = ret >>> 0; - JwtCredentialValidatorFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Decodes and validates a {@link Credential} issued as a JWS. A {@link DecodedJwtCredential} is returned upon - * success. - * - * The following properties are validated according to `options`: - * - the issuer's signature on the JWS, - * - the expiration date, - * - the issuance date, - * - the semantic structure. - * - * # Warning - * The lack of an error returned from this method is in of itself not enough to conclude that the credential can be - * trusted. This section contains more information on additional checks that should be carried out before and after - * calling this method. - * - * ## The state of the issuer's DID Document - * The caller must ensure that `issuer` represents an up-to-date DID Document. - * - * ## Properties that are not validated - * There are many properties defined in [The Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/) that are **not** validated, such as: - * `proof`, `credentialStatus`, `type`, `credentialSchema`, `refreshService` **and more**. - * These should be manually checked after validation, according to your requirements. - * - * # Errors - * An error is returned whenever a validated condition is not satisfied. - * @param {Jwt} credential_jwt - * @param {CoreDocument | IToCoreDocument} issuer - * @param {JwtCredentialValidationOptions} options - * @param {FailFast} fail_fast - * @returns {DecodedJwtCredential} - */ - validate(credential_jwt, issuer, options, fail_fast) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential_jwt, Jwt); - _assertClass(options, JwtCredentialValidationOptions); - wasm.jwtcredentialvalidator_validate(retptr, this.__wbg_ptr, credential_jwt.__wbg_ptr, addBorrowedObject(issuer), options.__wbg_ptr, fail_fast); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DecodedJwtCredential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Decode and verify the JWS signature of a {@link Credential} issued as a JWT using the DID Document of a trusted - * issuer. - * - * A {@link DecodedJwtCredential} is returned upon success. - * - * # Warning - * The caller must ensure that the DID Documents of the trusted issuers are up-to-date. - * - * ## Proofs - * Only the JWS signature is verified. If the {@link Credential} contains a `proof` property this will not be - * verified by this method. - * - * # Errors - * This method immediately returns an error if - * the credential issuer' url cannot be parsed to a DID belonging to one of the trusted issuers. Otherwise an attempt - * to verify the credential's signature will be made and an error is returned upon failure. - * @param {Jwt} credential - * @param {Array} trustedIssuers - * @param {JwsVerificationOptions} options - * @returns {DecodedJwtCredential} - */ - verifySignature(credential, trustedIssuers, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Jwt); - _assertClass(options, JwsVerificationOptions); - wasm.jwtcredentialvalidator_verifySignature(retptr, this.__wbg_ptr, credential.__wbg_ptr, addBorrowedObject(trustedIssuers), options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DecodedJwtCredential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Validate that the credential expires on or after the specified timestamp. - * @param {Credential} credential - * @param {Timestamp} timestamp - */ - static checkExpiresOnOrAfter(credential, timestamp) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - _assertClass(timestamp, Timestamp); - wasm.jwtcredentialvalidator_checkExpiresOnOrAfter(retptr, credential.__wbg_ptr, timestamp.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Validate that the credential is issued on or before the specified timestamp. - * @param {Credential} credential - * @param {Timestamp} timestamp - */ - static checkIssuedOnOrBefore(credential, timestamp) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - _assertClass(timestamp, Timestamp); - wasm.jwtcredentialvalidator_checkIssuedOnOrBefore(retptr, credential.__wbg_ptr, timestamp.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Validate that the relationship between the `holder` and the credential subjects is in accordance with - * `relationship`. The `holder` parameter is expected to be the URL of the holder. - * @param {Credential} credential - * @param {string} holder - * @param {SubjectHolderRelationship} relationship - */ - static checkSubjectHolderRelationship(credential, holder, relationship) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - const ptr0 = passStringToWasm0(holder, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.jwtcredentialvalidator_checkSubjectHolderRelationship(retptr, credential.__wbg_ptr, ptr0, len0, relationship); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Checks whether the credential status has been revoked. - * - * Only supports `RevocationBitmap2022`. - * @param {Credential} credential - * @param {Array} trustedIssuers - * @param {StatusCheck} statusCheck - */ - static checkStatus(credential, trustedIssuers, statusCheck) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - wasm.jwtcredentialvalidator_checkStatus(retptr, credential.__wbg_ptr, addBorrowedObject(trustedIssuers), statusCheck); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Checks wheter the credential status has been revoked using `StatusList2021`. - * @param {Credential} credential - * @param {StatusList2021Credential} status_list - * @param {StatusCheck} status_check - */ - static checkStatusWithStatusList2021(credential, status_list, status_check) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - _assertClass(status_list, StatusList2021Credential); - wasm.jwtcredentialvalidator_checkStatusWithStatusList2021(retptr, credential.__wbg_ptr, status_list.__wbg_ptr, status_check); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Utility for extracting the issuer field of a {@link Credential} as a DID. - * - * ### Errors - * - * Fails if the issuer field is not a valid DID. - * @param {Credential} credential - * @returns {CoreDID} - */ - static extractIssuer(credential) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - wasm.jwtcredentialvalidator_extractIssuer(retptr, credential.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Utility for extracting the issuer field of a credential in JWT representation as DID. - * - * # Errors - * - * If the JWT decoding fails or the issuer field is not a valid DID. - * @param {Jwt} credential - * @returns {CoreDID} - */ - static extractIssuerFromJwt(credential) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Jwt); - wasm.jwtcredentialvalidator_extractIssuerFromJwt(retptr, credential.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.JwtCredentialValidator = JwtCredentialValidator; - -const JwtDomainLinkageValidatorFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwtdomainlinkagevalidator_free(ptr >>> 0, 1)); -/** -* A validator for a Domain Linkage Configuration and Credentials. -*/ -class JwtDomainLinkageValidator { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwtDomainLinkageValidatorFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwtdomainlinkagevalidator_free(ptr, 0); - } - /** - * Creates a new {@link JwtDomainLinkageValidator}. If a `signatureVerifier` is provided it will be used when - * verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` - * algorithm will be used. - * @param {IJwsVerifier} signatureVerifier - */ - constructor(signatureVerifier) { - const ret = wasm.jwtdomainlinkagevalidator_new(addHeapObject(signatureVerifier)); - this.__wbg_ptr = ret >>> 0; - JwtDomainLinkageValidatorFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Validates the linkage between a domain and a DID. - * {@link DomainLinkageConfiguration} is validated according to [DID Configuration Resource Verification](https://identity.foundation/.well-known/resources/did-configuration/#did-configuration-resource-verification). - * - * Linkage is valid if no error is thrown. - * - * # Note: - * - Only the [JSON Web Token Proof Format](https://identity.foundation/.well-known/resources/did-configuration/#json-web-token-proof-format) - * is supported. - * - Only the Credential issued by `issuer` is verified. - * - * # Errors - * - * - Semantic structure of `configuration` is invalid. - * - `configuration` includes multiple credentials issued by `issuer`. - * - Validation of the matched Domain Linkage Credential fails. - * @param {CoreDocument | IToCoreDocument} issuer - * @param {DomainLinkageConfiguration} configuration - * @param {string} domain - * @param {JwtCredentialValidationOptions} options - */ - validateLinkage(issuer, configuration, domain, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(configuration, DomainLinkageConfiguration); - const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(options, JwtCredentialValidationOptions); - wasm.jwtdomainlinkagevalidator_validateLinkage(retptr, this.__wbg_ptr, addBorrowedObject(issuer), configuration.__wbg_ptr, ptr0, len0, options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Validates a [Domain Linkage Credential](https://identity.foundation/.well-known/resources/did-configuration/#domain-linkage-credential). - * - * Error will be thrown in case the validation fails. - * @param {CoreDocument | IToCoreDocument} issuer - * @param {Jwt} credentialJwt - * @param {string} domain - * @param {JwtCredentialValidationOptions} options - */ - validateCredential(issuer, credentialJwt, domain, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credentialJwt, Jwt); - const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(options, JwtCredentialValidationOptions); - wasm.jwtdomainlinkagevalidator_validateCredential(retptr, this.__wbg_ptr, addBorrowedObject(issuer), credentialJwt.__wbg_ptr, ptr0, len0, options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.JwtDomainLinkageValidator = JwtDomainLinkageValidator; - -const JwtPresentationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwtpresentationoptions_free(ptr >>> 0, 1)); -/** -*/ -class JwtPresentationOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwtPresentationOptions.prototype); - obj.__wbg_ptr = ptr; - JwtPresentationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwtPresentationOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwtpresentationoptions_free(ptr, 0); - } - /** - * Creates a new {@link JwtPresentationOptions} from the given fields. - * - * Throws an error if any of the options are invalid. - * @param {IJwtPresentationOptions | undefined} [options] - */ - constructor(options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwtpresentationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - JwtPresentationOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwtpresentationoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JwtPresentationOptions} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwtpresentationoptions_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwtPresentationOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {JwtPresentationOptions} - */ - clone() { - const ret = wasm.jwtpresentationoptions_clone(this.__wbg_ptr); - return JwtPresentationOptions.__wrap(ret); - } -} -module.exports.JwtPresentationOptions = JwtPresentationOptions; - -const JwtPresentationValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwtpresentationvalidationoptions_free(ptr >>> 0, 1)); -/** -* Options to declare validation criteria when validating presentation. -*/ -class JwtPresentationValidationOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(JwtPresentationValidationOptions.prototype); - obj.__wbg_ptr = ptr; - JwtPresentationValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwtPresentationValidationOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwtpresentationvalidationoptions_free(ptr, 0); - } - /** - * Creates a new {@link JwtPresentationValidationOptions} from the given fields. - * - * Throws an error if any of the options are invalid. - * @param {IJwtPresentationValidationOptions | undefined} [options] - */ - constructor(options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwtpresentationvalidationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - JwtPresentationValidationOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwtpresentationvalidationoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {JwtPresentationValidationOptions} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.jwtpresentationvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return JwtPresentationValidationOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {JwtPresentationValidationOptions} - */ - clone() { - const ret = wasm.jwtpresentationvalidationoptions_clone(this.__wbg_ptr); - return JwtPresentationValidationOptions.__wrap(ret); - } -} -module.exports.JwtPresentationValidationOptions = JwtPresentationValidationOptions; - -const JwtPresentationValidatorFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_jwtpresentationvalidator_free(ptr >>> 0, 1)); -/** -*/ -class JwtPresentationValidator { - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - JwtPresentationValidatorFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_jwtpresentationvalidator_free(ptr, 0); - } - /** - * Creates a new {@link JwtPresentationValidator}. If a `signatureVerifier` is provided it will be used when - * verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` - * algorithm will be used. - * @param {IJwsVerifier} signatureVerifier - */ - constructor(signatureVerifier) { - const ret = wasm.jwtpresentationvalidator_new(addHeapObject(signatureVerifier)); - this.__wbg_ptr = ret >>> 0; - JwtPresentationValidatorFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Validates a {@link Presentation} encoded as a {@link Jwt}. - * - * The following properties are validated according to `options`: - * - the JWT can be decoded into a semantically valid presentation. - * - the expiration and issuance date contained in the JWT claims. - * - the holder's signature. - * - * Validation is done with respect to the properties set in `options`. - * - * # Warning - * - * * This method does NOT validate the constituent credentials and therefore also not the relationship between the - * credentials' subjects and the presentation holder. This can be done with {@link JwtCredentialValidationOptions}. - * * The lack of an error returned from this method is in of itself not enough to conclude that the presentation can - * be trusted. This section contains more information on additional checks that should be carried out before and - * after calling this method. - * - * ## The state of the supplied DID Documents. - * - * The caller must ensure that the DID Documents in `holder` are up-to-date. - * - * # Errors - * - * An error is returned whenever a validated condition is not satisfied or when decoding fails. - * @param {Jwt} presentationJwt - * @param {CoreDocument | IToCoreDocument} holder - * @param {JwtPresentationValidationOptions} validation_options - * @returns {DecodedJwtPresentation} - */ - validate(presentationJwt, holder, validation_options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(presentationJwt, Jwt); - _assertClass(validation_options, JwtPresentationValidationOptions); - wasm.jwtpresentationvalidator_validate(retptr, this.__wbg_ptr, presentationJwt.__wbg_ptr, addBorrowedObject(holder), validation_options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DecodedJwtPresentation.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Validates the semantic structure of the {@link Presentation}. - * @param {Presentation} presentation - */ - static checkStructure(presentation) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(presentation, Presentation); - wasm.jwtpresentationvalidator_checkStructure(retptr, presentation.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Attempt to extract the holder of the presentation. - * - * # Errors: - * * If deserialization/decoding of the presentation fails. - * * If the holder can't be parsed as DIDs. - * @param {Jwt} presentation - * @returns {CoreDID} - */ - static extractHolder(presentation) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(presentation, Jwt); - wasm.jwtpresentationvalidator_extractHolder(retptr, presentation.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CoreDID.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.JwtPresentationValidator = JwtPresentationValidator; - -const KeyBindingJWTValidationOptionsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_keybindingjwtvalidationoptions_free(ptr >>> 0, 1)); -/** -* Options to declare validation criteria when validating credentials. -*/ -class KeyBindingJWTValidationOptions { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(KeyBindingJWTValidationOptions.prototype); - obj.__wbg_ptr = ptr; - KeyBindingJWTValidationOptionsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeyBindingJWTValidationOptionsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keybindingjwtvalidationoptions_free(ptr, 0); - } - /** - * @param {IKeyBindingJWTValidationOptions | undefined} [options] - */ - constructor(options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtvalidationoptions_new(retptr, isLikeNone(options) ? 0 : addHeapObject(options)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - KeyBindingJWTValidationOptionsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtvalidationoptions_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {KeyBindingJWTValidationOptions} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtvalidationoptions_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return KeyBindingJWTValidationOptions.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {KeyBindingJWTValidationOptions} - */ - clone() { - const ret = wasm.keybindingjwtvalidationoptions_clone(this.__wbg_ptr); - return KeyBindingJWTValidationOptions.__wrap(ret); - } -} -module.exports.KeyBindingJWTValidationOptions = KeyBindingJWTValidationOptions; - -const KeyBindingJwtClaimsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_keybindingjwtclaims_free(ptr >>> 0, 1)); -/** -* Claims set for key binding JWT. -*/ -class KeyBindingJwtClaims { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(KeyBindingJwtClaims.prototype); - obj.__wbg_ptr = ptr; - KeyBindingJwtClaimsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - KeyBindingJwtClaimsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_keybindingjwtclaims_free(ptr, 0); - } - /** - * Creates a new [`KeyBindingJwtClaims`]. - * When `issued_at` is left as None, it will automatically default to the current time. - * - * # Error - * When `issued_at` is set to `None` and the system returns time earlier than `SystemTime::UNIX_EPOCH`. - * @param {string} jwt - * @param {Array} disclosures - * @param {string} nonce - * @param {string} aud - * @param {Timestamp | undefined} [issued_at] - * @param {Record | undefined} [custom_properties] - */ - constructor(jwt, disclosures, nonce, aud, issued_at, custom_properties) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(nonce, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(aud, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - let ptr3 = 0; - if (!isLikeNone(issued_at)) { - _assertClass(issued_at, Timestamp); - ptr3 = issued_at.__destroy_into_raw(); - } - wasm.keybindingjwtclaims_new(retptr, ptr0, len0, addHeapObject(disclosures), ptr1, len1, ptr2, len2, ptr3, isLikeNone(custom_properties) ? 0 : addHeapObject(custom_properties)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - KeyBindingJwtClaimsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a string representation of the claims. - * @returns {string} - */ - toString() { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtclaims_toString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - var ptr1 = r0; - var len1 = r1; - if (r3) { - ptr1 = 0; len1 = 0; - throw takeObject(r2); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Returns a copy of the issued at `iat` property. - * @returns {bigint} - */ - iat() { - const ret = wasm.keybindingjwtclaims_iat(this.__wbg_ptr); - return ret; - } - /** - * Returns a copy of the audience `aud` property. - * @returns {string} - */ - aud() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtclaims_aud(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the `nonce` property. - * @returns {string} - */ - nonce() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtclaims_nonce(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the `sd_hash` property. - * @returns {string} - */ - sdHash() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtclaims_sdHash(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the custom properties. - * @returns {Record} - */ - customProperties() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtclaims_customProperties(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the value of the `typ` property of the JWT header according to - * https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-key-binding-jwt - * @returns {string} - */ - static keyBindingJwtHeaderTyp() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtclaims_keyBindingJwtHeaderTyp(retptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtclaims_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {KeyBindingJwtClaims} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.keybindingjwtclaims_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return KeyBindingJwtClaims.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {KeyBindingJwtClaims} - */ - clone() { - const ret = wasm.keybindingjwtclaims_clone(this.__wbg_ptr); - return KeyBindingJwtClaims.__wrap(ret); - } -} -module.exports.KeyBindingJwtClaims = KeyBindingJwtClaims; - -const LinkedDomainServiceFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_linkeddomainservice_free(ptr >>> 0, 1)); -/** -*/ -class LinkedDomainService { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(LinkedDomainService.prototype); - obj.__wbg_ptr = ptr; - LinkedDomainServiceFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - LinkedDomainServiceFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_linkeddomainservice_free(ptr, 0); - } - /** - * Constructs a new {@link LinkedDomainService} that wraps a spec compliant [Linked Domain Service Endpoint](https://identity.foundation/.well-known/resources/did-configuration/#linked-domain-service-endpoint). - * - * Domain URLs must include the `https` scheme in order to pass the domain linkage validation. - * @param {ILinkedDomainService} options - */ - constructor(options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.linkeddomainservice_new(retptr, addHeapObject(options)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - LinkedDomainServiceFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the domains contained in the Linked Domain Service. - * @returns {Array} - */ - domains() { - const ret = wasm.linkeddomainservice_domains(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns the inner service which can be added to a DID Document. - * @returns {Service} - */ - toService() { - const ret = wasm.linkeddomainservice_toService(this.__wbg_ptr); - return Service.__wrap(ret); - } - /** - * Creates a new {@link LinkedDomainService} from a {@link Service}. - * - * # Error - * - * Errors if `service` is not a valid Linked Domain Service. - * @param {Service} service - * @returns {LinkedDomainService} - */ - static fromService(service) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(service, Service); - wasm.linkeddomainservice_fromService(retptr, service.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return LinkedDomainService.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns `true` if a {@link Service} is a valid Linked Domain Service. - * @param {Service} service - * @returns {boolean} - */ - static isValid(service) { - _assertClass(service, Service); - const ret = wasm.linkeddomainservice_isValid(service.__wbg_ptr); - return ret !== 0; - } - /** - * Deep clones the object. - * @returns {LinkedDomainService} - */ - clone() { - const ret = wasm.linkeddomainservice_clone(this.__wbg_ptr); - return LinkedDomainService.__wrap(ret); - } -} -module.exports.LinkedDomainService = LinkedDomainService; - -const MethodDataFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_methoddata_free(ptr >>> 0, 1)); -/** -* Supported verification method data formats. -*/ -class MethodData { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(MethodData.prototype); - obj.__wbg_ptr = ptr; - MethodDataFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MethodDataFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_methoddata_free(ptr, 0); - } - /** - * Creates a new {@link MethodData} variant with Base58-BTC encoded content. - * @param {Uint8Array} data - * @returns {MethodData} - */ - static newBase58(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.methoddata_newBase58(ptr0, len0); - return MethodData.__wrap(ret); - } - /** - * Creates a new {@link MethodData} variant with Multibase-encoded content. - * @param {Uint8Array} data - * @returns {MethodData} - */ - static newMultibase(data) { - const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.methoddata_newMultibase(ptr0, len0); - return MethodData.__wrap(ret); - } - /** - * Creates a new {@link MethodData} variant consisting of the given `key`. - * - * ### Errors - * An error is thrown if the given `key` contains any private components. - * @param {Jwk} key - * @returns {MethodData} - */ - static newJwk(key) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(key, Jwk); - wasm.methoddata_newJwk(retptr, key.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return MethodData.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Creates a new custom {@link MethodData}. - * @param {string} name - * @param {any} data - * @returns {MethodData} - */ - static newCustom(name, data) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.methoddata_newCustom(retptr, ptr0, len0, addHeapObject(data)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return MethodData.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the wrapped custom method data format is `Custom`. - * @returns {CustomMethodData} - */ - tryCustom() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methoddata_tryCustom(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return CustomMethodData.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a `Uint8Array` containing the decoded bytes of the {@link MethodData}. - * - * This is generally a public key identified by a {@link MethodData} value. - * - * ### Errors - * Decoding can fail if {@link MethodData} has invalid content or cannot be - * represented as a vector of bytes. - * @returns {Uint8Array} - */ - tryDecode() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methoddata_tryDecode(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the wrapped {@link Jwk} if the format is `PublicKeyJwk`. - * @returns {Jwk} - */ - tryPublicKeyJwk() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methoddata_tryPublicKeyJwk(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Jwk.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methoddata_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {MethodData} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methoddata_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return MethodData.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {MethodData} - */ - clone() { - const ret = wasm.methoddata_clone(this.__wbg_ptr); - return MethodData.__wrap(ret); - } -} -module.exports.MethodData = MethodData; - -const MethodDigestFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_methoddigest_free(ptr >>> 0, 1)); -/** -* Unique identifier of a {@link VerificationMethod}. -* -* NOTE: -* This class does not have a JSON representation, -* use the methods `pack` and `unpack` instead. -*/ -class MethodDigest { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(MethodDigest.prototype); - obj.__wbg_ptr = ptr; - MethodDigestFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MethodDigestFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_methoddigest_free(ptr, 0); - } - /** - * @param {VerificationMethod} verification_method - */ - constructor(verification_method) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(verification_method, VerificationMethod); - wasm.methoddigest_new(retptr, verification_method.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - MethodDigestFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Packs {@link MethodDigest} into bytes. - * @returns {Uint8Array} - */ - pack() { - const ret = wasm.methoddigest_pack(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Unpacks bytes into {@link MethodDigest}. - * @param {Uint8Array} bytes - * @returns {MethodDigest} - */ - static unpack(bytes) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methoddigest_unpack(retptr, addBorrowedObject(bytes)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return MethodDigest.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {MethodDigest} - */ - clone() { - const ret = wasm.methoddigest_clone(this.__wbg_ptr); - return MethodDigest.__wrap(ret); - } -} -module.exports.MethodDigest = MethodDigest; - -const MethodScopeFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_methodscope_free(ptr >>> 0, 1)); -/** -* Supported verification method types. -*/ -class MethodScope { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(MethodScope.prototype); - obj.__wbg_ptr = ptr; - MethodScopeFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MethodScopeFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_methodscope_free(ptr, 0); - } - /** - * @returns {MethodScope} - */ - static VerificationMethod() { - const ret = wasm.methodscope_VerificationMethod(); - return MethodScope.__wrap(ret); - } - /** - * @returns {MethodScope} - */ - static Authentication() { - const ret = wasm.methodscope_Authentication(); - return MethodScope.__wrap(ret); - } - /** - * @returns {MethodScope} - */ - static AssertionMethod() { - const ret = wasm.methodscope_AssertionMethod(); - return MethodScope.__wrap(ret); - } - /** - * @returns {MethodScope} - */ - static KeyAgreement() { - const ret = wasm.methodscope_KeyAgreement(); - return MethodScope.__wrap(ret); - } - /** - * @returns {MethodScope} - */ - static CapabilityDelegation() { - const ret = wasm.methodscope_CapabilityDelegation(); - return MethodScope.__wrap(ret); - } - /** - * @returns {MethodScope} - */ - static CapabilityInvocation() { - const ret = wasm.methodscope_CapabilityInvocation(); - return MethodScope.__wrap(ret); - } - /** - * Returns the {@link MethodScope} as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methodscope_toString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methodscope_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {MethodScope} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methodscope_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return MethodScope.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {MethodScope} - */ - clone() { - const ret = wasm.methodscope_clone(this.__wbg_ptr); - return MethodScope.__wrap(ret); - } -} -module.exports.MethodScope = MethodScope; - -const MethodTypeFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_methodtype_free(ptr >>> 0, 1)); -/** -* Supported verification method types. -*/ -class MethodType { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(MethodType.prototype); - obj.__wbg_ptr = ptr; - MethodTypeFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - MethodTypeFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_methodtype_free(ptr, 0); - } - /** - * @returns {MethodType} - */ - static Ed25519VerificationKey2018() { - const ret = wasm.methodtype_Ed25519VerificationKey2018(); - return MethodType.__wrap(ret); - } - /** - * @returns {MethodType} - */ - static X25519KeyAgreementKey2019() { - const ret = wasm.methodtype_X25519KeyAgreementKey2019(); - return MethodType.__wrap(ret); - } - /** - * @deprecated Use {@link JsonWebKey2020} instead. - */ - static JsonWebKey() { - const ret = wasm.methodtype_JsonWebKey(); - return MethodType.__wrap(ret); - } - /** - * A verification method for use with JWT verification as prescribed by the {@link Jwk} - * in the `publicKeyJwk` entry. - * @returns {MethodType} - */ - static JsonWebKey2020() { - const ret = wasm.methodtype_JsonWebKey2020(); - return MethodType.__wrap(ret); - } - /** - * A custom method. - * @param {string} type_ - * @returns {MethodType} - */ - static custom(type_) { - const ptr0 = passStringToWasm0(type_, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.methodtype_custom(ptr0, len0); - return MethodType.__wrap(ret); - } - /** - * Returns the {@link MethodType} as a string. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methodtype_toString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methodtype_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {MethodType} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.methodtype_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return MethodType.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {MethodType} - */ - clone() { - const ret = wasm.methodtype_clone(this.__wbg_ptr); - return MethodType.__wrap(ret); - } -} -module.exports.MethodType = MethodType; - -const PayloadEntryFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_payloadentry_free(ptr >>> 0, 1)); -/** -*/ -class PayloadEntry { - - static __unwrap(jsValue) { - if (!(jsValue instanceof PayloadEntry)) { - return 0; - } - return jsValue.__destroy_into_raw(); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PayloadEntryFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_payloadentry_free(ptr, 0); - } - /** - * @returns {PayloadType} - */ - get 1() { - const ret = wasm.__wbg_get_payloadentry_1(this.__wbg_ptr); - return ret; - } - /** - * @param {PayloadType} arg0 - */ - set 1(arg0) { - wasm.__wbg_set_payloadentry_1(this.__wbg_ptr, arg0); - } - /** - * @param {any} value - */ - set value(value) { - wasm.payloadentry_set_value(this.__wbg_ptr, addHeapObject(value)); - } - /** - * @returns {any} - */ - get value() { - const ret = wasm.payloadentry_value(this.__wbg_ptr); - return takeObject(ret); - } -} -module.exports.PayloadEntry = PayloadEntry; - -const PayloadsFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_payloads_free(ptr >>> 0, 1)); -/** -*/ -class Payloads { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Payloads.prototype); - obj.__wbg_ptr = ptr; - PayloadsFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PayloadsFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_payloads_free(ptr, 0); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.payloads_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Payloads} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.payloads_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Payloads.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {Payloads} - */ - clone() { - const ret = wasm.payloads_clone(this.__wbg_ptr); - return Payloads.__wrap(ret); - } - /** - * @param {(PayloadEntry)[]} entries - */ - constructor(entries) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(entries, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.payloads_new(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - PayloadsFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @param {any[]} values - * @returns {Payloads} - */ - static newFromValues(values) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.payloads_newFromValues(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Payloads.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {any[]} - */ - getValues() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.payloads_getValues(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - var v1 = getArrayJsValueFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 4, 4); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {Uint32Array} - */ - getUndisclosedIndexes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.payloads_getUndisclosedIndexes(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v1 = getArrayU32FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 4, 4); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {Uint32Array} - */ - getDisclosedIndexes() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.payloads_getDisclosedIndexes(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v1 = getArrayU32FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 4, 4); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {any[]} - */ - getUndisclosedPayloads() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.payloads_getUndisclosedPayloads(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - if (r3) { - throw takeObject(r2); - } - var v1 = getArrayJsValueFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 4, 4); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {Payloads} - */ - getDisclosedPayloads() { - const ret = wasm.payloads_getDisclosedPayloads(this.__wbg_ptr); - return Payloads.__wrap(ret); - } - /** - * @param {number} index - */ - setUndisclosed(index) { - wasm.payloads_setUndisclosed(this.__wbg_ptr, index); - } - /** - * @param {number} index - * @param {any} value - * @returns {any} - */ - replacePayloadAtIndex(index, value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.payloads_replacePayloadAtIndex(retptr, this.__wbg_ptr, index, addHeapObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Payloads = Payloads; - -const PresentationFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_presentation_free(ptr >>> 0, 1)); -/** -*/ -class Presentation { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Presentation.prototype); - obj.__wbg_ptr = ptr; - PresentationFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PresentationFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_presentation_free(ptr, 0); - } - /** - * Returns the base JSON-LD context. - * @returns {string} - */ - static BaseContext() { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_BaseContext(retptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - var ptr1 = r0; - var len1 = r1; - if (r3) { - ptr1 = 0; len1 = 0; - throw takeObject(r2); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Returns the base type. - * @returns {string} - */ - static BaseType() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_BaseType(retptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Constructs a new presentation. - * @param {IPresentation} values - */ - constructor(values) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_new(retptr, addHeapObject(values)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - PresentationFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the JSON-LD context(s) applicable to the presentation. - * @returns {Array>} - */ - context() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_context(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the unique `URI` identifying the presentation. - * @returns {string | undefined} - */ - id() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_id(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the URIs defining the type of the presentation. - * @returns {Array} - */ - type() { - const ret = wasm.presentation_type(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns the JWT credentials expressing the claims of the presentation. - * @returns {Array} - */ - verifiableCredential() { - const ret = wasm.presentation_verifiableCredential(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns a copy of the URI of the entity that generated the presentation. - * @returns {string} - */ - holder() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_holder(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns a copy of the service(s) used to refresh an expired {@link Credential} in the presentation. - * @returns {Array} - */ - refreshService() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_refreshService(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the terms-of-use specified by the presentation holder - * @returns {Array} - */ - termsOfUse() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_termsOfUse(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Optional cryptographic proof, unrelated to JWT. - * @returns {Proof | undefined} - */ - proof() { - const ret = wasm.presentation_proof(this.__wbg_ptr); - return ret === 0 ? undefined : Proof.__wrap(ret); - } - /** - * Sets the proof property of the {@link Presentation}. - * - * Note that this proof is not related to JWT. - * @param {Proof | undefined} [proof] - */ - setProof(proof) { - let ptr0 = 0; - if (!isLikeNone(proof)) { - _assertClass(proof, Proof); - ptr0 = proof.__destroy_into_raw(); - } - wasm.presentation_setProof(this.__wbg_ptr, ptr0); - } - /** - * Returns a copy of the miscellaneous properties on the presentation. - * @returns {Map} - */ - properties() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_properties(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Presentation} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.presentation_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Presentation.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {Presentation} - */ - clone() { - const ret = wasm.presentation_clone(this.__wbg_ptr); - return Presentation.__wrap(ret); - } -} -module.exports.Presentation = Presentation; - -const PresentationProtectedHeaderFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_presentationprotectedheader_free(ptr >>> 0, 1)); -/** -*/ -class PresentationProtectedHeader { - - toJSON() { - return { - alg: this.alg, - kid: this.kid, - aud: this.aud, - nonce: this.nonce, - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - PresentationProtectedHeaderFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_presentationprotectedheader_free(ptr, 0); - } - /** - * @returns {PresentationProofAlgorithm} - */ - get alg() { - const ret = wasm.__wbg_get_presentationprotectedheader_alg(this.__wbg_ptr); - return ret; - } - /** - * @param {PresentationProofAlgorithm} arg0 - */ - set alg(arg0) { - wasm.__wbg_set_presentationprotectedheader_alg(this.__wbg_ptr, arg0); - } - /** - * ID for the key used for the JWP. - * @returns {string | undefined} - */ - get kid() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_presentationprotectedheader_kid(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * ID for the key used for the JWP. - * @param {string | undefined} [arg0] - */ - set kid(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_presentationprotectedheader_kid(this.__wbg_ptr, ptr0, len0); - } - /** - * Who have received the JPT. - * @returns {string | undefined} - */ - get aud() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_presentationprotectedheader_aud(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Who have received the JPT. - * @param {string | undefined} [arg0] - */ - set aud(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_presentationprotectedheader_aud(this.__wbg_ptr, ptr0, len0); - } - /** - * For replay attacks. - * @returns {string | undefined} - */ - get nonce() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_presentationprotectedheader_nonce(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * For replay attacks. - * @param {string | undefined} [arg0] - */ - set nonce(arg0) { - var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_presentationprotectedheader_nonce(this.__wbg_ptr, ptr0, len0); - } -} -module.exports.PresentationProtectedHeader = PresentationProtectedHeader; - -const ProofFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_proof_free(ptr >>> 0, 1)); -/** -* Represents a cryptographic proof that can be used to validate verifiable credentials and -* presentations. -* -* This representation does not inherently implement any standard; instead, it -* can be utilized to implement standards or user-defined proofs. The presence of the -* `type` field is necessary to accommodate different types of cryptographic proofs. -* -* Note that this proof is not related to JWT and can be used in combination or as an alternative -* to it. -*/ -class Proof { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Proof.prototype); - obj.__wbg_ptr = ptr; - ProofFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ProofFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_proof_free(ptr, 0); - } - /** - * @param {string} type_ - * @param {any} properties - */ - constructor(type_, properties) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(type_, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.proof_constructor(retptr, ptr0, len0, addHeapObject(properties)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - ProofFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the type of proof. - * @returns {string} - */ - type() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.proof_type(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns the properties of the proof. - * @returns {any} - */ - properties() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.proof_properties(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.proof_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Proof} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.proof_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Proof.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {Proof} - */ - clone() { - const ret = wasm.proof_clone(this.__wbg_ptr); - return Proof.__wrap(ret); - } -} -module.exports.Proof = Proof; - -const ProofUpdateCtxFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_proofupdatectx_free(ptr >>> 0, 1)); -/** -*/ -class ProofUpdateCtx { - - toJSON() { - return { - old_start_validity_timeframe: this.old_start_validity_timeframe, - new_start_validity_timeframe: this.new_start_validity_timeframe, - old_end_validity_timeframe: this.old_end_validity_timeframe, - new_end_validity_timeframe: this.new_end_validity_timeframe, - index_start_validity_timeframe: this.index_start_validity_timeframe, - index_end_validity_timeframe: this.index_end_validity_timeframe, - number_of_signed_messages: this.number_of_signed_messages, - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ProofUpdateCtxFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_proofupdatectx_free(ptr, 0); - } - /** - * Old `startValidityTimeframe` value - * @returns {Uint8Array} - */ - get old_start_validity_timeframe() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_proofupdatectx_old_start_validity_timeframe(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Old `startValidityTimeframe` value - * @param {Uint8Array} arg0 - */ - set old_start_validity_timeframe(arg0) { - const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_proofupdatectx_old_start_validity_timeframe(this.__wbg_ptr, ptr0, len0); - } - /** - * New `startValidityTimeframe` value to be signed - * @returns {Uint8Array} - */ - get new_start_validity_timeframe() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_proofupdatectx_new_start_validity_timeframe(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * New `startValidityTimeframe` value to be signed - * @param {Uint8Array} arg0 - */ - set new_start_validity_timeframe(arg0) { - const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_proofupdatectx_new_start_validity_timeframe(this.__wbg_ptr, ptr0, len0); - } - /** - * Old `endValidityTimeframe` value - * @returns {Uint8Array} - */ - get old_end_validity_timeframe() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_proofupdatectx_old_end_validity_timeframe(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Old `endValidityTimeframe` value - * @param {Uint8Array} arg0 - */ - set old_end_validity_timeframe(arg0) { - const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_proofupdatectx_old_end_validity_timeframe(this.__wbg_ptr, ptr0, len0); - } - /** - * New `endValidityTimeframe` value to be signed - * @returns {Uint8Array} - */ - get new_end_validity_timeframe() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.__wbg_get_proofupdatectx_new_end_validity_timeframe(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var v1 = getArrayU8FromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * New `endValidityTimeframe` value to be signed - * @param {Uint8Array} arg0 - */ - set new_end_validity_timeframe(arg0) { - const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - wasm.__wbg_set_proofupdatectx_new_end_validity_timeframe(this.__wbg_ptr, ptr0, len0); - } - /** - * Index of `startValidityTimeframe` claim inside the array of Claims - * @returns {number} - */ - get index_start_validity_timeframe() { - const ret = wasm.__wbg_get_proofupdatectx_index_start_validity_timeframe(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Index of `startValidityTimeframe` claim inside the array of Claims - * @param {number} arg0 - */ - set index_start_validity_timeframe(arg0) { - wasm.__wbg_set_proofupdatectx_index_start_validity_timeframe(this.__wbg_ptr, arg0); - } - /** - * Index of `endValidityTimeframe` claim inside the array of Claims - * @returns {number} - */ - get index_end_validity_timeframe() { - const ret = wasm.__wbg_get_proofupdatectx_index_end_validity_timeframe(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Index of `endValidityTimeframe` claim inside the array of Claims - * @param {number} arg0 - */ - set index_end_validity_timeframe(arg0) { - wasm.__wbg_set_proofupdatectx_index_end_validity_timeframe(this.__wbg_ptr, arg0); - } - /** - * Number of signed messages, number of payloads in a JWP - * @returns {number} - */ - get number_of_signed_messages() { - const ret = wasm.__wbg_get_proofupdatectx_number_of_signed_messages(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Number of signed messages, number of payloads in a JWP - * @param {number} arg0 - */ - set number_of_signed_messages(arg0) { - wasm.__wbg_set_proofupdatectx_number_of_signed_messages(this.__wbg_ptr, arg0); - } -} -module.exports.ProofUpdateCtx = ProofUpdateCtx; - -const ResolverFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_resolver_free(ptr >>> 0, 1)); -/** -* Convenience type for resolving DID documents from different DID methods. -* -* Also provides methods for resolving DID Documents associated with -* verifiable {@link Credential}s and {@link Presentation}s. -* -* # Configuration -* -* The resolver will only be able to resolve DID documents for methods it has been configured for in the constructor. -*/ -class Resolver { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ResolverFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_resolver_free(ptr, 0); - } - /** - * Constructs a new {@link Resolver}. - * - * # Errors - * If both a `client` is given and the `handlers` map contains the "iota" key the construction process - * will throw an error because the handler for the "iota" method then becomes ambiguous. - * @param {ResolverConfig} config - */ - constructor(config) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.resolver_new(retptr, addHeapObject(config)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - ResolverFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Fetches the DID Document of the given DID. - * - * ### Errors - * - * Errors if the resolver has not been configured to handle the method - * corresponding to the given DID or the resolution process itself fails. - * @param {string} did - * @returns {Promise} - */ - resolve(did) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(did, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.resolver_resolve(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Concurrently fetches the DID Documents of the multiple given DIDs. - * - * # Errors - * * If the resolver has not been configured to handle the method of any of the given DIDs. - * * If the resolution process of any DID fails. - * - * ## Note - * * The order of the documents in the returned array matches that in `dids`. - * * If `dids` contains duplicates, these will be resolved only once and the resolved document - * is copied into the returned array to match the order of `dids`. - * @param {Array} dids - * @returns {Promise>} - */ - resolveMultiple(dids) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.resolver_resolveMultiple(retptr, this.__wbg_ptr, addHeapObject(dids)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.Resolver = Resolver; - -const RevocationBitmapFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_revocationbitmap_free(ptr >>> 0, 1)); -/** -* A compressed bitmap for managing credential revocation. -*/ -class RevocationBitmap { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(RevocationBitmap.prototype); - obj.__wbg_ptr = ptr; - RevocationBitmapFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RevocationBitmapFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_revocationbitmap_free(ptr, 0); - } - /** - * Creates a new {@link RevocationBitmap} instance. - */ - constructor() { - const ret = wasm.revocationbitmap_new(); - this.__wbg_ptr = ret >>> 0; - RevocationBitmapFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * The name of the service type. - * @returns {string} - */ - static type() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.revocationbitmap_type(retptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns `true` if the credential at the given `index` is revoked. - * @param {number} index - * @returns {boolean} - */ - isRevoked(index) { - const ret = wasm.revocationbitmap_isRevoked(this.__wbg_ptr, index); - return ret !== 0; - } - /** - * Mark the given index as revoked. - * - * Returns true if the index was absent from the set. - * @param {number} index - * @returns {boolean} - */ - revoke(index) { - const ret = wasm.revocationbitmap_revoke(this.__wbg_ptr, index); - return ret !== 0; - } - /** - * Mark the index as not revoked. - * - * Returns true if the index was present in the set. - * @param {number} index - * @returns {boolean} - */ - unrevoke(index) { - const ret = wasm.revocationbitmap_unrevoke(this.__wbg_ptr, index); - return ret !== 0; - } - /** - * Returns the number of revoked credentials. - * @returns {number} - */ - len() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.revocationbitmap_len(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 >>> 0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Return a `Service` with: - * - the service's id set to `serviceId`, - * - of type `RevocationBitmap2022`, - * - and with the bitmap embedded in a data url in the service's endpoint. - * @param {DIDUrl} serviceId - * @returns {Service} - */ - toService(serviceId) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(serviceId, DIDUrl); - wasm.revocationbitmap_toService(retptr, this.__wbg_ptr, serviceId.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Service.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Try to construct a {@link RevocationBitmap} from a service - * if it is a valid Revocation Bitmap Service. - * @param {Service} service - * @returns {RevocationBitmap} - */ - static fromEndpoint(service) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(service, Service); - wasm.revocationbitmap_fromEndpoint(retptr, service.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return RevocationBitmap.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.RevocationBitmap = RevocationBitmap; - -const RevocationTimeframeStatusFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_revocationtimeframestatus_free(ptr >>> 0, 1)); -/** -* Information used to determine the current status of a {@link Credential}. -*/ -class RevocationTimeframeStatus { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(RevocationTimeframeStatus.prototype); - obj.__wbg_ptr = ptr; - RevocationTimeframeStatusFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - RevocationTimeframeStatusFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_revocationtimeframestatus_free(ptr, 0); - } - /** - * Deep clones the object. - * @returns {RevocationTimeframeStatus} - */ - clone() { - const ret = wasm.revocationtimeframestatus_clone(this.__wbg_ptr); - return RevocationTimeframeStatus.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.revocationtimeframestatus_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {RevocationTimeframeStatus} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.revocationtimeframestatus_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return RevocationTimeframeStatus.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Creates a new `RevocationTimeframeStatus`. - * @param {string} id - * @param {number} index - * @param {Duration} duration - * @param {Timestamp | undefined} [start_validity] - */ - constructor(id, index, duration, start_validity) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - _assertClass(duration, Duration); - var ptr1 = duration.__destroy_into_raw(); - let ptr2 = 0; - if (!isLikeNone(start_validity)) { - _assertClass(start_validity, Timestamp); - ptr2 = start_validity.__destroy_into_raw(); - } - wasm.revocationtimeframestatus_new(retptr, ptr0, len0, index, ptr1, ptr2); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - RevocationTimeframeStatusFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Get startValidityTimeframe value. - * @returns {Timestamp} - */ - startValidityTimeframe() { - const ret = wasm.revocationtimeframestatus_startValidityTimeframe(this.__wbg_ptr); - return Timestamp.__wrap(ret); - } - /** - * Get endValidityTimeframe value. - * @returns {Timestamp} - */ - endValidityTimeframe() { - const ret = wasm.revocationtimeframestatus_endValidityTimeframe(this.__wbg_ptr); - return Timestamp.__wrap(ret); - } - /** - * Return the URL fo the `RevocationBitmapStatus`. - * @returns {string} - */ - id() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.revocationtimeframestatus_id(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Return the index of the credential in the issuer's revocation bitmap - * @returns {number | undefined} - */ - index() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.revocationtimeframestatus_index(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - return r0 === 0 ? undefined : r1 >>> 0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.RevocationTimeframeStatus = RevocationTimeframeStatus; - -const SdJwtFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_sdjwt_free(ptr >>> 0, 1)); -/** -* Representation of an SD-JWT of the format -* `~~~...~~`. -*/ -class SdJwt { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(SdJwt.prototype); - obj.__wbg_ptr = ptr; - SdJwtFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SdJwtFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_sdjwt_free(ptr, 0); - } - /** - * Creates a new `SdJwt` from its components. - * @param {string} jwt - * @param {Array} disclosures - * @param {string | undefined} [key_binding_jwt] - */ - constructor(jwt, disclosures, key_binding_jwt) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(key_binding_jwt) ? 0 : passStringToWasm0(key_binding_jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - wasm.sdjwt_new(retptr, ptr0, len0, addHeapObject(disclosures), ptr1, len1); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - SdJwtFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes the components into the final SD-JWT. - * @returns {string} - */ - presentation() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdjwt_presentation(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Parses an SD-JWT into its components as [`SdJwt`]. - * - * ## Error - * Returns `DeserializationError` if parsing fails. - * @param {string} sd_jwt - * @returns {SdJwt} - */ - static parse(sd_jwt) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(sd_jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.sdjwt_parse(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return SdJwt.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes the components into the final SD-JWT. - * @returns {string} - */ - toString() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdjwt_presentation(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The JWT part. - * @returns {string} - */ - jwt() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdjwt_jwt(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * The disclosures part. - * @returns {Array} - */ - disclosures() { - const ret = wasm.sdjwt_disclosures(this.__wbg_ptr); - return takeObject(ret); - } - /** - * The optional key binding JWT. - * @returns {string | undefined} - */ - keyBindingJwt() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdjwt_keyBindingJwt(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - let v1; - if (r0 !== 0) { - v1 = getStringFromWasm0(r0, r1).slice(); - wasm.__wbindgen_free(r0, r1 * 1, 1); - } - return v1; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deep clones the object. - * @returns {SdJwt} - */ - clone() { - const ret = wasm.sdjwt_clone(this.__wbg_ptr); - return SdJwt.__wrap(ret); - } -} -module.exports.SdJwt = SdJwt; - -const SdJwtCredentialValidatorFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_sdjwtcredentialvalidator_free(ptr >>> 0, 1)); -/** -* A type for decoding and validating {@link Credential}. -*/ -class SdJwtCredentialValidator { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SdJwtCredentialValidatorFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_sdjwtcredentialvalidator_free(ptr, 0); - } - /** - * Creates a new `SdJwtCredentialValidator`. If a `signatureVerifier` is provided it will be used when - * verifying decoded JWS signatures, otherwise the default which is only capable of handling the `EdDSA` - * algorithm will be used. - * @param {IJwsVerifier} signatureVerifier - */ - constructor(signatureVerifier) { - const ret = wasm.sdjwtcredentialvalidator_new(addHeapObject(signatureVerifier)); - this.__wbg_ptr = ret >>> 0; - SdJwtCredentialValidatorFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Decodes and validates a `Credential` issued as an SD-JWT. A `DecodedJwtCredential` is returned upon success. - * The credential is constructed by replacing disclosures following the - * [`Selective Disclosure for JWTs (SD-JWT)`](https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html) standard. - * - * The following properties are validated according to `options`: - * - the issuer's signature on the JWS, - * - the expiration date, - * - the issuance date, - * - the semantic structure. - * - * # Warning - * * The key binding JWT is not validated. If needed, it must be validated separately using - * `SdJwtValidator::validate_key_binding_jwt`. - * * The lack of an error returned from this method is in of itself not enough to conclude that the credential can be - * trusted. This section contains more information on additional checks that should be carried out before and after - * calling this method. - * - * ## The state of the issuer's DID Document - * The caller must ensure that `issuer` represents an up-to-date DID Document. - * - * ## Properties that are not validated - * There are many properties defined in [The Verifiable Credentials Data Model](https://www.w3.org/TR/vc-data-model/) that are **not** validated, such as: - * `proof`, `credentialStatus`, `type`, `credentialSchema`, `refreshService` **and more**. - * These should be manually checked after validation, according to your requirements. - * - * # Errors - * An error is returned whenever a validated condition is not satisfied. - * @param {SdJwt} sd_jwt - * @param {CoreDocument | IToCoreDocument} issuer - * @param {JwtCredentialValidationOptions} options - * @param {FailFast} fail_fast - * @returns {DecodedJwtCredential} - */ - validateCredential(sd_jwt, issuer, options, fail_fast) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(sd_jwt, SdJwt); - _assertClass(options, JwtCredentialValidationOptions); - wasm.sdjwtcredentialvalidator_validateCredential(retptr, this.__wbg_ptr, sd_jwt.__wbg_ptr, addBorrowedObject(issuer), options.__wbg_ptr, fail_fast); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DecodedJwtCredential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Decode and verify the JWS signature of a `Credential` issued as an SD-JWT using the DID Document of a trusted - * issuer and replaces the disclosures. - * - * A `DecodedJwtCredential` is returned upon success. - * - * # Warning - * The caller must ensure that the DID Documents of the trusted issuers are up-to-date. - * - * ## Proofs - * Only the JWS signature is verified. If the `Credential` contains a `proof` property this will not be verified - * by this method. - * - * # Errors - * * If the issuer' URL cannot be parsed. - * * If Signature verification fails. - * * If SD decoding fails. - * @param {SdJwt} credential - * @param {Array} trustedIssuers - * @param {JwsVerificationOptions} options - * @returns {DecodedJwtCredential} - */ - verifySignature(credential, trustedIssuers, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, SdJwt); - _assertClass(options, JwsVerificationOptions); - wasm.sdjwtcredentialvalidator_verifySignature(retptr, this.__wbg_ptr, credential.__wbg_ptr, addBorrowedObject(trustedIssuers), options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return DecodedJwtCredential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Validates a Key Binding JWT (KB-JWT) according to `https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-07.html#name-key-binding-jwt`. - * The Validation process includes: - * * Signature validation using public key materials defined in the `holder` document. - * * `typ` value in KB-JWT header. - * * `sd_hash` claim value in the KB-JWT claim. - * * Optional `nonce`, `aud` and issuance date validation. - * @param {SdJwt} sdJwt - * @param {CoreDocument | IToCoreDocument} holder - * @param {KeyBindingJWTValidationOptions} options - * @returns {KeyBindingJwtClaims} - */ - validateKeyBindingJwt(sdJwt, holder, options) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(sdJwt, SdJwt); - _assertClass(options, KeyBindingJWTValidationOptions); - wasm.sdjwtcredentialvalidator_validateKeyBindingJwt(retptr, this.__wbg_ptr, sdJwt.__wbg_ptr, addBorrowedObject(holder), options.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return KeyBindingJwtClaims.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.SdJwtCredentialValidator = SdJwtCredentialValidator; - -const SdObjectDecoderFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_sdobjectdecoder_free(ptr >>> 0, 1)); -/** -* Substitutes digests in an SD-JWT object by their corresponding plaintext values provided by disclosures. -*/ -class SdObjectDecoder { - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SdObjectDecoderFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_sdobjectdecoder_free(ptr, 0); - } - /** - * Creates a new `SdObjectDecoder` with `sha-256` hasher. - */ - constructor() { - const ret = wasm.sdobjectdecoder_new(); - this.__wbg_ptr = ret >>> 0; - SdObjectDecoderFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Decodes an SD-JWT `object` containing by Substituting the digests with their corresponding - * plaintext values provided by `disclosures`. - * - * ## Notes - * * Claims like `exp` or `iat` are not validated in the process of decoding. - * * `_sd_alg` property will be removed if present. - * @param {Record} object - * @param {Array} disclosures - * @returns {Record} - */ - decode(object, disclosures) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdobjectdecoder_decode(retptr, this.__wbg_ptr, addHeapObject(object), addHeapObject(disclosures)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.SdObjectDecoder = SdObjectDecoder; - -const SdObjectEncoderFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_sdobjectencoder_free(ptr >>> 0, 1)); -/** -* Transforms a JSON object into an SD-JWT object by substituting selected values -* with their corresponding disclosure digests. -* -* Note: digests are created using the sha-256 algorithm. -*/ -class SdObjectEncoder { - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SdObjectEncoderFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_sdobjectencoder_free(ptr, 0); - } - /** - * Creates a new `SdObjectEncoder` with `sha-256` hash function. - * @param {any} object - */ - constructor(object) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdobjectencoder_new(retptr, addBorrowedObject(object)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - SdObjectEncoderFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Substitutes a value with the digest of its disclosure. - * If no salt is provided, the disclosure will be created with a random salt value. - * - * `path` indicates the pointer to the value that will be concealed using the syntax of - * [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901). - * - * For the following object: - * - * ``` - * { - * "id": "did:value", - * "claim1": { - * "abc": true - * }, - * "claim2": ["val_1", "val_2"] - * } - * ``` - * - * Path "/id" conceals `"id": "did:value"` - * Path "/claim1/abc" conceals `"abc": true` - * Path "/claim2/0" conceals `val_1` - * ``` - * - * ## Errors - * * `InvalidPath` if pointer is invalid. - * * `DataTypeMismatch` if existing SD format is invalid. - * @param {string} path - * @param {string | undefined} [salt] - * @returns {Disclosure} - */ - conceal(path, salt) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(salt) ? 0 : passStringToWasm0(salt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - wasm.sdobjectencoder_conceal(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Disclosure.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Adds the `_sd_alg` property to the top level of the object, with - * its value set to "sha-256". - */ - addSdAlgProperty() { - wasm.sdobjectencoder_addSdAlgProperty(this.__wbg_ptr); - } - /** - * Returns the modified object as a string. - * @returns {string} - */ - encodeToString() { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdobjectencoder_encodeToString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - var ptr1 = r0; - var len1 = r1; - if (r3) { - ptr1 = 0; len1 = 0; - throw takeObject(r2); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Returns the modified object as a string. - * @returns {string} - */ - toString() { - let deferred2_0; - let deferred2_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdobjectencoder_encodeToString(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); - var ptr1 = r0; - var len1 = r1; - if (r3) { - ptr1 = 0; len1 = 0; - throw takeObject(r2); - } - deferred2_0 = ptr1; - deferred2_1 = len1; - return getStringFromWasm0(ptr1, len1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); - } - } - /** - * Returns the modified object. - * @returns {Record} - */ - encodeToObject() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdobjectencoder_encodeToObject(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the modified object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.sdobjectencoder_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Adds a decoy digest to the specified path. - * If path is an empty slice, decoys will be added to the top level. - * @param {string} path - * @param {number} number_of_decoys - */ - addDecoys(path, number_of_decoys) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.sdobjectencoder_addDecoys(retptr, this.__wbg_ptr, ptr0, len0, number_of_decoys); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.SdObjectEncoder = SdObjectEncoder; - -const SelectiveDisclosurePresentationFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_selectivedisclosurepresentation_free(ptr >>> 0, 1)); -/** -* Used to construct a JwpPresentedBuilder and handle the selective disclosure of attributes -* - @context MUST NOT be blinded -* - id MUST be blinded -* - type MUST NOT be blinded -* - issuer MUST NOT be blinded -* - issuanceDate MUST be blinded (if Timeframe Revocation mechanism is used) -* - expirationDate MUST be blinded (if Timeframe Revocation mechanism is used) -* - credentialSubject (User have to choose which attribute must be blinded) -* - credentialSchema MUST NOT be blinded -* - credentialStatus MUST NOT be blinded -* - refreshService MUST NOT be blinded (probably will be used for Timeslot Revocation mechanism) -* - termsOfUse NO reason to use it in ZK VC (will be in any case blinded) -* - evidence (User have to choose which attribute must be blinded) -*/ -class SelectiveDisclosurePresentation { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - SelectiveDisclosurePresentationFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_selectivedisclosurepresentation_free(ptr, 0); - } - /** - * Initialize a presentation starting from an Issued JWP. - * The properties `jti`, `nbf`, `issuanceDate`, `expirationDate` and `termsOfUse` are concealed by default. - * @param {JwpIssued} issued_jwp - */ - constructor(issued_jwp) { - _assertClass(issued_jwp, JwpIssued); - var ptr0 = issued_jwp.__destroy_into_raw(); - const ret = wasm.selectivedisclosurepresentation_new(ptr0); - this.__wbg_ptr = ret >>> 0; - SelectiveDisclosurePresentationFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Selectively disclose "credentialSubject" attributes. - * # Example - * ``` - * { - * "id": 1234, - * "name": "Alice", - * "mainCourses": ["Object-oriented Programming", "Mathematics"], - * "degree": { - * "type": "BachelorDegree", - * "name": "Bachelor of Science and Arts", - * }, - * "GPA": "4.0", - * } - * ``` - * If you want to undisclose for example the Mathematics course and the name of the degree: - * ``` - * undisclose_subject("mainCourses[1]"); - * undisclose_subject("degree.name"); - * ``` - * @param {string} path - */ - concealInSubject(path) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.selectivedisclosurepresentation_concealInSubject(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Undiscloses "evidence" attributes. - * @param {string} path - */ - concealInEvidence(path) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.selectivedisclosurepresentation_concealInEvidence(retptr, this.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets presentation protected header. - * @param {PresentationProtectedHeader} header - */ - setPresentationHeader(header) { - _assertClass(header, PresentationProtectedHeader); - var ptr0 = header.__destroy_into_raw(); - wasm.selectivedisclosurepresentation_setPresentationHeader(this.__wbg_ptr, ptr0); - } -} -module.exports.SelectiveDisclosurePresentation = SelectiveDisclosurePresentation; - -const ServiceFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_service_free(ptr >>> 0, 1)); -/** -* A DID Document Service used to enable trusted interactions associated with a DID subject. -*/ -class Service { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Service.prototype); - obj.__wbg_ptr = ptr; - ServiceFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - ServiceFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_service_free(ptr, 0); - } - /** - * @param {IService} service - */ - constructor(service) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.service_new(retptr, addHeapObject(service)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - ServiceFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the {@link Service} id. - * @returns {DIDUrl} - */ - id() { - const ret = wasm.service_id(this.__wbg_ptr); - return DIDUrl.__wrap(ret); - } - /** - * Returns a copy of the {@link Service} type. - * @returns {Array} - */ - type() { - const ret = wasm.service_type(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns a copy of the {@link Service} endpoint. - * @returns {string | string[] | Map} - */ - serviceEndpoint() { - const ret = wasm.service_serviceEndpoint(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Returns a copy of the custom properties on the {@link Service}. - * @returns {Map} - */ - properties() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.service_properties(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.service_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Service} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.service_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Service.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {Service} - */ - clone() { - const ret = wasm.service_clone(this.__wbg_ptr); - return Service.__wrap(ret); - } -} -module.exports.Service = Service; - -const StatusList2021Finalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_statuslist2021_free(ptr >>> 0, 1)); -/** -* StatusList2021 data structure as described in [W3C's VC status list 2021](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/). -*/ -class StatusList2021 { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(StatusList2021.prototype); - obj.__wbg_ptr = ptr; - StatusList2021Finalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StatusList2021Finalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_statuslist2021_free(ptr, 0); - } - /** - * Deep clones the object. - * @returns {StatusList2021} - */ - clone() { - const ret = wasm.statuslist2021_clone(this.__wbg_ptr); - return StatusList2021.__wrap(ret); - } - /** - * Creates a new {@link StatusList2021} of `size` entries. - * @param {number | undefined} [size] - */ - constructor(size) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021_new(retptr, !isLikeNone(size), isLikeNone(size) ? 0 : size); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - StatusList2021Finalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the number of entries in this {@link StatusList2021}. - * @returns {number} - */ - len() { - const ret = wasm.statuslist2021_len(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Returns whether the entry at `index` is set. - * @param {number} index - * @returns {boolean} - */ - get(index) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021_get(retptr, this.__wbg_ptr, index); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0 !== 0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the value of the `index`-th entry. - * @param {number} index - * @param {boolean} value - */ - set(index, value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021_set(retptr, this.__wbg_ptr, index, value); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Encodes this {@link StatusList2021} into its compressed - * base64 string representation. - * @returns {string} - */ - intoEncodedStr() { - let deferred1_0; - let deferred1_1; - try { - const ptr = this.__destroy_into_raw(); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021_intoEncodedStr(retptr, ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Attempts to decode a {@link StatusList2021} from a string. - * @param {string} s - * @returns {StatusList2021} - */ - static fromEncodedStr(s) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.statuslist2021_fromEncodedStr(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return StatusList2021.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.StatusList2021 = StatusList2021; - -const StatusList2021CredentialFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_statuslist2021credential_free(ptr >>> 0, 1)); -/** -* A parsed [StatusList2021Credential](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/#statuslist2021credential). -*/ -class StatusList2021Credential { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(StatusList2021Credential.prototype); - obj.__wbg_ptr = ptr; - StatusList2021CredentialFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StatusList2021CredentialFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_statuslist2021credential_free(ptr, 0); - } - /** - * Creates a new {@link StatusList2021Credential}. - * @param {Credential} credential - */ - constructor(credential) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - var ptr0 = credential.__destroy_into_raw(); - wasm.statuslist2021credential_new(retptr, ptr0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - StatusList2021CredentialFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {string} - */ - id() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021credential_id(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Sets the given credential's status using the `index`-th entry of this status list. - * Returns the created `credentialStatus`. - * @param {Credential} credential - * @param {number} index - * @param {boolean} revoked_or_suspended - * @returns {StatusList2021Entry} - */ - setCredentialStatus(credential, index, revoked_or_suspended) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(credential, Credential); - wasm.statuslist2021credential_setCredentialStatus(retptr, this.__wbg_ptr, credential.__wbg_ptr, index, revoked_or_suspended); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return StatusList2021Entry.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns the {@link StatusPurpose} of this {@link StatusList2021Credential}. - * @returns {StatusPurpose} - */ - purpose() { - const ret = wasm.statuslist2021credential_purpose(this.__wbg_ptr); - return ret; - } - /** - * Returns the state of the `index`-th entry, if any. - * @param {number} index - * @returns {CredentialStatus} - */ - entry(index) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021credential_entry(retptr, this.__wbg_ptr, index); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return r0; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {StatusList2021Credential} - */ - clone() { - const ret = wasm.statuslist2021credential_clone(this.__wbg_ptr); - return StatusList2021Credential.__wrap(ret); - } - /** - * @param {any} json - * @returns {StatusList2021Credential} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021credential_fromJSON(retptr, addHeapObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return StatusList2021Credential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021credential_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.StatusList2021Credential = StatusList2021Credential; - -const StatusList2021CredentialBuilderFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_statuslist2021credentialbuilder_free(ptr >>> 0, 1)); -/** -* Builder type to construct valid {@link StatusList2021Credential} istances. -*/ -class StatusList2021CredentialBuilder { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(StatusList2021CredentialBuilder.prototype); - obj.__wbg_ptr = ptr; - StatusList2021CredentialBuilderFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StatusList2021CredentialBuilderFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_statuslist2021credentialbuilder_free(ptr, 0); - } - /** - * Creates a new {@link StatusList2021CredentialBuilder}. - * @param {StatusList2021 | undefined} [status_list] - */ - constructor(status_list) { - let ptr0 = 0; - if (!isLikeNone(status_list)) { - _assertClass(status_list, StatusList2021); - ptr0 = status_list.__destroy_into_raw(); - } - const ret = wasm.statuslist2021credentialbuilder_new(ptr0); - this.__wbg_ptr = ret >>> 0; - StatusList2021CredentialBuilderFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Sets the purpose of the {@link StatusList2021Credential} that is being created. - * @param {StatusPurpose} purpose - * @returns {StatusList2021CredentialBuilder} - */ - purpose(purpose) { - const ptr = this.__destroy_into_raw(); - const ret = wasm.statuslist2021credentialbuilder_purpose(ptr, purpose); - return StatusList2021CredentialBuilder.__wrap(ret); - } - /** - * Sets `credentialSubject.id`. - * @param {string} id - * @returns {StatusList2021CredentialBuilder} - */ - subjectId(id) { - try { - const ptr = this.__destroy_into_raw(); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.statuslist2021credentialbuilder_subjectId(retptr, ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return StatusList2021CredentialBuilder.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the expiration date of the credential. - * @param {Timestamp} time - * @returns {StatusList2021CredentialBuilder} - */ - expirationDate(time) { - const ptr = this.__destroy_into_raw(); - _assertClass(time, Timestamp); - var ptr0 = time.__destroy_into_raw(); - const ret = wasm.statuslist2021credentialbuilder_expirationDate(ptr, ptr0); - return StatusList2021CredentialBuilder.__wrap(ret); - } - /** - * Sets the issuer of the credential. - * @param {string} issuer - * @returns {StatusList2021CredentialBuilder} - */ - issuer(issuer) { - try { - const ptr = this.__destroy_into_raw(); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(issuer, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.statuslist2021credentialbuilder_issuer(retptr, ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return StatusList2021CredentialBuilder.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Sets the context of the credential. - * @param {string} context - * @returns {StatusList2021CredentialBuilder} - */ - context(context) { - try { - const ptr = this.__destroy_into_raw(); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(context, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.statuslist2021credentialbuilder_context(retptr, ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return StatusList2021CredentialBuilder.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Adds a credential type. - * @param {string} t - * @returns {StatusList2021CredentialBuilder} - */ - type(t) { - const ptr = this.__destroy_into_raw(); - const ptr0 = passStringToWasm0(t, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ret = wasm.statuslist2021credentialbuilder_type(ptr, ptr0, len0); - return StatusList2021CredentialBuilder.__wrap(ret); - } - /** - * Adds a credential's proof. - * @param {Proof} proof - * @returns {StatusList2021CredentialBuilder} - */ - proof(proof) { - const ptr = this.__destroy_into_raw(); - _assertClass(proof, Proof); - var ptr0 = proof.__destroy_into_raw(); - const ret = wasm.statuslist2021credentialbuilder_proof(ptr, ptr0); - return StatusList2021CredentialBuilder.__wrap(ret); - } - /** - * Attempts to build a valid {@link StatusList2021Credential} with the previously provided data. - * @returns {StatusList2021Credential} - */ - build() { - try { - const ptr = this.__destroy_into_raw(); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021credentialbuilder_build(retptr, ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return StatusList2021Credential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } -} -module.exports.StatusList2021CredentialBuilder = StatusList2021CredentialBuilder; - -const StatusList2021EntryFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_statuslist2021entry_free(ptr >>> 0, 1)); -/** -* [StatusList2021Entry](https://www.w3.org/TR/2023/WD-vc-status-list-20230427/#statuslist2021entry) implementation. -*/ -class StatusList2021Entry { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(StatusList2021Entry.prototype); - obj.__wbg_ptr = ptr; - StatusList2021EntryFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StatusList2021EntryFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_statuslist2021entry_free(ptr, 0); - } - /** - * Creates a new {@link StatusList2021Entry}. - * @param {string} status_list - * @param {StatusPurpose} purpose - * @param {number} index - * @param {string | undefined} [id] - */ - constructor(status_list, purpose, index, id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(status_list, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - var ptr1 = isLikeNone(id) ? 0 : passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - wasm.statuslist2021entry_new(retptr, ptr0, len0, purpose, index, ptr1, len1); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - StatusList2021EntryFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns this `credentialStatus`'s `id`. - * @returns {string} - */ - id() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021entry_id(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Returns the purpose of this entry. - * @returns {StatusPurpose} - */ - purpose() { - const ret = wasm.statuslist2021entry_purpose(this.__wbg_ptr); - return ret; - } - /** - * Returns the index of this entry. - * @returns {number} - */ - index() { - const ret = wasm.statuslist2021entry_index(this.__wbg_ptr); - return ret >>> 0; - } - /** - * Returns the referenced {@link StatusList2021Credential}'s url. - * @returns {string} - */ - statusListCredential() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021entry_statusListCredential(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Downcasts {@link this} to {@link Status} - * @returns {Status} - */ - toStatus() { - try { - const ptr = this.__destroy_into_raw(); - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021entry_toStatus(retptr, ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deep clones the object. - * @returns {StatusList2021Entry} - */ - clone() { - const ret = wasm.statuslist2021entry_clone(this.__wbg_ptr); - return StatusList2021Entry.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021entry_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {StatusList2021Entry} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.statuslist2021entry_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return StatusList2021Entry.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.StatusList2021Entry = StatusList2021Entry; - -const StorageFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_storage_free(ptr >>> 0, 1)); -/** -* A type wrapping a `JwkStorage` and `KeyIdStorage` that should always be used together when -* working with storage backed DID documents. -*/ -class Storage { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StorageFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_storage_free(ptr, 0); - } - /** - * Constructs a new `Storage`. - * @param {JwkStorage} jwkStorage - * @param {KeyIdStorage} keyIdStorage - */ - constructor(jwkStorage, keyIdStorage) { - const ret = wasm.storage_new(addHeapObject(jwkStorage), addHeapObject(keyIdStorage)); - this.__wbg_ptr = ret >>> 0; - StorageFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Obtain the wrapped `KeyIdStorage`. - * @returns {KeyIdStorage} - */ - keyIdStorage() { - const ret = wasm.storage_keyIdStorage(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Obtain the wrapped `JwkStorage`. - * @returns {JwkStorage} - */ - keyStorage() { - const ret = wasm.storage_keyStorage(this.__wbg_ptr); - return takeObject(ret); - } -} -module.exports.Storage = Storage; - -const TimestampFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_timestamp_free(ptr >>> 0, 1)); -/** -*/ -class Timestamp { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(Timestamp.prototype); - obj.__wbg_ptr = ptr; - TimestampFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - TimestampFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_timestamp_free(ptr, 0); - } - /** - * Creates a new {@link Timestamp} with the current date and time. - */ - constructor() { - const ret = wasm.timestamp_new(); - this.__wbg_ptr = ret >>> 0; - TimestampFinalization.register(this, this.__wbg_ptr, this); - return this; - } - /** - * Parses a {@link Timestamp} from the provided input string. - * @param {string} input - * @returns {Timestamp} - */ - static parse(input) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.timestamp_parse(retptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Timestamp.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Creates a new {@link Timestamp} with the current date and time. - * @returns {Timestamp} - */ - static nowUTC() { - const ret = wasm.timestamp_new(); - return Timestamp.__wrap(ret); - } - /** - * Returns the {@link Timestamp} as an RFC 3339 `String`. - * @returns {string} - */ - toRFC3339() { - let deferred1_0; - let deferred1_1; - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.timestamp_toRFC3339(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - deferred1_0 = r0; - deferred1_1 = r1; - return getStringFromWasm0(r0, r1); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } - } - /** - * Computes `self + duration` - * - * Returns `null` if the operation leads to a timestamp not in the valid range for [RFC 3339](https://tools.ietf.org/html/rfc3339). - * @param {Duration} duration - * @returns {Timestamp | undefined} - */ - checkedAdd(duration) { - _assertClass(duration, Duration); - const ret = wasm.timestamp_checkedAdd(this.__wbg_ptr, duration.__wbg_ptr); - return ret === 0 ? undefined : Timestamp.__wrap(ret); - } - /** - * Computes `self - duration` - * - * Returns `null` if the operation leads to a timestamp not in the valid range for [RFC 3339](https://tools.ietf.org/html/rfc3339). - * @param {Duration} duration - * @returns {Timestamp | undefined} - */ - checkedSub(duration) { - _assertClass(duration, Duration); - const ret = wasm.timestamp_checkedSub(this.__wbg_ptr, duration.__wbg_ptr); - return ret === 0 ? undefined : Timestamp.__wrap(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.timestamp_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {Timestamp} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.timestamp_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return Timestamp.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } -} -module.exports.Timestamp = Timestamp; - -const UnknownCredentialFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_unknowncredential_free(ptr >>> 0, 1)); -/** -*/ -class UnknownCredential { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(UnknownCredential.prototype); - obj.__wbg_ptr = ptr; - UnknownCredentialFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - UnknownCredentialFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_unknowncredential_free(ptr, 0); - } - /** - * Returns a {@link Jwt} if the credential is of type string, `undefined` otherwise. - * @returns {Jwt | undefined} - */ - tryIntoJwt() { - const ret = wasm.unknowncredential_tryIntoJwt(this.__wbg_ptr); - return ret === 0 ? undefined : Jwt.__wrap(ret); - } - /** - * Returns a {@link Credential} if the credential is of said type, `undefined` otherwise. - * @returns {Credential | undefined} - */ - tryIntoCredential() { - const ret = wasm.unknowncredential_tryIntoCredential(this.__wbg_ptr); - return ret === 0 ? undefined : Credential.__wrap(ret); - } - /** - * Returns the contained value as an Object, if it can be converted, `undefined` otherwise. - * @returns {Record | undefined} - */ - tryIntoRaw() { - const ret = wasm.unknowncredential_tryIntoRaw(this.__wbg_ptr); - return takeObject(ret); - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.unknowncredential_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {UnknownCredential} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.unknowncredential_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return UnknownCredential.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {UnknownCredential} - */ - clone() { - const ret = wasm.unknowncredential_clone(this.__wbg_ptr); - return UnknownCredential.__wrap(ret); - } -} -module.exports.UnknownCredential = UnknownCredential; - -const VerificationMethodFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => { }, unregister: () => { } } - : new FinalizationRegistry(ptr => wasm.__wbg_verificationmethod_free(ptr >>> 0, 1)); -/** -* A DID Document Verification Method. -*/ -class VerificationMethod { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(VerificationMethod.prototype); - obj.__wbg_ptr = ptr; - VerificationMethodFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - toJSON() { - return { - }; - } - - toString() { - return JSON.stringify(this); - } - - [inspect.custom]() { - return Object.assign(Object.create({ constructor: this.constructor }), this.toJSON()); - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - VerificationMethodFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_verificationmethod_free(ptr, 0); - } - /** - * Creates a new {@link VerificationMethod} from the given `did` and {@link Jwk}. If `fragment` is not given - * the `kid` value of the given `key` will be used, if present, otherwise an error is returned. - * - * ### Recommendations - * The following recommendations are essentially taken from the `publicKeyJwk` description from the [DID specification](https://www.w3.org/TR/did-core/#dfn-publickeyjwk): - * - It is recommended that verification methods that use `Jwks` to represent their public keys use the value of - * `kid` as their fragment identifier. This is - * done automatically if `None` is passed in as the fragment. - * - It is recommended that {@link Jwk} kid values are set to the public key fingerprint. - * @param {CoreDID | IToCoreDID} did - * @param {Jwk} key - * @param {string | undefined} [fragment] - * @returns {VerificationMethod} - */ - static newFromJwk(did, key, fragment) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(key, Jwk); - var ptr0 = isLikeNone(fragment) ? 0 : passStringToWasm0(fragment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len0 = WASM_VECTOR_LEN; - wasm.verificationmethod_newFromJwk(retptr, addBorrowedObject(did), key.__wbg_ptr, ptr0, len0); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return VerificationMethod.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Create a custom {@link VerificationMethod}. - * @param {DIDUrl} id - * @param {CoreDID} controller - * @param {MethodType} type_ - * @param {MethodData} data - */ - constructor(id, controller, type_, data) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(id, DIDUrl); - _assertClass(controller, CoreDID); - _assertClass(type_, MethodType); - _assertClass(data, MethodData); - wasm.verificationmethod_new(retptr, id.__wbg_ptr, controller.__wbg_ptr, type_.__wbg_ptr, data.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - this.__wbg_ptr = r0 >>> 0; - VerificationMethodFinalization.register(this, this.__wbg_ptr, this); - return this; - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the {@link DIDUrl} of the {@link VerificationMethod}'s `id`. - * @returns {DIDUrl} - */ - id() { - const ret = wasm.verificationmethod_id(this.__wbg_ptr); - return DIDUrl.__wrap(ret); - } - /** - * Sets the id of the {@link VerificationMethod}. - * @param {DIDUrl} id - */ - setId(id) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - _assertClass(id, DIDUrl); - wasm.verificationmethod_setId(retptr, this.__wbg_ptr, id.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Returns a copy of the `controller` `DID` of the {@link VerificationMethod}. - * @returns {CoreDID} - */ - controller() { - const ret = wasm.verificationmethod_controller(this.__wbg_ptr); - return CoreDID.__wrap(ret); - } - /** - * Sets the `controller` `DID` of the {@link VerificationMethod} object. - * @param {CoreDID} did - */ - setController(did) { - _assertClass(did, CoreDID); - wasm.verificationmethod_setController(this.__wbg_ptr, did.__wbg_ptr); - } - /** - * Returns a copy of the {@link VerificationMethod} type. - * @returns {MethodType} - */ - type() { - const ret = wasm.verificationmethod_type(this.__wbg_ptr); - return MethodType.__wrap(ret); - } - /** - * Sets the {@link VerificationMethod} type. - * @param {MethodType} type_ - */ - setType(type_) { - _assertClass(type_, MethodType); - wasm.verificationmethod_setType(this.__wbg_ptr, type_.__wbg_ptr); - } - /** - * Returns a copy of the {@link VerificationMethod} public key data. - * @returns {MethodData} - */ - data() { - const ret = wasm.verificationmethod_data(this.__wbg_ptr); - return MethodData.__wrap(ret); - } - /** - * Sets {@link VerificationMethod} public key data. - * @param {MethodData} data - */ - setData(data) { - _assertClass(data, MethodData); - wasm.verificationmethod_setData(this.__wbg_ptr, data.__wbg_ptr); - } - /** - * Get custom properties of the Verification Method. - * @returns {Map} - */ - properties() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.verificationmethod_properties(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Adds a custom property to the Verification Method. - * If the value is set to `null`, the custom property will be removed. - * - * ### WARNING - * This method can overwrite existing properties like `id` and result - * in an invalid Verification Method. - * @param {string} key - * @param {any} value - */ - setPropertyUnchecked(key, value) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - wasm.verificationmethod_setPropertyUnchecked(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(value)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - if (r1) { - throw takeObject(r0); - } - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Serializes this to a JSON object. - * @returns {any} - */ - toJSON() { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.verificationmethod_toJSON(retptr, this.__wbg_ptr); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return takeObject(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - } - } - /** - * Deserializes an instance from a JSON object. - * @param {any} json - * @returns {VerificationMethod} - */ - static fromJSON(json) { - try { - const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); - wasm.verificationmethod_fromJSON(retptr, addBorrowedObject(json)); - var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); - var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); - var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); - if (r2) { - throw takeObject(r1); - } - return VerificationMethod.__wrap(r0); - } finally { - wasm.__wbindgen_add_to_stack_pointer(16); - heap[stack_pointer++] = undefined; - } - } - /** - * Deep clones the object. - * @returns {VerificationMethod} - */ - clone() { - const ret = wasm.verificationmethod_clone(this.__wbg_ptr); - return VerificationMethod.__wrap(ret); - } -} -module.exports.VerificationMethod = VerificationMethod; - -module.exports.__wbg_service_new = function (arg0) { - const ret = Service.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_object_drop_ref = function (arg0) { - takeObject(arg0); -}; - -module.exports.__wbg_verificationmethod_new = function (arg0) { - const ret = VerificationMethod.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_jwt_new = function (arg0) { - const ret = Jwt.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_unknowncredential_new = function (arg0) { - const ret = UnknownCredential.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_jpt_new = function (arg0) { - const ret = Jpt.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_iotadocument_new = function (arg0) { - const ret = IotaDocument.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_coredid_new = function (arg0) { - const ret = CoreDID.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_jws_new = function (arg0) { - const ret = Jws.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_iotadid_new = function (arg0) { - const ret = IotaDID.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_didurl_new = function (arg0) { - const ret = DIDUrl.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_jwkgenoutput_new = function (arg0) { - const ret = JwkGenOutput.__wrap(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbg_payloadentry_unwrap = function (arg0) { - const ret = PayloadEntry.__unwrap(takeObject(arg0)); - return ret; -}; - -module.exports.__wbindgen_string_new = function (arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_object_clone_ref = function (arg0) { - const ret = getObject(arg0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_error_new = function (arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_generate_7a89d14c93c6da18 = function (arg0, arg1, arg2, arg3, arg4) { - let deferred0_0; - let deferred0_1; - let deferred1_0; - let deferred1_1; - try { - deferred0_0 = arg1; - deferred0_1 = arg2; - deferred1_0 = arg3; - deferred1_1 = arg4; - const ret = getObject(arg0).generate(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); - return addHeapObject(ret); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - wasm.__wbindgen_free(deferred1_0, deferred1_1, 1); - } -}; - -module.exports.__wbg_insert_da8b50c74383af0d = function (arg0, arg1) { - const ret = getObject(arg0).insert(Jwk.__wrap(arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_sign_421bfbd38dd4553a = function (arg0, arg1, arg2, arg3, arg4, arg5) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg1; - deferred0_1 = arg2; - var v1 = getArrayU8FromWasm0(arg3, arg4).slice(); - wasm.__wbindgen_free(arg3, arg4 * 1, 1); - const ret = getObject(arg0).sign(getStringFromWasm0(arg1, arg2), v1, Jwk.__wrap(arg5)); - return addHeapObject(ret); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } -}; - -module.exports.__wbg_delete_2ee32e53cb78797f = function (arg0, arg1, arg2) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg1; - deferred0_1 = arg2; - const ret = getObject(arg0).delete(getStringFromWasm0(arg1, arg2)); - return addHeapObject(ret); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } -}; - -module.exports.__wbg_getkey_7593da5ee7e5f5f0 = function (arg0, arg1, arg2) { - const ret = getObject(arg0)._get_key(getStringFromWasm0(arg1, arg2)); - let ptr1 = 0; - if (!isLikeNone(ret)) { - _assertClass(ret, Jwk); - ptr1 = ret.__destroy_into_raw(); - } - return ptr1; -}; - -module.exports.__wbindgen_is_string = function (arg0) { - const ret = typeof (getObject(arg0)) === 'string'; - return ret; -}; - -module.exports.__wbg_client_9b83f75e2726d87f = function (arg0) { - const ret = getObject(arg0).client; - return isLikeNone(ret) ? 0 : addHeapObject(ret); -}; - -module.exports.__wbg_handlers_faa84e527a39cdf8 = function (arg0) { - const ret = getObject(arg0).handlers; - return isLikeNone(ret) ? 0 : addHeapObject(ret); -}; - -module.exports.__wbindgen_json_parse = function (arg0, arg1) { - const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_json_serialize = function (arg0, arg1) { - const obj = getObject(arg1); - const ret = JSON.stringify(obj === undefined ? null : obj); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -}; - -module.exports.__wbg_getAliasOutput_cec17fa4c27f521a = function (arg0, arg1, arg2) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg1; - deferred0_1 = arg2; - const ret = getObject(arg0).getAliasOutput(getStringFromWasm0(arg1, arg2)); - return addHeapObject(ret); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } -}; - -module.exports.__wbg_getProtocolParameters_c2d053891e679b55 = function (arg0) { - const ret = getObject(arg0).getProtocolParameters(); - return addHeapObject(ret); -}; - -module.exports.__wbg_insertKeyId_99b1ef8ced0ab42e = function (arg0, arg1, arg2, arg3) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg2; - deferred0_1 = arg3; - const ret = getObject(arg0).insertKeyId(MethodDigest.__wrap(arg1), getStringFromWasm0(arg2, arg3)); - return addHeapObject(ret); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } -}; - -module.exports.__wbg_getKeyId_5b3b70e12f7e53aa = function (arg0, arg1) { - const ret = getObject(arg0).getKeyId(MethodDigest.__wrap(arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_deleteKeyId_e47ce8f9b5a1d684 = function (arg0, arg1) { - const ret = getObject(arg0).deleteKeyId(MethodDigest.__wrap(arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_verify_0b54d052c343c289 = function () { - return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg1; - deferred0_1 = arg2; - var v1 = getArrayU8FromWasm0(arg3, arg4).slice(); - wasm.__wbindgen_free(arg3, arg4 * 1, 1); - var v2 = getArrayU8FromWasm0(arg5, arg6).slice(); - wasm.__wbindgen_free(arg5, arg6 * 1, 1); - getObject(arg0).verify(getStringFromWasm0(arg1, arg2), v1, v2, Jwk.__wrap(arg7)); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } - }, arguments) -}; - -module.exports.__wbindgen_string_get = function (arg0, arg1) { - const obj = getObject(arg1); - const ret = typeof (obj) === 'string' ? obj : undefined; - var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -}; - -module.exports.__wbg_maybeGetIotaDocumentInternal_fd250ef4074a0c1e = function (arg0) { - const ret = _maybeGetIotaDocumentInternal(getObject(arg0)); - let ptr1 = 0; - if (!isLikeNone(ret)) { - _assertClass(ret, IotaDocument); - ptr1 = ret.__destroy_into_raw(); - } - return ptr1; -}; - -module.exports.__wbg_getCoreDocumentInternal_e937cd8649fc1d76 = function (arg0) { - const ret = _getCoreDocumentInternal(getObject(arg0)); - _assertClass(ret, CoreDocument); - var ptr1 = ret.__destroy_into_raw(); - return ptr1; -}; - -module.exports.__wbg_id_81f123397a43f160 = function (arg0) { - const ret = getObject(arg0).id; - return addHeapObject(ret); -}; - -module.exports.__wbg_type_a6d92648720e7f8b = function (arg0) { - const ret = getObject(arg0).type; - return addHeapObject(ret); -}; - -module.exports.__wbg_serviceEndpoint_3133f0c11b566fad = function (arg0) { - const ret = getObject(arg0).serviceEndpoint; - return addHeapObject(ret); -}; - -module.exports.__wbg_properties_4246821a1cd87560 = function (arg0) { - const ret = getObject(arg0).properties; - return addHeapObject(ret); -}; - -module.exports.__wbg_getCoreDidCloneInternal_9d05a6ed9c0bc653 = function (arg0) { - const ret = _getCoreDidCloneInternal(getObject(arg0)); - _assertClass(ret, CoreDID); - var ptr1 = ret.__destroy_into_raw(); - return ptr1; -}; - -module.exports.__wbg_new_abda76e883ba8a5f = function () { - const ret = new Error(); - return addHeapObject(ret); -}; - -module.exports.__wbg_stack_658279fe44541cf6 = function (arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -}; - -module.exports.__wbg_error_f851667af71bcfc6 = function (arg0, arg1) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg0; - deferred0_1 = arg1; - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } -}; - -module.exports.__wbg_queueMicrotask_12a30234db4045d3 = function (arg0) { - queueMicrotask(getObject(arg0)); -}; - -module.exports.__wbg_queueMicrotask_48421b3cc9052b68 = function (arg0) { - const ret = getObject(arg0).queueMicrotask; - return addHeapObject(ret); -}; - -module.exports.__wbindgen_is_function = function (arg0) { - const ret = typeof (getObject(arg0)) === 'function'; - return ret; -}; - -module.exports.__wbindgen_cb_drop = function (arg0) { - const obj = takeObject(arg0).original; - if (obj.cnt-- == 1) { - obj.a = 0; - return true; - } - const ret = false; - return ret; -}; - -module.exports.__wbg_crypto_1d1f22824a6a080c = function (arg0) { - const ret = getObject(arg0).crypto; - return addHeapObject(ret); -}; - -module.exports.__wbindgen_is_object = function (arg0) { - const val = getObject(arg0); - const ret = typeof (val) === 'object' && val !== null; - return ret; -}; - -module.exports.__wbg_process_4a72847cc503995b = function (arg0) { - const ret = getObject(arg0).process; - return addHeapObject(ret); -}; - -module.exports.__wbg_versions_f686565e586dd935 = function (arg0) { - const ret = getObject(arg0).versions; - return addHeapObject(ret); -}; - -module.exports.__wbg_node_104a2ff8d6ea03a2 = function (arg0) { - const ret = getObject(arg0).node; - return addHeapObject(ret); -}; - -module.exports.__wbg_require_cca90b1a94a0255b = function () { - return handleError(function () { - const ret = module.require; - return addHeapObject(ret); - }, arguments) -}; - -module.exports.__wbg_msCrypto_eb05e62b530a1508 = function (arg0) { - const ret = getObject(arg0).msCrypto; - return addHeapObject(ret); -}; - -module.exports.__wbg_randomFillSync_5c9c955aa56b6049 = function () { - return handleError(function (arg0, arg1) { - getObject(arg0).randomFillSync(takeObject(arg1)); - }, arguments) -}; - -module.exports.__wbg_getRandomValues_3aa56aa6edec874c = function () { - return handleError(function (arg0, arg1) { - getObject(arg0).getRandomValues(getObject(arg1)); - }, arguments) -}; - -module.exports.__wbg_get_3baa728f9d58d3f6 = function (arg0, arg1) { - const ret = getObject(arg0)[arg1 >>> 0]; - return addHeapObject(ret); -}; - -module.exports.__wbg_length_ae22078168b726f5 = function (arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -module.exports.__wbg_new_a220cf903aa02ca2 = function () { - const ret = new Array(); - return addHeapObject(ret); -}; - -module.exports.__wbg_newnoargs_76313bd6ff35d0f2 = function (arg0, arg1) { - const ret = new Function(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_new_8608a2b51a5f6737 = function () { - const ret = new Map(); - return addHeapObject(ret); -}; - -module.exports.__wbg_next_f9cb570345655b9a = function () { - return handleError(function (arg0) { - const ret = getObject(arg0).next(); - return addHeapObject(ret); - }, arguments) -}; - -module.exports.__wbg_done_bfda7aa8f252b39f = function (arg0) { - const ret = getObject(arg0).done; - return ret; -}; - -module.exports.__wbg_value_6d39332ab4788d86 = function (arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); -}; - -module.exports.__wbg_call_1084a111329e68ce = function () { - return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); - }, arguments) -}; - -module.exports.__wbg_self_3093d5d1f7bcb682 = function () { - return handleError(function () { - const ret = self.self; - return addHeapObject(ret); - }, arguments) -}; - -module.exports.__wbg_window_3bcfc4d31bc012f8 = function () { - return handleError(function () { - const ret = window.window; - return addHeapObject(ret); - }, arguments) -}; - -module.exports.__wbg_globalThis_86b222e13bdf32ed = function () { - return handleError(function () { - const ret = globalThis.globalThis; - return addHeapObject(ret); - }, arguments) -}; - -module.exports.__wbg_global_e5a3fe56f8be9485 = function () { - return handleError(function () { - const ret = global.global; - return addHeapObject(ret); - }, arguments) -}; - -module.exports.__wbindgen_is_undefined = function (arg0) { - const ret = getObject(arg0) === undefined; - return ret; -}; - -module.exports.__wbg_from_0791d740a9d37830 = function (arg0) { - const ret = Array.from(getObject(arg0)); - return addHeapObject(ret); -}; - -module.exports.__wbg_isArray_8364a5371e9737d8 = function (arg0) { - const ret = Array.isArray(getObject(arg0)); - return ret; -}; - -module.exports.__wbg_push_37c89022f34c01ca = function (arg0, arg1) { - const ret = getObject(arg0).push(getObject(arg1)); - return ret; -}; - -module.exports.__wbg_instanceof_Error_69bde193b0cc95e3 = function (arg0) { - let result; - try { - result = getObject(arg0) instanceof Error; - } catch (_) { - result = false; - } - const ret = result; - return ret; -}; - -module.exports.__wbg_new_796382978dfd4fb0 = function (arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_setname_ef058a4c6ff7e6d4 = function (arg0, arg1, arg2) { - getObject(arg0).name = getStringFromWasm0(arg1, arg2); -}; - -module.exports.__wbg_toString_9d18e102ca933e68 = function (arg0) { - const ret = getObject(arg0).toString(); - return addHeapObject(ret); -}; - -module.exports.__wbg_call_89af060b4e1523f2 = function () { - return handleError(function (arg0, arg1, arg2) { - const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); - return addHeapObject(ret); - }, arguments) -}; - -module.exports.__wbg_instanceof_Map_763ce0e95960d55e = function (arg0) { - let result; - try { - result = getObject(arg0) instanceof Map; - } catch (_) { - result = false; - } - const ret = result; - return ret; -}; - -module.exports.__wbg_get_5a402b270e32a550 = function (arg0, arg1) { - const ret = getObject(arg0).get(getObject(arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_49185437f0ab06f8 = function (arg0, arg1, arg2) { - const ret = getObject(arg0).set(getObject(arg1), getObject(arg2)); - return addHeapObject(ret); -}; - -module.exports.__wbg_keys_2a4853eb6ff523cf = function (arg0) { - const ret = getObject(arg0).keys(); - return addHeapObject(ret); -}; - -module.exports.__wbg_now_b7a162010a9e75b4 = function () { - const ret = Date.now(); - return ret; -}; - -module.exports.__wbg_fromEntries_623a5958a8dd4673 = function () { - return handleError(function (arg0) { - const ret = Object.fromEntries(getObject(arg0)); - return addHeapObject(ret); - }, arguments) -}; - -module.exports.__wbg_new_b85e72ed1bfd57f9 = function (arg0, arg1) { - try { - var state0 = { a: arg0, b: arg1 }; - var cb0 = (arg0, arg1) => { - const a = state0.a; - state0.a = 0; - try { - return __wbg_adapter_813(a, state0.b, arg0, arg1); - } finally { - state0.a = a; - } - }; - const ret = new Promise(cb0); - return addHeapObject(ret); - } finally { - state0.a = state0.b = 0; - } -}; - -module.exports.__wbg_resolve_570458cb99d56a43 = function (arg0) { - const ret = Promise.resolve(getObject(arg0)); - return addHeapObject(ret); -}; - -module.exports.__wbg_then_95e6edc0f89b73b1 = function (arg0, arg1) { - const ret = getObject(arg0).then(getObject(arg1)); - return addHeapObject(ret); -}; - -module.exports.__wbg_then_876bb3c633745cc6 = function (arg0, arg1, arg2) { - const ret = getObject(arg0).then(getObject(arg1), getObject(arg2)); - return addHeapObject(ret); -}; - -module.exports.__wbg_buffer_b7b08af79b0b0974 = function (arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); -}; - -module.exports.__wbg_newwithbyteoffsetandlength_8a2cb9ca96b27ec9 = function (arg0, arg1, arg2) { - const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); - return addHeapObject(ret); -}; - -module.exports.__wbg_new_ea1883e1e5e86686 = function (arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); -}; - -module.exports.__wbg_set_d1e79e2388520f18 = function (arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); -}; - -module.exports.__wbg_length_8339fcf5d8ecd12e = function (arg0) { - const ret = getObject(arg0).length; - return ret; -}; - -module.exports.__wbg_instanceof_Uint8Array_247a91427532499e = function (arg0) { - let result; - try { - result = getObject(arg0) instanceof Uint8Array; - } catch (_) { - result = false; - } - const ret = result; - return ret; -}; - -module.exports.__wbg_newwithlength_ec548f448387c968 = function (arg0) { - const ret = new Uint8Array(arg0 >>> 0); - return addHeapObject(ret); -}; - -module.exports.__wbg_subarray_7c2e3576afe181d1 = function (arg0, arg1, arg2) { - const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); - return addHeapObject(ret); -}; - -module.exports.__wbindgen_debug_string = function (arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); -}; - -module.exports.__wbindgen_throw = function (arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - -module.exports.__wbindgen_memory = function () { - const ret = wasm.memory; - return addHeapObject(ret); -}; - -module.exports.__wbindgen_closure_wrapper4915 = function (arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 557, __wbg_adapter_32); - return addHeapObject(ret); -}; - -const path = require('path').join(__dirname, 'identity_wasm_bg.wasm'); -const bytes = require('fs').readFileSync(path); - -const wasmModule = new WebAssembly.Module(bytes); -const wasmInstance = new WebAssembly.Instance(wasmModule, imports); -wasm = wasmInstance.exports; -module.exports.__wasm = wasm; - -wasm.__wbindgen_start(); - From e7e9dd23c96fa992aa4a64722dfeef6ec34f6b22 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Fri, 30 Aug 2024 15:59:59 +0200 Subject: [PATCH 06/21] Update config --- bindings/wasm/typedoc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bindings/wasm/typedoc.json b/bindings/wasm/typedoc.json index b383d21269..b80b17c080 100644 --- a/bindings/wasm/typedoc.json +++ b/bindings/wasm/typedoc.json @@ -9,7 +9,8 @@ "entryPointStrategy": "expand", "tsconfig": "./tsconfig.typedoc.json", "out": "./docs/api", - // "externalPattern": ["lib/*.ts"], + "plugin": ["typedoc-plugin-markdown"], + "readme": "none", "compilerOptions": { "skipLibCheck": true, } From 3b3ae9c1e715f1a063fd88c012fdd5222461fb27 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Mon, 2 Sep 2024 22:06:20 +0200 Subject: [PATCH 07/21] Downgrade typedoc and add flags from IOTA SDK to make it work --- bindings/wasm/package-lock.json | 314 ++++++++++---------------------- bindings/wasm/package.json | 4 +- bindings/wasm/typedoc.json | 6 + 3 files changed, 109 insertions(+), 215 deletions(-) diff --git a/bindings/wasm/package-lock.json b/bindings/wasm/package-lock.json index 7371b4e79d..f70949c608 100644 --- a/bindings/wasm/package-lock.json +++ b/bindings/wasm/package-lock.json @@ -29,8 +29,8 @@ "ts-node": "^10.9.1", "tsconfig-paths": "^4.1.0", "txm": "^8.1.0", - "typedoc": "^0.26.6", - "typedoc-plugin-markdown": "^4.2.5", + "typedoc": "^0.24.6", + "typedoc-plugin-markdown": "^3.14.0", "typescript": "^4.7.2", "wasm-opt": "^1.3.0" }, @@ -317,16 +317,6 @@ "node": ">= 8" } }, - "node_modules/@shikijs/core": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.14.1.tgz", - "integrity": "sha512-KyHIIpKNaT20FtFPFjCQB5WVSTpLR/n+jQXhWHWVUMm9MaOaG9BGOG0MSyt7yA4+Lm+4c9rTc03tt3nYzeYSfw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/hast": "^3.0.4" - } - }, "node_modules/@stablelib/binary": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", @@ -548,16 +538,6 @@ "dev": true, "peer": true }, - "node_modules/@types/hast": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", - "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/unist": "*" - } - }, "node_modules/@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -972,6 +952,13 @@ "node": ">=8" } }, + "node_modules/ansi-sequence-parser": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz", + "integrity": "sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==", + "dev": true, + "license": "MIT" + }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -3429,6 +3416,13 @@ "node": ">=6" } }, + "node_modules/jsonc-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", + "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", + "dev": true, + "license": "MIT" + }, "node_modules/jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -3801,10 +3795,11 @@ } }, "node_modules/marked": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.1.0.tgz", - "integrity": "sha512-+Z6KDjSPa6/723PQYyc1axYZpYYpDnECDaU6hkaf5gqBieBkMKYReL5hteF2QizhlMbgbo8umXl/clZ67+GlsA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", "dev": true, + "license": "MIT", "bin": { "marked": "bin/marked.js" }, @@ -4894,16 +4889,6 @@ "node": ">=6" } }, - "node_modules/punycode.js": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", - "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/qs": { "version": "6.10.4", "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.4.tgz", @@ -5316,14 +5301,16 @@ } }, "node_modules/shiki": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.14.1.tgz", - "integrity": "sha512-FujAN40NEejeXdzPt+3sZ3F2dx1U24BY2XTY01+MG8mbxCiA2XukXdcbyMyLAHJ/1AUUnQd1tZlvIjefWWEJeA==", + "version": "0.14.7", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.7.tgz", + "integrity": "sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg==", "dev": true, "license": "MIT", "dependencies": { - "@shikijs/core": "1.14.1", - "@types/hast": "^3.0.4" + "ansi-sequence-parser": "^1.1.0", + "jsonc-parser": "^3.2.0", + "vscode-oniguruma": "^1.7.0", + "vscode-textmate": "^8.0.0" } }, "node_modules/side-channel": { @@ -6037,39 +6024,38 @@ } }, "node_modules/typedoc": { - "version": "0.26.6", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.6.tgz", - "integrity": "sha512-SfEU3SH3wHNaxhFPjaZE2kNl/NFtLNW5c1oHsg7mti7GjmUj1Roq6osBQeMd+F4kL0BoRBBr8gQAuqBlfFu8LA==", + "version": "0.24.8", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.24.8.tgz", + "integrity": "sha512-ahJ6Cpcvxwaxfu4KtjA8qZNqS43wYt6JL27wYiIgl1vd38WW/KWX11YuAeZhuz9v+ttrutSsgK+XO1CjL1kA3w==", "dev": true, "license": "Apache-2.0", "dependencies": { "lunr": "^2.3.9", - "markdown-it": "^14.1.0", - "minimatch": "^9.0.5", - "shiki": "^1.9.1", - "yaml": "^2.4.5" + "marked": "^4.3.0", + "minimatch": "^9.0.0", + "shiki": "^0.14.1" }, "bin": { "typedoc": "bin/typedoc" }, "engines": { - "node": ">= 18" + "node": ">= 14.14" }, "peerDependencies": { - "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x" + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x" } }, "node_modules/typedoc-plugin-markdown": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-4.2.5.tgz", - "integrity": "sha512-ZWIfc0OqwEtQfuaqbmM1kesMi/Fhc++W+5f3TDEm1Tsi28pHSoZk4WCOm4lNuN30WtEImwAHhhXC4DIWki1DiA==", + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.17.1.tgz", + "integrity": "sha512-QzdU3fj0Kzw2XSdoL15ExLASt2WPqD7FbLeaqwT70+XjKyTshBnUlQA5nNREO1C2P8Uen0CDjsBLMsCQ+zd0lw==", "dev": true, "license": "MIT", - "engines": { - "node": ">= 18" + "dependencies": { + "handlebars": "^4.7.7" }, "peerDependencies": { - "typedoc": "0.26.x" + "typedoc": ">=0.24.0" } }, "node_modules/typedoc/node_modules/brace-expansion": { @@ -6082,54 +6068,6 @@ "balanced-match": "^1.0.0" } }, - "node_modules/typedoc/node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, - "node_modules/typedoc/node_modules/linkify-it": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", - "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "uc.micro": "^2.0.0" - } - }, - "node_modules/typedoc/node_modules/markdown-it": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", - "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", - "dev": true, - "license": "MIT", - "dependencies": { - "argparse": "^2.0.1", - "entities": "^4.4.0", - "linkify-it": "^5.0.0", - "mdurl": "^2.0.0", - "punycode.js": "^2.3.1", - "uc.micro": "^2.1.0" - }, - "bin": { - "markdown-it": "bin/markdown-it.mjs" - } - }, - "node_modules/typedoc/node_modules/mdurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", - "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", - "dev": true, - "license": "MIT" - }, "node_modules/typedoc/node_modules/minimatch": { "version": "9.0.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", @@ -6146,13 +6084,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/typedoc/node_modules/uc.micro": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", - "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", - "dev": true, - "license": "MIT" - }, "node_modules/typescript": { "version": "4.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz", @@ -6370,6 +6301,20 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/vscode-oniguruma": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", + "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-textmate": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", + "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", + "dev": true, + "license": "MIT" + }, "node_modules/walk-back": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/walk-back/-/walk-back-5.1.0.tgz", @@ -6577,19 +6522,6 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, - "node_modules/yaml": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", - "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", - "dev": true, - "license": "ISC", - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14" - } - }, "node_modules/yargs-parser": { "version": "20.2.4", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", @@ -6876,15 +6808,6 @@ "fastq": "^1.6.0" } }, - "@shikijs/core": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.14.1.tgz", - "integrity": "sha512-KyHIIpKNaT20FtFPFjCQB5WVSTpLR/n+jQXhWHWVUMm9MaOaG9BGOG0MSyt7yA4+Lm+4c9rTc03tt3nYzeYSfw==", - "dev": true, - "requires": { - "@types/hast": "^3.0.4" - } - }, "@stablelib/binary": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", @@ -7094,15 +7017,6 @@ "dev": true, "peer": true }, - "@types/hast": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz", - "integrity": "sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==", - "dev": true, - "requires": { - "@types/unist": "*" - } - }, "@types/json-schema": { "version": "7.0.11", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", @@ -7478,6 +7392,12 @@ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, + "ansi-sequence-parser": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz", + "integrity": "sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==", + "dev": true + }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -9274,6 +9194,12 @@ "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, + "jsonc-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", + "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", + "dev": true + }, "jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", @@ -9548,9 +9474,9 @@ "requires": {} }, "marked": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.1.0.tgz", - "integrity": "sha512-+Z6KDjSPa6/723PQYyc1axYZpYYpDnECDaU6hkaf5gqBieBkMKYReL5hteF2QizhlMbgbo8umXl/clZ67+GlsA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", + "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", "dev": true }, "mdast-util-from-markdown": { @@ -10255,12 +10181,6 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, - "punycode.js": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", - "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", - "dev": true - }, "qs": { "version": "6.10.4", "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.4.tgz", @@ -10560,13 +10480,15 @@ "dev": true }, "shiki": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-1.14.1.tgz", - "integrity": "sha512-FujAN40NEejeXdzPt+3sZ3F2dx1U24BY2XTY01+MG8mbxCiA2XukXdcbyMyLAHJ/1AUUnQd1tZlvIjefWWEJeA==", + "version": "0.14.7", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-0.14.7.tgz", + "integrity": "sha512-dNPAPrxSc87ua2sKJ3H5dQ/6ZaY8RNnaAqK+t0eG7p0Soi2ydiqbGOTaZCqaYvA/uZYfS1LJnemt3Q+mSfcPCg==", "dev": true, "requires": { - "@shikijs/core": "1.14.1", - "@types/hast": "^3.0.4" + "ansi-sequence-parser": "^1.1.0", + "jsonc-parser": "^3.2.0", + "vscode-oniguruma": "^1.7.0", + "vscode-textmate": "^8.0.0" } }, "side-channel": { @@ -11095,16 +11017,15 @@ "dev": true }, "typedoc": { - "version": "0.26.6", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.26.6.tgz", - "integrity": "sha512-SfEU3SH3wHNaxhFPjaZE2kNl/NFtLNW5c1oHsg7mti7GjmUj1Roq6osBQeMd+F4kL0BoRBBr8gQAuqBlfFu8LA==", + "version": "0.24.8", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.24.8.tgz", + "integrity": "sha512-ahJ6Cpcvxwaxfu4KtjA8qZNqS43wYt6JL27wYiIgl1vd38WW/KWX11YuAeZhuz9v+ttrutSsgK+XO1CjL1kA3w==", "dev": true, "requires": { "lunr": "^2.3.9", - "markdown-it": "^14.1.0", - "minimatch": "^9.0.5", - "shiki": "^1.9.1", - "yaml": "^2.4.5" + "marked": "^4.3.0", + "minimatch": "^9.0.0", + "shiki": "^0.14.1" }, "dependencies": { "brace-expansion": { @@ -11116,41 +11037,6 @@ "balanced-match": "^1.0.0" } }, - "entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true - }, - "linkify-it": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz", - "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", - "dev": true, - "requires": { - "uc.micro": "^2.0.0" - } - }, - "markdown-it": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", - "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", - "dev": true, - "requires": { - "argparse": "^2.0.1", - "entities": "^4.4.0", - "linkify-it": "^5.0.0", - "mdurl": "^2.0.0", - "punycode.js": "^2.3.1", - "uc.micro": "^2.1.0" - } - }, - "mdurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz", - "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", - "dev": true - }, "minimatch": { "version": "9.0.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", @@ -11159,21 +11045,17 @@ "requires": { "brace-expansion": "^2.0.1" } - }, - "uc.micro": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", - "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", - "dev": true } } }, "typedoc-plugin-markdown": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-4.2.5.tgz", - "integrity": "sha512-ZWIfc0OqwEtQfuaqbmM1kesMi/Fhc++W+5f3TDEm1Tsi28pHSoZk4WCOm4lNuN30WtEImwAHhhXC4DIWki1DiA==", + "version": "3.17.1", + "resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.17.1.tgz", + "integrity": "sha512-QzdU3fj0Kzw2XSdoL15ExLASt2WPqD7FbLeaqwT70+XjKyTshBnUlQA5nNREO1C2P8Uen0CDjsBLMsCQ+zd0lw==", "dev": true, - "requires": {} + "requires": { + "handlebars": "^4.7.7" + } }, "typescript": { "version": "4.8.3", @@ -11329,6 +11211,18 @@ "unist-util-stringify-position": "^3.0.0" } }, + "vscode-oniguruma": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz", + "integrity": "sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==", + "dev": true + }, + "vscode-textmate": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/vscode-textmate/-/vscode-textmate-8.0.0.tgz", + "integrity": "sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==", + "dev": true + }, "walk-back": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/walk-back/-/walk-back-5.1.0.tgz", @@ -11489,12 +11383,6 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, - "yaml": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", - "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", - "dev": true - }, "yargs-parser": { "version": "20.2.4", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 0cf571ad8f..2645f01432 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -71,8 +71,8 @@ "ts-node": "^10.9.1", "tsconfig-paths": "^4.1.0", "txm": "^8.1.0", - "typedoc": "^0.26.6", - "typedoc-plugin-markdown": "^4.2.5", + "typedoc": "^0.24.6", + "typedoc-plugin-markdown": "^3.14.0", "typescript": "^4.7.2", "wasm-opt": "^1.3.0" }, diff --git a/bindings/wasm/typedoc.json b/bindings/wasm/typedoc.json index b80b17c080..3b74164e4a 100644 --- a/bindings/wasm/typedoc.json +++ b/bindings/wasm/typedoc.json @@ -11,6 +11,12 @@ "out": "./docs/api", "plugin": ["typedoc-plugin-markdown"], "readme": "none", + "githubPages": false, + "theme": "markdown", + "entryDocument": "api_ref.md", + "hideBreadcrumbs": true, + "hideGenerator": true, + "sort": ["source-order"], "compilerOptions": { "skipLibCheck": true, } From da3bbb2cea2c68bd1c694868b9f5a9ce559a6791 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Mon, 2 Sep 2024 22:08:20 +0200 Subject: [PATCH 08/21] Remove useless(?) backticks --- bindings/wasm/src/sd_jwt/encoder.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/bindings/wasm/src/sd_jwt/encoder.rs b/bindings/wasm/src/sd_jwt/encoder.rs index 550742b42b..6e912e885e 100644 --- a/bindings/wasm/src/sd_jwt/encoder.rs +++ b/bindings/wasm/src/sd_jwt/encoder.rs @@ -47,7 +47,6 @@ impl WasmSdObjectEncoder { /// Path "/id" conceals `"id": "did:value"` /// Path "/claim1/abc" conceals `"abc": true` /// Path "/claim2/0" conceals `val_1` - /// ``` /// /// ## Errors /// * `InvalidPath` if pointer is invalid. From 4392045e1f0604be0e172794425c96fc33a8d7ec Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Mon, 2 Sep 2024 23:08:45 +0200 Subject: [PATCH 09/21] Fix docs with fix_docs script ;) --- bindings/wasm/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 2645f01432..9645b5c96e 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -15,7 +15,7 @@ "bundle:web": "wasm-bindgen target/wasm32-unknown-unknown/release/identity_wasm.wasm --typescript --weak-refs --target web --out-dir web && node ./build/web && tsc --project ./lib/tsconfig.web.json && node ./build/replace_paths ./lib/tsconfig.web.json web", "build:nodejs": "npm run build:src && npm run bundle:nodejs && wasm-opt -O node/identity_wasm_bg.wasm -o node/identity_wasm_bg.wasm", "build:web": "npm run build:src && npm run bundle:web && wasm-opt -O web/identity_wasm_bg.wasm -o web/identity_wasm_bg.wasm", - "build:docs": "typedoc", + "build:docs": "typedoc && npm run fix_docs", "build:examples:web": "tsc --project ./examples/tsconfig.web.json && node ./build/replace_paths ./examples/tsconfig.web.json ./examples/dist resolve", "build": "npm run build:web && npm run build:nodejs && npm run build:docs", "example:node": "ts-node --project tsconfig.node.json -r tsconfig-paths/register ./examples/src/main.ts", @@ -32,7 +32,7 @@ "test:unit:node": "ts-mocha -p tsconfig.node.json ./tests/*.ts --parallel --exit", "cypress": "cypress open", "fmt": "dprint fmt", - "fix_js_doc": "sed -Ei 's/\\((.*)\\)\\[\\]/\\1\\[\\]/' ./node/identity_wasm.js" + "fix_docs": "sed -Ei 's/(\\.md?#([^#]*)?)#/\\1/' ./docs/api/**/*.md" }, "config": { "CYPRESS_VERIFY_TIMEOUT": 100000 From a9dc169ae8e3d5191a2e0963f5a35624bc903801 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 3 Sep 2024 13:50:54 +0200 Subject: [PATCH 10/21] Change output path --- bindings/wasm/package.json | 2 +- bindings/wasm/typedoc.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 9645b5c96e..9f2bad1e04 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -32,7 +32,7 @@ "test:unit:node": "ts-mocha -p tsconfig.node.json ./tests/*.ts --parallel --exit", "cypress": "cypress open", "fmt": "dprint fmt", - "fix_docs": "sed -Ei 's/(\\.md?#([^#]*)?)#/\\1/' ./docs/api/**/*.md" + "fix_docs": "sed -Ei 's/(\\.md?#([^#]*)?)#/\\1/' ./docs/**/*.md" }, "config": { "CYPRESS_VERIFY_TIMEOUT": 100000 diff --git a/bindings/wasm/typedoc.json b/bindings/wasm/typedoc.json index 3b74164e4a..91dde62be3 100644 --- a/bindings/wasm/typedoc.json +++ b/bindings/wasm/typedoc.json @@ -8,7 +8,7 @@ "entryPoints": ["./node/"], "entryPointStrategy": "expand", "tsconfig": "./tsconfig.typedoc.json", - "out": "./docs/api", + "out": "./docs", "plugin": ["typedoc-plugin-markdown"], "readme": "none", "githubPages": false, From c31d9fb674c532f2bb5f6876ea1c9767a807ec57 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 3 Sep 2024 13:51:49 +0200 Subject: [PATCH 11/21] Add docs to artifacts --- .github/workflows/shared-build-wasm.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/shared-build-wasm.yml b/.github/workflows/shared-build-wasm.yml index 8f39769dfd..3b0e52b38a 100644 --- a/.github/workflows/shared-build-wasm.yml +++ b/.github/workflows/shared-build-wasm.yml @@ -89,5 +89,6 @@ jobs: bindings/wasm/node bindings/wasm/web bindings/wasm/examples/dist + bindings/wasm/docs if-no-files-found: error retention-days: 1 From bf5678bf7760b3b8e9cf111375e20266481e7c46 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 3 Sep 2024 13:54:42 +0200 Subject: [PATCH 12/21] Add upload action --- .github/workflows/upload-docs.yml | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/upload-docs.yml diff --git a/.github/workflows/upload-docs.yml b/.github/workflows/upload-docs.yml new file mode 100644 index 0000000000..2dff74128d --- /dev/null +++ b/.github/workflows/upload-docs.yml @@ -0,0 +1,54 @@ +name: Build and upload API docs + +on: + release: + types: [published] + workflow_dispatch: + inputs: + version: + description: 'Version to publish docs under (e.g. `v1.2.3-dev.1`)' + required: true + +env: + GH_TOKEN: ${{ github.token }} + +permissions: + actions: 'write' + +jobs: + build-wasm: + # owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 + uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main + with: + run-unit-tests: false + ref: ${{ inputs.ref }} + output-artifact-name: identity-docs + + upload-docs: + runs-on: ubuntu-latest + needs: build-wasm + steps: + - uses: actions/download-artifact@v2 + with: + name: identity-docs + - name: Get release version + id: get_release_version + run: | + if [ "${{ github.event_name }}" = "release" ]; then + INPUT_VERSION="${{ github.ref }}" + else + INPUT_VERSION="${{ github.event.inputs.version }}" + fi + VERSION=$(echo $INPUT_VERSION | sed -e 's/.*v\([0-9]*\.[0-9]*\).*/\1/') + echo VERSION=$VERSION >> $GITHUB_OUTPUT + - name: Compress generated docs + run: | + tar czvf identity.tar.gz docs/* + + - name: Upload docs to AWS S3 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_IOTA_WIKI }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_IOTA_WIKI }} + AWS_DEFAULT_REGION: "eu-central-1" + run: | + aws s3 cp identity.tar.gz s3://files.iota.org/iota-wiki/iota-identity/${{ steps.get_release_version.outputs.VERSION }}/ --acl public-read From 022a6ea589d2e3994a130cd428e0d0d6bd809b11 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 3 Sep 2024 14:01:01 +0200 Subject: [PATCH 13/21] Remove unused docs script --- bindings/wasm/build/docs.js | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 bindings/wasm/build/docs.js diff --git a/bindings/wasm/build/docs.js b/bindings/wasm/build/docs.js deleted file mode 100644 index b496ccd7d0..0000000000 --- a/bindings/wasm/build/docs.js +++ /dev/null @@ -1,15 +0,0 @@ -const fs = require("fs"); -const path = require("path"); -const jsdoc2md = require("jsdoc-to-markdown"); - -const importFile = path.join(__dirname, "../node/identity_wasm.js"); -const exportFile = path.join(__dirname, "../docs/api-reference.md"); - -const docsRoot = path.join(__dirname, "../docs"); -const docsData = jsdoc2md.renderSync({ files: importFile }); - -if (!fs.existsSync(docsRoot)) { - fs.mkdirSync(docsRoot); -} - -fs.writeFileSync(exportFile, docsData); From 42b4c4be1ff1d9d2966137c3968d313f2da644ea Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 3 Sep 2024 14:37:40 +0200 Subject: [PATCH 14/21] Move content into wasm folder --- .github/workflows/upload-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload-docs.yml b/.github/workflows/upload-docs.yml index 2dff74128d..e7b981ed4e 100644 --- a/.github/workflows/upload-docs.yml +++ b/.github/workflows/upload-docs.yml @@ -51,4 +51,4 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_IOTA_WIKI }} AWS_DEFAULT_REGION: "eu-central-1" run: | - aws s3 cp identity.tar.gz s3://files.iota.org/iota-wiki/iota-identity/${{ steps.get_release_version.outputs.VERSION }}/ --acl public-read + aws s3 cp identity.tar.gz s3://files.iota.org/iota-wiki/iota-identity/${{ steps.get_release_version.outputs.VERSION }}/wasm/ --acl public-read From ce18ed8125025811aa947b4989b3140d03d1560c Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 3 Sep 2024 15:12:14 +0200 Subject: [PATCH 15/21] I can't decide --- .github/workflows/upload-docs.yml | 2 +- bindings/wasm/package.json | 2 +- bindings/wasm/typedoc.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/upload-docs.yml b/.github/workflows/upload-docs.yml index e7b981ed4e..2dff74128d 100644 --- a/.github/workflows/upload-docs.yml +++ b/.github/workflows/upload-docs.yml @@ -51,4 +51,4 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_IOTA_WIKI }} AWS_DEFAULT_REGION: "eu-central-1" run: | - aws s3 cp identity.tar.gz s3://files.iota.org/iota-wiki/iota-identity/${{ steps.get_release_version.outputs.VERSION }}/wasm/ --acl public-read + aws s3 cp identity.tar.gz s3://files.iota.org/iota-wiki/iota-identity/${{ steps.get_release_version.outputs.VERSION }}/ --acl public-read diff --git a/bindings/wasm/package.json b/bindings/wasm/package.json index 9f2bad1e04..085abe22a7 100644 --- a/bindings/wasm/package.json +++ b/bindings/wasm/package.json @@ -32,7 +32,7 @@ "test:unit:node": "ts-mocha -p tsconfig.node.json ./tests/*.ts --parallel --exit", "cypress": "cypress open", "fmt": "dprint fmt", - "fix_docs": "sed -Ei 's/(\\.md?#([^#]*)?)#/\\1/' ./docs/**/*.md" + "fix_docs": "sed -Ei 's/(\\.md?#([^#]*)?)#/\\1/' ./docs/wasm/**/*.md" }, "config": { "CYPRESS_VERIFY_TIMEOUT": 100000 diff --git a/bindings/wasm/typedoc.json b/bindings/wasm/typedoc.json index 91dde62be3..b9520d8859 100644 --- a/bindings/wasm/typedoc.json +++ b/bindings/wasm/typedoc.json @@ -8,7 +8,7 @@ "entryPoints": ["./node/"], "entryPointStrategy": "expand", "tsconfig": "./tsconfig.typedoc.json", - "out": "./docs", + "out": "./docs/wasm", "plugin": ["typedoc-plugin-markdown"], "readme": "none", "githubPages": false, From e21cccef103e8e3b6e861c9bdc03c8730b622c1e Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 3 Sep 2024 16:22:14 +0200 Subject: [PATCH 16/21] Unify setup with SDK and EVM docs --- .github/workflows/upload-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/upload-docs.yml b/.github/workflows/upload-docs.yml index 2dff74128d..c9befe49ef 100644 --- a/.github/workflows/upload-docs.yml +++ b/.github/workflows/upload-docs.yml @@ -43,7 +43,7 @@ jobs: echo VERSION=$VERSION >> $GITHUB_OUTPUT - name: Compress generated docs run: | - tar czvf identity.tar.gz docs/* + tar czvf wasm.tar.gz docs/* - name: Upload docs to AWS S3 env: @@ -51,4 +51,4 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_IOTA_WIKI }} AWS_DEFAULT_REGION: "eu-central-1" run: | - aws s3 cp identity.tar.gz s3://files.iota.org/iota-wiki/iota-identity/${{ steps.get_release_version.outputs.VERSION }}/ --acl public-read + aws s3 cp wasm.tar.gz s3://files.iota.org/iota-wiki/iota-identity/${{ steps.get_release_version.outputs.VERSION }}/ --acl public-read From 53fc53d8db3b9a16a2cbeace463e8f7032fd6092 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 3 Sep 2024 20:43:26 +0200 Subject: [PATCH 17/21] Update bindings/wasm/typedoc.json --- bindings/wasm/typedoc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/wasm/typedoc.json b/bindings/wasm/typedoc.json index b9520d8859..c6874ebe33 100644 --- a/bindings/wasm/typedoc.json +++ b/bindings/wasm/typedoc.json @@ -20,4 +20,4 @@ "compilerOptions": { "skipLibCheck": true, } -} \ No newline at end of file +} From 21ce4ebe3e07292c0d8a460b9e37d5f6e5622169 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Fri, 6 Sep 2024 11:21:36 +0200 Subject: [PATCH 18/21] Update artifacts action to v4 --- .github/actions/publish/publish-wasm/action.yml | 2 +- .github/workflows/build-and-test.yml | 6 +++--- .github/workflows/shared-build-wasm.yml | 2 +- .github/workflows/upload-docs.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/publish/publish-wasm/action.yml b/.github/actions/publish/publish-wasm/action.yml index cfaedea939..6bb1171fbd 100644 --- a/.github/actions/publish/publish-wasm/action.yml +++ b/.github/actions/publish/publish-wasm/action.yml @@ -24,7 +24,7 @@ runs: registry-url: 'https://registry.npmjs.org' - name: Download bindings/wasm artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: ${{ inputs.input-artifact-name }} path: bindings/wasm diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ba3b7ef0b1..c92432e36f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -198,7 +198,7 @@ jobs: working-directory: bindings/wasm - name: Download bindings/wasm artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: identity-wasm-bindings-build path: bindings/wasm @@ -238,7 +238,7 @@ jobs: working-directory: bindings/wasm - name: Download bindings/wasm artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: identity-wasm-bindings-build path: bindings/wasm @@ -286,7 +286,7 @@ jobs: working-directory: bindings/wasm - name: Download bindings/wasm artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: identity-wasm-bindings-build path: bindings/wasm diff --git a/.github/workflows/shared-build-wasm.yml b/.github/workflows/shared-build-wasm.yml index 3b0e52b38a..263e1da66c 100644 --- a/.github/workflows/shared-build-wasm.yml +++ b/.github/workflows/shared-build-wasm.yml @@ -82,7 +82,7 @@ jobs: os: ${{matrix.os}} - name: Upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ inputs.output-artifact-name }} path: | diff --git a/.github/workflows/upload-docs.yml b/.github/workflows/upload-docs.yml index c9befe49ef..7c98b7cb7e 100644 --- a/.github/workflows/upload-docs.yml +++ b/.github/workflows/upload-docs.yml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-latest needs: build-wasm steps: - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4 with: name: identity-docs - name: Get release version From 2f24b18190c2365150aed63b677ce1a667d43daa Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Fri, 6 Sep 2024 16:52:09 +0200 Subject: [PATCH 19/21] Use PR branch for static action --- .github/workflows/build-and-test.yml | 2 +- .github/workflows/upload-docs.yml | 2 +- .github/workflows/wasm-automatic-release-and-publish.yml | 2 +- .github/workflows/wasm-publish-to-npm.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index c92432e36f..32d2efb72c 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -170,7 +170,7 @@ jobs: needs: check-for-run-condition if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} # owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 - uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main + uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@typedoc with: output-artifact-name: identity-wasm-bindings-build diff --git a/.github/workflows/upload-docs.yml b/.github/workflows/upload-docs.yml index 7c98b7cb7e..35e654225d 100644 --- a/.github/workflows/upload-docs.yml +++ b/.github/workflows/upload-docs.yml @@ -18,7 +18,7 @@ permissions: jobs: build-wasm: # owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 - uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main + uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@typedoc with: run-unit-tests: false ref: ${{ inputs.ref }} diff --git a/.github/workflows/wasm-automatic-release-and-publish.yml b/.github/workflows/wasm-automatic-release-and-publish.yml index 1c7b4f141a..b3b1481c1a 100644 --- a/.github/workflows/wasm-automatic-release-and-publish.yml +++ b/.github/workflows/wasm-automatic-release-and-publish.yml @@ -26,7 +26,7 @@ jobs: needs: call-create-release-workflow if: ${{ needs.call-create-release-workflow.outputs.is-release }} # owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 - uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main + uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@typedoc with: output-artifact-name: identity-wasm-bindings-build diff --git a/.github/workflows/wasm-publish-to-npm.yml b/.github/workflows/wasm-publish-to-npm.yml index a1d8b8762b..0ee571d5e2 100644 --- a/.github/workflows/wasm-publish-to-npm.yml +++ b/.github/workflows/wasm-publish-to-npm.yml @@ -19,7 +19,7 @@ jobs: build-wasm: # owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 - uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main + uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@typedoc with: ref: ${{ github.event.inputs.branch }} output-artifact-name: identity-wasm-bindings-build From 83bef46635675ae4aec0cdefec7b8de37fb68c53 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Fri, 6 Sep 2024 17:13:37 +0200 Subject: [PATCH 20/21] Remove token --- .github/workflows/upload-docs.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/upload-docs.yml b/.github/workflows/upload-docs.yml index 35e654225d..aba1d057fb 100644 --- a/.github/workflows/upload-docs.yml +++ b/.github/workflows/upload-docs.yml @@ -9,9 +9,6 @@ on: description: 'Version to publish docs under (e.g. `v1.2.3-dev.1`)' required: true -env: - GH_TOKEN: ${{ github.token }} - permissions: actions: 'write' From 186db509a56063c303745ad042aec8924b60880a Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Mon, 9 Sep 2024 00:02:38 +0200 Subject: [PATCH 21/21] Revert branch change --- .github/workflows/build-and-test.yml | 2 +- .github/workflows/upload-docs.yml | 2 +- .github/workflows/wasm-automatic-release-and-publish.yml | 2 +- .github/workflows/wasm-publish-to-npm.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 32d2efb72c..c92432e36f 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -170,7 +170,7 @@ jobs: needs: check-for-run-condition if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }} # owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 - uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@typedoc + uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main with: output-artifact-name: identity-wasm-bindings-build diff --git a/.github/workflows/upload-docs.yml b/.github/workflows/upload-docs.yml index aba1d057fb..5ce1429767 100644 --- a/.github/workflows/upload-docs.yml +++ b/.github/workflows/upload-docs.yml @@ -15,7 +15,7 @@ permissions: jobs: build-wasm: # owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 - uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@typedoc + uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main with: run-unit-tests: false ref: ${{ inputs.ref }} diff --git a/.github/workflows/wasm-automatic-release-and-publish.yml b/.github/workflows/wasm-automatic-release-and-publish.yml index b3b1481c1a..1c7b4f141a 100644 --- a/.github/workflows/wasm-automatic-release-and-publish.yml +++ b/.github/workflows/wasm-automatic-release-and-publish.yml @@ -26,7 +26,7 @@ jobs: needs: call-create-release-workflow if: ${{ needs.call-create-release-workflow.outputs.is-release }} # owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 - uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@typedoc + uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main with: output-artifact-name: identity-wasm-bindings-build diff --git a/.github/workflows/wasm-publish-to-npm.yml b/.github/workflows/wasm-publish-to-npm.yml index 0ee571d5e2..a1d8b8762b 100644 --- a/.github/workflows/wasm-publish-to-npm.yml +++ b/.github/workflows/wasm-publish-to-npm.yml @@ -19,7 +19,7 @@ jobs: build-wasm: # owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466 - uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@typedoc + uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main with: ref: ${{ github.event.inputs.branch }} output-artifact-name: identity-wasm-bindings-build