wjec-one 4.0.0-alpha.9 → 4.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/auth/index.d.ts +130 -41
- package/auth/index.js +1 -1
- package/config/babel.config.js +62 -0
- package/config/eslint-config.js +224 -0
- package/config/jest.config.js +77 -0
- package/config/tsconfig.json +52 -0
- package/config/webpack.config.js +237 -0
- package/index.d.ts +383 -233
- package/index.js +1 -1
- package/localization/index.d.ts +32 -30
- package/localization/index.js +1 -1
- package/package.json +65 -75
- package/portal/index.d.ts +270 -0
- package/portal/index.js +1 -0
- package/scripts/bin/wjec-one-scripts.js +44 -0
- package/scripts/build.js +54 -0
- package/scripts/check-config.js +46 -0
- package/scripts/check-tests.js +93 -0
- package/scripts/config/babel.config.js +29 -0
- package/scripts/config/webpack.standalone.config.js +119 -0
- package/scripts/init.js +91 -0
- package/scripts/standalone.js +28 -0
- package/scripts/start.js +25 -0
- package/scripts/test.js +78 -0
- package/services/index.d.ts +14 -14
- package/services/index.js +1 -1
- package/store/index.d.ts +9 -9
- package/store/index.js +1 -1
- package/store/utils/index.d.ts +2 -23
- package/test/assetsTransformer.ts +7 -0
- package/test/index.d.ts +106 -0
- package/test/index.js +1 -0
- package/test/index.ts +182 -0
- package/test/setupTests.ts +76 -0
- package/test/setupTestsAfterEnv.ts +47 -0
- package/test/svgTransformer.tsx +3 -0
- package/test/wjecOneMocks.ts +247 -0
- package/theme/index.d.ts +23 -24
- package/theme/index.js +1 -1
- package/umd/auth/index.js +1 -1
- package/umd/index.js +1 -1
- package/umd/localization/index.js +1 -1
- package/umd/portal/index.js +1 -0
- package/umd/services/index.js +1 -1
- package/umd/store/index.js +1 -1
- package/umd/test/index.js +1 -0
- package/umd/theme/index.js +1 -1
- package/umd/utils/index.js +1 -1
- package/utils/index.d.ts +49 -53
- package/utils/index.js +1 -1
- package/wjec-one-project.d.ts +74 -0
package/auth/index.d.ts
CHANGED
|
@@ -1,100 +1,189 @@
|
|
|
1
1
|
import { CognitoUserSession, CognitoUser } from 'amazon-cognito-identity-js';
|
|
2
|
+
import { LocalizationState } from 'wjec-one/localization';
|
|
3
|
+
import { ServiceCallStatus as ServiceCallStatus$1 } from 'wjec-one/services';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare type GenericStrings = {
|
|
6
|
-
[key: string]: string;
|
|
7
|
-
};
|
|
8
|
-
declare type LocalizationState<L extends number | string | symbol = any, S extends GenericStrings = any> = {
|
|
9
|
-
availableLocales: L[];
|
|
10
|
-
locale: L;
|
|
11
|
-
strings: S;
|
|
12
|
-
};
|
|
5
|
+
type ServiceCallStatus = 'done' | 'failed' | 'idle' | 'loading';
|
|
13
6
|
|
|
7
|
+
declare enum AuthAction {
|
|
8
|
+
CHANGE_PASSWORD = "changePassword",
|
|
9
|
+
COMPLETE_PASSWORD_RESET = "completePasswordReset",
|
|
10
|
+
FORCE_CHANGE_PASSWORD = "forceChangePassword",
|
|
11
|
+
GET_AUTHORIZATION_TOKEN = "getAuthorizationToken",
|
|
12
|
+
GET_USER_PREFERENCES = "getUserPreferences",
|
|
13
|
+
GET_USER_SESSION = "getUserSession",
|
|
14
|
+
INIT = "init",
|
|
15
|
+
REFRESH_USER_SESSION = "refreshUserSession",
|
|
16
|
+
REQUEST_PASSWORD_RESET = "requestPasswordReset",
|
|
17
|
+
REQUEST_TOTP_TOKEN = "requestSoftwareToken",
|
|
18
|
+
SET_MFA_TYPE = "setMfaType",
|
|
19
|
+
SIGN_IN = "signIn",
|
|
20
|
+
SIGN_OUT = "signOut",
|
|
21
|
+
SUBMIT_MFA_CODE = "confirmSignIn",
|
|
22
|
+
UPDATE_USER_ATTRIBUTES = "updateUserAttributes",
|
|
23
|
+
UPDATE_USER_PREFERENCES = "updateUserPreferences",
|
|
24
|
+
VERIFY_TELEPHONE_NUMBER = "verifyTelephoneNumber",
|
|
25
|
+
VERIFY_TOTP_TOKEN = "verifySoftwareToken"
|
|
26
|
+
}
|
|
14
27
|
declare enum ChallengeType {
|
|
28
|
+
CUSTOM_CHALLENGE = "CUSTOM_CHALLENGE",
|
|
29
|
+
EMAIL_MFA = "EMAIL",
|
|
30
|
+
MFA_SETUP = "MFA_SETUP",
|
|
15
31
|
NEW_PASSWORD_REQUIRED = "NEW_PASSWORD_REQUIRED",
|
|
16
|
-
SMS_MFA = "
|
|
17
|
-
|
|
32
|
+
SMS_MFA = "SMS",
|
|
33
|
+
TOTP_MFA = "TOTP",
|
|
34
|
+
VERIFY_TELEPHONE_NUMBER = "VERIFY_TELEPHONE_NUMBER",
|
|
35
|
+
VERIFY_TOTP_TOKEN = "VERIFY_TOTP_TOKEN"
|
|
18
36
|
}
|
|
19
37
|
declare enum MFAType {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
TOTP = "SOFTWARE_TOKEN_MFA"
|
|
38
|
+
EMAIL = "EMAIL",
|
|
39
|
+
NONE = "NONE",
|
|
40
|
+
SMS = "SMS",
|
|
41
|
+
TOTP = "TOTP"
|
|
25
42
|
}
|
|
26
|
-
interface
|
|
43
|
+
interface Cache extends EditableCognitoUserAttributes, EditablePrivateUserAttributes, ReadonlyCognitoUserAttributes {
|
|
44
|
+
isInitialized: boolean;
|
|
45
|
+
isSignedIn: boolean;
|
|
46
|
+
preferences: UserPreferences;
|
|
47
|
+
provider: 'Cognito' | 'AzureWJEC' | string;
|
|
48
|
+
requestStatuses: Record<AuthAction, ServiceCallStatus$1>;
|
|
49
|
+
usersEndpoint: string;
|
|
50
|
+
}
|
|
51
|
+
interface EditableCognitoUserAttributes {
|
|
52
|
+
telephoneNumber: string;
|
|
53
|
+
}
|
|
54
|
+
interface EditablePrivateUserAttributes {
|
|
27
55
|
familyName: string;
|
|
28
|
-
|
|
56
|
+
name: string;
|
|
29
57
|
givenName: string;
|
|
30
58
|
languagePreference: LocalizationState['locale'];
|
|
31
59
|
middleName: string;
|
|
32
|
-
telephoneNumber: string;
|
|
33
60
|
}
|
|
34
|
-
interface
|
|
35
|
-
|
|
61
|
+
interface ReadonlyCognitoUserAttributes {
|
|
62
|
+
centrePermissions: Record<string, string>;
|
|
36
63
|
emailAddress: string;
|
|
64
|
+
emailAddressVerified: boolean;
|
|
37
65
|
groups: string[];
|
|
38
66
|
id: string;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
67
|
+
mfaType: MFAType;
|
|
68
|
+
telephoneNumberVerified: boolean;
|
|
69
|
+
totpVerified: boolean;
|
|
42
70
|
}
|
|
43
|
-
|
|
71
|
+
type CognitoUserAttributes = EditableCognitoUserAttributes & ReadonlyCognitoUserAttributes;
|
|
72
|
+
type EmailMfaChallenge = {
|
|
73
|
+
attemptNumber: number;
|
|
74
|
+
challengeType: ChallengeType.EMAIL_MFA;
|
|
75
|
+
completeChallenge: (code: string) => Promise<Challenge>;
|
|
76
|
+
emailAddress: string;
|
|
77
|
+
};
|
|
78
|
+
type NewPasswordChallenge = {
|
|
44
79
|
challengeType: ChallengeType.NEW_PASSWORD_REQUIRED;
|
|
45
80
|
completeChallenge: (newPassword: string) => Promise<boolean>;
|
|
46
81
|
};
|
|
47
|
-
|
|
82
|
+
type SmsMfaChallenge = {
|
|
83
|
+
attemptNumber: number;
|
|
48
84
|
challengeType: ChallengeType.SMS_MFA;
|
|
85
|
+
completeChallenge: (code: string) => Promise<Challenge>;
|
|
86
|
+
telephoneNumber: string;
|
|
87
|
+
};
|
|
88
|
+
type TotpMfaChallenge = {
|
|
89
|
+
attemptNumber: number;
|
|
90
|
+
challengeType: ChallengeType.TOTP_MFA;
|
|
91
|
+
completeChallenge: (code: string) => Promise<Challenge>;
|
|
92
|
+
};
|
|
93
|
+
type VerifyTelephoneNumberChallenge = {
|
|
94
|
+
challengeType: ChallengeType.VERIFY_TELEPHONE_NUMBER;
|
|
49
95
|
completeChallenge: (code: string) => Promise<boolean>;
|
|
50
96
|
};
|
|
51
|
-
|
|
52
|
-
challengeType: ChallengeType.
|
|
97
|
+
type VerifyTotpTokenChallenge = {
|
|
98
|
+
challengeType: ChallengeType.VERIFY_TOTP_TOKEN;
|
|
53
99
|
completeChallenge: (code: string) => Promise<boolean>;
|
|
100
|
+
secretKey: string;
|
|
54
101
|
};
|
|
55
|
-
|
|
102
|
+
type Challenge = EmailMfaChallenge | NewPasswordChallenge | SmsMfaChallenge | TotpMfaChallenge | VerifyTelephoneNumberChallenge | VerifyTotpTokenChallenge;
|
|
103
|
+
declare enum Role {
|
|
104
|
+
ADMINISTRATIVE_SUPPORT = "administrativeSupport",
|
|
105
|
+
EXAMS_OFFICER = "examsOfficer",
|
|
106
|
+
HEAD_OF_DEPARTMENT = "headOfDepartment",
|
|
107
|
+
HEAD_OF_YEAR = "headOfYear",
|
|
108
|
+
HEAD_TEACHER = "headTeacher",
|
|
109
|
+
LOCAL_AUTHORITY_ADVISOR = "localAuthorityAdvisor",
|
|
110
|
+
OTHER = "other",
|
|
111
|
+
STAKEHOLDER = "stakeholder",
|
|
112
|
+
TEACHER = "teacher",
|
|
113
|
+
TUTOR = "tutor"
|
|
114
|
+
}
|
|
115
|
+
declare enum Subject {
|
|
116
|
+
ENGLISH = "english",
|
|
117
|
+
MATHS = "maths",
|
|
118
|
+
SCIENCE = "science"
|
|
119
|
+
}
|
|
120
|
+
type UserPreferences = {
|
|
121
|
+
emailMfaAccepted?: Date;
|
|
122
|
+
favouriteLinks?: string[];
|
|
123
|
+
lastSeenVersion?: string;
|
|
124
|
+
role?: Role;
|
|
125
|
+
subjects?: Subject[];
|
|
126
|
+
title?: string;
|
|
127
|
+
};
|
|
56
128
|
|
|
57
129
|
interface Props {
|
|
58
130
|
amplifyConfig?: Record<string, any>;
|
|
59
131
|
oAuthConfig?: Record<string, any>;
|
|
60
132
|
onChallenge?: (challenge: Challenge) => void;
|
|
61
133
|
onCompletePasswordReset?: () => void;
|
|
62
|
-
onError?: (errorType:
|
|
134
|
+
onError?: (errorType: AuthAction, errorDetails?: any) => void;
|
|
63
135
|
onInit?: (session: CognitoUserSession) => void;
|
|
136
|
+
onRefreshSession?: (session: CognitoUserSession) => void;
|
|
64
137
|
onRequestPasswordReset?: (emailAddress: string) => void;
|
|
138
|
+
onSetMfaType?: (mfaType: MFAType) => void;
|
|
65
139
|
onSignIn?: (session: CognitoUserSession) => void;
|
|
66
140
|
onSignOut?: () => void;
|
|
141
|
+
usersEndpoint?: string;
|
|
67
142
|
}
|
|
68
|
-
|
|
143
|
+
type UseAuthorizationHook = (props?: Props) => typeof state;
|
|
69
144
|
declare const useAuthorization: UseAuthorizationHook;
|
|
70
145
|
|
|
71
|
-
declare const
|
|
146
|
+
declare const changePassword: (currentPassword: string, newPassword: string) => Promise<boolean>;
|
|
147
|
+
declare const completePasswordReset: (username: string, code: string, newPassword: string) => Promise<boolean>;
|
|
72
148
|
declare const getAuthorizationToken: () => Promise<string>;
|
|
73
|
-
declare const getMFAOptions: () => Promise<MFAType[]>;
|
|
74
149
|
declare const getUserSession: () => Promise<CognitoUserSession>;
|
|
75
|
-
declare const init: (amplifyConfig: Record<string, any>, oAuthConfig: Record<string, any
|
|
150
|
+
declare const init: (amplifyConfig: Record<string, any>, oAuthConfig: Record<string, any>, usersEndpoint: string) => Promise<CognitoUserSession>;
|
|
151
|
+
declare const refreshUserSession: () => Promise<CognitoUserSession>;
|
|
76
152
|
declare const requestPasswordReset: (emailAddress: string) => Promise<boolean>;
|
|
77
|
-
declare const
|
|
153
|
+
declare const setMfaType: (mfaType: MFAType.EMAIL | MFAType.SMS | MFAType.TOTP, syncCache?: boolean) => Promise<boolean>;
|
|
154
|
+
declare const setupTotp: () => Promise<{
|
|
155
|
+
challenge?: Challenge;
|
|
156
|
+
secretKey: string;
|
|
157
|
+
}>;
|
|
78
158
|
declare const signIn: (emailAddress: string, password: string) => Promise<{
|
|
79
159
|
challenge?: Challenge;
|
|
80
160
|
user: CognitoUser;
|
|
81
161
|
}>;
|
|
82
162
|
declare const signOut: () => Promise<boolean>;
|
|
83
|
-
declare const updateUserAttributes: (attributes: Partial<
|
|
163
|
+
declare const updateUserAttributes: (attributes: Partial<EditableCognitoUserAttributes & EditablePrivateUserAttributes>) => Promise<boolean>;
|
|
164
|
+
declare const updateUserPreferences: (preferences: Partial<UserPreferences>) => Promise<boolean>;
|
|
165
|
+
declare const verifyTelephoneNumber: () => Promise<Challenge>;
|
|
166
|
+
declare const verifyTotp: (code: string) => Promise<boolean>;
|
|
84
167
|
declare const state: Readonly<{
|
|
85
|
-
readonly
|
|
168
|
+
readonly centrePermissions: Record<string, string>;
|
|
86
169
|
readonly emailAddress: string;
|
|
170
|
+
readonly emailAddressVerified: boolean;
|
|
87
171
|
readonly familyName: string;
|
|
88
|
-
readonly
|
|
172
|
+
readonly name: string;
|
|
89
173
|
readonly givenName: string;
|
|
90
174
|
readonly groups: string[];
|
|
91
175
|
readonly id: string;
|
|
92
176
|
readonly isInitialized: boolean;
|
|
93
177
|
readonly isSignedIn: boolean;
|
|
94
178
|
readonly languagePreference: any;
|
|
179
|
+
readonly mfaType: MFAType;
|
|
95
180
|
readonly middleName: string;
|
|
96
|
-
readonly
|
|
181
|
+
readonly preferences: UserPreferences;
|
|
182
|
+
readonly provider: string;
|
|
183
|
+
readonly requestStatuses: Record<AuthAction, ServiceCallStatus>;
|
|
97
184
|
readonly telephoneNumber: string;
|
|
185
|
+
readonly telephoneNumberVerified: boolean;
|
|
186
|
+
readonly totpVerified: boolean;
|
|
98
187
|
}>;
|
|
99
188
|
|
|
100
|
-
export {
|
|
189
|
+
export { AuthAction, Cache, Challenge, ChallengeType, CognitoUserAttributes, EditableCognitoUserAttributes, EditablePrivateUserAttributes, EmailMfaChallenge, MFAType, NewPasswordChallenge, ReadonlyCognitoUserAttributes, Role, SmsMfaChallenge, Subject, TotpMfaChallenge, UserPreferences, VerifyTelephoneNumberChallenge, VerifyTotpTokenChallenge, changePassword, completePasswordReset, getAuthorizationToken, getUserSession, init, refreshUserSession, requestPasswordReset, setMfaType, setupTotp, signIn, signOut, state, updateUserAttributes, updateUserPreferences, useAuthorization, verifyTelephoneNumber, verifyTotp };
|
package/auth/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Hub as e,Auth as t,Amplify as r}from"aws-amplify";import{assertNever as n,isCallableFunction as o,developerWarning as i}from"../utils";import{useState as a,useRef as u,useEffect as c}from"react";function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){p(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(){l=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function s(e,t,r,o){var i=t&&t.prototype instanceof h?t:h,a=Object.create(i.prototype),u=new N(o||[]);return n(a,"_invoke",{value:A(e,r,u)}),a}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var d={};function h(){}function p(){}function g(){}var m={};c(m,i,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(P([])));y&&y!==t&&r.call(y,i)&&(m=y);var w=g.prototype=h.prototype=Object.create(m);function b(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function o(n,i,a,u){var c=f(e[n],e,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){o("next",e,a,u)}),(function(e){o("throw",e,a,u)})):t.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return o("throw",e,a,u)}))}u(c.arg)}var i;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){o(e,r,t,n)}))}return i=i?i.then(n,n):n()}})}function A(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return x()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=O(a,r);if(u){if(u===d)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function O(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,O(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=f(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,d;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(E,this),this.reset(!0)}function P(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return p.prototype=g,n(w,"constructor",{value:g,configurable:!0}),n(g,"constructor",{value:p,configurable:!0}),p.displayName=c(g,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,c(e,u,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},b(S.prototype),c(S.prototype,a,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new S(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(w),c(w,u,"Generator"),c(w,i,(function(){return this})),c(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=P,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:P(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function d(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function h(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function a(e){d(i,n,o,a,u,"next",e)}function u(e){d(i,n,o,a,u,"throw",e)}a(void 0)}))}}function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,o,i=[],a=!0,u=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(u)throw o}}return i}(e,t)||v(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||v(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,t){if(e){if("string"==typeof e)return y(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?y(e,t):void 0}}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var w,b,S={configuredMFA:[],emailAddress:void 0,familyName:void 0,fullName:void 0,givenName:void 0,groups:[],id:void 0,isInitialized:!1,isSignedIn:!1,languagePreference:"en-gb",middleName:void 0,requestStatus:"idle",telephoneNumber:void 0},A=function(e){return S[e]},O=function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];Object.entries(t).forEach((function(e){var t=g(e,2),r=t[0],n=t[1];S[r]=n})),r&&e.dispatch("custom",{data:{updatedTimestamp:Date.now()},event:"cacheUpdated"})},E=function(){var e=h(l().mark((function e(t){var r,n;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.getIdToken().payload,e.next=3,q();case 3:n=e.sent,O({configuredMFA:n,emailAddress:r.email,familyName:r.family_name||r.familyName,fullName:r.name,givenName:r.given_name||r.givenName,groups:r["cognito:groups"]||[],id:r.sub,isSignedIn:!0,languagePreference:r["custom:language_preference"],middleName:r.middle_name||r.middleName,telephoneNumber:r.phone_number});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),_=function(t){e.dispatch("custom",{data:{challenge:t},event:"challenge"})},N=function(t,r){e.dispatch("custom",{data:{errorDetails:r,errorType:t},event:"error"})},P=function(t){e.dispatch("custom",{data:{session:t},event:"init"})},x=function(){e.listen("auth",(function(e){var t=e.payload,r=t.data;switch(t.event){case"completeNewPassword_failure":case"forgotPassword_failure":case"forgotPasswordSubmit_failure":case"signIn_failure":case"signOut_failure":O({requestStatus:"failed"});break;case"signIn":E(r.signInUserSession);break;case"signOut":O({configuredMFA:[],emailAddress:void 0,familyName:void 0,fullName:void 0,givenName:void 0,groups:[],id:void 0,isSignedIn:!1,languagePreference:void 0,middleName:void 0,telephoneNumber:void 0})}})),e.listen("custom",(function(e){if("error"===e.payload.event)"loading"===A("requestStatus")&&O({requestStatus:"failed"})}))};!function(e){e.NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",e.SMS_MFA="SMS_MFA",e.SOFTWARE_TOKEN_MFA="SOFTWARE_TOKEN_MFA"}(w||(w={})),function(e){e.DISABLED="NOMFA",e.SMS="SMS_MFA",e.SMS_MFA="SMS_MFA",e.SOFTWARE_TOKEN_MFA="SOFTWARE_TOKEN_MFA",e.TOTP="SOFTWARE_TOKEN_MFA"}(b||(b={}));var M=function(e,r){return function(){var n;if(A("isInitialized")){for(var o=arguments.length,i=new Array(o),a=0;a<o;a++)i[a]=arguments[a];(n=e.call.apply(e,[t].concat(i)))instanceof Promise&&n.catch((function(e){N(r,e)}))}else console.error("WJEC One Authorization: You tried to call ".concat(r,"() before AWS Amplify was initialized. Please provide values for amplifyConfig & oAuthConfig to get set up"));return n}},I=function(e,r){var n;switch(e){case w.NEW_PASSWORD_REQUIRED:n={challengeType:w.NEW_PASSWORD_REQUIRED,completeChallenge:function(e){return O({requestStatus:"loading"}),F(t.completeNewPassword(r,e),"completeNewPassword")}};break;case w.SMS_MFA:case w.SOFTWARE_TOKEN_MFA:n={challengeType:e,completeChallenge:function(n){return O({requestStatus:"loading"}),F(t.confirmSignIn(r,n,e),"confirmSignIn")}}}return n},F=function(e,t){return e.then((function(){return O({requestStatus:"done"}),!0})).catch((function(e){return(e instanceof Error||"string"==typeof e)&&N(t,e),!1}))},k=function(e){return Object.entries(e).reduce((function(e,t){var r=g(t,2),o=r[0],i=r[1];return f(f({},e),{},p({},function(e){switch(e){case"familyName":return"family_name";case"fullName":return"name";case"givenName":return"given_name";case"languagePreference":return"custom:language_preference";case"middleName":return"middle_name";case"telephoneNumber":return"phone_number";default:return n(e)}}(o),i))}),{})},j=!1,T=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.amplifyConfig,n=t.oAuthConfig,s=t.onChallenge,f=t.onCompletePasswordReset,l=t.onError,d=t.onInit,h=t.onRequestPasswordReset,p=t.onSignIn,m=t.onSignOut,v=a(Date.now()),y=g(v,2);y[0];var w=y[1],b=u(!1);return c((function(){var t=!1,r=e.listen("auth",(function(e){var r=e.payload,n=r.data,i=r.event;if(!t)switch(i){case"forgotPassword":o(h)&&h(n.username);break;case"forgotPassword_failure":o(l)&&l("requestPasswordReset",n);break;case"forgotPasswordSubmit":o(f)&&f();break;case"forgotPasswordSubmit_failure":o(l)&&l("completePasswordReset",n);break;case"signIn":o(p)&&p(n.signInUserSession);break;case"signIn_failure":o(l)&&l("signIn",n);break;case"signOut":o(m)&&m()}})),n=e.listen("custom",(function(e){var r=e.payload,n=r.data,i=r.event;if(!t)switch(i){case"cacheUpdated":w(n.updatedTimestamp);break;case"challenge":o(s)&&s(n.challenge);break;case"error":o(l)&&l(n.errorType,n.errorDetails);break;case"init":o(d)&&d(n.session)}}));return function(){t=!0,r(),n()}}),[]),c((function(){if(r&&n){try{W(r,n),b.current=!0,j=!0}catch(e){o(l)&&l("initialization")}j&&!b.current&&i("WJEC One useAuthorization: Config should only be provided to the first instance of the useAuthorization hook in your component tree (recommendation is to include this in your entry point component, even if you don't need authorization tools at that point)")}}),[r,n]),J},L=M((function(e,r,n){return O({requestStatus:"loading"}),F(t.forgotPasswordSubmit(e,r,n),"completePasswordReset")}),"completePasswordReset"),R=M(h(l().mark((function e(){var t,r;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D();case 2:return t=e.sent,r=t.getIdToken().getJwtToken(),e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),"getAuthorizationToken"),q=M(h(l().mark((function e(){var r,n;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.currentAuthenticatedUser();case 2:return r=e.sent,e.next=5,new Promise((function(e,t){r.getUserData((function(r,n){var o=n.MFAOptions,i=void 0===o?[]:o,a=n.UserMFASettingList,u=void 0===a?[]:a;if(r)t(r);else{var c=[];c.push.apply(c,m(u)),!c.includes(b.SMS_MFA)&&i.find((function(e){return"SMS"===e.DeliveryMedium}))&&c.push(b.SMS_MFA),e(c)}}),{bypassCache:!0})}));case 5:return n=e.sent,e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)}))),"getMFAOptions"),D=M(h(l().mark((function e(){var r;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.currentSession();case 2:return r=e.sent,e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)}))),"getUserSession"),W=function(){var e=h(l().mark((function e(n,o){var a;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!A("isInitialized")){e.next=4;break}i("WJEC One Authorization: Config cannot be changed after initialization - the config that was originally provided will continue to be used"),e.next=16;break;case 4:if(n&&o){e.next=8;break}throw new Error("WJEC One Authorization: Both amplifyConfig and oAuthConfig objects must be provided");case 8:return r.configure(n),t.configure({oauth:o}),O({isInitialized:!0},!1),x(),e.next=14,t.currentSession().then((function(e){return E(e),e})).catch((function(){}));case 14:a=e.sent,P(a);case 16:return e.abrupt("return",a);case 17:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),U=M((function(e){return O({requestStatus:"loading"}),F(t.forgotPassword(e),"requestPasswordReset")}),"requestPasswordReset"),C=M(function(){var e=h(l().mark((function e(r){var n,o,i,a;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=!1,O({requestStatus:"loading"}),e.next=4,t.currentAuthenticatedUser();case 4:return o=e.sent,i=r.includes(b.SMS_MFA),a=r.includes(b.SOFTWARE_TOKEN_MFA),e.next=9,new Promise((function(e,t){o.setUserMfaPreference({Enabled:i,PreferredMfa:!1},{Enabled:a,PreferredMfa:!1},(function(n){n?t(n):(O({configuredMFA:r}),e(!0))}))}));case 9:return n=e.sent,e.abrupt("return",n);case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),"setMFAOptions"),z=M(function(){var e=h(l().mark((function e(r,n){var o,i;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return O({requestStatus:"loading"}),e.next=3,t.signIn(r,n).catch((function(e){(e instanceof Error||"string"==typeof e)&&N("signIn",e)}));case 3:return(i=e.sent)&&(i.challengeName&&(o=I(i.challengeName,i),_(o)),O({requestStatus:"done"})),e.abrupt("return",{challenge:o,user:i});case 6:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),"signIn"),G=M((function(){return O({requestStatus:"loading"}),F(t.signOut(),"signOut")}),"signOut"),K=M(function(){var e=h(l().mark((function e(r){var n,o;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return O({requestStatus:"loading"}),e.next=3,t.currentAuthenticatedUser();case 3:return n=e.sent,e.next=6,F(t.updateUserAttributes(n,k(r)),"updateUserAttributes");case 6:return(o=e.sent)&&O(r),e.abrupt("return",o);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),"updateUserAttributes"),J=Object.freeze({get configuredMFA(){return A("configuredMFA")},get emailAddress(){return A("emailAddress")},get familyName(){return A("familyName")},get fullName(){return A("fullName")},get givenName(){return A("givenName")},get groups(){return A("groups")},get id(){return A("id")},get isInitialized(){return A("isInitialized")},get isSignedIn(){return A("isSignedIn")},get languagePreference(){return A("languagePreference")},get middleName(){return A("middleName")},get requestStatus(){return A("requestStatus")},get telephoneNumber(){return A("telephoneNumber")}});export{w as ChallengeType,b as MFAType,L as completePasswordReset,R as getAuthorizationToken,q as getMFAOptions,D as getUserSession,W as init,U as requestPasswordReset,C as setMFAOptions,z as signIn,G as signOut,J as state,K as updateUserAttributes,T as useAuthorization};
|
|
1
|
+
import{Auth as e,Hub as t,Amplify as r}from"aws-amplify";import{assertNever as n,developerWarning as a,isCallableFunction as o}from"wjec-one/utils";import{useState as i,useRef as u,useEffect as c}from"react";function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function l(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){f(o,n,a,i,u,"next",e)}function u(e){f(o,n,a,i,u,"throw",e)}i(void 0)}))}}function p(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){p(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function E(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.includes(r)||{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function m(){m=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var o=t&&t.prototype instanceof S?t:S,i=Object.create(o.prototype),u=new x(n||[]);return a(i,"_invoke",{value:w(e,r,u)}),i}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var p="suspendedStart",d="suspendedYield",h="executing",E="completed",v={};function S(){}function g(){}function y(){}var T={};s(T,i,(function(){return this}));var _=Object.getPrototypeOf,b=_&&_(_(k([])));b&&b!==r&&n.call(b,i)&&(T=b);var O=y.prototype=S.prototype=Object.create(T);function N(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function r(a,o,i,u){var c=l(e[a],e,o);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,i,u)}),(function(e){r("throw",e,i,u)})):t.resolve(f).then((function(e){s.value=e,i(s)}),(function(e){return r("throw",e,i,u)}))}u(c.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return o=o?o.then(a,a):a()}})}function w(t,r,n){var a=p;return function(o,i){if(a===h)throw Error("Generator is already running");if(a===E){if("throw"===o)throw i;return{value:e,done:!0}}for(n.method=o,n.arg=i;;){var u=n.delegate;if(u){var c=A(u,n);if(c){if(c===v)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===p)throw a=E,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=h;var s=l(t,r,n);if("normal"===s.type){if(a=n.done?E:d,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(a=E,n.method="throw",n.arg=s.arg)}}}function A(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function k(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return g.prototype=y,a(O,"constructor",{value:y,configurable:!0}),a(y,"constructor",{value:g,configurable:!0}),g.displayName=s(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,s(e,c,"GeneratorFunction")),e.prototype=Object.create(O),e},t.awrap=function(e){return{__await:e}},N(R.prototype),s(R.prototype,u,(function(){return this})),t.AsyncIterator=R,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new R(f(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},N(O),s(O,c,"Generator"),s(O,i,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=k,x.prototype={constructor:x,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(I),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return u.type="throw",u.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;I(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o,i,u=[],c=!0,s=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(u.push(n.value),u.length!==t);c=!0);}catch(e){s=!0,a=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw a}}return u}}(e,t)||y(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function y(e,t){if(e){if("string"==typeof e)return s(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}var T,_,b,O,N;!function(e){e.CHANGE_PASSWORD="changePassword",e.COMPLETE_PASSWORD_RESET="completePasswordReset",e.FORCE_CHANGE_PASSWORD="forceChangePassword",e.GET_AUTHORIZATION_TOKEN="getAuthorizationToken",e.GET_USER_PREFERENCES="getUserPreferences",e.GET_USER_SESSION="getUserSession",e.INIT="init",e.REFRESH_USER_SESSION="refreshUserSession",e.REQUEST_PASSWORD_RESET="requestPasswordReset",e.REQUEST_TOTP_TOKEN="requestSoftwareToken",e.SET_MFA_TYPE="setMfaType",e.SIGN_IN="signIn",e.SIGN_OUT="signOut",e.SUBMIT_MFA_CODE="confirmSignIn",e.UPDATE_USER_ATTRIBUTES="updateUserAttributes",e.UPDATE_USER_PREFERENCES="updateUserPreferences",e.VERIFY_TELEPHONE_NUMBER="verifyTelephoneNumber",e.VERIFY_TOTP_TOKEN="verifySoftwareToken"}(T||(T={})),function(e){e.CUSTOM_CHALLENGE="CUSTOM_CHALLENGE",e.EMAIL_MFA="EMAIL",e.MFA_SETUP="MFA_SETUP",e.NEW_PASSWORD_REQUIRED="NEW_PASSWORD_REQUIRED",e.SMS_MFA="SMS",e.TOTP_MFA="TOTP",e.VERIFY_TELEPHONE_NUMBER="VERIFY_TELEPHONE_NUMBER",e.VERIFY_TOTP_TOKEN="VERIFY_TOTP_TOKEN"}(_||(_={})),function(e){e.EMAIL="EMAIL",e.NONE="NONE",e.SMS="SMS",e.TOTP="TOTP"}(b||(b={})),function(e){e.ADMINISTRATIVE_SUPPORT="administrativeSupport",e.EXAMS_OFFICER="examsOfficer",e.HEAD_OF_DEPARTMENT="headOfDepartment",e.HEAD_OF_YEAR="headOfYear",e.HEAD_TEACHER="headTeacher",e.LOCAL_AUTHORITY_ADVISOR="localAuthorityAdvisor",e.OTHER="other",e.STAKEHOLDER="stakeholder",e.TEACHER="teacher",e.TUTOR="tutor"}(O||(O={})),function(e){e.ENGLISH="english",e.MATHS="maths",e.SCIENCE="science"}(N||(N={}));var R=function(t,r){return function(){var n;if(Y("isInitialized")){for(var a=arguments.length,o=new Array(a),i=0;i<a;i++)o[i]=arguments[i];(n=t.call.apply(t,[e].concat(o)))instanceof Promise&&n.catch((function(e){M(r,e)}))}else console.error("WJEC One Authorization: You tried to call ".concat(r,"() before AWS Amplify was initialized. Please provide values for amplifyConfig & oAuthConfig to get set up"));return n}},w=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return e.then((function(){return r&&k(t,"done"),!0})).catch((function(e){return(e instanceof Error||"string"==typeof e)&&M(t,e),!1}))},A=function(e){return"object"===g(e)&&Object.hasOwn(e,"name")&&"NotAuthorizedException"===e.name},P=function(e){return"object"===g(e)&&Object.hasOwn(e,"name")&&"InvalidPasswordException"===e.name},I=function(e){return Object.entries(e).reduce((function(e,t){var r=v(t,2),a=r[0],o=r[1];return h(h({},e),{},p({},function(e){return"telephoneNumber"===e?"phone_number":n(e)}(a),o))}),{})},x=function(e){return h(h({},e),{},{emailMfaAccepted:e.emailMfaAccepted?new Date(e.emailMfaAccepted):void 0})},k=function(e,t){var r=Y("requestStatuses");z({requestStatuses:h(h({},r),{},p({},e,t))})},U=function(e){t.dispatch("custom",{data:{challenge:e},event:"challenge"})},M=function(e,r){t.dispatch("custom",{data:{errorDetails:r,errorType:e},event:"error"})},C=function(e,r){t.dispatch("custom",{data:r,event:e})},F=function(e){C(T.INIT,{session:e})},L=function(){var t=l(m().mark((function t(){var r,n,a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,n=r.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(n.payload.sub,"/mfa/secret"),{headers:{Authorization:n.getJwtToken()}}).then((function(e){return e.json()})).then((function(e){return e.secret}));case 6:return a=t.sent,t.abrupt("return",a);case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),D=function(){var t=l(m().mark((function t(){var r,n,a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,n=r.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(n.payload.sub,"/preferences"),{headers:{Authorization:n.getJwtToken()}}).then((function(e){return null==e?void 0:e.json()}));case 6:return a=t.sent,t.abrupt("return",a||{});case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),j=function(){var t=l(m().mark((function t(r){var n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,a=n.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(a.payload.sub,"/mfa"),{body:JSON.stringify({mfaType:r}),headers:{Authorization:a.getJwtToken()},method:"POST"}).then((function(e){if(2!==Math.floor(e.status/100))throw new Error("Request failed");return!0}));case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),G=function(){var t=l(m().mark((function t(r){var n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,a=n.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(a.payload.sub),{body:JSON.stringify(r),headers:{Authorization:a.getJwtToken()},method:"POST"}).then((function(e){return e.json()})).then((function(e){return e.success}));case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),V=function(){var t=l(m().mark((function t(r){var n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,a=n.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(a.payload.sub,"/preferences"),{body:JSON.stringify(r),headers:{Authorization:a.getJwtToken()},method:"POST"}).then((function(e){return e.json()})).then((function(e){return e.success}));case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),H=function(){var t=l(m().mark((function t(r){var n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return n=t.sent,a=n.getIdToken(),t.next=6,fetch("".concat(Y("usersEndpoint")).concat(a.payload.sub,"/mfa/secret"),{body:JSON.stringify({totpCode:r}),headers:{Authorization:a.getJwtToken()},method:"POST"}).then((function(e){if(2!==Math.floor(e.status/100))throw new Error("Request failed");return!0}));case 6:return o=t.sent,t.abrupt("return",o);case 8:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),W={centrePermissions:{},emailAddress:void 0,emailAddressVerified:!1,familyName:void 0,name:void 0,givenName:void 0,groups:[],id:void 0,isInitialized:!1,isSignedIn:!1,languagePreference:"en-gb",mfaType:void 0,middleName:void 0,preferences:{},provider:void 0,requestStatuses:Object.values(T).reduce((function(e,t){return h(h({},e),{},p({},t,"idle"))}),{}),telephoneNumber:void 0,telephoneNumberVerified:!1,totpVerified:!1,usersEndpoint:void 0},Y=function(e){return W[e]},z=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];Object.entries(e).forEach((function(e){var t=v(e,2),r=t[0],n=t[1];W[r]=n})),r&&t.dispatch("custom",{data:{updatedTimestamp:Date.now()},event:"cacheUpdated"})},B=function(){var e=l(m().mark((function e(t){var r,n,a,o,i,u;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t.getIdToken().payload,k(T.GET_USER_PREFERENCES,"loading"),e.next=4,D().then((function(e){return k(T.GET_USER_PREFERENCES,"done"),e})).catch((function(e){return M(T.GET_USER_PREFERENCES,e),{}}));case 4:i=e.sent,u=x(i),z({centrePermissions:JSON.parse(o["custom:centre_permissions"]||"{}"),emailAddress:o.email,emailAddressVerified:o.email_verified,familyName:o.family_name||o.familyName,name:o.name,givenName:o.given_name||o.givenName,groups:o["cognito:groups"]||[],id:o.sub,isInitialized:!0,isSignedIn:!0,languagePreference:o["custom:language_preference"],mfaType:o["custom:mfa_type"],middleName:o.middle_name||o.middleName,preferences:u,provider:(null===(r=o.identities)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.providerName)||"Cognito",telephoneNumber:o.phone_number,telephoneNumberVerified:o.phone_number_verified,totpVerified:"true"===(null===(a=o["custom:totp_verified"])||void 0===a?void 0:a.toLowerCase())});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),K=function(){z({centrePermissions:{},emailAddress:void 0,emailAddressVerified:!1,familyName:void 0,name:void 0,givenName:void 0,groups:[],id:void 0,isSignedIn:!1,languagePreference:void 0,mfaType:void 0,middleName:void 0,preferences:{},provider:void 0,telephoneNumber:void 0,telephoneNumberVerified:!1,totpVerified:!1})},J=function(t){return function(){var r=l(m().mark((function r(n){var a,o,i;return m().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return k(T.FORCE_CHANGE_PASSWORD,"loading"),r.next=3,e.completeNewPassword(t,n).catch((function(e){A(e)||P(e)||M(T.FORCE_CHANGE_PASSWORD,e),a=!1}));case 3:if(!(o=r.sent)){r.next=12;break}if(!o.challengeName){r.next=10;break}return r.next=8,q(o.challengeName,o,o.challengeParam);case 8:i=r.sent,U(i);case 10:k(T.FORCE_CHANGE_PASSWORD,"done"),a=!0;case 12:return r.abrupt("return",a);case 13:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()},Q=function(t){return function(){var r=l(m().mark((function r(n){var a;return m().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return k(T.SUBMIT_MFA_CODE,"loading"),r.next=3,e.sendCustomChallengeAnswer(t,n).then(function(){var e=l(m().mark((function e(r){return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==r||!r.challengeName){e.next=5;break}return e.next=3,q(r.challengeName,t,r.challengeParam);case 3:a=e.sent,U(a);case 5:k(T.SUBMIT_MFA_CODE,"done");case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){M(T.SUBMIT_MFA_CODE,e)}));case 3:return r.abrupt("return",a);case 4:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}()},q=function(t,r){var n,a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=Z(t,null==o?void 0:o.selectedMfaType);switch(i){case _.EMAIL_MFA:n={attemptNumber:o.attemptNumber?parseInt(o.attemptNumber):void 0,challengeType:_.EMAIL_MFA,completeChallenge:Q(r),emailAddress:o.emailAddress};break;case _.NEW_PASSWORD_REQUIRED:n={challengeType:_.NEW_PASSWORD_REQUIRED,completeChallenge:J(r)};break;case _.SMS_MFA:n={attemptNumber:o.attemptNumber?parseInt(o.attemptNumber):void 0,challengeType:i,completeChallenge:Q(r),telephoneNumber:t===_.CUSTOM_CHALLENGE?o.redactedPhoneNumber:o.CODE_DELIVERY_DESTINATION};break;case _.TOTP_MFA:n={attemptNumber:o.attemptNumber?parseInt(o.attemptNumber):void 0,challengeType:i,completeChallenge:Q(r)};break;case _.VERIFY_TELEPHONE_NUMBER:n={challengeType:i,completeChallenge:(a=o.currentMfaType,function(){var t=l(m().mark((function t(r){var n;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.VERIFY_TELEPHONE_NUMBER,"loading"),t.next=3,w(e.verifyCurrentUserAttributeSubmit("phone_number",r),T.VERIFY_TELEPHONE_NUMBER);case 3:if(!(n=t.sent)){t.next=9;break}if(z({telephoneNumberVerified:!0}),Y("mfaType")===b.SMS||a!==b.SMS){t.next=9;break}return t.next=9,se(b.SMS,!0);case 9:return t.abrupt("return",n);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())};break;case _.VERIFY_TOTP_TOKEN:n={challengeType:i,completeChallenge:function(){var e=l(m().mark((function e(t){var r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,me(t);case 2:return r=e.sent,e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),secretKey:o.secretKey}}return n},Z=function(e,t){if(e===_.CUSTOM_CHALLENGE)switch(t){case b.EMAIL:return _.EMAIL_MFA;case b.SMS:return _.SMS_MFA;case b.TOTP:return _.TOTP_MFA}return e},X=["amplifyConfig","oAuthConfig","usersEndpoint"],$=!1,ee=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.amplifyConfig,n=e.oAuthConfig,s=e.usersEndpoint,f=E(e,X),l=v(i(Date.now()),2);l[0];var p=l[1],d=u(!1),m=u(h({},f));c((function(){m.current=h({},f)}),S(Object.values(f)));var g=function(e){if(o(m.current[e])){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];(t=m.current[e]).call.apply(t,[void 0].concat(n))}};return c((function(){if(r||n||s){try{ie(r,n,s),d.current=!0,$=!0}catch(e){g("onError",T.INIT)}$&&!d.current&&a("WJEC One useAuthorization: Config should only be provided to the first instance of the useAuthorization hook in your component tree (recommendation is to include this in your entry point component, even if you don't need authorization tools at that point)")}}),[r,n,s]),c((function(){var e=!1,r=t.listen("auth",(function(t){var r=t.payload,n=r.data,a=r.event;if(!e)switch(a){case"completeNewPassword_failure":g("onError",T.FORCE_CHANGE_PASSWORD,n);break;case"forgotPassword":g("onRequestPasswordReset",n.username);break;case"forgotPassword_failure":g("onError",T.REQUEST_PASSWORD_RESET,n);break;case"forgotPasswordSubmit":g("onCompletePasswordReset");break;case"forgotPasswordSubmit_failure":g("onError",T.COMPLETE_PASSWORD_RESET,n);break;case"signIn_failure":g("onError",T.SIGN_IN,n);break;case"signOut":g("onSignOut");break;case"tokenRefresh":o(m.current.onRefreshSession)&&oe().then(m.current.onRefreshSession);break;case"tokenRefresh_failure":g("onError",T.REFRESH_USER_SESSION,n)}})),n=t.listen("custom",(function(t){var r=t.payload,n=r.data,a=r.event;if(!e)switch(a){case"cacheUpdated":p(n.updatedTimestamp);break;case"challenge":g("onChallenge",n.challenge);break;case"error":g("onError",n.errorType,n.errorDetails);break;case"init":g("onInit",n.session);break;case"setMfaType":g("onSetMfaType",n.mfaType);break;case T.SIGN_IN:g("onSignIn",n.session)}}));return function(){e=!0,r(),n()}}),[]),ve},te=["telephoneNumber"],re=R(function(){var t=l(m().mark((function t(r,n){var a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.CHANGE_PASSWORD,"loading"),t.next=3,e.currentAuthenticatedUser();case 3:return a=t.sent,t.abrupt("return",w(e.changePassword(a,r,n),T.CHANGE_PASSWORD));case 5:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),T.CHANGE_PASSWORD),ne=R((function(t,r,n){return k(T.COMPLETE_PASSWORD_RESET,"loading"),w(e.forgotPasswordSubmit(t,r,n),T.COMPLETE_PASSWORD_RESET)}),T.COMPLETE_PASSWORD_RESET),ae=R(l(m().mark((function e(){var t,r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oe();case 2:return t=e.sent,r=t.getIdToken().getJwtToken(),e.abrupt("return",r);case 5:case"end":return e.stop()}}),e)}))),T.GET_AUTHORIZATION_TOKEN),oe=R(l(m().mark((function t(){var r;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,t.abrupt("return",r);case 4:case"end":return t.stop()}}),t)}))),T.GET_USER_SESSION),ie=function(){var n=l(m().mark((function n(o,i,u){var c;return m().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!Y("isInitialized")){n.next=4;break}a("WJEC One Authorization: Config cannot be changed after initialization - the config that was originally provided will continue to be used"),n.next=23;break;case 4:if(o&&i&&u){n.next=8;break}throw new Error("WJEC One Authorization: Both amplifyConfig and oAuthConfig objects must be provided, in addition to the endpoint URL for the users service");case 8:return n.prev=8,r.configure(o),e.configure({oauth:i}),z({usersEndpoint:u},!1),t.listen("auth",function(){var e=l(m().mark((function e(t){var r,n,a;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.payload,n=r.data,a=r.event,e.t0=a,e.next="completeNewPassword_failure"===e.t0?4:"forgotPassword_failure"===e.t0?6:"forgotPasswordSubmit_failure"===e.t0?8:"signIn"===e.t0?10:"signIn_failure"===e.t0?14:"signOut"===e.t0?16:"signOut_failure"===e.t0?18:"tokenRefresh_failure"===e.t0?20:22;break;case 4:return k(T.FORCE_CHANGE_PASSWORD,"failed"),e.abrupt("break",22);case 6:return k(T.REQUEST_PASSWORD_RESET,"failed"),e.abrupt("break",22);case 8:return k(T.COMPLETE_PASSWORD_RESET,"failed"),e.abrupt("break",22);case 10:return e.next=12,B(n.signInUserSession);case 12:return C(T.SIGN_IN,{session:n.signInUserSession}),e.abrupt("break",22);case 14:return k(T.SIGN_IN,"failed"),e.abrupt("break",22);case 16:return K(),e.abrupt("break",22);case 18:return k(T.SIGN_OUT,"failed"),e.abrupt("break",22);case 20:return k(T.REFRESH_USER_SESSION,"failed"),e.abrupt("break",22);case 22:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),t.listen("custom",(function(e){var t=e.payload,r=t.data;if("error"===t.event){var n=r.errorType;"loading"===Y("requestStatuses")[n]&&k(n,"failed")}})),n.next=15,e.currentAuthenticatedUser({bypassCache:!0}).then(function(){var e=l(m().mark((function e(t){var r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.getSignInUserSession(),e.next=3,B(r);case 3:return e.abrupt("return",r);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(){}));case 15:(c=n.sent)||z({isInitialized:!0}),F(c),n.next=23;break;case 20:n.prev=20,n.t0=n.catch(8),M(T.INIT,n.t0);case 23:return n.abrupt("return",c);case 24:case"end":return n.stop()}}),n,null,[[8,20]])})));return function(e,t,r){return n.apply(this,arguments)}}(),ue=R(l(m().mark((function t(){var r,n,a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.currentSession();case 2:return r=t.sent,t.next=5,e.currentAuthenticatedUser();case 5:return n=t.sent,t.next=8,new Promise((function(e,t){try{n.refreshSession(r.getRefreshToken(),(function(t,r){if(t)throw t;e(r)}))}catch(e){M(T.REFRESH_USER_SESSION,e),t(e)}}));case 8:return a=t.sent,t.abrupt("return",a);case 10:case"end":return t.stop()}}),t)}))),T.REFRESH_USER_SESSION),ce=R((function(t){return k(T.REQUEST_PASSWORD_RESET,"loading"),w(e.forgotPassword(t),T.REQUEST_PASSWORD_RESET)}),T.REQUEST_PASSWORD_RESET),se=R(function(){var e=l(m().mark((function e(t){var r,n,a=arguments;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]&&a[1],k(T.SET_MFA_TYPE,"loading"),e.next=4,j(t).catch((function(e){return M(T.SET_MFA_TYPE,e),!1}));case 4:return(n=e.sent)&&(z({mfaType:t},r),C(T.SET_MFA_TYPE,{mfaType:t}),k(T.SET_MFA_TYPE,"done"),t!==b.EMAIL&&he({emailMfaAccepted:void 0})),e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),T.SET_MFA_TYPE),fe=R(l(m().mark((function t(){var r,n,a,o;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.REQUEST_TOTP_TOKEN,"loading"),n=Y("mfaType"),t.next=4,e.currentAuthenticatedUser();case 4:if(a=t.sent,n!==b.TOTP){t.next=8;break}return t.next=8,se(b.EMAIL);case 8:return t.next=10,L().catch((function(e){M(T.REQUEST_TOTP_TOKEN,e)}));case 10:if(!(o=t.sent)){t.next=18;break}return t.next=14,q(_.VERIFY_TOTP_TOKEN,a,{secretKey:o});case 14:r=t.sent,U(r),z({totpVerified:!1},!1),k(T.REQUEST_TOTP_TOKEN,"done");case 18:return t.abrupt("return",{challenge:r,secretKey:o});case 19:case"end":return t.stop()}}),t)}))),T.REQUEST_TOTP_TOKEN),le=R(function(){var t=l(m().mark((function t(r,n){var a,o,i;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.SIGN_IN,"loading"),t.next=3,e.signIn(r,n).catch((function(e){A(e)||M(T.SIGN_IN,e)}));case 3:if(!(o=t.sent)){t.next=16;break}if(!o.challengeName){t.next=15;break}if((null===(i=o.challengeParam)||void 0===i?void 0:i.selectedMfaType)!==b.NONE){t.next=11;break}return t.next=9,e.sendCustomChallengeAnswer(o,"N/A").catch((function(e){M(T.SIGN_IN,e)}));case 9:t.next=15;break;case 11:return t.next=13,q(o.challengeName,o,o.challengeParam);case 13:a=t.sent,U(a);case 15:k(T.SIGN_IN,"done");case 16:return t.abrupt("return",{challenge:a,user:o});case 17:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),T.SIGN_IN),pe=R((function(){return k(T.SIGN_OUT,"loading"),w(e.signOut(),T.SIGN_OUT)}),T.SIGN_OUT),de=R(function(){var t=l(m().mark((function t(r){var n,a,o,i,u,c,s;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=r.telephoneNumber,a=E(r,te),o=!0,k(T.UPDATE_USER_ATTRIBUTES,"loading"),!Object.hasOwn(r,"telephoneNumber")){t.next=13;break}return i=Y("telephoneNumber"),u=Y("telephoneNumberVerified"),t.next=8,e.currentAuthenticatedUser();case 8:return c=t.sent,t.next=11,w(e.updateUserAttributes(c,I({telephoneNumber:n})),T.UPDATE_USER_ATTRIBUTES,!1);case 11:(o=t.sent)&&z({telephoneNumber:n,telephoneNumberVerified:n===i&&u},!1);case 13:return t.next=15,G(a);case 15:return(s=t.sent)&&z(a,!1),k(T.UPDATE_USER_ATTRIBUTES,o&&s?"done":"failed"),t.abrupt("return",o&&s);case 19:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),T.UPDATE_USER_ATTRIBUTES),he=R(function(){var e=l(m().mark((function e(t){var r,n;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return k(T.UPDATE_USER_PREFERENCES,"loading"),r=h(h({},Y("preferences")),t),e.next=4,V(r).catch((function(e){return M(T.UPDATE_USER_PREFERENCES,e),!1}));case 4:return(n=e.sent)&&(z({preferences:r},!1),k(T.UPDATE_USER_PREFERENCES,"done")),e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),T.UPDATE_USER_PREFERENCES),Ee=R(l(m().mark((function t(){var r,n,a;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return k(T.VERIFY_TELEPHONE_NUMBER,"loading"),t.next=3,e.currentAuthenticatedUser();case 3:return n=t.sent,a=Y("mfaType"),t.next=7,w(e.verifyCurrentUserAttribute("phone_number"),T.VERIFY_TELEPHONE_NUMBER);case 7:if(!t.sent){t.next=17;break}return t.next=11,q(_.VERIFY_TELEPHONE_NUMBER,n,{currentMfaType:a});case 11:if(r=t.sent,a!==b.SMS){t.next=15;break}return t.next=15,se(b.EMAIL,!0);case 15:U(r),k(T.VERIFY_TELEPHONE_NUMBER,"done");case 17:return t.abrupt("return",r);case 18:case"end":return t.stop()}}),t)}))),T.VERIFY_TELEPHONE_NUMBER),me=R(function(){var e=l(m().mark((function e(t){var r;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return k(T.VERIFY_TOTP_TOKEN,"loading"),e.next=3,H(t).catch((function(e){return M(T.VERIFY_TOTP_TOKEN,e),!1}));case 3:return(r=e.sent)&&(z({totpVerified:!0},!1),k(T.VERIFY_TOTP_TOKEN,"done")),e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),T.VERIFY_TOTP_TOKEN),ve=Object.freeze({get centrePermissions(){return Y("centrePermissions")},get emailAddress(){return Y("emailAddress")},get emailAddressVerified(){return Y("emailAddressVerified")},get familyName(){return Y("familyName")},get name(){return Y("name")},get givenName(){return Y("givenName")},get groups(){return Y("groups")},get id(){return Y("id")},get isInitialized(){return Y("isInitialized")},get isSignedIn(){return Y("isSignedIn")},get languagePreference(){return Y("languagePreference")},get mfaType(){return Y("mfaType")},get middleName(){return Y("middleName")},get preferences(){return Y("preferences")},get provider(){return Y("provider")},get requestStatuses(){return Y("requestStatuses")},get telephoneNumber(){return Y("telephoneNumber")},get telephoneNumberVerified(){return Y("telephoneNumberVerified")},get totpVerified(){return Y("totpVerified")}});export{T as AuthAction,_ as ChallengeType,b as MFAType,O as Role,N as Subject,re as changePassword,ne as completePasswordReset,ae as getAuthorizationToken,oe as getUserSession,ie as init,ue as refreshUserSession,ce as requestPasswordReset,se as setMfaType,fe as setupTotp,le as signIn,pe as signOut,ve as state,de as updateUserAttributes,he as updateUserPreferences,ee as useAuthorization,Ee as verifyTelephoneNumber,me as verifyTotp};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
production: {
|
|
4
|
+
plugins: [
|
|
5
|
+
['emotion', { sourceMap: false }],
|
|
6
|
+
'@babel/proposal-class-properties',
|
|
7
|
+
'@babel/proposal-optional-chaining',
|
|
8
|
+
['module-resolver', {
|
|
9
|
+
root: ['./'],
|
|
10
|
+
alias: {
|
|
11
|
+
auth: './auth',
|
|
12
|
+
localization: './localization',
|
|
13
|
+
portal: './portal',
|
|
14
|
+
root: './',
|
|
15
|
+
src: './src',
|
|
16
|
+
store: './store',
|
|
17
|
+
test: './test',
|
|
18
|
+
theme: './theme',
|
|
19
|
+
utils: './utils'
|
|
20
|
+
}
|
|
21
|
+
}]
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
development: {
|
|
25
|
+
plugins: [
|
|
26
|
+
'emotion',
|
|
27
|
+
'@babel/proposal-class-properties',
|
|
28
|
+
'@babel/proposal-optional-chaining',
|
|
29
|
+
['module-resolver', {
|
|
30
|
+
root: ['./'],
|
|
31
|
+
alias: {
|
|
32
|
+
auth: './auth',
|
|
33
|
+
localization: './localization',
|
|
34
|
+
portal: './portal',
|
|
35
|
+
root: './',
|
|
36
|
+
src: './src',
|
|
37
|
+
store: './store',
|
|
38
|
+
test: './test',
|
|
39
|
+
theme: './theme',
|
|
40
|
+
utils: './utils'
|
|
41
|
+
}
|
|
42
|
+
}]
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
presets: [
|
|
47
|
+
'@babel/react',
|
|
48
|
+
'@babel/typescript',
|
|
49
|
+
'@emotion/babel-preset-css-prop',
|
|
50
|
+
['@babel/preset-env', {
|
|
51
|
+
corejs: '3.6.5',
|
|
52
|
+
targets: {
|
|
53
|
+
chrome: 58,
|
|
54
|
+
firefox: 62,
|
|
55
|
+
ie: 10
|
|
56
|
+
},
|
|
57
|
+
useBuiltIns: 'entry'
|
|
58
|
+
}]
|
|
59
|
+
].filter((e) => e),
|
|
60
|
+
sourceType: 'unambiguous'
|
|
61
|
+
};
|
|
62
|
+
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
env: {
|
|
5
|
+
browser: true,
|
|
6
|
+
es6: true,
|
|
7
|
+
node: true
|
|
8
|
+
},
|
|
9
|
+
extends: [
|
|
10
|
+
'plugin:@typescript-eslint/eslint-recommended',
|
|
11
|
+
'eslint:recommended',
|
|
12
|
+
'plugin:import/errors',
|
|
13
|
+
'plugin:import/warnings',
|
|
14
|
+
'plugin:import/typescript',
|
|
15
|
+
'plugin:react/recommended'
|
|
16
|
+
],
|
|
17
|
+
overrides: [
|
|
18
|
+
{
|
|
19
|
+
env: {
|
|
20
|
+
jest: true
|
|
21
|
+
},
|
|
22
|
+
files: [
|
|
23
|
+
'**/test/**/*.{ts,tsx}',
|
|
24
|
+
'*.test.{ts,tsx}'
|
|
25
|
+
],
|
|
26
|
+
globals: {
|
|
27
|
+
fetchMock: 'readonly'
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
camelcase: 'off',
|
|
31
|
+
'max-len': ['error', {
|
|
32
|
+
code: 120,
|
|
33
|
+
ignoreComments: true,
|
|
34
|
+
ignoreRegExpLiterals: true,
|
|
35
|
+
ignoreStrings: true
|
|
36
|
+
}],
|
|
37
|
+
'max-len': 'off',
|
|
38
|
+
'no-console': 'off',
|
|
39
|
+
'no-restricted-imports': 'off',
|
|
40
|
+
'padding-line-between-statements': 'off',
|
|
41
|
+
'import/first': 'off',
|
|
42
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
43
|
+
'@typescript-eslint/no-object-literal-type-assertion': 'off'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
files: ['**/demo/**/*', '**/scratchpad/**/*'],
|
|
48
|
+
rules: {
|
|
49
|
+
'max-len': ['error', {
|
|
50
|
+
code: 120,
|
|
51
|
+
ignoreComments: true,
|
|
52
|
+
ignoreRegExpLiterals: true,
|
|
53
|
+
ignoreStrings: true
|
|
54
|
+
}],
|
|
55
|
+
'no-restricted-imports': ['error', { patterns: ['./*', '../*', 'wjec-one/auth', 'wjec-one/localization', 'wjec-one/portal', 'wjec-one/services', 'wjec-one/store', 'wjec-one/test', 'wjec-one/theme', 'wjec-one/utils'] }]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
files: ['scripts/*.js'],
|
|
60
|
+
env: {
|
|
61
|
+
node: true
|
|
62
|
+
},
|
|
63
|
+
rules: {
|
|
64
|
+
'no-console': 'off',
|
|
65
|
+
'@typescript-eslint/no-var-requires': 'off'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
files: ['*.ts', '*.tsx'],
|
|
70
|
+
rules: {
|
|
71
|
+
'no-undef': 'off',
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
parser: '@typescript-eslint/parser',
|
|
76
|
+
parserOptions: {
|
|
77
|
+
ecmaVersion: '2019',
|
|
78
|
+
project: './config/tsconfig.json',
|
|
79
|
+
sourceType: 'module'
|
|
80
|
+
},
|
|
81
|
+
plugins: ['import', '@typescript-eslint'],
|
|
82
|
+
rules: {
|
|
83
|
+
'array-bracket-newline': ['error', 'consistent'],
|
|
84
|
+
'array-bracket-spacing': ['error', 'never'],
|
|
85
|
+
'array-element-newline': ['error', 'consistent'],
|
|
86
|
+
'arrow-body-style': 'error',
|
|
87
|
+
'arrow-parens': 'error',
|
|
88
|
+
'arrow-spacing': 'error',
|
|
89
|
+
'block-scoped-var': 'error',
|
|
90
|
+
'block-spacing': 'error',
|
|
91
|
+
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
|
92
|
+
camelcase: 'error',
|
|
93
|
+
'class-methods-use-this': ['error', { exceptMethods: ['render'] }],
|
|
94
|
+
'comma-dangle': ['error', 'never'],
|
|
95
|
+
'comma-spacing': 'error',
|
|
96
|
+
'comma-style': 'error',
|
|
97
|
+
'computed-property-spacing': 'error',
|
|
98
|
+
'consistent-return': ['error', { treatUndefinedAsUnspecified: true }],
|
|
99
|
+
curly: 'error',
|
|
100
|
+
'eol-last': 'error',
|
|
101
|
+
eqeqeq: 'error',
|
|
102
|
+
'func-call-spacing': 'error',
|
|
103
|
+
indent: ['error', 2, { SwitchCase: 1, VariableDeclarator: 'first' }],
|
|
104
|
+
'key-spacing': 'error',
|
|
105
|
+
'keyword-spacing': 'error',
|
|
106
|
+
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
|
|
107
|
+
'max-classes-per-file': 'error',
|
|
108
|
+
'max-len': ['error', {
|
|
109
|
+
code: 120,
|
|
110
|
+
ignoreComments: true,
|
|
111
|
+
ignoreRegExpLiterals: true
|
|
112
|
+
}],
|
|
113
|
+
'multiline-ternary': ['error', 'always-multiline'],
|
|
114
|
+
'new-parens': 'error',
|
|
115
|
+
'no-console': 'error',
|
|
116
|
+
'no-duplicate-imports': ['error', { includeExports: true }],
|
|
117
|
+
'no-else-return': 'error',
|
|
118
|
+
'no-empty-function': 'error',
|
|
119
|
+
'no-eval': 'error',
|
|
120
|
+
'no-floating-decimal': 'error',
|
|
121
|
+
'no-lone-blocks': 'error',
|
|
122
|
+
'no-lonely-if': 'error',
|
|
123
|
+
'no-loop-func': 'error',
|
|
124
|
+
'no-mixed-operators': 'error',
|
|
125
|
+
'no-multi-assign': 'error',
|
|
126
|
+
'no-multi-spaces': 'error',
|
|
127
|
+
'no-negated-condition': 'error',
|
|
128
|
+
'no-param-reassign': 'error',
|
|
129
|
+
// 'no-restricted-imports': ['error', { patterns: ['!./*', '!../*', '../../*', 'wjec-one/auth', 'wjec-one/localization', 'wjec-one/portal', 'wjec-one/services', 'wjec-one/store', 'wjec-one/test', 'wjec-one/theme', 'wjec-one/utils'] }],
|
|
130
|
+
'no-return-await': 'error',
|
|
131
|
+
'no-self-compare': 'error',
|
|
132
|
+
'no-sequences': 'error',
|
|
133
|
+
'no-shadow': 'off', // Overridden by @typescript-eslint
|
|
134
|
+
'no-shadow-restricted-names': 'error',
|
|
135
|
+
'no-tabs': 'error',
|
|
136
|
+
'no-template-curly-in-string': 'error',
|
|
137
|
+
'no-throw-literal': 'error',
|
|
138
|
+
'no-trailing-spaces': 'error',
|
|
139
|
+
'no-unneeded-ternary': 'error',
|
|
140
|
+
'no-unused-vars': 'off', // Overridden by @typescript-eslint
|
|
141
|
+
'no-use-before-define': 'off', // Overriden by @typescript-eslint
|
|
142
|
+
'no-useless-computed-key': 'error',
|
|
143
|
+
'no-useless-rename': 'error',
|
|
144
|
+
'no-useless-return': 'error',
|
|
145
|
+
'no-var': 'error',
|
|
146
|
+
'no-whitespace-before-property': 'error',
|
|
147
|
+
'object-curly-newline': ['error', { consistent: true }],
|
|
148
|
+
'object-curly-spacing': ['error', 'always'],
|
|
149
|
+
'object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
|
|
150
|
+
'object-shorthand': 'error',
|
|
151
|
+
'one-var': ['error', 'never'],
|
|
152
|
+
'padded-blocks': ['error', 'never'],
|
|
153
|
+
'padding-line-between-statements': [
|
|
154
|
+
'error',
|
|
155
|
+
{ blankLine: 'always', prev: '*', next: 'return' },
|
|
156
|
+
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
|
|
157
|
+
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] }
|
|
158
|
+
],
|
|
159
|
+
'prefer-arrow-callback': ['error', { allowUnboundThis: false }],
|
|
160
|
+
'prefer-const': 'error',
|
|
161
|
+
'prefer-object-spread': 'error',
|
|
162
|
+
'prefer-rest-params': 'error',
|
|
163
|
+
'prefer-spread': 'error',
|
|
164
|
+
'prefer-template': 'error',
|
|
165
|
+
quotes: ['error', 'single'],
|
|
166
|
+
'quote-props': ['error', 'as-needed'],
|
|
167
|
+
radix: ['error', 'as-needed'],
|
|
168
|
+
'require-atomic-updates': 'error',
|
|
169
|
+
'require-await': 'error',
|
|
170
|
+
'rest-spread-spacing': 'error',
|
|
171
|
+
semi: 'off', // Overidden by @typescript-eslint
|
|
172
|
+
'semi-spacing': 'error',
|
|
173
|
+
'semi-style': 'error',
|
|
174
|
+
'space-before-blocks': 'error',
|
|
175
|
+
'space-before-function-paren': ['error', {
|
|
176
|
+
anonymous: 'always',
|
|
177
|
+
named: 'never',
|
|
178
|
+
asyncArrow: 'always'
|
|
179
|
+
}],
|
|
180
|
+
'space-in-parens': 'error',
|
|
181
|
+
'spaced-comment': ['error', 'always', { exceptions: ['-', '/', '*'] }],
|
|
182
|
+
'switch-colon-spacing': 'error',
|
|
183
|
+
'template-curly-spacing': 'error',
|
|
184
|
+
'template-tag-spacing': 'error',
|
|
185
|
+
'wrap-iife': ['error', 'inside'],
|
|
186
|
+
yoda: "error",
|
|
187
|
+
'react/display-name': 'off',
|
|
188
|
+
'react/no-unknown-property': ['error', { ignore: ['css'] }],
|
|
189
|
+
'react/prop-types': 'off', // Don't need this with TypeScript
|
|
190
|
+
'import/first': 'error',
|
|
191
|
+
'import/no-mutable-exports': 'error',
|
|
192
|
+
'import/no-self-import': 'error',
|
|
193
|
+
'import/no-unresolved': ['error', { ignore: ['csstype'] }],
|
|
194
|
+
// Would like to have an unused exports check, but unfortunately this doesn't work well with TypeScript...
|
|
195
|
+
// Will replace with appropriate alternative once identified
|
|
196
|
+
// 'import/no-unused-modules': ['error', { unusedExports: true }],
|
|
197
|
+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
|
|
198
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
199
|
+
// '@typescript-eslint/indent': ['error', 2, { ObjectExpression: 2, VariableDeclarator: 'first' }],
|
|
200
|
+
'@typescript-eslint/indent': 'off', // Not sure why, but this doesn't seem to work as well as the standard rule
|
|
201
|
+
'@typescript-eslint/member-delimiter-style': ['error', {
|
|
202
|
+
singleline: { delimiter: 'comma' }
|
|
203
|
+
}],
|
|
204
|
+
'@typescript-eslint/member-ordering': 'error',
|
|
205
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
206
|
+
'@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
|
|
207
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^React$|^_' }],
|
|
208
|
+
'@typescript-eslint/no-use-before-define': ['error', { classes: true, functions: false, variables: false }],
|
|
209
|
+
'@typescript-eslint/prefer-includes': 'error',
|
|
210
|
+
'@typescript-eslint/prefer-interface': 'off',
|
|
211
|
+
'@typescript-eslint/semi': ['error'],
|
|
212
|
+
'@typescript-eslint/unified-signatures': 'error'
|
|
213
|
+
},
|
|
214
|
+
settings: {
|
|
215
|
+
'import/resolver': {
|
|
216
|
+
webpack: {
|
|
217
|
+
config: path.resolve(__dirname, './webpack.config.js')
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
react: {
|
|
221
|
+
version: 'detect'
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|