wjec-one 4.0.2 → 4.0.3-alpha.1
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.js +1 -1
- package/config/eslint-config.js +2 -1
- package/config/jest.config.js +12 -35
- package/config/utils.js +49 -0
- package/config/webpack.common.config.js +82 -0
- package/config/webpack.config.js +41 -206
- package/{scripts/config → config}/webpack.standalone.config.js +14 -9
- package/package.json +16 -17
- package/scripts/bin/wjec-one-scripts.js +8 -7
- package/scripts/build.js +5 -42
- package/scripts/check-tests.js +4 -23
- package/scripts/standalone.js +4 -25
- package/scripts/start.js +6 -21
- package/scripts/test.js +40 -59
- package/scripts/utils.js +44 -0
- package/test/setupTests.ts +1 -53
- package/test/setupTestsForPackage.ts +49 -0
- package/umd/auth/index.js +1 -1
- package/scripts/config/babel.config.js +0 -29
- package/test/index.d.ts +0 -106
- package/test/index.js +0 -1
- package/umd/test/index.js +0 -1
package/auth/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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){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)}}(),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};
|
|
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=_&&_(_(U([])));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 U(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=U,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:U(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(z("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){C(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!1!==r.updateStatus&&k(t,"done"),!0})).catch((function(e){return("function"==typeof r.isUnhandledError?r.isUnhandledError(e):e instanceof Error||"string"==typeof e)&&C(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"===g(e)&&Object.hasOwn(e,"name")&&"CodeMismatchException"===e.name},x=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))}),{})},U=function(e){return h(h({},e),{},{emailMfaAccepted:e.emailMfaAccepted?new Date(e.emailMfaAccepted):void 0})},k=function(e,t){var r=z("requestStatuses");B({requestStatuses:h(h({},r),{},p({},e,t))})},M=function(e){t.dispatch("custom",{data:{challenge:e},event:"challenge"})},C=function(e,r){t.dispatch("custom",{data:{errorDetails:r,errorType:e},event:"error"})},F=function(e,r){t.dispatch("custom",{data:r,event:e})},L=function(e){F(T.INIT,{session:e})},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(z("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)}}(),j=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(z("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)}}(),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(z("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)}}(),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(z("usersEndpoint")).concat(a.payload.sub),{body:JSON.stringify(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)}}(),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(z("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)}}(),W=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(z("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)}}(),Y={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},z=function(e){return Y[e]},B=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];Y[r]=n})),r&&t.dispatch("custom",{data:{updatedTimestamp:Date.now()},event:"cacheUpdated"})},K=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,j().then((function(e){return k(T.GET_USER_PREFERENCES,"done"),e})).catch((function(e){return C(T.GET_USER_PREFERENCES,e),{}}));case 4:i=e.sent,u=U(i),B({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)}}(),J=function(){B({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})},Q=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)||C(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,Z(o.challengeName,o,o.challengeParam);case 8:i=r.sent,M(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,Z(r.challengeName,t,r.challengeParam);case 3:a=e.sent,M(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){I(e)||C(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)}}()},Z=function(t,r){var n,a,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=X(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:Q(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(B({telephoneNumberVerified:!0}),z("mfaType")===b.SMS||a!==b.SMS){t.next=9;break}return t.next=9,fe(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,ve(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},X=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},$=["amplifyConfig","oAuthConfig","usersEndpoint"],ee=!1,te=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.amplifyConfig,n=e.oAuthConfig,s=e.usersEndpoint,f=E(e,$),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{ue(r,n,s),d.current=!0,ee=!0}catch(e){g("onError",T.INIT)}ee&&!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)&&ie().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()}}),[]),Se},re=["telephoneNumber"],ne=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),ae=R((function(t,r,n){return k(T.COMPLETE_PASSWORD_RESET,"loading"),w(e.forgotPasswordSubmit(t,r,n),T.COMPLETE_PASSWORD_RESET,{isUnhandledError:function(e){return!I(e)}})}),T.COMPLETE_PASSWORD_RESET),oe=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,ie();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),ie=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),ue=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(!z("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}),B({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,K(n.signInUserSession);case 12:return F(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 J(),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"===z("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,K(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)||B({isInitialized:!0}),L(c),n.next=23;break;case 20:n.prev=20,n.t0=n.catch(8),C(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)}}(),ce=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){C(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),se=R((function(t){return k(T.REQUEST_PASSWORD_RESET,"loading"),w(e.forgotPassword(t),T.REQUEST_PASSWORD_RESET)}),T.REQUEST_PASSWORD_RESET),fe=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,G(t).catch((function(e){return C(T.SET_MFA_TYPE,e),!1}));case 4:return(n=e.sent)&&(B({mfaType:t},r),F(T.SET_MFA_TYPE,{mfaType:t}),k(T.SET_MFA_TYPE,"done"),t!==b.EMAIL&&Ee({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),le=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=z("mfaType"),t.next=4,e.currentAuthenticatedUser();case 4:if(a=t.sent,n!==b.TOTP){t.next=8;break}return t.next=8,fe(b.EMAIL);case 8:return t.next=10,D().catch((function(e){C(T.REQUEST_TOTP_TOKEN,e)}));case 10:if(!(o=t.sent)){t.next=18;break}return t.next=14,Z(_.VERIFY_TOTP_TOKEN,a,{secretKey:o});case 14:r=t.sent,M(r),B({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),pe=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)||C(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){C(T.SIGN_IN,e)}));case 9:t.next=15;break;case 11:return t.next=13,Z(o.challengeName,o,o.challengeParam);case 13:a=t.sent,M(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),de=R((function(){return k(T.SIGN_OUT,"loading"),w(e.signOut(),T.SIGN_OUT)}),T.SIGN_OUT),he=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,re),o=!0,k(T.UPDATE_USER_ATTRIBUTES,"loading"),!Object.hasOwn(r,"telephoneNumber")){t.next=13;break}return i=z("telephoneNumber"),u=z("telephoneNumberVerified"),t.next=8,e.currentAuthenticatedUser();case 8:return c=t.sent,t.next=11,w(e.updateUserAttributes(c,x({telephoneNumber:n})),T.UPDATE_USER_ATTRIBUTES,{updateStatus:!1});case 11:(o=t.sent)&&B({telephoneNumber:n,telephoneNumberVerified:n===i&&u},!1);case 13:return t.next=15,V(a);case 15:return(s=t.sent)&&B(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),Ee=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({},z("preferences")),t),e.next=4,H(r).catch((function(e){return C(T.UPDATE_USER_PREFERENCES,e),!1}));case 4:return(n=e.sent)&&(B({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),me=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=z("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,Z(_.VERIFY_TELEPHONE_NUMBER,n,{currentMfaType:a});case 11:if(r=t.sent,a!==b.SMS){t.next=15;break}return t.next=15,fe(b.EMAIL,!0);case 15:M(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),ve=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,W(t).catch((function(e){return C(T.VERIFY_TOTP_TOKEN,e),!1}));case 3:return(r=e.sent)&&(B({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),Se=Object.freeze({get centrePermissions(){return z("centrePermissions")},get emailAddress(){return z("emailAddress")},get emailAddressVerified(){return z("emailAddressVerified")},get familyName(){return z("familyName")},get name(){return z("name")},get givenName(){return z("givenName")},get groups(){return z("groups")},get id(){return z("id")},get isInitialized(){return z("isInitialized")},get isSignedIn(){return z("isSignedIn")},get languagePreference(){return z("languagePreference")},get mfaType(){return z("mfaType")},get middleName(){return z("middleName")},get preferences(){return z("preferences")},get provider(){return z("provider")},get requestStatuses(){return z("requestStatuses")},get telephoneNumber(){return z("telephoneNumber")},get telephoneNumberVerified(){return z("telephoneNumberVerified")},get totpVerified(){return z("totpVerified")}});export{T as AuthAction,_ as ChallengeType,b as MFAType,O as Role,N as Subject,ne as changePassword,ae as completePasswordReset,oe as getAuthorizationToken,ie as getUserSession,ue as init,ce as refreshUserSession,se as requestPasswordReset,fe as setMfaType,le as setupTotp,pe as signIn,de as signOut,Se as state,he as updateUserAttributes,Ee as updateUserPreferences,te as useAuthorization,me as verifyTelephoneNumber,ve as verifyTotp};
|
package/config/eslint-config.js
CHANGED
|
@@ -189,8 +189,9 @@ module.exports = {
|
|
|
189
189
|
'react/prop-types': 'off', // Don't need this with TypeScript
|
|
190
190
|
'import/first': 'error',
|
|
191
191
|
'import/no-mutable-exports': 'error',
|
|
192
|
+
'import/no-named-as-default-member': 'off',
|
|
192
193
|
'import/no-self-import': 'error',
|
|
193
|
-
'import/no-unresolved':
|
|
194
|
+
'import/no-unresolved': 'off',
|
|
194
195
|
// Would like to have an unused exports check, but unfortunately this doesn't work well with TypeScript...
|
|
195
196
|
// Will replace with appropriate alternative once identified
|
|
196
197
|
// 'import/no-unused-modules': ['error', { unusedExports: true }],
|
package/config/jest.config.js
CHANGED
|
@@ -1,43 +1,19 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
const isProjectEnv = /node_modules[\\/]wjec-one[\\/]?$/.test(path.join(fs.realpathSync(__dirname), '../'));
|
|
5
|
-
|
|
6
4
|
const appPath = fs.realpathSync(process.cwd());
|
|
7
|
-
const
|
|
5
|
+
const testPath = path.resolve(__dirname, '../test');
|
|
8
6
|
|
|
9
7
|
const { overrides = {} } = require(path.join(appPath, 'package.json'));
|
|
10
8
|
const coverageThreshold = overrides.coverageThreshold === undefined ? 100 : overrides.coverageThreshold;
|
|
11
9
|
|
|
12
10
|
module.exports = {
|
|
13
11
|
collectCoverageFrom: [
|
|
14
|
-
'./auth/**/*.{ts,tsx}',
|
|
15
|
-
'./localization/**/*.{ts,tsx}',
|
|
16
|
-
'./portal/**/*.{ts,tsx}',
|
|
17
|
-
'./services/**/*.{ts,tsx}',
|
|
18
12
|
'./src/**/*.{ts,tsx}',
|
|
19
|
-
'./store/**/*.{ts,tsx}',
|
|
20
|
-
'./theme/**/*.{ts,tsx}',
|
|
21
|
-
'./utils/**/*.{ts,tsx}',
|
|
22
13
|
|
|
23
14
|
'!./**/*.d.ts',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
'!./portal/**/store/state.{ts,tsx}',
|
|
27
|
-
'!./services/index.ts',
|
|
28
|
-
'!./src/ColorPalette*.ts',
|
|
29
|
-
'!./src/components/**/styles.{ts,tsx}',
|
|
30
|
-
'!./src/StylePalette.ts',
|
|
31
|
-
'!./src/styles',
|
|
32
|
-
'!./test/**/*',
|
|
33
|
-
'!./theme/index.ts',
|
|
34
|
-
'!./theme/ThemeContext.ts',
|
|
35
|
-
'!./theme/ThemeState.ts',
|
|
36
|
-
'!./theme/utils.ts',
|
|
37
|
-
'!./**/types',
|
|
38
|
-
'!./types.ts',
|
|
39
|
-
'!./utils/index.ts',
|
|
40
|
-
'!./utils/ConfigUtils.ts'
|
|
15
|
+
|
|
16
|
+
...(overrides.ignoreCoverage || []).map((p) => `!./${p}`)
|
|
41
17
|
],
|
|
42
18
|
coverageReporters: ['cobertura', 'json', 'text'],
|
|
43
19
|
coverageThreshold: {
|
|
@@ -48,24 +24,25 @@ module.exports = {
|
|
|
48
24
|
statements: coverageThreshold
|
|
49
25
|
}
|
|
50
26
|
},
|
|
51
|
-
coverageDirectory:
|
|
27
|
+
coverageDirectory: `${appPath}/test-coverage`,
|
|
52
28
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
|
|
53
29
|
moduleNameMapper: {
|
|
54
|
-
|
|
55
|
-
'\\.
|
|
30
|
+
// eslint-disable-next-line max-len
|
|
31
|
+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': path.resolve(testPath, 'assetsTransformer.ts'),
|
|
32
|
+
'\\.svg': path.join(testPath, 'svgTransformer.tsx'),
|
|
56
33
|
'^src/(.&)$': '<rootDir>/src/$1'
|
|
57
34
|
},
|
|
58
|
-
modulePaths: [
|
|
35
|
+
modulePaths: ['./'],
|
|
59
36
|
modulePathIgnorePatterns: ['./lib', 'dist'],
|
|
60
37
|
roots: [
|
|
61
38
|
'<rootDir>'
|
|
62
39
|
],
|
|
63
|
-
rootDir:
|
|
40
|
+
rootDir: appPath,
|
|
64
41
|
setupFiles: [
|
|
65
|
-
|
|
42
|
+
path.join(testPath, 'setupTests.ts')
|
|
66
43
|
],
|
|
67
|
-
setupFilesAfterEnv:
|
|
68
|
-
snapshotSerializers:
|
|
44
|
+
setupFilesAfterEnv: [path.join(testPath, 'setupTestsAfterEnv.ts')],
|
|
45
|
+
snapshotSerializers: ['@emotion/jest/serializer'],
|
|
69
46
|
testEnvironment: 'jsdom',
|
|
70
47
|
testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'],
|
|
71
48
|
transform: {
|
package/config/utils.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const appPath = fs.realpathSync(process.cwd());
|
|
5
|
+
const configFilePath = path.resolve(appPath, './config/config.json');
|
|
6
|
+
const packageFilePath = path.resolve(appPath, './package.json');
|
|
7
|
+
|
|
8
|
+
const config = require(configFilePath);
|
|
9
|
+
const { overrides = {}, version } = require(packageFilePath);
|
|
10
|
+
|
|
11
|
+
const currentTimestamp = Date.now();
|
|
12
|
+
|
|
13
|
+
const generateFilename = (filename = '[name]') => {
|
|
14
|
+
const { filenameSuffix } = overrides;
|
|
15
|
+
let suffix = filenameSuffix;
|
|
16
|
+
|
|
17
|
+
switch (filenameSuffix) {
|
|
18
|
+
case 'buildId':
|
|
19
|
+
suffix = process.env.BITBUCKET_BUILD_NUMBER;
|
|
20
|
+
break;
|
|
21
|
+
case 'currentTimestamp':
|
|
22
|
+
suffix = currentTimestamp;
|
|
23
|
+
break;
|
|
24
|
+
case 'version':
|
|
25
|
+
suffix = getVersionNumber();
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return suffix
|
|
30
|
+
? `${filename}.${suffix}.js`
|
|
31
|
+
: `${filename}.js`;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const getVersionNumber = () => {
|
|
35
|
+
const { property, source } = overrides.versionNumberSource || { property: 'version', source: 'package' };
|
|
36
|
+
|
|
37
|
+
switch (source) {
|
|
38
|
+
case 'env':
|
|
39
|
+
return process.env[property];
|
|
40
|
+
case 'config':
|
|
41
|
+
return config[property];
|
|
42
|
+
default:
|
|
43
|
+
return version;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
generateFilename
|
|
49
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const babelConfig = require('./babel.config');
|
|
2
|
+
|
|
3
|
+
module.exports = (_env, { mode }) => ({
|
|
4
|
+
devtool: mode === 'production' ? undefined : 'inline-source-map',
|
|
5
|
+
mode,
|
|
6
|
+
module: {
|
|
7
|
+
rules: [{
|
|
8
|
+
exclude: /node_modules/,
|
|
9
|
+
loader: 'babel-loader',
|
|
10
|
+
options: babelConfig,
|
|
11
|
+
test: /\.(js|jsx|ts|tsx)$/
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
test: /\.mjs$/,
|
|
15
|
+
include: /node_modules/,
|
|
16
|
+
type: 'javascript/auto'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
test: /\.(png|jp(e*)g)$/,
|
|
20
|
+
use: [{
|
|
21
|
+
loader: 'url-loader',
|
|
22
|
+
options: {
|
|
23
|
+
limit: 5000000,
|
|
24
|
+
name: 'images/[name].[ext]'
|
|
25
|
+
}
|
|
26
|
+
}]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
test: /\.svg$/,
|
|
30
|
+
use: [{
|
|
31
|
+
loader: '@svgr/webpack',
|
|
32
|
+
options: {
|
|
33
|
+
dimensions: false,
|
|
34
|
+
ref: true,
|
|
35
|
+
replaceAttrValues: {
|
|
36
|
+
'#000': 'currentColor',
|
|
37
|
+
'#2D3538': 'currentColor',
|
|
38
|
+
'#2E3638': 'currentColor'
|
|
39
|
+
},
|
|
40
|
+
svgoConfig: {
|
|
41
|
+
plugins: [{
|
|
42
|
+
name: 'preset-default',
|
|
43
|
+
params: {
|
|
44
|
+
overrides: {
|
|
45
|
+
removeViewBox: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}]
|
|
49
|
+
},
|
|
50
|
+
svgProps: {
|
|
51
|
+
xmlns: 'http://www.w3.org/2000/svg'
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: 'javascript/auto',
|
|
58
|
+
test: /config\/*\.json$/,
|
|
59
|
+
exclude: /node_modules/,
|
|
60
|
+
use: {
|
|
61
|
+
loader: 'file-loader',
|
|
62
|
+
options: {
|
|
63
|
+
name: './config/[name].json',
|
|
64
|
+
publicPath: '../'
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
test: /\.(ttf|eot|woff|woff2)$/,
|
|
70
|
+
use: {
|
|
71
|
+
loader: 'file-loader',
|
|
72
|
+
options: {
|
|
73
|
+
name: './fonts/[name].[ext]',
|
|
74
|
+
publicPath: '../'
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}]
|
|
78
|
+
},
|
|
79
|
+
optimization: {
|
|
80
|
+
usedExports: true
|
|
81
|
+
}
|
|
82
|
+
});
|