@axinom/mosaic-user-auth 0.5.4 → 0.5.5

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/index.js CHANGED
@@ -4,6 +4,27 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
 
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
26
+
27
+ exports.TokenRenewalMethod = void 0;
7
28
  (function (TokenRenewalMethod) {
8
29
  /**
9
30
  * The token is continuously renewed just before expiry.
@@ -16,7 +37,7 @@ var React = require('react');
16
37
  TokenRenewalMethod[TokenRenewalMethod["ON_DEMAND"] = 1] = "ON_DEMAND";
17
38
  })(exports.TokenRenewalMethod || (exports.TokenRenewalMethod = {}));
18
39
 
19
- /*! *****************************************************************************
40
+ /******************************************************************************
20
41
  Copyright (c) Microsoft Corporation.
21
42
 
22
43
  Permission to use, copy, modify, and/or distribute this software for any
@@ -59,43 +80,32 @@ function commonjsRequire () {
59
80
 
60
81
  var enums = createCommonjsModule(function (module, exports) {
61
82
  Object.defineProperty(exports, "__esModule", { value: true });
62
- exports.DecryptNativeCookieResponseCode = exports.IdpProtocol = exports.CheckOtpResponseCode = exports.CompleteUserSignUpResponseCode = exports.UserSignUpResponseCode = exports.ResetPasswordResponseCode = exports.SignInResponseCode = exports.IdpConfigurationResponseCode = exports.SignOutResponseCode = exports.TokenResponseCode = exports.UserAuthErrorCode = void 0;
63
- /**
64
- * This is the Error Type that the REST middleware will respond when there's an error
65
- * from the User Service that does not belong to Token/SignOut or IDPConfiguration responses.
66
- */
67
- var UserAuthErrorCode;
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;
68
84
  (function (UserAuthErrorCode) {
69
85
  UserAuthErrorCode["AUTH_FLOW_ERROR"] = "AUTH_FLOW_ERROR";
70
86
  UserAuthErrorCode["IDP_CONFIGURATION_ERROR"] = "IDP_CONFIGURATION_ERROR";
71
87
  UserAuthErrorCode["BAD_REQUEST"] = "BAD_REQUEST";
88
+ UserAuthErrorCode["ACCOUNT_NOT_ACTIVE"] = "ACCOUNT_NOT_ACTIVE";
89
+ UserAuthErrorCode["INVALID_USER"] = "INVALID_USER";
90
+ UserAuthErrorCode["INVALID_APPLICATION"] = "INVALID_APPLICATION";
91
+ UserAuthErrorCode["APPLICATION_NOT_ACTIVE"] = "APPLICATION_NOT_ACTIVE";
92
+ UserAuthErrorCode["INVALID_IDP_CONNECTION"] = "INVALID_IDP_CONNECTION";
72
93
  UserAuthErrorCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
73
- })(UserAuthErrorCode = exports.UserAuthErrorCode || (exports.UserAuthErrorCode = {}));
74
- /**
75
- * Token response code from User Service Auth API
76
- */
77
- var TokenResponseCode;
94
+ })(exports.UserAuthErrorCode || (exports.UserAuthErrorCode = {}));
78
95
  (function (TokenResponseCode) {
79
96
  TokenResponseCode["SUCCESS"] = "SUCCESS";
80
97
  TokenResponseCode["NEEDS_LOGIN"] = "NEEDS_LOGIN";
98
+ TokenResponseCode["USER_NOT_FOUND"] = "USER_NOT_FOUND";
81
99
  TokenResponseCode["ACCOUNT_NOT_ACTIVE"] = "ACCOUNT_NOT_ACTIVE";
82
100
  TokenResponseCode["AUTH_FLOW_ERROR"] = "AUTH_FLOW_ERROR";
83
101
  TokenResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
84
102
  TokenResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
85
- })(TokenResponseCode = exports.TokenResponseCode || (exports.TokenResponseCode = {}));
86
- /**
87
- * Sign out response code from User Service Auth API
88
- */
89
- var SignOutResponseCode;
103
+ })(exports.TokenResponseCode || (exports.TokenResponseCode = {}));
90
104
  (function (SignOutResponseCode) {
91
105
  SignOutResponseCode["SUCCESS"] = "SUCCESS";
92
106
  SignOutResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
93
107
  SignOutResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
94
- })(SignOutResponseCode = exports.SignOutResponseCode || (exports.SignOutResponseCode = {}));
95
- /**
96
- * IDP Configuration response code from User Service Auth API
97
- */
98
- var IdpConfigurationResponseCode;
108
+ })(exports.SignOutResponseCode || (exports.SignOutResponseCode = {}));
99
109
  (function (IdpConfigurationResponseCode) {
100
110
  IdpConfigurationResponseCode["SUCCESS"] = "SUCCESS";
101
111
  IdpConfigurationResponseCode["APPLICATION_NOT_ACTIVE"] = "APPLICATION_NOT_ACTIVE";
@@ -103,73 +113,51 @@ var IdpConfigurationResponseCode;
103
113
  IdpConfigurationResponseCode["ACCOUNT_NOT_ACTIVE"] = "ACCOUNT_NOT_ACTIVE";
104
114
  IdpConfigurationResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
105
115
  IdpConfigurationResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
106
- })(IdpConfigurationResponseCode = exports.IdpConfigurationResponseCode || (exports.IdpConfigurationResponseCode = {}));
107
- /**
108
- * Sign In With Credentials Response Code from User Service Auth API
109
- */
110
- var SignInResponseCode;
116
+ })(exports.IdpConfigurationResponseCode || (exports.IdpConfigurationResponseCode = {}));
111
117
  (function (SignInResponseCode) {
112
118
  SignInResponseCode["SUCCESS"] = "SUCCESS";
113
119
  SignInResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
114
- SignInResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
115
120
  SignInResponseCode["AUTH_FLOW_ERROR"] = "AUTH_FLOW_ERROR";
116
121
  SignInResponseCode["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
117
122
  SignInResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
118
- })(SignInResponseCode = exports.SignInResponseCode || (exports.SignInResponseCode = {}));
119
- /**
120
- * Sign In With Credentials Password Reset/Complete Password Reset Code from User Service Auth API
121
- */
122
- var ResetPasswordResponseCode;
123
+ SignInResponseCode["INVALID_IDP_CONNECTION"] = "INVALID_IDP_CONNECTION";
124
+ SignInResponseCode["APPLICATION_NOT_ACTIVE"] = "APPLICATION_NOT_ACTIVE";
125
+ })(exports.SignInResponseCode || (exports.SignInResponseCode = {}));
123
126
  (function (ResetPasswordResponseCode) {
124
127
  ResetPasswordResponseCode["SUCCESS"] = "SUCCESS";
125
128
  ResetPasswordResponseCode["ERROR"] = "ERROR";
126
129
  ResetPasswordResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
127
- })(ResetPasswordResponseCode = exports.ResetPasswordResponseCode || (exports.ResetPasswordResponseCode = {}));
128
- /**
129
- * Sign Up With Credential Response Code from User Service Auth API
130
- */
131
- var UserSignUpResponseCode;
130
+ })(exports.ResetPasswordResponseCode || (exports.ResetPasswordResponseCode = {}));
132
131
  (function (UserSignUpResponseCode) {
133
132
  UserSignUpResponseCode["SUCCESS"] = "SUCCESS";
134
133
  UserSignUpResponseCode["ERROR"] = "ERROR";
135
134
  UserSignUpResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
136
- })(UserSignUpResponseCode = exports.UserSignUpResponseCode || (exports.UserSignUpResponseCode = {}));
137
- /**
138
- * Verify Sign Up With Credential Response Code from User Service Auth API
139
- */
140
- var CompleteUserSignUpResponseCode;
135
+ })(exports.UserSignUpResponseCode || (exports.UserSignUpResponseCode = {}));
141
136
  (function (CompleteUserSignUpResponseCode) {
142
137
  CompleteUserSignUpResponseCode["SUCCESS"] = "SUCCESS";
143
138
  CompleteUserSignUpResponseCode["ERROR"] = "ERROR";
144
139
  CompleteUserSignUpResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
145
- })(CompleteUserSignUpResponseCode = exports.CompleteUserSignUpResponseCode || (exports.CompleteUserSignUpResponseCode = {}));
146
- /**
147
- * OTP Check Response Code from User Service Auth API
148
- * This response type is used for both Sign Up OTP check and Reset Password OTP check.
149
- */
150
- var CheckOtpResponseCode;
140
+ })(exports.CompleteUserSignUpResponseCode || (exports.CompleteUserSignUpResponseCode = {}));
151
141
  (function (CheckOtpResponseCode) {
152
142
  CheckOtpResponseCode["SUCCESS"] = "SUCCESS";
153
143
  CheckOtpResponseCode["ERROR"] = "ERROR";
154
144
  CheckOtpResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
155
- })(CheckOtpResponseCode = exports.CheckOtpResponseCode || (exports.CheckOtpResponseCode = {}));
156
- /**
157
- * IDP Protocol categories
158
- */
159
- var IdpProtocol;
145
+ })(exports.CheckOtpResponseCode || (exports.CheckOtpResponseCode = {}));
160
146
  (function (IdpProtocol) {
161
147
  IdpProtocol["OIDC"] = "OIDC";
162
148
  IdpProtocol["OAUTH2"] = "OAUTH2";
163
149
  IdpProtocol["DELEGATED"] = "DELEGATED";
164
- })(IdpProtocol = exports.IdpProtocol || (exports.IdpProtocol = {}));
165
- /**
166
- * Response codes specific to Native Cookie Decryption.
167
- */
168
- var DecryptNativeCookieResponseCode;
150
+ })(exports.IdpProtocol || (exports.IdpProtocol = {}));
169
151
  (function (DecryptNativeCookieResponseCode) {
170
152
  DecryptNativeCookieResponseCode["SUCCESS"] = "SUCCESS";
171
153
  DecryptNativeCookieResponseCode["COOKIE_DECRYPTION_FAILED"] = "COOKIE_DECRYPTION_FAILED";
172
- })(DecryptNativeCookieResponseCode = exports.DecryptNativeCookieResponseCode || (exports.DecryptNativeCookieResponseCode = {}));
154
+ })(exports.DecryptNativeCookieResponseCode || (exports.DecryptNativeCookieResponseCode = {}));
155
+ (function (AuthenticateEndUserApplicationResponseCode) {
156
+ AuthenticateEndUserApplicationResponseCode["SUCCESS"] = "SUCCESS";
157
+ AuthenticateEndUserApplicationResponseCode["APPLICATION_NOT_FOUND"] = "APPLICATION_NOT_FOUND";
158
+ AuthenticateEndUserApplicationResponseCode["APPLICATION_NOT_ENABLED"] = "APPLICATION_NOT_ENABLED";
159
+ AuthenticateEndUserApplicationResponseCode["END_USER_APP_TOKEN_GENERATION_ERROR"] = "END_USER_APP_TOKEN_GENERATION_ERROR";
160
+ })(exports.AuthenticateEndUserApplicationResponseCode || (exports.AuthenticateEndUserApplicationResponseCode = {}));
173
161
 
