@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,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIdentityServiceConfig = exports.Config = exports.FederatedSignInConfigCodec = exports.IdentityServiceConfigCodec = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const sudo_common_1 = require("@sudoplatform/sudo-common");
6
+ const t = tslib_1.__importStar(require("io-ts"));
7
+ const error_1 = require("../user/error");
8
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
9
+ exports.IdentityServiceConfigCodec = t.intersection([
10
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
11
+ t.type({
12
+ region: t.string,
13
+ poolId: t.string,
14
+ clientId: t.string,
15
+ identityPoolId: t.string,
16
+ apiUrl: t.string,
17
+ apiKey: t.string,
18
+ bucket: t.string,
19
+ transientBucket: t.string,
20
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
21
+ registrationMethods: t.array(t.string),
22
+ }),
23
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
24
+ t.partial({
25
+ refreshTokenLifetime: t.number,
26
+ }),
27
+ ], 'IdentityServiceConfig');
28
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
29
+ exports.FederatedSignInConfigCodec = t.intersection([
30
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
31
+ t.type({
32
+ appClientId: t.string,
33
+ signInRedirectUri: t.string,
34
+ signOutRedirectUri: t.string,
35
+ webDomain: t.string,
36
+ }),
37
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
38
+ t.partial({
39
+ identityProvider: t.string,
40
+ refreshTokenLifetime: t.number,
41
+ }),
42
+ ], 'FederatedSignInConfig');
43
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
44
+ exports.Config = t.intersection([
45
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
46
+ t.type({
47
+ identityService: exports.IdentityServiceConfigCodec,
48
+ }),
49
+ // eslint-disable-next-line tree-shaking/no-side-effects-in-initialization
50
+ t.partial({
51
+ federatedSignIn: exports.FederatedSignInConfigCodec,
52
+ }),
53
+ ]);
54
+ function getIdentityServiceConfig() {
55
+ if (!sudo_common_1.DefaultConfigurationManager.getInstance().getConfigSet('identityService')) {
56
+ throw new error_1.IdentityServiceConfigNotFoundError();
57
+ }
58
+ return sudo_common_1.DefaultConfigurationManager.getInstance().bindConfigSet(exports.Config, undefined);
59
+ }
60
+ exports.getIdentityServiceConfig = getIdentityServiceConfig;
61
+ //# sourceMappingURL=sdk-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-config.js","sourceRoot":"","sources":["../../src/core/sdk-config.ts"],"names":[],"mappings":";;;;AAAA,2DAAuE;AACvE,iDAA0B;AAC1B,yCAAkE;AAElE,0EAA0E;AAC7D,QAAA,0BAA0B,GAAG,CAAC,CAAC,YAAY,CACtD;IACE,0EAA0E;IAC1E,CAAC,CAAC,IAAI,CAAC;QACL,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,QAAQ,EAAE,CAAC,CAAC,MAAM;QAClB,cAAc,EAAE,CAAC,CAAC,MAAM;QACxB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,eAAe,EAAE,CAAC,CAAC,MAAM;QACzB,0EAA0E;QAC1E,mBAAmB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;KACvC,CAAC;IACF,0EAA0E;IAC1E,CAAC,CAAC,OAAO,CAAC;QACR,oBAAoB,EAAE,CAAC,CAAC,MAAM;KAC/B,CAAC;CACH,EACD,uBAAuB,CACxB,CAAA;AAED,0EAA0E;AAC7D,QAAA,0BAA0B,GAAG,CAAC,CAAC,YAAY,CACtD;IACE,0EAA0E;IAC1E,CAAC,CAAC,IAAI,CAAC;QACL,WAAW,EAAE,CAAC,CAAC,MAAM;QACrB,iBAAiB,EAAE,CAAC,CAAC,MAAM;QAC3B,kBAAkB,EAAE,CAAC,CAAC,MAAM;QAC5B,SAAS,EAAE,CAAC,CAAC,MAAM;KACpB,CAAC;IACF,0EAA0E;IAC1E,CAAC,CAAC,OAAO,CAAC;QACR,gBAAgB,EAAE,CAAC,CAAC,MAAM;QAC1B,oBAAoB,EAAE,CAAC,CAAC,MAAM;KAC/B,CAAC;CACH,EACD,uBAAuB,CACxB,CAAA;AAED,0EAA0E;AAC7D,QAAA,MAAM,GAAG,CAAC,CAAC,YAAY,CAAC;IACnC,0EAA0E;IAC1E,CAAC,CAAC,IAAI,CAAC;QACL,eAAe,EAAE,kCAA0B;KAC5C,CAAC;IACF,0EAA0E;IAC1E,CAAC,CAAC,OAAO,CAAC;QACR,eAAe,EAAE,kCAA0B;KAC5C,CAAC;CACH,CAAC,CAAA;AAMF,SAAgB,wBAAwB;IACtC,IACE,CAAC,yCAA2B,CAAC,WAAW,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAC1E;QACA,MAAM,IAAI,0CAAkC,EAAE,CAAA;KAC/C;IAED,OAAO,yCAA2B,CAAC,WAAW,EAAE,CAAC,aAAa,CAC5D,cAAM,EACN,SAAS,CACV,CAAA;AACH,CAAC;AAXD,4DAWC"}
@@ -0,0 +1,3 @@
1
+ export interface Subscriber {
2
+ update(itemName: string): void;
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=subscriber.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriber.js","sourceRoot":"","sources":["../../src/core/subscriber.ts"],"names":[],"mappings":""}
@@ -0,0 +1,101 @@
1
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
2
+ export declare type Maybe<T> = T | undefined;
3
+ export declare type InputMaybe<T> = T | undefined;
4
+ export declare type Exact<T extends {
5
+ [key: string]: unknown;
6
+ }> = {
7
+ [K in keyof T]: T[K];
8
+ };
9
+ export declare type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
+ [SubKey in K]?: Maybe<T[SubKey]>;
11
+ };
12
+ export declare type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
+ [SubKey in K]: Maybe<T[SubKey]>;
14
+ };
15
+ /** All built-in and custom scalars, mapped to their actual values */
16
+ export declare type Scalars = {
17
+ ID: string;
18
+ String: string;
19
+ Boolean: boolean;
20
+ Int: number;
21
+ Float: number;
22
+ AWSDate: any;
23
+ AWSDateTime: any;
24
+ AWSEmail: any;
25
+ AWSIPAddress: any;
26
+ AWSJSON: unknown;
27
+ AWSPhone: any;
28
+ AWSTime: any;
29
+ AWSTimestamp: any;
30
+ AWSURL: any;
31
+ };
32
+ export declare type Deregister = {
33
+ __typename?: 'Deregister';
34
+ success: Scalars['Boolean'];
35
+ };
36
+ export declare type FederatedId = {
37
+ __typename?: 'FederatedId';
38
+ identityId: Scalars['String'];
39
+ };
40
+ export declare type GlobalSignOut = {
41
+ __typename?: 'GlobalSignOut';
42
+ success: Scalars['Boolean'];
43
+ };
44
+ export declare type Mutation = {
45
+ __typename?: 'Mutation';
46
+ deregister?: Maybe<Deregister>;
47
+ globalSignOut?: Maybe<GlobalSignOut>;
48
+ registerFederatedId?: Maybe<FederatedId>;
49
+ };
50
+ export declare type MutationRegisterFederatedIdArgs = {
51
+ input?: InputMaybe<RegisterFederatedIdInput>;
52
+ };
53
+ export declare type Query = {
54
+ __typename?: 'Query';
55
+ notImplemented?: Maybe<Scalars['Boolean']>;
56
+ };
57
+ export declare type QueryNotImplementedArgs = {
58
+ dummy: Scalars['String'];
59
+ };
60
+ export declare type RegisterFederatedIdInput = {
61
+ idToken: Scalars['String'];
62
+ };
63
+ export declare type DeregisterMutationVariables = Exact<{
64
+ [key: string]: never;
65
+ }>;
66
+ export declare type DeregisterMutation = {
67
+ __typename?: 'Mutation';
68
+ deregister?: {
69
+ __typename?: 'Deregister';
70
+ success: boolean;
71
+ } | undefined;
72
+ };
73
+ export declare type GlobalSignOutMutationVariables = Exact<{
74
+ [key: string]: never;
75
+ }>;
76
+ export declare type GlobalSignOutMutation = {
77
+ __typename?: 'Mutation';
78
+ globalSignOut?: {
79
+ __typename?: 'GlobalSignOut';
80
+ success: boolean;
81
+ } | undefined;
82
+ };
83
+ export declare type RegisterFederatedIdMutationVariables = Exact<{
84
+ input: RegisterFederatedIdInput;
85
+ }>;
86
+ export declare type RegisterFederatedIdMutation = {
87
+ __typename?: 'Mutation';
88
+ registerFederatedId?: {
89
+ __typename?: 'FederatedId';
90
+ identityId: string;
91
+ } | undefined;
92
+ };
93
+ export declare const DeregisterDocument: DocumentNode<DeregisterMutation, Exact<{
94
+ [key: string]: never;
95
+ }>>;
96
+ export declare const GlobalSignOutDocument: DocumentNode<GlobalSignOutMutation, Exact<{
97
+ [key: string]: never;
98
+ }>>;
99
+ export declare const RegisterFederatedIdDocument: DocumentNode<RegisterFederatedIdMutation, Exact<{
100
+ input: RegisterFederatedIdInput;
101
+ }>>;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegisterFederatedIdDocument = exports.GlobalSignOutDocument = exports.DeregisterDocument = void 0;
4
+ exports.DeregisterDocument = {
5
+ kind: 'Document',
6
+ definitions: [
7
+ {
8
+ kind: 'OperationDefinition',
9
+ operation: 'mutation',
10
+ name: { kind: 'Name', value: 'deregister' },
11
+ selectionSet: {
12
+ kind: 'SelectionSet',
13
+ selections: [
14
+ {
15
+ kind: 'Field',
16
+ name: { kind: 'Name', value: 'deregister' },
17
+ selectionSet: {
18
+ kind: 'SelectionSet',
19
+ selections: [
20
+ { kind: 'Field', name: { kind: 'Name', value: 'success' } },
21
+ ],
22
+ },
23
+ },
24
+ ],
25
+ },
26
+ },
27
+ ],
28
+ };
29
+ exports.GlobalSignOutDocument = {
30
+ kind: 'Document',
31
+ definitions: [
32
+ {
33
+ kind: 'OperationDefinition',
34
+ operation: 'mutation',
35
+ name: { kind: 'Name', value: 'GlobalSignOut' },
36
+ selectionSet: {
37
+ kind: 'SelectionSet',
38
+ selections: [
39
+ {
40
+ kind: 'Field',
41
+ name: { kind: 'Name', value: 'globalSignOut' },
42
+ selectionSet: {
43
+ kind: 'SelectionSet',
44
+ selections: [
45
+ { kind: 'Field', name: { kind: 'Name', value: 'success' } },
46
+ ],
47
+ },
48
+ },
49
+ ],
50
+ },
51
+ },
52
+ ],
53
+ };
54
+ exports.RegisterFederatedIdDocument = {
55
+ kind: 'Document',
56
+ definitions: [
57
+ {
58
+ kind: 'OperationDefinition',
59
+ operation: 'mutation',
60
+ name: { kind: 'Name', value: 'registerFederatedId' },
61
+ variableDefinitions: [
62
+ {
63
+ kind: 'VariableDefinition',
64
+ variable: {
65
+ kind: 'Variable',
66
+ name: { kind: 'Name', value: 'input' },
67
+ },
68
+ type: {
69
+ kind: 'NonNullType',
70
+ type: {
71
+ kind: 'NamedType',
72
+ name: { kind: 'Name', value: 'RegisterFederatedIdInput' },
73
+ },
74
+ },
75
+ },
76
+ ],
77
+ selectionSet: {
78
+ kind: 'SelectionSet',
79
+ selections: [
80
+ {
81
+ kind: 'Field',
82
+ name: { kind: 'Name', value: 'registerFederatedId' },
83
+ arguments: [
84
+ {
85
+ kind: 'Argument',
86
+ name: { kind: 'Name', value: 'input' },
87
+ value: {
88
+ kind: 'Variable',
89
+ name: { kind: 'Name', value: 'input' },
90
+ },
91
+ },
92
+ ],
93
+ selectionSet: {
94
+ kind: 'SelectionSet',
95
+ selections: [
96
+ { kind: 'Field', name: { kind: 'Name', value: 'identityId' } },
97
+ ],
98
+ },
99
+ },
100
+ ],
101
+ },
102
+ },
103
+ ],
104
+ };
105
+ //# sourceMappingURL=graphql-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-types.js","sourceRoot":"","sources":["../../src/gen/graphql-types.ts"],"names":[],"mappings":";;;AAgGa,QAAA,kBAAkB,GAAG;IAChC,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE;QACX;YACE,IAAI,EAAE,qBAAqB;YAC3B,SAAS,EAAE,UAAU;YACrB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE;YAC3C,Y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,QAAQ,EAAE;wBACR,IAAI,EAAE,UAAU;wBAChB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;qBACvC;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,aAAa;wBACnB,IAAI,EAAE;4BACJ,IAAI,EAAE,WAAW;4BACjB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,0BAA0B,EAAE;yBAC1D;qBACF;iBACF;aACF;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,cAAc;gBACpB,UAAU,EAAE;oBACV;wBACE,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE;wBACpD,SAAS,EAAE;4BACT;gCACE,IAAI,EAAE,UAAU;gCAChB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;gCACtC,KAAK,EAAE;oCACL,IAAI,EAAE,UAAU;oCAChB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE;iCACvC;6BACF;yBACF;wBACD,YAAY,EAAE;4BACZ,IAAI,EAAE,cAAc;4BACpB,UAAU,EAAE;gCACV,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;6BAC/D;yBACF;qBACF;iBACF;aACF;SACF;KACF;CAIF,CAAA"}
package/cjs/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { DefaultSudoUserClient } from './user/user-client';
2
+ export * from './user/user-client-interface';
3
+ export { TESTAuthenticationProvider, LocalAuthenticationProvider, AuthenticationProvider, } from './user/auth-provider';
4
+ export * from './user/error';
package/cjs/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalAuthenticationProvider = exports.TESTAuthenticationProvider = exports.DefaultSudoUserClient = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /* Everything exported here is considered public API and is documented by typedoc. */
6
+ var user_client_1 = require("./user/user-client");
7
+ Object.defineProperty(exports, "DefaultSudoUserClient", { enumerable: true, get: function () { return user_client_1.DefaultSudoUserClient; } });
8
+ tslib_1.__exportStar(require("./user/user-client-interface"), exports);
9
+ var auth_provider_1 = require("./user/auth-provider");
10
+ Object.defineProperty(exports, "TESTAuthenticationProvider", { enumerable: true, get: function () { return auth_provider_1.TESTAuthenticationProvider; } });
11
+ Object.defineProperty(exports, "LocalAuthenticationProvider", { enumerable: true, get: function () { return auth_provider_1.LocalAuthenticationProvider; } });
12
+ tslib_1.__exportStar(require("./user/error"), exports);
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,qFAAqF;AACrF,kDAA0D;AAAjD,oHAAA,qBAAqB,OAAA;AAC9B,uEAA4C;AAC5C,sDAI6B;AAH3B,2HAAA,0BAA0B,OAAA;AAC1B,4HAAA,2BAA2B,OAAA;AAI7B,uDAA4B"}
@@ -0,0 +1,2 @@
1
+ import { CryptoProvider } from '../../core/crypto';
2
+ export declare const cryptoProvider: CryptoProvider;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cryptoProvider = void 0;
4
+ const sudo_common_1 = require("@sudoplatform/sudo-common");
5
+ exports.cryptoProvider = {
6
+ arrayBufferToBase64: (buffer) => {
7
+ return sudo_common_1.Base64.encode(buffer);
8
+ },
9
+ };
10
+ //# sourceMappingURL=browser-crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-crypto.js","sourceRoot":"","sources":["../../../src/runtimes/browser/browser-crypto.ts"],"names":[],"mappings":";;;AACA,2DAAkD;AAErC,QAAA,cAAc,GAAmB;IAC5C,mBAAmB,EAAE,CAAC,MAAmB,EAAU,EAAE;QACnD,OAAO,oBAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC9B,CAAC;CACF,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { CryptoProvider } from '../../core/crypto';
2
+ export declare const cryptoProvider: CryptoProvider;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cryptoProvider = void 0;
4
+ exports.cryptoProvider = {
5
+ arrayBufferToBase64: (buffer) => {
6
+ return Buffer.from(buffer).toString('base64');
7
+ },
8
+ };
9
+ //# sourceMappingURL=node-crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-crypto.js","sourceRoot":"","sources":["../../../src/runtimes/node/node-crypto.ts"],"names":[],"mappings":";;;AAEa,QAAA,cAAc,GAAmB;IAC5C,mBAAmB,EAAE,CAAC,MAAmB,EAAU,EAAE;QACnD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC/C,CAAC;CACF,CAAA"}
package/cjs/sdk.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './core/sdk-config';
package/cjs/sdk.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /*
5
+ * Private interfaces for support for other Sudo Platform
6
+ * SDKs.
7
+ */
8
+ tslib_1.__exportStar(require("./core/sdk-config"), exports);
9
+ //# sourceMappingURL=sdk.js.map
package/cjs/sdk.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,4DAAiC"}
@@ -0,0 +1,97 @@
1
+ export interface AuthenticationInfo {
2
+ /**
3
+ * Authentication type.
4
+ */
5
+ type: string;
6
+ /**
7
+ * Indicates whether or not the authentication information is valid.
8
+ *
9
+ * @return *true* if the authentication information is valid.
10
+ */
11
+ isValid(): boolean;
12
+ /**
13
+ * Encodes the authentication information as a string.
14
+ *
15
+ * @return encoded authentication information.
16
+ */
17
+ encode(): string;
18
+ /**
19
+ * Returns the username associated with this authentication information.
20
+ *
21
+ * @return username.
22
+ */
23
+ getUsername(): string;
24
+ }
25
+ export interface AuthenticationProvider {
26
+ /**
27
+ * Generates and returns authentication information.
28
+ *
29
+ * @return authentication information.
30
+ */
31
+ getAuthenticationInfo(): Promise<AuthenticationInfo>;
32
+ /**
33
+ * Resets internal state and releases any associated resources.
34
+ */
35
+ reset(): void;
36
+ }
37
+ /**
38
+ * Authentication info consisting of a JWT signed using the TEST registration key.
39
+ */
40
+ export declare class TESTAuthenticationInfo implements AuthenticationInfo {
41
+ private jwt;
42
+ readonly type: string;
43
+ constructor(jwt: string);
44
+ isValid(): boolean;
45
+ encode(): string;
46
+ getUsername(): string;
47
+ }
48
+ /**
49
+ * Authentication provider for generating authentication info using a TEST registration key.
50
+ *
51
+ * @param name provider name. This name will be prepended to the generated UUID in JWT sub.
52
+ * @param privateKey PEM encoded RSA private key.
53
+ * @param keyId key ID of the TEST registration key which is obtained from the admin console.
54
+ * @param attributes additional attributes to be added to the issued authentication info.
55
+ */
56
+ export declare class TESTAuthenticationProvider implements AuthenticationProvider {
57
+ private name;
58
+ private privateKey;
59
+ private keyId;
60
+ private attributes?;
61
+ readonly testRegistrationIssuer: string;
62
+ readonly testRegistrationAudience: string;
63
+ constructor(name: string, privateKey: string, keyId?: string, attributes?: Record<string, any> | undefined);
64
+ getAuthenticationInfo(): Promise<AuthenticationInfo>;
65
+ reset(): void;
66
+ }
67
+ /**
68
+ * Authentication info consisting of a JWT signed using the locally stored private key.
69
+ */
70
+ export declare class LocalAuthenticationInfo implements AuthenticationInfo {
71
+ private jwt;
72
+ private username;
73
+ readonly type: string;
74
+ constructor(jwt: string, username: string);
75
+ isValid(): boolean;
76
+ encode(): string;
77
+ getUsername(): string;
78
+ }
79
+ /**
80
+ * Authentication info consisting of a JWT signed using the locally stored private key.
81
+ *
82
+ * @param name provider name. This name will be used to populate JWT iss (issuer).
83
+ * @param privateKey PEM encoded RSA private key.
84
+ * @param keyId key ID.
85
+ * @param username username to be associated with the issued authentication info.
86
+ * @param attributes additional attributes to be added to the issued authentication info.
87
+ */
88
+ export declare class LocalAuthenticationProvider implements AuthenticationProvider {
89
+ private name;
90
+ private privateKey;
91
+ private keyId;
92
+ private username;
93
+ private attributes?;
94
+ constructor(name: string, privateKey: string, keyId: string, username: string, attributes?: Record<string, any> | undefined);
95
+ getAuthenticationInfo(): Promise<AuthenticationInfo>;
96
+ reset(): void;
97
+ }
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalAuthenticationProvider = exports.LocalAuthenticationInfo = exports.TESTAuthenticationProvider = exports.TESTAuthenticationInfo = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const JWT = tslib_1.__importStar(require("jsonwebtoken"));
6
+ const uuid_1 = require("uuid");
7
+ /**
8
+ * Authentication info consisting of a JWT signed using the TEST registration key.
9
+ */
10
+ class TESTAuthenticationInfo {
11
+ constructor(jwt) {
12
+ this.jwt = jwt;
13
+ this.type = 'TEST';
14
+ }
15
+ isValid() {
16
+ return true;
17
+ }
18
+ encode() {
19
+ return this.jwt;
20
+ }
21
+ getUsername() {
22
+ return '';
23
+ }
24
+ }
25
+ exports.TESTAuthenticationInfo = TESTAuthenticationInfo;
26
+ /**
27
+ * Authentication provider for generating authentication info using a TEST registration key.
28
+ *
29
+ * @param name provider name. This name will be prepended to the generated UUID in JWT sub.
30
+ * @param privateKey PEM encoded RSA private key.
31
+ * @param keyId key ID of the TEST registration key which is obtained from the admin console.
32
+ * @param attributes additional attributes to be added to the issued authentication info.
33
+ */
34
+ class TESTAuthenticationProvider {
35
+ constructor(name, privateKey, keyId = 'register_key', attributes) {
36
+ this.name = name;
37
+ this.privateKey = privateKey;
38
+ this.keyId = keyId;
39
+ this.attributes = attributes;
40
+ this.testRegistrationIssuer = 'testRegisterIssuer';
41
+ this.testRegistrationAudience = 'testRegisterAudience';
42
+ }
43
+ async getAuthenticationInfo() {
44
+ const jwt = JWT.sign(this.attributes ? this.attributes : {}, this.privateKey, {
45
+ jwtid: (0, uuid_1.v4)(),
46
+ audience: this.testRegistrationAudience,
47
+ expiresIn: '60s',
48
+ notBefore: '0m',
49
+ subject: `${this.name}-${(0, uuid_1.v4)()}`,
50
+ issuer: this.testRegistrationIssuer,
51
+ header: { alg: 'RS256', kid: this.keyId },
52
+ algorithm: 'RS256',
53
+ });
54
+ return new TESTAuthenticationInfo(jwt);
55
+ }
56
+ reset() {
57
+ // Not implemented
58
+ }
59
+ }
60
+ exports.TESTAuthenticationProvider = TESTAuthenticationProvider;
61
+ /**
62
+ * Authentication info consisting of a JWT signed using the locally stored private key.
63
+ */
64
+ class LocalAuthenticationInfo {
65
+ constructor(jwt, username) {
66
+ this.jwt = jwt;
67
+ this.username = username;
68
+ this.type = 'FSSO';
69
+ }
70
+ isValid() {
71
+ return true;
72
+ }
73
+ encode() {
74
+ return this.jwt;
75
+ }
76
+ getUsername() {
77
+ return this.username;
78
+ }
79
+ }
80
+ exports.LocalAuthenticationInfo = LocalAuthenticationInfo;
81
+ /**
82
+ * Authentication info consisting of a JWT signed using the locally stored private key.
83
+ *
84
+ * @param name provider name. This name will be used to populate JWT iss (issuer).
85
+ * @param privateKey PEM encoded RSA private key.
86
+ * @param keyId key ID.
87
+ * @param username username to be associated with the issued authentication info.
88
+ * @param attributes additional attributes to be added to the issued authentication info.
89
+ */
90
+ class LocalAuthenticationProvider {
91
+ constructor(name, privateKey, keyId, username, attributes) {
92
+ this.name = name;
93
+ this.privateKey = privateKey;
94
+ this.keyId = keyId;
95
+ this.username = username;
96
+ this.attributes = attributes;
97
+ }
98
+ async getAuthenticationInfo() {
99
+ const jwt = JWT.sign(this.attributes ? this.attributes : {}, this.privateKey, {
100
+ jwtid: (0, uuid_1.v4)(),
101
+ audience: 'identity-service',
102
+ expiresIn: '60s',
103
+ notBefore: '0m',
104
+ subject: this.username,
105
+ issuer: this.name,
106
+ header: { alg: 'RS256', kid: this.keyId },
107
+ algorithm: 'RS256',
108
+ });
109
+ return new LocalAuthenticationInfo(jwt, this.username);
110
+ }
111
+ reset() {
112
+ // Not implemented
113
+ }
114
+ }
115
+ exports.LocalAuthenticationProvider = LocalAuthenticationProvider;
116
+ //# sourceMappingURL=auth-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-provider.js","sourceRoot":"","sources":["../../src/user/auth-provider.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AACnC,+BAAyB;AA2CzB;;GAEG;AACH,MAAa,sBAAsB;IAGjC,YAAoB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAFtB,SAAI,GAAW,MAAM,CAAA;IAEI,CAAC;IAEnC,OAAO;QACL,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;IAED,WAAW;QACT,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AAhBD,wDAgBC;AAED;;;;;;;GAOG;AACH,MAAa,0BAA0B;IAGrC,YACU,IAAY,EACZ,UAAkB,EAClB,QAAgB,cAAc,EAC9B,UAAgC;QAHhC,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAQ;QAClB,UAAK,GAAL,KAAK,CAAyB;QAC9B,eAAU,GAAV,UAAU,CAAsB;QANjC,2BAAsB,GAAW,oBAAoB,CAAA;QACrD,6BAAwB,GAAW,sBAAsB,CAAA;IAM/D,CAAC;IAEJ,KAAK,CAAC,qBAAqB;QACzB,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAClB,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EACtC,IAAI,CAAC,U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C,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EACtC,IAAI,CAAC,UAAU,EACf;YACE,KAAK,EAAE,IAAA,SAAE,GAAE;YACX,QAAQ,EAAE,kBAAkB;YAC5B,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,MAAM,EAAE,IAAI,CAAC,IAAI;YACjB,MAAM,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE;YACzC,SAAS,EAAE,OAAO;SACnB,CACF,CAAA;QACD,OAAO,IAAI,uBAAuB,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;IACxD,CAAC;IAED,KAAK;QACH,kBAAkB;IACpB,CAAC;CACF;AA9BD,kEA8BC"}
@@ -0,0 +1,64 @@
1
+ import { Logger } from '@sudoplatform/sudo-common';
2
+ import { AuthenticationStore } from '../core/auth-store';
3
+ import { KeyManager } from '../core/key-manager';
4
+ import { FederatedSignInConfig } from '../core/sdk-config';
5
+ import { Subscriber } from '../core/subscriber';
6
+ import { AuthenticationTokens } from './user-client-interface';
7
+ export interface AuthenticationDetails {
8
+ authenticationTokens: AuthenticationTokens;
9
+ userId: string;
10
+ }
11
+ export interface AuthUI {
12
+ /**
13
+ * Presents the sign in UI for federated sign in using an external identity provider.
14
+ */
15
+ presentFederatedSignInUI(): void;
16
+ /**
17
+ * Processes tokens from federated sign in that are returned in exchange
18
+ * for the authorization code that is returned to the specified URL.
19
+ *
20
+ * @param url callback URL containing the authorization code.
21
+ * @return Successful authentication result AuthenticationTokens.
22
+ */
23
+ processFederatedSignInTokens(url: string): Promise<AuthenticationTokens>;
24
+ /**
25
+ * Resets any internal state.
26
+ */
27
+ reset(): void;
28
+ /**
29
+ * Presents the Cognito hosted UI signout endpoint.
30
+ * When the endpoint is invoked, the hosted web app's cookies
31
+ * will be invalidated, but the user is not logged out of Cognito.
32
+ */
33
+ presentSignOutUI(): void;
34
+ }
35
+ export declare const DefaultRefreshTokenLifetime = 60;
36
+ export declare class CognitoAuthUI implements AuthUI, Subscriber {
37
+ private authenticationStore;
38
+ private federatedSignInConfig;
39
+ private keyManager;
40
+ private launchUriFn?;
41
+ private auth;
42
+ private tokensRefreshedPromise?;
43
+ private refreshTokenLifetime;
44
+ private logger;
45
+ constructor(authenticationStore: AuthenticationStore, federatedSignInConfig: FederatedSignInConfig, keyManager: KeyManager, logger: Logger, launchUriFn?: ((url: string) => void) | undefined);
46
+ private initCognitoAuthSDK;
47
+ presentFederatedSignInUI(): void;
48
+ processFederatedSignInTokens(url: string): Promise<AuthenticationTokens>;
49
+ /**
50
+ * This function is called when the authentication store notifies subscribers of an item update.
51
+ *
52
+ * @param itemName the name of the item being updated
53
+ */
54
+ update(itemName: string): void;
55
+ reset(): void;
56
+ presentSignOutUI(): void;
57
+ private storeRefreshTokenLifetime;
58
+ private getAuthTokens;
59
+ private getTokenExpiry;
60
+ /**
61
+ * Store the authentication tokens and user id of the signed in user in the key manager.
62
+ */
63
+ private storeTokensInKeyManager;
64
+ }