@twin.org/identity-connector-universal 0.0.3-next.20 → 0.0.3-next.21
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/universalResolverConnector.js +38 -1
- package/dist/es/universalResolverConnector.js.map +1 -1
- package/dist/types/universalResolverConnector.d.ts +6 -0
- package/docs/changelog.md +16 -2
- package/docs/reference/classes/UniversalResolverConnector.md +18 -0
- package/locales/en.json +6 -0
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright 2024 IOTA Stiftung.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
-
import { GeneralError, Guards, StringHelper } from "@twin.org/core";
|
|
3
|
+
import { GeneralError, Guards, HealthStatus, StringHelper } from "@twin.org/core";
|
|
4
4
|
import { FetchHelper, HttpMethod } from "@twin.org/web";
|
|
5
5
|
/**
|
|
6
6
|
* Class for performing identity operations on a universal resolver.
|
|
@@ -36,6 +36,43 @@ export class UniversalResolverConnector {
|
|
|
36
36
|
className() {
|
|
37
37
|
return UniversalResolverConnector.CLASS_NAME;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the health status of the component.
|
|
41
|
+
* @returns The health status of the component.
|
|
42
|
+
*/
|
|
43
|
+
async health() {
|
|
44
|
+
try {
|
|
45
|
+
const response = await FetchHelper.fetch(UniversalResolverConnector.CLASS_NAME, `${StringHelper.trimTrailingSlashes(this._resolverEndpoint)}/1.0/identifiers/did:iota:0`, HttpMethod.GET);
|
|
46
|
+
const body = await response.text();
|
|
47
|
+
if (!body.includes("invalid method id")) {
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
source: UniversalResolverConnector.CLASS_NAME,
|
|
51
|
+
status: HealthStatus.Error,
|
|
52
|
+
description: "healthDescription",
|
|
53
|
+
message: "resolverHealthCheckFailed"
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
source: UniversalResolverConnector.CLASS_NAME,
|
|
60
|
+
status: HealthStatus.Ok,
|
|
61
|
+
description: "healthDescription"
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
source: UniversalResolverConnector.CLASS_NAME,
|
|
69
|
+
status: HealthStatus.Error,
|
|
70
|
+
description: "healthDescription",
|
|
71
|
+
message: "resolverHealthCheckFailed"
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
39
76
|
/**
|
|
40
77
|
* Resolve a document from its id.
|
|
41
78
|
* @param documentId The id of the document to resolve.
|
|
@@ -1 +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;
|
|
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,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAIhG,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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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, HealthStatus, StringHelper, type IHealth } 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 * Returns the health status of the component.\n\t * @returns The health status of the component.\n\t */\n\tpublic async health(): Promise<IHealth[]> {\n\t\ttry {\n\t\t\tconst response = await FetchHelper.fetch(\n\t\t\t\tUniversalResolverConnector.CLASS_NAME,\n\t\t\t\t`${StringHelper.trimTrailingSlashes(this._resolverEndpoint)}/1.0/identifiers/did:iota:0`,\n\t\t\t\tHttpMethod.GET\n\t\t\t);\n\n\t\t\tconst body = await response.text();\n\n\t\t\tif (!body.includes(\"invalid method id\")) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: UniversalResolverConnector.CLASS_NAME,\n\t\t\t\t\t\tstatus: HealthStatus.Error,\n\t\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\t\tmessage: \"resolverHealthCheckFailed\"\n\t\t\t\t\t}\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: UniversalResolverConnector.CLASS_NAME,\n\t\t\t\t\tstatus: HealthStatus.Ok,\n\t\t\t\t\tdescription: \"healthDescription\"\n\t\t\t\t}\n\t\t\t];\n\t\t} catch {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tsource: UniversalResolverConnector.CLASS_NAME,\n\t\t\t\t\tstatus: HealthStatus.Error,\n\t\t\t\t\tdescription: \"healthDescription\",\n\t\t\t\t\tmessage: \"resolverHealthCheckFailed\"\n\t\t\t\t}\n\t\t\t];\n\t\t}\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,4 @@
|
|
|
1
|
+
import { type IHealth } from "@twin.org/core";
|
|
1
2
|
import type { IIdentityResolverConnector } from "@twin.org/identity-models";
|
|
2
3
|
import type { IDidDocument } from "@twin.org/standards-w3c-did";
|
|
3
4
|
import type { IUniversalResolverConnectorConstructorOptions } from "./models/IUniversalResolverConnectorConstructorOptions.js";
|
|
@@ -23,6 +24,11 @@ export declare class UniversalResolverConnector implements IIdentityResolverConn
|
|
|
23
24
|
* @returns The class name of the component.
|
|
24
25
|
*/
|
|
25
26
|
className(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the health status of the component.
|
|
29
|
+
* @returns The health status of the component.
|
|
30
|
+
*/
|
|
31
|
+
health(): Promise<IHealth[]>;
|
|
26
32
|
/**
|
|
27
33
|
* Resolve a document from its id.
|
|
28
34
|
* @param documentId The id of the document to resolve.
|
package/docs/changelog.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.0.3-next.
|
|
3
|
+
## [0.0.3-next.21](https://github.com/iotaledger/twin-identity/compare/identity-connector-universal-v0.0.3-next.20...identity-connector-universal-v0.0.3-next.21) (2026-05-07)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* health check ([#124](https://github.com/iotaledger/twin-identity/issues/124)) ([5a55bef](https://github.com/iotaledger/twin-identity/commit/5a55bef0c455f7a305822c96de6ffa19699edc6f))
|
|
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.20 to 0.0.3-next.21
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.20](https://github.com/iotaledger/twin-identity/compare/identity-connector-universal-v0.0.3-next.19...identity-connector-universal-v0.0.3-next.20) (2026-04-29)
|
|
4
18
|
|
|
5
19
|
|
|
6
20
|
### Miscellaneous Chores
|
|
@@ -14,7 +28,7 @@
|
|
|
14
28
|
* dependencies
|
|
15
29
|
* @twin.org/identity-models bumped from 0.0.3-next.19 to 0.0.3-next.20
|
|
16
30
|
|
|
17
|
-
## [0.0.3-next.19](https://github.com/
|
|
31
|
+
## [0.0.3-next.19](https://github.com/iotaledger/twin-identity/compare/identity-connector-universal-v0.0.3-next.18...identity-connector-universal-v0.0.3-next.19) (2026-04-29)
|
|
18
32
|
|
|
19
33
|
|
|
20
34
|
### Miscellaneous Chores
|
|
@@ -62,6 +62,24 @@ The class name of the component.
|
|
|
62
62
|
|
|
63
63
|
***
|
|
64
64
|
|
|
65
|
+
### health() {#health}
|
|
66
|
+
|
|
67
|
+
> **health**(): `Promise`\<`IHealth`[]\>
|
|
68
|
+
|
|
69
|
+
Returns the health status of the component.
|
|
70
|
+
|
|
71
|
+
#### Returns
|
|
72
|
+
|
|
73
|
+
`Promise`\<`IHealth`[]\>
|
|
74
|
+
|
|
75
|
+
The health status of the component.
|
|
76
|
+
|
|
77
|
+
#### Implementation of
|
|
78
|
+
|
|
79
|
+
`IIdentityResolverConnector.health`
|
|
80
|
+
|
|
81
|
+
***
|
|
82
|
+
|
|
65
83
|
### resolveDocument() {#resolvedocument}
|
|
66
84
|
|
|
67
85
|
> **resolveDocument**(`documentId`): `Promise`\<`IDidDocument`\>
|
package/locales/en.json
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
+
"health": {
|
|
3
|
+
"universalResolverConnector": {
|
|
4
|
+
"healthDescription": "Connectivity and availability of the universal resolver",
|
|
5
|
+
"resolverHealthCheckFailed": "Failed to check universal resolver health status"
|
|
6
|
+
}
|
|
7
|
+
},
|
|
2
8
|
"error": {
|
|
3
9
|
"universalResolverConnector": {
|
|
4
10
|
"resolveDocumentFailed": "Resolving the document failed \"{documentId}\""
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/identity-connector-universal",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.21",
|
|
4
4
|
"description": "Connector for resolving decentralised identifiers through the Universal Resolver ecosystem.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/iotaledger/identity.git",
|
|
8
8
|
"directory": "packages/identity-connector-universal"
|
|
9
9
|
},
|
|
10
10
|
"author": "martyn.janes@iota.org",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
|
-
"@twin.org/identity-models": "0.0.3-next.
|
|
18
|
+
"@twin.org/identity-models": "0.0.3-next.21",
|
|
19
19
|
"@twin.org/nameof": "next",
|
|
20
20
|
"@twin.org/standards-w3c-did": "next",
|
|
21
21
|
"@twin.org/web": "next"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"integration"
|
|
52
52
|
],
|
|
53
53
|
"bugs": {
|
|
54
|
-
"url": "git+https://github.com/
|
|
54
|
+
"url": "git+https://github.com/iotaledger/identity/issues"
|
|
55
55
|
},
|
|
56
56
|
"homepage": "https://twindev.org"
|
|
57
57
|
}
|