@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.
Files changed (115) hide show
  1. package/cjs/client/apiClient.d.ts +25 -0
  2. package/cjs/client/apiClient.js +149 -0
  3. package/cjs/client/apiClient.js.map +1 -0
  4. package/cjs/core/api-key-names.d.ts +8 -0
  5. package/cjs/core/api-key-names.js +12 -0
  6. package/cjs/core/api-key-names.js.map +1 -0
  7. package/cjs/core/auth-store.d.ts +51 -0
  8. package/cjs/core/auth-store.js +92 -0
  9. package/cjs/core/auth-store.js.map +1 -0
  10. package/cjs/core/crypto.d.ts +3 -0
  11. package/cjs/core/crypto.js +3 -0
  12. package/cjs/core/crypto.js.map +1 -0
  13. package/cjs/core/key-manager.d.ts +31 -0
  14. package/cjs/core/key-manager.js +113 -0
  15. package/cjs/core/key-manager.js.map +1 -0
  16. package/cjs/core/protected-store.d.ts +5 -0
  17. package/cjs/core/protected-store.js +3 -0
  18. package/cjs/core/protected-store.js.map +1 -0
  19. package/cjs/core/publisher.d.ts +6 -0
  20. package/cjs/core/publisher.js +3 -0
  21. package/cjs/core/publisher.js.map +1 -0
  22. package/cjs/core/sdk-config.d.ts +52 -0
  23. package/cjs/core/sdk-config.js +61 -0
  24. package/cjs/core/sdk-config.js.map +1 -0
  25. package/cjs/core/subscriber.d.ts +3 -0
  26. package/cjs/core/subscriber.js +3 -0
  27. package/cjs/core/subscriber.js.map +1 -0
  28. package/cjs/gen/graphql-types.d.ts +101 -0
  29. package/cjs/gen/graphql-types.js +105 -0
  30. package/cjs/gen/graphql-types.js.map +1 -0
  31. package/cjs/index.d.ts +4 -0
  32. package/cjs/index.js +13 -0
  33. package/cjs/index.js.map +1 -0
  34. package/cjs/runtimes/browser/browser-crypto.d.ts +2 -0
  35. package/cjs/runtimes/browser/browser-crypto.js +10 -0
  36. package/cjs/runtimes/browser/browser-crypto.js.map +1 -0
  37. package/cjs/runtimes/node/node-crypto.d.ts +2 -0
  38. package/cjs/runtimes/node/node-crypto.js +9 -0
  39. package/cjs/runtimes/node/node-crypto.js.map +1 -0
  40. package/cjs/sdk.d.ts +1 -0
  41. package/cjs/sdk.js +9 -0
  42. package/cjs/sdk.js.map +1 -0
  43. package/cjs/user/auth-provider.d.ts +97 -0
  44. package/cjs/user/auth-provider.js +116 -0
  45. package/cjs/user/auth-provider.js.map +1 -0
  46. package/cjs/user/auth.d.ts +64 -0
  47. package/cjs/user/auth.js +136 -0
  48. package/cjs/user/auth.js.map +1 -0
  49. package/cjs/user/error.d.ts +18 -0
  50. package/cjs/user/error.js +33 -0
  51. package/cjs/user/error.js.map +1 -0
  52. package/cjs/user/identity-provider.d.ts +73 -0
  53. package/cjs/user/identity-provider.js +245 -0
  54. package/cjs/user/identity-provider.js.map +1 -0
  55. package/cjs/user/user-client-interface.d.ts +168 -0
  56. package/cjs/user/user-client-interface.js +3 -0
  57. package/cjs/user/user-client-interface.js.map +1 -0
  58. package/cjs/user/user-client.d.ts +82 -0
  59. package/cjs/user/user-client.js +440 -0
  60. package/cjs/user/user-client.js.map +1 -0
  61. package/cjs/user/user-key-names.d.ts +6 -0
  62. package/cjs/user/user-key-names.js +10 -0
  63. package/cjs/user/user-key-names.js.map +1 -0
  64. package/cjs/utils/resolvable-promise.d.ts +9 -0
  65. package/cjs/utils/resolvable-promise.js +20 -0
  66. package/cjs/utils/resolvable-promise.js.map +1 -0
  67. package/docs/classes/AlreadyRegisteredError.html +4 -4
  68. package/docs/classes/IdentityServiceConfigNotFoundError.html +4 -4
  69. package/lib/client/apiClient.js +135 -180
  70. package/lib/client/apiClient.js.map +1 -0
  71. package/lib/core/api-key-names.js +8 -14
  72. package/lib/core/api-key-names.js.map +1 -0
  73. package/lib/core/auth-store.js +82 -138
  74. package/lib/core/auth-store.js.map +1 -0
  75. package/lib/core/crypto.js +2 -5
  76. package/lib/core/crypto.js.map +1 -0
  77. package/lib/core/key-manager.js +98 -148
  78. package/lib/core/key-manager.js.map +1 -0
  79. package/lib/core/protected-store.d.ts +5 -0
  80. package/lib/core/protected-store.js +2 -5
  81. package/lib/core/protected-store.js.map +1 -0
  82. package/lib/core/publisher.js +2 -5
  83. package/lib/core/publisher.js.map +1 -0
  84. package/lib/core/sdk-config.js +56 -56
  85. package/lib/core/sdk-config.js.map +1 -0
  86. package/lib/core/subscriber.js +2 -5
  87. package/lib/core/subscriber.js.map +1 -0
  88. package/lib/gen/graphql-types.js +96 -135
  89. package/lib/gen/graphql-types.js.map +1 -0
  90. package/lib/index.js +6 -67
  91. package/lib/index.js.map +1 -0
  92. package/lib/runtimes/browser/browser-crypto.d.ts +2 -0
  93. package/lib/runtimes/browser/browser-crypto.js +6 -14
  94. package/lib/runtimes/browser/browser-crypto.js.map +1 -0
  95. package/lib/runtimes/node/node-crypto.js +5 -11
  96. package/lib/runtimes/node/node-crypto.js.map +1 -0
  97. package/lib/sdk.js +6 -18
  98. package/lib/sdk.js.map +1 -0
  99. package/lib/user/auth-provider.js +81 -131
  100. package/lib/user/auth-provider.js.map +1 -0
  101. package/lib/user/auth.js +127 -179
  102. package/lib/user/auth.js.map +1 -0
  103. package/lib/user/error.js +15 -33
  104. package/lib/user/error.js.map +1 -0
  105. package/lib/user/identity-provider.js +232 -261
  106. package/lib/user/identity-provider.js.map +1 -0
  107. package/lib/user/user-client-interface.js +2 -5
  108. package/lib/user/user-client-interface.js.map +1 -0
  109. package/lib/user/user-client.js +423 -510
  110. package/lib/user/user-client.js.map +1 -0
  111. package/lib/user/user-key-names.js +6 -12
  112. package/lib/user/user-key-names.js.map +1 -0
  113. package/lib/utils/resolvable-promise.js +13 -19
  114. package/lib/utils/resolvable-promise.js.map +1 -0
  115. package/package.json +22 -21
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CognitoAuthUI = exports.DefaultRefreshTokenLifetime = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const sudo_common_1 = require("@sudoplatform/sudo-common");
6
+ const amazon_cognito_auth_js_1 = require("amazon-cognito-auth-js");
7
+ const api_key_names_1 = require("../core/api-key-names");
8
+ const resolvable_promise_1 = require("../utils/resolvable-promise");
9
+ const JWT = tslib_1.__importStar(require("jsonwebtoken"));
10
+ const user_key_names_1 = require("./user-key-names");
11
+ exports.DefaultRefreshTokenLifetime = 60;
12
+ class CognitoAuthUI {
13
+ constructor(authenticationStore, federatedSignInConfig, keyManager, logger, launchUriFn) {
14
+ this.authenticationStore = authenticationStore;
15
+ this.federatedSignInConfig = federatedSignInConfig;
16
+ this.keyManager = keyManager;
17
+ this.launchUriFn = launchUriFn;
18
+ this.authenticationStore.subscribe(this);
19
+ this.auth = this.initCognitoAuthSDK();
20
+ const refreshTokenLifetime = this.federatedSignInConfig.refreshTokenLifetime;
21
+ this.refreshTokenLifetime =
22
+ refreshTokenLifetime ?? exports.DefaultRefreshTokenLifetime;
23
+ this.logger = logger;
24
+ }
25
+ initCognitoAuthSDK() {
26
+ const cognitoAuthConfig = {
27
+ ClientId: this.federatedSignInConfig.appClientId,
28
+ AppWebDomain: this.federatedSignInConfig.webDomain,
29
+ IdentityProvider: this.federatedSignInConfig.identityProvider,
30
+ RedirectUriSignIn: this.federatedSignInConfig.signInRedirectUri,
31
+ RedirectUriSignOut: this.federatedSignInConfig.signOutRedirectUri,
32
+ TokenScopesArray: ['openid'],
33
+ Storage: this.authenticationStore,
34
+ LaunchUri: this.launchUriFn,
35
+ };
36
+ const auth = new amazon_cognito_auth_js_1.CognitoAuth(cognitoAuthConfig);
37
+ auth.useCodeGrantFlow();
38
+ auth.userhandler = {
39
+ onSuccess: (result) => {
40
+ this.logger.info('Successfully signed in.', { result });
41
+ },
42
+ onFailure: (error) => {
43
+ this.logger.error(new sudo_common_1.AuthenticationError(error).message);
44
+ },
45
+ };
46
+ return auth;
47
+ }
48
+ presentFederatedSignInUI() {
49
+ this.auth.getSession();
50
+ }
51
+ async processFederatedSignInTokens(url) {
52
+ this.tokensRefreshedPromise =
53
+ (0, resolvable_promise_1.createResolvablePromise)();
54
+ this.auth.parseCognitoWebResponse(url);
55
+ const authDetails = await this.tokensRefreshedPromise;
56
+ await this.storeTokensInKeyManager(authDetails);
57
+ return authDetails.authenticationTokens;
58
+ }
59
+ /**
60
+ * This function is called when the authentication store notifies subscribers of an item update.
61
+ *
62
+ * @param itemName the name of the item being updated
63
+ */
64
+ update(itemName) {
65
+ if (itemName === 'idToken') {
66
+ const authTokens = this.getAuthTokens();
67
+ const userId = this.authenticationStore.getItem(api_key_names_1.apiKeyNames.userId);
68
+ if (authTokens && userId) {
69
+ this.tokensRefreshedPromise?.resolve({
70
+ authenticationTokens: authTokens,
71
+ userId,
72
+ });
73
+ }
74
+ }
75
+ this.logger.debug('Updated: ', { itemName });
76
+ }
77
+ reset() {
78
+ const cognitoAuthAny = this.auth;
79
+ cognitoAuthAny.clearCachedTokensScopes();
80
+ cognitoAuthAny.signInUserSession = null;
81
+ cognitoAuthAny.signInUserSession = cognitoAuthAny.getCachedSession();
82
+ }
83
+ presentSignOutUI() {
84
+ const signOutUrl = this.auth.getFQDNSignOut();
85
+ this.auth.launchUri(signOutUrl);
86
+ }
87
+ async storeRefreshTokenLifetime(refreshTokenLifetime) {
88
+ const tokenLifetime = refreshTokenLifetime * 24 * 60 * 60 * 1000 + new Date().getTime();
89
+ await this.keyManager.removeItem(api_key_names_1.apiKeyNames.refreshTokenExpiry);
90
+ await this.keyManager.addString(api_key_names_1.apiKeyNames.refreshTokenExpiry, tokenLifetime.toString());
91
+ }
92
+ getAuthTokens() {
93
+ const idToken = this.authenticationStore.getItem(api_key_names_1.apiKeyNames.idToken);
94
+ const accessToken = this.authenticationStore.getItem(api_key_names_1.apiKeyNames.accessToken);
95
+ const refreshToken = this.authenticationStore.getItem(api_key_names_1.apiKeyNames.refreshToken);
96
+ const tokenExpiry = this.getTokenExpiry();
97
+ if (idToken && accessToken && refreshToken && tokenExpiry) {
98
+ return {
99
+ idToken: idToken,
100
+ accessToken: accessToken,
101
+ refreshToken: refreshToken,
102
+ tokenExpiry: tokenExpiry.getTime(),
103
+ };
104
+ }
105
+ else {
106
+ return undefined;
107
+ }
108
+ }
109
+ getTokenExpiry() {
110
+ const expiry = this.authenticationStore.getItem(api_key_names_1.apiKeyNames.tokenExpiry);
111
+ return expiry ? new Date(Number(expiry) * 1000) : undefined;
112
+ }
113
+ /**
114
+ * Store the authentication tokens and user id of the signed in user in the key manager.
115
+ */
116
+ async storeTokensInKeyManager(authDetails) {
117
+ await this.keyManager.removeItem(user_key_names_1.userKeyNames.userId);
118
+ await this.keyManager.removeItem(api_key_names_1.apiKeyNames.idToken);
119
+ await this.keyManager.removeItem(api_key_names_1.apiKeyNames.accessToken);
120
+ await this.keyManager.removeItem(api_key_names_1.apiKeyNames.refreshToken);
121
+ await this.keyManager.removeItem(api_key_names_1.apiKeyNames.tokenExpiry);
122
+ const authTokens = authDetails.authenticationTokens;
123
+ await this.keyManager.addString(user_key_names_1.userKeyNames.userId, authDetails.userId);
124
+ await this.keyManager.addString(api_key_names_1.apiKeyNames.idToken, authTokens.idToken);
125
+ await this.keyManager.addString(api_key_names_1.apiKeyNames.accessToken, authTokens.accessToken);
126
+ await this.keyManager.addString(api_key_names_1.apiKeyNames.refreshToken, authTokens.refreshToken);
127
+ const decoded = JWT.decode(authTokens.idToken, { complete: true });
128
+ if (decoded) {
129
+ const tokenExpiry = decoded.payload['exp'];
130
+ await this.keyManager.addString(api_key_names_1.apiKeyNames.tokenExpiry, tokenExpiry);
131
+ }
132
+ await this.storeRefreshTokenLifetime(this.refreshTokenLifetime);
133
+ }
134
+ }
135
+ exports.CognitoAuthUI = CognitoAuthUI;
136
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/user/auth.ts"],"names":[],"mappings":";;;;AAAA,2DAAuE;AACvE,mEAAoD;AACpD,yDAAmD;AAKnD,oEAGoC;AAEpC,0DAAmC;AACnC,q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CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;QACvE,IAAI,OAAO,EAAE;YACX,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YAC1C,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,2BAAW,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;SACtE;QACD,MAAM,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;IACjE,CAAC;CACF;AApKD,sCAoKC"}
@@ -0,0 +1,18 @@
1
+ declare class UserError extends Error {
2
+ constructor(msg?: string);
3
+ }
4
+ /**
5
+ * Indicates the user associated with the client is already registered.
6
+ */
7
+ export declare class AlreadyRegisteredError extends UserError {
8
+ constructor();
9
+ }
10
+ /**
11
+ * Indicates the configuration related to Identity Service is not found. This may indicate that Identity Service
12
+ * is not deployed into your runtime instance or the config file that
13
+ * you are using is invalid.
14
+ */
15
+ export declare class IdentityServiceConfigNotFoundError extends UserError {
16
+ constructor();
17
+ }
18
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdentityServiceConfigNotFoundError = exports.AlreadyRegisteredError = void 0;
4
+ class UserError extends Error {
5
+ constructor(msg) {
6
+ super(msg);
7
+ this.name = this.constructor.name;
8
+ if (Error.captureStackTrace) {
9
+ Error.captureStackTrace(this, this.constructor);
10
+ }
11
+ }
12
+ }
13
+ /**
14
+ * Indicates the user associated with the client is already registered.
15
+ */
16
+ class AlreadyRegisteredError extends UserError {
17
+ constructor() {
18
+ super('User is already registered.');
19
+ }
20
+ }
21
+ exports.AlreadyRegisteredError = AlreadyRegisteredError;
22
+ /**
23
+ * Indicates the configuration related to Identity Service is not found. This may indicate that Identity Service
24
+ * is not deployed into your runtime instance or the config file that
25
+ * you are using is invalid.
26
+ */
27
+ class IdentityServiceConfigNotFoundError extends UserError {
28
+ constructor() {
29
+ super('Identity service configuration not found.');
30
+ }
31
+ }
32
+ exports.IdentityServiceConfigNotFoundError = IdentityServiceConfigNotFoundError;
33
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/user/error.ts"],"names":[],"mappings":";;;AAAA,MAAM,SAAU,SAAQ,KAAK;IAC3B,YAAY,GAAY;QACtB,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,IAAI,KAAK,CAAC,iBAAiB,EAAE;YAC3B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;SAChD;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAa,sBAAuB,SAAQ,SAAS;IACnD;QACE,KAAK,CAAC,6BAA6B,CAAC,CAAA;IACtC,CAAC;CACF;AAJD,wDAIC;AAED;;;;GAIG;AACH,MAAa,kCAAmC,SAAQ,SAAS;IAC/D;QACE,KAAK,CAAC,2CAA2C,CAAC,CAAA;IACpD,CAAC;CACF;AAJD,gFAIC"}
@@ -0,0 +1,73 @@
1
+ import { Config } from '../core/sdk-config';
2
+ import { AuthenticationTokens } from './user-client-interface';
3
+ import { KeyManager } from '../core/key-manager';
4
+ import { Logger } from '@sudoplatform/sudo-common';
5
+ export interface IdentityProvider {
6
+ /**
7
+ * Signs out the user from all devices.
8
+ *
9
+ * @param accessToken access token used to authorize the request.
10
+ */
11
+ globalSignOut(accessToken: string): Promise<void>;
12
+ /**
13
+ * Registers a new user against the identity provider.
14
+ *
15
+ * @param uid user ID.
16
+ * @param validationData registration parameters.
17
+ * @return user ID
18
+ */
19
+ register(uid: string, validationData: {
20
+ Name: string;
21
+ Value: string;
22
+ }[]): Promise<string>;
23
+ /**
24
+ * Sign into the identity provider using a signing key.
25
+ *
26
+ * @param uid user ID.
27
+ * @param keyId signing key id.
28
+ * @return Successful authentication result AuthenticationTokens
29
+ */
30
+ signInWithKey(uid: string, keyId: string): Promise<AuthenticationTokens>;
31
+ /**
32
+ * Sign into the identity provider using a token issued by an external
33
+ * authentication provider.
34
+ *
35
+ * @param uid user ID.
36
+ * @param token authentication token.
37
+ * @param type token type.
38
+ * @return Successful authentication result AuthenticationTokens
39
+ */
40
+ signInWithToken(uid: string, token: string, type: string): Promise<AuthenticationTokens>;
41
+ /**
42
+ * Refresh the access and ID tokens using the refresh token.
43
+ *
44
+ * @param refreshToken refresh token used to refresh the access and ID tokens.
45
+ * @return Successful authentication result AuthenticationTokens containing refreshed tokens
46
+ */
47
+ refreshTokens(refreshToken: string): Promise<AuthenticationTokens>;
48
+ /**
49
+ * Signs out the user from this device.
50
+ *
51
+ * @param refreshToken refresh token to revoke to sign out this device.
52
+ */
53
+ signOut(refreshToken: string): Promise<void>;
54
+ }
55
+ export declare class CognitoUserPoolIdentityProvider implements IdentityProvider {
56
+ private keyManager;
57
+ private config;
58
+ private idpService;
59
+ private refreshTokenLifetime;
60
+ private logger;
61
+ constructor(keyManager: KeyManager, config: Config, logger: Logger);
62
+ private initCognitoIdpService;
63
+ globalSignOut(accessToken: string): Promise<void>;
64
+ register(uid: string, validationData: {
65
+ Name: string;
66
+ Value: string;
67
+ }[]): Promise<string>;
68
+ signInWithKey(userId: string, keyId: string): Promise<AuthenticationTokens>;
69
+ signInWithToken(userId: string, token: string, type: string): Promise<AuthenticationTokens>;
70
+ refreshTokens(refreshToken: string): Promise<AuthenticationTokens>;
71
+ signOut(refreshToken: string): Promise<void>;
72
+ private storeRefreshTokenLifetime;
73
+ }
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CognitoUserPoolIdentityProvider = void 0;
4
+ const client_cognito_identity_provider_1 = require("@aws-sdk/client-cognito-identity-provider");
5
+ const api_key_names_1 = require("../core/api-key-names");
6
+ const uuid_1 = require("uuid");
7
+ const sudo_common_1 = require("@sudoplatform/sudo-common");
8
+ const error_1 = require("./error");
9
+ class CognitoUserPoolIdentityProvider {
10
+ constructor(keyManager, config, logger) {
11
+ this.keyManager = keyManager;
12
+ this.config = config;
13
+ this.idpService = this.initCognitoIdpService();
14
+ const refreshTokenLifetime = this.config.identityService.refreshTokenLifetime;
15
+ this.refreshTokenLifetime = refreshTokenLifetime ?? 60;
16
+ this.logger = logger;
17
+ }
18
+ initCognitoIdpService() {
19
+ const idpService = new client_cognito_identity_provider_1.CognitoIdentityProviderClient({
20
+ region: this.config.identityService.region,
21
+ });
22
+ return idpService;
23
+ }
24
+ async globalSignOut(accessToken) {
25
+ try {
26
+ const params = {
27
+ AccessToken: accessToken,
28
+ };
29
+ const globalSignOut = new client_cognito_identity_provider_1.GlobalSignOutCommand(params);
30
+ const response = await this.idpService.send(globalSignOut);
31
+ this.logger.info('User successfully signed out.', { response });
32
+ }
33
+ catch (err) {
34
+ const error = err;
35
+ throw new sudo_common_1.SignOutError(error.message);
36
+ }
37
+ }
38
+ async register(uid, validationData) {
39
+ try {
40
+ const signUp = new client_cognito_identity_provider_1.SignUpCommand({
41
+ ValidationData: validationData,
42
+ Username: uid,
43
+ Password: `@FF57&Z1)123!-${(0, uuid_1.v4)()}`,
44
+ ClientId: this.config.identityService.clientId,
45
+ });
46
+ const response = await this.idpService.send(signUp);
47
+ if (response.UserConfirmed) {
48
+ this.logger.info('User successfully signed up.', { uid });
49
+ return uid;
50
+ }
51
+ else {
52
+ throw new sudo_common_1.UserNotConfirmedError();
53
+ }
54
+ }
55
+ catch (err) {
56
+ const error = err;
57
+ const errorMsg = error.message;
58
+ if (errorMsg.includes('sudoplatform.ServiceError')) {
59
+ throw new sudo_common_1.ServiceError(errorMsg);
60
+ }
61
+ else if (errorMsg.includes('sudoplatform.identity.UserValidationFailed') ||
62
+ errorMsg.includes('sudoplatform.identity.TestRegCheckFailed')) {
63
+ throw new sudo_common_1.NotAuthorizedError(errorMsg);
64
+ }
65
+ else if (errorMsg.includes('sudoplatform.identity.AlreadyRegistered')) {
66
+ throw new error_1.AlreadyRegisteredError();
67
+ }
68
+ else {
69
+ throw new sudo_common_1.FatalError(errorMsg);
70
+ }
71
+ }
72
+ }
73
+ async signInWithKey(userId, keyId) {
74
+ try {
75
+ const initiateAuthCommand = new client_cognito_identity_provider_1.InitiateAuthCommand({
76
+ ClientId: this.config.identityService.clientId,
77
+ AuthFlow: 'CUSTOM_AUTH',
78
+ AuthParameters: {
79
+ USERNAME: userId,
80
+ },
81
+ });
82
+ const initiateAuthResult = await this.idpService.send(initiateAuthCommand);
83
+ const challengeName = initiateAuthResult.ChallengeName;
84
+ const session = initiateAuthResult.Session;
85
+ const params = initiateAuthResult.ChallengeParameters;
86
+ if (params &&
87
+ params['nonce'] &&
88
+ params['audience'] &&
89
+ challengeName &&
90
+ session) {
91
+ const nonce = params['nonce'];
92
+ const audience = params['audience'];
93
+ const answer = await this.keyManager.signJWT(keyId, {
94
+ jti: nonce,
95
+ iss: userId,
96
+ aud: audience,
97
+ sub: userId,
98
+ exp: Math.floor(+new Date() / 1000) + 300,
99
+ });
100
+ const respondToAuthChallenge = new client_cognito_identity_provider_1.RespondToAuthChallengeCommand({
101
+ Session: session,
102
+ ClientId: this.config.identityService.clientId,
103
+ ChallengeName: challengeName,
104
+ ChallengeResponses: {
105
+ USERNAME: userId,
106
+ ANSWER: answer,
107
+ },
108
+ });
109
+ const respondToAuthChallengeResult = await this.idpService.send(respondToAuthChallenge);
110
+ const authResult = respondToAuthChallengeResult.AuthenticationResult;
111
+ const idToken = authResult?.IdToken;
112
+ const accessToken = authResult?.AccessToken;
113
+ const refreshToken = authResult?.RefreshToken;
114
+ const tokenExpiry = authResult?.ExpiresIn;
115
+ if (idToken && accessToken && refreshToken && tokenExpiry) {
116
+ const authTokens = {
117
+ idToken: idToken,
118
+ accessToken: accessToken,
119
+ refreshToken: refreshToken,
120
+ tokenExpiry: tokenExpiry,
121
+ };
122
+ await this.storeRefreshTokenLifetime(this.refreshTokenLifetime);
123
+ return authTokens;
124
+ }
125
+ else {
126
+ throw new sudo_common_1.AuthenticationError('Authentication tokens not found.');
127
+ }
128
+ }
129
+ else {
130
+ throw new sudo_common_1.AuthenticationError('Invalid initiate auth result.');
131
+ }
132
+ }
133
+ catch (err) {
134
+ const error = err;
135
+ throw new sudo_common_1.AuthenticationError(error.message);
136
+ }
137
+ }
138
+ async signInWithToken(userId, token, type) {
139
+ try {
140
+ const initiateAuth = new client_cognito_identity_provider_1.InitiateAuthCommand({
141
+ ClientId: this.config.identityService.clientId,
142
+ AuthFlow: 'CUSTOM_AUTH',
143
+ AuthParameters: {
144
+ USERNAME: userId,
145
+ },
146
+ });
147
+ const initiateAuthResult = await this.idpService.send(initiateAuth);
148
+ const challengeName = initiateAuthResult.ChallengeName;
149
+ const session = initiateAuthResult.Session;
150
+ if (challengeName && session) {
151
+ const respondToAuthChallenge = new client_cognito_identity_provider_1.RespondToAuthChallengeCommand({
152
+ Session: session,
153
+ ClientId: this.config.identityService.clientId,
154
+ ChallengeName: challengeName,
155
+ ChallengeResponses: {
156
+ USERNAME: userId,
157
+ ANSWER: token,
158
+ },
159
+ ClientMetadata: { challengeType: type },
160
+ });
161
+ const respondToAuthChallengeResult = await this.idpService.send(respondToAuthChallenge);
162
+ const authResult = respondToAuthChallengeResult.AuthenticationResult;
163
+ const idToken = authResult?.IdToken;
164
+ const accessToken = authResult?.AccessToken;
165
+ const refreshToken = authResult?.RefreshToken;
166
+ const tokenExpiry = authResult?.ExpiresIn;
167
+ if (idToken && accessToken && refreshToken && tokenExpiry) {
168
+ const authTokens = {
169
+ idToken: idToken,
170
+ accessToken: accessToken,
171
+ refreshToken: refreshToken,
172
+ tokenExpiry: tokenExpiry,
173
+ };
174
+ await this.storeRefreshTokenLifetime(this.refreshTokenLifetime);
175
+ return authTokens;
176
+ }
177
+ else {
178
+ throw new sudo_common_1.AuthenticationError('Authentication tokens not found.');
179
+ }
180
+ }
181
+ else {
182
+ throw new sudo_common_1.AuthenticationError('Invalid initiate auth result.');
183
+ }
184
+ }
185
+ catch (err) {
186
+ const error = err;
187
+ throw new sudo_common_1.AuthenticationError(error.message);
188
+ }
189
+ }
190
+ async refreshTokens(refreshToken) {
191
+ try {
192
+ const initiateAuth = new client_cognito_identity_provider_1.InitiateAuthCommand({
193
+ ClientId: this.config.identityService.clientId,
194
+ AuthFlow: 'REFRESH_TOKEN_AUTH',
195
+ AuthParameters: {
196
+ REFRESH_TOKEN: refreshToken,
197
+ },
198
+ });
199
+ const initiateAuthResult = await this.idpService.send(initiateAuth);
200
+ const idToken = initiateAuthResult.AuthenticationResult?.IdToken;
201
+ const accessToken = initiateAuthResult.AuthenticationResult?.AccessToken;
202
+ const tokenExpiry = initiateAuthResult.AuthenticationResult?.ExpiresIn;
203
+ if (idToken && accessToken && tokenExpiry) {
204
+ const authTokens = {
205
+ idToken: idToken,
206
+ accessToken: accessToken,
207
+ refreshToken: refreshToken,
208
+ tokenExpiry: tokenExpiry,
209
+ };
210
+ await this.storeRefreshTokenLifetime(this.refreshTokenLifetime);
211
+ return authTokens;
212
+ }
213
+ else {
214
+ throw new sudo_common_1.AuthenticationError('Authentication tokens not found.');
215
+ }
216
+ }
217
+ catch (err) {
218
+ const error = err;
219
+ throw new sudo_common_1.AuthenticationError(error.message);
220
+ }
221
+ }
222
+ async signOut(refreshToken) {
223
+ try {
224
+ const params = {
225
+ Token: refreshToken,
226
+ ClientId: this.config.identityService.clientId,
227
+ };
228
+ const revokeToken = new client_cognito_identity_provider_1.RevokeTokenCommand(params);
229
+ const response = await this.idpService.send(revokeToken);
230
+ this.logger.info('User successfully signed out.', { response });
231
+ }
232
+ catch (err) {
233
+ const error = err;
234
+ this.logger.error(error.message);
235
+ throw new sudo_common_1.SignOutError(error.message);
236
+ }
237
+ }
238
+ async storeRefreshTokenLifetime(refreshTokenLifetime) {
239
+ const tokenLifetime = refreshTokenLifetime * 24 * 60 * 60 * 1000 + new Date().getTime();
240
+ await this.keyManager.removeItem(api_key_names_1.apiKeyNames.refreshTokenExpiry);
241
+ await this.keyManager.addString(api_key_names_1.apiKeyNames.refreshTokenExpiry, tokenLifetime.toString());
242
+ }
243
+ }
244
+ exports.CognitoUserPoolIdentityProvider = CognitoUserPoolIdentityProvider;
245
+ //# sourceMappingURL=identity-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-provider.js","sourceRoot":"","sources":["../../src/user/identity-provider.ts"],"names":[],"mappings":";;;AAAA,gGAOkD;AAElD,yDAAmD;AAGnD,+BAAyB;AACzB,2DAQkC;AAClC,mCAAgD;AA4DhD,MAAa,+BAA+B;IAK1C,YACU,UAAsB,EACtB,MAAc,EACtB,MAAc;QAFN,eAAU,GAAV,UAAU,CAAY;QACtB,WAAM,GAAN,MAAM,CAAQ;QAGtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;QAE9C,MAAM,oBAAoB,GACxB,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,oBAAoB,CAAA;QAClD,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,IAAI,EAAE,CAAA;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEO,qBAAqB;QAC3B,MAAM,UAAU,GAAG,IAAI,gEAA6B,CAAC;YACnD,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM;SAC3C,CAAC,CAAA;QAEF,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,IAAI;YACF,MAAM,MAAM,GAAG;gBACb,WAAW,EAAE,WAAW;aACzB,CAAA;YACD,MAAM,aAAa,GAAG,IAAI,uDAAoB,CAAC,MAAM,CAAC,CAAA;YACtD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;YAC1D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+BAA+B,EAAE,EAAE,QA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