174
162
  });
175
163
 
@@ -231,7 +219,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
231
219
  var dist = createCommonjsModule(function (module, exports) {
232
220
  var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
233
221
  if (k2 === undefined) k2 = k;
234
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
222
+ var desc = Object.getOwnPropertyDescriptor(m, k);
223
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
224
+ desc = { enumerable: true, get: function() { return m[k]; } };
225
+ }
226
+ Object.defineProperty(o, k2, desc);
235
227
  }) : (function(o, m, k, k2) {
236
228
  if (k2 === undefined) k2 = k;
237
229
  o[k2] = m[k];
@@ -246,6 +238,16 @@ __exportStar(types, exports);
246
238
 
247
239
  });
248
240
 
241
+ /**
242
+ * Class mimicking the minimal structure of a MosaicError.
243
+ * This class is defined here to avoid the @axinom/service-common dependency.
244
+ */
245
+ class UserAuthError extends Error {
246
+ constructor(message, code) {
247
+ super(message);
248
+ this.code = code;
249
+ }
250
+ }
249
251
  /**
250
252
  * Type assertion function that throws an error if provided parameter is not an instance of an Error, and asserts value to an Error type if no error is thrown.
251
253
  * This is a copy of assertError() in @axinom/service-common to avoid dependencies.
@@ -258,6 +260,7 @@ const assertError = (error) => {
258
260
 
259
261
  // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
260
262
  var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
263
+ var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
261
264
 
262
265
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
263
266
  var MAX_ARRAY_LENGTH = 10;
@@ -356,7 +359,7 @@ function formatArray(array, seenValues) {
356
359
  }
357
360
 
358
361
  function getCustomFn(object) {
359
- var customInspectFn = object[String(nodejsCustomInspectSymbol)];
362
+ var customInspectFn = object[String(nodejsCustomInspectSymbol$1)];
360
363
 
361
364
  if (typeof customInspectFn === 'function') {
362
365
  return customInspectFn;
@@ -398,8 +401,8 @@ function defineInspect(classObject) {
398
401
  typeof fn === 'function' || invariant(0);
399
402
  classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
400
403
 
401
- if (nodejsCustomInspectSymbol) {
402
- classObject.prototype[nodejsCustomInspectSymbol] = fn;
404
+ if (nodejsCustomInspectSymbol$1) {
405
+ classObject.prototype[nodejsCustomInspectSymbol$1] = fn;
403
406
  }
404
407
  }
405
408
 
@@ -1287,7 +1290,7 @@ var ApplicationsOrderBy;
1287
1290
  ApplicationsOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
1288
1291
  })(ApplicationsOrderBy || (ApplicationsOrderBy = {}));
1289
1292
  /** Exposes all error codes and messages for errors that a service requests can throw. In some cases, messages that are actually thrown can be different, since they can include more details or a single code can used for different errors of the same type. */
