@twin.org/identity-connector-universal 0.0.2-next.8 → 0.0.3-next.1

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.
@@ -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,4 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ export {};
4
+ //# sourceMappingURL=IUniversalResolverConnectorConfig.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IUniversalResolverConnectorConstructorOptions.js.map
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=IUniversalResolverResult.js.map
@@ -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"]}
@@ -0,0 +1,55 @@
1
+ // Copyright 2024 IOTA Stiftung.
2
+ // SPDX-License-Identifier: Apache-2.0.
3
+ import { GeneralError, Guards, StringHelper } from "@twin.org/core";
4
+ import { FetchHelper, HttpMethod } from "@twin.org/web";
5
+ /**
6
+ * Class for performing identity operations on a universal resolver.
7
+ */
8
+ export class UniversalResolverConnector {
9
+ /**
10
+ * The namespace supported by the identity connector.
11
+ */
12
+ static NAMESPACE = "universal";
13
+ /**
14
+ * Runtime name for the class.
15
+ */
16
+ static CLASS_NAME = "UniversalResolverConnector";
17
+ /**
18
+ * The url for the resolver.
19
+ * @internal
20
+ */
21
+ _resolverEndpoint;
22
+ /**
23
+ * Create a new instance of UniversalResolverConnector.
24
+ * @param options The options for the identity connector.
25
+ */
26
+ constructor(options) {
27
+ Guards.object(UniversalResolverConnector.CLASS_NAME, "options", options);
28
+ Guards.object(UniversalResolverConnector.CLASS_NAME, "options.config", options.config);
29
+ Guards.stringValue(UniversalResolverConnector.CLASS_NAME, "options.config.endpoint", options.config.endpoint);
30
+ this._resolverEndpoint = options.config.endpoint;
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
+ }
39
+ /**
40
+ * Resolve a document from its id.
41
+ * @param documentId The id of the document to resolve.
42
+ * @returns The resolved document.
43
+ * @throws NotFoundError if the id can not be resolved.
44
+ */
45
+ async resolveDocument(documentId) {
46
+ try {
47
+ const result = await FetchHelper.fetchJson(UniversalResolverConnector.CLASS_NAME, `${StringHelper.trimTrailingSlashes(this._resolverEndpoint)}/1.0/identifiers/${encodeURIComponent(documentId)}`, HttpMethod.GET);
48
+ return result.didDocument;
49
+ }
50
+ catch (error) {
51
+ throw new GeneralError(UniversalResolverConnector.CLASS_NAME, "resolveDocumentFailed", { documentId }, error);
52
+ }
53
+ }
54
+ }
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"]}
@@ -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,4 +1,4 @@
1
- import type { IUniversalResolverConnectorConfig } from "./IUniversalResolverConnectorConfig";
1
+ import type { IUniversalResolverConnectorConfig } from "./IUniversalResolverConnectorConfig.js";
2
2
  /**
3
3
  * Options for the Universal Resolver Connector constructor.
4
4
  */
@@ -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
  */
@@ -12,12 +12,17 @@ export declare class UniversalResolverConnector implements IIdentityResolverConn
12
12
  /**
13
13
  * Runtime name for the class.
14
14
  */
