@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.es.js CHANGED
@@ -1,4 +1,5 @@
1
- import { createContext, createElement, useContext } from 'react';
1
+ import * as React from 'react';
2
+ import { createContext, useContext } from 'react';
2
3
 
3
4
  var TokenRenewalMethod;
4
5
  (function (TokenRenewalMethod) {
@@ -13,7 +14,7 @@ var TokenRenewalMethod;
13
14
  TokenRenewalMethod[TokenRenewalMethod["ON_DEMAND"] = 1] = "ON_DEMAND";
14
15
  })(TokenRenewalMethod || (TokenRenewalMethod = {}));
15
16
 
16
- /*! *****************************************************************************
17
+ /******************************************************************************
17
18
  Copyright (c) Microsoft Corporation.
18
19
 
19
20
  Permission to use, copy, modify, and/or distribute this software for any
@@ -56,43 +57,32 @@ function commonjsRequire () {
56
57
 
57
58
  var enums = createCommonjsModule(function (module, exports) {
58
59
  Object.defineProperty(exports, "__esModule", { value: true });
59
- exports.DecryptNativeCookieResponseCode = exports.IdpProtocol = exports.CheckOtpResponseCode = exports.CompleteUserSignUpResponseCode = exports.UserSignUpResponseCode = exports.ResetPasswordResponseCode = exports.SignInResponseCode = exports.IdpConfigurationResponseCode = exports.SignOutResponseCode = exports.TokenResponseCode = exports.UserAuthErrorCode = void 0;
60
- /**
61
- * This is the Error Type that the REST middleware will respond when there's an error
62
- * from the User Service that does not belong to Token/SignOut or IDPConfiguration responses.
63
- */
64
- var UserAuthErrorCode;
60
+ 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;
65
61
  (function (UserAuthErrorCode) {
66
62
  UserAuthErrorCode["AUTH_FLOW_ERROR"] = "AUTH_FLOW_ERROR";
67
63
  UserAuthErrorCode["IDP_CONFIGURATION_ERROR"] = "IDP_CONFIGURATION_ERROR";
68
64
  UserAuthErrorCode["BAD_REQUEST"] = "BAD_REQUEST";
65
+ UserAuthErrorCode["ACCOUNT_NOT_ACTIVE"] = "ACCOUNT_NOT_ACTIVE";
66
+ UserAuthErrorCode["INVALID_USER"] = "INVALID_USER";
67
+ UserAuthErrorCode["INVALID_APPLICATION"] = "INVALID_APPLICATION";
68
+ UserAuthErrorCode["APPLICATION_NOT_ACTIVE"] = "APPLICATION_NOT_ACTIVE";
69
+ UserAuthErrorCode["INVALID_IDP_CONNECTION"] = "INVALID_IDP_CONNECTION";
69
70
  UserAuthErrorCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
70
- })(UserAuthErrorCode = exports.UserAuthErrorCode || (exports.UserAuthErrorCode = {}));
71
- /**
72
- * Token response code from User Service Auth API
73
- */
74
- var TokenResponseCode;
71
+ })(exports.UserAuthErrorCode || (exports.UserAuthErrorCode = {}));
75
72
  (function (TokenResponseCode) {
76
73
  TokenResponseCode["SUCCESS"] = "SUCCESS";
77
74
  TokenResponseCode["NEEDS_LOGIN"] = "NEEDS_LOGIN";
75
+ TokenResponseCode["USER_NOT_FOUND"] = "USER_NOT_FOUND";
78
76
  TokenResponseCode["ACCOUNT_NOT_ACTIVE"] = "ACCOUNT_NOT_ACTIVE";
79
77
  TokenResponseCode["AUTH_FLOW_ERROR"] = "AUTH_FLOW_ERROR";
80
78
  TokenResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
81
79
  TokenResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
82
- })(TokenResponseCode = exports.TokenResponseCode || (exports.TokenResponseCode = {}));
83
- /**
84
- * Sign out response code from User Service Auth API
85
- */
86
- var SignOutResponseCode;
80
+ })(exports.TokenResponseCode || (exports.TokenResponseCode = {}));
87
81
  (function (SignOutResponseCode) {
88
82
  SignOutResponseCode["SUCCESS"] = "SUCCESS";
89
83
  SignOutResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
90
84
  SignOutResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
91
- })(SignOutResponseCode = exports.SignOutResponseCode || (exports.SignOutResponseCode = {}));
92
- /**
93
- * IDP Configuration response code from User Service Auth API
94
- */
95
- var IdpConfigurationResponseCode;
85
+ })(exports.SignOutResponseCode || (exports.SignOutResponseCode = {}));
96
86
  (function (IdpConfigurationResponseCode) {
97
87
  IdpConfigurationResponseCode["SUCCESS"] = "SUCCESS";
98
88
  IdpConfigurationResponseCode["APPLICATION_NOT_ACTIVE"] = "APPLICATION_NOT_ACTIVE";
@@ -100,73 +90,51 @@ var IdpConfigurationResponseCode;
100
90
  IdpConfigurationResponseCode["ACCOUNT_NOT_ACTIVE"] = "ACCOUNT_NOT_ACTIVE";
101
91
  IdpConfigurationResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
102
92
  IdpConfigurationResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
103
- })(IdpConfigurationResponseCode = exports.IdpConfigurationResponseCode || (exports.IdpConfigurationResponseCode = {}));
104
- /**
105
- * Sign In With Credentials Response Code from User Service Auth API
106
- */
107
- var SignInResponseCode;
93
+ })(exports.IdpConfigurationResponseCode || (exports.IdpConfigurationResponseCode = {}));
108
94
  (function (SignInResponseCode) {
109
95
  SignInResponseCode["SUCCESS"] = "SUCCESS";
110
96
  SignInResponseCode["INTERNAL_SERVER_ERROR"] = "INTERNAL_SERVER_ERROR";
111
- SignInResponseCode["BAD_REQUEST"] = "BAD_REQUEST";
112
97
  SignInResponseCode["AUTH_FLOW_ERROR"] = "AUTH_FLOW_ERROR";
113
98
  SignInResponseCode["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
114
99
  SignInResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
115
- })(SignInResponseCode = exports.SignInResponseCode || (exports.SignInResponseCode = {}));
116
- /**
117
- * Sign In With Credentials Password Reset/Complete Password Reset Code from User Service Auth API
118
- */
119
- var ResetPasswordResponseCode;
100
+ SignInResponseCode["INVALID_IDP_CONNECTION"] = "INVALID_IDP_CONNECTION";
101
+ SignInResponseCode["APPLICATION_NOT_ACTIVE"] = "APPLICATION_NOT_ACTIVE";
102
+ })(exports.SignInResponseCode || (exports.SignInResponseCode = {}));
120
103
  (function (ResetPasswordResponseCode) {
121
104
  ResetPasswordResponseCode["SUCCESS"] = "SUCCESS";
122
105
  ResetPasswordResponseCode["ERROR"] = "ERROR";
123
106
  ResetPasswordResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
124
- })(ResetPasswordResponseCode = exports.ResetPasswordResponseCode || (exports.ResetPasswordResponseCode = {}));
125
- /**
126
- * Sign Up With Credential Response Code from User Service Auth API
127
- */
128
- var UserSignUpResponseCode;
107
+ })(exports.ResetPasswordResponseCode || (exports.ResetPasswordResponseCode = {}));
129
108
  (function (UserSignUpResponseCode) {
130
109
  UserSignUpResponseCode["SUCCESS"] = "SUCCESS";
131
110
  UserSignUpResponseCode["ERROR"] = "ERROR";
132
111
  UserSignUpResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
133
- })(UserSignUpResponseCode = exports.UserSignUpResponseCode || (exports.UserSignUpResponseCode = {}));
134
- /**
135
- * Verify Sign Up With Credential Response Code from User Service Auth API
136
- */
137
- var CompleteUserSignUpResponseCode;
112
+ })(exports.UserSignUpResponseCode || (exports.UserSignUpResponseCode = {}));
138
113
  (function (CompleteUserSignUpResponseCode) {
139
114
  CompleteUserSignUpResponseCode["SUCCESS"] = "SUCCESS";
140
115
  CompleteUserSignUpResponseCode["ERROR"] = "ERROR";
141
116
  CompleteUserSignUpResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
142
- })(CompleteUserSignUpResponseCode = exports.CompleteUserSignUpResponseCode || (exports.CompleteUserSignUpResponseCode = {}));
143
- /**
144
- * OTP Check Response Code from User Service Auth API
145
- * This response type is used for both Sign Up OTP check and Reset Password OTP check.
146
- */
147
- var CheckOtpResponseCode;
117
+ })(exports.CompleteUserSignUpResponseCode || (exports.CompleteUserSignUpResponseCode = {}));
148
118
  (function (CheckOtpResponseCode) {
149
119
  CheckOtpResponseCode["SUCCESS"] = "SUCCESS";
150
120
  CheckOtpResponseCode["ERROR"] = "ERROR";
151
121
  CheckOtpResponseCode["SERVICE_CONFIGURATION_ERROR"] = "SERVICE_CONFIGURATION_ERROR";
152
- })(CheckOtpResponseCode = exports.CheckOtpResponseCode || (exports.CheckOtpResponseCode = {}));
153
- /**
154
- * IDP Protocol categories
155
- */
156
- var IdpProtocol;
122
+ })(exports.CheckOtpResponseCode || (exports.CheckOtpResponseCode = {}));
157
123
  (function (IdpProtocol) {
158
124
  IdpProtocol["OIDC"] = "OIDC";
159
125
  IdpProtocol["OAUTH2"] = "OAUTH2";
160
126
  IdpProtocol["DELEGATED"] = "DELEGATED";
161
- })(IdpProtocol = exports.IdpProtocol || (exports.IdpProtocol = {}));
162
- /**
163
- * Response codes specific to Native Cookie Decryption.
164
- */
165
- var DecryptNativeCookieResponseCode;
127
+ })(exports.IdpProtocol || (exports.IdpProtocol = {}));
166
128
  (function (DecryptNativeCookieResponseCode) {
167
129
  DecryptNativeCookieResponseCode["SUCCESS"] = "SUCCESS";
168
130
  DecryptNativeCookieResponseCode["COOKIE_DECRYPTION_FAILED"] = "COOKIE_DECRYPTION_FAILED";
169
- })(DecryptNativeCookieResponseCode = exports.DecryptNativeCookieResponseCode || (exports.DecryptNativeCookieResponseCode = {}));
131
+ })(exports.DecryptNativeCookieResponseCode || (exports.DecryptNativeCookieResponseCode = {}));
132
+ (function (AuthenticateEndUserApplicationResponseCode) {
133
+ AuthenticateEndUserApplicationResponseCode["SUCCESS"] = "SUCCESS";
134
+ AuthenticateEndUserApplicationResponseCode["APPLICATION_NOT_FOUND"] = "APPLICATION_NOT_FOUND";
135
+ AuthenticateEndUserApplicationResponseCode["APPLICATION_NOT_ENABLED"] = "APPLICATION_NOT_ENABLED";
136
+ AuthenticateEndUserApplicationResponseCode["END_USER_APP_TOKEN_GENERATION_ERROR"] = "END_USER_APP_TOKEN_GENERATION_ERROR";
137
+ })(exports.AuthenticateEndUserApplicationResponseCode || (exports.AuthenticateEndUserApplicationResponseCode = {}));
170
138
 
