@twin.org/identity-connector-universal 0.0.2-next.9 → 0.0.3-next.2
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.
- package/dist/es/index.js +6 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IUniversalResolverConnectorConfig.js +4 -0
- package/dist/es/models/IUniversalResolverConnectorConfig.js.map +1 -0
- package/dist/es/models/IUniversalResolverConnectorConstructorOptions.js +2 -0
- package/dist/es/models/IUniversalResolverConnectorConstructorOptions.js.map +1 -0
- package/dist/es/models/api/IUniversalResolverResult.js +2 -0
- package/dist/es/models/api/IUniversalResolverResult.js.map +1 -0
- package/dist/{esm/index.mjs → es/universalResolverConnector.js} +11 -6
- package/dist/es/universalResolverConnector.js.map +1 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/models/IUniversalResolverConnectorConstructorOptions.d.ts +1 -1
- package/dist/types/universalResolverConnector.d.ts +6 -1
- package/docs/changelog.md +57 -0
- package/docs/reference/classes/UniversalResolverConnector.md +18 -0
- package/package.json +6 -8
- package/dist/cjs/index.cjs +0 -52
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./universalResolverConnector.js";
|
|
4
|
+
export * from "./models/IUniversalResolverConnectorConfig.js";
|
|
5
|
+
export * from "./models/IUniversalResolverConnectorConstructorOptions.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,2DAA2D,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./universalResolverConnector.js\";\nexport * from \"./models/IUniversalResolverConnectorConfig.js\";\nexport * from \"./models/IUniversalResolverConnectorConstructorOptions.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IUniversalResolverConnectorConfig.js","sourceRoot":"","sources":["../../../src/models/IUniversalResolverConnectorConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Universal Resolver Connector.\n */\nexport interface IUniversalResolverConnectorConfig {\n\t/**\n\t * The root url for the universal resolver.\n\t */\n\tendpoint: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IUniversalResolverConnectorConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IUniversalResolverConnectorConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IUniversalResolverConnectorConfig } from \"./IUniversalResolverConnectorConfig.js\";\n\n/**\n * Options for the Universal Resolver Connector constructor.\n */\nexport interface IUniversalResolverConnectorConstructorOptions {\n\t/**\n\t * The configuration for the identity connector.\n\t */\n\tconfig: IUniversalResolverConnectorConfig;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IUniversalResolverResult.js","sourceRoot":"","sources":["../../../../src/models/api/IUniversalResolverResult.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\n\n/**\n * Universal Resolver DIF resolution result\n */\nexport interface IUniversalResolverResult {\n\t/**\n\t * DID Document resolved.\n\t */\n\tdidDocument: IDidDocument;\n\n\t/**\n\t * Resolution metadata\n\t */\n\tdidResolutionMetadata: {\n\t\t/**\n\t\t * The created date of the did document.\n\t\t */\n\t\tcreated: string;\n\n\t\t/**\n\t\t * The updated date of the did document.\n\t\t */\n\t\tupdated: string;\n\t};\n\n\t/**\n\t * DID Document metadata\n\t */\n\tdidDocumentMetadata: unknown;\n}\n"]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Guards, StringHelper, GeneralError } from '@twin.org/core';
|
|
2
|
-
import { FetchHelper, HttpMethod } from '@twin.org/web';
|
|
3
|
-
|
|
4
1
|
// Copyright 2024 IOTA Stiftung.
|
|
5
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { GeneralError, Guards, StringHelper } from "@twin.org/core";
|
|
4
|
+
import { FetchHelper, HttpMethod } from "@twin.org/web";
|
|
6
5
|
/**
|
|
7
6
|
* Class for performing identity operations on a universal resolver.
|
|
8
7
|
*/
|
|
9
|
-
class UniversalResolverConnector {
|
|
8
|
+
export class UniversalResolverConnector {
|
|
10
9
|
/**
|
|
11
10
|
* The namespace supported by the identity connector.
|
|
12
11
|
*/
|
|
@@ -30,6 +29,13 @@ class UniversalResolverConnector {
|
|
|
30
29
|
Guards.stringValue(UniversalResolverConnector.CLASS_NAME, "options.config.endpoint", options.config.endpoint);
|
|
31
30
|
this._resolverEndpoint = options.config.endpoint;
|
|
32
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the class name of the component.
|
|
34
|
+
* @returns The class name of the component.
|
|
35
|
+
*/
|
|
36
|
+
className() {
|
|
37
|
+
return UniversalResolverConnector.CLASS_NAME;
|
|
38
|
+
}
|
|
33
39
|
/**
|
|
34
40
|
* Resolve a document from its id.
|
|
35
41
|
* @param documentId The id of the document to resolve.
|
|
@@ -46,5 +52,4 @@ class UniversalResolverConnector {
|
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
}
|
|
49
|
-
|
|
50
|
-
export { UniversalResolverConnector };
|
|
55
|
+
//# sourceMappingURL=universalResolverConnector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"universalResolverConnector.js","sourceRoot":"","sources":["../../src/universalResolverConnector.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAIpE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAKxD;;GAEG;AACH,MAAM,OAAO,0BAA0B;IACtC;;OAEG;IACI,MAAM,CAAU,SAAS,GAAW,WAAW,CAAC;IAEvD;;OAEG;IACI,MAAM,CAAU,UAAU,gCAAgD;IAEjF;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;OAGG;IACH,YAAY,OAAsD;QACjE,MAAM,CAAC,MAAM,CAAC,0BAA0B,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QAC/E,MAAM,CAAC,MAAM,CACZ,0BAA0B,CAAC,UAAU,oBAErC,OAAO,CAAC,MAAM,CACd,CAAC;QACF,MAAM,CAAC,WAAW,CACjB,0BAA0B,CAAC,UAAU,6BAErC,OAAO,CAAC,MAAM,CAAC,QAAQ,CACvB,CAAC;QAEF,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;IAClD,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,0BAA0B,CAAC,UAAU,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,eAAe,CAAC,UAAkB;QAC9C,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CACzC,0BAA0B,CAAC,UAAU,EACrC,GAAG,YAAY,CAAC,mBAAmB,CAAC,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,kBAAkB,CAAC,UAAU,CAAC,EAAE,EAC/G,UAAU,CAAC,GAAG,CACd,CAAC;YAEF,OAAO,MAAM,CAAC,WAAW,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,YAAY,CACrB,0BAA0B,CAAC,UAAU,EACrC,uBAAuB,EACvB,EAAE,UAAU,EAAE,EACd,KAAK,CACL,CAAC;QACH,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, StringHelper } from \"@twin.org/core\";\nimport type { IIdentityResolverConnector } from \"@twin.org/identity-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IDidDocument } from \"@twin.org/standards-w3c-did\";\nimport { FetchHelper, HttpMethod } from \"@twin.org/web\";\nimport type { IUniversalResolverResult } from \"./models/api/IUniversalResolverResult.js\";\nimport type { IUniversalResolverConnectorConfig } from \"./models/IUniversalResolverConnectorConfig.js\";\nimport type { IUniversalResolverConnectorConstructorOptions } from \"./models/IUniversalResolverConnectorConstructorOptions.js\";\n\n/**\n * Class for performing identity operations on a universal resolver.\n */\nexport class UniversalResolverConnector implements IIdentityResolverConnector {\n\t/**\n\t * The namespace supported by the identity connector.\n\t */\n\tpublic static readonly NAMESPACE: string = \"universal\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<UniversalResolverConnector>();\n\n\t/**\n\t * The url for the resolver.\n\t * @internal\n\t */\n\tprivate readonly _resolverEndpoint: string;\n\n\t/**\n\t * Create a new instance of UniversalResolverConnector.\n\t * @param options The options for the identity connector.\n\t */\n\tconstructor(options: IUniversalResolverConnectorConstructorOptions) {\n\t\tGuards.object(UniversalResolverConnector.CLASS_NAME, nameof(options), options);\n\t\tGuards.object<IUniversalResolverConnectorConfig>(\n\t\t\tUniversalResolverConnector.CLASS_NAME,\n\t\t\tnameof(options.config),\n\t\t\toptions.config\n\t\t);\n\t\tGuards.stringValue(\n\t\t\tUniversalResolverConnector.CLASS_NAME,\n\t\t\tnameof(options.config.endpoint),\n\t\t\toptions.config.endpoint\n\t\t);\n\n\t\tthis._resolverEndpoint = options.config.endpoint;\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn UniversalResolverConnector.CLASS_NAME;\n\t}\n\n\t/**\n\t * Resolve a document from its id.\n\t * @param documentId The id of the document to resolve.\n\t * @returns The resolved document.\n\t * @throws NotFoundError if the id can not be resolved.\n\t */\n\tpublic async resolveDocument(documentId: string): Promise<IDidDocument> {\n\t\ttry {\n\t\t\tconst result = await FetchHelper.fetchJson<never, IUniversalResolverResult>(\n\t\t\t\tUniversalResolverConnector.CLASS_NAME,\n\t\t\t\t`${StringHelper.trimTrailingSlashes(this._resolverEndpoint)}/1.0/identifiers/${encodeURIComponent(documentId)}`,\n\t\t\t\tHttpMethod.GET\n\t\t\t);\n\n\t\t\treturn result.didDocument;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tUniversalResolverConnector.CLASS_NAME,\n\t\t\t\t\"resolveDocumentFailed\",\n\t\t\t\t{ documentId },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./universalResolverConnector";
|
|
2
|
-
export * from "./models/IUniversalResolverConnectorConfig";
|
|
3
|
-
export * from "./models/IUniversalResolverConnectorConstructorOptions";
|
|
1
|
+
export * from "./universalResolverConnector.js";
|
|
2
|
+
export * from "./models/IUniversalResolverConnectorConfig.js";
|
|
3
|
+
export * from "./models/IUniversalResolverConnectorConstructorOptions.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IIdentityResolverConnector } from "@twin.org/identity-models";
|
|
2
2
|
import type { IDidDocument } from "@twin.org/standards-w3c-did";
|
|
3
|
-
import type { IUniversalResolverConnectorConstructorOptions } from "./models/IUniversalResolverConnectorConstructorOptions";
|
|
3
|
+
import type { IUniversalResolverConnectorConstructorOptions } from "./models/IUniversalResolverConnectorConstructorOptions.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class for performing identity operations on a universal resolver.
|
|
6
6
|
*/
|
|
@@ -18,6 +18,11 @@ export declare class UniversalResolverConnector implements IIdentityResolverConn
|
|
|
18
18
|
* @param options The options for the identity connector.
|
|
19
19
|
*/
|
|
20
20
|
constructor(options: IUniversalResolverConnectorConstructorOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Returns the class name of the component.
|
|
23
|
+
* @returns The class name of the component.
|
|
24
|
+
*/
|
|
25
|
+
className(): string;
|
|
21
26
|
/**
|
|
22
27
|
* Resolve a document from its id.
|
|
23
28
|
* @param documentId The id of the document to resolve.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,62 @@
|
|
|
1
1
|
# @twin.org/identity-connector-Universal - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.2](https://github.com/twinfoundation/identity/compare/identity-connector-universal-v0.0.3-next.1...identity-connector-universal-v0.0.3-next.2) (2025-11-14)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **identity-connector-universal:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/identity-models bumped from 0.0.3-next.1 to 0.0.3-next.2
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.1](https://github.com/twinfoundation/identity/compare/identity-connector-universal-v0.0.3-next.0...identity-connector-universal-v0.0.3-next.1) (2025-11-11)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add context id features ([#62](https://github.com/twinfoundation/identity/issues/62)) ([e02ecca](https://github.com/twinfoundation/identity/commit/e02ecca9c45a849104bfbf7bc18a1f44e6eea8a1))
|
|
23
|
+
* add mainnet support ([af56a38](https://github.com/twinfoundation/identity/commit/af56a382837896cd4e13d5814c0924c46658b99c))
|
|
24
|
+
* add validate-locales ([04d74b4](https://github.com/twinfoundation/identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
|
|
25
|
+
* eslint migration to flat config ([fd6246d](https://github.com/twinfoundation/identity/commit/fd6246d566280b6d5d10a108eb1e92c4b510f2f2))
|
|
26
|
+
* identity key separator use slash ([1319d0d](https://github.com/twinfoundation/identity/commit/1319d0d07164a36b3ec279e6421b8835ffefc3d3))
|
|
27
|
+
* improve url construction ([544a435](https://github.com/twinfoundation/identity/commit/544a435dadb90b9e29533f4a4ce09725268d04bd))
|
|
28
|
+
* re-use vault keys if available ([5a848d7](https://github.com/twinfoundation/identity/commit/5a848d7520829d9c891ec889fd773fbc0ee77ba5))
|
|
29
|
+
* update comment ([436e030](https://github.com/twinfoundation/identity/commit/436e030e9480bdc4e35b44ad7199a5ccc7a7b31e))
|
|
30
|
+
* update framework core ([c824497](https://github.com/twinfoundation/identity/commit/c82449709af0215eb7af496cf687c93fb30b5ae0))
|
|
31
|
+
* use shared store mechanism ([#27](https://github.com/twinfoundation/identity/issues/27)) ([ce41f3f](https://github.com/twinfoundation/identity/commit/ce41f3fc3da1b206ec06da7ea5b2c968f788804d))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* Import path and bump version ([#21](https://github.com/twinfoundation/identity/issues/21)) ([ccea845](https://github.com/twinfoundation/identity/commit/ccea845bf32562267280bc1b3dde1c9af1a00360))
|
|
37
|
+
* Install sdk-wasm ([#20](https://github.com/twinfoundation/identity/issues/20)) ([75ec14e](https://github.com/twinfoundation/identity/commit/75ec14e072f8c219863a1c028a3b0783802086e9))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Dependencies
|
|
41
|
+
|
|
42
|
+
* The following workspace dependencies were updated
|
|
43
|
+
* dependencies
|
|
44
|
+
* @twin.org/identity-models bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
45
|
+
|
|
46
|
+
## [0.0.2-next.10](https://github.com/twinfoundation/identity/compare/identity-connector-universal-v0.0.2-next.9...identity-connector-universal-v0.0.2-next.10) (2025-10-27)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Miscellaneous Chores
|
|
50
|
+
|
|
51
|
+
* **identity-connector-universal:** Synchronize repo versions
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Dependencies
|
|
55
|
+
|
|
56
|
+
* The following workspace dependencies were updated
|
|
57
|
+
* dependencies
|
|
58
|
+
* @twin.org/identity-models bumped from 0.0.2-next.9 to 0.0.2-next.10
|
|
59
|
+
|
|
3
60
|
## [0.0.2-next.9](https://github.com/twinfoundation/identity/compare/identity-connector-universal-v0.0.2-next.8...identity-connector-universal-v0.0.2-next.9) (2025-10-09)
|
|
4
61
|
|
|
5
62
|
|
|
@@ -44,6 +44,24 @@ Runtime name for the class.
|
|
|
44
44
|
|
|
45
45
|
## Methods
|
|
46
46
|
|
|
47
|
+
### className()
|
|
48
|
+
|
|
49
|
+
> **className**(): `string`
|
|
50
|
+
|
|
51
|
+
Returns the class name of the component.
|
|
52
|
+
|
|
53
|
+
#### Returns
|
|
54
|
+
|
|
55
|
+
`string`
|
|
56
|
+
|
|
57
|
+
The class name of the component.
|
|
58
|
+
|
|
59
|
+
#### Implementation of
|
|
60
|
+
|
|
61
|
+
`IIdentityResolverConnector.className`
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
47
65
|
### resolveDocument()
|
|
48
66
|
|
|
49
67
|
> **resolveDocument**(`documentId`): `Promise`\<`IDidDocument`\>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-connector-universal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-next.2",
|
|
4
4
|
"description": "Identity connector implementation using universal resolver",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,25 +15,23 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
|
-
"@twin.org/identity-models": "0.0.
|
|
18
|
+
"@twin.org/identity-models": "0.0.3-next.2",
|
|
19
19
|
"@twin.org/nameof": "next",
|
|
20
20
|
"@twin.org/standards-w3c-did": "next",
|
|
21
21
|
"@twin.org/web": "next"
|
|
22
22
|
},
|
|
23
|
-
"main": "./dist/
|
|
24
|
-
"module": "./dist/esm/index.mjs",
|
|
23
|
+
"main": "./dist/es/index.js",
|
|
25
24
|
"types": "./dist/types/index.d.ts",
|
|
26
25
|
"exports": {
|
|
27
26
|
".": {
|
|
28
27
|
"types": "./dist/types/index.d.ts",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
28
|
+
"import": "./dist/es/index.js",
|
|
29
|
+
"default": "./dist/es/index.js"
|
|
31
30
|
},
|
|
32
31
|
"./locales/*.json": "./locales/*.json"
|
|
33
32
|
},
|
|
34
33
|
"files": [
|
|
35
|
-
"dist/
|
|
36
|
-
"dist/esm",
|
|
34
|
+
"dist/es",
|
|
37
35
|
"dist/types",
|
|
38
36
|
"locales",
|
|
39
37
|
"docs"
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@twin.org/core');
|
|
4
|
-
var web = require('@twin.org/web');
|
|
5
|
-
|
|
6
|
-
// Copyright 2024 IOTA Stiftung.
|
|
7
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
8
|
-
/**
|
|
9
|
-
* Class for performing identity operations on a universal resolver.
|
|
10
|
-
*/
|
|
11
|
-
class UniversalResolverConnector {
|
|
12
|
-
/**
|
|
13
|
-
* The namespace supported by the identity connector.
|
|
14
|
-
*/
|
|
15
|
-
static NAMESPACE = "universal";
|
|
16
|
-
/**
|
|
17
|
-
* Runtime name for the class.
|
|
18
|
-
*/
|
|
19
|
-
static CLASS_NAME = "UniversalResolverConnector";
|
|
20
|
-
/**
|
|
21
|
-
* The url for the resolver.
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
_resolverEndpoint;
|
|
25
|
-
/**
|
|
26
|
-
* Create a new instance of UniversalResolverConnector.
|
|
27
|
-
* @param options The options for the identity connector.
|
|
28
|
-
*/
|
|
29
|
-
constructor(options) {
|
|
30
|
-
core.Guards.object(UniversalResolverConnector.CLASS_NAME, "options", options);
|
|
31
|
-
core.Guards.object(UniversalResolverConnector.CLASS_NAME, "options.config", options.config);
|
|
32
|
-
core.Guards.stringValue(UniversalResolverConnector.CLASS_NAME, "options.config.endpoint", options.config.endpoint);
|
|
33
|
-
this._resolverEndpoint = options.config.endpoint;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Resolve a document from its id.
|
|
37
|
-
* @param documentId The id of the document to resolve.
|
|
38
|
-
* @returns The resolved document.
|
|
39
|
-
* @throws NotFoundError if the id can not be resolved.
|
|
40
|
-
*/
|
|
41
|
-
async resolveDocument(documentId) {
|
|
42
|
-
try {
|
|
43
|
-
const result = await web.FetchHelper.fetchJson(UniversalResolverConnector.CLASS_NAME, `${core.StringHelper.trimTrailingSlashes(this._resolverEndpoint)}/1.0/identifiers/${encodeURIComponent(documentId)}`, web.HttpMethod.GET);
|
|
44
|
-
return result.didDocument;
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
throw new core.GeneralError(UniversalResolverConnector.CLASS_NAME, "resolveDocumentFailed", { documentId }, error);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
exports.UniversalResolverConnector = UniversalResolverConnector;
|