@twin.org/identity-service 0.0.3-next.9 → 0.9.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.
- package/README.md +2 -2
- package/dist/es/identityProfileRoutes.js +1 -2
- package/dist/es/identityProfileRoutes.js.map +1 -1
- package/dist/es/identityProfileService.js +3 -3
- package/dist/es/identityProfileService.js.map +1 -1
- package/dist/es/identityResolverRoutes.js +3 -4
- package/dist/es/identityResolverRoutes.js.map +1 -1
- package/dist/es/identityResolverService.js +3 -0
- package/dist/es/identityResolverService.js.map +1 -1
- package/dist/es/identityRoutes.js +284 -14
- package/dist/es/identityRoutes.js.map +1 -1
- package/dist/es/identityService.js +154 -31
- package/dist/es/identityService.js.map +1 -1
- package/dist/es/models/IIdentityResolverServiceConfig.js.map +1 -1
- package/dist/es/models/IIdentityServiceConfig.js.map +1 -1
- package/dist/es/models/IIdentityServiceConstructorOptions.js.map +1 -1
- package/dist/es/restEntryPoints.js +3 -0
- package/dist/es/restEntryPoints.js.map +1 -1
- package/dist/types/identityProfileService.d.ts +3 -3
- package/dist/types/identityResolverRoutes.d.ts +1 -1
- package/dist/types/identityResolverService.d.ts +1 -0
- package/dist/types/identityRoutes.d.ts +33 -1
- package/dist/types/identityService.d.ts +59 -12
- package/dist/types/models/IIdentityResolverServiceConfig.d.ts +1 -1
- package/dist/types/models/IIdentityServiceConfig.d.ts +1 -1
- package/dist/types/models/IIdentityServiceConstructorOptions.d.ts +4 -0
- package/dist/types/restEntryPoints.d.ts +3 -0
- package/docs/changelog.md +682 -101
- package/docs/examples.md +196 -1
- package/docs/open-api/spec.json +804 -482
- package/docs/reference/classes/IdentityProfileService.md +11 -11
- package/docs/reference/classes/IdentityResolverService.md +7 -3
- package/docs/reference/classes/IdentityService.md +188 -44
- package/docs/reference/functions/generateRestRoutesIdentityResolver.md +1 -1
- package/docs/reference/functions/identityAlsoKnownAsCreate.md +31 -0
- package/docs/reference/functions/identityAlsoKnownAsRemove.md +31 -0
- package/docs/reference/functions/identityVerifiableCredentialVerifyDocument.md +31 -0
- package/docs/reference/functions/identityVerifiablePresentationVerifyDocument.md +31 -0
- package/docs/reference/index.md +4 -0
- package/docs/reference/interfaces/IIdentityProfileServiceConstructorOptions.md +2 -2
- package/docs/reference/interfaces/IIdentityResolverServiceConfig.md +3 -3
- package/docs/reference/interfaces/IIdentityResolverServiceConstructorOptions.md +4 -4
- package/docs/reference/interfaces/IIdentityServiceConfig.md +3 -3
- package/docs/reference/interfaces/IIdentityServiceConstructorOptions.md +10 -2
- package/docs/reference/variables/restEntryPoints.md +2 -0
- package/locales/en.json +2 -0
- package/package.json +17 -16
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IHttpRequestContext, INoContentResponse, IRestRoute, ITag } from "@twin.org/api-models";
|
|
2
|
-
import { type IIdentityCreateRequest, type IIdentityCreateResponse, type IIdentityProofCreateRequest, type IIdentityProofCreateResponse, type IIdentityProofVerifyRequest, type IIdentityProofVerifyResponse, type IIdentityRemoveRequest, type IIdentityServiceCreateRequest, type IIdentityServiceCreateResponse, type IIdentityServiceRemoveRequest, type IIdentityVerifiableCredentialCreateRequest, type IIdentityVerifiableCredentialCreateResponse, type IIdentityVerifiableCredentialRevokeRequest, type IIdentityVerifiableCredentialUnrevokeRequest, type IIdentityVerifiableCredentialVerifyRequest, type IIdentityVerifiableCredentialVerifyResponse, type IIdentityVerifiablePresentationCreateRequest, type IIdentityVerifiablePresentationCreateResponse, type IIdentityVerifiablePresentationVerifyRequest, type IIdentityVerifiablePresentationVerifyResponse, type IIdentityVerificationMethodCreateRequest, type IIdentityVerificationMethodCreateResponse, type IIdentityVerificationMethodRemoveRequest } from "@twin.org/identity-models";
|
|
2
|
+
import { type IIdentityAlsoKnownAsCreateRequest, type IIdentityAlsoKnownAsRemoveRequest, type IIdentityCreateRequest, type IIdentityCreateResponse, type IIdentityProofCreateRequest, type IIdentityProofCreateResponse, type IIdentityProofVerifyRequest, type IIdentityProofVerifyResponse, type IIdentityRemoveRequest, type IIdentityServiceCreateRequest, type IIdentityServiceCreateResponse, type IIdentityServiceRemoveRequest, type IIdentityVerifiableCredentialCreateRequest, type IIdentityVerifiableCredentialCreateResponse, type IIdentityVerifiableCredentialRevokeRequest, type IIdentityVerifiableCredentialUnrevokeRequest, type IIdentityVerifiableCredentialVerifyRequest, type IIdentityVerifiableCredentialVerifyDocumentRequest, type IIdentityVerifiableCredentialVerifyResponse, type IIdentityVerifiablePresentationCreateRequest, type IIdentityVerifiablePresentationCreateResponse, type IIdentityVerifiablePresentationVerifyRequest, type IIdentityVerifiablePresentationVerifyResponse, type IIdentityVerificationMethodCreateRequest, type IIdentityVerificationMethodCreateResponse, type IIdentityVerificationMethodRemoveRequest, type IIdentityVerifiablePresentationVerifyDocumentRequest } from "@twin.org/identity-models";
|
|
3
3
|
/**
|
|
4
4
|
* The tag to associate with the routes.
|
|
5
5
|
*/
|
|
@@ -59,6 +59,22 @@ export declare function identityServiceCreate(httpRequestContext: IHttpRequestCo
|
|
|
59
59
|
* @returns The response object with additional http response properties.
|
|
60
60
|
*/
|
|
61
61
|
export declare function identityServiceRemove(httpRequestContext: IHttpRequestContext, componentName: string, request: IIdentityServiceRemoveRequest): Promise<INoContentResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Create an identity alias.
|
|
64
|
+
* @param httpRequestContext The request context for the API.
|
|
65
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
66
|
+
* @param request The request.
|
|
67
|
+
* @returns The response object with additional http response properties.
|
|
68
|
+
*/
|
|
69
|
+
export declare function identityAlsoKnownAsCreate(httpRequestContext: IHttpRequestContext, componentName: string, request: IIdentityAlsoKnownAsCreateRequest): Promise<INoContentResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* Remove an identity alias.
|
|
72
|
+
* @param httpRequestContext The request context for the API.
|
|
73
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
74
|
+
* @param request The request.
|
|
75
|
+
* @returns The response object with additional http response properties.
|
|
76
|
+
*/
|
|
77
|
+
export declare function identityAlsoKnownAsRemove(httpRequestContext: IHttpRequestContext, componentName: string, request: IIdentityAlsoKnownAsRemoveRequest): Promise<INoContentResponse>;
|
|
62
78
|
/**
|
|
63
79
|
* Create a verifiable credential.
|
|
64
80
|
* @param httpRequestContext The request context for the API.
|
|
@@ -75,6 +91,14 @@ export declare function identityVerifiableCredentialCreate(httpRequestContext: I
|
|
|
75
91
|
* @returns The response object with additional http response properties.
|
|
76
92
|
*/
|
|
77
93
|
export declare function identityVerifiableCredentialVerify(httpRequestContext: IHttpRequestContext, componentName: string, request: IIdentityVerifiableCredentialVerifyRequest): Promise<IIdentityVerifiableCredentialVerifyResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Verify a verifiable credential document.
|
|
96
|
+
* @param httpRequestContext The request context for the API.
|
|
97
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
98
|
+
* @param request The request.
|
|
99
|
+
* @returns The response object with additional http response properties.
|
|
100
|
+
*/
|
|
101
|
+
export declare function identityVerifiableCredentialVerifyDocument(httpRequestContext: IHttpRequestContext, componentName: string, request: IIdentityVerifiableCredentialVerifyDocumentRequest): Promise<IIdentityVerifiableCredentialVerifyResponse>;
|
|
78
102
|
/**
|
|
79
103
|
* Revoke a verifiable credential.
|
|
80
104
|
* @param httpRequestContext The request context for the API.
|
|
@@ -107,6 +131,14 @@ export declare function identityVerifiablePresentationCreate(httpRequestContext:
|
|
|
107
131
|
* @returns The response object with additional http response properties.
|
|
108
132
|
*/
|
|
109
133
|
export declare function identityVerifiablePresentationVerify(httpRequestContext: IHttpRequestContext, componentName: string, request: IIdentityVerifiablePresentationVerifyRequest): Promise<IIdentityVerifiablePresentationVerifyResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* Verify a verifiable presentation document.
|
|
136
|
+
* @param httpRequestContext The request context for the API.
|
|
137
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
138
|
+
* @param request The request.
|
|
139
|
+
* @returns The response object with additional http response properties.
|
|
140
|
+
*/
|
|
141
|
+
export declare function identityVerifiablePresentationVerifyDocument(httpRequestContext: IHttpRequestContext, componentName: string, request: IIdentityVerifiablePresentationVerifyDocumentRequest): Promise<IIdentityVerifiablePresentationVerifyResponse>;
|
|
110
142
|
/**
|
|
111
143
|
* Create an identity proof.
|
|
112
144
|
* @param httpRequestContext The request context for the API.
|
|
@@ -13,6 +13,7 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
13
13
|
/**
|
|
14
14
|
* Create a new instance of IdentityService.
|
|
15
15
|
* @param options The options for the service.
|
|
16
|
+
* @throws GeneralError if no connectors are registered.
|
|
16
17
|
*/
|
|
17
18
|
constructor(options?: IIdentityServiceConstructorOptions);
|
|
18
19
|
/**
|
|
@@ -20,6 +21,11 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
20
21
|
* @returns The class name of the component.
|
|
21
22
|
*/
|
|
22
23
|
className(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Register all identity metrics with the telemetry component.
|
|
26
|
+
* @returns A promise that resolves when all metrics have been registered.
|
|
27
|
+
*/
|
|
28
|
+
start(): Promise<void>;
|
|
23
29
|
/**
|
|
24
30
|
* Create a new identity.
|
|
25
31
|
* @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.
|
|
@@ -31,7 +37,7 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
31
37
|
* Remove an identity.
|
|
32
38
|
* @param identity The id of the document to remove.
|
|
33
39
|
* @param controller The controller of the identity who can make changes.
|
|
34
|
-
* @returns
|
|
40
|
+
* @returns A promise that resolves when the identity has been removed.
|
|
35
41
|
*/
|
|
36
42
|
identityRemove(identity: string, controller?: string): Promise<void>;
|
|
37
43
|
/**
|
|
@@ -49,7 +55,7 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
49
55
|
* Remove a verification method from the document.
|
|
50
56
|
* @param verificationMethodId The id of the verification method.
|
|
51
57
|
* @param controller The controller of the identity who can make changes.
|
|
52
|
-
* @returns
|
|
58
|
+
* @returns A promise that resolves when the verification method has been removed.
|
|
53
59
|
* @throws NotFoundError if the id can not be resolved.
|
|
54
60
|
* @throws NotSupportedError if the platform does not support multiple revocable keys.
|
|
55
61
|
*/
|
|
@@ -69,10 +75,32 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
69
75
|
* Remove a service from the document.
|
|
70
76
|
* @param serviceId The id of the service.
|
|
71
77
|
* @param controller The controller of the identity who can make changes.
|
|
72
|
-
* @returns
|
|
78
|
+
* @returns A promise that resolves when the service has been removed.
|
|
73
79
|
* @throws NotFoundError if the id can not be resolved.
|
|
74
80
|
*/
|
|
75
81
|
serviceRemove(serviceId: string, controller?: string): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Add an alias to the alsoKnownAs property on the document.
|
|
84
|
+
* If the alias is already present the operation is a no-op.
|
|
85
|
+
* @param documentId The id of the document to update.
|
|
86
|
+
* @param alias The alias to add. Must be a Url or Urn (typically another DID).
|
|
87
|
+
* @param controller The controller of the identity who can make changes.
|
|
88
|
+
* @returns A promise that resolves when the alias has been added.
|
|
89
|
+
* @throws GeneralError if the alias is not a Url or Urn.
|
|
90
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
91
|
+
*/
|
|
92
|
+
alsoKnownAsAdd(documentId: string, alias: string, controller?: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Remove an alias from the alsoKnownAs property on the document.
|
|
95
|
+
* If the alias is not present the operation is a no-op.
|
|
96
|
+
* @param documentId The id of the document to update.
|
|
97
|
+
* @param alias The alias to remove. Must be a Url or Urn.
|
|
98
|
+
* @param controller The controller of the identity who can make changes.
|
|
99
|
+
* @returns A promise that resolves when the alias has been removed.
|
|
100
|
+
* @throws GeneralError if the alias is not a Url or Urn.
|
|
101
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
102
|
+
*/
|
|
103
|
+
alsoKnownAsRemove(documentId: string, alias: string, controller?: string): Promise<void>;
|
|
76
104
|
/**
|
|
77
105
|
* Create a verifiable credential for a verification method.
|
|
78
106
|
* @param verificationMethodId The verification method id to use.
|
|
@@ -81,6 +109,8 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
81
109
|
* @param options Additional options for creating the verifiable credential.
|
|
82
110
|
* @param options.revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
|
|
83
111
|
* @param options.expirationDate The date the verifiable credential is valid until.
|
|
112
|
+
* @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable credential in jwt format.
|
|
113
|
+
* @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable credential in jwt format.
|
|
84
114
|
* @param controller The controller of the identity who can make changes.
|
|
85
115
|
* @returns The created verifiable credential and its token.
|
|
86
116
|
* @throws NotFoundError if the id can not be resolved.
|
|
@@ -88,25 +118,31 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
88
118
|
verifiableCredentialCreate(verificationMethodId: string, id: string | undefined, subject: IJsonLdNodeObject, options?: {
|
|
89
119
|
revocationIndex?: number;
|
|
90
120
|
expirationDate?: Date;
|
|
121
|
+
jwtHeaderFields?: {
|
|
122
|
+
[id: string]: string;
|
|
123
|
+
};
|
|
124
|
+
jwtPayloadFields?: {
|
|
125
|
+
[id: string]: string;
|
|
126
|
+
};
|
|
91
127
|
}, controller?: string): Promise<{
|
|
92
128
|
verifiableCredential: IDidVerifiableCredential;
|
|
93
129
|
jwt: string;
|
|
94
130
|
}>;
|
|
95
131
|
/**
|
|
96
132
|
* Verify a verifiable credential is valid.
|
|
97
|
-
* @param
|
|
133
|
+
* @param credential The credential to verify.
|
|
98
134
|
* @returns The credential stored in the jwt and the revocation status.
|
|
99
135
|
*/
|
|
100
|
-
verifiableCredentialVerify(
|
|
136
|
+
verifiableCredentialVerify(credential: string | IDidVerifiableCredential): Promise<{
|
|
101
137
|
revoked: boolean;
|
|
102
138
|
verifiableCredential?: IDidVerifiableCredential;
|
|
103
139
|
}>;
|
|
104
140
|
/**
|
|
105
141
|
* Revoke verifiable credential.
|
|
106
142
|
* @param issuerIdentity The id of the document to update the revocation list for.
|
|
107
|
-
* @param credentialIndex The revocation bitmap index revoke.
|
|
143
|
+
* @param credentialIndex The revocation bitmap index to revoke.
|
|
108
144
|
* @param controller The controller of the identity who can make changes.
|
|
109
|
-
* @returns
|
|
145
|
+
* @returns A promise that resolves when the credential has been revoked.
|
|
110
146
|
*/
|
|
111
147
|
verifiableCredentialRevoke(issuerIdentity: string, credentialIndex: number, controller?: string): Promise<void>;
|
|
112
148
|
/**
|
|
@@ -114,7 +150,7 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
114
150
|
* @param issuerIdentity The id of the document to update the revocation list for.
|
|
115
151
|
* @param credentialIndex The revocation bitmap index to un revoke.
|
|
116
152
|
* @param controller The controller of the identity who can make changes.
|
|
117
|
-
* @returns
|
|
153
|
+
* @returns A promise that resolves when the credential has been unrevoked.
|
|
118
154
|
*/
|
|
119
155
|
verifiableCredentialUnrevoke(issuerIdentity: string, credentialIndex: number, controller?: string): Promise<void>;
|
|
120
156
|
/**
|
|
@@ -124,21 +160,32 @@ export declare class IdentityService implements IIdentityComponent {
|
|
|
124
160
|
* @param contexts The contexts for the data stored in the verifiable credential.
|
|
125
161
|
* @param types The types for the data stored in the verifiable credential.
|
|
126
162
|
* @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
|
|
127
|
-
* @param
|
|
163
|
+
* @param options Additional options for creating the verifiable presentation.
|
|
164
|
+
* @param options.expirationDate The date the verifiable presentation is valid until.
|
|
165
|
+
* @param options.jwtHeaderFields Additional fields to include in the JWT header when creating the verifiable presentation in jwt format.
|
|
166
|
+
* @param options.jwtPayloadFields Additional fields to include in the JWT payload when creating the verifiable presentation in jwt format.
|
|
128
167
|
* @param controller The controller of the identity who can make changes.
|
|
129
168
|
* @returns The created verifiable presentation and its token.
|
|
130
169
|
* @throws NotFoundError if the id can not be resolved.
|
|
131
170
|
*/
|
|
132
|
-
verifiablePresentationCreate(verificationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[],
|
|
171
|
+
verifiablePresentationCreate(verificationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], options?: {
|
|
172
|
+
expirationDate?: Date;
|
|
173
|
+
jwtHeaderFields?: {
|
|
174
|
+
[id: string]: string;
|
|
175
|
+
};
|
|
176
|
+
jwtPayloadFields?: {
|
|
177
|
+
[id: string]: string;
|
|
178
|
+
};
|
|
179
|
+
}, controller?: string): Promise<{
|
|
133
180
|
verifiablePresentation: IDidVerifiablePresentation;
|
|
134
181
|
jwt: string;
|
|
135
182
|
}>;
|
|
136
183
|
/**
|
|
137
184
|
* Verify a verifiable presentation is valid.
|
|
138
|
-
* @param
|
|
185
|
+
* @param presentation The presentation to verify.
|
|
139
186
|
* @returns The presentation stored in the jwt and the revocation status.
|
|
140
187
|
*/
|
|
141
|
-
verifiablePresentationVerify(
|
|
188
|
+
verifiablePresentationVerify(presentation: string | IDidVerifiablePresentation): Promise<{
|
|
142
189
|
revoked: boolean;
|
|
143
190
|
verifiablePresentation?: IDidVerifiablePresentation;
|
|
144
191
|
issuers?: IDidDocument[];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface IIdentityResolverServiceConfig {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* The default connector namespace to use for identity resolution. If not provided, the first registered connector is used.
|
|
7
7
|
*/
|
|
8
8
|
defaultNamespace?: string;
|
|
9
9
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface IIdentityServiceConfig {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* The default connector namespace to use for identity operations. If not provided, the first registered connector is used.
|
|
7
7
|
*/
|
|
8
8
|
defaultNamespace?: string;
|
|
9
9
|
}
|
|
@@ -7,4 +7,8 @@ export interface IIdentityServiceConstructorOptions {
|
|
|
7
7
|
* The configuration for the identity service.
|
|
8
8
|
*/
|
|
9
9
|
config?: IIdentityServiceConfig;
|
|
10
|
+
/**
|
|
11
|
+
* The component type for the optional telemetry component used for event metrics.
|
|
12
|
+
*/
|
|
13
|
+
telemetryComponentType?: string;
|
|
10
14
|
}
|