171
139
  });
172
140
 
@@ -228,7 +196,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
228
196
  var dist = createCommonjsModule(function (module, exports) {
229
197
  var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
230
198
  if (k2 === undefined) k2 = k;
231
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
199
+ var desc = Object.getOwnPropertyDescriptor(m, k);
200
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
201
+ desc = { enumerable: true, get: function() { return m[k]; } };
202
+ }
203
+ Object.defineProperty(o, k2, desc);
232
204
  }) : (function(o, m, k, k2) {
233
205
  if (k2 === undefined) k2 = k;
234
206
  o[k2] = m[k];
@@ -243,6 +215,16 @@ __exportStar(types, exports);
243
215
 
244
216
  });
245
217
 
218
+ /**
219
+ * Class mimicking the minimal structure of a MosaicError.
220
+ * This class is defined here to avoid the @axinom/service-common dependency.
221
+ */
222
+ class UserAuthError extends Error {
223
+ constructor(message, code) {
224
+ super(message);
225
+ this.code = code;
226
+ }
227
+ }
246
228
  /**
247
229
  * 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.
248
230
  * This is a copy of assertError() in @axinom/service-common to avoid dependencies.
@@ -255,6 +237,7 @@ const assertError = (error) => {
255
237
 
256
238
  // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
257
239
  var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
240
+ var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
258
241
 
259
242
  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); }
260
243
  var MAX_ARRAY_LENGTH = 10;
@@ -353,7 +336,7 @@ function formatArray(array, seenValues) {
353
336
  }
354
337
 
355
338
  function getCustomFn(object) {
356
- var customInspectFn = object[String(nodejsCustomInspectSymbol)];
339
+ var customInspectFn = object[String(nodejsCustomInspectSymbol$1)];
357
340
 
358
341
  if (typeof customInspectFn === 'function') {
359
342
  return customInspectFn;
@@ -395,8 +378,8 @@ function defineInspect(classObject) {
395
378
  typeof fn === 'function' || invariant(0);
396
379
  classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
397
380
 
398
- if (nodejsCustomInspectSymbol) {
399
- classObject.prototype[nodejsCustomInspectSymbol] = fn;
381
+ if (nodejsCustomInspectSymbol$1) {
382
+ classObject.prototype[nodejsCustomInspectSymbol$1] = fn;
400
383
  }
401
384
  }
402
385
 
@@ -1284,7 +1267,7 @@ var ApplicationsOrderBy;
1284
1267
  ApplicationsOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
1285
1268
  })(ApplicationsOrderBy || (ApplicationsOrderBy = {}));
1286
1269
  /** 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. */