15
- readonly CLASS_NAME: string;
15
+ static readonly CLASS_NAME: string;
16
16
  /**
17
17
  * Create a new instance of UniversalResolverConnector.
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.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)
4
+
5
+
6
+ ### Features
7
+
8
+ * add context id features ([#62](https://github.com/twinfoundation/identity/issues/62)) ([e02ecca](https://github.com/twinfoundation/identity/commit/e02ecca9c45a849104bfbf7bc18a1f44e6eea8a1))
9
+ * add mainnet support ([af56a38](https://github.com/twinfoundation/identity/commit/af56a382837896cd4e13d5814c0924c46658b99c))
10
+ * add validate-locales ([04d74b4](https://github.com/twinfoundation/identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
11
+ * eslint migration to flat config ([fd6246d](https://github.com/twinfoundation/identity/commit/fd6246d566280b6d5d10a108eb1e92c4b510f2f2))
12
+ * identity key separator use slash ([1319d0d](https://github.com/twinfoundation/identity/commit/1319d0d07164a36b3ec279e6421b8835ffefc3d3))
13
+ * improve url construction ([544a435](https://github.com/twinfoundation/identity/commit/544a435dadb90b9e29533f4a4ce09725268d04bd))
14
+ * re-use vault keys if available ([5a848d7](https://github.com/twinfoundation/identity/commit/5a848d7520829d9c891ec889fd773fbc0ee77ba5))
15
+ * update comment ([436e030](https://github.com/twinfoundation/identity/commit/436e030e9480bdc4e35b44ad7199a5ccc7a7b31e))
16
+ * update framework core ([c824497](https://github.com/twinfoundation/identity/commit/c82449709af0215eb7af496cf687c93fb30b5ae0))
17
+ * use shared store mechanism ([#27](https://github.com/twinfoundation/identity/issues/27)) ([ce41f3f](https://github.com/twinfoundation/identity/commit/ce41f3fc3da1b206ec06da7ea5b2c968f788804d))
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * Import path and bump version ([#21](https://github.com/twinfoundation/identity/issues/21)) ([ccea845](https://github.com/twinfoundation/identity/commit/ccea845bf32562267280bc1b3dde1c9af1a00360))
23
+ * Install sdk-wasm ([#20](https://github.com/twinfoundation/identity/issues/20)) ([75ec14e](https://github.com/twinfoundation/identity/commit/75ec14e072f8c219863a1c028a3b0783802086e9))
24
+
25
+
26
+ ### Dependencies
27
+
28
+ * The following workspace dependencies were updated
29
+ * dependencies
30
+ * @twin.org/identity-models bumped from 0.0.3-next.0 to 0.0.3-next.1
31
+
32
+ ## [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)
33
+
34
+
35
+ ### Miscellaneous Chores
36
+
37
+ * **identity-connector-universal:** Synchronize repo versions
38
+
39
+
40
+ ### Dependencies
41
+
42
+ * The following workspace dependencies were updated
43
+ * dependencies
44
+ * @twin.org/identity-models bumped from 0.0.2-next.9 to 0.0.2-next.10
45
+
46
+ ## [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)
47
+
48
+
49
+ ### Features
50
+
51
+ * add validate-locales ([04d74b4](https://github.com/twinfoundation/identity/commit/04d74b4d1ebe42672e8ca75a7bdb8e3556afd0be))
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.8 to 0.0.2-next.9
59
+
3
60
  ## [0.0.2-next.8](https://github.com/twinfoundation/identity/compare/identity-connector-universal-v0.0.2-next.7...identity-connector-universal-v0.0.2-next.8) (2025-09-25)
4
61
 
5
62
 
@@ -38,15 +38,29 @@ The namespace supported by the identity connector.
38
38
 
39
39
  ### CLASS\_NAME
40
40
 
41
- > `readonly` **CLASS\_NAME**: `string`
41
+ > `readonly` `static` **CLASS\_NAME**: `string`
42
42
 
43
43
  Runtime name for the class.
44
44
 
45
+ ## Methods
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
+
45
59
  #### Implementation of
46
60
 
47
- `IIdentityResolverConnector.CLASS_NAME`
61
+ `IIdentityResolverConnector.className`
48
62
 
49
- ## Methods
63
+ ***
50
64
 
51
65
  ### resolveDocument()
52
66
 
package/locales/en.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "error": {
3
3
  "universalResolverConnector": {
4
- "documentNotFound": "The document could not be found",
5
4
  "resolveDocumentFailed": "Resolving the document failed \"{documentId}\""
6
5
  }
7
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/identity-connector-universal",
3
- "version": "0.0.2-next.8",
3
+ "version": "0.0.3-next.1",
4
4
  "description": "Identity connector implementation using universal resolver",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,27 +15,43 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@twin.org/core": "next",
18
- "@twin.org/identity-models": "0.0.2-next.8",
18
+ "@twin.org/identity-models": "0.0.3-next.1",
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/cjs/index.cjs",
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
- "require": "./dist/cjs/index.cjs",
30
- "import": "./dist/esm/index.mjs"
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/cjs",
36
- "dist/esm",
34
+ "dist/es",
37
35
  "dist/types",
38
36
  "locales",
39
37
  "docs"
40
- ]
38
+ ],
39
+ "keywords": [
40
+ "twin",
41
+ "trade",
42
+ "iota",
43
+ "framework",
44
+ "blockchain",
45
+ "identity",
46
+ "did",
47
+ "credentials",
48
+ "authentication",
49
+ "connector",
50
+ "adapter",
51
+ "integration"
52
+ ],
53
+ "bugs": {
54
+ "url": "git+https://github.com/twinfoundation/identity/issues"
55
+ },
56
+ "homepage": "https://twindev.org"
41
57
  }
@@ -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
- 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(this.CLASS_NAME, "options", options);
31
- core.Guards.object(this.CLASS_NAME, "options.config", options.config);
32
- core.Guards.stringValue(this.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(this.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(this.CLASS_NAME, "resolveDocumentFailed", { documentId }, error);
48
- }
49
- }
50
- }
51
-
52
- exports.UniversalResolverConnector = UniversalResolverConnector;
@@ -1,50 +0,0 @@
1
- import { Guards, StringHelper, GeneralError } from '@twin.org/core';
2
- import { FetchHelper, HttpMethod } from '@twin.org/web';
3
-
4
- // Copyright 2024 IOTA Stiftung.
5
- // SPDX-License-Identifier: Apache-2.0.
6
- /**
7
- * Class for performing identity operations on a universal resolver.
8
- */
9
- class UniversalResolverConnector {
10
- /**
11
- * The namespace supported by the identity connector.
12
- */
13
- static NAMESPACE = "universal";
14
- /**
15
- * Runtime name for the class.
16
- */
17
- CLASS_NAME = "UniversalResolverConnector";
18
- /**
19
- * The url for the resolver.
20
- * @internal
21
- */
22
- _resolverEndpoint;
23
- /**
24
- * Create a new instance of UniversalResolverConnector.
25
- * @param options The options for the identity connector.
26
- */
27
- constructor(options) {
28
- Guards.object(this.CLASS_NAME, "options", options);
29
- Guards.object(this.CLASS_NAME, "options.config", options.config);
30
- Guards.stringValue(this.CLASS_NAME, "options.config.endpoint", options.config.endpoint);
31
- this._resolverEndpoint = options.config.endpoint;
32
- }
33
- /**
34
- * Resolve a document from its id.
35
- * @param documentId The id of the document to resolve.
36
- * @returns The resolved document.
37
- * @throws NotFoundError if the id can not be resolved.
38
- */
39
- async resolveDocument(documentId) {
40
- try {
41
- const result = await FetchHelper.fetchJson(this.CLASS_NAME, `${StringHelper.trimTrailingSlashes(this._resolverEndpoint)}/1.0/identifiers/${encodeURIComponent(documentId)}`, HttpMethod.GET);
42
- return result.didDocument;
43
- }
44
- catch (error) {
45
- throw new GeneralError(this.CLASS_NAME, "resolveDocumentFailed", { documentId }, error);
46
- }
47
- }
48
- }
49
-
50
- export { UniversalResolverConnector };