1290
- var ErrorCodesEnum;
1293
+ var ErrorCodesEnum$1;
1291
1294
  (function (ErrorCodesEnum) {
1292
1295
  /** Access Token has expired. */
1293
1296
  ErrorCodesEnum["ACCESS_TOKEN_EXPIRED"] = "ACCESS_TOKEN_EXPIRED";
@@ -1401,7 +1404,7 @@ var ErrorCodesEnum;
1401
1404
  ErrorCodesEnum["TOKEN_ENRICHMENT_EXCEEDS_LIMIT"] = "TOKEN_ENRICHMENT_EXCEEDS_LIMIT";
1402
1405
  /** Retrieving user information from Access Token Enrichment Webhook failed. */
1403
1406
  ErrorCodesEnum["TOKEN_ENRICHMENT_WEBHOOK_FAILURE"] = "TOKEN_ENRICHMENT_WEBHOOK_FAILURE";
1404
- /** An unhandled database-related has occurred. Please contact the service support. */
1407
+ /** An unhandled database-related error has occurred. Please contact the service support. */
1405
1408
  ErrorCodesEnum["UNHANDLED_DATABASE_ERROR"] = "UNHANDLED_DATABASE_ERROR";
1406
1409
  /** An unhandled error has occurred. Please contact the service support. */
1407
1410
  ErrorCodesEnum["UNHANDLED_ERROR"] = "UNHANDLED_ERROR";
@@ -1415,7 +1418,7 @@ var ErrorCodesEnum;
1415
1418
  ErrorCodesEnum["USER_STORE_SHOULD_NOT_BE_EMPTY"] = "USER_STORE_SHOULD_NOT_BE_EMPTY";
1416
1419
  /** Websocket not found in ExtendedGraphQLContext. This is a development time issue. A reference to the websocket must be included in Postgraphile build options. */
1417
1420
  ErrorCodesEnum["WEBSOCKET_NOT_FOUND"] = "WEBSOCKET_NOT_FOUND";
1418
- })(ErrorCodesEnum || (ErrorCodesEnum = {}));
1421
+ })(ErrorCodesEnum$1 || (ErrorCodesEnum$1 = {}));
1419
1422
  /** Methods to use when ordering `IdpConnection`. */
