@axinom/mosaic-user-auth 0.26.0-rc.2 → 0.26.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/UserServiceClient/UserServiceClient.d.ts +1 -1
- package/dist/UserServiceClient/UserServiceClient.d.ts.map +1 -1
- package/dist/common/ensure-error.d.ts.map +1 -1
- package/dist/common/stringify-gql-query.d.ts.map +1 -1
- package/dist/generated/ax-auth-management-graphql.types.d.ts +6 -18
- package/dist/generated/ax-auth-management-graphql.types.d.ts.map +1 -1
- package/dist/generated/user-service-end-user-graphql.types.d.ts +6 -18
- package/dist/generated/user-service-end-user-graphql.types.d.ts.map +1 -1
- package/dist/generated/user-service-management-graphql.types.d.ts +2 -6
- package/dist/generated/user-service-management-graphql.types.d.ts.map +1 -1
- package/dist/index.es.js +78 -28
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +78 -28
- package/dist/index.js.map +1 -1
- package/dist/util/endUserApplication.d.ts +1 -1
- package/dist/util/endUserApplication.d.ts.map +1 -1
- package/dist/util/userAuth.d.ts.map +1 -1
- package/dist/util/userProfile.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/util/endUserApplication.spec.ts +4 -3
- package/src/util/endUserApplication.ts +1 -1
- package/src/util/userAuth.spec.ts +6 -10
- package/src/util/userProfile.spec.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -81,6 +81,11 @@ function commonjsRequire () {
|
|
|
81
81
|
var enums = createCommonjsModule(function (module, exports) {
|
|
82
82
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
83
|
exports.AuthenticateEndUserApplicationResponseCode = exports.DecryptNativeCookieResponseCode = exports.IdpProtocol = exports.CheckOtpResponseCode = exports.CompleteUserSignUpResponseCode = exports.UserSignUpResponseCode = exports.ResetPasswordResponseCode = exports.SignInResponseCode = exports.IdpConfigurationResponseCode = exports.SignOutResponseCode = exports.TokenResponseCode = exports.UserAuthErrorCode = void 0;
|
|
84
|
+
/**
|
|
85
|
+
* This is the Error Type that the REST middleware will respond when there's an error
|
|
86
|
+
* from the User Service that does not belong to Token/SignOut or IDPConfiguration responses.
|
|
87
|
+
*/
|
|
88
|
+
var UserAuthErrorCode;
|
|
84
89
|
(function (UserAuthErrorCode) {
|
|
85
90
|
UserAuthErrorCode["AUTH_FLOW_ERROR"] = "AUTH_FLOW_ERROR";
|
|
86
91
|
UserAuthErrorCode["IDP_CONFIGURATION_ERROR"] = "IDP_CONFIGURATION_ERROR";
|
|
@@ -91,7 +96,11 @@ exports.AuthenticateEndUserApplicationResponseCode = exports.DecryptNativeCookie
|
|
|
91
96
|
UserAuthErrorCode["APPLICATION_NOT_ACTIVE"] = "APPLICATION_NOT_ACTIVE";
|
|
92
97
|
UserAuthErrorCode["INVALID_IDP_CONNECTION"] = "INVALID_IDP_CONNECTION";
|
|
93
98
|
UserAuthErrorCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
|
|
94
|
-
})(
|
|
99
|
+
})(UserAuthErrorCode || (exports.UserAuthErrorCode = UserAuthErrorCode = {}));
|
|
100
|
+
/**
|
|
101
|
+
* Token response code from User Service Auth API
|
|
102
|
+
*/
|
|
103
|
+
var TokenResponseCode;
|
|
95
104
|
(function (TokenResponseCode) {
|
|
96
105
|
TokenResponseCode["SUCCESS"] = "SUCCESS";
|
|
97
106
|
TokenResponseCode["NEEDS_LOGIN"] = "NEEDS_LOGIN";
|
|
@@ -100,12 +109,20 @@ exports.AuthenticateEndUserApplicationResponseCode = exports.DecryptNativeCookie
|
|
|
100
109
|
TokenResponseCode["AUTH_FLOW_ERROR"] = "AUTH_FLOW_ERROR";
|
|
101
110
|
TokenResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
|
|
102
111
|
TokenResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
|
|
103
|
-
})(
|
|
112
|
+
})(TokenResponseCode || (exports.TokenResponseCode = TokenResponseCode = {}));
|
|
113
|
+
/**
|
|
114
|
+
* Sign out response code from User Service Auth API
|
|
115
|
+
*/
|
|
116
|
+
var SignOutResponseCode;
|
|
104
117
|
(function (SignOutResponseCode) {
|
|
105
118
|
SignOutResponseCode["SUCCESS"] = "SUCCESS";
|
|
106
119
|
SignOutResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
|
|
107
120
|
SignOutResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
|
|
108
|
-
})(
|
|
121
|
+
})(SignOutResponseCode || (exports.SignOutResponseCode = SignOutResponseCode = {}));
|
|
122
|
+
/**
|
|
123
|
+
* IDP Configuration response code from User Service Auth API
|
|
124
|
+
*/
|
|
125
|
+
var IdpConfigurationResponseCode;
|
|
109
126
|
(function (IdpConfigurationResponseCode) {
|
|
110
127
|
IdpConfigurationResponseCode["SUCCESS"] = "SUCCESS";
|
|
111
128
|
IdpConfigurationResponseCode["APPLICATION_NOT_ACTIVE"] = "APPLICATION_NOT_ACTIVE";
|
|
@@ -113,7 +130,11 @@ exports.AuthenticateEndUserApplicationResponseCode = exports.DecryptNativeCookie
|
|
|
113
130
|
IdpConfigurationResponseCode["ACCOUNT_NOT_ACTIVE"] = "ACCOUNT_NOT_ACTIVE";
|
|
114
131
|
IdpConfigurationResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
|
|
115
132
|
IdpConfigurationResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
|
|
116
|
-
})(
|
|
133
|
+
})(IdpConfigurationResponseCode || (exports.IdpConfigurationResponseCode = IdpConfigurationResponseCode = {}));
|
|
134
|
+
/**
|
|
135
|
+
* Sign In With Credentials Response Code from User Service Auth API
|
|
136
|
+
*/
|
|
137
|
+
var SignInResponseCode;
|
|
117
138
|
(function (SignInResponseCode) {
|
|
118
139
|
SignInResponseCode["SUCCESS"] = "SUCCESS";
|
|
119
140
|
SignInResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
|
|
@@ -122,42 +143,71 @@ exports.AuthenticateEndUserApplicationResponseCode = exports.DecryptNativeCookie
|
|
|
122
143
|
SignInResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
|
|
123
144
|
SignInResponseCode["INVALID_IDP_CONNECTION"] = "INVALID_IDP_CONNECTION";
|
|
124
145
|
SignInResponseCode["APPLICATION_NOT_ACTIVE"] = "APPLICATION_NOT_ACTIVE";
|
|
125
|
-
})(
|
|
146
|
+
})(SignInResponseCode || (exports.SignInResponseCode = SignInResponseCode = {}));
|
|
147
|
+
/**
|
|
148
|
+
* Sign In With Credentials Password Reset/Complete Password Reset Code from User Service Auth API
|
|
149
|
+
*/
|
|
150
|
+
var ResetPasswordResponseCode;
|
|
126
151
|
(function (ResetPasswordResponseCode) {
|
|
127
152
|
ResetPasswordResponseCode["SUCCESS"] = "SUCCESS";
|
|
128
153
|
ResetPasswordResponseCode["ERROR"] = "ERROR";
|
|
129
154
|
ResetPasswordResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
|
|
130
|
-
})(
|
|
155
|
+
})(ResetPasswordResponseCode || (exports.ResetPasswordResponseCode = ResetPasswordResponseCode = {}));
|
|
156
|
+
/**
|
|
157
|
+
* Sign Up With Credential Response Code from User Service Auth API
|
|
158
|
+
*/
|
|
159
|
+
var UserSignUpResponseCode;
|
|
131
160
|
(function (UserSignUpResponseCode) {
|
|
132
161
|
UserSignUpResponseCode["SUCCESS"] = "SUCCESS";
|
|
133
162
|
UserSignUpResponseCode["ERROR"] = "ERROR";
|
|
134
163
|
UserSignUpResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
|
|
135
|
-
})(
|
|
164
|
+
})(UserSignUpResponseCode || (exports.UserSignUpResponseCode = UserSignUpResponseCode = {}));
|
|
165
|
+
/**
|
|
166
|
+
* Verify Sign Up With Credential Response Code from User Service Auth API
|
|
167
|
+
*/
|
|
168
|
+
var CompleteUserSignUpResponseCode;
|
|
136
169
|
(function (CompleteUserSignUpResponseCode) {
|
|
137
170
|
CompleteUserSignUpResponseCode["SUCCESS"] = "SUCCESS";
|
|
138
171
|
CompleteUserSignUpResponseCode["ERROR"] = "ERROR";
|
|
139
172
|
CompleteUserSignUpResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
|
|
140
|
-
})(
|
|
173
|
+
})(CompleteUserSignUpResponseCode || (exports.CompleteUserSignUpResponseCode = CompleteUserSignUpResponseCode = {}));
|
|
174
|
+
/**
|
|
175
|
+
* OTP Check Response Code from User Service Auth API
|
|
176
|
+
* This response type is used for both Sign Up OTP check and Reset Password OTP check.
|
|
177
|
+
*/
|
|
178
|
+
var CheckOtpResponseCode;
|
|
141
179
|
(function (CheckOtpResponseCode) {
|
|
142
180
|
CheckOtpResponseCode["SUCCESS"] = "SUCCESS";
|
|
143
181
|
CheckOtpResponseCode["ERROR"] = "ERROR";
|
|
144
182
|
CheckOtpResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
|
|
145
|
-
})(
|
|
183
|
+
})(CheckOtpResponseCode || (exports.CheckOtpResponseCode = CheckOtpResponseCode = {}));
|
|
184
|
+
/**
|
|
185
|
+
* IDP Protocol categories
|
|
186
|
+
*/
|
|
187
|
+
var IdpProtocol;
|
|
146
188
|
(function (IdpProtocol) {
|
|
147
189
|
IdpProtocol["OIDC"] = "OIDC";
|
|
148
190
|
IdpProtocol["OAUTH2"] = "OAUTH2";
|
|
149
191
|
IdpProtocol["DELEGATED"] = "DELEGATED";
|
|
150
|
-
})(
|
|
192
|
+
})(IdpProtocol || (exports.IdpProtocol = IdpProtocol = {}));
|
|
193
|
+
/**
|
|
194
|
+
* Response codes specific to Native Cookie Decryption.
|
|
195
|
+
*/
|
|
196
|
+
var DecryptNativeCookieResponseCode;
|
|
151
197
|
(function (DecryptNativeCookieResponseCode) {
|
|
152
198
|
DecryptNativeCookieResponseCode["SUCCESS"] = "SUCCESS";
|
|
153
199
|
DecryptNativeCookieResponseCode["COOKIE_DECRYPTION_FAILED"] = "COOKIE_DECRYPTION_FAILED";
|
|
154
|
-
})(
|
|
200
|
+
})(DecryptNativeCookieResponseCode || (exports.DecryptNativeCookieResponseCode = DecryptNativeCookieResponseCode = {}));
|
|
201
|
+
/**
|
|
202
|
+
* Response codes specific to End User Application Token Generation
|
|
203
|
+
*/
|
|
204
|
+
var AuthenticateEndUserApplicationResponseCode;
|
|
155
205
|
(function (AuthenticateEndUserApplicationResponseCode) {
|
|
156
206
|
AuthenticateEndUserApplicationResponseCode["SUCCESS"] = "SUCCESS";
|
|
157
207
|
AuthenticateEndUserApplicationResponseCode["APPLICATION_NOT_FOUND"] = "APPLICATION_NOT_FOUND";
|
|
158
208
|
AuthenticateEndUserApplicationResponseCode["APPLICATION_NOT_ENABLED"] = "APPLICATION_NOT_ENABLED";
|
|
159
209
|
AuthenticateEndUserApplicationResponseCode["END_USER_APP_TOKEN_GENERATION_ERROR"] = "END_USER_APP_TOKEN_GENERATION_ERROR";
|
|
160
|
-
})(
|
|
210
|
+
})(AuthenticateEndUserApplicationResponseCode || (exports.AuthenticateEndUserApplicationResponseCode = AuthenticateEndUserApplicationResponseCode = {}));
|
|
161
211
|
|
|
162
212
|
});
|
|
163
213
|
|
|
@@ -1870,8 +1920,8 @@ const InitiateEndUserPasswordResetDocument = { "kind": "Document", "definitions"
|
|
|
1870
1920
|
const CheckPasswordResetOtpDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CheckPasswordResetOtp" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "CheckEndUserPasswordResetOtpInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "checkEndUserPasswordResetOtp" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "isOtpValid" } }] } }] } }] };
|
|
1871
1921
|
const CompleteEndUserPasswordResetDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "CompleteEndUserPasswordReset" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "CompleteEndUserPasswordResetInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "completeEndUserPasswordReset" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "idpUserId" } }] } }] } }] };
|
|
1872
1922
|
|
|
1873
|
-
function invokeUserAuthMethod(
|
|
1874
|
-
return __awaiter(this,
|
|
1923
|
+
function invokeUserAuthMethod(method_1, userAuthConfig_1) {
|
|
1924
|
+
return __awaiter(this, arguments, void 0, function* (method, userAuthConfig, isRootLevel = false) {
|
|
1875
1925
|
const endpointUrl = new URL(`${userAuthConfig.tenantId}/${userAuthConfig.environmentId}/${userAuthConfig.applicationId}/${method}`, userAuthConfig.userAuthBaseUrl);
|
|
1876
1926
|
const rootEndpointUrl = new URL(`${method}`, userAuthConfig.userAuthBaseUrl);
|
|
1877
1927
|
return (yield fetch(isRootLevel ? rootEndpointUrl.href : endpointUrl.href, {
|
|
@@ -2166,7 +2216,7 @@ const getNativeAuthUrl = (userAuthConfig, idpConnectionId, returnUrl, encryption
|
|
|
2166
2216
|
* Returns a new user token by invoking the User Auth API
|
|
2167
2217
|
*/
|
|
2168
2218
|
const fetchUserToken = (userAuthConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2169
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s
|
|
2219
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
2170
2220
|
try {
|
|
2171
2221
|
const tokenResponse = yield invokeUserAuthMethod('token', userAuthConfig);
|
|
2172
2222
|
if (tokenResponse.code !== dist.TokenResponseCode.SUCCESS) {
|
|
@@ -2174,23 +2224,23 @@ const fetchUserToken = (userAuthConfig) => __awaiter(void 0, void 0, void 0, fun
|
|
|
2174
2224
|
}
|
|
2175
2225
|
else {
|
|
2176
2226
|
return {
|
|
2177
|
-
tenantId: (
|
|
2178
|
-
environmentId: (
|
|
2179
|
-
applicationId: (
|
|
2180
|
-
userId: (
|
|
2181
|
-
profileId: (
|
|
2182
|
-
email: (
|
|
2183
|
-
name: (
|
|
2227
|
+
tenantId: (_a = tokenResponse.tenantId) !== null && _a !== void 0 ? _a : '',
|
|
2228
|
+
environmentId: (_b = tokenResponse.environmentId) !== null && _b !== void 0 ? _b : '',
|
|
2229
|
+
applicationId: (_c = tokenResponse.applicationId) !== null && _c !== void 0 ? _c : '',
|
|
2230
|
+
userId: (_e = (_d = tokenResponse.user) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : '',
|
|
2231
|
+
profileId: (_g = (_f = tokenResponse.user) === null || _f === void 0 ? void 0 : _f.profileId) !== null && _g !== void 0 ? _g : '',
|
|
2232
|
+
email: (_j = (_h = tokenResponse.user) === null || _h === void 0 ? void 0 : _h.email) !== null && _j !== void 0 ? _j : null,
|
|
2233
|
+
name: (_l = (_k = tokenResponse.user) === null || _k === void 0 ? void 0 : _k.name) !== null && _l !== void 0 ? _l : null,
|
|
2184
2234
|
extensions: tokenResponse.extensions,
|
|
2185
|
-
accessToken: (
|
|
2186
|
-
expiresInSeconds: (
|
|
2187
|
-
expiresAt: (
|
|
2235
|
+
accessToken: (_o = (_m = tokenResponse.user) === null || _m === void 0 ? void 0 : _m.token.accessToken) !== null && _o !== void 0 ? _o : '',
|
|
2236
|
+
expiresInSeconds: (_q = (_p = tokenResponse.user) === null || _p === void 0 ? void 0 : _p.token.expiresInSeconds) !== null && _q !== void 0 ? _q : 0,
|
|
2237
|
+
expiresAt: (_r = tokenResponse.user) === null || _r === void 0 ? void 0 : _r.token.expiresAt,
|
|
2188
2238
|
};
|
|
2189
2239
|
}
|
|
2190
2240
|
}
|
|
2191
2241
|
catch (e) {
|
|
2192
2242
|
const error = ensureError(e);
|
|
2193
|
-
throw new UserAuthError(error.message, (
|
|
2243
|
+
throw new UserAuthError(error.message, (_s = error.code) !== null && _s !== void 0 ? _s : dist.TokenResponseCode.INTERNAL_SERVER_ERROR);
|
|
2194
2244
|
}
|
|
2195
2245
|
});
|
|
2196
2246
|
const logoutUser = (userAuthConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -2893,10 +2943,10 @@ class UserServiceClient {
|
|
|
2893
2943
|
* When in need of a token, please call this method to get a new token.
|
|
2894
2944
|
*/
|
|
2895
2945
|
this.getToken = () => __awaiter(this, void 0, void 0, function* () {
|
|
2896
|
-
var
|
|
2946
|
+
var _a;
|
|
2897
2947
|
// Set token response to null if the token has expired.
|
|
2898
2948
|
if (this.tokenResponse !== null &&
|
|
2899
|
-
(((
|
|
2949
|
+
(((_a = this.tokenResponse.userToken) === null || _a === void 0 ? void 0 : _a.expiresAt) === undefined ||
|
|
2900
2950
|
this.tokenResponse.userToken.expiresAt <= new Date(Date.now()))) {
|
|
2901
2951
|
this.tokenResponse = null;
|
|
2902
2952
|
}
|