@interop/did-web-resolver 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +38 -12
  2. package/dist/DidWebResolver.d.ts +267 -0
  3. package/dist/DidWebResolver.d.ts.map +1 -0
  4. package/dist/DidWebResolver.js +557 -0
  5. package/dist/DidWebResolver.js.map +1 -0
  6. package/dist/assertions.d.ts +47 -0
  7. package/dist/assertions.d.ts.map +1 -0
  8. package/dist/assertions.js +90 -0
  9. package/dist/assertions.js.map +1 -0
  10. package/dist/constants.d.ts +23 -0
  11. package/dist/constants.d.ts.map +1 -0
  12. package/dist/constants.js +45 -0
  13. package/dist/constants.js.map +1 -0
  14. package/dist/index.d.ts +8 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +6 -0
  17. package/dist/index.js.map +1 -0
  18. package/package.json +64 -72
  19. package/dist/esm/DidWebResolver.d.ts +0 -147
  20. package/dist/esm/DidWebResolver.d.ts.map +0 -1
  21. package/dist/esm/DidWebResolver.js +0 -322
  22. package/dist/esm/DidWebResolver.js.map +0 -1
  23. package/dist/esm/index.d.ts +0 -8
  24. package/dist/esm/index.d.ts.map +0 -1
  25. package/dist/esm/index.js +0 -6
  26. package/dist/esm/index.js.map +0 -1
  27. package/dist/src/DidWebResolver.d.ts +0 -146
  28. package/dist/src/DidWebResolver.js +0 -329
  29. package/dist/src/DidWebResolver.js.map +0 -1
  30. package/dist/src/index.d.ts +0 -7
  31. package/dist/src/index.js +0 -12
  32. package/dist/src/index.js.map +0 -1
  33. package/dist/test/DidWebResolver.spec.d.ts +0 -1
  34. package/dist/test/DidWebResolver.spec.js +0 -183
  35. package/dist/test/DidWebResolver.spec.js.map +0 -1
  36. package/src/DidWebResolver.ts +0 -366
  37. package/src/declarations.d.ts +0 -11
  38. package/src/index.ts +0 -8
  39. /package/{LICENSE → LICENSE.md} +0 -0
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Assertions guarding the resolver's network path: that a fetch target is an
3
+ * HTTPS URL, that an identifier is a well-formed `did:web` DID, and that a
4
+ * target host is permitted by an optional allow list (SSRF gate).
5
+ */
6
+ /**
7
+ * Asserts that the given value is an HTTPS URL.
8
+ *
9
+ * @param url {URL|string} - The URL to check.
10
+ *
11
+ * @throws {TypeError} If the value is not a URL or its protocol is not https.
12
+ */
13
+ export function assertHttpsUrl(url) {
14
+ const parsed = assertUrl(url);
15
+ if (parsed.protocol !== 'https:') {
16
+ throw new TypeError(`"url" protocol must be "https:"; received "${parsed.protocol}".`);
17
+ }
18
+ }
19
+ /**
20
+ * Coerces a string to a `URL`, or returns an existing `URL` instance.
21
+ *
22
+ * @param url {URL|string} - The value to coerce.
23
+ *
24
+ * @returns {URL} The parsed URL.
25
+ */
26
+ export function assertUrl(url) {
27
+ if (url instanceof URL) {
28
+ return url;
29
+ }
30
+ if (typeof url === 'string') {
31
+ return new URL(url);
32
+ }
33
+ throw new TypeError('"url" must be a string or a URL.');
34
+ }
35
+ /**
36
+ * Asserts that a DID is a well-formed `did:web` identifier whose
37
+ * method-specific id (the domain component) does not itself contain a path.
38
+ * Sets `err.code` to `'invalidDid'` or `'methodNotSupported'` where relevant.
39
+ *
40
+ * @param did {string} - The DID to check.
41
+ *
42
+ * @throws {Error} If the DID is missing, malformed, or not a did:web DID.
43
+ */
44
+ export function assertDidWebUrl(did) {
45
+ if (!did) {
46
+ throw new TypeError('"did" must be a non-zero length string.');
47
+ }
48
+ if (typeof did !== 'string') {
49
+ throw new TypeError(`Expected DID to be a string; received "${typeof did}".`);
50
+ }
51
+ const [scheme, method, domain] = did.split(':', 3);
52
+ if (scheme !== 'did') {
53
+ const err = new Error(`Scheme must be "did"; received "${scheme}".`);
54
+ err.code = 'invalidDid';
55
+ throw err;
56
+ }
57
+ if (method !== 'web') {
58
+ const err = new Error(`DID method must be "web"; received "${method}".`);
59
+ err.code = 'methodNotSupported';
60
+ throw err;
61
+ }
62
+ if (!domain) {
63
+ throw new Error('Expected domain to be a non-zero length string.');
64
+ }
65
+ if (domain.includes('/')) {
66
+ throw new Error(`Expected domain to not contain a path; received "${domain}".`);
67
+ }
68
+ }
69
+ /**
70
+ * SSRF gate: asserts that the host of `url` is present in `allowList`. An empty
71
+ * or absent allow list disables the check (all hosts permitted).
72
+ *
73
+ * @param options {object} - Options hashmap.
74
+ * @param [options.allowList] {string[]} - Permitted hosts (e.g. 'example.com'
75
+ * or 'example.com:3000'). When empty/absent, no restriction is applied.
76
+ * @param options.url {URL|string} - The fetch target URL.
77
+ *
78
+ * @throws {Error} If the host is not in a non-empty allow list.
79
+ */
80
+ export function assertDomain({ allowList, url }) {
81
+ if (!allowList || allowList.length === 0) {
82
+ return;
83
+ }
84
+ const { host } = assertUrl(url);
85
+ if (allowList.includes(host)) {
86
+ return;
87
+ }
88
+ throw new Error(`Domain "${host}" is not allowed.`);
89
+ }
90
+ //# sourceMappingURL=assertions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.js","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAE,GAAiB;IAC/C,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;IAC7B,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,MAAM,IAAI,SAAS,CACjB,8CAA8C,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAA;IACtE,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAE,GAAiB;IAC1C,IAAI,GAAG,YAAY,GAAG,EAAE,CAAC;QACvB,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;IACrB,CAAC;IACD,MAAM,IAAI,SAAS,CAAC,kCAA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CAAC;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;IAC/B,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAM;IACR,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,mBAAmB,CAAC,CAAA;AACrD,CAAC"}
@@ -0,0 +1,23 @@
1
+ export declare const DID_CONTEXT_URL: string;
2
+ export declare const didPrefix = "did:web:";
3
+ export declare const didFile = "did.json";
4
+ export declare const fileSuffix = ".well-known/did.json";
5
+ /**
6
+ * Default network limits for fetching a DID document. `size` is the maximum
7
+ * response body in bytes; `timeout` is the request timeout in milliseconds.
8
+ */
9
+ export declare const defaultFetchOptions: {
10
+ size: number;
11
+ timeout: number;
12
+ };
13
+ /**
14
+ * Maps a verification method `type` to the JSON-LD `@context` that defines it.
15
+ * Used by `getNode` to attach the correct context to a dereferenced subnode.
16
+ */
17
+ export declare const contextsBySuite: Map<string, string>;
18
+ /**
19
+ * The verification relationships a generated verification key is wired into by
20
+ * default (when no explicit `purposes` are given for it).
21
+ */
22
+ export declare const DEFAULT_PURPOSES: string[];
23
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,EAAE,MAA6C,CAAA;AAE3E,eAAO,MAAM,SAAS,aAAa,CAAA;AACnC,eAAO,MAAM,OAAO,aAAa,CAAA;AACjC,eAAO,MAAM,UAAU,yBAA2B,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;CAG/B,CAAA;AAYD;;;GAGG;AACH,eAAO,MAAM,eAAe,qBAM1B,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,UAK5B,CAAA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Shared constants for the did:web resolver: the DID Core context URL, default
3
+ * network fetch limits, a suite-to-context lookup used when dereferencing
4
+ * subnodes, and the default verification relationships for generated keys.
5
+ */
6
+ import * as didContext from 'did-context';
7
+ export const DID_CONTEXT_URL = didContext.constants.DID_CONTEXT_URL;
8
+ export const didPrefix = 'did:web:';
9
+ export const didFile = 'did.json';
10
+ export const fileSuffix = `.well-known/${didFile}`;
11
+ /**
12
+ * Default network limits for fetching a DID document. `size` is the maximum
13
+ * response body in bytes; `timeout` is the request timeout in milliseconds.
14
+ */
15
+ export const defaultFetchOptions = {
16
+ size: 8192,
17
+ timeout: 5000
18
+ };
19
+ const ED25519_KEY_2018_CONTEXT_URL = 'https://w3id.org/security/suites/ed25519-2018/v1';
20
+ const ED25519_KEY_2020_CONTEXT_URL = 'https://w3id.org/security/suites/ed25519-2020/v1';
21
+ const X25519_KEY_2019_CONTEXT_URL = 'https://w3id.org/security/suites/x25519-2019/v1';
22
+ const X25519_KEY_2020_CONTEXT_URL = 'https://w3id.org/security/suites/x25519-2020/v1';
23
+ const MULTIKEY_CONTEXT_V1_URL = 'https://w3id.org/security/multikey/v1';
24
+ /**
25
+ * Maps a verification method `type` to the JSON-LD `@context` that defines it.
26
+ * Used by `getNode` to attach the correct context to a dereferenced subnode.
27
+ */
28
+ export const contextsBySuite = new Map([
29
+ ['Ed25519VerificationKey2020', ED25519_KEY_2020_CONTEXT_URL],
30
+ ['Ed25519VerificationKey2018', ED25519_KEY_2018_CONTEXT_URL],
31
+ ['Multikey', MULTIKEY_CONTEXT_V1_URL],
32
+ ['X25519KeyAgreementKey2020', X25519_KEY_2020_CONTEXT_URL],
33
+ ['X25519KeyAgreementKey2019', X25519_KEY_2019_CONTEXT_URL]
34
+ ]);
35
+ /**
36
+ * The verification relationships a generated verification key is wired into by
37
+ * default (when no explicit `purposes` are given for it).
38
+ */
39
+ export const DEFAULT_PURPOSES = [
40
+ 'authentication',
41
+ 'assertionMethod',
42
+ 'capabilityDelegation',
43
+ 'capabilityInvocation'
44
+ ];
45
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AAEzC,MAAM,CAAC,MAAM,eAAe,GAAW,UAAU,CAAC,SAAS,CAAC,eAAe,CAAA;AAE3E,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAA;AACnC,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAA;AACjC,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,OAAO,EAAE,CAAA;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;CACd,CAAA;AAED,MAAM,4BAA4B,GAChC,kDAAkD,CAAA;AACpD,MAAM,4BAA4B,GAChC,kDAAkD,CAAA;AACpD,MAAM,2BAA2B,GAC/B,iDAAiD,CAAA;AACnD,MAAM,2BAA2B,GAC/B,iDAAiD,CAAA;AACnD,MAAM,uBAAuB,GAAG,uCAAuC,CAAA;AAEvE;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAiB;IACrD,CAAC,4BAA4B,EAAE,4BAA4B,CAAC;IAC5D,CAAC,4BAA4B,EAAE,4BAA4B,CAAC;IAC5D,CAAC,UAAU,EAAE,uBAAuB,CAAC;IACrC,CAAC,2BAA2B,EAAE,2BAA2B,CAAC;IAC1D,CAAC,2BAA2B,EAAE,2BAA2B,CAAC;CAC3D,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,gBAAgB;IAChB,iBAAiB;IACjB,sBAAsB;IACtB,sBAAsB;CACvB,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { DidWebResolver, didFromUrl, getNode, urlFromDid } from './DidWebResolver.js';
2
+ declare const driver: (options?: {
3
+ allowList?: string[];
4
+ fetchOptions?: any;
5
+ logger?: any;
6
+ }) => DidWebResolver;
7
+ export { driver, DidWebResolver, didFromUrl, getNode, urlFromDid };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,UAAU,EACV,OAAO,EACP,UAAU,EACX,MAAM,qBAAqB,CAAA;AAE5B,QAAA,MAAM,MAAM,GACV,UAAS;IAAE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,CAAC,EAAE,GAAG,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,CAAA;CAAO,KACvE,cAEF,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { DidWebResolver, didFromUrl, getNode, urlFromDid } from './DidWebResolver.js';
2
+ const driver = (options = {}) => {
3
+ return new DidWebResolver(options);
4
+ };
5
+ export { driver, DidWebResolver, didFromUrl, getNode, urlFromDid };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,UAAU,EACV,OAAO,EACP,UAAU,EACX,MAAM,qBAAqB,CAAA;AAE5B,MAAM,MAAM,GAAG,CACb,UAAsE,EAAE,EACxD,EAAE;IAClB,OAAO,IAAI,cAAc,CAAC,OAAO,CAAC,CAAA;AACpC,CAAC,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,93 +1,85 @@
1
1
  {
2
2
  "name": "@interop/did-web-resolver",
3
3
  "description": "A did:web method Decentralized Identifier (DID) resolver for the did-io library.",
4
- "version": "5.0.0",
5
- "author": {
6
- "name": "Dmitri Zagidulin",
7
- "url": "https://github.com/dmitrizagidulin/"
8
- },
9
- "license": "MIT",
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/interop-alliance/did-web-driver"
13
- },
14
- "homepage": "https://github.com/interop-alliance/did-web-driver",
15
- "bugs": "https://github.com/interop-alliance/did-web-driver/issues",
4
+ "version": "6.0.0",
5
+ "type": "module",
16
6
  "scripts": {
17
- "build": "npm run clear && tsc -d && tsc -p tsconfig.esm.json",
7
+ "build": "pnpm run clear && tsc",
18
8
  "clear": "rimraf dist/*",
19
- "lint": "ts-standard --fix --project tsconfig.spec.json",
20
- "prepare": "npm run build",
21
- "rebuild": "npm run clear && npm run build",
22
- "test": "npm run lint && npm run test-node",
23
- "test-node": "cross-env NODE_ENV=test TS_NODE_PROJECT=tsconfig.spec.json TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register --project tsconfig.spec.json 'test/*.ts'"
9
+ "dev": "vite",
10
+ "fix": "eslint --fix src test && pnpm run format",
11
+ "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
12
+ "lint": "eslint src test",
13
+ "prepare": "pnpm run build",
14
+ "rebuild": "pnpm run clear && pnpm run build",
15
+ "test": "pnpm run lint && pnpm run test-node && pnpm run test-browser",
16
+ "test-browser": "playwright test",
17
+ "test-node": "vitest run",
18
+ "test-coverage": "vitest run --coverage"
24
19
  },