1420
1423
  var IdpConnectionsOrderBy;
1421
1424
  (function (IdpConnectionsOrderBy) {
@@ -1546,7 +1549,7 @@ var UserIdpDataOrderBy;
1546
1549
  UserIdpDataOrderBy["USER_ID_DESC"] = "USER_ID_DESC";
1547
1550
  })(UserIdpDataOrderBy || (UserIdpDataOrderBy = {}));
1548
1551
  /** Methods to use when ordering `UserProfile`. */
1549
- var UserProfilesOrderBy;
1552
+ var UserProfilesOrderBy$1;
1550
1553
  (function (UserProfilesOrderBy) {
1551
1554
  UserProfilesOrderBy["CREATED_DATE_ASC"] = "CREATED_DATE_ASC";
1552
1555
  UserProfilesOrderBy["CREATED_DATE_DESC"] = "CREATED_DATE_DESC";
@@ -1575,9 +1578,9 @@ var UserProfilesOrderBy;
1575
1578
  UserProfilesOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
1576
1579
  UserProfilesOrderBy["USER_ID_ASC"] = "USER_ID_ASC";
1577
1580
  UserProfilesOrderBy["USER_ID_DESC"] = "USER_ID_DESC";
1578
- })(UserProfilesOrderBy || (UserProfilesOrderBy = {}));
1581
+ })(UserProfilesOrderBy$1 || (UserProfilesOrderBy$1 = {}));
1579
1582
  /** Methods to use when ordering `User`. */
