@aws-amplify/ui 5.3.0 → 5.4.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.
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as n}from"tslib";import{Hub as e}from"aws-amplify";import{waitFor as r}from"xstate/lib/waitFor";import{ALLOWED_SPECIAL_CHARACTERS as a}from"./constants.js";import{getActorState as o}from"./actor.js";var u=function(t){for(var n=t.trim().split(""),e=0;e<n.length;e++)e>0&&e<n.length-1&&(n[e]="*");return n.join("")},i=function(t){if(t.length<4)return t;for(var n=t.split(""),e=0;e<n.length-4;e++)n[e]="*";return n.join("")},c=function(e){return t(void 0,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,r(e,(function(t){return o(t).matches("autoSignIn")}))];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},s=function(e,r){return t(void 0,void 0,void 0,(function(){var t,a,u,i;return n(this,(function(n){switch(n.label){case 0:switch(t=r.send,a=r.getSnapshot(),e.payload.event){case"tokenRefresh":return[3,1];case"autoSignIn":return[3,2];case"autoSignIn_failure":return[3,5];case"signOut":case"tokenRefresh_failure":return[3,7]}return[3,8];case 1:return a.matches("authenticated.idle")&&t("TOKEN_REFRESH"),[3,9];case 2:return a.matches("authenticated")?[3,4]:[4,c(r)];case 3:n.sent(),(null==(u=o(r.getSnapshot()))?void 0:u.matches("autoSignIn"))&&t({type:"AUTO_SIGN_IN",data:e.payload.data}),n.label=4;case 4:return[3,9];case 5:return[4,c(r)];case 6:return n.sent(),(null==(i=o(r.getSnapshot()))?void 0:i.matches("autoSignIn"))&&t({type:"AUTO_SIGN_IN_FAILURE",data:e.payload.data}),[3,9];case 7:return a.matches("authenticated.idle")&&t("SIGN_OUT"),[3,9];case 8:return[3,9];case 9:return[2]}}))}))},h=function(t,n){return void 0===n&&(n=s),e.listen("auth",function(t,n){return function(e){n(e,t)}}(t,n),"authenticator-hub-handler")},l=function(t){return a.some((function(n){return t.includes(n)}))},f=function(t,n,e){return encodeURI("otpauth://totp/".concat(t,":").concat(n,"?secret=").concat(e,"&issuer=").concat(t))};export{u as censorAllButFirstAndLast,i as censorPhoneNumber,s as defaultAuthHubHandler,f as getTotpCodeURL,l as hasSpecialChars,h as listenToAuthHub};
1
+ import{__awaiter as t,__generator as n}from"tslib";import{Hub as e}from"aws-amplify";import{appendToCognitoUserAgent as r}from"@aws-amplify/auth";import{waitFor as a}from"xstate/lib/waitFor";import{ALLOWED_SPECIAL_CHARACTERS as o}from"./constants.js";import{getActorState as c}from"./actor.js";var u=function(t){var n=t.packageName,e=t.version;r("".concat(n,"/").concat(e))},i=function(t){for(var n=t.trim().split(""),e=0;e<n.length;e++)e>0&&e<n.length-1&&(n[e]="*");return n.join("")},s=function(t){if(t.length<4)return t;for(var n=t.split(""),e=0;e<n.length-4;e++)n[e]="*";return n.join("")},f=function(e){return t(void 0,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,a(e,(function(t){return c(t).matches("autoSignIn")}))];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},h=function(e,r){return t(void 0,void 0,void 0,(function(){var t,a,o,u;return n(this,(function(n){switch(n.label){case 0:switch(t=r.send,a=r.getSnapshot(),e.payload.event){case"tokenRefresh":return[3,1];case"autoSignIn":return[3,2];case"autoSignIn_failure":return[3,5];case"signOut":case"tokenRefresh_failure":return[3,7]}return[3,8];case 1:return a.matches("authenticated.idle")&&t("TOKEN_REFRESH"),[3,9];case 2:return a.matches("authenticated")?[3,4]:[4,f(r)];case 3:n.sent(),(null==(o=c(r.getSnapshot()))?void 0:o.matches("autoSignIn"))&&t({type:"AUTO_SIGN_IN",data:e.payload.data}),n.label=4;case 4:return[3,9];case 5:return[4,f(r)];case 6:return n.sent(),(null==(u=c(r.getSnapshot()))?void 0:u.matches("autoSignIn"))&&t({type:"AUTO_SIGN_IN_FAILURE",data:e.payload.data}),[3,9];case 7:return a.matches("authenticated.idle")&&t("SIGN_OUT"),[3,9];case 8:return[3,9];case 9:return[2]}}))}))},l=function(t,n){return void 0===n&&(n=h),e.listen("auth",function(t,n){return function(e){n(e,t)}}(t,n),"authenticator-hub-handler")},d=function(t){return o.some((function(n){return t.includes(n)}))},m=function(t,n,e){return encodeURI("otpauth://totp/".concat(t,":").concat(n,"?secret=").concat(e,"&issuer=").concat(t))};export{i as censorAllButFirstAndLast,s as censorPhoneNumber,u as configureComponent,h as defaultAuthHubHandler,m as getTotpCodeURL,d as hasSpecialChars,l as listenToAuthHub};
@@ -1 +1 @@
1
- var e={"Account recovery requires verified contact information":"La récupération du compte nécessite des informations de contact vérifiées","Back to Sign In":"Retour à la connexion","Change Password":"Modifier le mot de passe",Changing:"Modification en cours",Code:"Code","Confirm Password":"Confirmez le mot de passe","Confirm Sign Up":"Confirmer l'inscription","Confirm SMS Code":"Confirmer le code SMS","Confirm TOTP Code":"Confirmer le code TOTP",Confirm:"Confirmer","Confirmation Code":"Code de confirmation",Confirming:"Confirmation","Create a new account":"Créer un nouveau compte","Create Account":"Créer un compte","Creating Account":"Création d'un compte","Dismiss alert":"Supprimer l'alerte",Email:"Email","Enter your code":"Saisissez cotre code de confirmation","Enter your email":"Saisissez votre adresse email","Enter your phone number":"Saisissez votre numéro de téléphone","Enter your username":"Saisissez votre nom d'utilisateur","Forgot your password?":"Mot de passe oublié ? ","Hide password":"Masquer le mot de passe",Loading:"Chargement en cours","New password":"Nouveau mot de passe",Password:"Mot de passe","Phone Number":"Numéro de téléphone","Resend Code":"Renvoyer le code","Reset your Password":"Réinitialiser votre mot de passe","Reset your password":"Réinitialisez votre mot de passe","Send code":"Envoyer le code","Send Code":"M'envoyer un code",Sending:"Envoi en cours","Setup TOTP":"Configuration de TOTP","Show password":"Afficher le mot de passe","Sign in to your account":"Connexion à votre compte","Sign In with Amazon":"Se connecter avec Amazon","Sign In with Apple":"Se connecter avec Apple","Sign In with Facebook":"Se connecter avec Facebook","Sign In with Google":"Se connecter avec Google","Sign in":"Se connecter","Sign In":"Se connecter","Signing in":"Connexion en cours",Skip:"Passer",Submit:"Soumettre",Submitting:"Envoi en cours",Username:"Nom d'utilisateur","Verify Contact":"Vérifier le contact",Verify:"Vérifier","An account with the given email already exists.":"Un utilisateur avec cette adresse email existe déjà.",Change:"Modifier","Confirm a Code":"Confirmer un code","Confirm Sign In":"Confirmer la connexion","Create account":"Créer un compte","Enter your password":"Saisissez votre mot de passe","Forgot Password":"Mot de passe oublié","Have an account? ":"Déjà un compte ? ",Hello:"Bonjour","Incorrect username or password":"Identifiant ou mot de passe incorrect","Invalid password format":"Format de mot de passe invalide","Invalid phone number format":"Format de numéro de téléphone invalide. Veuillez utiliser un format +12345678900","Loading...":"Chargement...","Lost your code? ":"Vous avez perdu votre code ? ","Network error":"Erreur réseau","New Password":"Nouveau mot de passe","No account? ":"Pas de compte ? ",or:"ou","Resend a Code":"Renvoyer un code","Reset password":"Réinitialisez votre mot de passe",Send:"Envoyer","Sign In with AWS":"Se connecter avec AWS","Sign Out":"Déconnexion","Sign Up":"S'inscrire",SMS:"SMS","User already exists":"L'utilisateur existe déjà","User does not exist":"L'utilisateur n'existe pas","Username cannot be empty":"Le nom d'utilisateur doit être renseigné","Username/client id combination not found.":"L'utilisateur n'existe pas"};export{e as frDict};
1
+ var e={"Account recovery requires verified contact information":"La récupération du compte nécessite des informations de contact vérifiées","Back to Sign In":"Retour à la connexion","Change Password":"Modifier le mot de passe",Changing:"Modification en cours",Code:"Code","Confirm Password":"Confirmez le mot de passe","Confirm Sign Up":"Confirmer l'inscription","Confirm SMS Code":"Confirmer le code SMS","Confirm TOTP Code":"Confirmer le code TOTP",Confirm:"Confirmer","Confirmation Code":"Code de confirmation",Confirming:"Confirmation","Create a new account":"Créer un nouveau compte","Create Account":"Créer un compte","Creating Account":"Création d'un compte","Dismiss alert":"Supprimer l'alerte",Email:"Email","Enter your code":"Saisissez cotre code de confirmation","Enter your email":"Saisissez votre adresse email","Enter your phone number":"Saisissez votre numéro de téléphone","Enter your username":"Saisissez votre nom d'utilisateur","Forgot your password?":"Mot de passe oublié ? ","Hide password":"Masquer le mot de passe",Loading:"Chargement en cours","New password":"Nouveau mot de passe",Password:"Mot de passe","Phone Number":"Numéro de téléphone","Resend Code":"Renvoyer le code","Reset your Password":"Réinitialiser votre mot de passe","Reset your password":"Réinitialisez votre mot de passe","Send code":"Envoyer le code","Send Code":"M'envoyer un code",Sending:"Envoi en cours","Setup TOTP":"Configuration de TOTP","Show password":"Afficher le mot de passe","Sign in to your account":"Connexion à votre compte","Sign In with Amazon":"Se connecter avec Amazon","Sign In with Apple":"Se connecter avec Apple","Sign In with Facebook":"Se connecter avec Facebook","Sign In with Google":"Se connecter avec Google","Sign in":"Se connecter","Sign In":"Se connecter","Signing in":"Connexion en cours",Skip:"Passer",Submit:"Soumettre",Submitting:"Envoi en cours",Username:"Nom d'utilisateur","Verify Contact":"Vérifier le contact",Verify:"Vérifier","An account with the given email already exists.":"Un utilisateur avec cette adresse email existe déjà.",Change:"Modifier","Confirm a Code":"Confirmer un code","Confirm Sign In":"Confirmer la connexion","Create account":"Créer un compte","Enter your password":"Saisissez votre mot de passe","Forgot Password":"Mot de passe oublié","Have an account? ":"Déjà un compte ? ",Hello:"Bonjour","Incorrect username or password":"Identifiant ou mot de passe incorrect","Invalid password format":"Format de mot de passe invalide","Invalid phone number format":"Format de numéro de téléphone invalide. Veuillez utiliser un format +12345678900","Loading...":"Chargement...","Lost your code? ":"Vous avez perdu votre code ? ","Network error":"Erreur réseau","New Password":"Nouveau mot de passe","No account? ":"Pas de compte ? ",or:"ou","Resend a Code":"Renvoyer un code","Reset password":"Réinitialisez votre mot de passe",Send:"Envoyer","Sign In with AWS":"Se connecter avec AWS","Sign Out":"Déconnexion","Sign Up":"S'inscrire",SMS:"SMS","User already exists":"L'utilisateur existe déjà","User does not exist":"L'utilisateur n'existe pas","Username cannot be empty":"Le nom d'utilisateur doit être renseigné","Username/client id combination not found.":"L'utilisateur n'existe pas","We Emailed You":"Nous vous avons envoyé un code","Your code is on the way. To log in, enter the code we emailed to":"Votre code est en route. Pour vous connecter entrez le code reçu sur cette adresse email","Your code is on the way. To log in, enter the code we texted to":"Votre code est en route. Pour vous connecter entrez le code reçu sur ce numéro de téléphone","It may take a minute to arrive.":"Cela peut prendre quelques minutes."};export{e as frDict};
@@ -0,0 +1 @@
1
+ var n={"Account recovery requires verified contact information":"שחזור לקוח דורש עוד מידע","Back to Sign In":"חזור להרשמה","Change Password":"עדכון סיסמא",Changing:"מעדכן",Code:"קוד","Confirm Password":"אשר סיסמא","Confirm Sign Up":"אשר הרשמה","Confirm SMS Code":"אשר sms קוד","Confirm TOTP Code":"אשר totp קוד",Confirm:"אישור","Confirmation Code":"אישור קוד",Confirming:"מאשר","Create a new account":"צור משתמש חדש","Create Account":"צור משתמש","Creating Account":"יצירת משתמש","Dismiss alert":"הסר התראה",Email:"אימייל","Enter your code":"הכנס את הקוד","Enter your email":"הכנס את המייל שלך","Enter your phone number":"הכנס את מספר הטלפון שלך","Enter your username":"הכנס את שם המתמש שלך","Forgot your password?":"שחכת סיסמא ?","Hide password":"הסתר סיסמא",Loading:"טוען","New password":"סיסמא חדשה",Password:"סיסמא","Phone Number":"מספר טלפון","Resend Code":"שלח קוד שוב","Reset your password":"אפס סיסמא","Reset your Password":"אפס סיסמא","Send code":"שלח קוד","Send Code":"שלח קוד",Sending:"שולח","Setup TOTP":"Setup TOTP","Show password":"הצג סיסמא","Sign in to your account":"התחבר לחשבון שלך","Sign In with Amazon":"Sign In with Amazon","Sign In with Apple":"Sign In with Apple","Sign In with Facebook":"Sign In with Facebook","Sign In with Google":"Sign In with Google","Sign in":"התחבר","Sign In":"התחבר","Signing in":"מתחבר",Skip:"דלג",Submit:"שלח",Submitting:"שולח",Username:"שם משתמש","Verify Contact":"אמת איש קשר",Verify:"אמת"};export{n as heDict};
@@ -1 +1 @@
1
- var o={"Account recovery requires verified contact information":"Il ripristino dell'account richiede informazioni di contatto verificate","Back to Sign In":"Torna alla schermata di accesso","Change Password":"Cambia la password",Changing:"Modifica in corso",Code:"Codice","Confirm Password":"Conferma la password","Confirm Sign Up":"Conferma registrazione","Confirm SMS Code":"Conferma codice SMS","Confirm TOTP Code":"Conferma codice TOTP",Confirm:"Conferma","Confirmation Code":"Codice di verifica",Confirming:"Conferma in corso","Create a new account":"Crea un nuovo account","Create Account":"Crea Account","Creating Account":"Creazione account in corso","Dismiss alert":"Ignora l'avviso",Email:"Email","Enter your code":"Inserisci il tuo codice","Enter your email":"Inserisci la tua e-mail","Enter your phone number":'Inserisci il tuo numero di telefono"',"Enter your username":"Inserisci il tuo nome utente","Forgot your password?":"Password dimenticata?","Hide password":"Nascondi password",Loading:"Caricamento in corso","New password":"Nuova password",Password:"Password","Phone Number":"Numero di telefono","Resend Code":"Invia nuovamente il codice","Reset your Password":"Reimposta la tua Password","Reset your password":"Reimposta la tua password","Send code":"Invia codice","Send Code":"Invia codice",Sending:"Invio in corso","Setup TOTP":"Configura TOTP","Show password":"Mostra password","Sign in to your account":"Accedi al tuo account","Sign In with Amazon":"Accedi con Amazon","Sign In with Apple":"Accedi con Apple","Sign In with Facebook":"Accedi con Facebook","Sign In with Google":"Accedi con Google","Sign in":"Accedi","Sign In":"Accedi","Signing in":"Accesso in corso",Skip:"Salta",Submit:"Invia",Submitting:"Invio in corso",Username:"Nome utente","Verify Contact":"Verifica contatto",Verify:"Verifica","An account with the given email already exists.":"Questa email è già utilizzata da un altro account.","Confirm a Code":"Conferma un codice","Confirm Sign In":"Conferma l'accesso","Create account":"Crea account","Enter your password":"Inserisci la tua password","Forgot Password":"Password dimenticata","Have an account? ":"Già registrato?","Incorrect username or password":"Nome utente o password errati","Invalid password format":"Formato della password non valido","Invalid phone number format":"Formato del numero di telefono non valido","Lost your code?":"Codice smarrito?","New Password":"Nuova password","No account? ":"Non hai un account?",or:"o","Password attempts exceeded":"Il numero massimo di tentativi di accesso falliti è stato raggiunto","Reset password":"Reimposta password","Sign Out":"Esci","Sign Up":"Registrati","User already exists":"Utente già esistente","User does not exist":"Utente inesistente","Username cannot be empty":"Il nome utente non può essere vuoto"};export{o as itDict};
1
+ var o={"Account recovery requires verified contact information":"Il ripristino dell'account richiede informazioni di contatto verificate","Back to Sign In":"Torna alla schermata di accesso","Change Password":"Cambia la password",Changing:"Modifica in corso",Code:"Codice","Confirm Password":"Conferma la password","Confirm Sign Up":"Conferma registrazione","Confirm SMS Code":"Conferma codice SMS","Confirm TOTP Code":"Conferma codice TOTP",Confirm:"Conferma","Confirmation Code":"Codice di verifica",Confirming:"Conferma in corso","Create a new account":"Crea un nuovo account","Create Account":"Crea Account","Creating Account":"Creazione account in corso","Dismiss alert":"Ignora l'avviso",Email:"Email","Enter your code":"Inserisci il tuo codice","Enter your email":"Inserisci la tua e-mail","Enter your phone number":'Inserisci il tuo numero di telefono"',"Enter your username":"Inserisci il tuo nome utente","Forgot your password?":"Password dimenticata?","Hide password":"Nascondi password",Loading:"Caricamento in corso","New password":"Nuova password",Password:"Password","Phone Number":"Numero di telefono","Resend Code":"Invia nuovamente il codice","Reset your Password":"Reimposta la tua Password","Reset your password":"Reimposta la tua password","Send code":"Invia codice","Send Code":"Invia codice",Sending:"Invio in corso","Setup TOTP":"Configura TOTP","Show password":"Mostra password","Sign in to your account":"Accedi al tuo account","Sign In with Amazon":"Accedi con Amazon","Sign In with Apple":"Accedi con Apple","Sign In with Facebook":"Accedi con Facebook","Sign In with Google":"Accedi con Google","Sign in":"Accedi","Sign In":"Accedi","Signing in":"Accesso in corso",Skip:"Salta",Submit:"Invia",Submitting:"Invio in corso",Username:"Nome utente","Verify Contact":"Verifica contatto",Verify:"Verifica","An account with the given email already exists.":"Questa email è già utilizzata da un altro account.","Confirm a Code":"Conferma un codice","Confirm Sign In":"Conferma l'accesso","Create account":"Crea account","Enter your password":"Inserisci la tua password","Forgot Password?":"Password dimenticata?","Have an account? ":"Già registrato?","Incorrect username or password":"Nome utente o password errati","Invalid password format":"Formato della password non valido","Invalid phone number format":"Formato del numero di telefono non valido","Lost your code?":"Codice smarrito?","New Password":"Nuova password","No account? ":"Non hai un account?",or:"o","Password attempts exceeded":"Il numero massimo di tentativi di accesso falliti è stato raggiunto","Reset password":"Reimposta password","Sign Out":"Esci","Sign Up":"Registrati","User already exists":"Utente già esistente","User does not exist":"Utente inesistente","Username cannot be empty":"Il nome utente non può essere vuoto"};export{o as itDict};
@@ -1 +1 @@
1
- import{__assign as t}from"tslib";import{deDict as r}from"./authenticator/de.js";import{enDict as a}from"./authenticator/en.js";import{esDict as i}from"./authenticator/es.js";import{frDict as o}from"./authenticator/fr.js";import{itDict as s}from"./authenticator/it.js";import{jaDict as m}from"./authenticator/ja.js";import{krDict as c}from"./authenticator/kr.js";import{nlDict as e}from"./authenticator/nl.js";import{plDict as p}from"./authenticator/pl.js";import{ptDict as f}from"./authenticator/pt.js";import{zhDict as n}from"./authenticator/zh.js";import{svDict as u}from"./authenticator/sv.js";import{idDict as h}from"./authenticator/id.js";import{trDict as j}from"./authenticator/tr.js";import{ruDict as D}from"./authenticator/ru.js";import{defaultTexts as l}from"./authenticator/defaultTexts.js";var d=t({},r),v=t({},a),x=t({},i),k=t({},o),z=t({},s),T=t({},m),b=t({},c),g=t({},e),q=t({},p),w=t({},f),y=t({},n),A=t({},u),B=t({},h),C=t({},j),E=t({},D),F=t({},l);export{d as deDict,F as defaultTexts,v as enDict,x as esDict,k as frDict,B as idDict,z as itDict,T as jaDict,b as krDict,g as nlDict,q as plDict,w as ptDict,E as ruDict,A as svDict,C as trDict,y as zhDict};
1
+ import{__assign as t}from"tslib";import{deDict as r}from"./authenticator/de.js";import{enDict as a}from"./authenticator/en.js";import{esDict as i}from"./authenticator/es.js";import{frDict as o}from"./authenticator/fr.js";import{itDict as s}from"./authenticator/it.js";import{jaDict as m}from"./authenticator/ja.js";import{krDict as c}from"./authenticator/kr.js";import{nlDict as e}from"./authenticator/nl.js";import{plDict as p}from"./authenticator/pl.js";import{ptDict as f}from"./authenticator/pt.js";import{zhDict as h}from"./authenticator/zh.js";import{svDict as n}from"./authenticator/sv.js";import{idDict as u}from"./authenticator/id.js";import{trDict as j}from"./authenticator/tr.js";import{ruDict as D}from"./authenticator/ru.js";import{heDict as l}from"./authenticator/he.js";import{defaultTexts as d}from"./authenticator/defaultTexts.js";var v=t({},r),x=t({},a),k=t({},i),z=t({},o),T=t({},s),b=t({},m),g=t({},c),q=t({},e),w=t({},p),y=t({},f),A=t({},h),B=t({},n),C=t({},u),E=t({},j),F=t({},D),G=t({},l),H=t({},d);export{v as deDict,H as defaultTexts,x as enDict,k as esDict,z as frDict,G as heDict,C as idDict,T as itDict,b as jaDict,g as krDict,q as nlDict,w as plDict,y as ptDict,F as ruDict,B as svDict,E as trDict,A as zhDict};
@@ -1 +1 @@
1
- import{__assign as r}from"tslib";import{I18n as t}from"aws-amplify";import{defaultTexts as i,deDict as e,enDict as n,esDict as o,frDict as f,idDict as m,itDict as p,jaDict as a,krDict as s,nlDict as u,plDict as d,ptDict as l,zhDict as c,svDict as v,trDict as g,ruDict as j}from"./dictionaries/index.js";var x=r({},i);function b(r){return t.get(r)}function h(r){return t.get(r)!==r}var k={de:e,en:n,es:o,fr:f,id:m,it:p,ja:a,kr:s,nl:u,pl:d,pt:l,zh:c,sv:v,tr:g,ru:j};export{x as DefaultTexts,h as hasTranslation,b as translate,k as translations};
1
+ import{__assign as r}from"tslib";import{I18n as t}from"aws-amplify";import{defaultTexts as i,deDict as e,enDict as n,esDict as o,frDict as f,idDict as m,itDict as p,jaDict as a,krDict as s,nlDict as u,plDict as d,ptDict as l,zhDict as c,svDict as v,trDict as g,ruDict as h,heDict as j}from"./dictionaries/index.js";var x=r({},i);function b(r){return t.get(r)}function k(r){return t.get(r)!==r}var w={de:e,en:n,es:o,fr:f,id:m,it:p,ja:a,kr:s,nl:u,pl:d,pt:l,zh:c,sv:v,tr:g,ru:h,he:j};export{x as DefaultTexts,k as hasTranslation,b as translate,w as translations};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{getActorContext,getActorState}from"./helpers/authenticator/actor.js";export{getConfiguredAliases,getPrimaryAlias}from"./helpers/authenticator/context.js";export{getSendEventAliases,getServiceContextFacade,getServiceFacade}from"./helpers/authenticator/facade.js";export{ALLOWED_SPECIAL_CHARACTERS,defaultFormFieldOptions}from"./helpers/authenticator/constants.js";export{getErrors,getFormDataFromEvent,isAuthFieldWithDefaults,setFormOrder}from"./helpers/authenticator/form.js";export{censorAllButFirstAndLast,censorPhoneNumber,defaultAuthHubHandler,getTotpCodeURL,hasSpecialChars,listenToAuthHub}from"./helpers/authenticator/utils.js";export{getDefaultFormFields,getFormFields,getSortedFormFields}from"./helpers/authenticator/formFields/formFields.js";export{defaultFormFieldsGetters}from"./helpers/authenticator/formFields/defaults.js";export{applyDefaults,applyTranslation,sortFormFields}from"./helpers/authenticator/formFields/util.js";export{authenticatorTextUtil}from"./helpers/authenticator/textUtil.js";export{changePassword,deleteUser}from"./helpers/accountSettings/utils.js";export{getDefaultConfirmPasswordValidators,getDefaultPasswordValidators,runFieldValidators}from"./helpers/accountSettings/validator.js";export{checkMaxSize,humanFileSize,isValidExtension,returnAcceptedFiles,uploadFile}from"./helpers/storage/fileUploader/utils/uploader.js";export{getLogger}from"./helpers/utils.js";export{countryDialCodes}from"./i18n/country-dial-codes.js";export{DefaultTexts,hasTranslation,translate,translations}from"./i18n/translations.js";export{createAuthenticatorMachine}from"./machines/authenticator/index.js";export{createTheme}from"./theme/createTheme.js";export{defaultTheme}from"./theme/defaultTheme.js";export{defaultDarkModeOverride,reactNativeDarkTokens}from"./theme/defaultDarkModeOverride.js";export{reactNativeTokens}from"./theme/tokens/index.js";export{cssNameTransform,isDesignToken,setupTokens}from"./theme/utils.js";export{FederatedIdentityProviders,UnverifiedContactMethodType}from"./types/authenticator/user.js";export{isUnverifiedContactMethodType}from"./types/authenticator/utils.js";export{LoginMechanismArray,authFieldsWithDefaults,signUpFieldsWithDefault,signUpFieldsWithoutDefault}from"./types/authenticator/attributes.js";export{ComponentClassName}from"./types/primitives/componentClassName.js";
1
+ export{getActorContext,getActorState}from"./helpers/authenticator/actor.js";export{getConfiguredAliases,getPrimaryAlias}from"./helpers/authenticator/context.js";export{getSendEventAliases,getServiceContextFacade,getServiceFacade}from"./helpers/authenticator/facade.js";export{ALLOWED_SPECIAL_CHARACTERS,defaultFormFieldOptions}from"./helpers/authenticator/constants.js";export{getErrors,getFormDataFromEvent,isAuthFieldWithDefaults,setFormOrder}from"./helpers/authenticator/form.js";export{censorAllButFirstAndLast,censorPhoneNumber,configureComponent,defaultAuthHubHandler,getTotpCodeURL,hasSpecialChars,listenToAuthHub}from"./helpers/authenticator/utils.js";export{getDefaultFormFields,getFormFields,getSortedFormFields}from"./helpers/authenticator/formFields/formFields.js";export{defaultFormFieldsGetters}from"./helpers/authenticator/formFields/defaults.js";export{applyDefaults,applyTranslation,sortFormFields}from"./helpers/authenticator/formFields/util.js";export{authenticatorTextUtil}from"./helpers/authenticator/textUtil.js";export{changePassword,deleteUser}from"./helpers/accountSettings/utils.js";export{getDefaultConfirmPasswordValidators,getDefaultPasswordValidators,runFieldValidators}from"./helpers/accountSettings/validator.js";export{checkMaxSize,humanFileSize,isValidExtension,returnAcceptedFiles,uploadFile}from"./helpers/storage/fileUploader/utils/uploader.js";export{getLogger}from"./helpers/utils.js";export{countryDialCodes}from"./i18n/country-dial-codes.js";export{DefaultTexts,hasTranslation,translate,translations}from"./i18n/translations.js";export{createAuthenticatorMachine}from"./machines/authenticator/index.js";export{createTheme}from"./theme/createTheme.js";export{defaultTheme}from"./theme/defaultTheme.js";export{defaultDarkModeOverride,reactNativeDarkTokens}from"./theme/defaultDarkModeOverride.js";export{reactNativeTokens}from"./theme/tokens/index.js";export{cssNameTransform,isDesignToken,setupTokens}from"./theme/utils.js";export{FederatedIdentityProviders,UnverifiedContactMethodType}from"./types/authenticator/user.js";export{isUnverifiedContactMethodType}from"./types/authenticator/utils.js";export{LoginMechanismArray,authFieldsWithDefaults,signUpFieldsWithDefault,signUpFieldsWithoutDefault}from"./types/authenticator/attributes.js";export{ComponentClassName}from"./types/primitives/componentClassName.js";
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as r}from"tslib";import{createMachine as t,sendUpdate as n}from"xstate";import{runValidators as s}from"../../../validators/index.js";import{clearError as o,clearFormValues as a,clearTouched as i,clearUsername as d,clearValidationError as l,handleInput as c,handleSubmit as u,handleBlur as m,setFieldErrors as p,setRemoteError as g,setUsername as v}from"../actions.js";import{defaultServices as f}from"../defaultServices.js";function E(E){var h=E.services;return t({id:"resetPasswordActor",initial:"init",predictableActionArguments:!0,states:{init:{always:[{target:"confirmResetPassword",cond:"shouldAutoConfirmReset"},{target:"resetPassword"}]},resetPassword:{initial:"edit",exit:["clearFormValues","clearError","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},CHANGE:{actions:"handleInput"},BLUR:{actions:"handleBlur"}}},submit:{tags:["pending"],entry:["sendUpdate","setUsername","clearError"],invoke:{src:"resetPassword",onDone:{target:"#resetPasswordActor.confirmResetPassword"},onError:{actions:["setRemoteError"],target:"edit"}}}}},confirmResetPassword:{type:"parallel",exit:["clearFormValues","clearError","clearUsername","clearTouched"],states:{validation:{initial:"pending",states:{pending:{invoke:{src:"validateFields",onDone:{target:"valid",actions:"clearValidationError"},onError:{target:"invalid",actions:"setFieldErrors"}}},valid:{entry:"sendUpdate"},invalid:{entry:"sendUpdate"}},on:{CHANGE:{actions:"handleInput",target:".pending"},BLUR:{actions:"handleBlur",target:".pending"}}},submission:{initial:"idle",states:{idle:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"validate"},RESEND:"resendCode",CHANGE:{actions:"handleInput"},BLUR:{actions:"handleBlur"}}},validate:{entry:"sendUpdate",invoke:{src:"validateFields",onDone:{target:"pending",actions:"clearValidationError"},onError:{target:"idle",actions:"setFieldErrors"}}},resendCode:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"resetPassword",onDone:{target:"idle"},onError:{actions:"setRemoteError",target:"idle"}}},pending:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"confirmResetPassword",onDone:{actions:"clearUsername",target:"#resetPasswordActor.resolved"},onError:{actions:"setRemoteError",target:"idle"}}}}}}},resolved:{type:"final"}}},{actions:{clearError:o,clearFormValues:a,clearTouched:i,clearUsername:d,clearValidationError:l,handleInput:c,handleSubmit:u,handleBlur:m,setFieldErrors:p,setRemoteError:g,setUsername:v,sendUpdate:n()},guards:{shouldAutoConfirmReset:function(e,r){return!(!e.intent||"confirmPasswordReset"!==e.intent)}},services:{resetPassword:function(t){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){return e=t.username,[2,h.handleForgotPassword(e)]}))}))},confirmResetPassword:function(t){return e(this,void 0,void 0,(function(){var e,n,s,o;return r(this,(function(r){return e=t.username,n=t.formValues,s=n.confirmation_code,o=n.password,[2,h.handleForgotPasswordSubmit({username:e,code:s,password:o})]}))}))},validateFields:function(t,n){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,s(t.formValues,t.touched,t.passwordSettings,[f.validateConfirmPassword])]}))}))}}})}export{E as resetPasswordActor};
1
+ import{__awaiter as e,__generator as r}from"tslib";import{createMachine as t,sendUpdate as n}from"xstate";import{runValidators as s}from"../../../validators/index.js";import{clearError as a,clearFormValues as o,clearTouched as i,clearUsername as d,clearValidationError as l,handleInput as c,handleSubmit as u,handleBlur as m,setFieldErrors as p,setRemoteError as g,setUsername as v}from"../actions.js";import{defaultServices as f}from"../defaultServices.js";function E(E){var h=E.services;return t({id:"resetPasswordActor",initial:"init",predictableActionArguments:!0,states:{init:{always:[{target:"confirmResetPassword",cond:"shouldAutoConfirmReset"},{target:"resetPassword"}]},resetPassword:{initial:"edit",exit:["clearFormValues","clearError","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},CHANGE:{actions:"handleInput"},BLUR:{actions:"handleBlur"}}},submit:{tags:["pending"],entry:["sendUpdate","setUsername","clearError"],invoke:{src:"resetPassword",onDone:{target:"#resetPasswordActor.confirmResetPassword"},onError:{actions:["setRemoteError"],target:"edit"}}}}},confirmResetPassword:{type:"parallel",exit:["clearFormValues","clearError","clearUsername","clearTouched"],states:{validation:{initial:"pending",states:{pending:{invoke:{src:"validateFields",onDone:{target:"valid",actions:"clearValidationError"},onError:{target:"invalid",actions:"setFieldErrors"}}},valid:{entry:"sendUpdate"},invalid:{entry:"sendUpdate"}},on:{CHANGE:{actions:"handleInput",target:".pending"},BLUR:{actions:"handleBlur",target:".pending"}}},submission:{initial:"idle",states:{idle:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"validate"},RESEND:"resendCode",CHANGE:{actions:"handleInput"},BLUR:{actions:"handleBlur"}}},validate:{entry:"sendUpdate",invoke:{src:"validateFields",onDone:{target:"pending",actions:"clearValidationError"},onError:{target:"idle",actions:"setFieldErrors"}}},resendCode:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"resetPassword",onDone:{target:"idle"},onError:{actions:"setRemoteError",target:"idle"}}},pending:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"confirmResetPassword",onDone:{actions:"clearUsername",target:"#resetPasswordActor.resolved"},onError:{actions:"setRemoteError",target:"idle"}}}}}}},resolved:{type:"final"}}},{actions:{clearError:a,clearFormValues:o,clearTouched:i,clearUsername:d,clearValidationError:l,handleInput:c,handleSubmit:u,handleBlur:m,setFieldErrors:p,setRemoteError:g,setUsername:v,sendUpdate:n()},guards:{shouldAutoConfirmReset:function(e,r){return!(!e.intent||"confirmPasswordReset"!==e.intent)}},services:{resetPassword:function(t){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){return e=t.username,[2,h.handleForgotPassword(e)]}))}))},confirmResetPassword:function(t){return e(this,void 0,void 0,(function(){var e,n,s,a;return r(this,(function(r){return e=t.username,n=t.formValues,s=n.confirmation_code,a=n.password,[2,h.handleForgotPasswordSubmit({username:e,code:s,password:a})]}))}))},validateFields:function(t,n){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,s(t.formValues,t.touched,t.passwordSettings,[f.validateFormPassword,f.validateConfirmPassword])]}))}))}}})}export{E as resetPasswordActor};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as r,__rest as n}from"tslib";import{Auth as i}from"aws-amplify";import o from"lodash/get";import s from"lodash/isEmpty";import{createMachine as a,sendUpdate as c}from"xstate";import{runValidators as d}from"../../../validators/index.js";import{clearAttributeToVerify as u,clearChallengeName as l,clearRequiredAttributes as g,clearError as f,clearFormValues as m,clearTouched as h,clearUnverifiedContactMethods as I,clearValidationError as p,handleInput as v,handleSubmit as A,handleBlur as U,parsePhoneNumber as S,setChallengeName as E,setConfirmResetPasswordIntent as b,setConfirmSignUpIntent as y,setRequiredAttributes as T,setCredentials as C,setFieldErrors as N,setRemoteError as w,setUnverifiedContactMethods as R,setUser as P,setUsernameAuthAttributes as V}from"../actions.js";import{defaultServices as _}from"../defaultServices.js";var F=["SMS_MFA","SOFTWARE_TOKEN_MFA"],k=function(e){return o(e,"data.challengeName")},O=function(e,t){return e===t},D=function(e){return F.includes(e)};function M(o){var F=o.services;return a({initial:"init",id:"signInActor",predictableActionArguments:!0,states:{init:{always:[{target:"autoSignIn.submit",cond:"shouldAutoSubmit"},{target:"autoSignIn",cond:"shouldAutoSignIn"},{target:"signIn"}]},signIn:{initial:"edit",exit:["clearFormValues","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},CHANGE:{actions:"handleInput"},FEDERATED_SIGN_IN:"federatedSignIn"}},federatedSignIn:{tags:["pending"],entry:["sendUpdate","clearError"],invoke:{src:"federatedSignIn",onError:{actions:"setRemoteError"}}},submit:{tags:["pending"],entry:["parsePhoneNumber","clearError","sendUpdate"],invoke:{src:"signIn",onDone:[{cond:"shouldSetupTOTP",actions:["setUser","setChallengeName"],target:"#signInActor.setupTOTP"},{cond:"shouldConfirmSignIn",actions:["setUser","setChallengeName"],target:"#signInActor.confirmSignIn"},{cond:"shouldForceChangePassword",actions:["setUser","setChallengeName","setRequiredAttributes"],target:"#signInActor.forceNewPassword"},{actions:"setUser",target:"verifying"}],onError:[{cond:"shouldRedirectToConfirmSignUp",actions:["setCredentials","setConfirmSignUpIntent"],target:"rejected"},{cond:"shouldRedirectToConfirmResetPassword",actions:["setUsernameAuthAttributes","setConfirmResetPasswordIntent"],target:"rejected"},{actions:"setRemoteError",target:"edit"}]}},verifying:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"checkVerifiedContact",onDone:[{cond:"shouldRequestVerification",target:"#signInActor.verifyUser",actions:"setUnverifiedContactMethods"},{target:"resolved"}],onError:{actions:"setRemoteError",target:"edit"}}},resolved:{always:"#signInActor.resolved"},rejected:{always:"#signInActor.rejected"}}},autoSignIn:{initial:"pending",states:{pending:{tags:["pending"],entry:["clearError","sendUpdate"],on:{AUTO_SIGN_IN:[{cond:"shouldSetupTOTP",actions:["setUser","setChallengeName"],target:"#signInActor.setupTOTP"},{cond:"shouldConfirmSignIn",actions:["setUser","setChallengeName"],target:"#signInActor.confirmSignIn"},{cond:"shouldForceChangePassword",actions:["setUser","setChallengeName","setRequiredAttributes"],target:"#signInActor.forceNewPassword"},{actions:"setUser",target:"#signInActor.resolved"}],AUTO_SIGN_IN_FAILURE:{actions:"setRemoteError",target:"pending"}}},submit:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"signIn",onDone:[{cond:"shouldSetupTOTP",actions:["setUser","setChallengeName"],target:"#signInActor.setupTOTP"},{cond:"shouldConfirmSignIn",actions:["setUser","setChallengeName"],target:"#signInActor.confirmSignIn"},{cond:"shouldForceChangePassword",actions:["setUser","setChallengeName","setRequiredAttributes"],target:"#signInActor.forceNewPassword"},{actions:"setUser",target:"#signInActor.resolved"}],onError:{actions:"setRemoteError",target:"#signInActor.signIn"}}},resolved:{always:"#signInActor.resolved"},rejected:{always:"#signInActor.rejected"}}},confirmSignIn:{initial:"edit",exit:["clearFormValues","clearError","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},SIGN_IN:"#signInActor.signIn",CHANGE:{actions:"handleInput"}}},submit:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"confirmSignIn",onDone:{target:"#signInActor.resolved",actions:["setUser","clearChallengeName","clearRequiredAttributes"]},onError:{target:"edit",actions:"setRemoteError"}}}}},forceNewPassword:{type:"parallel",exit:["clearFormValues","clearError","clearTouched"],states:{validation:{initial:"pending",states:{pending:{invoke:{src:"validateFields",onDone:{target:"valid",actions:"clearValidationError"},onError:{target:"invalid",actions:"setFieldErrors"}}},valid:{entry:"sendUpdate"},invalid:{entry:"sendUpdate"}},on:{SIGN_IN:"#signInActor.signIn",CHANGE:{actions:"handleInput",target:".pending"},BLUR:{actions:"handleBlur",target:".pending"}}},submit:{initial:"idle",entry:"clearError",states:{idle:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"validate"}}},validate:{entry:"sendUpdate",invoke:{src:"validateFields",onDone:{target:"pending",actions:"clearValidationError"},onError:{target:"idle",actions:"setFieldErrors"}}},pending:{tags:["pending"],entry:["sendUpdate","clearError"],invoke:{src:"forceNewPassword",onDone:[{cond:"shouldConfirmSignIn",actions:["setUser","setChallengeName"],target:"#signInActor.confirmSignIn"},{cond:"shouldSetupTOTP",actions:["setUser","setChallengeName"],target:"#signInActor.setupTOTP"},{target:"resolved",actions:["setUser","setCredentials"]}],onError:{target:"idle",actions:"setRemoteError"}}},resolved:{type:"final",always:"#signInActor.resolved"}}}}},setupTOTP:{initial:"edit",exit:["clearFormValues","clearError","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},SIGN_IN:"#signInActor.signIn",CHANGE:{actions:"handleInput"}}},submit:{tags:["pending"],entry:["sendUpdate","clearError"],invoke:{src:"verifyTotpToken",onDone:{actions:["clearChallengeName","clearRequiredAttributes"],target:"#signInActor.resolved"},onError:{actions:"setRemoteError",target:"edit"}}}}},verifyUser:{initial:"edit",exit:["clearFormValues","clearError","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},SKIP:"#signInActor.resolved",CHANGE:{actions:"handleInput"}}},submit:{tags:["pending"],entry:"clearError",invoke:{src:"verifyUser",onDone:{target:"#signInActor.confirmVerifyUser"},onError:{actions:"setRemoteError",target:"edit"}}}}},confirmVerifyUser:{initial:"edit",exit:["clearFormValues","clearError","clearUnverifiedContactMethods","clearAttributeToVerify","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},SKIP:"#signInActor.resolved",CHANGE:{actions:"handleInput"}}},submit:{tags:["pending"],entry:"clearError",invoke:{src:"confirmVerifyUser",onDone:{target:"#signInActor.resolved"},onError:{actions:"setRemoteError",target:"edit"}}}}},resolved:{type:"final",data:function(e){return{user:e.user}}},rejected:{type:"final",data:function(e,t){return{intent:e.redirectIntent,authAttributes:e.authAttributes}}}}},{actions:{clearAttributeToVerify:u,clearChallengeName:l,clearRequiredAttributes:g,clearError:f,clearFormValues:m,clearTouched:h,clearUnverifiedContactMethods:I,clearValidationError:p,handleInput:v,handleSubmit:A,handleBlur:U,parsePhoneNumber:S,setChallengeName:E,setConfirmResetPasswordIntent:b,setConfirmSignUpIntent:y,setRequiredAttributes:T,setCredentials:C,setFieldErrors:N,setRemoteError:w,setUnverifiedContactMethods:R,setUser:P,setUsernameAuthAttributes:V,sendUpdate:c()},guards:{shouldAutoSignIn:function(e){return"autoSignIn"===(null==e?void 0:e.intent)},shouldAutoSubmit:function(e){return"autoSignInSubmit"===(null==e?void 0:e.intent)},shouldConfirmSignIn:function(e,t){return D(k(t))},shouldForceChangePassword:function(e,t){return O(k(t),"NEW_PASSWORD_REQUIRED")},shouldRedirectToConfirmResetPassword:function(e,t){return"PasswordResetRequiredException"===t.data.code},shouldRedirectToConfirmSignUp:function(e,t){return"UserNotConfirmedException"===t.data.code},shouldRequestVerification:function(e,t){var r=t.data,n=r.unverified,i=r.verified;return s(i)&&!s(n)},shouldSetupTOTP:function(e,t){return O(k(t),"MFA_SETUP")}},services:{signIn:function(n){return e(this,void 0,void 0,(function(){var e,i,o,s,a,c,d;return t(this,(function(t){switch(t.label){case 0:return e=n.authAttributes,i=void 0===e?{}:e,o=n.formValues,s=void 0===o?{}:o,a=r(r({},i),s),c=a.username,d=a.password,[4,F.handleSignIn({username:c,password:d})];case 1:return[2,t.sent()]}}))}))},confirmSignIn:function(r){return e(this,void 0,void 0,(function(){var e,n,o,s;return t(this,(function(t){switch(t.label){case 0:return e=r.challengeName,n=r.user,o=r.formValues.confirmation_code,s=D(e)?e:void 0,[4,F.handleConfirmSignIn({user:n,code:o,mfaType:s})];case 1:return t.sent(),[4,i.currentAuthenticatedUser()];case 2:return[2,t.sent()]}}))}))},forceNewPassword:function(o){return e(this,void 0,void 0,(function(){var e,s,a,c,d,u,l,g,f;return t(this,(function(t){switch(t.label){case 0:e=o.user,s=o.formValues,a=s.password,s.confirm_password,c=s.phone_number,d=s.country_code,u=n(s,["password","confirm_password","phone_number","country_code"]),c&&(l="".concat(d).concat(c).replace(/[^A-Z0-9+]/gi,""),u=r(r({},u),{phone_number:l})),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,i.completeNewPassword(e,a,u)];case 2:return(g=t.sent()).challengeName?[2,g]:[2,i.currentAuthenticatedUser()];case 3:return f=t.sent(),[2,Promise.reject(f)];case 4:return[2]}}))}))},verifyTotpToken:function(r){return e(this,void 0,void 0,(function(){var e,n,o;return t(this,(function(t){return e=r.formValues,n=r.user,o=e.confirmation_code,[2,i.verifyTotpToken(n,o)]}))}))},federatedSignIn:function(r,n){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=n.data.provider,[4,i.federatedSignIn({provider:e})];case 1:return[2,t.sent()]}}))}))},checkVerifiedContact:function(r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=r.user,[4,i.verifiedContact(e)];case 1:return[2,t.sent()]}}))}))},verifyUser:function(r){return e(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=r.formValues.unverifiedAttr,[4,i.verifyCurrentUserAttribute(e)];case 1:return n=t.sent(),r.attributeToVerify=e,[2,n]}}))}))},confirmVerifyUser:function(r){return e(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=r.attributeToVerify,n=r.formValues.confirmation_code,[4,i.verifyCurrentUserAttributeSubmit(e,n)];case 1:return[2,t.sent()]}}))}))},validateFields:function(r){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,d(r.formValues,r.touched,r.passwordSettings,[_.validateConfirmPassword])]}))}))}}})}export{M as signInActor};
1
+ import{__awaiter as e,__generator as t,__assign as r,__rest as n}from"tslib";import{Auth as i}from"aws-amplify";import o from"lodash/get";import s from"lodash/isEmpty";import{createMachine as a,sendUpdate as c}from"xstate";import{runValidators as d}from"../../../validators/index.js";import{clearAttributeToVerify as u,clearChallengeName as l,clearRequiredAttributes as g,clearError as f,clearFormValues as m,clearTouched as h,clearUnverifiedContactMethods as I,clearValidationError as p,handleInput as v,handleSubmit as A,handleBlur as U,parsePhoneNumber as S,setChallengeName as E,setConfirmResetPasswordIntent as b,setConfirmSignUpIntent as y,setRequiredAttributes as T,setCredentials as C,setFieldErrors as N,setRemoteError as w,setUnverifiedContactMethods as R,setUser as P,setUsernameAuthAttributes as V}from"../actions.js";import{defaultServices as _}from"../defaultServices.js";var F=["SMS_MFA","SOFTWARE_TOKEN_MFA"],k=function(e){return o(e,"data.challengeName")},O=function(e,t){return e===t},D=function(e){return F.includes(e)};function M(o){var F=o.services;return a({initial:"init",id:"signInActor",predictableActionArguments:!0,states:{init:{always:[{target:"autoSignIn.submit",cond:"shouldAutoSubmit"},{target:"autoSignIn",cond:"shouldAutoSignIn"},{target:"signIn"}]},signIn:{initial:"edit",exit:["clearFormValues","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},CHANGE:{actions:"handleInput"},FEDERATED_SIGN_IN:"federatedSignIn"}},federatedSignIn:{tags:["pending"],entry:["sendUpdate","clearError"],invoke:{src:"federatedSignIn",onError:{actions:"setRemoteError"}}},submit:{tags:["pending"],entry:["parsePhoneNumber","clearError","sendUpdate"],invoke:{src:"signIn",onDone:[{cond:"shouldSetupTOTP",actions:["setUser","setChallengeName"],target:"#signInActor.setupTOTP"},{cond:"shouldConfirmSignIn",actions:["setUser","setChallengeName"],target:"#signInActor.confirmSignIn"},{cond:"shouldForceChangePassword",actions:["setUser","setChallengeName","setRequiredAttributes"],target:"#signInActor.forceNewPassword"},{actions:"setUser",target:"verifying"}],onError:[{cond:"shouldRedirectToConfirmSignUp",actions:["setCredentials","setConfirmSignUpIntent"],target:"rejected"},{cond:"shouldRedirectToConfirmResetPassword",actions:["setUsernameAuthAttributes","setConfirmResetPasswordIntent"],target:"rejected"},{actions:"setRemoteError",target:"edit"}]}},verifying:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"checkVerifiedContact",onDone:[{cond:"shouldRequestVerification",target:"#signInActor.verifyUser",actions:"setUnverifiedContactMethods"},{target:"resolved"}],onError:{actions:"setRemoteError",target:"edit"}}},resolved:{always:"#signInActor.resolved"},rejected:{always:"#signInActor.rejected"}}},autoSignIn:{initial:"pending",states:{pending:{tags:["pending"],entry:["clearError","sendUpdate"],on:{AUTO_SIGN_IN:[{cond:"shouldSetupTOTP",actions:["setUser","setChallengeName"],target:"#signInActor.setupTOTP"},{cond:"shouldConfirmSignIn",actions:["setUser","setChallengeName"],target:"#signInActor.confirmSignIn"},{cond:"shouldForceChangePassword",actions:["setUser","setChallengeName","setRequiredAttributes"],target:"#signInActor.forceNewPassword"},{actions:"setUser",target:"#signInActor.resolved"}],AUTO_SIGN_IN_FAILURE:{actions:"setRemoteError",target:"pending"}}},submit:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"signIn",onDone:[{cond:"shouldSetupTOTP",actions:["setUser","setChallengeName"],target:"#signInActor.setupTOTP"},{cond:"shouldConfirmSignIn",actions:["setUser","setChallengeName"],target:"#signInActor.confirmSignIn"},{cond:"shouldForceChangePassword",actions:["setUser","setChallengeName","setRequiredAttributes"],target:"#signInActor.forceNewPassword"},{actions:"setUser",target:"#signInActor.resolved"}],onError:{actions:"setRemoteError",target:"#signInActor.signIn"}}},resolved:{always:"#signInActor.resolved"},rejected:{always:"#signInActor.rejected"}}},confirmSignIn:{initial:"edit",exit:["clearFormValues","clearError","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},SIGN_IN:"#signInActor.signIn",CHANGE:{actions:"handleInput"}}},submit:{tags:["pending"],entry:["clearError","sendUpdate"],invoke:{src:"confirmSignIn",onDone:{target:"#signInActor.resolved",actions:["setUser","clearChallengeName","clearRequiredAttributes"]},onError:{target:"edit",actions:"setRemoteError"}}}}},forceNewPassword:{type:"parallel",exit:["clearFormValues","clearError","clearTouched"],states:{validation:{initial:"pending",states:{pending:{invoke:{src:"validateFields",onDone:{target:"valid",actions:"clearValidationError"},onError:{target:"invalid",actions:"setFieldErrors"}}},valid:{entry:"sendUpdate"},invalid:{entry:"sendUpdate"}},on:{SIGN_IN:"#signInActor.signIn",CHANGE:{actions:"handleInput",target:".pending"},BLUR:{actions:"handleBlur",target:".pending"}}},submit:{initial:"idle",entry:"clearError",states:{idle:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"validate"}}},validate:{entry:"sendUpdate",invoke:{src:"validateFields",onDone:{target:"pending",actions:"clearValidationError"},onError:{target:"idle",actions:"setFieldErrors"}}},pending:{tags:["pending"],entry:["sendUpdate","clearError"],invoke:{src:"forceNewPassword",onDone:[{cond:"shouldConfirmSignIn",actions:["setUser","setChallengeName"],target:"#signInActor.confirmSignIn"},{cond:"shouldSetupTOTP",actions:["setUser","setChallengeName"],target:"#signInActor.setupTOTP"},{target:"resolved",actions:["setUser","setCredentials"]}],onError:{target:"idle",actions:"setRemoteError"}}},resolved:{type:"final",always:"#signInActor.resolved"}}}}},setupTOTP:{initial:"edit",exit:["clearFormValues","clearError","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},SIGN_IN:"#signInActor.signIn",CHANGE:{actions:"handleInput"}}},submit:{tags:["pending"],entry:["sendUpdate","clearError"],invoke:{src:"verifyTotpToken",onDone:{actions:["clearChallengeName","clearRequiredAttributes"],target:"#signInActor.resolved"},onError:{actions:"setRemoteError",target:"edit"}}}}},verifyUser:{initial:"edit",exit:["clearFormValues","clearError","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},SKIP:"#signInActor.resolved",CHANGE:{actions:"handleInput"}}},submit:{tags:["pending"],entry:"clearError",invoke:{src:"verifyUser",onDone:{target:"#signInActor.confirmVerifyUser"},onError:{actions:"setRemoteError",target:"edit"}}}}},confirmVerifyUser:{initial:"edit",exit:["clearFormValues","clearError","clearUnverifiedContactMethods","clearAttributeToVerify","clearTouched"],states:{edit:{entry:"sendUpdate",on:{SUBMIT:{actions:"handleSubmit",target:"submit"},SKIP:"#signInActor.resolved",CHANGE:{actions:"handleInput"}}},submit:{tags:["pending"],entry:"clearError",invoke:{src:"confirmVerifyUser",onDone:{target:"#signInActor.resolved"},onError:{actions:"setRemoteError",target:"edit"}}}}},resolved:{type:"final",data:function(e){return{user:e.user}}},rejected:{type:"final",data:function(e,t){return{intent:e.redirectIntent,authAttributes:e.authAttributes}}}}},{actions:{clearAttributeToVerify:u,clearChallengeName:l,clearRequiredAttributes:g,clearError:f,clearFormValues:m,clearTouched:h,clearUnverifiedContactMethods:I,clearValidationError:p,handleInput:v,handleSubmit:A,handleBlur:U,parsePhoneNumber:S,setChallengeName:E,setConfirmResetPasswordIntent:b,setConfirmSignUpIntent:y,setRequiredAttributes:T,setCredentials:C,setFieldErrors:N,setRemoteError:w,setUnverifiedContactMethods:R,setUser:P,setUsernameAuthAttributes:V,sendUpdate:c()},guards:{shouldAutoSignIn:function(e){return"autoSignIn"===(null==e?void 0:e.intent)},shouldAutoSubmit:function(e){return"autoSignInSubmit"===(null==e?void 0:e.intent)},shouldConfirmSignIn:function(e,t){return D(k(t))},shouldForceChangePassword:function(e,t){return O(k(t),"NEW_PASSWORD_REQUIRED")},shouldRedirectToConfirmResetPassword:function(e,t){return"PasswordResetRequiredException"===t.data.code},shouldRedirectToConfirmSignUp:function(e,t){return"UserNotConfirmedException"===t.data.code},shouldRequestVerification:function(e,t){var r=t.data,n=r.unverified,i=r.verified;return s(i)&&!s(n)},shouldSetupTOTP:function(e,t){return O(k(t),"MFA_SETUP")}},services:{signIn:function(n){return e(this,void 0,void 0,(function(){var e,i,o,s,a,c,d;return t(this,(function(t){switch(t.label){case 0:return e=n.authAttributes,i=void 0===e?{}:e,o=n.formValues,s=void 0===o?{}:o,a=r(r({},i),s),c=a.username,d=a.password,[4,F.handleSignIn({username:c,password:d})];case 1:return[2,t.sent()]}}))}))},confirmSignIn:function(r){return e(this,void 0,void 0,(function(){var e,n,o,s;return t(this,(function(t){switch(t.label){case 0:return e=r.challengeName,n=r.user,o=r.formValues.confirmation_code,s=D(e)?e:void 0,[4,F.handleConfirmSignIn({user:n,code:o,mfaType:s})];case 1:return t.sent(),[4,i.currentAuthenticatedUser()];case 2:return[2,t.sent()]}}))}))},forceNewPassword:function(o){return e(this,void 0,void 0,(function(){var e,s,a,c,d,u,l,g,f;return t(this,(function(t){switch(t.label){case 0:e=o.user,s=o.formValues,a=s.password,s.confirm_password,c=s.phone_number,d=s.country_code,u=n(s,["password","confirm_password","phone_number","country_code"]),c&&(l="".concat(d).concat(c).replace(/[^A-Z0-9+]/gi,""),u=r(r({},u),{phone_number:l})),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,i.completeNewPassword(e,a,u)];case 2:return(g=t.sent()).challengeName?[2,g]:[2,i.currentAuthenticatedUser()];case 3:return f=t.sent(),[2,Promise.reject(f)];case 4:return[2]}}))}))},verifyTotpToken:function(r){return e(this,void 0,void 0,(function(){var e,n,o;return t(this,(function(t){return e=r.formValues,n=r.user,o=e.confirmation_code,[2,i.verifyTotpToken(n,o)]}))}))},federatedSignIn:function(r,n){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=n.data.provider,[4,i.federatedSignIn({provider:e})];case 1:return[2,t.sent()]}}))}))},checkVerifiedContact:function(r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e=r.user,[4,i.verifiedContact(e)];case 1:return[2,t.sent()]}}))}))},verifyUser:function(r){return e(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=r.formValues.unverifiedAttr,[4,i.verifyCurrentUserAttribute(e)];case 1:return n=t.sent(),r.attributeToVerify=e,[2,n]}}))}))},confirmVerifyUser:function(r){return e(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return e=r.attributeToVerify,n=r.formValues.confirmation_code,[4,i.verifyCurrentUserAttributeSubmit(e,n)];case 1:return[2,t.sent()]}}))}))},validateFields:function(r){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,d(r.formValues,r.touched,r.passwordSettings,[_.validateFormPassword,_.validateConfirmPassword])]}))}))}}})}export{M as signInActor};
@@ -1 +1 @@
1
- import{__assign as t,__spreadArray as o,__rest as n}from"tslib";import{createMachine as r,forwardTo as i,assign as e,spawn as a}from"xstate";import{choose as s}from"xstate/lib/actions";import{stopActor as c}from"./actions.js";import{signInActor as u}from"./actors/signIn.js";import{signOutActor as d}from"./actors/signOut.js";import{resetPasswordActor as l}from"./actors/resetPassword.js";import{defaultServices as g}from"./defaultServices.js";import{createSignUpMachine as v}from"./signUp.js";function f(){return r({id:"authenticator",initial:"idle",context:{user:void 0,config:{},services:g,actorRef:void 0,hasSetup:!1},predictableActionArguments:!0,states:{idle:{invoke:{src:"getCurrentUser",onDone:{actions:"setUser",target:"authenticated"},onError:{target:"setup"}}},setup:{initial:"waitConfig",states:{waitConfig:{on:{INIT:{actions:["configure","setHasSetup"],target:"applyConfig"}}},applyConfig:{invoke:{src:"getAmplifyConfig",onDone:{actions:"applyAmplifyConfig",target:"goToInitialState"}}},goToInitialState:{always:[{target:"#authenticator.signUp",cond:"isInitialStateSignUp"},{target:"#authenticator.resetPassword",cond:"isInitialStateResetPassword"},{target:"#authenticator.signIn"}]}}},signIn:{initial:"spawnActor",states:{spawnActor:{always:{actions:"spawnSignInActor",target:"runActor"}},runActor:{entry:"clearActorDoneData",exit:"stopSignInActor"}},on:{SIGN_UP:"signUp",RESET_PASSWORD:"resetPassword","done.invoke.signInActor":[{target:"signUp",actions:"setActorDoneData",cond:"shouldRedirectToSignUp"},{target:"resetPassword",actions:"setActorDoneData",cond:"shouldRedirectToResetPassword"},{target:"authenticated",actions:"setActorDoneData"}]}},signUp:{initial:"spawnActor",states:{spawnActor:{always:{actions:"spawnSignUpActor",target:"runActor"}},runActor:{entry:"clearActorDoneData",exit:"stopSignUpActor"},autoSignIn:{invoke:{src:"getCurrentUser",onDone:"#authenticator.authenticated",onError:"#authenticator.setup.goToInitialState"}}},on:{SIGN_IN:"signIn","done.invoke.signUpActor":{target:"#authenticator.signIn",actions:"setActorDoneData",cond:"shouldAutoSignIn"}}},resetPassword:{initial:"spawnActor",states:{spawnActor:{always:{actions:"spawnResetPasswordActor",target:"runActor"}},runActor:{entry:"clearActorDoneData",exit:"stopResetPasswordActor"}},on:{SIGN_IN:"signIn","done.invoke.resetPasswordActor":{target:"signIn",actions:"setActorDoneData"}}},signOut:{initial:"spawnActor",states:{spawnActor:{always:{actions:"spawnSignOutActor",target:"runActor"}},runActor:{entry:"clearActorDoneData",exit:["stopSignOutActor","clearUser"]}},on:{"done.invoke.signOutActor":[{target:"setup",cond:"shouldSetup"},{target:"setup.goToInitialState"}]}},authenticated:{initial:"idle",states:{idle:{on:{TOKEN_REFRESH:"refreshUser"}},refreshUser:{invoke:{src:"getCurrentUser",onDone:{actions:"setUser",target:"idle"},onError:{target:"#authenticator.signOut"}}}},on:{SIGN_OUT:"signOut"}}},on:{CHANGE:{actions:"forwardToActor"},BLUR:{actions:"forwardToActor"},SUBMIT:{actions:"forwardToActor"},FEDERATED_SIGN_IN:{actions:"forwardToActor"},AUTO_SIGN_IN:{actions:"forwardToActor"},RESEND:{actions:"forwardToActor"},SIGN_IN:{actions:"forwardToActor"},SKIP:{actions:"forwardToActor"}}},{actions:{forwardToActor:s([{cond:"hasActor",actions:i((function(t){return t.actorRef}))}]),setUser:e({user:function(t,o){return o.data}}),setActorDoneData:e({actorDoneData:function(o,n){var r,i;return{authAttributes:t({},null===(r=n.data)||void 0===r?void 0:r.authAttributes),intent:null===(i=n.data)||void 0===i?void 0:i.intent}},user:function(t,o){var n;return null===(n=o.data)||void 0===n?void 0:n.user}}),clearUser:e({user:void 0}),clearActorDoneData:e({actorDoneData:void 0}),applyAmplifyConfig:e({config:function(t,n){var r,i,e,a,s,c,u,d,l,g=null!==(i=null===(r=n.data.aws_cognito_username_attributes)||void 0===r?void 0:r.map((function(t){return t.toLowerCase()})))&&void 0!==i?i:[],v=null!==(a=null===(e=n.data.aws_cognito_verification_mechanisms)||void 0===e?void 0:e.map((function(t){return t.toLowerCase()})))&&void 0!==a?a:[],f=null!==(c=null===(s=n.data.aws_cognito_signup_attributes)||void 0===s?void 0:s.map((function(t){return t.toLowerCase()})))&&void 0!==c?c:[],A=null!==(d=null===(u=n.data.aws_cognito_social_providers)||void 0===u?void 0:u.map((function(t){return t.toLowerCase()})))&&void 0!==d?d:[],w=n.data.aws_cognito_password_protection_settings||{};0===g.length&&g.push("username");var S=t.config,m=S.loginMechanisms,h=S.signUpAttributes,D=S.socialProviders,I=S.initialState;return{loginMechanisms:null!=m?m:g,formFields:null!==(l=p(S.formFields))&&void 0!==l?l:{},passwordSettings:w,signUpAttributes:null!=h?h:Array.from(new Set(o(o([],v,!0),f,!0))),socialProviders:null!=D?D:A.sort(),initialState:I}}}),spawnSignInActor:e({actorRef:function(t,o){var n,r,i,e,s,c,d=t.services,l=u({services:d}).withContext({authAttributes:null!==(r=null===(n=t.actorDoneData)||void 0===n?void 0:n.authAttributes)&&void 0!==r?r:{},user:t.user,intent:null===(i=t.actorDoneData)||void 0===i?void 0:i.intent,country_code:"+1",formValues:{},touched:{},validationError:{},loginMechanisms:null===(e=t.config)||void 0===e?void 0:e.loginMechanisms,socialProviders:null===(s=t.config)||void 0===s?void 0:s.socialProviders,formFields:null===(c=t.config)||void 0===c?void 0:c.formFields});return a(l,{name:"signInActor"})}}),spawnSignUpActor:e({actorRef:function(t,o){var n,r,i,e,s,c,u,d=t.services,l=v({services:d}).withContext({authAttributes:null!==(r=null===(n=t.actorDoneData)||void 0===n?void 0:n.authAttributes)&&void 0!==r?r:{},country_code:"+1",intent:null===(i=t.actorDoneData)||void 0===i?void 0:i.intent,formValues:{},touched:{},validationError:{},loginMechanisms:null===(e=t.config)||void 0===e?void 0:e.loginMechanisms,socialProviders:null===(s=t.config)||void 0===s?void 0:s.socialProviders,formFields:null===(c=t.config)||void 0===c?void 0:c.formFields,passwordSettings:null===(u=t.config)||void 0===u?void 0:u.passwordSettings});return a(l,{name:"signUpActor"})}}),spawnResetPasswordActor:e({actorRef:function(t,o){var n,r,i,e,s=t.services,c=l({services:s}).withContext({formValues:{},touched:{},intent:null===(n=t.actorDoneData)||void 0===n?void 0:n.intent,username:null===(i=null===(r=t.actorDoneData)||void 0===r?void 0:r.authAttributes)||void 0===i?void 0:i.username,formFields:null===(e=t.config)||void 0===e?void 0:e.formFields,validationError:{}});return a(c,{name:"resetPasswordActor"})}}),spawnSignOutActor:e({actorRef:function(t){var o=d.withContext({user:t.user});return a(o,{name:"signOutActor"})}}),stopSignInActor:c("signInActor"),stopSignUpActor:c("signUpActor"),stopResetPasswordActor:c("resetPasswordActor"),stopSignOutActor:c("signOutActor"),configure:e((function(o,r){var i=r.data,e=i.services,a=n(i,["services"]);return{services:t(t({},g),e),config:a}})),setHasSetup:e({hasSetup:!0})},guards:{isInitialStateSignUp:function(t){return"signUp"===t.config.initialState},isInitialStateResetPassword:function(t){return"resetPassword"===t.config.initialState},shouldRedirectToSignUp:function(t,o){var n;return"confirmSignUp"===(null===(n=o.data)||void 0===n?void 0:n.intent)},shouldRedirectToResetPassword:function(t,o){var n;return"confirmPasswordReset"===(null===(n=o.data)||void 0===n?void 0:n.intent)},shouldAutoSignIn:function(t,o){var n,r;return"autoSignIn"===(null===(n=o.data)||void 0===n?void 0:n.intent)||"autoSignInSubmit"===(null===(r=o.data)||void 0===r?void 0:r.intent)},shouldSetup:function(t){return!1===t.hasSetup},hasActor:function(t){return!!t.actorRef}},services:{getCurrentUser:function(t,o){return t.services.getCurrentUser()},getAmplifyConfig:function(t,o){return t.services.getAmplifyConfig()}}})}function p(t){return t&&Object.keys(t).forEach((function(o){Object.keys(t[o]).forEach((function(n){var r=t[o][n];r.required=r.isRequired}))})),t}export{f as createAuthenticatorMachine};
1
+ import{__assign as t,__spreadArray as o,__rest as n}from"tslib";import{createMachine as i,forwardTo as r,assign as e,spawn as a}from"xstate";import{choose as s}from"xstate/lib/actions";import{stopActor as c}from"./actions.js";import{signInActor as u}from"./actors/signIn.js";import{signOutActor as d}from"./actors/signOut.js";import{resetPasswordActor as l}from"./actors/resetPassword.js";import{defaultServices as g}from"./defaultServices.js";import{createSignUpMachine as v}from"./signUp.js";function f(){return i({id:"authenticator",initial:"idle",context:{user:void 0,config:{},services:g,actorRef:void 0,hasSetup:!1},predictableActionArguments:!0,states:{idle:{invoke:{src:"getCurrentUser",onDone:{actions:"setUser",target:"authenticated"},onError:{target:"setup"}}},setup:{initial:"waitConfig",states:{waitConfig:{on:{INIT:{actions:["configure","setHasSetup"],target:"applyConfig"}}},applyConfig:{invoke:{src:"getAmplifyConfig",onDone:{actions:"applyAmplifyConfig",target:"goToInitialState"}}},goToInitialState:{always:[{target:"#authenticator.signUp",cond:"isInitialStateSignUp"},{target:"#authenticator.resetPassword",cond:"isInitialStateResetPassword"},{target:"#authenticator.signIn"}]}}},signIn:{initial:"spawnActor",states:{spawnActor:{always:{actions:"spawnSignInActor",target:"runActor"}},runActor:{entry:"clearActorDoneData",exit:"stopSignInActor"}},on:{SIGN_UP:"signUp",RESET_PASSWORD:"resetPassword","done.invoke.signInActor":[{target:"signUp",actions:"setActorDoneData",cond:"shouldRedirectToSignUp"},{target:"resetPassword",actions:"setActorDoneData",cond:"shouldRedirectToResetPassword"},{target:"authenticated",actions:"setActorDoneData"}]}},signUp:{initial:"spawnActor",states:{spawnActor:{always:{actions:"spawnSignUpActor",target:"runActor"}},runActor:{entry:"clearActorDoneData",exit:"stopSignUpActor"},autoSignIn:{invoke:{src:"getCurrentUser",onDone:"#authenticator.authenticated",onError:"#authenticator.setup.goToInitialState"}}},on:{SIGN_IN:"signIn","done.invoke.signUpActor":{target:"#authenticator.signIn",actions:"setActorDoneData",cond:"shouldAutoSignIn"}}},resetPassword:{initial:"spawnActor",states:{spawnActor:{always:{actions:"spawnResetPasswordActor",target:"runActor"}},runActor:{entry:"clearActorDoneData",exit:"stopResetPasswordActor"}},on:{SIGN_IN:"signIn","done.invoke.resetPasswordActor":{target:"signIn",actions:"setActorDoneData"}}},signOut:{initial:"spawnActor",states:{spawnActor:{always:{actions:"spawnSignOutActor",target:"runActor"}},runActor:{entry:"clearActorDoneData",exit:["stopSignOutActor","clearUser"]}},on:{"done.invoke.signOutActor":[{target:"setup",cond:"shouldSetup"},{target:"setup.goToInitialState"}]}},authenticated:{initial:"idle",states:{idle:{on:{TOKEN_REFRESH:"refreshUser"}},refreshUser:{invoke:{src:"getCurrentUser",onDone:{actions:"setUser",target:"idle"},onError:{target:"#authenticator.signOut"}}}},on:{SIGN_OUT:"signOut"}}},on:{CHANGE:{actions:"forwardToActor"},BLUR:{actions:"forwardToActor"},SUBMIT:{actions:"forwardToActor"},FEDERATED_SIGN_IN:{actions:"forwardToActor"},AUTO_SIGN_IN:{actions:"forwardToActor"},RESEND:{actions:"forwardToActor"},SIGN_IN:{actions:"forwardToActor"},SKIP:{actions:"forwardToActor"}}},{actions:{forwardToActor:s([{cond:"hasActor",actions:r((function(t){return t.actorRef}))}]),setUser:e({user:function(t,o){return o.data}}),setActorDoneData:e({actorDoneData:function(o,n){var i,r;return{authAttributes:t({},null===(i=n.data)||void 0===i?void 0:i.authAttributes),intent:null===(r=n.data)||void 0===r?void 0:r.intent}},user:function(t,o){var n;return null===(n=o.data)||void 0===n?void 0:n.user}}),clearUser:e({user:void 0}),clearActorDoneData:e({actorDoneData:void 0}),applyAmplifyConfig:e({config:function(t,n){var i,r,e,a,s,c,u,d,l,g=null!==(r=null===(i=n.data.aws_cognito_username_attributes)||void 0===i?void 0:i.map((function(t){return t.toLowerCase()})))&&void 0!==r?r:[],v=null!==(a=null===(e=n.data.aws_cognito_verification_mechanisms)||void 0===e?void 0:e.map((function(t){return t.toLowerCase()})))&&void 0!==a?a:[],f=null!==(c=null===(s=n.data.aws_cognito_signup_attributes)||void 0===s?void 0:s.map((function(t){return t.toLowerCase()})))&&void 0!==c?c:[],A=null!==(d=null===(u=n.data.aws_cognito_social_providers)||void 0===u?void 0:u.map((function(t){return t.toLowerCase()})))&&void 0!==d?d:[],w=n.data.aws_cognito_password_protection_settings||{};0===g.length&&g.push("username");var S=t.config,m=S.loginMechanisms,h=S.signUpAttributes,D=S.socialProviders,I=S.initialState;return{loginMechanisms:null!=m?m:g,formFields:null!==(l=p(S.formFields))&&void 0!==l?l:{},passwordSettings:w,signUpAttributes:null!=h?h:Array.from(new Set(o(o([],v,!0),f,!0))),socialProviders:null!=D?D:A.sort(),initialState:I}}}),spawnSignInActor:e({actorRef:function(t,o){var n,i,r,e,s,c,d,l=t.services,g=u({services:l}).withContext({authAttributes:null!==(i=null===(n=t.actorDoneData)||void 0===n?void 0:n.authAttributes)&&void 0!==i?i:{},user:t.user,intent:null===(r=t.actorDoneData)||void 0===r?void 0:r.intent,country_code:"+1",formValues:{},touched:{},validationError:{},passwordSettings:null===(e=t.config)||void 0===e?void 0:e.passwordSettings,loginMechanisms:null===(s=t.config)||void 0===s?void 0:s.loginMechanisms,socialProviders:null===(c=t.config)||void 0===c?void 0:c.socialProviders,formFields:null===(d=t.config)||void 0===d?void 0:d.formFields});return a(g,{name:"signInActor"})}}),spawnSignUpActor:e({actorRef:function(t,o){var n,i,r,e,s,c,u,d=t.services,l=v({services:d}).withContext({authAttributes:null!==(i=null===(n=t.actorDoneData)||void 0===n?void 0:n.authAttributes)&&void 0!==i?i:{},country_code:"+1",intent:null===(r=t.actorDoneData)||void 0===r?void 0:r.intent,formValues:{},touched:{},validationError:{},loginMechanisms:null===(e=t.config)||void 0===e?void 0:e.loginMechanisms,socialProviders:null===(s=t.config)||void 0===s?void 0:s.socialProviders,formFields:null===(c=t.config)||void 0===c?void 0:c.formFields,passwordSettings:null===(u=t.config)||void 0===u?void 0:u.passwordSettings});return a(l,{name:"signUpActor"})}}),spawnResetPasswordActor:e({actorRef:function(t,o){var n,i,r,e,s,c=t.services,u=l({services:c}).withContext({formValues:{},touched:{},intent:null===(n=t.actorDoneData)||void 0===n?void 0:n.intent,username:null===(r=null===(i=t.actorDoneData)||void 0===i?void 0:i.authAttributes)||void 0===r?void 0:r.username,formFields:null===(e=t.config)||void 0===e?void 0:e.formFields,validationError:{},passwordSettings:null===(s=t.config)||void 0===s?void 0:s.passwordSettings});return a(u,{name:"resetPasswordActor"})}}),spawnSignOutActor:e({actorRef:function(t){var o=d.withContext({user:t.user});return a(o,{name:"signOutActor"})}}),stopSignInActor:c("signInActor"),stopSignUpActor:c("signUpActor"),stopResetPasswordActor:c("resetPasswordActor"),stopSignOutActor:c("signOutActor"),configure:e((function(o,i){var r=i.data,e=r.services,a=n(r,["services"]);return{services:t(t({},g),e),config:a}})),setHasSetup:e({hasSetup:!0})},guards:{isInitialStateSignUp:function(t){return"signUp"===t.config.initialState},isInitialStateResetPassword:function(t){return"resetPassword"===t.config.initialState},shouldRedirectToSignUp:function(t,o){var n;return"confirmSignUp"===(null===(n=o.data)||void 0===n?void 0:n.intent)},shouldRedirectToResetPassword:function(t,o){var n;return"confirmPasswordReset"===(null===(n=o.data)||void 0===n?void 0:n.intent)},shouldAutoSignIn:function(t,o){var n,i;return"autoSignIn"===(null===(n=o.data)||void 0===n?void 0:n.intent)||"autoSignInSubmit"===(null===(i=o.data)||void 0===i?void 0:i.intent)},shouldSetup:function(t){return!1===t.hasSetup},hasActor:function(t){return!!t.actorRef}},services:{getCurrentUser:function(t,o){return t.services.getCurrentUser()},getAmplifyConfig:function(t,o){return t.services.getAmplifyConfig()}}})}function p(t){return t&&Object.keys(t).forEach((function(o){Object.keys(t[o]).forEach((function(n){var i=t[o][n];i.required=i.isRequired}))})),t}export{f as createAuthenticatorMachine};