1287
- var ErrorCodesEnum;
1270
+ var ErrorCodesEnum$1;
1288
1271
  (function (ErrorCodesEnum) {
1289
1272
  /** Access Token has expired. */
1290
1273
  ErrorCodesEnum["ACCESS_TOKEN_EXPIRED"] = "ACCESS_TOKEN_EXPIRED";
@@ -1398,7 +1381,7 @@ var ErrorCodesEnum;
1398
1381
  ErrorCodesEnum["TOKEN_ENRICHMENT_EXCEEDS_LIMIT"] = "TOKEN_ENRICHMENT_EXCEEDS_LIMIT";
1399
1382
  /** Retrieving user information from Access Token Enrichment Webhook failed. */
1400
1383
  ErrorCodesEnum["TOKEN_ENRICHMENT_WEBHOOK_FAILURE"] = "TOKEN_ENRICHMENT_WEBHOOK_FAILURE";
1401
- /** An unhandled database-related has occurred. Please contact the service support. */
1384
+ /** An unhandled database-related error has occurred. Please contact the service support. */
1402
1385
  ErrorCodesEnum["UNHANDLED_DATABASE_ERROR"] = "UNHANDLED_DATABASE_ERROR";
1403
1386
  /** An unhandled error has occurred. Please contact the service support. */
1404
1387
  ErrorCodesEnum["UNHANDLED_ERROR"] = "UNHANDLED_ERROR";
@@ -1412,7 +1395,7 @@ var ErrorCodesEnum;
1412
1395
  ErrorCodesEnum["USER_STORE_SHOULD_NOT_BE_EMPTY"] = "USER_STORE_SHOULD_NOT_BE_EMPTY";
1413
1396
  /** Websocket not found in ExtendedGraphQLContext. This is a development time issue. A reference to the websocket must be included in Postgraphile build options. */
1414
1397
  ErrorCodesEnum["WEBSOCKET_NOT_FOUND"] = "WEBSOCKET_NOT_FOUND";
1415
- })(ErrorCodesEnum || (ErrorCodesEnum = {}));
1398
+ })(ErrorCodesEnum$1 || (ErrorCodesEnum$1 = {}));
1416
1399
  /** Methods to use when ordering `IdpConnection`. */