1580
- var UsersOrderBy;
1583
+ var UsersOrderBy$1;
1581
1584
  (function (UsersOrderBy) {
1582
1585
  UsersOrderBy["CREATED_DATE_ASC"] = "CREATED_DATE_ASC";
1583
1586
  UsersOrderBy["CREATED_DATE_DESC"] = "CREATED_DATE_DESC";
@@ -1608,7 +1611,7 @@ var UsersOrderBy;
1608
1611
  UsersOrderBy["UPDATED_DATE_DESC"] = "UPDATED_DATE_DESC";
1609
1612
  UsersOrderBy["UPDATED_USER_ASC"] = "UPDATED_USER_ASC";
1610
1613
  UsersOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
1611
- })(UsersOrderBy || (UsersOrderBy = {}));
1614
+ })(UsersOrderBy$1 || (UsersOrderBy$1 = {}));
1612
1615
  const AuthenticateEndUserApplicationDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "AuthenticateEndUserApplication" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "AuthenticateEndUserApplicationInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "authenticateEndUserApplication" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "accessToken" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "expiresInSeconds" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "tokenType" }, "arguments": [], "directives": [] }] } }] } }] };
1613
1616
  const DecryptNativeCookieDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "DecryptNativeCookie" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "DecryptWithKeyAesInput" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "decryptWithKeyAes" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "input" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "input" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "decryptedValue" }, "arguments": [], "directives": [] }] } }] } }] };
1614
1617
 
@@ -1635,12 +1638,13 @@ const authenticateEndUserApplication = (authenticateEndUserApplicationInput, use
1635
1638
  })).json();
1636
1639
  if (authenticateEndUserApplicationResponse.errors !== undefined) {
1637
1640
  return {
1638
- code: 'ERROR',
1641
+ code: authenticateEndUserApplicationResponse.errors[0]
1642
+ .code,
1639
1643
  message: authenticateEndUserApplicationResponse.errors[0].message,
1640
1644
  };
1641
1645
  }