25
20
  "files": [
26
21
  "dist",
27
- "src",
28
22
  "README.md",
29
- "LICENSE"
23
+ "LICENSE.md"
30
24
  ],
31
- "main": "dist/src/index.js",
32
- "module": "dist/esm/index.js",
33
- "browser": "dist/esm/index.js",
34
- "types": "dist/esm/index.d.ts",
35
- "dependencies": {
36
- "@digitalcredentials/http-client": "^5.0.1",
37
- "@digitalcredentials/bnid": "^3.0.1",
38
- "@digitalcredentials/did-io": "^1.0.2",
39
- "did-context": "^3.1.1",
40
- "ed25519-signature-2020-context": "^1.1.0",
41
- "whatwg-url": "^14.0.0",
42
- "x25519-key-agreement-2020-context": "^1.0.0"
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "react-native": "./dist/index.js",
29
+ "import": "./dist/index.js"
30
+ }
43
31
  },
44
- "resolutions": {
45
- "@typescript-eslint/typescript-estree": "^6.1.6"
32
+ "module": "dist/index.js",
33
+ "browser": "dist/index.js",
34
+ "types": "dist/index.d.ts",
35
+ "sideEffects": false,
36
+ "dependencies": {
37
+ "@digitalcredentials/bnid": "^5.0.0",
38
+ "@interop/did-io": "^2.0.1",
39
+ "@interop/http-client": "^1.0.3",
40
+ "did-context": "^3.1.1"
46
41
  },
47
42
  "devDependencies": {
48
- "@digitalcredentials/ed25519-verification-key-2020": "^3.2.2",
49
43
  "@digitalcredentials/x25519-key-agreement-key-2020": "^2.0.2",
50
- "@types/chai": "^4.3.5",
51
- "@types/mocha": "^10.0.1",
52
- "@types/node": "^20.4.6",
53
- "@typescript-eslint/eslint-plugin": "^5.0.0",
54
- "@typescript-eslint/parser": "^5.0.0",
55
- "chai": "^4.3.7",
56
- "cross-env": "^7.0.3",
57
- "crypto-ld": "^6.0.0",
58
- "eslint": "^8.46.0",
59
- "mocha": "^10.2.0",
60
- "rimraf": "^6.0.1",
61
- "ts-node": "^10.9.1",
62
- "ts-standard": "^12.0.2",
63
- "typescript": "5.2.2"
44
+ "@eslint/js": "^10.0.1",
45
+ "@interop/ed25519-verification-key": "^6.2.0",
46
+ "@playwright/test": "^1.60.0",
47
+ "@types/node": "^25.9.1",
48
+ "@vitest/coverage-v8": "^4.1.7",
49
+ "eslint": "^10.4.0",
50
+ "eslint-config-prettier": "^10.1.8",
51
+ "globals": "^17.6.0",
52
+ "prettier": "^3.8.3",
53
+ "rimraf": "^6.1.3",
54
+ "typescript": "^5.5.0",
55
+ "typescript-eslint": "^8.59.4",
56
+ "vite": "^8.0.14",
57
+ "vitest": "^4.1.7"
64
58
  },
65
59
  "publishConfig": {
66
- "access": "public"
60
+ "access": "public",
61
+ "provenance": true
67
62
  },
68
- "mocha": {
69
- "require": "ts-node/register",
70
- "extension": [
71
- "ts"
72
- ],
73
- "spec": "test/**/*.ts"
63
+ "keywords": [
64
+ "did",
65
+ "did:web",
66
+ "decentralized-identifier",
67
+ "did-io",
68
+ "isomorphic"
69
+ ],
70
+ "packageManager": "pnpm@11.3.0",
71
+ "engines": {
72
+ "node": ">=24.0"
74
73
  },
75
- "ts-standard": {
76
- "ignore": [
77
- "dist"
78
- ],
79
- "globals": [
80
- "it",
81
- "describe",
82
- "beforeEach"
83
- ]
74
+ "author": {
75
+ "name": "Interop Alliance",
76
+ "url": "https://github.com/interop-alliance/"
84
77
  },
85
- "engines": {
86
- "node": ">=18.0"
78
+ "license": "MIT",
79
+ "repository": {
80
+ "type": "git",
81
+ "url": "git+https://github.com/interop-alliance/did-web-resolver.git"
87
82
  },
88
- "standard": {
89
- "globals": [
90
- "it"
91
- ]
92
- }
83
+ "homepage": "https://github.com/interop-alliance/did-web-resolver",
84
+ "bugs": "https://github.com/interop-alliance/did-web-resolver/issues"
93
85
  }
@@ -1,147 +0,0 @@
1
- export declare function didFromUrl({ url }?: {
2
- url?: string;
3
- }): string;
4
- export declare function urlFromDid({ did }: {
5
- did: string | undefined;
6
- }): string;
7
- /**
8
- * Initializes the DID Document's keys/proof methods.
9
- *
10
- * @example
11
- * didDocument.id = 'did:ex:123';
12
- * const {didDocument, keyPairs} = await initKeys({
13
- * didDocument,
14
- * cryptoLd,
15
- * keyMap: {
16
- * capabilityInvocation: someExistingKey,
17
- * authentication: 'Ed25519VerificationKey2020',
18
- * assertionMethod: 'Ed25519VerificationKey2020',
19
- * keyAgreement: 'X25519KeyAgreementKey2019'
20
- * }
21
- * });.
22
- *
23
- * @param {object} options - Options hashmap.
24
- * @param {object} options.didDocument - DID Document.
25
- * @typedef {object} CryptoLD
26
- * @param {CryptoLD} [options.cryptoLd] - CryptoLD driver instance,
27
- * initialized with the key types this DID Document intends to support.
28
- * @param {object} [options.keyMap] - Map of keys (or key types) by purpose.
29
- *
30
- * @returns {Promise<{didDocument: object, keyPairs: Map}>} Resolves with the
31
- * DID Document initialized with keys, as well as the map of the corresponding
32
- * key pairs (by key id).
33
- */
34
- export declare function initKeys({ didDocument, cryptoLd, keyMap }?: {
35
- didDocument?: object;
36
- cryptoLd?: any;
37
- keyMap?: any;
38
- }): Promise<{
39
- didDocument: object;
40
- keyPairs: Map<string, any>;
41
- }>;
42
- export declare class DidWebResolver {
43
- cryptoLd: any;
44
- keyMap: object;
45
- method: string;
46
- logger: any;
47
- /**
48
- * @param cryptoLd {CryptoLD}
49
- * @param keyMap {object}
50
- * @param [logger] {object} Logger object (with .log, .error, .warn,
51
- * etc methods).
52
- */
53
- constructor({ cryptoLd, keyMap, logger }?: {
54
- cryptoLd?: any;
55
- keyMap?: object;
56
- logger?: any;
57
- });
58
- /**
59
- * Generates a new DID Document and initializes various authentication
60
- * and authorization proof purpose keys.
61
- *
62
- * @example
63
- * const url = 'https://example.com'
64
- * const { didDocument, didKeys } = await didWeb.generate({url})
65
- * didDocument.id
66
- * // -> 'did:web:example.com'
67
- *
68
- *
69
- * Either an `id` or a `url` is required:
70
- * @param [id] {string} - A did:web DID. If absent, will be converted from url
71
- * @param [url] {string}
72
- * @param [seed] {string|Uint8Array}
73
- *
74
- * @param [keyMap] {object} A hashmap of key types by purpose.
75
- *
76
- * @param cryptoLd
77
- * @parma [cryptoLd] {object} CryptoLD instance with support for supported
78
- * crypto suites installed.
79
- *
80
- * @returns {Promise<{didDocument: object, keyPairs: object,
81
- * methodFor: Function}>} Resolves with the generated DID Document, along
82
- * with the corresponding key pairs used to generate it (for storage in a
83
- * KMS).
84
- */
85
- generate({ id, url, seed, keyMap, cryptoLd }?: {
86
- id?: string;
87
- url?: string;
88
- seed?: string | Uint8Array;
89
- keyMap?: any;
90
- cryptoLd?: any;
91
- }): Promise<{
92
- didDocument: any;
93
- keyPairs: object;
94
- methodFor: Function;
95
- }>;
96
- /**
97
- * Fetches a DID Document for a given DID.
98
- *
99
- * @example
100
- * // In Node.js tests, use an agent to avoid self-signed certificate errors
101
- * const agent = new https.agent({rejectUnauthorized: false});
102
- *
103
- * @param {string} [did] For example, 'did:web:example.com'
104
- * @param {string} [url]
105
- * @param {https.Agent} [agent] Optional agent used to customize network
106
- * behavior in Node.js (such as `rejectUnauthorized: false`).
107
- * @param {object} [logger] Logger object (with .log, .error, .warn,
108
- * etc methods).
109
- *
110
- * @throws {Error}
111
- *
112
- * @returns {Promise<object>} Plain parsed JSON object of the DID Document.
113
- */
114
- get({ did, url, agent, logger }: {
115
- did?: string | undefined;
116
- url?: string | undefined;
117
- agent?: any;
118
- logger?: any;
119
- }): Promise<object>;
120
- /**
121
- * Returns the public key (verification method) object for a given DID
122
- * Document and purpose. Useful in conjunction with a `.get()` call.
123
- *
124
- * @example
125
- * const didDocument = await didKeyDriver.get({did});
126
- * const authKeyData = didDriver.publicMethodFor({
127
- * didDocument, purpose: 'authentication'
128
- * });
129
- * // You can then create a suite instance object to verify signatures etc.
130
- * const authPublicKey = await cryptoLd.from(authKeyData);
131
- * const {verify} = authPublicKey.verifier();
132
- *
133
- * @param {object} options - Options hashmap.
134
- * @param {object} options.didDocument - DID Document (retrieved via a
135
- * `.get()` or from some other source).
136
- * @param {string} options.purpose - Verification method purpose, such as
137
- * 'authentication', 'assertionMethod', 'keyAgreement' and so on.
138
- *
139
- * @returns {object} Returns the public key object (obtained from the DID
140
- * Document), without a `@context`.
141
- */
142
- publicMethodFor({ didDocument, purpose }: {
143
- didDocument: any;
144
- purpose: string;
145
- }): any;
146
- }
147
- //# sourceMappingURL=DidWebResolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DidWebResolver.d.ts","sourceRoot":"","sources":["../../src/DidWebResolver.ts"],"names":[],"mappings":"AAmBA,wBAAgB,UAAU,CAAE,EAAE,GAAG,EAAE,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAkClE;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