@twin.org/identity-models 0.0.1-next.19 → 0.0.1-next.20
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/cjs/index.cjs +40 -22
- package/dist/esm/index.mjs +41 -23
- package/dist/types/index.d.ts +11 -11
- package/dist/types/models/IIdentityComponent.d.ts +130 -3
- package/dist/types/models/api/{IIdentityResolveRequest.d.ts → identity/IIdentityResolveRequest.d.ts} +1 -1
- package/dist/types/utils/jwtHelper.d.ts +22 -0
- package/docs/changelog.md +1 -1
- package/docs/reference/classes/DocumentHelper.md +3 -1
- package/docs/reference/classes/JwtHelper.md +59 -0
- package/docs/reference/index.md +3 -7
- package/docs/reference/interfaces/IIdentityComponent.md +485 -3
- package/docs/reference/interfaces/IIdentityConnector.md +128 -84
- package/docs/reference/interfaces/IIdentityProfileComponent.md +52 -44
- package/docs/reference/interfaces/IIdentityProfileConnector.md +52 -40
- package/docs/reference/interfaces/IIdentityResolveRequest.md +1 -1
- package/docs/reference/variables/IdentityProfileConnectorFactory.md +1 -1
- package/locales/en.json +5 -4
- package/package.json +1 -1
- package/dist/types/models/identityRole.d.ts +0 -21
- package/docs/reference/type-aliases/IdentityRole.md +0 -5
- package/docs/reference/variables/IdentityRole.md +0 -25
- /package/dist/types/models/api/{IIdentityResolveResponse.d.ts → identity/IIdentityResolveResponse.d.ts} +0 -0
- /package/dist/types/models/api/{IIdentityProfileCreateRequest.d.ts → profile/IIdentityProfileCreateRequest.d.ts} +0 -0
- /package/dist/types/models/api/{IIdentityProfileGetPublicRequest.d.ts → profile/IIdentityProfileGetPublicRequest.d.ts} +0 -0
- /package/dist/types/models/api/{IIdentityProfileGetPublicResponse.d.ts → profile/IIdentityProfileGetPublicResponse.d.ts} +0 -0
- /package/dist/types/models/api/{IIdentityProfileGetRequest.d.ts → profile/IIdentityProfileGetRequest.d.ts} +0 -0
- /package/dist/types/models/api/{IIdentityProfileGetResponse.d.ts → profile/IIdentityProfileGetResponse.d.ts} +0 -0
- /package/dist/types/models/api/{IIdentityProfileListRequest.d.ts → profile/IIdentityProfileListRequest.d.ts} +0 -0
- /package/dist/types/models/api/{IIdentityProfileListResponse.d.ts → profile/IIdentityProfileListResponse.d.ts} +0 -0
- /package/dist/types/models/api/{IIdentityProfileUpdateRequest.d.ts → profile/IIdentityProfileUpdateRequest.d.ts} +0 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@twin.org/core');
|
|
4
|
+
var web = require('@twin.org/web');
|
|
4
5
|
|
|
5
6
|
// Copyright 2024 IOTA Stiftung.
|
|
6
7
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -18,27 +19,6 @@ const IdentityConnectorFactory = core.Factory.createFactory("identity-connector"
|
|
|
18
19
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
19
20
|
const IdentityProfileConnectorFactory = core.Factory.createFactory("identity-profile-connector");
|
|
20
21
|
|
|
21
|
-
// Copyright 2024 IOTA Stiftung.
|
|
22
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
23
|
-
/**
|
|
24
|
-
* The roles that an identity can have.
|
|
25
|
-
*/
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
-
const IdentityRole = {
|
|
28
|
-
/**
|
|
29
|
-
* Node.
|
|
30
|
-
*/
|
|
31
|
-
Node: "node",
|
|
32
|
-
/**
|
|
33
|
-
* Organization.
|
|
34
|
-
*/
|
|
35
|
-
Organization: "organization",
|
|
36
|
-
/**
|
|
37
|
-
* User.
|
|
38
|
-
*/
|
|
39
|
-
User: "user"
|
|
40
|
-
};
|
|
41
|
-
|
|
42
22
|
// Copyright 2024 IOTA Stiftung.
|
|
43
23
|
// SPDX-License-Identifier: Apache-2.0.
|
|
44
24
|
/**
|
|
@@ -65,7 +45,45 @@ class DocumentHelper {
|
|
|
65
45
|
}
|
|
66
46
|
}
|
|
67
47
|
|
|
48
|
+
// Copyright 2024 IOTA Stiftung.
|
|
49
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
50
|
+
/**
|
|
51
|
+
* Helper methods for JSON Web Tokens.
|
|
52
|
+
*/
|
|
53
|
+
class JwtHelper {
|
|
54
|
+
/**
|
|
55
|
+
* Runtime name for the class.
|
|
56
|
+
*/
|
|
57
|
+
static CLASS_NAME = "JwtHelper";
|
|
58
|
+
/**
|
|
59
|
+
* Parse the token and check that the properties are valid.
|
|
60
|
+
* @param jwt The token top validate.
|
|
61
|
+
* @param paramsToCheck Parameters to check they exist.
|
|
62
|
+
* @returns The token components.
|
|
63
|
+
* @throws Error if the token is invalid.
|
|
64
|
+
*/
|
|
65
|
+
static async parse(jwt, paramsToCheck) {
|
|
66
|
+
const jwtDecoded = await web.Jwt.decode(jwt);
|
|
67
|
+
const jwtHeader = jwtDecoded.header;
|
|
68
|
+
const jwtPayload = jwtDecoded.payload;
|
|
69
|
+
const jwtSignature = jwtDecoded.signature;
|
|
70
|
+
if (core.Is.undefined(jwtHeader) || core.Is.undefined(jwtPayload) || core.Is.undefined(jwtSignature)) {
|
|
71
|
+
throw new core.GeneralError(JwtHelper.CLASS_NAME, "jwtDecodeFailed");
|
|
72
|
+
}
|
|
73
|
+
if (core.Is.arrayValue(paramsToCheck)) {
|
|
74
|
+
for (const param of paramsToCheck) {
|
|
75
|
+
if (!core.Is.stringValue(jwtPayload[param])) {
|
|
76
|
+
throw new core.GeneralError(JwtHelper.CLASS_NAME, "jwtPayloadMissingParam", {
|
|
77
|
+
param
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return jwtDecoded;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
68
86
|
exports.DocumentHelper = DocumentHelper;
|
|
69
87
|
exports.IdentityConnectorFactory = IdentityConnectorFactory;
|
|
70
88
|
exports.IdentityProfileConnectorFactory = IdentityProfileConnectorFactory;
|
|
71
|
-
exports.
|
|
89
|
+
exports.JwtHelper = JwtHelper;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Factory, Is } from '@twin.org/core';
|
|
1
|
+
import { Factory, Is, GeneralError } from '@twin.org/core';
|
|
2
|
+
import { Jwt } from '@twin.org/web';
|
|
2
3
|
|
|
3
4
|
// Copyright 2024 IOTA Stiftung.
|
|
4
5
|
// SPDX-License-Identifier: Apache-2.0.
|
|
@@ -16,27 +17,6 @@ const IdentityConnectorFactory = Factory.createFactory("identity-connector");
|
|
|
16
17
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
17
18
|
const IdentityProfileConnectorFactory = Factory.createFactory("identity-profile-connector");
|
|
18
19
|
|
|
19
|
-
// Copyright 2024 IOTA Stiftung.
|
|
20
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
21
|
-
/**
|
|
22
|
-
* The roles that an identity can have.
|
|
23
|
-
*/
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
|
-
const IdentityRole = {
|
|
26
|
-
/**
|
|
27
|
-
* Node.
|
|
28
|
-
*/
|
|
29
|
-
Node: "node",
|
|
30
|
-
/**
|
|
31
|
-
* Organization.
|
|
32
|
-
*/
|
|
33
|
-
Organization: "organization",
|
|
34
|
-
/**
|
|
35
|
-
* User.
|
|
36
|
-
*/
|
|
37
|
-
User: "user"
|
|
38
|
-
};
|
|
39
|
-
|
|
40
20
|
// Copyright 2024 IOTA Stiftung.
|
|
41
21
|
// SPDX-License-Identifier: Apache-2.0.
|
|
42
22
|
/**
|
|
@@ -63,4 +43,42 @@ class DocumentHelper {
|
|
|
63
43
|
}
|
|
64
44
|
}
|
|
65
45
|
|
|
66
|
-
|
|
46
|
+
// Copyright 2024 IOTA Stiftung.
|
|
47
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
48
|
+
/**
|
|
49
|
+
* Helper methods for JSON Web Tokens.
|
|
50
|
+
*/
|
|
51
|
+
class JwtHelper {
|
|
52
|
+
/**
|
|
53
|
+
* Runtime name for the class.
|
|
54
|
+
*/
|
|
55
|
+
static CLASS_NAME = "JwtHelper";
|
|
56
|
+
/**
|
|
57
|
+
* Parse the token and check that the properties are valid.
|
|
58
|
+
* @param jwt The token top validate.
|
|
59
|
+
* @param paramsToCheck Parameters to check they exist.
|
|
60
|
+
* @returns The token components.
|
|
61
|
+
* @throws Error if the token is invalid.
|
|
62
|
+
*/
|
|
63
|
+
static async parse(jwt, paramsToCheck) {
|
|
64
|
+
const jwtDecoded = await Jwt.decode(jwt);
|
|
65
|
+
const jwtHeader = jwtDecoded.header;
|
|
66
|
+
const jwtPayload = jwtDecoded.payload;
|
|
67
|
+
const jwtSignature = jwtDecoded.signature;
|
|
68
|
+
if (Is.undefined(jwtHeader) || Is.undefined(jwtPayload) || Is.undefined(jwtSignature)) {
|
|
69
|
+
throw new GeneralError(JwtHelper.CLASS_NAME, "jwtDecodeFailed");
|
|
70
|
+
}
|
|
71
|
+
if (Is.arrayValue(paramsToCheck)) {
|
|
72
|
+
for (const param of paramsToCheck) {
|
|
73
|
+
if (!Is.stringValue(jwtPayload[param])) {
|
|
74
|
+
throw new GeneralError(JwtHelper.CLASS_NAME, "jwtPayloadMissingParam", {
|
|
75
|
+
param
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return jwtDecoded;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { DocumentHelper, IdentityConnectorFactory, IdentityProfileConnectorFactory, JwtHelper };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
export * from "./factories/identityConnectorFactory";
|
|
2
2
|
export * from "./factories/identityProfileConnectorFactory";
|
|
3
|
-
export * from "./models/api/
|
|
4
|
-
export * from "./models/api/
|
|
5
|
-
export * from "./models/api/
|
|
6
|
-
export * from "./models/api/
|
|
7
|
-
export * from "./models/api/
|
|
8
|
-
export * from "./models/api/
|
|
9
|
-
export * from "./models/api/
|
|
10
|
-
export * from "./models/api/
|
|
11
|
-
export * from "./models/api/
|
|
12
|
-
export * from "./models/api/
|
|
13
|
-
export * from "./models/identityRole";
|
|
3
|
+
export * from "./models/api/identity/IIdentityResolveRequest";
|
|
4
|
+
export * from "./models/api/identity/IIdentityResolveResponse";
|
|
5
|
+
export * from "./models/api/profile/IIdentityProfileCreateRequest";
|
|
6
|
+
export * from "./models/api/profile/IIdentityProfileGetPublicRequest";
|
|
7
|
+
export * from "./models/api/profile/IIdentityProfileGetPublicResponse";
|
|
8
|
+
export * from "./models/api/profile/IIdentityProfileGetRequest";
|
|
9
|
+
export * from "./models/api/profile/IIdentityProfileGetResponse";
|
|
10
|
+
export * from "./models/api/profile/IIdentityProfileListRequest";
|
|
11
|
+
export * from "./models/api/profile/IIdentityProfileListResponse";
|
|
12
|
+
export * from "./models/api/profile/IIdentityProfileUpdateRequest";
|
|
14
13
|
export * from "./models/IIdentityComponent";
|
|
15
14
|
export * from "./models/IIdentityConnector";
|
|
16
15
|
export * from "./models/IIdentityProfileComponent";
|
|
17
16
|
export * from "./models/IIdentityProfileConnector";
|
|
18
17
|
export * from "./utils/documentHelper";
|
|
18
|
+
export * from "./utils/jwtHelper";
|
|
@@ -1,13 +1,140 @@
|
|
|
1
1
|
import type { IComponent } from "@twin.org/core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IJsonLdContextDefinitionRoot, IJsonLdNodeObject } from "@twin.org/data-json-ld";
|
|
3
|
+
import type { DidVerificationMethodType, IDidDocument, IDidDocumentVerificationMethod, IDidProof, IDidService, IDidVerifiableCredential, IDidVerifiablePresentation } from "@twin.org/standards-w3c-did";
|
|
3
4
|
/**
|
|
4
5
|
* Interface describing a contract which provides identity operations.
|
|
5
6
|
*/
|
|
6
7
|
export interface IIdentityComponent extends IComponent {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new identity.
|
|
10
|
+
* @param controller The controller of the identity who can make changes.
|
|
11
|
+
* @param namespace The namespace of the connector to use for the identity, defaults to service configured namespace.
|
|
12
|
+
* @returns The created identity document.
|
|
13
|
+
*/
|
|
14
|
+
identityCreate(controller: string, namespace?: string): Promise<IDidDocument>;
|
|
7
15
|
/**
|
|
8
16
|
* Resolve an identity.
|
|
9
|
-
* @param
|
|
17
|
+
* @param identity The id of the document to resolve.
|
|
10
18
|
* @returns The resolved document.
|
|
11
19
|
*/
|
|
12
|
-
|
|
20
|
+
identityResolve(identity: string): Promise<IDidDocument>;
|
|
21
|
+
/**
|
|
22
|
+
* Add a verification method to the document in JSON Web key Format.
|
|
23
|
+
* @param controller The controller of the identity who can make changes.
|
|
24
|
+
* @param identity The id of the document to add the verification method to.
|
|
25
|
+
* @param verificationMethodType The type of the verification method to add.
|
|
26
|
+
* @param verificationMethodId The id of the verification method, if undefined uses the kid of the generated JWK.
|
|
27
|
+
* @returns The verification method.
|
|
28
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
29
|
+
* @throws NotSupportedError if the platform does not support multiple keys.
|
|
30
|
+
*/
|
|
31
|
+
verificationMethodCreate(controller: string, identity: string, verificationMethodType: DidVerificationMethodType, verificationMethodId?: string): Promise<IDidDocumentVerificationMethod>;
|
|
32
|
+
/**
|
|
33
|
+
* Remove a verification method from the document.
|
|
34
|
+
* @param controller The controller of the identity who can make changes.
|
|
35
|
+
* @param verificationMethodId The id of the verification method.
|
|
36
|
+
* @returns Nothing.
|
|
37
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
38
|
+
* @throws NotSupportedError if the platform does not support multiple revocable keys.
|
|
39
|
+
*/
|
|
40
|
+
verificationMethodRemove(controller: string, verificationMethodId: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Add a service to the document.
|
|
43
|
+
* @param controller The controller of the identity who can make changes.
|
|
44
|
+
* @param identity The id of the document to add the service to.
|
|
45
|
+
* @param serviceId The id of the service.
|
|
46
|
+
* @param serviceType The type of the service.
|
|
47
|
+
* @param serviceEndpoint The endpoint for the service.
|
|
48
|
+
* @returns The service.
|
|
49
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
50
|
+
*/
|
|
51
|
+
serviceCreate(controller: string, identity: string, serviceId: string, serviceType: string, serviceEndpoint: string): Promise<IDidService>;
|
|
52
|
+
/**
|
|
53
|
+
* Remove a service from the document.
|
|
54
|
+
* @param controller The controller of the identity who can make changes.
|
|
55
|
+
* @param serviceId The id of the service.
|
|
56
|
+
* @returns Nothing.
|
|
57
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
58
|
+
*/
|
|
59
|
+
serviceRemove(controller: string, serviceId: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Create a verifiable credential for a verification method.
|
|
62
|
+
* @param controller The controller of the identity who can make changes.
|
|
63
|
+
* @param verificationMethodId The verification method id to use.
|
|
64
|
+
* @param id The id of the credential.
|
|
65
|
+
* @param credential The credential to store in the verifiable credential.
|
|
66
|
+
* @param revocationIndex The bitmap revocation index of the credential, if undefined will not have revocation status.
|
|
67
|
+
* @returns The created verifiable credential and its token.
|
|
68
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
69
|
+
*/
|
|
70
|
+
verifiableCredentialCreate(controller: string, verificationMethodId: string, id: string | undefined, credential: IJsonLdNodeObject, revocationIndex?: number): Promise<{
|
|
71
|
+
verifiableCredential: IDidVerifiableCredential;
|
|
72
|
+
jwt: string;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Verify a verifiable credential is valid.
|
|
76
|
+
* @param credentialJwt The credential to verify.
|
|
77
|
+
* @returns The credential stored in the jwt and the revocation status.
|
|
78
|
+
*/
|
|
79
|
+
verifiableCredentialVerify(credentialJwt: string): Promise<{
|
|
80
|
+
revoked: boolean;
|
|
81
|
+
verifiableCredential?: IDidVerifiableCredential;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Revoke verifiable credential.
|
|
85
|
+
* @param controller The controller of the identity who can make changes.
|
|
86
|
+
* @param issuerId The id of the document to update the revocation list for.
|
|
87
|
+
* @param credentialIndex The revocation bitmap index revoke.
|
|
88
|
+
* @returns Nothing.
|
|
89
|
+
*/
|
|
90
|
+
verifiableCredentialRevoke(controller: string, issuerId: string, credentialIndex: number): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Unrevoke verifiable credential.
|
|
93
|
+
* @param controller The controller of the identity who can make changes.
|
|
94
|
+
* @param issuerId The id of the document to update the revocation list for.
|
|
95
|
+
* @param credentialIndex The revocation bitmap index to un revoke.
|
|
96
|
+
* @returns Nothing.
|
|
97
|
+
*/
|
|
98
|
+
verifiableCredentialUnrevoke(controller: string, issuerId: string, credentialIndex: number): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Create a verifiable presentation from the supplied verifiable credentials.
|
|
101
|
+
* @param controller The controller of the identity who can make changes.
|
|
102
|
+
* @param presentationMethodId The method to associate with the presentation.
|
|
103
|
+
* @param presentationId The id of the presentation.
|
|
104
|
+
* @param contexts The contexts for the data stored in the verifiable credential.
|
|
105
|
+
* @param types The types for the data stored in the verifiable credential.
|
|
106
|
+
* @param verifiableCredentials The credentials to use for creating the presentation in jwt format.
|
|
107
|
+
* @param expiresInMinutes The time in minutes for the presentation to expire.
|
|
108
|
+
* @returns The created verifiable presentation and its token.
|
|
109
|
+
* @throws NotFoundError if the id can not be resolved.
|
|
110
|
+
*/
|
|
111
|
+
verifiablePresentationCreate(controller: string, presentationMethodId: string, presentationId: string | undefined, contexts: IJsonLdContextDefinitionRoot | undefined, types: string | string[] | undefined, verifiableCredentials: (string | IDidVerifiableCredential)[], expiresInMinutes?: number): Promise<{
|
|
112
|
+
verifiablePresentation: IDidVerifiablePresentation;
|
|
113
|
+
jwt: string;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Verify a verifiable presentation is valid.
|
|
117
|
+
* @param presentationJwt The presentation to verify.
|
|
118
|
+
* @returns The presentation stored in the jwt and the revocation status.
|
|
119
|
+
*/
|
|
120
|
+
verifiablePresentationVerify(presentationJwt: string): Promise<{
|
|
121
|
+
revoked: boolean;
|
|
122
|
+
verifiablePresentation?: IDidVerifiablePresentation;
|
|
123
|
+
issuers?: IDidDocument[];
|
|
124
|
+
}>;
|
|
125
|
+
/**
|
|
126
|
+
* Create a proof for arbitrary data with the specified verification method.
|
|
127
|
+
* @param controller The controller of the identity who can make changes.
|
|
128
|
+
* @param verificationMethodId The verification method id to use.
|
|
129
|
+
* @param bytes The data bytes to sign.
|
|
130
|
+
* @returns The proof.
|
|
131
|
+
*/
|
|
132
|
+
proofCreate(controller: string, verificationMethodId: string, bytes: Uint8Array): Promise<IDidProof>;
|
|
133
|
+
/**
|
|
134
|
+
* Verify proof for arbitrary data with the specified verification method.
|
|
135
|
+
* @param bytes The data bytes to verify.
|
|
136
|
+
* @param proof The proof to verify.
|
|
137
|
+
* @returns True if the proof is verified.
|
|
138
|
+
*/
|
|
139
|
+
proofVerify(bytes: Uint8Array, proof: IDidProof): Promise<boolean>;
|
|
13
140
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type IJwtHeader, type IJwtPayload } from "@twin.org/web";
|
|
2
|
+
/**
|
|
3
|
+
* Helper methods for JSON Web Tokens.
|
|
4
|
+
*/
|
|
5
|
+
export declare class JwtHelper {
|
|
6
|
+
/**
|
|
7
|
+
* Runtime name for the class.
|
|
8
|
+
*/
|
|
9
|
+
static readonly CLASS_NAME: string;
|
|
10
|
+
/**
|
|
11
|
+
* Parse the token and check that the properties are valid.
|
|
12
|
+
* @param jwt The token top validate.
|
|
13
|
+
* @param paramsToCheck Parameters to check they exist.
|
|
14
|
+
* @returns The token components.
|
|
15
|
+
* @throws Error if the token is invalid.
|
|
16
|
+
*/
|
|
17
|
+
static parse<U extends IJwtHeader, T extends IJwtPayload>(jwt: string, paramsToCheck?: string[]): Promise<{
|
|
18
|
+
header?: U;
|
|
19
|
+
payload?: T;
|
|
20
|
+
signature?: Uint8Array;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
package/docs/changelog.md
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Class: JwtHelper
|
|
2
|
+
|
|
3
|
+
Helper methods for JSON Web Tokens.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new JwtHelper()
|
|
8
|
+
|
|
9
|
+
> **new JwtHelper**(): [`JwtHelper`](JwtHelper.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`JwtHelper`](JwtHelper.md)
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### CLASS\_NAME
|
|
18
|
+
|
|
19
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
20
|
+
|
|
21
|
+
Runtime name for the class.
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### parse()
|
|
26
|
+
|
|
27
|
+
> `static` **parse**\<`U`, `T`\>(`jwt`, `paramsToCheck`?): `Promise`\<\{ `header`: `U`; `payload`: `T`; `signature`: `Uint8Array`; \}\>
|
|
28
|
+
|
|
29
|
+
Parse the token and check that the properties are valid.
|
|
30
|
+
|
|
31
|
+
#### Type Parameters
|
|
32
|
+
|
|
33
|
+
• **U** *extends* `IJwtHeader`
|
|
34
|
+
|
|
35
|
+
• **T** *extends* `IJwtPayload`
|
|
36
|
+
|
|
37
|
+
#### Parameters
|
|
38
|
+
|
|
39
|
+
##### jwt
|
|
40
|
+
|
|
41
|
+
`string`
|
|
42
|
+
|
|
43
|
+
The token top validate.
|
|
44
|
+
|
|
45
|
+
##### paramsToCheck?
|
|
46
|
+
|
|
47
|
+
`string`[]
|
|
48
|
+
|
|
49
|
+
Parameters to check they exist.
|
|
50
|
+
|
|
51
|
+
#### Returns
|
|
52
|
+
|
|
53
|
+
`Promise`\<\{ `header`: `U`; `payload`: `T`; `signature`: `Uint8Array`; \}\>
|
|
54
|
+
|
|
55
|
+
The token components.
|
|
56
|
+
|
|
57
|
+
#### Throws
|
|
58
|
+
|
|
59
|
+
Error if the token is invalid.
|
package/docs/reference/index.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
## Classes
|
|
4
4
|
|
|
5
5
|
- [DocumentHelper](classes/DocumentHelper.md)
|
|
6
|
+
- [JwtHelper](classes/JwtHelper.md)
|
|
6
7
|
|
|
7
8
|
## Interfaces
|
|
8
9
|
|
|
@@ -10,6 +11,8 @@
|
|
|
10
11
|
- [IIdentityConnector](interfaces/IIdentityConnector.md)
|
|
11
12
|
- [IIdentityProfileComponent](interfaces/IIdentityProfileComponent.md)
|
|
12
13
|
- [IIdentityProfileConnector](interfaces/IIdentityProfileConnector.md)
|
|
14
|
+
- [IIdentityResolveRequest](interfaces/IIdentityResolveRequest.md)
|
|
15
|
+
- [IIdentityResolveResponse](interfaces/IIdentityResolveResponse.md)
|
|
13
16
|
- [IIdentityProfileCreateRequest](interfaces/IIdentityProfileCreateRequest.md)
|
|
14
17
|
- [IIdentityProfileGetPublicRequest](interfaces/IIdentityProfileGetPublicRequest.md)
|
|
15
18
|
- [IIdentityProfileGetPublicResponse](interfaces/IIdentityProfileGetPublicResponse.md)
|
|
@@ -18,15 +21,8 @@
|
|
|
18
21
|
- [IIdentityProfileListRequest](interfaces/IIdentityProfileListRequest.md)
|
|
19
22
|
- [IIdentityProfileListResponse](interfaces/IIdentityProfileListResponse.md)
|
|
20
23
|
- [IIdentityProfileUpdateRequest](interfaces/IIdentityProfileUpdateRequest.md)
|
|
21
|
-
- [IIdentityResolveRequest](interfaces/IIdentityResolveRequest.md)
|
|
22
|
-
- [IIdentityResolveResponse](interfaces/IIdentityResolveResponse.md)
|
|
23
|
-
|
|
24
|
-
## Type Aliases
|
|
25
|
-
|
|
26
|
-
- [IdentityRole](type-aliases/IdentityRole.md)
|
|
27
24
|
|
|
28
25
|
## Variables
|
|
29
26
|
|
|
30
27
|
- [IdentityConnectorFactory](variables/IdentityConnectorFactory.md)
|
|
31
28
|
- [IdentityProfileConnectorFactory](variables/IdentityProfileConnectorFactory.md)
|
|
32
|
-
- [IdentityRole](variables/IdentityRole.md)
|