1642
1646
  return {
1643
- code: 'SUCCESS',
1647
+ code: dist.AuthenticateEndUserApplicationResponseCode.SUCCESS,
1644
1648
  endUserApplicationToken: {
1645
1649
  accessToken: authenticateEndUserApplicationResponse.data
1646
1650
  .authenticateEndUserApplication.accessToken,
@@ -2075,25 +2079,31 @@ const getNativeAuthUrl = (userAuthConfig, idpConnectionId, returnUrl, encryption
2075
2079
  * Returns a new user token by invoking the User Auth API
2076
2080
  */
2077
2081
  const fetchUserToken = (userAuthConfig) => __awaiter(void 0, void 0, void 0, function* () {
2078
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
2079
- const tokenResponse = yield invokeUserAuthMethod('token', userAuthConfig);
2080
- if (tokenResponse.code !== dist.TokenResponseCode.SUCCESS) {
2081
- throw Error(tokenResponse.message);
2082
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
2083
+ try {
2084
+ const tokenResponse = yield invokeUserAuthMethod('token', userAuthConfig);
2085
+ if (tokenResponse.code !== dist.TokenResponseCode.SUCCESS) {
2086
+ throw new UserAuthError(tokenResponse.message, tokenResponse.code);
2087
+ }
2088
+ else {
2089
+ return {
2090
+ tenantId: (_c = tokenResponse.tenantId) !== null && _c !== void 0 ? _c : '',
2091
+ environmentId: (_d = tokenResponse.environmentId) !== null && _d !== void 0 ? _d : '',
2092
+ applicationId: (_e = tokenResponse.applicationId) !== null && _e !== void 0 ? _e : '',
2093
+ userId: (_g = (_f = tokenResponse.user) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : '',
2094
+ profileId: (_j = (_h = tokenResponse.user) === null || _h === void 0 ? void 0 : _h.profileId) !== null && _j !== void 0 ? _j : '',
2095
+ email: (_l = (_k = tokenResponse.user) === null || _k === void 0 ? void 0 : _k.email) !== null && _l !== void 0 ? _l : null,
2096
+ name: (_o = (_m = tokenResponse.user) === null || _m === void 0 ? void 0 : _m.name) !== null && _o !== void 0 ? _o : null,
2097
+ extensions: tokenResponse.extensions,
2098
+ accessToken: (_q = (_p = tokenResponse.user) === null || _p === void 0 ? void 0 : _p.token.accessToken) !== null && _q !== void 0 ? _q : '',
2099
+ expiresInSeconds: (_s = (_r = tokenResponse.user) === null || _r === void 0 ? void 0 : _r.token.expiresInSeconds) !== null && _s !== void 0 ? _s : 0,
2100
+ expiresAt: (_t = tokenResponse.user) === null || _t === void 0 ? void 0 : _t.token.expiresAt,
2101
+ };
2102
+ }
2082
2103
  }
2083
- else {
2084
- return {
2085
- tenantId: (_c = tokenResponse.tenantId) !== null && _c !== void 0 ? _c : '',
2086
- environmentId: (_d = tokenResponse.environmentId) !== null && _d !== void 0 ? _d : '',
2087
- applicationId: (_e = tokenResponse.applicationId) !== null && _e !== void 0 ? _e : '',
2088
- userId: (_g = (_f = tokenResponse.user) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : '',
2089
- profileId: (_j = (_h = tokenResponse.user) === null || _h === void 0 ? void 0 : _h.profileId) !== null && _j !== void 0 ? _j : '',
2090
- email: (_l = (_k = tokenResponse.user) === null || _k === void 0 ? void 0 : _k.email) !== null && _l !== void 0 ? _l : null,
2091
- name: (_o = (_m = tokenResponse.user) === null || _m === void 0 ? void 0 : _m.name) !== null && _o !== void 0 ? _o : null,
2092
- extensions: tokenResponse.extensions,
2093
- accessToken: (_q = (_p = tokenResponse.user) === null || _p === void 0 ? void 0 : _p.token.accessToken) !== null && _q !== void 0 ? _q : '',
2094
- expiresInSeconds: (_s = (_r = tokenResponse.user) === null || _r === void 0 ? void 0 : _r.token.expiresInSeconds) !== null && _s !== void 0 ? _s : 0,
2095
- expiresAt: (_t = tokenResponse.user) === null || _t === void 0 ? void 0 : _t.token.expiresAt,
2096
- };
2104
+ catch (error) {
2105
+ assertError(error);
2106
+ throw new UserAuthError(error.message, (_u = error.code) !== null && _u !== void 0 ? _u : dist.TokenResponseCode.INTERNAL_SERVER_ERROR);
2097
2107
  }
2098
2108
  });
2099
2109
  const logoutUser = (userAuthConfig) => __awaiter(void 0, void 0, void 0, function* () {
@@ -2138,7 +2148,7 @@ const decryptNativeCookie = (encryptedCookie, key, userServiceManagementEndpoint
2138
2148
  });
2139
2149
 
2140
2150
  /** Exposes all error codes and messages for errors that a service requests can throw. In some cases, messages that are actually thrown can be different, since they can include more details or a single code can used for different errors of the same type. */
2141
- var ErrorCodesEnum$1;
2151
+ var ErrorCodesEnum;
2142
2152
  (function (ErrorCodesEnum) {
2143
2153
  /** Access Token has expired. */
2144
2154
  ErrorCodesEnum["ACCESS_TOKEN_EXPIRED"] = "ACCESS_TOKEN_EXPIRED";
@@ -2220,7 +2230,7 @@ var ErrorCodesEnum$1;
2220
2230
  ErrorCodesEnum["SIGNING_KEY_NOT_FOUND"] = "SIGNING_KEY_NOT_FOUND";
2221
2231
  /** An application startup error has occurred. The actual message will have more information. */
2222
2232
  ErrorCodesEnum["STARTUP_ERROR"] = "STARTUP_ERROR";
2223
- /** An unhandled database-related has occurred. Please contact the service support. */
2233
+ /** An unhandled database-related error has occurred. Please contact the service support. */
2224
2234
  ErrorCodesEnum["UNHANDLED_DATABASE_ERROR"] = "UNHANDLED_DATABASE_ERROR";
2225
2235
  /** An unhandled error has occurred. Please contact the service support. */
2226
2236
  ErrorCodesEnum["UNHANDLED_ERROR"] = "UNHANDLED_ERROR";
@@ -2232,9 +2242,9 @@ var ErrorCodesEnum$1;
2232
2242
  ErrorCodesEnum["USER_SERVICE_NOT_ACCESSIBLE"] = "USER_SERVICE_NOT_ACCESSIBLE";
2233
2243
  /** Websocket not found in ExtendedGraphQLContext. This is a development time issue. A reference to the websocket must be included in Postgraphile build options. */
2234
2244
  ErrorCodesEnum["WEBSOCKET_NOT_FOUND"] = "WEBSOCKET_NOT_FOUND";
2235
- })(ErrorCodesEnum$1 || (ErrorCodesEnum$1 = {}));
2245
+ })(ErrorCodesEnum || (ErrorCodesEnum = {}));
2236
2246
  /** Methods to use when ordering `UserProfile`. */
2237
- var UserProfilesOrderBy$1;
2247
+ var UserProfilesOrderBy;
2238
2248
  (function (UserProfilesOrderBy) {
2239
2249
  UserProfilesOrderBy["CREATED_DATE_ASC"] = "CREATED_DATE_ASC";
2240
2250
  UserProfilesOrderBy["CREATED_DATE_DESC"] = "CREATED_DATE_DESC";
@@ -2261,9 +2271,9 @@ var UserProfilesOrderBy$1;
2261
2271
  UserProfilesOrderBy["UPDATED_DATE_DESC"] = "UPDATED_DATE_DESC";
2262
2272
  UserProfilesOrderBy["UPDATED_USER_ASC"] = "UPDATED_USER_ASC";
2263
2273
  UserProfilesOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
2264
- })(UserProfilesOrderBy$1 || (UserProfilesOrderBy$1 = {}));
2274
+ })(UserProfilesOrderBy || (UserProfilesOrderBy = {}));
2265
2275
  /** Methods to use when ordering `User`. */
2266
- var UsersOrderBy$1;
2276
+ var UsersOrderBy;
2267
2277
  (function (UsersOrderBy) {
2268
2278
  UsersOrderBy["CREATED_DATE_ASC"] = "CREATED_DATE_ASC";
2269
2279
  UsersOrderBy["CREATED_DATE_DESC"] = "CREATED_DATE_DESC";
@@ -2294,7 +2304,7 @@ var UsersOrderBy$1;
2294
2304
  UsersOrderBy["UPDATED_DATE_DESC"] = "UPDATED_DATE_DESC";
2295
2305
  UsersOrderBy["UPDATED_USER_ASC"] = "UPDATED_USER_ASC";
2296
2306
  UsersOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
2297
- })(UsersOrderBy$1 || (UsersOrderBy$1 = {}));
2307
+ })(UsersOrderBy || (UsersOrderBy = {}));
2298
2308
  const SetActiveProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "mutation", "name": { "kind": "Name", "value": "SetActiveProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "UUID" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "setActiveProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "profileId" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "profilePictureUrl" }, "arguments": [], "directives": [] }] } }] } }] };