1417
1400
  var IdpConnectionsOrderBy;
1418
1401
  (function (IdpConnectionsOrderBy) {
@@ -1543,7 +1526,7 @@ var UserIdpDataOrderBy;
1543
1526
  UserIdpDataOrderBy["USER_ID_DESC"] = "USER_ID_DESC";
1544
1527
  })(UserIdpDataOrderBy || (UserIdpDataOrderBy = {}));
1545
1528
  /** Methods to use when ordering `UserProfile`. */
1546
- var UserProfilesOrderBy;
1529
+ var UserProfilesOrderBy$1;
1547
1530
  (function (UserProfilesOrderBy) {
1548
1531
  UserProfilesOrderBy["CREATED_DATE_ASC"] = "CREATED_DATE_ASC";
1549
1532
  UserProfilesOrderBy["CREATED_DATE_DESC"] = "CREATED_DATE_DESC";
@@ -1572,9 +1555,9 @@ var UserProfilesOrderBy;
1572
1555
  UserProfilesOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
1573
1556
  UserProfilesOrderBy["USER_ID_ASC"] = "USER_ID_ASC";
1574
1557
  UserProfilesOrderBy["USER_ID_DESC"] = "USER_ID_DESC";
1575
- })(UserProfilesOrderBy || (UserProfilesOrderBy = {}));
1558
+ })(UserProfilesOrderBy$1 || (UserProfilesOrderBy$1 = {}));
1576
1559
  /** Methods to use when ordering `User`. */
