@sudoplatform/sudo-user 11.0.0 → 12.0.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.
- package/cjs/client/apiClient.d.ts +25 -0
- package/cjs/client/apiClient.js +149 -0
- package/cjs/client/apiClient.js.map +1 -0
- package/cjs/core/api-key-names.d.ts +8 -0
- package/cjs/core/api-key-names.js +12 -0
- package/cjs/core/api-key-names.js.map +1 -0
- package/cjs/core/auth-store.d.ts +51 -0
- package/cjs/core/auth-store.js +92 -0
- package/cjs/core/auth-store.js.map +1 -0
- package/cjs/core/crypto.d.ts +3 -0
- package/cjs/core/crypto.js +3 -0
- package/cjs/core/crypto.js.map +1 -0
- package/cjs/core/key-manager.d.ts +31 -0
- package/cjs/core/key-manager.js +113 -0
- package/cjs/core/key-manager.js.map +1 -0
- package/cjs/core/protected-store.d.ts +5 -0
- package/cjs/core/protected-store.js +3 -0
- package/cjs/core/protected-store.js.map +1 -0
- package/cjs/core/publisher.d.ts +6 -0
- package/cjs/core/publisher.js +3 -0
- package/cjs/core/publisher.js.map +1 -0
- package/cjs/core/sdk-config.d.ts +52 -0
- package/cjs/core/sdk-config.js +61 -0
- package/cjs/core/sdk-config.js.map +1 -0
- package/cjs/core/subscriber.d.ts +3 -0
- package/cjs/core/subscriber.js +3 -0
- package/cjs/core/subscriber.js.map +1 -0
- package/cjs/gen/graphql-types.d.ts +101 -0
- package/cjs/gen/graphql-types.js +105 -0
- package/cjs/gen/graphql-types.js.map +1 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +13 -0
- package/cjs/index.js.map +1 -0
- package/cjs/runtimes/browser/browser-crypto.d.ts +2 -0
- package/cjs/runtimes/browser/browser-crypto.js +10 -0
- package/cjs/runtimes/browser/browser-crypto.js.map +1 -0
- package/cjs/runtimes/node/node-crypto.d.ts +2 -0
- package/cjs/runtimes/node/node-crypto.js +9 -0
- package/cjs/runtimes/node/node-crypto.js.map +1 -0
- package/cjs/sdk.d.ts +1 -0
- package/cjs/sdk.js +9 -0
- package/cjs/sdk.js.map +1 -0
- package/cjs/user/auth-provider.d.ts +97 -0
- package/cjs/user/auth-provider.js +116 -0
- package/cjs/user/auth-provider.js.map +1 -0
- package/cjs/user/auth.d.ts +64 -0
- package/cjs/user/auth.js +136 -0
- package/cjs/user/auth.js.map +1 -0
- package/cjs/user/error.d.ts +18 -0
- package/cjs/user/error.js +33 -0
- package/cjs/user/error.js.map +1 -0
- package/cjs/user/identity-provider.d.ts +73 -0
- package/cjs/user/identity-provider.js +245 -0
- package/cjs/user/identity-provider.js.map +1 -0
- package/cjs/user/user-client-interface.d.ts +168 -0
- package/cjs/user/user-client-interface.js +3 -0
- package/cjs/user/user-client-interface.js.map +1 -0
- package/cjs/user/user-client.d.ts +82 -0
- package/cjs/user/user-client.js +440 -0
- package/cjs/user/user-client.js.map +1 -0
- package/cjs/user/user-key-names.d.ts +6 -0
- package/cjs/user/user-key-names.js +10 -0
- package/cjs/user/user-key-names.js.map +1 -0
- package/cjs/utils/resolvable-promise.d.ts +9 -0
- package/cjs/utils/resolvable-promise.js +20 -0
- package/cjs/utils/resolvable-promise.js.map +1 -0
- package/docs/classes/AlreadyRegisteredError.html +4 -4
- package/docs/classes/IdentityServiceConfigNotFoundError.html +4 -4
- package/lib/client/apiClient.js +135 -180
- package/lib/client/apiClient.js.map +1 -0
- package/lib/core/api-key-names.js +8 -14
- package/lib/core/api-key-names.js.map +1 -0
- package/lib/core/auth-store.js +82 -138
- package/lib/core/auth-store.js.map +1 -0
- package/lib/core/crypto.js +2 -5
- package/lib/core/crypto.js.map +1 -0
- package/lib/core/key-manager.js +98 -148
- package/lib/core/key-manager.js.map +1 -0
- package/lib/core/protected-store.d.ts +5 -0
- package/lib/core/protected-store.js +2 -5
- package/lib/core/protected-store.js.map +1 -0
- package/lib/core/publisher.js +2 -5
- package/lib/core/publisher.js.map +1 -0
- package/lib/core/sdk-config.js +56 -56
- package/lib/core/sdk-config.js.map +1 -0
- package/lib/core/subscriber.js +2 -5
- package/lib/core/subscriber.js.map +1 -0
- package/lib/gen/graphql-types.js +96 -135
- package/lib/gen/graphql-types.js.map +1 -0
- package/lib/index.js +6 -67
- package/lib/index.js.map +1 -0
- package/lib/runtimes/browser/browser-crypto.d.ts +2 -0
- package/lib/runtimes/browser/browser-crypto.js +6 -14
- package/lib/runtimes/browser/browser-crypto.js.map +1 -0
- package/lib/runtimes/node/node-crypto.js +5 -11
- package/lib/runtimes/node/node-crypto.js.map +1 -0
- package/lib/sdk.js +6 -18
- package/lib/sdk.js.map +1 -0
- package/lib/user/auth-provider.js +81 -131
- package/lib/user/auth-provider.js.map +1 -0
- package/lib/user/auth.js +127 -179
- package/lib/user/auth.js.map +1 -0
- package/lib/user/error.js +15 -33
- package/lib/user/error.js.map +1 -0
- package/lib/user/identity-provider.js +232 -261
- package/lib/user/identity-provider.js.map +1 -0
- package/lib/user/user-client-interface.js +2 -5
- package/lib/user/user-client-interface.js.map +1 -0
- package/lib/user/user-client.js +423 -510
- package/lib/user/user-client.js.map +1 -0
- package/lib/user/user-key-names.js +6 -12
- package/lib/user/user-key-names.js.map +1 -0
- package/lib/utils/resolvable-promise.js +13 -19
- package/lib/utils/resolvable-promise.js.map +1 -0
- package/package.json +22 -21
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RegisterFederatedIdInput } from '../gen/graphql-types';
|
|
2
|
+
import { Logger } from '@sudoplatform/sudo-common';
|
|
3
|
+
import { SudoUserClient } from '../user/user-client-interface';
|
|
4
|
+
/**
|
|
5
|
+
* AppSync wrapper to use to invoke Identity Service APIs.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ApiClient {
|
|
8
|
+
private client;
|
|
9
|
+
private region;
|
|
10
|
+
private graphqlUrl;
|
|
11
|
+
private sudoUserClient;
|
|
12
|
+
private logger;
|
|
13
|
+
constructor(region: string, graphqlUrl: string, sudoUserClient: SudoUserClient, logger: Logger);
|
|
14
|
+
deregister(): Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
globalSignOut(): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
registerFederatedId(input: RegisterFederatedIdInput): Promise<{
|
|
21
|
+
identityId: string;
|
|
22
|
+
}>;
|
|
23
|
+
reset(): void;
|
|
24
|
+
private graphQLErrorsToClientError;
|
|
25
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiClient = void 0;
|
|
4
|
+
const aws_appsync_1 = require("aws-appsync");
|
|
5
|
+
const graphql_types_1 = require("../gen/graphql-types");
|
|
6
|
+
const sudo_common_1 = require("@sudoplatform/sudo-common");
|
|
7
|
+
/**
|
|
8
|
+
* AppSync wrapper to use to invoke Identity Service APIs.
|
|
9
|
+
*/
|
|
10
|
+
class ApiClient {
|
|
11
|
+
constructor(region, graphqlUrl, sudoUserClient, logger) {
|
|
12
|
+
this.region = region;
|
|
13
|
+
this.graphqlUrl = graphqlUrl;
|
|
14
|
+
this.sudoUserClient = sudoUserClient;
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
this.client = new aws_appsync_1.AWSAppSyncClient({
|
|
17
|
+
url: graphqlUrl,
|
|
18
|
+
region: region,
|
|
19
|
+
auth: {
|
|
20
|
+
type: aws_appsync_1.AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
|
|
21
|
+
jwtToken: async () => await sudoUserClient.getLatestAuthToken(),
|
|
22
|
+
},
|
|
23
|
+
disableOffline: true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async deregister() {
|
|
27
|
+
if (!(await this.sudoUserClient.isSignedIn())) {
|
|
28
|
+
throw new sudo_common_1.NotSignedInError();
|
|
29
|
+
}
|
|
30
|
+
let result;
|
|
31
|
+
try {
|
|
32
|
+
result = await this.client.mutate({
|
|
33
|
+
mutation: graphql_types_1.DeregisterDocument,
|
|
34
|
+
fetchPolicy: 'no-cache',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
const apolloError = err;
|
|
39
|
+
const error = apolloError.graphQLErrors?.[0];
|
|
40
|
+
if (error) {
|
|
41
|
+
throw this.graphQLErrorsToClientError(error);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw new sudo_common_1.UnknownGraphQLError(err);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const error = result.errors?.[0];
|
|
48
|
+
if (error) {
|
|
49
|
+
throw this.graphQLErrorsToClientError(error);
|
|
50
|
+
}
|
|
51
|
+
if (result.data) {
|
|
52
|
+
return { success: result.data.deregister?.success ? true : false };
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new sudo_common_1.FatalError('deregister did not return any result.');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async globalSignOut() {
|
|
59
|
+
if (!(await this.sudoUserClient.isSignedIn())) {
|
|
60
|
+
throw new sudo_common_1.NotSignedInError();
|
|
61
|
+
}
|
|
62
|
+
let result;
|
|
63
|
+
try {
|
|
64
|
+
result = await this.client.mutate({
|
|
65
|
+
mutation: graphql_types_1.GlobalSignOutDocument,
|
|
66
|
+
fetchPolicy: 'no-cache',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
const apolloError = err;
|
|
71
|
+
const error = apolloError.graphQLErrors?.[0];
|
|
72
|
+
if (error) {
|
|
73
|
+
throw this.graphQLErrorsToClientError(error);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw new sudo_common_1.UnknownGraphQLError(err);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const error = result.errors?.[0];
|
|
80
|
+
if (error) {
|
|
81
|
+
throw this.graphQLErrorsToClientError(error);
|
|
82
|
+
}
|
|
83
|
+
if (result.data) {
|
|
84
|
+
return { success: result.data.globalSignOut?.success ? true : false };
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw new sudo_common_1.FatalError('globalSignOut did not return any result.');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async registerFederatedId(input) {
|
|
91
|
+
let result;
|
|
92
|
+
try {
|
|
93
|
+
result = await this.client.mutate({
|
|
94
|
+
mutation: graphql_types_1.RegisterFederatedIdDocument,
|
|
95
|
+
variables: { input },
|
|
96
|
+
fetchPolicy: 'no-cache',
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
const apolloError = err;
|
|
101
|
+
const error = apolloError.graphQLErrors?.[0];
|
|
102
|
+
if (error) {
|
|
103
|
+
throw this.graphQLErrorsToClientError(error);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
throw new sudo_common_1.UnknownGraphQLError(err);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const error = result.errors?.[0];
|
|
110
|
+
if (error) {
|
|
111
|
+
throw this.graphQLErrorsToClientError(error);
|
|
112
|
+
}
|
|
113
|
+
const identityId = result.data?.registerFederatedId?.identityId;
|
|
114
|
+
if (identityId) {
|
|
115
|
+
return {
|
|
116
|
+
identityId,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw new sudo_common_1.FatalError('registerFederatedId did not return expected result.');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
reset() {
|
|
124
|
+
this.client.clearStore();
|
|
125
|
+
this.client = new aws_appsync_1.AWSAppSyncClient({
|
|
126
|
+
url: this.graphqlUrl,
|
|
127
|
+
region: this.region,
|
|
128
|
+
auth: {
|
|
129
|
+
type: aws_appsync_1.AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
|
|
130
|
+
jwtToken: async () => await this.sudoUserClient.getLatestAuthToken(),
|
|
131
|
+
},
|
|
132
|
+
disableOffline: true,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
graphQLErrorsToClientError(error) {
|
|
136
|
+
this.logger.error('GraphQL call failed.', { error });
|
|
137
|
+
if (error.errorType === 'sudoplatform.ServiceError') {
|
|
138
|
+
return new sudo_common_1.ServiceError(error.message);
|
|
139
|
+
}
|
|
140
|
+
else if (error.errorType === 'sudoplatform.identity.TokenValidationError') {
|
|
141
|
+
return new sudo_common_1.NotAuthorizedError();
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return new sudo_common_1.UnknownGraphQLError(error);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.ApiClient = ApiClient;
|
|
149
|
+
//# sourceMappingURL=apiClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../src/client/apiClient.ts"],"names":[],"mappings":";;;AACA,6CAAyD;AACzD,wDAQ6B;AAC7B,2DAQkC;AAIlC;;GAEG;AACH,MAAa,SAAS;IAOpB,YACE,MAAc,EACd,UAAkB,EAClB,cAA8B,EAC9B,MAAc;QAEd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,IAAI,CAAC,MAAM,GAAG,IAAI,8BAAgB,CAAC;YACjC,GAAG,EAAE,UAAU;YACf,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE,uBAAS,CAAC,yBAAyB;gBACzC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,cAAc,CAAC,kBAAkB,EAAE;aAChE;YACD,cAAc,EAAE,IAAI;SACrB,CAAC,CAAA;IACJ,CAAC;IAEM,KAAK,CAAC,UAAU;QACrB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,EAAE;YAC7C,MAAM,IAAI,8BAAgB,EAAE,CA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: true });
|
|
3
|
+
exports.apiKeyNames = void 0;
|
|
4
|
+
exports.apiKeyNames = {
|
|
5
|
+
idToken: 'idToken',
|
|
6
|
+
accessToken: 'accessToken',
|
|
7
|
+
refreshToken: 'refreshToken',
|
|
8
|
+
tokenExpiry: 'tokenExpiry',
|
|
9
|
+
refreshTokenExpiry: 'refreshTokenExpiry',
|
|
10
|
+
userId: 'LastAuthUser',
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=api-key-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key-names.js","sourceRoot":"","sources":["../../src/core/api-key-names.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;IAC1B,kBAAkB,EAAE,oBAAoB;IACxC,MAAM,EAAE,cAAc;CACvB,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Publisher } from './publisher';
|
|
2
|
+
import { Subscriber } from './subscriber';
|
|
3
|
+
export interface Store {
|
|
4
|
+
setItem(keyId: string, value: string): Promise<void>;
|
|
5
|
+
getItem(keyId: string): string | undefined;
|
|
6
|
+
removeItem(keyId: string): void;
|
|
7
|
+
reset(): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Stores authentication details such as tokens and username
|
|
11
|
+
*/
|
|
12
|
+
export declare class AuthenticationStore implements Store, Publisher {
|
|
13
|
+
#private;
|
|
14
|
+
subscribers: Subscriber[];
|
|
15
|
+
/** Adds a secret into private _secrets object */
|
|
16
|
+
private addSecret;
|
|
17
|
+
/**
|
|
18
|
+
* Adds a string value into authentication store
|
|
19
|
+
*/
|
|
20
|
+
setItem(keyId: string, value: string): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns a string value from authentication store
|
|
23
|
+
*/
|
|
24
|
+
getItem(keyId: string): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Removes a secret
|
|
27
|
+
*/
|
|
28
|
+
removeItem(keyId: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Clears all secrets
|
|
31
|
+
*/
|
|
32
|
+
reset(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Register a subscriber to be notified when items are added
|
|
35
|
+
*
|
|
36
|
+
* @param subscriber a subscriber to be notified when items are added
|
|
37
|
+
*/
|
|
38
|
+
subscribe(subscriber: Subscriber): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Remove a subscriber from the list of subscribers
|
|
41
|
+
*
|
|
42
|
+
* @param subscriber the subscriber to be removed
|
|
43
|
+
*/
|
|
44
|
+
unsubscribe(subscriber: Subscriber): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Notify all subscribers that a change event was triggered for a specific item
|
|
47
|
+
*
|
|
48
|
+
* @param itemName the name of the item that changed
|
|
49
|
+
*/
|
|
50
|
+
notifySubscribers(itemName: string): Promise<void>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _AuthenticationStore_secrets;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AuthenticationStore = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const JWT = tslib_1.__importStar(require("jsonwebtoken"));
|
|
7
|
+
/**
|
|
8
|
+
* Stores authentication details such as tokens and username
|
|
9
|
+
*/
|
|
10
|
+
class AuthenticationStore {
|
|
11
|
+
constructor() {
|
|
12
|
+
/** Do not expose these directly */
|
|
13
|
+
// eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
|
|
14
|
+
_AuthenticationStore_secrets.set(this, {});
|
|
15
|
+
this.subscribers = [];
|
|
16
|
+
}
|
|
17
|
+
/** Adds a secret into private _secrets object */
|
|
18
|
+
async addSecret(keyId, secret) {
|
|
19
|
+
const key = keyId.substr(keyId.lastIndexOf('.') + 1);
|
|
20
|
+
tslib_1.__classPrivateFieldGet(this, _AuthenticationStore_secrets, "f")[key] = secret;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Adds a string value into authentication store
|
|
24
|
+
*/
|
|
25
|
+
async setItem(keyId, value) {
|
|
26
|
+
const key = keyId.substr(keyId.lastIndexOf('.') + 1);
|
|
27
|
+
if (key === 'idToken') {
|
|
28
|
+
// Store the token expiry
|
|
29
|
+
const decoded = JWT.decode(value, { complete: true });
|
|
30
|
+
if (decoded) {
|
|
31
|
+
const tokenExpiry = decoded.payload['exp'];
|
|
32
|
+
await this.addSecret('tokenExpiry', {
|
|
33
|
+
type: 'string',
|
|
34
|
+
value: tokenExpiry,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
await this.addSecret(key, { type: 'string', value });
|
|
39
|
+
await this.notifySubscribers(key);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns a string value from authentication store
|
|
43
|
+
*/
|
|
44
|
+
getItem(keyId) {
|
|
45
|
+
const key = keyId.substr(keyId.lastIndexOf('.') + 1);
|
|
46
|
+
const secret = tslib_1.__classPrivateFieldGet(this, _AuthenticationStore_secrets, "f")[key];
|
|
47
|
+
return secret?.type === 'string' ? secret.value : undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Removes a secret
|
|
51
|
+
*/
|
|
52
|
+
removeItem(keyId) {
|
|
53
|
+
const key = keyId.substr(keyId.lastIndexOf('.') + 1);
|
|
54
|
+
delete tslib_1.__classPrivateFieldGet(this, _AuthenticationStore_secrets, "f")[key];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Clears all secrets
|
|
58
|
+
*/
|
|
59
|
+
reset() {
|
|
60
|
+
tslib_1.__classPrivateFieldSet(this, _AuthenticationStore_secrets, {}, "f");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Register a subscriber to be notified when items are added
|
|
64
|
+
*
|
|
65
|
+
* @param subscriber a subscriber to be notified when items are added
|
|
66
|
+
*/
|
|
67
|
+
async subscribe(subscriber) {
|
|
68
|
+
this.subscribers.push(subscriber);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Remove a subscriber from the list of subscribers
|
|
72
|
+
*
|
|
73
|
+
* @param subscriber the subscriber to be removed
|
|
74
|
+
*/
|
|
75
|
+
async unsubscribe(subscriber) {
|
|
76
|
+
const index = this.subscribers.indexOf(subscriber);
|
|
77
|
+
this.subscribers.splice(index, 1);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Notify all subscribers that a change event was triggered for a specific item
|
|
81
|
+
*
|
|
82
|
+
* @param itemName the name of the item that changed
|
|
83
|
+
*/
|
|
84
|
+
async notifySubscribers(itemName) {
|
|
85
|
+
for (const subscriber of this.subscribers) {
|
|
86
|
+
subscriber.update(itemName);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.AuthenticationStore = AuthenticationStore;
|
|
91
|
+
_AuthenticationStore_secrets = new WeakMap();
|
|
92
|
+
//# sourceMappingURL=auth-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-store.js","sourceRoot":"","sources":["../../src/core/auth-store.ts"],"names":[],"mappings":";;;;;AAEA,0DAAmC;AAcnC;;GAEG;AACH,MAAa,mBAAmB;IAAhC;QACE,mCAAmC;QACnC,0EAA0E;QAC1E,uCAAmC,EAAE,EAAA;QACrC,gBAAW,GAAiB,EAAE,CAAA;IAiFhC,CAAC;IA/EC,iDAAiD;IACzC,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,MAAc;QACnD,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QACpD,+BAAA,IAAI,oCAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAA;IAC7B,CAAC;IAED;;OAEG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AC,CAAA;IAC3B,CAAC;IAED;;OAEG;IACI,KAAK;QACV,+BAAA,IAAI,gCAAY,EAAE,MAAA,CAAA;IACpB,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,SAAS,CAAC,UAAsB;QAC3C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,WAAW,CAAC,UAAsB;QAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QAClD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB,CAAC,QAAgB;QACtC,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE;YACzC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;SAC5B;IACH,CAAC;CACF;AArFD,kDAqFC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/core/crypto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PublicKeyFormat, SudoKeyManager } from '@sudoplatform/sudo-common';
|
|
2
|
+
export interface PublicKey {
|
|
3
|
+
keyId: string;
|
|
4
|
+
algorithm: string;
|
|
5
|
+
symmetricAlgorithm: string;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
keyFormat: PublicKeyFormat;
|
|
8
|
+
}
|
|
9
|
+
export interface KeyPair {
|
|
10
|
+
publicKey: unknown;
|
|
11
|
+
publicKeyFormat: PublicKeyFormat;
|
|
12
|
+
privateKey: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface KeyManager {
|
|
15
|
+
addString(keyId: string, value: string): Promise<void>;
|
|
16
|
+
getString(keyId: string): Promise<string | undefined>;
|
|
17
|
+
generateKeyPair(keyId?: string): Promise<string>;
|
|
18
|
+
exportPublicKey(keyId: string): Promise<PublicKey>;
|
|
19
|
+
signJWT(keyId: string, payload: Record<string, unknown>): Promise<string>;
|
|
20
|
+
reset(): Promise<void>;
|
|
21
|
+
removeItem(keyId: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Key Manager
|
|
25
|
+
*/
|
|
26
|
+
export declare class KeyManager implements KeyManager {
|
|
27
|
+
private sudoKeyManager;
|
|
28
|
+
private static Constants;
|
|
29
|
+
constructor(sudoKeyManager: SudoKeyManager);
|
|
30
|
+
retrieveKeyPair(keyId: string): Promise<KeyPair>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyManager = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sudo_common_1 = require("@sudoplatform/sudo-common");
|
|
6
|
+
const jsonwebtoken_1 = tslib_1.__importDefault(require("jsonwebtoken"));
|
|
7
|
+
const uuid = tslib_1.__importStar(require("uuid"));
|
|
8
|
+
const node_crypto_1 = require("../runtimes/node/node-crypto");
|
|
9
|
+
/**
|
|
10
|
+
* Key Manager
|
|
11
|
+
*/
|
|
12
|
+
class KeyManager {
|
|
13
|
+
constructor(sudoKeyManager) {
|
|
14
|
+
this.sudoKeyManager = sudoKeyManager;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Adds a string value into key manager
|
|
18
|
+
*/
|
|
19
|
+
async addString(keyId, value) {
|
|
20
|
+
await this.sudoKeyManager.addPassword(new TextEncoder().encode(value).buffer, keyId);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns a string value from key manager
|
|
24
|
+
*/
|
|
25
|
+
async getString(keyId) {
|
|
26
|
+
const passwordBuffer = await this.sudoKeyManager.getPassword(keyId);
|
|
27
|
+
if (!passwordBuffer) {
|
|
28
|
+
throw new sudo_common_1.KeyNotFoundError(`No key found for keyId: ${keyId}`);
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
return new TextDecoder('utf-8', { fatal: true }).decode(passwordBuffer);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
const error = err;
|
|
35
|
+
throw new sudo_common_1.DecodeError(error.message);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generates and adds a new key pair into key manager
|
|
40
|
+
* @returns Key ID
|
|
41
|
+
*/
|
|
42
|
+
async generateKeyPair(keyId = uuid.v4()) {
|
|
43
|
+
await this.sudoKeyManager.generateKeyPair(keyId);
|
|
44
|
+
return keyId;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Removes a secret
|
|
48
|
+
*/
|
|
49
|
+
async removeItem(id) {
|
|
50
|
+
await this.sudoKeyManager.deletePassword(id);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Signs a JWT with a signing key that is in key manager
|
|
54
|
+
* @returns JWT data
|
|
55
|
+
*/
|
|
56
|
+
async signJWT(keyId, payload) {
|
|
57
|
+
const privateKeyBits = await this.sudoKeyManager.getPrivateKey(keyId);
|
|
58
|
+
if (!privateKeyBits) {
|
|
59
|
+
throw new sudo_common_1.KeyNotFoundError(`No key found for keyId: ${keyId}`);
|
|
60
|
+
}
|
|
61
|
+
const base64encoded = node_crypto_1.cryptoProvider.arrayBufferToBase64(privateKeyBits);
|
|
62
|
+
//PEM encode private key
|
|
63
|
+
const signingKey = `-----BEGIN PRIVATE KEY-----\n${base64encoded}\n-----END PRIVATE KEY-----`;
|
|
64
|
+
return jsonwebtoken_1.default.sign(payload, signingKey, {
|
|
65
|
+
algorithm: 'RS256',
|
|
66
|
+
keyid: keyId,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Exports public key in a format for use with SudoPlatform
|
|
71
|
+
*/
|
|
72
|
+
async exportPublicKey(keyId) {
|
|
73
|
+
const publicKey = await this.sudoKeyManager.getPublicKey(keyId);
|
|
74
|
+
if (!publicKey) {
|
|
75
|
+
throw new Error('Invalid key ID for exportPublicKey');
|
|
76
|
+
}
|
|
77
|
+
const base64encoded = node_crypto_1.cryptoProvider.arrayBufferToBase64(publicKey.keyData);
|
|
78
|
+
return {
|
|
79
|
+
keyId,
|
|
80
|
+
algorithm: KeyManager.Constants.publicKeyAlgorithm,
|
|
81
|
+
symmetricAlgorithm: KeyManager.Constants.symmetricAlgorithm,
|
|
82
|
+
publicKey: base64encoded,
|
|
83
|
+
keyFormat: publicKey.keyFormat,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Clears all private keys from memory
|
|
88
|
+
*/
|
|
89
|
+
async reset() {
|
|
90
|
+
await this.sudoKeyManager.removeAllKeys();
|
|
91
|
+
}
|
|
92
|
+
async retrieveKeyPair(keyId) {
|
|
93
|
+
const publicKey = await this.sudoKeyManager.getPublicKey(keyId);
|
|
94
|
+
if (!publicKey) {
|
|
95
|
+
throw new sudo_common_1.KeyNotFoundError(`Public key not found for keyId: ${keyId}`);
|
|
96
|
+
}
|
|
97
|
+
const privateKey = await this.sudoKeyManager.getPrivateKey(keyId);
|
|
98
|
+
if (!privateKey) {
|
|
99
|
+
throw new sudo_common_1.KeyNotFoundError(`Private key not found for keyId: ${keyId}`);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
publicKey: node_crypto_1.cryptoProvider.arrayBufferToBase64(publicKey.keyData),
|
|
103
|
+
publicKeyFormat: publicKey.keyFormat,
|
|
104
|
+
privateKey: node_crypto_1.cryptoProvider.arrayBufferToBase64(privateKey),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.KeyManager = KeyManager;
|
|
109
|
+
KeyManager.Constants = {
|
|
110
|
+
publicKeyAlgorithm: 'RSA',
|
|
111
|
+
symmetricAlgorithm: 'AES/256',
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=key-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-manager.js","sourceRoot":"","sources":["../../src/core/key-manager.ts"],"names":[],"mappings":";;;;AAAA,2DAKkC;AAClC,wEAA8B;AAC9B,mDAA4B;AAC5B,8DAA6D;AA0B7D;;GAEG;AACH,MAAa,UAAU;IAMrB,YAAoB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAEtD;;OAEG;IACI,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,KAAa;QACjD,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CACnC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EACtC,KAAK,CACN,CAAA;IACH,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,SAAS,CAAC,KAAa;QAClC,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QACnE,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,IAAI,8BAAgB,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAA;SAC/D;QACD,IAAI;YACF,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;SACxE;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,KAAK,GAAG,GAAY,CAAA;YAC1B,MAAM,IAAI,yBAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;SACrC;IACH,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,eAAe,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE;QAC5C,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;QAChD,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU,CA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AAK,CAAC,eAAe,CAAC,KAAa;QACxC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QAC/D,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,IAAI,8BAAgB,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAA;SACvE;QACD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QACjE,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,8BAAgB,CAAC,oCAAoC,KAAK,EAAE,CAAC,CAAA;SACxE;QAED,OAAO;YACL,SAAS,EAAE,4BAAc,CAAC,mBAAmB,CAAC,SAAS,CAAC,OAAO,CAAC;YAChE,eAAe,EAAE,SAAS,CAAC,SAAS;YACpC,UAAU,EAAE,4BAAc,CAAC,mBAAmB,CAAC,UAAyB,CAAC;SAC1E,CAAA;IACH,CAAC;;AAnHH,gCAoHC;AAnHgB,oBAAS,GAAG;IACzB,kBAAkB,EAAE,KAAK;IACzB,kBAAkB,EAAE,SAAS;CAC9B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protected-store.js","sourceRoot":"","sources":["../../src/core/protected-store.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publisher.js","sourceRoot":"","sources":["../../src/core/publisher.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as t from 'io-ts';
|
|
2
|
+
export declare const IdentityServiceConfigCodec: t.IntersectionC<[t.TypeC<{
|
|
3
|
+
region: t.StringC;
|
|
4
|
+
poolId: t.StringC;
|
|
5
|
+
clientId: t.StringC;
|
|
6
|
+
identityPoolId: t.StringC;
|
|
7
|
+
apiUrl: t.StringC;
|
|
8
|
+
apiKey: t.StringC;
|
|
9
|
+
bucket: t.StringC;
|
|
10
|
+
transientBucket: t.StringC;
|
|
11
|
+
registrationMethods: t.ArrayC<t.StringC>;
|
|
12
|
+
}>, t.PartialC<{
|
|
13
|
+
refreshTokenLifetime: t.NumberC;
|
|
14
|
+
}>]>;
|
|
15
|
+
export declare const FederatedSignInConfigCodec: t.IntersectionC<[t.TypeC<{
|
|
16
|
+
appClientId: t.StringC;
|
|
17
|
+
signInRedirectUri: t.StringC;
|
|
18
|
+
signOutRedirectUri: t.StringC;
|
|
19
|
+
webDomain: t.StringC;
|
|
20
|
+
}>, t.PartialC<{
|
|
21
|
+
identityProvider: t.StringC;
|
|
22
|
+
refreshTokenLifetime: t.NumberC;
|
|
23
|
+
}>]>;
|
|
24
|
+
export declare const Config: t.IntersectionC<[t.TypeC<{
|
|
25
|
+
identityService: t.IntersectionC<[t.TypeC<{
|
|
26
|
+
region: t.StringC;
|
|
27
|
+
poolId: t.StringC;
|
|
28
|
+
clientId: t.StringC;
|
|
29
|
+
identityPoolId: t.StringC;
|
|
30
|
+
apiUrl: t.StringC;
|
|
31
|
+
apiKey: t.StringC;
|
|
32
|
+
bucket: t.StringC;
|
|
33
|
+
transientBucket: t.StringC;
|
|
34
|
+
registrationMethods: t.ArrayC<t.StringC>;
|
|
35
|
+
}>, t.PartialC<{
|
|
36
|
+
refreshTokenLifetime: t.NumberC;
|
|
37
|
+
}>]>;
|
|
38
|
+
}>, t.PartialC<{
|
|
39
|
+
federatedSignIn: t.IntersectionC<[t.TypeC<{
|
|
40
|
+
appClientId: t.StringC;
|
|
41
|
+
signInRedirectUri: t.StringC;
|
|
42
|
+
signOutRedirectUri: t.StringC;
|
|
43
|
+
webDomain: t.StringC;
|
|
44
|
+
}>, t.PartialC<{
|
|
45
|
+
identityProvider: t.StringC;
|
|
46
|
+
refreshTokenLifetime: t.NumberC;
|
|
47
|
+
}>]>;
|
|
48
|
+
}>]>;
|
|
49
|
+
export declare type Config = t.TypeOf<typeof Config>;
|
|
50
|
+
export declare type IdentityServiceConfig = t.TypeOf<typeof IdentityServiceConfigCodec>;
|
|
51
|
+
export declare type FederatedSignInConfig = t.TypeOf<typeof FederatedSignInConfigCodec>;
|
|
52
|
+
export declare function getIdentityServiceConfig(): Config;
|