2299
2309
  const GetUserProfileDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetUserProfile" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "UUID" } } }, "directives": [] }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfile" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "profileId" } } }], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "profilePictureUrl" }, "arguments": [], "directives": [] }] } }] } }] };
2300
2310
  const GetUserProfilesDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetUserProfiles" }, "variableDefinitions": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "userProfiles" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "nodes" }, "arguments": [], "directives": [], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "displayName" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "defaultProfile" }, "arguments": [], "directives": [] }, { "kind": "Field", "name": { "kind": "Name", "value": "profilePictureUrl" }, "arguments": [], "directives": [] }] } }] } }] } }] };
@@ -2546,7 +2556,7 @@ class UserServiceClient {
2546
2556
  const userToken = yield fetchUserToken(this.userAuthConfig);
2547
2557
  const userProfileResponse = yield getUserProfile(this.userServiceConfig.userServiceBaseUrl, userToken.accessToken, userToken.profileId);
2548
2558
  return {
2549
- code: 'SUCCESS',
2559
+ code: dist.TokenResponseCode.SUCCESS,
2550
2560
  userToken,
2551
2561
  userProfile: userProfileResponse.userProfile,
2552
2562
  nextTokenRenewalAt: new Date(Date.now() +
@@ -2556,9 +2566,8 @@ class UserServiceClient {
2556
2566
  };
2557
2567
  }
2558
2568
  catch (error) {
2559
- assertError(error);
2560
2569
  return {
2561
- code: 'ERROR',
2570
+ code: error.code,
2562
2571
  message: error.message,
2563
2572
  };
2564
2573
  }
@@ -2817,7 +2826,7 @@ class UserServiceClient {
2817
2826
  }
2818
2827
  catch (error) {
2819
2828
  assertError(error);
2820
- return { code: 'ERROR', message: error.message };
2829
+ return { code: 'ERROR', message: error.message, details: { error } };
2821
2830
  }
2822
2831
  });