1577
- var UsersOrderBy;
1560
+ var UsersOrderBy$1;
1578
1561
  (function (UsersOrderBy) {
1579
1562
  UsersOrderBy["CREATED_DATE_ASC"] = "CREATED_DATE_ASC";
1580
1563
  UsersOrderBy["CREATED_DATE_DESC"] = "CREATED_DATE_DESC";
@@ -1605,7 +1588,7 @@ var UsersOrderBy;
1605
1588
  UsersOrderBy["UPDATED_DATE_DESC"] = "UPDATED_DATE_DESC";
1606
1589
  UsersOrderBy["UPDATED_USER_ASC"] = "UPDATED_USER_ASC";
1607
1590
  UsersOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
1608
- })(UsersOrderBy || (UsersOrderBy = {}));
1591
+ })(UsersOrderBy$1 || (UsersOrderBy$1 = {}));
1609
1592
  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": [] }] } }] } }] };
1610
1593
  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": [] }] } }] } }] };
1611
1594
 
@@ -1632,12 +1615,13 @@ const authenticateEndUserApplication = (authenticateEndUserApplicationInput, use
1632
1615
  })).json();
1633
1616
  if (authenticateEndUserApplicationResponse.errors !== undefined) {
1634
1617
  return {
1635
- code: 'ERROR',
1618
+ code: authenticateEndUserApplicationResponse.errors[0]
1619
+ .code,
1636
1620
  message: authenticateEndUserApplicationResponse.errors[0].message,
1637
1621
  };
1638
1622
  }
