@sudoplatform/sudo-user 10.1.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{lib → cjs/src}/client/apiClient.d.ts +0 -0
- package/cjs/src/client/apiClient.js +149 -0
- package/cjs/src/client/apiClient.js.map +1 -0
- package/{lib → cjs/src}/core/api-key-names.d.ts +0 -0
- package/cjs/src/core/api-key-names.js +12 -0
- package/cjs/src/core/api-key-names.js.map +1 -0
- package/{lib → cjs/src}/core/auth-store.d.ts +0 -0
- package/cjs/src/core/auth-store.js +92 -0
- package/cjs/src/core/auth-store.js.map +1 -0
- package/{lib → cjs/src}/core/crypto.d.ts +0 -0
- package/cjs/src/core/crypto.js +3 -0
- package/cjs/src/core/crypto.js.map +1 -0
- package/{lib → cjs/src}/core/key-manager.d.ts +0 -0
- package/cjs/src/core/key-manager.js +113 -0
- package/cjs/src/core/key-manager.js.map +1 -0
- package/cjs/src/core/protected-store.d.ts +5 -0
- package/cjs/src/core/protected-store.js +3 -0
- package/cjs/src/core/protected-store.js.map +1 -0
- package/{lib → cjs/src}/core/publisher.d.ts +0 -0
- package/cjs/src/core/publisher.js +3 -0
- package/cjs/src/core/publisher.js.map +1 -0
- package/{lib → cjs/src}/core/sdk-config.d.ts +0 -0
- package/cjs/src/core/sdk-config.js +61 -0
- package/cjs/src/core/sdk-config.js.map +1 -0
- package/{lib → cjs/src}/core/subscriber.d.ts +0 -0
- package/cjs/src/core/subscriber.js +3 -0
- package/cjs/src/core/subscriber.js.map +1 -0
- package/{lib → cjs/src}/gen/graphql-types.d.ts +5 -4
- package/cjs/src/gen/graphql-types.js +105 -0
- package/cjs/src/gen/graphql-types.js.map +1 -0
- package/{lib → cjs/src}/index.d.ts +0 -0
- package/cjs/src/index.js +13 -0
- package/cjs/src/index.js.map +1 -0
- package/{lib/runtimes/node/node-crypto.d.ts → cjs/src/runtimes/browser/browser-crypto.d.ts} +0 -0
- package/cjs/src/runtimes/browser/browser-crypto.js +10 -0
- package/cjs/src/runtimes/browser/browser-crypto.js.map +1 -0
- package/cjs/src/runtimes/node/node-crypto.d.ts +2 -0
- package/cjs/src/runtimes/node/node-crypto.js +9 -0
- package/cjs/src/runtimes/node/node-crypto.js.map +1 -0
- package/{lib → cjs/src}/sdk.d.ts +0 -0
- package/cjs/src/sdk.js +9 -0
- package/cjs/src/sdk.js.map +1 -0
- package/{lib → cjs/src}/user/auth-provider.d.ts +0 -0
- package/cjs/src/user/auth-provider.js +116 -0
- package/cjs/src/user/auth-provider.js.map +1 -0
- package/{lib → cjs/src}/user/auth.d.ts +0 -0
- package/cjs/src/user/auth.js +136 -0
- package/cjs/src/user/auth.js.map +1 -0
- package/{lib → cjs/src}/user/error.d.ts +0 -0
- package/{lib → cjs/src}/user/error.js +16 -29
- package/cjs/src/user/error.js.map +1 -0
- package/{lib → cjs/src}/user/identity-provider.d.ts +0 -0
- package/cjs/src/user/identity-provider.js +245 -0
- package/cjs/src/user/identity-provider.js.map +1 -0
- package/{lib → cjs/src}/user/user-client-interface.d.ts +0 -0
- package/cjs/src/user/user-client-interface.js +3 -0
- package/cjs/src/user/user-client-interface.js.map +1 -0
- package/{lib → cjs/src}/user/user-client.d.ts +0 -0
- package/cjs/src/user/user-client.js +440 -0
- package/cjs/src/user/user-client.js.map +1 -0
- package/{lib → cjs/src}/user/user-key-names.d.ts +0 -0
- package/cjs/src/user/user-key-names.js +10 -0
- package/cjs/src/user/user-key-names.js.map +1 -0
- package/{lib → cjs/src}/utils/resolvable-promise.d.ts +0 -0
- package/cjs/src/utils/resolvable-promise.js +20 -0
- package/cjs/src/utils/resolvable-promise.js.map +1 -0
- package/cjs/test/integration/user-client-int.spec.d.ts +1 -0
- package/cjs/test/integration/user-client-int.spec.js +206 -0
- package/cjs/test/integration/user-client-int.spec.js.map +1 -0
- package/cjs/test/unit/core/sdk-config.spec.d.ts +1 -0
- package/cjs/test/unit/core/sdk-config.spec.js +51 -0
- package/cjs/test/unit/core/sdk-config.spec.js.map +1 -0
- package/cjs/test/unit/key-manager.spec.d.ts +1 -0
- package/cjs/test/unit/key-manager.spec.js +23 -0
- package/cjs/test/unit/key-manager.spec.js.map +1 -0
- package/cjs/test/unit/user-client.spec.d.ts +1 -0
- package/cjs/test/unit/user-client.spec.js +323 -0
- package/cjs/test/unit/user-client.spec.js.map +1 -0
- package/docs/assets/highlight.css +3 -3
- package/docs/assets/main.js +4 -2
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +427 -617
- package/docs/classes/AlreadyRegisteredError.html +163 -8
- package/docs/classes/DefaultSudoUserClient.html +568 -57
- package/docs/classes/IdentityServiceConfigNotFoundError.html +163 -8
- package/docs/classes/LocalAuthenticationProvider.html +131 -12
- package/docs/classes/TESTAuthenticationProvider.html +146 -11
- package/docs/index.html +47 -2
- package/docs/interfaces/AuthenticationProvider.html +89 -6
- package/docs/interfaces/AuthenticationTokens.html +97 -7
- package/docs/interfaces/SudoUserClient.html +431 -80
- package/docs/modules.html +62 -1
- package/lib/src/client/apiClient.d.ts +25 -0
- package/lib/src/client/apiClient.js +145 -0
- package/lib/src/client/apiClient.js.map +1 -0
- package/lib/src/core/api-key-names.d.ts +8 -0
- package/lib/src/core/api-key-names.js +9 -0
- package/lib/src/core/api-key-names.js.map +1 -0
- package/lib/src/core/auth-store.d.ts +51 -0
- package/lib/src/core/auth-store.js +88 -0
- package/lib/src/core/auth-store.js.map +1 -0
- package/lib/src/core/crypto.d.ts +3 -0
- package/lib/src/core/crypto.js +2 -0
- package/lib/src/core/crypto.js.map +1 -0
- package/lib/src/core/key-manager.d.ts +31 -0
- package/lib/src/core/key-manager.js +108 -0
- package/lib/src/core/key-manager.js.map +1 -0
- package/lib/src/core/protected-store.d.ts +5 -0
- package/lib/src/core/protected-store.js +2 -0
- package/lib/src/core/protected-store.js.map +1 -0
- package/lib/src/core/publisher.d.ts +6 -0
- package/lib/src/core/publisher.js +2 -0
- package/lib/src/core/publisher.js.map +1 -0
- package/lib/src/core/sdk-config.d.ts +52 -0
- package/lib/src/core/sdk-config.js +56 -0
- package/lib/src/core/sdk-config.js.map +1 -0
- package/lib/src/core/subscriber.d.ts +3 -0
- package/lib/src/core/subscriber.js +2 -0
- package/lib/src/core/subscriber.js.map +1 -0
- package/lib/src/gen/graphql-types.d.ts +101 -0
- package/lib/src/gen/graphql-types.js +102 -0
- package/lib/src/gen/graphql-types.js.map +1 -0
- package/lib/src/index.d.ts +4 -0
- package/lib/src/index.js +6 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/runtimes/browser/browser-crypto.d.ts +2 -0
- package/lib/src/runtimes/browser/browser-crypto.js +7 -0
- package/lib/src/runtimes/browser/browser-crypto.js.map +1 -0
- package/lib/src/runtimes/node/node-crypto.d.ts +2 -0
- package/lib/src/runtimes/node/node-crypto.js +6 -0
- package/lib/src/runtimes/node/node-crypto.js.map +1 -0
- package/lib/src/sdk.d.ts +1 -0
- package/lib/src/sdk.js +6 -0
- package/lib/src/sdk.js.map +1 -0
- package/lib/src/user/auth-provider.d.ts +97 -0
- package/lib/src/user/auth-provider.js +108 -0
- package/lib/src/user/auth-provider.js.map +1 -0
- package/lib/src/user/auth.d.ts +64 -0
- package/lib/src/user/auth.js +131 -0
- package/lib/src/user/auth.js.map +1 -0
- package/lib/src/user/error.d.ts +18 -0
- package/lib/src/user/error.js +28 -0
- package/lib/src/user/error.js.map +1 -0
- package/lib/src/user/identity-provider.d.ts +73 -0
- package/lib/src/user/identity-provider.js +241 -0
- package/lib/src/user/identity-provider.js.map +1 -0
- package/lib/src/user/user-client-interface.d.ts +168 -0
- package/lib/src/user/user-client-interface.js +2 -0
- package/lib/src/user/user-client-interface.js.map +1 -0
- package/lib/src/user/user-client.d.ts +82 -0
- package/lib/src/user/user-client.js +435 -0
- package/lib/src/user/user-client.js.map +1 -0
- package/lib/src/user/user-key-names.d.ts +6 -0
- package/lib/src/user/user-key-names.js +7 -0
- package/lib/src/user/user-key-names.js.map +1 -0
- package/lib/src/utils/resolvable-promise.d.ts +9 -0
- package/lib/src/utils/resolvable-promise.js +16 -0
- package/lib/src/utils/resolvable-promise.js.map +1 -0
- package/lib/test/integration/user-client-int.spec.d.ts +1 -0
- package/lib/test/integration/user-client-int.spec.js +203 -0
- package/lib/test/integration/user-client-int.spec.js.map +1 -0
- package/lib/test/unit/core/sdk-config.spec.d.ts +1 -0
- package/lib/test/unit/core/sdk-config.spec.js +49 -0
- package/lib/test/unit/core/sdk-config.spec.js.map +1 -0
- package/lib/test/unit/key-manager.spec.d.ts +1 -0
- package/lib/test/unit/key-manager.spec.js +21 -0
- package/lib/test/unit/key-manager.spec.js.map +1 -0
- package/lib/test/unit/user-client.spec.d.ts +1 -0
- package/lib/test/unit/user-client.spec.js +320 -0
- package/lib/test/unit/user-client.spec.js.map +1 -0
- package/package.json +47 -41
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/lib/client/apiClient.js +0 -206
- package/lib/core/api-key-names.js +0 -15
- package/lib/core/auth-store.js +0 -144
- package/lib/core/crypto.js +0 -5
- package/lib/core/key-manager.js +0 -158
- package/lib/core/protected-store.js +0 -5
- package/lib/core/publisher.js +0 -5
- package/lib/core/sdk-config.js +0 -56
- package/lib/core/subscriber.js +0 -5
- package/lib/gen/graphql-types.js +0 -141
- package/lib/index.js +0 -67
- package/lib/runtimes/browser/browser-crypto.js +0 -15
- package/lib/runtimes/node/node-crypto.js +0 -12
- package/lib/sdk.js +0 -18
- package/lib/user/auth-provider.js +0 -158
- package/lib/user/auth.js +0 -185
- package/lib/user/identity-provider.js +0 -272
- package/lib/user/user-client-interface.js +0 -5
- package/lib/user/user-client.js +0 -530
- package/lib/user/user-key-names.js +0 -13
- package/lib/utils/resolvable-promise.js +0 -22
package/lib/gen/graphql-types.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.RegisterFederatedIdDocument = exports.GlobalSignOutDocument = exports.DeregisterDocument = void 0;
|
|
7
|
-
// Sourcecode generated by graphql-codegen. DO NOT EDIT!
|
|
8
|
-
|
|
9
|
-
/* eslint-disable */
|
|
10
|
-
|
|
11
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
12
|
-
const DeregisterDocument = {
|
|
13
|
-
kind: 'Document',
|
|
14
|
-
definitions: [{
|
|
15
|
-
kind: 'OperationDefinition',
|
|
16
|
-
operation: 'mutation',
|
|
17
|
-
name: {
|
|
18
|
-
kind: 'Name',
|
|
19
|
-
value: 'deregister'
|
|
20
|
-
},
|
|
21
|
-
selectionSet: {
|
|
22
|
-
kind: 'SelectionSet',
|
|
23
|
-
selections: [{
|
|
24
|
-
kind: 'Field',
|
|
25
|
-
name: {
|
|
26
|
-
kind: 'Name',
|
|
27
|
-
value: 'deregister'
|
|
28
|
-
},
|
|
29
|
-
selectionSet: {
|
|
30
|
-
kind: 'SelectionSet',
|
|
31
|
-
selections: [{
|
|
32
|
-
kind: 'Field',
|
|
33
|
-
name: {
|
|
34
|
-
kind: 'Name',
|
|
35
|
-
value: 'success'
|
|
36
|
-
}
|
|
37
|
-
}]
|
|
38
|
-
}
|
|
39
|
-
}]
|
|
40
|
-
}
|
|
41
|
-
}]
|
|
42
|
-
};
|
|
43
|
-
exports.DeregisterDocument = DeregisterDocument;
|
|
44
|
-
const GlobalSignOutDocument = {
|
|
45
|
-
kind: 'Document',
|
|
46
|
-
definitions: [{
|
|
47
|
-
kind: 'OperationDefinition',
|
|
48
|
-
operation: 'mutation',
|
|
49
|
-
name: {
|
|
50
|
-
kind: 'Name',
|
|
51
|
-
value: 'GlobalSignOut'
|
|
52
|
-
},
|
|
53
|
-
selectionSet: {
|
|
54
|
-
kind: 'SelectionSet',
|
|
55
|
-
selections: [{
|
|
56
|
-
kind: 'Field',
|
|
57
|
-
name: {
|
|
58
|
-
kind: 'Name',
|
|
59
|
-
value: 'globalSignOut'
|
|
60
|
-
},
|
|
61
|
-
selectionSet: {
|
|
62
|
-
kind: 'SelectionSet',
|
|
63
|
-
selections: [{
|
|
64
|
-
kind: 'Field',
|
|
65
|
-
name: {
|
|
66
|
-
kind: 'Name',
|
|
67
|
-
value: 'success'
|
|
68
|
-
}
|
|
69
|
-
}]
|
|
70
|
-
}
|
|
71
|
-
}]
|
|
72
|
-
}
|
|
73
|
-
}]
|
|
74
|
-
};
|
|
75
|
-
exports.GlobalSignOutDocument = GlobalSignOutDocument;
|
|
76
|
-
const RegisterFederatedIdDocument = {
|
|
77
|
-
kind: 'Document',
|
|
78
|
-
definitions: [{
|
|
79
|
-
kind: 'OperationDefinition',
|
|
80
|
-
operation: 'mutation',
|
|
81
|
-
name: {
|
|
82
|
-
kind: 'Name',
|
|
83
|
-
value: 'registerFederatedId'
|
|
84
|
-
},
|
|
85
|
-
variableDefinitions: [{
|
|
86
|
-
kind: 'VariableDefinition',
|
|
87
|
-
variable: {
|
|
88
|
-
kind: 'Variable',
|
|
89
|
-
name: {
|
|
90
|
-
kind: 'Name',
|
|
91
|
-
value: 'input'
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
type: {
|
|
95
|
-
kind: 'NonNullType',
|
|
96
|
-
type: {
|
|
97
|
-
kind: 'NamedType',
|
|
98
|
-
name: {
|
|
99
|
-
kind: 'Name',
|
|
100
|
-
value: 'RegisterFederatedIdInput'
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}],
|
|
105
|
-
selectionSet: {
|
|
106
|
-
kind: 'SelectionSet',
|
|
107
|
-
selections: [{
|
|
108
|
-
kind: 'Field',
|
|
109
|
-
name: {
|
|
110
|
-
kind: 'Name',
|
|
111
|
-
value: 'registerFederatedId'
|
|
112
|
-
},
|
|
113
|
-
arguments: [{
|
|
114
|
-
kind: 'Argument',
|
|
115
|
-
name: {
|
|
116
|
-
kind: 'Name',
|
|
117
|
-
value: 'input'
|
|
118
|
-
},
|
|
119
|
-
value: {
|
|
120
|
-
kind: 'Variable',
|
|
121
|
-
name: {
|
|
122
|
-
kind: 'Name',
|
|
123
|
-
value: 'input'
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}],
|
|
127
|
-
selectionSet: {
|
|
128
|
-
kind: 'SelectionSet',
|
|
129
|
-
selections: [{
|
|
130
|
-
kind: 'Field',
|
|
131
|
-
name: {
|
|
132
|
-
kind: 'Name',
|
|
133
|
-
value: 'identityId'
|
|
134
|
-
}
|
|
135
|
-
}]
|
|
136
|
-
}
|
|
137
|
-
}]
|
|
138
|
-
}
|
|
139
|
-
}]
|
|
140
|
-
};
|
|
141
|
-
exports.RegisterFederatedIdDocument = RegisterFederatedIdDocument;
|
package/lib/index.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
DefaultSudoUserClient: true,
|
|
8
|
-
TESTAuthenticationProvider: true,
|
|
9
|
-
LocalAuthenticationProvider: true,
|
|
10
|
-
AuthenticationProvider: true
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "AuthenticationProvider", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _authProvider.AuthenticationProvider;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "DefaultSudoUserClient", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _userClient.DefaultSudoUserClient;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "LocalAuthenticationProvider", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _authProvider.LocalAuthenticationProvider;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "TESTAuthenticationProvider", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _authProvider.TESTAuthenticationProvider;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
var _userClient = require("./user/user-client");
|
|
38
|
-
|
|
39
|
-
var _userClientInterface = require("./user/user-client-interface");
|
|
40
|
-
|
|
41
|
-
Object.keys(_userClientInterface).forEach(function (key) {
|
|
42
|
-
if (key === "default" || key === "__esModule") return;
|
|
43
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
44
|
-
if (key in exports && exports[key] === _userClientInterface[key]) return;
|
|
45
|
-
Object.defineProperty(exports, key, {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function () {
|
|
48
|
-
return _userClientInterface[key];
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
var _authProvider = require("./user/auth-provider");
|
|
54
|
-
|
|
55
|
-
var _error = require("./user/error");
|
|
56
|
-
|
|
57
|
-
Object.keys(_error).forEach(function (key) {
|
|
58
|
-
if (key === "default" || key === "__esModule") return;
|
|
59
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
60
|
-
if (key in exports && exports[key] === _error[key]) return;
|
|
61
|
-
Object.defineProperty(exports, key, {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
get: function () {
|
|
64
|
-
return _error[key];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.cryptoProvider = void 0;
|
|
7
|
-
|
|
8
|
-
var _sudoCommon = require("@sudoplatform/sudo-common");
|
|
9
|
-
|
|
10
|
-
const cryptoProvider = {
|
|
11
|
-
arrayBufferToBase64: buffer => {
|
|
12
|
-
return _sudoCommon.Base64.encode(buffer);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
exports.cryptoProvider = cryptoProvider;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.cryptoProvider = void 0;
|
|
7
|
-
const cryptoProvider = {
|
|
8
|
-
arrayBufferToBase64: buffer => {
|
|
9
|
-
return Buffer.from(buffer).toString('base64');
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
exports.cryptoProvider = cryptoProvider;
|
package/lib/sdk.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _sdkConfig = require("./core/sdk-config");
|
|
8
|
-
|
|
9
|
-
Object.keys(_sdkConfig).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _sdkConfig[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _sdkConfig[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.TESTAuthenticationProvider = exports.TESTAuthenticationInfo = exports.LocalAuthenticationProvider = exports.LocalAuthenticationInfo = void 0;
|
|
7
|
-
|
|
8
|
-
var JWT = _interopRequireWildcard(require("jsonwebtoken"));
|
|
9
|
-
|
|
10
|
-
var _uuid = require("uuid");
|
|
11
|
-
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
|
|
14
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
-
|
|
16
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Authentication info consisting of a JWT signed using the TEST registration key.
|
|
20
|
-
*/
|
|
21
|
-
class TESTAuthenticationInfo {
|
|
22
|
-
constructor(jwt) {
|
|
23
|
-
this.jwt = jwt;
|
|
24
|
-
|
|
25
|
-
_defineProperty(this, "type", 'TEST');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
isValid() {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
encode() {
|
|
33
|
-
return this.jwt;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getUsername() {
|
|
37
|
-
return '';
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Authentication provider for generating authentication info using a TEST registration key.
|
|
43
|
-
*
|
|
44
|
-
* @param name provider name. This name will be prepended to the generated UUID in JWT sub.
|
|
45
|
-
* @param privateKey PEM encoded RSA private key.
|
|
46
|
-
* @param keyId key ID of the TEST registration key which is obtained from the admin console.
|
|
47
|
-
* @param attributes additional attributes to be added to the issued authentication info.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
exports.TESTAuthenticationInfo = TESTAuthenticationInfo;
|
|
52
|
-
|
|
53
|
-
class TESTAuthenticationProvider {
|
|
54
|
-
constructor(name, privateKey, keyId = 'register_key', attributes) {
|
|
55
|
-
this.name = name;
|
|
56
|
-
this.privateKey = privateKey;
|
|
57
|
-
this.keyId = keyId;
|
|
58
|
-
this.attributes = attributes;
|
|
59
|
-
|
|
60
|
-
_defineProperty(this, "testRegistrationIssuer", 'testRegisterIssuer');
|
|
61
|
-
|
|
62
|
-
_defineProperty(this, "testRegistrationAudience", 'testRegisterAudience');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async getAuthenticationInfo() {
|
|
66
|
-
const jwt = JWT.sign(this.attributes ? this.attributes : {}, this.privateKey, {
|
|
67
|
-
jwtid: (0, _uuid.v4)(),
|
|
68
|
-
audience: this.testRegistrationAudience,
|
|
69
|
-
expiresIn: '60s',
|
|
70
|
-
notBefore: '0m',
|
|
71
|
-
subject: `${this.name}-${(0, _uuid.v4)()}`,
|
|
72
|
-
issuer: this.testRegistrationIssuer,
|
|
73
|
-
header: {
|
|
74
|
-
alg: 'RS256',
|
|
75
|
-
kid: this.keyId
|
|
76
|
-
},
|
|
77
|
-
algorithm: 'RS256'
|
|
78
|
-
});
|
|
79
|
-
return new TESTAuthenticationInfo(jwt);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
reset() {// Not implemented
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Authentication info consisting of a JWT signed using the locally stored private key.
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
exports.TESTAuthenticationProvider = TESTAuthenticationProvider;
|
|
92
|
-
|
|
93
|
-
class LocalAuthenticationInfo {
|
|
94
|
-
constructor(jwt, username) {
|
|
95
|
-
this.jwt = jwt;
|
|
96
|
-
this.username = username;
|
|
97
|
-
|
|
98
|
-
_defineProperty(this, "type", 'FSSO');
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
isValid() {
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
encode() {
|
|
106
|
-
return this.jwt;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
getUsername() {
|
|
110
|
-
return this.username;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Authentication info consisting of a JWT signed using the locally stored private key.
|
|
116
|
-
*
|
|
117
|
-
* @param name provider name. This name will be used to populate JWT iss (issuer).
|
|
118
|
-
* @param privateKey PEM encoded RSA private key.
|
|
119
|
-
* @param keyId key ID.
|
|
120
|
-
* @param username username to be associated with the issued authentication info.
|
|
121
|
-
* @param attributes additional attributes to be added to the issued authentication info.
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
exports.LocalAuthenticationInfo = LocalAuthenticationInfo;
|
|
126
|
-
|
|
127
|
-
class LocalAuthenticationProvider {
|
|
128
|
-
constructor(name, privateKey, keyId, username, attributes) {
|
|
129
|
-
this.name = name;
|
|
130
|
-
this.privateKey = privateKey;
|
|
131
|
-
this.keyId = keyId;
|
|
132
|
-
this.username = username;
|
|
133
|
-
this.attributes = attributes;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async getAuthenticationInfo() {
|
|
137
|
-
const jwt = JWT.sign(this.attributes ? this.attributes : {}, this.privateKey, {
|
|
138
|
-
jwtid: (0, _uuid.v4)(),
|
|
139
|
-
audience: 'identity-service',
|
|
140
|
-
expiresIn: '60s',
|
|
141
|
-
notBefore: '0m',
|
|
142
|
-
subject: this.username,
|
|
143
|
-
issuer: this.name,
|
|
144
|
-
header: {
|
|
145
|
-
alg: 'RS256',
|
|
146
|
-
kid: this.keyId
|
|
147
|
-
},
|
|
148
|
-
algorithm: 'RS256'
|
|
149
|
-
});
|
|
150
|
-
return new LocalAuthenticationInfo(jwt, this.username);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
reset() {// Not implemented
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
exports.LocalAuthenticationProvider = LocalAuthenticationProvider;
|
package/lib/user/auth.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DefaultRefreshTokenLifetime = exports.CognitoAuthUI = void 0;
|
|
7
|
-
|
|
8
|
-
var _sudoCommon = require("@sudoplatform/sudo-common");
|
|
9
|
-
|
|
10
|
-
var _amazonCognitoAuthJs = require("amazon-cognito-auth-js");
|
|
11
|
-
|
|
12
|
-
var _apiKeyNames = require("../core/api-key-names");
|
|
13
|
-
|
|
14
|
-
var _resolvablePromise = require("../utils/resolvable-promise");
|
|
15
|
-
|
|
16
|
-
var JWT = _interopRequireWildcard(require("jsonwebtoken"));
|
|
17
|
-
|
|
18
|
-
var _userKeyNames = require("./user-key-names");
|
|
19
|
-
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
-
|
|
26
|
-
const DefaultRefreshTokenLifetime = 60;
|
|
27
|
-
exports.DefaultRefreshTokenLifetime = DefaultRefreshTokenLifetime;
|
|
28
|
-
|
|
29
|
-
class CognitoAuthUI {
|
|
30
|
-
constructor(authenticationStore, federatedSignInConfig, keyManager, logger, launchUriFn) {
|
|
31
|
-
this.authenticationStore = authenticationStore;
|
|
32
|
-
this.federatedSignInConfig = federatedSignInConfig;
|
|
33
|
-
this.keyManager = keyManager;
|
|
34
|
-
this.launchUriFn = launchUriFn;
|
|
35
|
-
|
|
36
|
-
_defineProperty(this, "auth", void 0);
|
|
37
|
-
|
|
38
|
-
_defineProperty(this, "tokensRefreshedPromise", void 0);
|
|
39
|
-
|
|
40
|
-
_defineProperty(this, "refreshTokenLifetime", void 0);
|
|
41
|
-
|
|
42
|
-
_defineProperty(this, "logger", void 0);
|
|
43
|
-
|
|
44
|
-
this.authenticationStore.subscribe(this);
|
|
45
|
-
this.auth = this.initCognitoAuthSDK();
|
|
46
|
-
const refreshTokenLifetime = this.federatedSignInConfig.refreshTokenLifetime;
|
|
47
|
-
this.refreshTokenLifetime = refreshTokenLifetime ?? DefaultRefreshTokenLifetime;
|
|
48
|
-
this.logger = logger;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
initCognitoAuthSDK() {
|
|
52
|
-
const cognitoAuthConfig = {
|
|
53
|
-
ClientId: this.federatedSignInConfig.appClientId,
|
|
54
|
-
AppWebDomain: this.federatedSignInConfig.webDomain,
|
|
55
|
-
IdentityProvider: this.federatedSignInConfig.identityProvider,
|
|
56
|
-
RedirectUriSignIn: this.federatedSignInConfig.signInRedirectUri,
|
|
57
|
-
RedirectUriSignOut: this.federatedSignInConfig.signOutRedirectUri,
|
|
58
|
-
TokenScopesArray: ['openid'],
|
|
59
|
-
Storage: this.authenticationStore,
|
|
60
|
-
LaunchUri: this.launchUriFn
|
|
61
|
-
};
|
|
62
|
-
const auth = new _amazonCognitoAuthJs.CognitoAuth(cognitoAuthConfig);
|
|
63
|
-
auth.useCodeGrantFlow();
|
|
64
|
-
auth.userhandler = {
|
|
65
|
-
onSuccess: result => {
|
|
66
|
-
this.logger.info('Successfully signed in.', {
|
|
67
|
-
result
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
onFailure: error => {
|
|
71
|
-
this.logger.error(new _sudoCommon.AuthenticationError(error).message);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
return auth;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
presentFederatedSignInUI() {
|
|
78
|
-
this.auth.getSession();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async processFederatedSignInTokens(url) {
|
|
82
|
-
this.tokensRefreshedPromise = (0, _resolvablePromise.createResolvablePromise)();
|
|
83
|
-
this.auth.parseCognitoWebResponse(url);
|
|
84
|
-
const authDetails = await this.tokensRefreshedPromise;
|
|
85
|
-
await this.storeTokensInKeyManager(authDetails);
|
|
86
|
-
return authDetails.authenticationTokens;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* This function is called when the authentication store notifies subscribers of an item update.
|
|
90
|
-
*
|
|
91
|
-
* @param itemName the name of the item being updated
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
update(itemName) {
|
|
96
|
-
if (itemName === 'idToken') {
|
|
97
|
-
const authTokens = this.getAuthTokens();
|
|
98
|
-
const userId = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.userId);
|
|
99
|
-
|
|
100
|
-
if (authTokens && userId) {
|
|
101
|
-
var _this$tokensRefreshed;
|
|
102
|
-
|
|
103
|
-
(_this$tokensRefreshed = this.tokensRefreshedPromise) === null || _this$tokensRefreshed === void 0 ? void 0 : _this$tokensRefreshed.resolve({
|
|
104
|
-
authenticationTokens: authTokens,
|
|
105
|
-
userId
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
this.logger.debug('Updated: ', {
|
|
111
|
-
itemName
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
reset() {
|
|
116
|
-
const cognitoAuthAny = this.auth;
|
|
117
|
-
cognitoAuthAny.clearCachedTokensScopes();
|
|
118
|
-
cognitoAuthAny.signInUserSession = null;
|
|
119
|
-
cognitoAuthAny.signInUserSession = cognitoAuthAny.getCachedSession();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
presentSignOutUI() {
|
|
123
|
-
const signOutUrl = this.auth.getFQDNSignOut();
|
|
124
|
-
this.auth.launchUri(signOutUrl);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
async storeRefreshTokenLifetime(refreshTokenLifetime) {
|
|
128
|
-
const tokenLifetime = refreshTokenLifetime * 24 * 60 * 60 * 1000 + new Date().getTime();
|
|
129
|
-
await this.keyManager.removeItem(_apiKeyNames.apiKeyNames.refreshTokenExpiry);
|
|
130
|
-
await this.keyManager.addString(_apiKeyNames.apiKeyNames.refreshTokenExpiry, tokenLifetime.toString());
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
getAuthTokens() {
|
|
134
|
-
const idToken = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.idToken);
|
|
135
|
-
const accessToken = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.accessToken);
|
|
136
|
-
const refreshToken = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.refreshToken);
|
|
137
|
-
const tokenExpiry = this.getTokenExpiry();
|
|
138
|
-
|
|
139
|
-
if (idToken && accessToken && refreshToken && tokenExpiry) {
|
|
140
|
-
return {
|
|
141
|
-
idToken: idToken,
|
|
142
|
-
accessToken: accessToken,
|
|
143
|
-
refreshToken: refreshToken,
|
|
144
|
-
tokenExpiry: tokenExpiry.getTime()
|
|
145
|
-
};
|
|
146
|
-
} else {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
getTokenExpiry() {
|
|
152
|
-
const expiry = this.authenticationStore.getItem(_apiKeyNames.apiKeyNames.tokenExpiry);
|
|
153
|
-
return expiry ? new Date(Number(expiry) * 1000) : undefined;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Store the authentication tokens and user id of the signed in user in the key manager.
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
async storeTokensInKeyManager(authDetails) {
|
|
161
|
-
await this.keyManager.removeItem(_userKeyNames.userKeyNames.userId);
|
|
162
|
-
await this.keyManager.removeItem(_apiKeyNames.apiKeyNames.idToken);
|
|
163
|
-
await this.keyManager.removeItem(_apiKeyNames.apiKeyNames.accessToken);
|
|
164
|
-
await this.keyManager.removeItem(_apiKeyNames.apiKeyNames.refreshToken);
|
|
165
|
-
await this.keyManager.removeItem(_apiKeyNames.apiKeyNames.tokenExpiry);
|
|
166
|
-
const authTokens = authDetails.authenticationTokens;
|
|
167
|
-
await this.keyManager.addString(_userKeyNames.userKeyNames.userId, authDetails.userId);
|
|
168
|
-
await this.keyManager.addString(_apiKeyNames.apiKeyNames.idToken, authTokens.idToken);
|
|
169
|
-
await this.keyManager.addString(_apiKeyNames.apiKeyNames.accessToken, authTokens.accessToken);
|
|
170
|
-
await this.keyManager.addString(_apiKeyNames.apiKeyNames.refreshToken, authTokens.refreshToken);
|
|
171
|
-
const decoded = JWT.decode(authTokens.idToken, {
|
|
172
|
-
complete: true
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
if (decoded) {
|
|
176
|
-
const tokenExpiry = decoded.payload['exp'];
|
|
177
|
-
await this.keyManager.addString(_apiKeyNames.apiKeyNames.tokenExpiry, tokenExpiry);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
await this.storeRefreshTokenLifetime(this.refreshTokenLifetime);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
exports.CognitoAuthUI = CognitoAuthUI;
|