2823
2832
  /**
@@ -2829,7 +2838,7 @@ class UserServiceClient {
2829
2838
  }
2830
2839
  catch (error) {
2831
2840
  assertError(error);
2832
- return { code: 'ERROR', message: error.message };
2841
+ return { code: 'ERROR', message: error.message, details: { error } };
2833
2842
  }
2834
2843
  });
2835
2844
  /**
@@ -2841,7 +2850,7 @@ class UserServiceClient {
2841
2850
  }
2842
2851
  catch (error) {
2843
2852
  assertError(error);
2844
- return { code: 'ERROR', message: error.message };
2853
+ return { code: 'ERROR', message: error.message, details: { error } };
2845
2854
  }
2846
2855
  });
2847
2856
  /**
@@ -2853,7 +2862,7 @@ class UserServiceClient {
2853
2862
  }
2854
2863
  catch (error) {
2855
2864
  assertError(error);
2856
- return { code: 'ERROR', message: error.message };
2865
+ return { code: 'ERROR', message: error.message, details: { error } };
2857
2866
  }
2858
2867
  });
2859
2868
  /**
@@ -2866,7 +2875,7 @@ class UserServiceClient {
2866
2875
  }
2867
2876
  catch (error) {
2868
2877
  assertError(error);
2869
- return { code: 'ERROR', message: error.message };
2878
+ return { code: 'ERROR', message: error.message, details: { error } };
2870
2879
  }
2871
2880
  });
2872
2881
  /**
@@ -2940,7 +2949,7 @@ const UserServiceContext = React.createContext(null);
2940
2949
  */
2941
2950
  const UserServiceProvider = ({ children, userAuthConfig, userServiceConfig, tokenRenewalMethod = exports.TokenRenewalMethod.ON_DEMAND, }) => {
2942
2951
  const client = new UserServiceClient(userAuthConfig, userServiceConfig, tokenRenewalMethod);
2943
- return (React.createElement(UserServiceContext.Provider, { value: client }, children));
2952
+ return (React__namespace.createElement(UserServiceContext.Provider, { value: client }, children));
2944
2953
  };
2945
2954
  /**
2946
2955
  * Retrieves the User Service Client