1639
1623
  return {
1640
- code: 'SUCCESS',
1624
+ code: dist.AuthenticateEndUserApplicationResponseCode.SUCCESS,
1641
1625
  endUserApplicationToken: {
1642
1626
  accessToken: authenticateEndUserApplicationResponse.data
1643
1627
  .authenticateEndUserApplication.accessToken,
@@ -2072,25 +2056,31 @@ const getNativeAuthUrl = (userAuthConfig, idpConnectionId, returnUrl, encryption
2072
2056
  * Returns a new user token by invoking the User Auth API
2073
2057
  */
2074
2058
  const fetchUserToken = (userAuthConfig) => __awaiter(void 0, void 0, void 0, function* () {
2075
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
2076
- const tokenResponse = yield invokeUserAuthMethod('token', userAuthConfig);
2077
- if (tokenResponse.code !== dist.TokenResponseCode.SUCCESS) {
2078
- throw Error(tokenResponse.message);
2059
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
2060
+ try {
2061
+ const tokenResponse = yield invokeUserAuthMethod('token', userAuthConfig);
2062
+ if (tokenResponse.code !== dist.TokenResponseCode.SUCCESS) {
2063
+ throw new UserAuthError(tokenResponse.message, tokenResponse.code);
2064
+ }
2065
+ else {
2066
+ return {
2067
+ tenantId: (_c = tokenResponse.tenantId) !== null && _c !== void 0 ? _c : '',
2068
+ environmentId: (_d = tokenResponse.environmentId) !== null && _d !== void 0 ? _d : '',
2069
+ applicationId: (_e = tokenResponse.applicationId) !== null && _e !== void 0 ? _e : '',
2070
+ userId: (_g = (_f = tokenResponse.user) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : '',
2071
+ profileId: (_j = (_h = tokenResponse.user) === null || _h === void 0 ? void 0 : _h.profileId) !== null && _j !== void 0 ? _j : '',
2072
+ email: (_l = (_k = tokenResponse.user) === null || _k === void 0 ? void 0 : _k.email) !== null && _l !== void 0 ? _l : null,
2073
+ name: (_o = (_m = tokenResponse.user) === null || _m === void 0 ? void 0 : _m.name) !== null && _o !== void 0 ? _o : null,
2074
+ extensions: tokenResponse.extensions,
2075
+ accessToken: (_q = (_p = tokenResponse.user) === null || _p === void 0 ? void 0 : _p.token.accessToken) !== null && _q !== void 0 ? _q : '',
2076
+ expiresInSeconds: (_s = (_r = tokenResponse.user) === null || _r === void 0 ? void 0 : _r.token.expiresInSeconds) !== null && _s !== void 0 ? _s : 0,
2077
+ expiresAt: (_t = tokenResponse.user) === null || _t === void 0 ? void 0 : _t.token.expiresAt,
2078
+ };
2079
+ }
2079
2080
  }
2080
- else {
2081
- return {
2082
- tenantId: (_c = tokenResponse.tenantId) !== null && _c !== void 0 ? _c : '',
2083
- environmentId: (_d = tokenResponse.environmentId) !== null && _d !== void 0 ? _d : '',
2084
- applicationId: (_e = tokenResponse.applicationId) !== null && _e !== void 0 ? _e : '',
2085
- userId: (_g = (_f = tokenResponse.user) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : '',
2086
- profileId: (_j = (_h = tokenResponse.user) === null || _h === void 0 ? void 0 : _h.profileId) !== null && _j !== void 0 ? _j : '',
2087
- email: (_l = (_k = tokenResponse.user) === null || _k === void 0 ? void 0 : _k.email) !== null && _l !== void 0 ? _l : null,
2088
- name: (_o = (_m = tokenResponse.user) === null || _m === void 0 ? void 0 : _m.name) !== null && _o !== void 0 ? _o : null,
2089
- extensions: tokenResponse.extensions,
2090
- accessToken: (_q = (_p = tokenResponse.user) === null || _p === void 0 ? void 0 : _p.token.accessToken) !== null && _q !== void 0 ? _q : '',
2091
- expiresInSeconds: (_s = (_r = tokenResponse.user) === null || _r === void 0 ? void 0 : _r.token.expiresInSeconds) !== null && _s !== void 0 ? _s : 0,
2092
- expiresAt: (_t = tokenResponse.user) === null || _t === void 0 ? void 0 : _t.token.expiresAt,
2093
- };
2081
+ catch (error) {
2082
+ assertError(error);
2083
+ throw new UserAuthError(error.message, (_u = error.code) !== null && _u !== void 0 ? _u : dist.TokenResponseCode.INTERNAL_SERVER_ERROR);
2094
2084
  }
2095
2085
  });
2096
2086
  const logoutUser = (userAuthConfig) => __awaiter(void 0, void 0, void 0, function* () {
@@ -2135,7 +2125,7 @@ const decryptNativeCookie = (encryptedCookie, key, userServiceManagementEndpoint
2135
2125
  });
2136
2126
 
2137
2127
  /** 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. */
2138
- var ErrorCodesEnum$1;
2128
+ var ErrorCodesEnum;
2139
2129
  (function (ErrorCodesEnum) {
2140
2130
  /** Access Token has expired. */
2141
2131
  ErrorCodesEnum["ACCESS_TOKEN_EXPIRED"] = "ACCESS_TOKEN_EXPIRED";
@@ -2217,7 +2207,7 @@ var ErrorCodesEnum$1;
2217
2207
  ErrorCodesEnum["SIGNING_KEY_NOT_FOUND"] = "SIGNING_KEY_NOT_FOUND";
2218
2208
  /** An application startup error has occurred. The actual message will have more information. */
2219
2209
  ErrorCodesEnum["STARTUP_ERROR"] = "STARTUP_ERROR";
2220
- /** An unhandled database-related has occurred. Please contact the service support. */
2210
+ /** An unhandled database-related error has occurred. Please contact the service support. */
2221
2211
  ErrorCodesEnum["UNHANDLED_DATABASE_ERROR"] = "UNHANDLED_DATABASE_ERROR";
2222
2212
  /** An unhandled error has occurred. Please contact the service support. */
2223
2213
  ErrorCodesEnum["UNHANDLED_ERROR"] = "UNHANDLED_ERROR";
@@ -2229,9 +2219,9 @@ var ErrorCodesEnum$1;
2229
2219
  ErrorCodesEnum["USER_SERVICE_NOT_ACCESSIBLE"] = "USER_SERVICE_NOT_ACCESSIBLE";
2230
2220
  /** Websocket not found in ExtendedGraphQLContext. This is a development time issue. A reference to the websocket must be included in Postgraphile build options. */
2231
2221
  ErrorCodesEnum["WEBSOCKET_NOT_FOUND"] = "WEBSOCKET_NOT_FOUND";
2232
- })(ErrorCodesEnum$1 || (ErrorCodesEnum$1 = {}));
2222
+ })(ErrorCodesEnum || (ErrorCodesEnum = {}));
2233
2223
  /** Methods to use when ordering `UserProfile`. */
2234
- var UserProfilesOrderBy$1;
2224
+ var UserProfilesOrderBy;
2235
2225
  (function (UserProfilesOrderBy) {
2236
2226
  UserProfilesOrderBy["CREATED_DATE_ASC"] = "CREATED_DATE_ASC";
2237
2227
  UserProfilesOrderBy["CREATED_DATE_DESC"] = "CREATED_DATE_DESC";
@@ -2258,9 +2248,9 @@ var UserProfilesOrderBy$1;
2258
2248
  UserProfilesOrderBy["UPDATED_DATE_DESC"] = "UPDATED_DATE_DESC";
2259
2249
  UserProfilesOrderBy["UPDATED_USER_ASC"] = "UPDATED_USER_ASC";
2260
2250
  UserProfilesOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
2261
- })(UserProfilesOrderBy$1 || (UserProfilesOrderBy$1 = {}));
2251
+ })(UserProfilesOrderBy || (UserProfilesOrderBy = {}));
2262
2252
  /** Methods to use when ordering `User`. */
2263
- var UsersOrderBy$1;
2253
+ var UsersOrderBy;
2264
2254
  (function (UsersOrderBy) {
2265
2255
  UsersOrderBy["CREATED_DATE_ASC"] = "CREATED_DATE_ASC";
2266
2256
  UsersOrderBy["CREATED_DATE_DESC"] = "CREATED_DATE_DESC";
@@ -2291,7 +2281,7 @@ var UsersOrderBy$1;
2291
2281
  UsersOrderBy["UPDATED_DATE_DESC"] = "UPDATED_DATE_DESC";
2292
2282
  UsersOrderBy["UPDATED_USER_ASC"] = "UPDATED_USER_ASC";
2293
2283
  UsersOrderBy["UPDATED_USER_DESC"] = "UPDATED_USER_DESC";
2294
- })(UsersOrderBy$1 || (UsersOrderBy$1 = {}));
2284
+ })(UsersOrderBy || (UsersOrderBy = {}));
2295
2285
  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": [] }] } }] } }] };
2296
2286
  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": [] }] } }] } }] };
2297
2287
  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": [] }] } }] } }] } }] };
@@ -2543,7 +2533,7 @@ class UserServiceClient {
2543
2533
  const userToken = yield fetchUserToken(this.userAuthConfig);
2544
2534
  const userProfileResponse = yield getUserProfile(this.userServiceConfig.userServiceBaseUrl, userToken.accessToken, userToken.profileId);
2545
2535
  return {
2546
- code: 'SUCCESS',
2536
+ code: dist.TokenResponseCode.SUCCESS,
2547
2537
  userToken,
2548
2538
  userProfile: userProfileResponse.userProfile,
2549
2539
  nextTokenRenewalAt: new Date(Date.now() +
@@ -2553,9 +2543,8 @@ class UserServiceClient {
2553
2543
  };
2554
2544
  }
2555
2545
  catch (error) {
2556
- assertError(error);
2557
2546
  return {
2558
- code: 'ERROR',
2547
+ code: error.code,
2559
2548
  message: error.message,
2560
2549
  };
2561
2550
  }
@@ -2814,7 +2803,7 @@ class UserServiceClient {
2814
2803
  }
2815
2804
  catch (error) {
2816
2805
  assertError(error);
2817
- return { code: 'ERROR', message: error.message };
2806
+ return { code: 'ERROR', message: error.message, details: { error } };
2818
2807
  }
2819
2808
  });
2820
2809
  /**
@@ -2826,7 +2815,7 @@ class UserServiceClient {
2826
2815
  }
2827
2816
  catch (error) {
2828
2817
  assertError(error);
2829
- return { code: 'ERROR', message: error.message };
2818
+ return { code: 'ERROR', message: error.message, details: { error } };
2830
2819
  }
2831
2820
  });
2832
2821
  /**
@@ -2838,7 +2827,7 @@ class UserServiceClient {
2838
2827
  }
2839
2828
  catch (error) {
2840
2829
  assertError(error);
2841
- return { code: 'ERROR', message: error.message };
2830
+ return { code: 'ERROR', message: error.message, details: { error } };
2842
2831
  }
2843
2832
  });
2844
2833
  /**
@@ -2850,7 +2839,7 @@ class UserServiceClient {
2850
2839
  }
2851
2840
  catch (error) {
2852
2841
  assertError(error);
2853
- return { code: 'ERROR', message: error.message };
2842
+ return { code: 'ERROR', message: error.message, details: { error } };
2854
2843
  }
2855
2844
  });
2856
2845
  /**
@@ -2863,7 +2852,7 @@ class UserServiceClient {
2863
2852
  }
2864
2853
  catch (error) {
2865
2854
  assertError(error);
2866
- return { code: 'ERROR', message: error.message };
2855
+ return { code: 'ERROR', message: error.message, details: { error } };
2867
2856
  }
2868
2857
  });
2869
2858
  /**
@@ -2937,7 +2926,7 @@ const UserServiceContext = createContext(null);
2937
2926
  */
2938
2927
  const UserServiceProvider = ({ children, userAuthConfig, userServiceConfig, tokenRenewalMethod = TokenRenewalMethod.ON_DEMAND, }) => {
2939
2928
  const client = new UserServiceClient(userAuthConfig, userServiceConfig, tokenRenewalMethod);
2940
- return (createElement(UserServiceContext.Provider, { value: client }, children));
2929
+ return (React.createElement(UserServiceContext.Provider, { value: client }, children));
2941
2930
  };
2942
2931
  /**
2943
2932
  * Retrieves the User Service Client