@gahojin-inc/amplify-auth-hooks 2026.5.1 → 2026.6.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/dist/authenticator/defaultAuthHubHandler.js.map +1 -1
- package/dist/context/AuthenticatorContext.js.map +1 -1
- package/dist/context/AuthenticatorProvider.js.map +1 -1
- package/dist/hooks/facade.js.map +1 -1
- package/dist/hooks/useAuth.js.map +1 -1
- package/dist/hooks/useAuthenticator.js.map +1 -1
- package/dist/hooks/utils.js.map +1 -1
- package/dist/machines/actions.js.map +1 -1
- package/dist/machines/defaultHandlers.js.map +1 -1
- package/dist/machines/forgotPassword/actor.js.map +1 -1
- package/dist/machines/guards.js.map +1 -1
- package/dist/machines/signIn/actor.js.map +1 -1
- package/dist/machines/signOut/actor.js.map +1 -1
- package/dist/machines/signUp/actor.js.map +1 -1
- package/dist/machines/verifyUserAttributes/actor.js.map +1 -1
- package/dist/machines.js.map +1 -1
- package/dist/types/user.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +7 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultAuthHubHandler.js","names":[],"sources":["../../src/authenticator/defaultAuthHubHandler.ts"],"sourcesContent":["/*\n * Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * (C) 2025 GAHOJIN, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\nimport { Hub } from '@aws-amplify/core'\nimport { AmplifyErrorCode } from '@aws-amplify/core/internals/utils'\nimport type { AuthActor, AuthMachineHubHandler, StopListenerCallback } from '~/types/authenticator.js'\n\nexport const defaultAuthHubHandler: AuthMachineHubHandler = ({ payload }, actor, options) => {\n const { data, event } = payload\n const { send } = actor\n const { onSignIn, onSignOut } = options ?? {}\n\n switch (event) {\n case 'signedIn': {\n if (typeof onSignIn === 'function') {\n onSignIn(payload)\n }\n break\n }\n case 'signInWithRedirect': {\n send({ type: 'SIGN_IN_WITH_REDIRECT' })\n break\n }\n case 'signedOut': {\n if (typeof onSignOut === 'function') {\n onSignOut()\n }\n send({ type: 'SIGN_OUT' })\n break\n }\n case 'tokenRefresh_failure': {\n if (data?.error?.name === AmplifyErrorCode.NetworkError) {\n return\n }\n send({ type: 'SIGN_OUT' })\n break\n }\n default: {\n break\n }\n }\n}\n\nexport const listenToAuthHub = (actor: AuthActor, handler: AuthMachineHubHandler = defaultAuthHubHandler): StopListenerCallback => {\n const eventHandler: Parameters<typeof Hub.listen>[1] = (data) => handler(data, actor)\n return Hub.listen('auth', eventHandler, 'authenticator-hub-handler')\n}\n"],"mappings":";;;AAeA,IAAa,yBAAgD,EAAE,WAAW,OAAO,YAAY;CAC3F,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,EAAE,SAAS;CACjB,MAAM,EAAE,UAAU,cAAc,WAAW,
|
|
1
|
+
{"version":3,"file":"defaultAuthHubHandler.js","names":[],"sources":["../../src/authenticator/defaultAuthHubHandler.ts"],"sourcesContent":["/*\n * Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * (C) 2025 GAHOJIN, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\nimport { Hub } from '@aws-amplify/core'\nimport { AmplifyErrorCode } from '@aws-amplify/core/internals/utils'\nimport type { AuthActor, AuthMachineHubHandler, StopListenerCallback } from '~/types/authenticator.js'\n\nexport const defaultAuthHubHandler: AuthMachineHubHandler = ({ payload }, actor, options) => {\n const { data, event } = payload\n const { send } = actor\n const { onSignIn, onSignOut } = options ?? {}\n\n switch (event) {\n case 'signedIn': {\n if (typeof onSignIn === 'function') {\n onSignIn(payload)\n }\n break\n }\n case 'signInWithRedirect': {\n send({ type: 'SIGN_IN_WITH_REDIRECT' })\n break\n }\n case 'signedOut': {\n if (typeof onSignOut === 'function') {\n onSignOut()\n }\n send({ type: 'SIGN_OUT' })\n break\n }\n case 'tokenRefresh_failure': {\n if (data?.error?.name === AmplifyErrorCode.NetworkError) {\n return\n }\n send({ type: 'SIGN_OUT' })\n break\n }\n default: {\n break\n }\n }\n}\n\nexport const listenToAuthHub = (actor: AuthActor, handler: AuthMachineHubHandler = defaultAuthHubHandler): StopListenerCallback => {\n const eventHandler: Parameters<typeof Hub.listen>[1] = (data) => handler(data, actor)\n return Hub.listen('auth', eventHandler, 'authenticator-hub-handler')\n}\n"],"mappings":";;;AAeA,IAAa,yBAAgD,EAAE,WAAW,OAAO,YAAY;CAC3F,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,EAAE,SAAS;CACjB,MAAM,EAAE,UAAU,cAAc,WAAW,CAAC;CAE5C,QAAQ,OAAR;EACE,KAAK;GACH,IAAI,OAAO,aAAa,YACtB,SAAS,OAAO;GAElB;EAEF,KAAK;GACH,KAAK,EAAE,MAAM,wBAAwB,CAAC;GACtC;EAEF,KAAK;GACH,IAAI,OAAO,cAAc,YACvB,UAAU;GAEZ,KAAK,EAAE,MAAM,WAAW,CAAC;GACzB;EAEF,KAAK;GACH,IAAI,MAAM,OAAO,SAAS,iBAAiB,cACzC;GAEF,KAAK,EAAE,MAAM,WAAW,CAAC;GACzB;EAEF,SACE;CAEJ;AACF;AAEA,IAAa,mBAAmB,OAAkB,UAAiC,0BAAgD;CACjI,MAAM,gBAAkD,SAAS,QAAQ,MAAM,KAAK;CACpF,OAAO,IAAI,OAAO,QAAQ,cAAc,2BAA2B;AACrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticatorContext.js","names":[],"sources":["../../src/context/AuthenticatorContext.ts"],"sourcesContent":["import { type Context, createContext } from 'react'\nimport type { AuthActor } from '~/types/authenticator.js'\n\ntype AuthenticatorContextType = {\n actor: AuthActor\n}\n\nexport const AuthenticatorContext: Context<AuthenticatorContextType | null> = createContext<AuthenticatorContextType | null>(null)\n"],"mappings":";;AAOA,IAAa,uBAAiE,cAA+C,
|
|
1
|
+
{"version":3,"file":"AuthenticatorContext.js","names":[],"sources":["../../src/context/AuthenticatorContext.ts"],"sourcesContent":["import { type Context, createContext } from 'react'\nimport type { AuthActor } from '~/types/authenticator.js'\n\ntype AuthenticatorContextType = {\n actor: AuthActor\n}\n\nexport const AuthenticatorContext: Context<AuthenticatorContextType | null> = createContext<AuthenticatorContextType | null>(null)\n"],"mappings":";;AAOA,IAAa,uBAAiE,cAA+C,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticatorProvider.js","names":[],"sources":["../../src/context/AuthenticatorProvider.tsx"],"sourcesContent":["import { useActor } from '@xstate/react'\nimport { type JSX, type PropsWithChildren, useContext, useEffect, useMemo } from 'react'\nimport { defaultAuthHubHandler, listenToAuthHub } from '~/authenticator/defaultAuthHubHandler.js'\nimport { AuthenticatorContext } from '~/context/AuthenticatorContext.js'\nimport { type AuthenticatorMachineOptions, createAuthenticatorMachine } from '~/machines/index.js'\nimport type { AuthMachineHubHandler, AuthMachineHubHandlerOptions } from '~/types/authenticator.js'\n\nconst createHubHandler = (options?: AuthMachineHubHandlerOptions): AuthMachineHubHandler => {\n return (data, service) => defaultAuthHubHandler(data, service, options)\n}\n\ntype Props = PropsWithChildren & {\n options?: AuthenticatorMachineOptions\n}\n\nexport default ({ options, children }: Props): JSX.Element => {\n const machine = useMemo(() => createAuthenticatorMachine(options), [options])\n\n // 階層構造にAuthenticatorContextを使用している場合、親Contextの認証状態を継承する\n const parentProvider = useContext(AuthenticatorContext)\n const [, , actor] = useActor(machine)\n const value = useMemo(() => parentProvider ?? { actor }, [parentProvider, actor])\n\n const { actor: activeActor } = value\n\n useEffect(() => {\n return listenToAuthHub(activeActor, createHubHandler(options))\n }, [activeActor, options])\n\n return <AuthenticatorContext.Provider value={value}>{children}</AuthenticatorContext.Provider>\n}\n"],"mappings":";;;;;;;AAOA,IAAM,oBAAoB,YAAkE;
|
|
1
|
+
{"version":3,"file":"AuthenticatorProvider.js","names":[],"sources":["../../src/context/AuthenticatorProvider.tsx"],"sourcesContent":["import { useActor } from '@xstate/react'\nimport { type JSX, type PropsWithChildren, useContext, useEffect, useMemo } from 'react'\nimport { defaultAuthHubHandler, listenToAuthHub } from '~/authenticator/defaultAuthHubHandler.js'\nimport { AuthenticatorContext } from '~/context/AuthenticatorContext.js'\nimport { type AuthenticatorMachineOptions, createAuthenticatorMachine } from '~/machines/index.js'\nimport type { AuthMachineHubHandler, AuthMachineHubHandlerOptions } from '~/types/authenticator.js'\n\nconst createHubHandler = (options?: AuthMachineHubHandlerOptions): AuthMachineHubHandler => {\n return (data, service) => defaultAuthHubHandler(data, service, options)\n}\n\ntype Props = PropsWithChildren & {\n options?: AuthenticatorMachineOptions\n}\n\nexport default ({ options, children }: Props): JSX.Element => {\n const machine = useMemo(() => createAuthenticatorMachine(options), [options])\n\n // 階層構造にAuthenticatorContextを使用している場合、親Contextの認証状態を継承する\n const parentProvider = useContext(AuthenticatorContext)\n const [, , actor] = useActor(machine)\n const value = useMemo(() => parentProvider ?? { actor }, [parentProvider, actor])\n\n const { actor: activeActor } = value\n\n useEffect(() => {\n return listenToAuthHub(activeActor, createHubHandler(options))\n }, [activeActor, options])\n\n return <AuthenticatorContext.Provider value={value}>{children}</AuthenticatorContext.Provider>\n}\n"],"mappings":";;;;;;;AAOA,IAAM,oBAAoB,YAAkE;CAC1F,QAAQ,MAAM,YAAY,sBAAsB,MAAM,SAAS,OAAO;AACxE;AAMA,IAAA,iCAAgB,EAAE,SAAS,eAAmC;CAC5D,MAAM,UAAU,cAAc,2BAA2B,OAAO,GAAG,CAAC,OAAO,CAAC;CAG5E,MAAM,iBAAiB,WAAW,oBAAoB;CACtD,MAAM,KAAK,SAAS,SAAS,OAAO;CACpC,MAAM,QAAQ,cAAc,kBAAkB,EAAE,MAAM,GAAG,CAAC,gBAAgB,KAAK,CAAC;CAEhF,MAAM,EAAE,OAAO,gBAAgB;CAE/B,gBAAgB;EACd,OAAO,gBAAgB,aAAa,iBAAiB,OAAO,CAAC;CAC/D,GAAG,CAAC,aAAa,OAAO,CAAC;CAEzB,OAAO,IAAC,qBAAqB,UAAtB;EAAsC;EAAQ;CAAwC,CAAA;AAC/F"}
|
package/dist/hooks/facade.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facade.js","names":[],"sources":["../../src/hooks/facade.ts"],"sourcesContent":["import type { AnyMachineSnapshot, SnapshotFrom } from 'xstate'\nimport type { AuthActor } from '~/types/authenticator.js'\nimport type { AuthenticatorRoute, AuthenticatorSendEventAliases, AuthenticatorServiceContextFacade } from '~/types/hooks.js'\nimport type { AuthActorContext, AuthEvent, AuthEventTypes, NavigableRoute } from '~/types/machines.js'\n\nconst NAVIGABLE_ROUTE_EVENT: Record<NavigableRoute, AuthEventTypes> = {\n forgotPassword: 'FORGOT_PASSWORD',\n signIn: 'SIGN_IN',\n signUp: 'SIGN_UP',\n signOut: 'SIGN_OUT',\n}\n\nexport const getSendEventAliases = (send: (event: AuthEvent) => void): AuthenticatorSendEventAliases => {\n return {\n handleSubmit: (data) => send({ type: 'SUBMIT', data }),\n resendConfirmationCode: () => send({ type: 'RESEND' }),\n refreshUser: () => send({ type: 'TOKEN_REFRESH' }),\n setRoute: (route) => send({ type: NAVIGABLE_ROUTE_EVENT[route] }),\n skipAttributeVerification: () => send({ type: 'SKIP' }),\n toFederatedSignIn: () => send({ type: 'FEDERATED_SIGN_IN' }),\n }\n}\n\nconst getChildActor = (snapshot: SnapshotFrom<AuthActor>): AnyMachineSnapshot | undefined => {\n return snapshot.children?.childActor?.getSnapshot() as AnyMachineSnapshot\n}\n\nconst getRoute = (actor: SnapshotFrom<AuthActor>, childActor: AnyMachineSnapshot | undefined): AuthenticatorRoute | null => {\n // 'federatedSignIn' exists as a state on both the 'signInActor' and 'signUpActor',\n // match against the `actorState` initially to determine if the federated sign in flow\n // has begun, then which actor has begun the flow and return the corresponding `route`\n if (childActor?.matches('federatedSignIn')) {\n if (actor.matches('signUpActor')) {\n return 'signUp'\n }\n if (actor.matches('signInActor')) {\n return 'signIn'\n }\n }\n\n switch (true) {\n case actor.matches('idle'):\n return 'idle'\n case actor.matches('setup'):\n return 'setup'\n case actor.matches('signOut'):\n return 'signOut'\n case actor.matches('authenticated'):\n return 'authenticated'\n case childActor?.matches('confirmSignUp'):\n case childActor?.matches('resendSignUpCode'):\n return 'confirmSignUp'\n case childActor?.matches('confirmSignIn'):\n return 'confirmSignIn'\n case childActor?.matches('setupTotp'):\n return 'setupTotp'\n case childActor?.matches('signIn'):\n return 'signIn'\n case childActor?.matches('signUp'):\n case childActor?.matches('autoSignIn'):\n return 'signUp'\n case childActor?.matches('forceChangePassword'):\n return 'forceNewPassword'\n case childActor?.matches('forgotPassword'):\n return 'forgotPassword'\n case childActor?.matches('confirmResetPassword'):\n return 'confirmResetPassword'\n case childActor?.matches('selectUserAttributes'):\n return 'verifyUser'\n case childActor?.matches('confirmVerifyUserAttribute'):\n return 'confirmVerifyUser'\n case childActor?.matches('setupEmail'):\n return 'setupEmail'\n case childActor?.matches('selectMfaType'):\n return 'selectMfaType'\n case actor.matches('getCurrentUser'):\n case childActor?.matches('fetchUserAttributes'):\n /**\n * This route is needed for autoSignIn to capture both the\n * autoSignIn.pending and the resolved states when the\n * signIn actor is running.\n */\n return 'transition'\n default:\n return null\n }\n}\n\nexport const getServiceContextFacade = (actor: SnapshotFrom<AuthActor>): AuthenticatorServiceContextFacade => {\n const childActor = getChildActor(actor)\n const isPending = (actor.hasTag('pending') || childActor?.hasTag('pending')) ?? false\n const route = getRoute(actor, childActor)\n const context = actor.context\n const actorContext: AuthActorContext = childActor?.context ?? {}\n const user = actorContext?.user ?? context.user\n\n const { allowedMfaTypes, codeDeliveryDetails, remoteError: errorMessage, totpSecretCode, unverifiedUserAttributes, username } = actorContext\n\n return {\n allowedMfaTypes,\n codeDeliveryDetails,\n errorMessage,\n isPending,\n route,\n totpSecretCode,\n unverifiedUserAttributes,\n user,\n username,\n }\n}\n"],"mappings":";AAKA,IAAM,wBAAgE;CACpE,gBAAgB;CAChB,QAAQ;CACR,QAAQ;CACR,SAAS;
|
|
1
|
+
{"version":3,"file":"facade.js","names":[],"sources":["../../src/hooks/facade.ts"],"sourcesContent":["import type { AnyMachineSnapshot, SnapshotFrom } from 'xstate'\nimport type { AuthActor } from '~/types/authenticator.js'\nimport type { AuthenticatorRoute, AuthenticatorSendEventAliases, AuthenticatorServiceContextFacade } from '~/types/hooks.js'\nimport type { AuthActorContext, AuthEvent, AuthEventTypes, NavigableRoute } from '~/types/machines.js'\n\nconst NAVIGABLE_ROUTE_EVENT: Record<NavigableRoute, AuthEventTypes> = {\n forgotPassword: 'FORGOT_PASSWORD',\n signIn: 'SIGN_IN',\n signUp: 'SIGN_UP',\n signOut: 'SIGN_OUT',\n}\n\nexport const getSendEventAliases = (send: (event: AuthEvent) => void): AuthenticatorSendEventAliases => {\n return {\n handleSubmit: (data) => send({ type: 'SUBMIT', data }),\n resendConfirmationCode: () => send({ type: 'RESEND' }),\n refreshUser: () => send({ type: 'TOKEN_REFRESH' }),\n setRoute: (route) => send({ type: NAVIGABLE_ROUTE_EVENT[route] }),\n skipAttributeVerification: () => send({ type: 'SKIP' }),\n toFederatedSignIn: () => send({ type: 'FEDERATED_SIGN_IN' }),\n }\n}\n\nconst getChildActor = (snapshot: SnapshotFrom<AuthActor>): AnyMachineSnapshot | undefined => {\n return snapshot.children?.childActor?.getSnapshot() as AnyMachineSnapshot\n}\n\nconst getRoute = (actor: SnapshotFrom<AuthActor>, childActor: AnyMachineSnapshot | undefined): AuthenticatorRoute | null => {\n // 'federatedSignIn' exists as a state on both the 'signInActor' and 'signUpActor',\n // match against the `actorState` initially to determine if the federated sign in flow\n // has begun, then which actor has begun the flow and return the corresponding `route`\n if (childActor?.matches('federatedSignIn')) {\n if (actor.matches('signUpActor')) {\n return 'signUp'\n }\n if (actor.matches('signInActor')) {\n return 'signIn'\n }\n }\n\n switch (true) {\n case actor.matches('idle'):\n return 'idle'\n case actor.matches('setup'):\n return 'setup'\n case actor.matches('signOut'):\n return 'signOut'\n case actor.matches('authenticated'):\n return 'authenticated'\n case childActor?.matches('confirmSignUp'):\n case childActor?.matches('resendSignUpCode'):\n return 'confirmSignUp'\n case childActor?.matches('confirmSignIn'):\n return 'confirmSignIn'\n case childActor?.matches('setupTotp'):\n return 'setupTotp'\n case childActor?.matches('signIn'):\n return 'signIn'\n case childActor?.matches('signUp'):\n case childActor?.matches('autoSignIn'):\n return 'signUp'\n case childActor?.matches('forceChangePassword'):\n return 'forceNewPassword'\n case childActor?.matches('forgotPassword'):\n return 'forgotPassword'\n case childActor?.matches('confirmResetPassword'):\n return 'confirmResetPassword'\n case childActor?.matches('selectUserAttributes'):\n return 'verifyUser'\n case childActor?.matches('confirmVerifyUserAttribute'):\n return 'confirmVerifyUser'\n case childActor?.matches('setupEmail'):\n return 'setupEmail'\n case childActor?.matches('selectMfaType'):\n return 'selectMfaType'\n case actor.matches('getCurrentUser'):\n case childActor?.matches('fetchUserAttributes'):\n /**\n * This route is needed for autoSignIn to capture both the\n * autoSignIn.pending and the resolved states when the\n * signIn actor is running.\n */\n return 'transition'\n default:\n return null\n }\n}\n\nexport const getServiceContextFacade = (actor: SnapshotFrom<AuthActor>): AuthenticatorServiceContextFacade => {\n const childActor = getChildActor(actor)\n const isPending = (actor.hasTag('pending') || childActor?.hasTag('pending')) ?? false\n const route = getRoute(actor, childActor)\n const context = actor.context\n const actorContext: AuthActorContext = childActor?.context ?? {}\n const user = actorContext?.user ?? context.user\n\n const { allowedMfaTypes, codeDeliveryDetails, remoteError: errorMessage, totpSecretCode, unverifiedUserAttributes, username } = actorContext\n\n return {\n allowedMfaTypes,\n codeDeliveryDetails,\n errorMessage,\n isPending,\n route,\n totpSecretCode,\n unverifiedUserAttributes,\n user,\n username,\n }\n}\n"],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AK,YAAY,QAAQ,sBAAsB,GAC7C,OAAO;EACT,KAAK,YAAY,QAAQ,sBAAsB,GAC7C,OAAO;EACT,KAAK,YAAY,QAAQ,4BAA4B,GACnD,OAAO;EACT,KAAK,YAAY,QAAQ,YAAY,GACnC,OAAO;EACT,KAAK,YAAY,QAAQ,eAAe,GACtC,OAAO;EACT,KAAK,MAAM,QAAQ,gBAAgB;EACnC,KAAK,YAAY,QAAQ,qBAAqB,GAM5C,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,IAAa,2BAA2B,UAAsE;CAC5G,MAAM,aAAa,cAAc,KAAK;CACtC,MAAM,aAAa,MAAM,OAAO,SAAS,KAAK,YAAY,OAAO,SAAS,MAAM;CAChF,MAAM,QAAQ,SAAS,OAAO,UAAU;CACxC,MAAM,UAAU,MAAM;CACtB,MAAM,eAAiC,YAAY,WAAW,CAAC;CAC/D,MAAM,OAAO,cAAc,QAAQ,QAAQ;CAE3C,MAAM,EAAE,iBAAiB,qBAAqB,aAAa,cAAc,gBAAgB,0BAA0B,aAAa;CAEhI,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.js","names":[],"sources":["../../src/hooks/useAuth.ts"],"sourcesContent":["/*\n * Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * (C) 2025 GAHOJIN, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\nimport { type AuthUser, getCurrentUser } from '@aws-amplify/auth'\nimport { Hub, type HubCallback } from '@aws-amplify/core'\nimport { useCallback, useEffect, useState } from 'react'\nimport type { Handlers } from '~/types/machines.js'\n\nexport type UseAuthResult = {\n user?: AuthUser\n isLoading: boolean\n error?: Error\n}\n\ntype Props = {\n getCurrentUser?: Handlers['getCurrentUser']\n}\n\nexport const useAuth = (handlers?: Props): UseAuthResult => {\n const [result, setResult] = useState<UseAuthResult>({\n isLoading: true,\n })\n\n const fetchCurrentUser = useCallback(() => {\n // loading\n setResult((prev) => ({ ...prev, isLoading: true }))\n\n void (handlers?.getCurrentUser ?? getCurrentUser)()\n .then((user) => setResult({ user, isLoading: false }))\n .catch((e) => setResult({ error: e as Error, isLoading: false }))\n }, [handlers?.getCurrentUser])\n\n const handleAuth: HubCallback = useCallback(\n ({ payload }) => {\n switch (payload.event) {\n // success events\n case 'signedIn':\n case 'signUp':\n case 'autoSignIn':\n setResult({ user: payload.data as AuthUser, isLoading: false })\n break\n case 'signedOut':\n setResult({ isLoading: false })\n break\n\n // failure events\n case 'tokenRefresh_failure':\n case 'signIn_failure':\n setResult({ error: payload.data as Error, isLoading: false })\n break\n case 'autoSignIn_failure':\n // autoSignIn just returns error message. Wrap it to an Error object\n setResult({ error: new Error(payload.message), isLoading: false })\n break\n\n // events that need another fetch\n case 'tokenRefresh':\n void fetchCurrentUser()\n break\n\n default:\n // we do not handle other hub events like `configured`.\n break\n }\n },\n [fetchCurrentUser],\n )\n\n useEffect(() => {\n const unsubscribe = Hub.listen('auth', handleAuth, 'useAuth')\n void fetchCurrentUser() // on init, see if user is already logged in\n\n return unsubscribe\n }, [handleAuth, fetchCurrentUser])\n\n return result\n}\n"],"mappings":";;;;AA0BA,IAAa,WAAW,aAAoC;CAC1D,MAAM,CAAC,QAAQ,aAAa,SAAwB,EAClD,WAAW,
|
|
1
|
+
{"version":3,"file":"useAuth.js","names":[],"sources":["../../src/hooks/useAuth.ts"],"sourcesContent":["/*\n * Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * (C) 2025 GAHOJIN, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\nimport { type AuthUser, getCurrentUser } from '@aws-amplify/auth'\nimport { Hub, type HubCallback } from '@aws-amplify/core'\nimport { useCallback, useEffect, useState } from 'react'\nimport type { Handlers } from '~/types/machines.js'\n\nexport type UseAuthResult = {\n user?: AuthUser\n isLoading: boolean\n error?: Error\n}\n\ntype Props = {\n getCurrentUser?: Handlers['getCurrentUser']\n}\n\nexport const useAuth = (handlers?: Props): UseAuthResult => {\n const [result, setResult] = useState<UseAuthResult>({\n isLoading: true,\n })\n\n const fetchCurrentUser = useCallback(() => {\n // loading\n setResult((prev) => ({ ...prev, isLoading: true }))\n\n void (handlers?.getCurrentUser ?? getCurrentUser)()\n .then((user) => setResult({ user, isLoading: false }))\n .catch((e) => setResult({ error: e as Error, isLoading: false }))\n }, [handlers?.getCurrentUser])\n\n const handleAuth: HubCallback = useCallback(\n ({ payload }) => {\n switch (payload.event) {\n // success events\n case 'signedIn':\n case 'signUp':\n case 'autoSignIn':\n setResult({ user: payload.data as AuthUser, isLoading: false })\n break\n case 'signedOut':\n setResult({ isLoading: false })\n break\n\n // failure events\n case 'tokenRefresh_failure':\n case 'signIn_failure':\n setResult({ error: payload.data as Error, isLoading: false })\n break\n case 'autoSignIn_failure':\n // autoSignIn just returns error message. Wrap it to an Error object\n setResult({ error: new Error(payload.message), isLoading: false })\n break\n\n // events that need another fetch\n case 'tokenRefresh':\n void fetchCurrentUser()\n break\n\n default:\n // we do not handle other hub events like `configured`.\n break\n }\n },\n [fetchCurrentUser],\n )\n\n useEffect(() => {\n const unsubscribe = Hub.listen('auth', handleAuth, 'useAuth')\n void fetchCurrentUser() // on init, see if user is already logged in\n\n return unsubscribe\n }, [handleAuth, fetchCurrentUser])\n\n return result\n}\n"],"mappings":";;;;AA0BA,IAAa,WAAW,aAAoC;CAC1D,MAAM,CAAC,QAAQ,aAAa,SAAwB,EAClD,WAAW,KACb,CAAC;CAED,MAAM,mBAAmB,kBAAkB;EAEzC,WAAW,UAAU;GAAE,GAAG;GAAM,WAAW;EAAK,EAAE;EAElD,CAAM,UAAU,kBAAkB,gBAAgB,EAC/C,MAAM,SAAS,UAAU;GAAE;GAAM,WAAW;EAAM,CAAC,CAAC,EACpD,OAAO,MAAM,UAAU;GAAE,OAAO;GAAY,WAAW;EAAM,CAAC,CAAC;CACpE,GAAG,CAAC,UAAU,cAAc,CAAC;CAE7B,MAAM,aAA0B,aAC7B,EAAE,cAAc;EACf,QAAQ,QAAQ,OAAhB;GAEE,KAAK;GACL,KAAK;GACL,KAAK;IACH,UAAU;KAAE,MAAM,QAAQ;KAAkB,WAAW;IAAM,CAAC;IAC9D;GACF,KAAK;IACH,UAAU,EAAE,WAAW,MAAM,CAAC;IAC9B;GAGF,KAAK;GACL,KAAK;IACH,UAAU;KAAE,OAAO,QAAQ;KAAe,WAAW;IAAM,CAAC;IAC5D;GACF,KAAK;IAEH,UAAU;KAAE,OAAO,IAAI,MAAM,QAAQ,OAAO;KAAG,WAAW;IAAM,CAAC;IACjE;GAGF,KAAK;IACH,iBAAsB;IACtB;GAEF,SAEE;EACJ;CACF,GACA,CAAC,gBAAgB,CACnB;CAEA,gBAAgB;EACd,MAAM,cAAc,IAAI,OAAO,QAAQ,YAAY,SAAS;EAC5D,iBAAsB;EAEtB,OAAO;CACT,GAAG,CAAC,YAAY,gBAAgB,CAAC;CAEjC,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthenticator.js","names":[],"sources":["../../src/hooks/useAuthenticator.ts"],"sourcesContent":["import { useSelector } from '@xstate/react'\nimport { useContext } from 'react'\nimport { AuthenticatorContext } from '~/context/index.js'\nimport { getComparator } from '~/hooks/utils.js'\nimport type { UseAuthenticator, UseAuthenticatorSelector } from '~/types/hooks.js'\nimport { getSendEventAliases, getServiceContextFacade } from './facade.js'\n\nconst defaultComparator = (): false => false\n\nexport const useAuthenticator = (selector?: UseAuthenticatorSelector): UseAuthenticator => {\n const context = useContext(AuthenticatorContext)\n\n if (!context) {\n throw new Error('`useAuthenticator` must be used inside an `AuthenticatorProvider`.')\n }\n\n const { actor } = context\n const { send } = actor\n\n const comparator = selector ? getComparator(selector) : defaultComparator\n\n return useSelector(\n actor,\n (snapshot) => ({\n ...getSendEventAliases(send),\n ...getServiceContextFacade(snapshot),\n }),\n comparator,\n )\n}\n"],"mappings":";;;;;;AAOA,IAAM,0BAAiC;AAEvC,IAAa,oBAAoB,aAA0D;CACzF,MAAM,UAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"useAuthenticator.js","names":[],"sources":["../../src/hooks/useAuthenticator.ts"],"sourcesContent":["import { useSelector } from '@xstate/react'\nimport { useContext } from 'react'\nimport { AuthenticatorContext } from '~/context/index.js'\nimport { getComparator } from '~/hooks/utils.js'\nimport type { UseAuthenticator, UseAuthenticatorSelector } from '~/types/hooks.js'\nimport { getSendEventAliases, getServiceContextFacade } from './facade.js'\n\nconst defaultComparator = (): false => false\n\nexport const useAuthenticator = (selector?: UseAuthenticatorSelector): UseAuthenticator => {\n const context = useContext(AuthenticatorContext)\n\n if (!context) {\n throw new Error('`useAuthenticator` must be used inside an `AuthenticatorProvider`.')\n }\n\n const { actor } = context\n const { send } = actor\n\n const comparator = selector ? getComparator(selector) : defaultComparator\n\n return useSelector(\n actor,\n (snapshot) => ({\n ...getSendEventAliases(send),\n ...getServiceContextFacade(snapshot),\n }),\n comparator,\n )\n}\n"],"mappings":";;;;;;AAOA,IAAM,0BAAiC;AAEvC,IAAa,oBAAoB,aAA0D;CACzF,MAAM,UAAU,WAAW,oBAAoB;CAE/C,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,oEAAoE;CAGtF,MAAM,EAAE,UAAU;CAClB,MAAM,EAAE,SAAS;CAIjB,OAAO,YACL,QACC,cAAc;EACb,GAAG,oBAAoB,IAAI;EAC3B,GAAG,wBAAwB,QAAQ;CACrC,IAPiB,WAAW,cAAc,QAAQ,IAAI,iBASxD;AACF"}
|
package/dist/hooks/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/hooks/utils.ts"],"sourcesContent":["/*\n * Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * (C) 2025 GAHOJIN, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\nimport type { Comparator, UseAuthenticatorSelector } from '~/types/hooks.js'\n\n/**\n * Checks if `value` is an Object (non-primitive, non-array, non-function)\n * Will return false for Arrays and functions\n *\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is an object, `false` otherwise\n */\nexport function isObject(value: unknown): value is object {\n return value != null && !Array.isArray(value) && typeof value === 'object'\n}\n\n/**\n * Checks if `value` is a string primitive or object\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is a string, `false` otherwise\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string' || (typeof value === 'object' && Object.prototype.toString.call(value) === '[object String]')\n}\n\n/**\n * Checks if `value` is a Map\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is a Map, `false` otherwise\n */\nexport function isMap(value: unknown): value is Map<unknown, unknown> {\n return isObject(value) && Object.prototype.toString.call(value) === '[object Map]'\n}\n\n/**\n * Checks if `value` is a Set\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is a Set, `false` otherwise\n */\nexport function isSet<T>(value: unknown): value is Set<T> {\n return isObject(value) && Object.prototype.toString.call(value) === '[object Set]'\n}\n\n/**\n * Checks if `value` is undefined\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is undefined, `false` otherwise\n */\nexport function isUndefined(value: unknown): value is undefined {\n return value === undefined\n}\n\n/**\n * Checks if `value` is nullish\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is nullish, `false` otherwise\n */\nexport function isNil(value: unknown): value is null | undefined {\n return value == null\n}\n\n/**\n * Checks if `value` is empty\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is empty, `false` otherwise\n */\nexport function isEmpty<T>(value: T): boolean {\n if (value === null || value === undefined) return true\n\n if (isObject(value) && (isMap(value) || isSet(value))) {\n return !value.size\n }\n if (isObject(value) && (isString(value) || Array.isArray(value))) {\n return !value.length\n }\n for (const key in value) {\n if (has(value, key)) {\n return false\n }\n }\n return true\n}\n\n/**\n * Checks if `value` is an empty array\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is a empty, `false` otherwise\n */\nfunction isEmptyArray<T>(value: T): boolean {\n return Array.isArray(value) && isEmpty(value)\n}\n\n/**\n * Checks if all members of the `values` param are empty arrays\n *\n * @param {unknown} value The values to check\n * @returns {boolean} Returns `true` if all members of `values` are empty, `false` otherwise\n */\nexport function areEmptyArrays<T>(...values: T[]): boolean {\n return values.every(isEmptyArray)\n}\n\n/**\n * Checks if `value` is an empty object\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is empty, `false` otherwise\n */\nexport function isEmptyObject<T>(value: T): boolean {\n return isObject(value) && isEmpty(value)\n}\n\n/**\n * Checks if all members of the `values` param are empty objects\n *\n * @param {unknown} values The values to check\n * @returns {boolean} Returns `true` if all members of the `values` param are empty, `false` otherwise\n */\nexport function areEmptyObjects<T>(...values: T[]): boolean {\n return values.every(isEmptyObject)\n}\n\n/**\n * Checks if `key` is a direct property of `value`\n *\n * @param {unknown} value `object` potentially containing property\n * @param {string} key property key\n * @returns whether `key` param is a property of the `obj` param\n */\nexport function has(value: unknown, key: string): boolean {\n return value != null && Object.hasOwn(value, key)\n}\n\n/**\n * Does an ordering and shallow comparison of each array value,\n * plus a value equality check for empty objects and arrays.\n */\nexport function areSelectorDepsEqual<T>(currentDeps: T[], nextDeps: T[]): boolean {\n if (currentDeps.length !== nextDeps.length) {\n return false\n }\n return currentDeps.every((currentDep, index) => {\n const nextDep = nextDeps[index]\n\n if (areEmptyArrays(currentDep, nextDep) || areEmptyObjects(currentDep, nextDep)) {\n return true\n }\n\n return currentDep === nextDep\n })\n}\n\nexport const getComparator = (selector: UseAuthenticatorSelector): Comparator => {\n return (currentFacade, nextFacade) => {\n const currentSelectorDeps = selector(currentFacade)\n const nextSelectorDeps = selector(nextFacade)\n\n // Shallow compare the array values\n return areSelectorDepsEqual(currentSelectorDeps, nextSelectorDeps)\n }\n}\n"],"mappings":";AAqBA,SAAgB,SAAS,OAAiC;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/hooks/utils.ts"],"sourcesContent":["/*\n * Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * (C) 2025 GAHOJIN, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\nimport type { Comparator, UseAuthenticatorSelector } from '~/types/hooks.js'\n\n/**\n * Checks if `value` is an Object (non-primitive, non-array, non-function)\n * Will return false for Arrays and functions\n *\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is an object, `false` otherwise\n */\nexport function isObject(value: unknown): value is object {\n return value != null && !Array.isArray(value) && typeof value === 'object'\n}\n\n/**\n * Checks if `value` is a string primitive or object\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is a string, `false` otherwise\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string' || (typeof value === 'object' && Object.prototype.toString.call(value) === '[object String]')\n}\n\n/**\n * Checks if `value` is a Map\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is a Map, `false` otherwise\n */\nexport function isMap(value: unknown): value is Map<unknown, unknown> {\n return isObject(value) && Object.prototype.toString.call(value) === '[object Map]'\n}\n\n/**\n * Checks if `value` is a Set\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is a Set, `false` otherwise\n */\nexport function isSet<T>(value: unknown): value is Set<T> {\n return isObject(value) && Object.prototype.toString.call(value) === '[object Set]'\n}\n\n/**\n * Checks if `value` is undefined\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is undefined, `false` otherwise\n */\nexport function isUndefined(value: unknown): value is undefined {\n return value === undefined\n}\n\n/**\n * Checks if `value` is nullish\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is nullish, `false` otherwise\n */\nexport function isNil(value: unknown): value is null | undefined {\n return value == null\n}\n\n/**\n * Checks if `value` is empty\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is empty, `false` otherwise\n */\nexport function isEmpty<T>(value: T): boolean {\n if (value === null || value === undefined) return true\n\n if (isObject(value) && (isMap(value) || isSet(value))) {\n return !value.size\n }\n if (isObject(value) && (isString(value) || Array.isArray(value))) {\n return !value.length\n }\n for (const key in value) {\n if (has(value, key)) {\n return false\n }\n }\n return true\n}\n\n/**\n * Checks if `value` is an empty array\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is a empty, `false` otherwise\n */\nfunction isEmptyArray<T>(value: T): boolean {\n return Array.isArray(value) && isEmpty(value)\n}\n\n/**\n * Checks if all members of the `values` param are empty arrays\n *\n * @param {unknown} value The values to check\n * @returns {boolean} Returns `true` if all members of `values` are empty, `false` otherwise\n */\nexport function areEmptyArrays<T>(...values: T[]): boolean {\n return values.every(isEmptyArray)\n}\n\n/**\n * Checks if `value` is an empty object\n *\n * @param {unknown} value The value to check\n * @returns {boolean} Returns `true` if `value` is empty, `false` otherwise\n */\nexport function isEmptyObject<T>(value: T): boolean {\n return isObject(value) && isEmpty(value)\n}\n\n/**\n * Checks if all members of the `values` param are empty objects\n *\n * @param {unknown} values The values to check\n * @returns {boolean} Returns `true` if all members of the `values` param are empty, `false` otherwise\n */\nexport function areEmptyObjects<T>(...values: T[]): boolean {\n return values.every(isEmptyObject)\n}\n\n/**\n * Checks if `key` is a direct property of `value`\n *\n * @param {unknown} value `object` potentially containing property\n * @param {string} key property key\n * @returns whether `key` param is a property of the `obj` param\n */\nexport function has(value: unknown, key: string): boolean {\n return value != null && Object.hasOwn(value, key)\n}\n\n/**\n * Does an ordering and shallow comparison of each array value,\n * plus a value equality check for empty objects and arrays.\n */\nexport function areSelectorDepsEqual<T>(currentDeps: T[], nextDeps: T[]): boolean {\n if (currentDeps.length !== nextDeps.length) {\n return false\n }\n return currentDeps.every((currentDep, index) => {\n const nextDep = nextDeps[index]\n\n if (areEmptyArrays(currentDep, nextDep) || areEmptyObjects(currentDep, nextDep)) {\n return true\n }\n\n return currentDep === nextDep\n })\n}\n\nexport const getComparator = (selector: UseAuthenticatorSelector): Comparator => {\n return (currentFacade, nextFacade) => {\n const currentSelectorDeps = selector(currentFacade)\n const nextSelectorDeps = selector(nextFacade)\n\n // Shallow compare the array values\n return areSelectorDepsEqual(currentSelectorDeps, nextSelectorDeps)\n }\n}\n"],"mappings":";AAqBA,SAAgB,SAAS,OAAiC;CACxD,OAAO,SAAS,QAAQ,CAAC,MAAM,QAAQ,KAAK,KAAK,OAAO,UAAU;AACpE;AAQA,SAAgB,SAAS,OAAiC;CACxD,OAAO,OAAO,UAAU,YAAa,OAAO,UAAU,YAAY,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;AAC9G;AAQA,SAAgB,MAAM,OAAgD;CACpE,OAAO,SAAS,KAAK,KAAK,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;AACtE;AAQA,SAAgB,MAAS,OAAiC;CACxD,OAAO,SAAS,KAAK,KAAK,OAAO,UAAU,SAAS,KAAK,KAAK,MAAM;AACtE;AA4BA,SAAgB,QAAW,OAAmB;CAC5C,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;CAElD,IAAI,SAAS,KAAK,MAAM,MAAM,KAAK,KAAK,MAAM,KAAK,IACjD,OAAO,CAAC,MAAM;CAEhB,IAAI,SAAS,KAAK,MAAM,SAAS,KAAK,KAAK,MAAM,QAAQ,KAAK,IAC5D,OAAO,CAAC,MAAM;CAEhB,KAAK,MAAM,OAAO,OAChB,IAAI,IAAI,OAAO,GAAG,GAChB,OAAO;CAGX,OAAO;AACT;AAQA,SAAS,aAAgB,OAAmB;CAC1C,OAAO,MAAM,QAAQ,KAAK,KAAK,QAAQ,KAAK;AAC9C;AAQA,SAAgB,eAAkB,GAAG,QAAsB;CACzD,OAAO,OAAO,MAAM,YAAY;AAClC;AAQA,SAAgB,cAAiB,OAAmB;CAClD,OAAO,SAAS,KAAK,KAAK,QAAQ,KAAK;AACzC;AAQA,SAAgB,gBAAmB,GAAG,QAAsB;CAC1D,OAAO,OAAO,MAAM,aAAa;AACnC;AASA,SAAgB,IAAI,OAAgB,KAAsB;CACxD,OAAO,SAAS,QAAQ,OAAO,OAAO,OAAO,GAAG;AAClD;AAMA,SAAgB,qBAAwB,aAAkB,UAAwB;CAChF,IAAI,YAAY,WAAW,SAAS,QAClC,OAAO;CAET,OAAO,YAAY,OAAO,YAAY,UAAU;EAC9C,MAAM,UAAU,SAAS;EAEzB,IAAI,eAAe,YAAY,OAAO,KAAK,gBAAgB,YAAY,OAAO,GAC5E,OAAO;EAGT,OAAO,eAAe;CACxB,CAAC;AACH;AAEA,IAAa,iBAAiB,aAAmD;CAC/E,QAAQ,eAAe,eAAe;EAKpC,OAAO,qBAJqB,SAAS,aAIT,GAHH,SAAS,UAGe,CAAgB;CACnE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","names":[],"sources":["../../src/machines/actions.ts"],"sourcesContent":["import type {\n CodeDeliveryDetails,\n FetchUserAttributesOutput,\n ResetPasswordOutput,\n SendUserAttributeVerificationCodeOutput,\n SignInOutput,\n SignUpOutput,\n UserAttributeKey,\n} from '@aws-amplify/auth'\nimport type { AuthVerifiableAttributeKey } from '@aws-amplify/core/internals/utils'\nimport type {\n AuthEvent,\n AuthEventData,\n AuthMFAType,\n AuthTOTPSetupDetails,\n ResetPasswordStep,\n SignInContext,\n SignInStep,\n SignUpStep,\n} from '~/types/machines.js'\nimport type { UnverifiedUserAttributes } from '~/types/user.js'\n\ntype ActionParams<Context = unknown> = {\n context: Context\n event: AuthEvent\n}\n\nconst setTotpSecretCode = ({ event }: ActionParams): string | undefined => {\n const { sharedSecret } = (event.output?.nextStep?.totpSetupDetails ?? {}) as AuthTOTPSetupDetails\n return sharedSecret\n}\n\nconst setAllowedMfaTypes = ({ event }: ActionParams): AuthMFAType[] | undefined => {\n return event.output?.nextStep?.allowedMFATypes as AuthMFAType[]\n}\n\nconst setNextSignInStep = ({ event }: ActionParams): SignInStep => {\n const output = (event.output ?? {}) as SignInOutput\n return output.nextStep?.signInStep === 'DONE' ? 'SIGN_IN_COMPLETE' : output.nextStep?.signInStep\n}\n\nconst setNextSignUpStep = ({ event }: ActionParams): SignUpStep => {\n const output = (event.output ?? {}) as SignUpOutput\n return output.nextStep?.signUpStep === 'DONE' ? 'SIGN_UP_COMPLETE' : output.nextStep?.signUpStep\n}\n\nconst setNextResetPasswordStep = ({ event }: ActionParams): ResetPasswordStep => {\n const output = (event.output ?? {}) as ResetPasswordOutput\n return output.nextStep?.resetPasswordStep === 'DONE' ? 'RESET_PASSWORD_COMPLETE' : output.nextStep?.resetPasswordStep\n}\n\nconst setMissingAttributes = ({ event }: ActionParams): string | undefined => event.output?.nextStep?.missingAttributes\n\nconst setRemoteError = ({ event }: ActionParams): string => {\n const error = event.error\n if (error?.name === 'NoUserPoolError') {\n return 'Configuration error (see console) – please contact the administrator'\n }\n return error?.message || String(error)\n}\n\nconst setUsername = ({ event }: ActionParams): string | undefined => event.data?.username\n\nconst setUser = ({ event }: ActionParams): AuthEventData | undefined => event.output\n\nconst setCodeDeliveryDetails = ({ event }: ActionParams): CodeDeliveryDetails<UserAttributeKey> => {\n const output = event.output\n if (output?.nextStep?.codeDeliveryDetails) {\n return output?.nextStep?.codeDeliveryDetails\n }\n return output as CodeDeliveryDetails<UserAttributeKey>\n}\n\nconst setUnverifiedUserAttributes = ({ event }: ActionParams): UnverifiedUserAttributes => {\n const { email, phone_number } = event.output as FetchUserAttributesOutput\n\n const unverifiedUserAttributes = {\n ...(email && { email }),\n ...(phone_number && { phone_number }),\n }\n\n return unverifiedUserAttributes\n}\n\nconst setSelectedUserAttribute = ({ event }: ActionParams): AuthVerifiableAttributeKey | undefined => {\n const output = event?.output as SendUserAttributeVerificationCodeOutput\n return output?.attributeName\n}\n\nconst setSignInActorDoneData = ({ event }: ActionParams<SignInContext>): SignInContext => {\n const output = event?.output ?? {}\n return {\n codeDeliveryDetails: output.codeDeliveryDetails,\n missingAttributes: output.missingAttributes,\n remoteError: output.remoteError,\n username: output.username,\n step: output.step,\n totpSecretCode: output.totpSecretCode,\n unverifiedUserAttributes: output.unverifiedUserAttributes,\n allowedMfaTypes: output.allowedMfaTypes,\n }\n}\n\nexport {\n setAllowedMfaTypes,\n setCodeDeliveryDetails,\n setMissingAttributes,\n setNextResetPasswordStep,\n setNextSignInStep,\n setNextSignUpStep,\n setRemoteError,\n setSelectedUserAttribute,\n setSignInActorDoneData,\n setTotpSecretCode,\n setUnverifiedUserAttributes,\n setUser,\n setUsername,\n}\n"],"mappings":";AA2BA,IAAM,qBAAqB,EAAE,YAA8C;CACzE,MAAM,EAAE,iBAAkB,MAAM,QAAQ,UAAU,oBAAoB,
|
|
1
|
+
{"version":3,"file":"actions.js","names":[],"sources":["../../src/machines/actions.ts"],"sourcesContent":["import type {\n CodeDeliveryDetails,\n FetchUserAttributesOutput,\n ResetPasswordOutput,\n SendUserAttributeVerificationCodeOutput,\n SignInOutput,\n SignUpOutput,\n UserAttributeKey,\n} from '@aws-amplify/auth'\nimport type { AuthVerifiableAttributeKey } from '@aws-amplify/core/internals/utils'\nimport type {\n AuthEvent,\n AuthEventData,\n AuthMFAType,\n AuthTOTPSetupDetails,\n ResetPasswordStep,\n SignInContext,\n SignInStep,\n SignUpStep,\n} from '~/types/machines.js'\nimport type { UnverifiedUserAttributes } from '~/types/user.js'\n\ntype ActionParams<Context = unknown> = {\n context: Context\n event: AuthEvent\n}\n\nconst setTotpSecretCode = ({ event }: ActionParams): string | undefined => {\n const { sharedSecret } = (event.output?.nextStep?.totpSetupDetails ?? {}) as AuthTOTPSetupDetails\n return sharedSecret\n}\n\nconst setAllowedMfaTypes = ({ event }: ActionParams): AuthMFAType[] | undefined => {\n return event.output?.nextStep?.allowedMFATypes as AuthMFAType[]\n}\n\nconst setNextSignInStep = ({ event }: ActionParams): SignInStep => {\n const output = (event.output ?? {}) as SignInOutput\n return output.nextStep?.signInStep === 'DONE' ? 'SIGN_IN_COMPLETE' : output.nextStep?.signInStep\n}\n\nconst setNextSignUpStep = ({ event }: ActionParams): SignUpStep => {\n const output = (event.output ?? {}) as SignUpOutput\n return output.nextStep?.signUpStep === 'DONE' ? 'SIGN_UP_COMPLETE' : output.nextStep?.signUpStep\n}\n\nconst setNextResetPasswordStep = ({ event }: ActionParams): ResetPasswordStep => {\n const output = (event.output ?? {}) as ResetPasswordOutput\n return output.nextStep?.resetPasswordStep === 'DONE' ? 'RESET_PASSWORD_COMPLETE' : output.nextStep?.resetPasswordStep\n}\n\nconst setMissingAttributes = ({ event }: ActionParams): string | undefined => event.output?.nextStep?.missingAttributes\n\nconst setRemoteError = ({ event }: ActionParams): string => {\n const error = event.error\n if (error?.name === 'NoUserPoolError') {\n return 'Configuration error (see console) – please contact the administrator'\n }\n return error?.message || String(error)\n}\n\nconst setUsername = ({ event }: ActionParams): string | undefined => event.data?.username\n\nconst setUser = ({ event }: ActionParams): AuthEventData | undefined => event.output\n\nconst setCodeDeliveryDetails = ({ event }: ActionParams): CodeDeliveryDetails<UserAttributeKey> => {\n const output = event.output\n if (output?.nextStep?.codeDeliveryDetails) {\n return output?.nextStep?.codeDeliveryDetails\n }\n return output as CodeDeliveryDetails<UserAttributeKey>\n}\n\nconst setUnverifiedUserAttributes = ({ event }: ActionParams): UnverifiedUserAttributes => {\n const { email, phone_number } = event.output as FetchUserAttributesOutput\n\n const unverifiedUserAttributes = {\n ...(email && { email }),\n ...(phone_number && { phone_number }),\n }\n\n return unverifiedUserAttributes\n}\n\nconst setSelectedUserAttribute = ({ event }: ActionParams): AuthVerifiableAttributeKey | undefined => {\n const output = event?.output as SendUserAttributeVerificationCodeOutput\n return output?.attributeName\n}\n\nconst setSignInActorDoneData = ({ event }: ActionParams<SignInContext>): SignInContext => {\n const output = event?.output ?? {}\n return {\n codeDeliveryDetails: output.codeDeliveryDetails,\n missingAttributes: output.missingAttributes,\n remoteError: output.remoteError,\n username: output.username,\n step: output.step,\n totpSecretCode: output.totpSecretCode,\n unverifiedUserAttributes: output.unverifiedUserAttributes,\n allowedMfaTypes: output.allowedMfaTypes,\n }\n}\n\nexport {\n setAllowedMfaTypes,\n setCodeDeliveryDetails,\n setMissingAttributes,\n setNextResetPasswordStep,\n setNextSignInStep,\n setNextSignUpStep,\n setRemoteError,\n setSelectedUserAttribute,\n setSignInActorDoneData,\n setTotpSecretCode,\n setUnverifiedUserAttributes,\n setUser,\n setUsername,\n}\n"],"mappings":";AA2BA,IAAM,qBAAqB,EAAE,YAA8C;CACzE,MAAM,EAAE,iBAAkB,MAAM,QAAQ,UAAU,oBAAoB,CAAC;CACvE,OAAO;AACT;AAEA,IAAM,sBAAsB,EAAE,YAAqD;CACjF,OAAO,MAAM,QAAQ,UAAU;AACjC;AAEA,IAAM,qBAAqB,EAAE,YAAsC;CACjE,MAAM,SAAU,MAAM,UAAU,CAAC;CACjC,OAAO,OAAO,UAAU,eAAe,SAAS,qBAAqB,OAAO,UAAU;AACxF;AAEA,IAAM,qBAAqB,EAAE,YAAsC;CACjE,MAAM,SAAU,MAAM,UAAU,CAAC;CACjC,OAAO,OAAO,UAAU,eAAe,SAAS,qBAAqB,OAAO,UAAU;AACxF;AAEA,IAAM,4BAA4B,EAAE,YAA6C;CAC/E,MAAM,SAAU,MAAM,UAAU,CAAC;CACjC,OAAO,OAAO,UAAU,sBAAsB,SAAS,4BAA4B,OAAO,UAAU;AACtG;AAIA,IAAM,kBAAkB,EAAE,YAAkC;CAC1D,MAAM,QAAQ,MAAM;CACpB,IAAI,OAAO,SAAS,mBAClB,OAAO;CAET,OAAO,OAAO,WAAW,OAAO,KAAK;AACvC;AAEA,IAAM,eAAe,EAAE,YAA8C,MAAM,MAAM;AAIjF,IAAM,0BAA0B,EAAE,YAAiE;CACjG,MAAM,SAAS,MAAM;CACrB,IAAI,QAAQ,UAAU,qBACpB,OAAO,QAAQ,UAAU;CAE3B,OAAO;AACT;AAEA,IAAM,+BAA+B,EAAE,YAAoD;CACzF,MAAM,EAAE,OAAO,iBAAiB,MAAM;CAOtC,OAAO;EAJL,GAAI,SAAS,EAAE,MAAM;EACrB,GAAI,gBAAgB,EAAE,aAAa;CAG9B;AACT;AAEA,IAAM,4BAA4B,EAAE,YAAkE;CAEpG,QADe,OAAO,SACP;AACjB;AAEA,IAAM,0BAA0B,EAAE,YAAwD;CACxF,MAAM,SAAS,OAAO,UAAU,CAAC;CACjC,OAAO;EACL,qBAAqB,OAAO;EAC5B,mBAAmB,OAAO;EAC1B,aAAa,OAAO;EACpB,UAAU,OAAO;EACjB,MAAM,OAAO;EACb,gBAAgB,OAAO;EACvB,0BAA0B,OAAO;EACjC,iBAAiB,OAAO;CAC1B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultHandlers.js","names":[],"sources":["../../src/machines/defaultHandlers.ts"],"sourcesContent":["import {\n autoSignIn,\n confirmResetPassword,\n confirmSignIn,\n confirmSignUp,\n confirmUserAttribute,\n fetchUserAttributes,\n getCurrentUser,\n resendSignUpCode,\n resetPassword,\n sendUserAttributeVerificationCode,\n signIn,\n signInWithRedirect,\n signOut,\n signUp,\n} from '@aws-amplify/auth'\nimport type { Handlers } from '~/types/machines.js'\n\nexport const defaultHandlers: Handlers = {\n getCurrentUser,\n fetchUserAttributes,\n signIn,\n signInWithRedirect,\n signUp,\n signOut,\n autoSignIn: () => autoSignIn(),\n confirmSignIn,\n confirmSignUp,\n confirmResetPassword,\n confirmUserAttribute,\n resetPassword,\n resendSignUpCode,\n sendUserAttributeVerificationCode,\n}\n"],"mappings":";;AAkBA,IAAa,kBAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA,kBAAkB,
|
|
1
|
+
{"version":3,"file":"defaultHandlers.js","names":[],"sources":["../../src/machines/defaultHandlers.ts"],"sourcesContent":["import {\n autoSignIn,\n confirmResetPassword,\n confirmSignIn,\n confirmSignUp,\n confirmUserAttribute,\n fetchUserAttributes,\n getCurrentUser,\n resendSignUpCode,\n resetPassword,\n sendUserAttributeVerificationCode,\n signIn,\n signInWithRedirect,\n signOut,\n signUp,\n} from '@aws-amplify/auth'\nimport type { Handlers } from '~/types/machines.js'\n\nexport const defaultHandlers: Handlers = {\n getCurrentUser,\n fetchUserAttributes,\n signIn,\n signInWithRedirect,\n signUp,\n signOut,\n autoSignIn: () => autoSignIn(),\n confirmSignIn,\n confirmSignUp,\n confirmResetPassword,\n confirmUserAttribute,\n resetPassword,\n resendSignUpCode,\n sendUserAttributeVerificationCode,\n}\n"],"mappings":";;AAkBA,IAAa,kBAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;CACA,kBAAkB,WAAW;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor.js","names":[],"sources":["../../../src/machines/forgotPassword/actor.ts"],"sourcesContent":["import type { ConfirmResetPasswordInput, ResetPasswordInput, ResetPasswordOutput } from '@aws-amplify/auth'\nimport { assign, fromPromise, sendParent, setup } from 'xstate'\nimport { setCodeDeliveryDetails, setNextResetPasswordStep, setRemoteError, setUsername } from '~/machines/actions.js'\nimport { hasCompletedResetPassword, shouldConfirmResetPassword, shouldResetPassword } from '~/machines/guards.js'\nimport type { AuthEvent, Handlers, ResetPasswordContext } from '~/types/machines.js'\n\ntype ForgotPasswordHandlers = Pick<Handlers, 'resetPassword' | 'confirmResetPassword'>\n\n/**\n * @internal\n */\nexport const forgotPasswordActor = (handlers: ForgotPasswordHandlers, overridesContext?: ResetPasswordContext) => {\n return setup({\n types: {\n context: {} as ResetPasswordContext,\n events: {} as AuthEvent,\n },\n guards: {\n shouldResetPassword: ({ context, event }) => shouldResetPassword(context, event),\n shouldConfirmResetPassword: ({ context, event }) => shouldConfirmResetPassword(context, event),\n hasCompletedResetPassword: ({ event }) => hasCompletedResetPassword(event),\n },\n actors: {\n resetPassword: fromPromise<ResetPasswordOutput, ResetPasswordInput>(({ input }) => handlers.resetPassword(input)),\n confirmResetPassword: fromPromise<void, ConfirmResetPasswordInput>(({ input }) => handlers.confirmResetPassword(input)),\n },\n actions: {\n sendUpdate: sendParent({ type: 'CHILD_CHANGED' }),\n setSignInStep: assign({ step: 'SIGN_IN' }),\n setNextResetPasswordStep: assign({ step: setNextResetPasswordStep }),\n setCodeDeliveryDetails: assign({ codeDeliveryDetails: setCodeDeliveryDetails }),\n setUsername: assign({ username: setUsername }),\n setRemoteError: assign({ remoteError: setRemoteError }),\n clearError: assign({ remoteError: undefined }),\n },\n }).createMachine({\n id: 'forgotPasswordActor',\n initial: 'init',\n context: ({ input }) => ({ step: 'FORGOT_PASSWORD', ...overridesContext, ...input }),\n states: {\n init: {\n always: [\n { guard: 'shouldResetPassword', target: '#forgotPasswordActor.confirmResetPassword' },\n { guard: 'shouldConfirmResetPassword', target: '#forgotPasswordActor.confirmResetPassword' },\n { target: '#forgotPasswordActor.forgotPassword' },\n ],\n },\n forgotPassword: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'setUsername', 'clearError'],\n invoke: {\n src: 'resetPassword',\n input: ({ context: { username } }) => ({ username }) as ResetPasswordInput,\n onDone: [{ actions: ['setCodeDeliveryDetails', 'setNextResetPasswordStep'], target: '#forgotPasswordActor.confirmResetPassword' }],\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n confirmResetPassword: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n RESEND: { target: 'resendCode' },\n },\n },\n resendCode: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'resetPassword',\n input: ({ context: { username } }) => ({ username }) as ResetPasswordInput,\n onDone: { target: 'idle' },\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmResetPassword',\n input: ({ context, event }) => ({ username: context.username, ...event.data }) as ConfirmResetPasswordInput,\n onDone: [\n { guard: 'hasCompletedResetPassword', actions: 'setNextResetPasswordStep', target: '#forgotPasswordActor.resolved' },\n { actions: 'setSignInStep', target: '#forgotPasswordActor.resolved' },\n ],\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n resolved: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;;;AAWA,IAAa,uBAAuB,UAAkC,qBAA4C;
|
|
1
|
+
{"version":3,"file":"actor.js","names":[],"sources":["../../../src/machines/forgotPassword/actor.ts"],"sourcesContent":["import type { ConfirmResetPasswordInput, ResetPasswordInput, ResetPasswordOutput } from '@aws-amplify/auth'\nimport { assign, fromPromise, sendParent, setup } from 'xstate'\nimport { setCodeDeliveryDetails, setNextResetPasswordStep, setRemoteError, setUsername } from '~/machines/actions.js'\nimport { hasCompletedResetPassword, shouldConfirmResetPassword, shouldResetPassword } from '~/machines/guards.js'\nimport type { AuthEvent, Handlers, ResetPasswordContext } from '~/types/machines.js'\n\ntype ForgotPasswordHandlers = Pick<Handlers, 'resetPassword' | 'confirmResetPassword'>\n\n/**\n * @internal\n */\nexport const forgotPasswordActor = (handlers: ForgotPasswordHandlers, overridesContext?: ResetPasswordContext) => {\n return setup({\n types: {\n context: {} as ResetPasswordContext,\n events: {} as AuthEvent,\n },\n guards: {\n shouldResetPassword: ({ context, event }) => shouldResetPassword(context, event),\n shouldConfirmResetPassword: ({ context, event }) => shouldConfirmResetPassword(context, event),\n hasCompletedResetPassword: ({ event }) => hasCompletedResetPassword(event),\n },\n actors: {\n resetPassword: fromPromise<ResetPasswordOutput, ResetPasswordInput>(({ input }) => handlers.resetPassword(input)),\n confirmResetPassword: fromPromise<void, ConfirmResetPasswordInput>(({ input }) => handlers.confirmResetPassword(input)),\n },\n actions: {\n sendUpdate: sendParent({ type: 'CHILD_CHANGED' }),\n setSignInStep: assign({ step: 'SIGN_IN' }),\n setNextResetPasswordStep: assign({ step: setNextResetPasswordStep }),\n setCodeDeliveryDetails: assign({ codeDeliveryDetails: setCodeDeliveryDetails }),\n setUsername: assign({ username: setUsername }),\n setRemoteError: assign({ remoteError: setRemoteError }),\n clearError: assign({ remoteError: undefined }),\n },\n }).createMachine({\n id: 'forgotPasswordActor',\n initial: 'init',\n context: ({ input }) => ({ step: 'FORGOT_PASSWORD', ...overridesContext, ...input }),\n states: {\n init: {\n always: [\n { guard: 'shouldResetPassword', target: '#forgotPasswordActor.confirmResetPassword' },\n { guard: 'shouldConfirmResetPassword', target: '#forgotPasswordActor.confirmResetPassword' },\n { target: '#forgotPasswordActor.forgotPassword' },\n ],\n },\n forgotPassword: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'setUsername', 'clearError'],\n invoke: {\n src: 'resetPassword',\n input: ({ context: { username } }) => ({ username }) as ResetPasswordInput,\n onDone: [{ actions: ['setCodeDeliveryDetails', 'setNextResetPasswordStep'], target: '#forgotPasswordActor.confirmResetPassword' }],\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n confirmResetPassword: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n RESEND: { target: 'resendCode' },\n },\n },\n resendCode: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'resetPassword',\n input: ({ context: { username } }) => ({ username }) as ResetPasswordInput,\n onDone: { target: 'idle' },\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmResetPassword',\n input: ({ context, event }) => ({ username: context.username, ...event.data }) as ConfirmResetPasswordInput,\n onDone: [\n { guard: 'hasCompletedResetPassword', actions: 'setNextResetPasswordStep', target: '#forgotPasswordActor.resolved' },\n { actions: 'setSignInStep', target: '#forgotPasswordActor.resolved' },\n ],\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n resolved: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;;;AAWA,IAAa,uBAAuB,UAAkC,qBAA4C;CAChH,OAAO,MAAM;EACX,OAAO;GACL,SAAS,CAAC;GACV,QAAQ,CAAC;EACX;EACA,QAAQ;GACN,sBAAsB,EAAE,SAAS,YAAY,oBAAoB,SAAS,KAAK;GAC/E,6BAA6B,EAAE,SAAS,YAAY,2BAA2B,SAAS,KAAK;GAC7F,4BAA4B,EAAE,YAAY,0BAA0B,KAAK;EAC3E;EACA,QAAQ;GACN,eAAe,aAAsD,EAAE,YAAY,SAAS,cAAc,KAAK,CAAC;GAChH,sBAAsB,aAA8C,EAAE,YAAY,SAAS,qBAAqB,KAAK,CAAC;EACxH;EACA,SAAS;GACP,YAAY,WAAW,EAAE,MAAM,gBAAgB,CAAC;GAChD,eAAe,OAAO,EAAE,MAAM,UAAU,CAAC;GACzC,0BAA0B,OAAO,EAAE,MAAM,yBAAyB,CAAC;GACnE,wBAAwB,OAAO,EAAE,qBAAqB,uBAAuB,CAAC;GAC9E,aAAa,OAAO,EAAE,UAAU,YAAY,CAAC;GAC7C,gBAAgB,OAAO,EAAE,aAAa,eAAe,CAAC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G,MAAM;OAAK;OAC5E,QAAQ,CACN;QAAE,OAAO;QAA6B,SAAS;QAA4B,QAAQ;OAAgC,GACnH;QAAE,SAAS;QAAiB,QAAQ;OAAgC,CACtE;OACA,SAAS;QAAE,SAAS;QAAkB,QAAQ;OAAO;MACvD;KACF;IACF;GACF;GACA,UAAU,EAAE,MAAM,QAAQ;EAC5B;EACA,SAAS,EAAE,cAAc;CAC3B,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","names":[],"sources":["../../src/machines/guards.ts"],"sourcesContent":["/*\n * Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * (C) 2025 GAHOJIN, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\nimport type { FetchUserAttributesOutput, ResetPasswordOutput, SignInOutput, SignUpOutput } from '@aws-amplify/auth'\nimport type { AuthEvent, ResetPasswordContext, SignUpContext, Step } from '~/types/machines.js'\n\nconst SIGN_IN_STEP_MFA_CONFIRMATION: Step[] = ['CONFIRM_SIGN_IN_WITH_SMS_CODE', 'CONFIRM_SIGN_IN_WITH_TOTP_CODE', 'CONFIRM_SIGN_IN_WITH_EMAIL_CODE']\n\nexport const shouldConfirmSignInWithNewPassword = (event: AuthEvent): boolean => {\n const output = event.output as SignInOutput\n return output?.nextStep?.signInStep === 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED'\n}\n\nexport const shouldResetPasswordFromSignIn = (event: AuthEvent): boolean => {\n const output = event.output as SignInOutput\n return output?.nextStep?.signInStep === 'RESET_PASSWORD'\n}\n\nexport const shouldConfirmSignUpFromSignIn = (event: AuthEvent): boolean => {\n const output = event.output as SignInOutput\n return output?.nextStep?.signInStep === 'CONFIRM_SIGN_UP'\n}\n\nexport const shouldAutoSignIn = (event: AuthEvent): boolean => {\n const output = event.output as SignUpOutput\n return output?.nextStep?.signUpStep === 'COMPLETE_AUTO_SIGN_IN'\n}\n\nexport const shouldManualSignIn = (context: SignUpContext, event: AuthEvent): boolean => {\n const output = event.output as SignUpOutput\n return output?.nextStep?.signUpStep === 'DONE' && context.step === 'CONFIRM_SIGN_UP'\n}\n\nexport const hasCompletedSignIn = (event: AuthEvent): boolean => {\n const output = event.output as SignInOutput\n return output?.nextStep?.signInStep === 'DONE'\n}\n\nexport const hasCompletedSignUp = (event: AuthEvent): boolean => {\n const output = event.output as SignUpOutput\n return output?.nextStep?.signUpStep === 'DONE'\n}\n\nexport const hasCompletedResetPassword = (event: AuthEvent): boolean => {\n const output = event.output as ResetPasswordOutput\n return output?.nextStep?.resetPasswordStep === 'DONE'\n}\n\nexport const hasCompletedAttributeConfirmation = (step: Step): boolean => {\n return step === 'CONFIRM_ATTRIBUTE_COMPLETE'\n}\n\nexport const isConfirmUserAttributeStep = (step: Step): boolean => {\n return step === 'CONFIRM_ATTRIBUTE_WITH_CODE'\n}\n\nexport const isShouldConfirmUserAttributeStep = (step: Step): boolean => {\n return step === 'SHOULD_CONFIRM_USER_ATTRIBUTE'\n}\n\nexport const isResetPasswordStep = (step: Step): boolean => {\n return step === 'RESET_PASSWORD'\n}\n\nexport const isConfirmSignUpStep = (step: Step): boolean => {\n return step === 'CONFIRM_SIGN_UP'\n}\n\nexport const isShouldConfirmSignInWithNewPassword = (step: Step): boolean => {\n return step === 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED'\n}\n\nexport const shouldConfirmSignIn = (step: Step): boolean => {\n return SIGN_IN_STEP_MFA_CONFIRMATION.includes(step)\n}\n\nexport const shouldSetupTotp = (step: Step): boolean => {\n return step === 'CONTINUE_SIGN_IN_WITH_TOTP_SETUP'\n}\n\nexport const shouldSetupEmail = (step: Step): boolean => {\n return step === 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP'\n}\n\nexport const shouldSelectMfaType = (step: Step): boolean => {\n return ['CONTINUE_SIGN_IN_WITH_MFA_SELECTION', 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION'].includes(step)\n}\n\nexport const shouldResetPassword = (context: ResetPasswordContext, event: AuthEvent): boolean => {\n const step = event?.input?.step ?? context.step\n return step === 'RESET_PASSWORD'\n}\n\nexport const shouldConfirmResetPassword = (context: ResetPasswordContext, event: AuthEvent): boolean => {\n const step = event?.input?.step ?? context.step\n return step === 'CONFIRM_RESET_PASSWORD_WITH_CODE'\n}\n\nexport const shouldVerifyAttribute = (event: AuthEvent): boolean => {\n const { email, phone_number, phone_number_verified, email_verified } = (event.output ?? {}) as FetchUserAttributesOutput\n\n // if neither email nor phone_number exist\n // there is nothing to verify\n if (!email && !phone_number) {\n return false\n }\n\n // email/phone_verified is returned as a string\n const emailNotVerified = email_verified === undefined || email_verified === 'false'\n const phoneNotVerified = phone_number_verified === undefined || phone_number_verified === 'false'\n\n // only request verification if both email and phone are not verified\n return emailNotVerified && phoneNotVerified\n}\n\nexport const isUserAlreadyConfirmed = (event: AuthEvent): boolean => {\n return event.error?.message === 'User is already confirmed.'\n}\n"],"mappings":";AAcA,IAAM,gCAAwC;CAAC;CAAiC;CAAkC;
|
|
1
|
+
{"version":3,"file":"guards.js","names":[],"sources":["../../src/machines/guards.ts"],"sourcesContent":["/*\n * Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * (C) 2025 GAHOJIN, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\nimport type { FetchUserAttributesOutput, ResetPasswordOutput, SignInOutput, SignUpOutput } from '@aws-amplify/auth'\nimport type { AuthEvent, ResetPasswordContext, SignUpContext, Step } from '~/types/machines.js'\n\nconst SIGN_IN_STEP_MFA_CONFIRMATION: Step[] = ['CONFIRM_SIGN_IN_WITH_SMS_CODE', 'CONFIRM_SIGN_IN_WITH_TOTP_CODE', 'CONFIRM_SIGN_IN_WITH_EMAIL_CODE']\n\nexport const shouldConfirmSignInWithNewPassword = (event: AuthEvent): boolean => {\n const output = event.output as SignInOutput\n return output?.nextStep?.signInStep === 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED'\n}\n\nexport const shouldResetPasswordFromSignIn = (event: AuthEvent): boolean => {\n const output = event.output as SignInOutput\n return output?.nextStep?.signInStep === 'RESET_PASSWORD'\n}\n\nexport const shouldConfirmSignUpFromSignIn = (event: AuthEvent): boolean => {\n const output = event.output as SignInOutput\n return output?.nextStep?.signInStep === 'CONFIRM_SIGN_UP'\n}\n\nexport const shouldAutoSignIn = (event: AuthEvent): boolean => {\n const output = event.output as SignUpOutput\n return output?.nextStep?.signUpStep === 'COMPLETE_AUTO_SIGN_IN'\n}\n\nexport const shouldManualSignIn = (context: SignUpContext, event: AuthEvent): boolean => {\n const output = event.output as SignUpOutput\n return output?.nextStep?.signUpStep === 'DONE' && context.step === 'CONFIRM_SIGN_UP'\n}\n\nexport const hasCompletedSignIn = (event: AuthEvent): boolean => {\n const output = event.output as SignInOutput\n return output?.nextStep?.signInStep === 'DONE'\n}\n\nexport const hasCompletedSignUp = (event: AuthEvent): boolean => {\n const output = event.output as SignUpOutput\n return output?.nextStep?.signUpStep === 'DONE'\n}\n\nexport const hasCompletedResetPassword = (event: AuthEvent): boolean => {\n const output = event.output as ResetPasswordOutput\n return output?.nextStep?.resetPasswordStep === 'DONE'\n}\n\nexport const hasCompletedAttributeConfirmation = (step: Step): boolean => {\n return step === 'CONFIRM_ATTRIBUTE_COMPLETE'\n}\n\nexport const isConfirmUserAttributeStep = (step: Step): boolean => {\n return step === 'CONFIRM_ATTRIBUTE_WITH_CODE'\n}\n\nexport const isShouldConfirmUserAttributeStep = (step: Step): boolean => {\n return step === 'SHOULD_CONFIRM_USER_ATTRIBUTE'\n}\n\nexport const isResetPasswordStep = (step: Step): boolean => {\n return step === 'RESET_PASSWORD'\n}\n\nexport const isConfirmSignUpStep = (step: Step): boolean => {\n return step === 'CONFIRM_SIGN_UP'\n}\n\nexport const isShouldConfirmSignInWithNewPassword = (step: Step): boolean => {\n return step === 'CONFIRM_SIGN_IN_WITH_NEW_PASSWORD_REQUIRED'\n}\n\nexport const shouldConfirmSignIn = (step: Step): boolean => {\n return SIGN_IN_STEP_MFA_CONFIRMATION.includes(step)\n}\n\nexport const shouldSetupTotp = (step: Step): boolean => {\n return step === 'CONTINUE_SIGN_IN_WITH_TOTP_SETUP'\n}\n\nexport const shouldSetupEmail = (step: Step): boolean => {\n return step === 'CONTINUE_SIGN_IN_WITH_EMAIL_SETUP'\n}\n\nexport const shouldSelectMfaType = (step: Step): boolean => {\n return ['CONTINUE_SIGN_IN_WITH_MFA_SELECTION', 'CONTINUE_SIGN_IN_WITH_MFA_SETUP_SELECTION'].includes(step)\n}\n\nexport const shouldResetPassword = (context: ResetPasswordContext, event: AuthEvent): boolean => {\n const step = event?.input?.step ?? context.step\n return step === 'RESET_PASSWORD'\n}\n\nexport const shouldConfirmResetPassword = (context: ResetPasswordContext, event: AuthEvent): boolean => {\n const step = event?.input?.step ?? context.step\n return step === 'CONFIRM_RESET_PASSWORD_WITH_CODE'\n}\n\nexport const shouldVerifyAttribute = (event: AuthEvent): boolean => {\n const { email, phone_number, phone_number_verified, email_verified } = (event.output ?? {}) as FetchUserAttributesOutput\n\n // if neither email nor phone_number exist\n // there is nothing to verify\n if (!email && !phone_number) {\n return false\n }\n\n // email/phone_verified is returned as a string\n const emailNotVerified = email_verified === undefined || email_verified === 'false'\n const phoneNotVerified = phone_number_verified === undefined || phone_number_verified === 'false'\n\n // only request verification if both email and phone are not verified\n return emailNotVerified && phoneNotVerified\n}\n\nexport const isUserAlreadyConfirmed = (event: AuthEvent): boolean => {\n return event.error?.message === 'User is already confirmed.'\n}\n"],"mappings":";AAcA,IAAM,gCAAwC;CAAC;CAAiC;CAAkC;AAAiC;AAEnJ,IAAa,sCAAsC,UAA8B;CAE/E,OADe,M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UAA8B;CAEtG,QADa,OAAO,OAAO,QAAQ,QAAQ,UAC3B;AAClB;AAEA,IAAa,yBAAyB,UAA8B;CAClE,MAAM,EAAE,OAAO,cAAc,uBAAuB,mBAAoB,MAAM,UAAU,CAAC;CAIzF,IAAI,CAAC,SAAS,CAAC,cACb,OAAO;CAQT,QAJyB,mBAAmB,KAAA,KAAa,mBAAmB,aACnD,0BAA0B,KAAA,KAAa,0BAA0B;AAI5F;AAEA,IAAa,0BAA0B,UAA8B;CACnE,OAAO,MAAM,OAAO,YAAY;AAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor.js","names":[],"sources":["../../../src/machines/signIn/actor.ts"],"sourcesContent":["import type {\n ConfirmSignInInput,\n ConfirmSignInOutput,\n ResendSignUpCodeInput,\n ResendSignUpCodeOutput,\n ResetPasswordInput,\n ResetPasswordOutput,\n SignInInput,\n SignInOutput,\n SignInWithRedirectInput,\n} from '@aws-amplify/auth'\nimport { assign, fromPromise, sendParent, setup } from 'xstate'\nimport {\n setAllowedMfaTypes,\n setCodeDeliveryDetails,\n setNextSignInStep,\n setRemoteError,\n setSignInActorDoneData,\n setTotpSecretCode,\n setUnverifiedUserAttributes,\n setUsername,\n} from '~/machines/actions.js'\nimport {\n hasCompletedSignIn,\n isShouldConfirmSignInWithNewPassword,\n shouldConfirmSignIn,\n shouldConfirmSignInWithNewPassword,\n shouldConfirmSignUpFromSignIn,\n shouldResetPasswordFromSignIn,\n shouldSelectMfaType,\n shouldSetupEmail,\n shouldSetupTotp,\n shouldVerifyAttribute,\n} from '~/machines/guards.js'\nimport type { AuthEvent, Handlers, SignInContext } from '~/types/machines.js'\n\ntype SignInHandlers = Pick<Handlers, 'confirmSignIn' | 'fetchUserAttributes' | 'resetPassword' | 'signIn' | 'signInWithRedirect' | 'resendSignUpCode'>\n\n/**\n * @internal\n */\nexport const signInActor = (handlers: SignInHandlers, overridesContext?: SignInContext) => {\n const machineSetup = setup({\n types: {\n context: {} as SignInContext,\n events: {} as AuthEvent,\n },\n guards: {\n hasCompletedSignIn: ({ event }) => hasCompletedSignIn(event),\n isShouldConfirmSignInWithNewPassword: ({ context: { step } }) => isShouldConfirmSignInWithNewPassword(step),\n shouldConfirmSignIn: ({ context: { step } }) => shouldConfirmSignIn(step),\n shouldSetupTotp: ({ context: { step } }) => shouldSetupTotp(step),\n shouldSetupEmail: ({ context: { step } }) => shouldSetupEmail(step),\n shouldSelectMfaType: ({ context: { step } }) => shouldSelectMfaType(step),\n shouldVerifyAttribute: ({ event }) => shouldVerifyAttribute(event),\n shouldConfirmSignInWithNewPassword: ({ event }) => shouldConfirmSignInWithNewPassword(event),\n shouldResetPasswordFromSignIn: ({ event }) => shouldResetPasswordFromSignIn(event),\n shouldConfirmSignUpFromSignIn: ({ event }) => shouldConfirmSignUpFromSignIn(event),\n },\n actors: {\n fetchUserAttributes: fromPromise(() => handlers.fetchUserAttributes()),\n resetPassword: fromPromise<ResetPasswordOutput, ResetPasswordInput>(({ input }) => handlers.resetPassword(input)),\n resendSignUpCode: fromPromise<ResendSignUpCodeOutput, ResendSignUpCodeInput>(({ input }) => handlers.resendSignUpCode(input)),\n signIn: fromPromise<SignInOutput, SignInInput>(({ input }) => handlers.signIn(input)),\n confirmSignIn: fromPromise<ConfirmSignInOutput, ConfirmSignInInput>(({ input }) => handlers.confirmSignIn(input)),\n signInWithRedirect: fromPromise<void, SignInWithRedirectInput>(({ input }) => handlers.signInWithRedirect(input)),\n },\n actions: {\n sendUpdate: sendParent({ type: 'CHILD_CHANGED' }),\n setShouldVerifyUserAttributeStep: assign({ step: 'SHOULD_CONFIRM_USER_ATTRIBUTE', unverifiedUserAttributes: setUnverifiedUserAttributes }),\n setConfirmAttributeCompleteStep: assign({ step: 'CONFIRM_ATTRIBUTE_COMPLETE' }),\n setConfirmSignUpStep: assign({ step: 'CONFIRM_SIGN_UP' }),\n setNextSignInStep: assign({ step: setNextSignInStep }),\n setCodeDeliveryDetails: assign({ codeDeliveryDetails: setCodeDeliveryDetails }),\n setTotpSecretCode: assign({ totpSecretCode: setTotpSecretCode }),\n setAllowedMfaTypes: assign({ allowedMfaTypes: setAllowedMfaTypes }),\n setActorDoneData: assign(setSignInActorDoneData),\n setUsername: assign({ username: setUsername }),\n setRemoteError: assign({ remoteError: setRemoteError }),\n clearError: assign({ remoteError: undefined }),\n },\n })\n\n const handleSignInResponse = machineSetup.createStateConfig({\n onDone: [\n { guard: 'hasCompletedSignIn', actions: 'setNextSignInStep', target: '#signInActor.fetchUserAttributes' },\n { guard: 'shouldConfirmSignInWithNewPassword', actions: 'setNextSignInStep', target: '#signInActor.forceChangePassword' },\n { guard: 'shouldResetPasswordFromSignIn', actions: 'setNextSignInStep', target: '#signInActor.resetPassword' },\n { guard: 'shouldConfirmSignUpFromSignIn', actions: 'setNextSignInStep', target: '#signInActor.resendSignUpCode' },\n { actions: ['setNextSignInStep', 'setTotpSecretCode', 'setAllowedMfaTypes'], target: '#signInActor.init' },\n ],\n })\n const confirmSignInState = machineSetup.createStateConfig({\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n SIGN_IN: { target: '#signInActor.signIn' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmSignIn',\n input: ({ event }) => event.data as ConfirmSignInInput,\n ...handleSignInResponse,\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n })\n\n return machineSetup.createMachine({\n id: 'signInActor',\n context: ({ input }) => ({ step: 'SIGN_IN', ...overridesContext, ...input }),\n initial: 'init',\n states: {\n init: {\n always: [\n { guard: 'shouldConfirmSignIn', target: '#signInActor.confirmSignIn' },\n { guard: 'shouldSetupTotp', target: '#signInActor.setupTotp' },\n { guard: 'shouldSetupEmail', target: '#signInActor.setupEmail' },\n { guard: 'shouldSelectMfaType', target: '#signInActor.selectMfaType' },\n { guard: 'isShouldConfirmSignInWithNewPassword', actions: 'setActorDoneData', target: '#signInActor.forceChangePassword' },\n { target: '#signInActor.signIn' },\n ],\n },\n federatedSignIn: {\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'signInWithRedirect',\n input: ({ event }) => event.data as SignInWithRedirectInput,\n onDone: { target: '#signInActor.signIn' },\n onError: { actions: 'setRemoteError', target: '#signInActor.signIn' },\n },\n },\n fetchUserAttributes: {\n invoke: {\n src: 'fetchUserAttributes',\n onDone: [\n {\n guard: 'shouldVerifyAttribute',\n actions: 'setShouldVerifyUserAttributeStep',\n target: '#signInActor.resolved',\n },\n { actions: 'setConfirmAttributeCompleteStep', target: '#signInActor.resolved' },\n ],\n onError: { actions: 'setConfirmAttributeCompleteStep', target: '#signInActor.resolved' },\n },\n },\n resendSignUpCode: {\n tags: 'pending',\n invoke: {\n src: 'resendSignUpCode',\n input: ({ context: { username }, event }) => ({ username, ...event.data }) as ResendSignUpCodeInput,\n onDone: { actions: 'setCodeDeliveryDetails', target: '#signInActor.resolved' },\n onError: { actions: 'setRemoteError', target: '#signInActor.signIn' },\n },\n },\n resetPassword: {\n invoke: {\n src: 'resetPassword',\n input: ({ context: { username }, event }) => ({ username, ...event.data }) as ResetPasswordInput,\n onDone: { actions: 'setCodeDeliveryDetails', target: '#signInActor.resolved' },\n onError: { actions: ['setRemoteError', 'sendUpdate'] },\n },\n },\n signIn: {\n initial: 'idle',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n FEDERATED_SIGN_IN: { target: '#signInActor.federatedSignIn' },\n SUBMIT: { target: 'submit' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'setUsername', 'clearError'],\n invoke: {\n src: 'signIn',\n input: ({ event }) => event.data as SignInInput,\n ...handleSignInResponse,\n onError: [\n { guard: 'shouldConfirmSignUpFromSignIn', actions: 'setConfirmSignUpStep', target: '#signInActor.resendSignUpCode' },\n { actions: 'setRemoteError', target: 'idle' },\n ],\n },\n },\n },\n },\n confirmSignIn: confirmSignInState,\n forceChangePassword: {\n initial: 'idle',\n entry: 'clearError',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: { SUBMIT: { target: 'submit' } },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmSignIn',\n input: ({ event }) => event.data as ConfirmSignInInput,\n ...handleSignInResponse,\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n setupTotp: confirmSignInState,\n setupEmail: confirmSignInState,\n selectMfaType: confirmSignInState,\n resolved: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;;;AAyCA,IAAa,eAAe,UAA0B,qBAAqC;CACzF,MAAM,eAAe,MAAM;EACzB,OAAO;GACL,SAAS,EAAE;GACX,QAAQ,EAAE;GACX;EACD,QAAQ;GACN,qBAAqB,EAAE,YAAY,mBAAmB,MAAM;GAC5D,uCAAuC,EAAE,SAAS,EAAE,aAAa,qCAAqC,KAAK;GAC3G,sBAAsB,EAAE,SAAS,EAAE,aAAa,oBAAoB,KAAK;GACzE,kBAAkB,EAAE,SAAS,EAAE,aAAa,gBAAgB,KAAK;GACjE,mBAAmB,EAAE,SAAS,EAAE,aAAa,iBAAiB,KAAK;GACnE,sBAAsB,EAAE,SAAS,EAAE,aAAa,oBAAoB,KAAK;GACzE,wBAAwB,EAAE,YAAY,sBAAsB,MAAM;GAClE,qCAAqC,EAAE,YAAY,mCAAmC,MAAM;GAC5F,gCAAgC,EAAE,YAAY,8BAA8B,MAAM;GAClF,gCAAgC,EAAE,YAAY,8BAA8B,MAAM;GACnF;EACD,QAAQ;GACN,qBAAqB,kBAAkB,SAAS,qBAAqB,CAAC;GACtE,eAAe,aAAsD,EAAE,YAAY,SAAS,cAAc,MAAM,CAAC;GACjH,kBAAkB,aAA4D,EAAE,YAAY,SAAS,iBAAiB,MAAM,CAAC;GAC7H,QAAQ,aAAwC,EAAE,YAAY,SAAS,OAAO,MAAM,CAAC;GACrF,eAAe,a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L,QAAQ,EAAE,SAAS,EAAE,YAAY,aAAa;KAAE;KAAU,GAAG,MAAM;KAAM;IACzE,QAAQ;KAAE,SAAS;KAA0B,QAAQ;KAAyB;IAC9E,SAAS,EAAE,SAAS,CAAC,kBAAkB,aAAa,EAAE;IACvD,EACF;GACD,QAAQ;IACN,SAAS;IACT,QAAQ;KACN,MAAM;MACJ,OAAO;MACP,IAAI;OACF,mBAAmB,EAAE,QAAQ,gCAAgC;OAC7D,QAAQ,EAAE,QAAQ,UAAU;OAC7B;MACF;KACD,QAAQ;MACN,MAAM;MACN,OAAO;OAAC;OAAc;OAAe;OAAa;MAClD,QAAQ;OACN,KAAK;OACL,QAAQ,EAAE,YAAY,MAAM;OAC5B,GAAG;OACH,SAAS,CACP;QAAE,OAAO;QAAiC,SAAS;QAAwB,QAAQ;QAAiC,EACpH;QAAE,SAAS;QAAkB,QAAQ;QAAQ,CAC9C;OACF;MACF;KACF;IACF;GACD,eAAe;GACf,qBAAqB;IACnB,SAAS;IACT,OAAO;IACP,MAAM;IACN,QAAQ;KACN,MAAM;MACJ,OAAO;MACP,IAAI,EAAE,QAAQ,EAAE,QAAQ,UAAU,EAAE;MACrC;KACD,QAAQ;MACN,MAAM;MACN,OAAO,CAAC,cAAc,aAAa;MACnC,QAAQ;OACN,KAAK;OACL,QAAQ,EAAE,YAAY,MAAM;OAC5B,GAAG;OACH,SAAS;QAAE,SAAS;QAAkB,QAAQ;QAAQ;OACvD;MACF;KACF;IACF;GACD,WAAW;GACX,YAAY;GACZ,eAAe;GACf,UAAU,EAAE,MAAM,SAAS;GAC5B;EACD,SAAS,EAAE,cAAc;EAC1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"actor.js","names":[],"sources":["../../../src/machines/signIn/actor.ts"],"sourcesContent":["import type {\n ConfirmSignInInput,\n ConfirmSignInOutput,\n ResendSignUpCodeInput,\n ResendSignUpCodeOutput,\n ResetPasswordInput,\n ResetPasswordOutput,\n SignInInput,\n SignInOutput,\n SignInWithRedirectInput,\n} from '@aws-amplify/auth'\nimport { assign, fromPromise, sendParent, setup } from 'xstate'\nimport {\n setAllowedMfaTypes,\n setCodeDeliveryDetails,\n setNextSignInStep,\n setRemoteError,\n setSignInActorDoneData,\n setTotpSecretCode,\n setUnverifiedUserAttributes,\n setUsername,\n} from '~/machines/actions.js'\nimport {\n hasCompletedSignIn,\n isShouldConfirmSignInWithNewPassword,\n shouldConfirmSignIn,\n shouldConfirmSignInWithNewPassword,\n shouldConfirmSignUpFromSignIn,\n shouldResetPasswordFromSignIn,\n shouldSelectMfaType,\n shouldSetupEmail,\n shouldSetupTotp,\n shouldVerifyAttribute,\n} from '~/machines/guards.js'\nimport type { AuthEvent, Handlers, SignInContext } from '~/types/machines.js'\n\ntype SignInHandlers = Pick<Handlers, 'confirmSignIn' | 'fetchUserAttributes' | 'resetPassword' | 'signIn' | 'signInWithRedirect' | 'resendSignUpCode'>\n\n/**\n * @internal\n */\nexport const signInActor = (handlers: SignInHandlers, overridesContext?: SignInContext) => {\n const machineSetup = setup({\n types: {\n context: {} as SignInContext,\n events: {} as AuthEvent,\n },\n guards: {\n hasCompletedSignIn: ({ event }) => hasCompletedSignIn(event),\n isShouldConfirmSignInWithNewPassword: ({ context: { step } }) => isShouldConfirmSignInWithNewPassword(step),\n shouldConfirmSignIn: ({ context: { step } }) => shouldConfirmSignIn(step),\n shouldSetupTotp: ({ context: { step } }) => shouldSetupTotp(step),\n shouldSetupEmail: ({ context: { step } }) => shouldSetupEmail(step),\n shouldSelectMfaType: ({ context: { step } }) => shouldSelectMfaType(step),\n shouldVerifyAttribute: ({ event }) => shouldVerifyAttribute(event),\n shouldConfirmSignInWithNewPassword: ({ event }) => shouldConfirmSignInWithNewPassword(event),\n shouldResetPasswordFromSignIn: ({ event }) => shouldResetPasswordFromSignIn(event),\n shouldConfirmSignUpFromSignIn: ({ event }) => shouldConfirmSignUpFromSignIn(event),\n },\n actors: {\n fetchUserAttributes: fromPromise(() => handlers.fetchUserAttributes()),\n resetPassword: fromPromise<ResetPasswordOutput, ResetPasswordInput>(({ input }) => handlers.resetPassword(input)),\n resendSignUpCode: fromPromise<ResendSignUpCodeOutput, ResendSignUpCodeInput>(({ input }) => handlers.resendSignUpCode(input)),\n signIn: fromPromise<SignInOutput, SignInInput>(({ input }) => handlers.signIn(input)),\n confirmSignIn: fromPromise<ConfirmSignInOutput, ConfirmSignInInput>(({ input }) => handlers.confirmSignIn(input)),\n signInWithRedirect: fromPromise<void, SignInWithRedirectInput>(({ input }) => handlers.signInWithRedirect(input)),\n },\n actions: {\n sendUpdate: sendParent({ type: 'CHILD_CHANGED' }),\n setShouldVerifyUserAttributeStep: assign({ step: 'SHOULD_CONFIRM_USER_ATTRIBUTE', unverifiedUserAttributes: setUnverifiedUserAttributes }),\n setConfirmAttributeCompleteStep: assign({ step: 'CONFIRM_ATTRIBUTE_COMPLETE' }),\n setConfirmSignUpStep: assign({ step: 'CONFIRM_SIGN_UP' }),\n setNextSignInStep: assign({ step: setNextSignInStep }),\n setCodeDeliveryDetails: assign({ codeDeliveryDetails: setCodeDeliveryDetails }),\n setTotpSecretCode: assign({ totpSecretCode: setTotpSecretCode }),\n setAllowedMfaTypes: assign({ allowedMfaTypes: setAllowedMfaTypes }),\n setActorDoneData: assign(setSignInActorDoneData),\n setUsername: assign({ username: setUsername }),\n setRemoteError: assign({ remoteError: setRemoteError }),\n clearError: assign({ remoteError: undefined }),\n },\n })\n\n const handleSignInResponse = machineSetup.createStateConfig({\n onDone: [\n { guard: 'hasCompletedSignIn', actions: 'setNextSignInStep', target: '#signInActor.fetchUserAttributes' },\n { guard: 'shouldConfirmSignInWithNewPassword', actions: 'setNextSignInStep', target: '#signInActor.forceChangePassword' },\n { guard: 'shouldResetPasswordFromSignIn', actions: 'setNextSignInStep', target: '#signInActor.resetPassword' },\n { guard: 'shouldConfirmSignUpFromSignIn', actions: 'setNextSignInStep', target: '#signInActor.resendSignUpCode' },\n { actions: ['setNextSignInStep', 'setTotpSecretCode', 'setAllowedMfaTypes'], target: '#signInActor.init' },\n ],\n })\n const confirmSignInState = machineSetup.createStateConfig({\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n SIGN_IN: { target: '#signInActor.signIn' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmSignIn',\n input: ({ event }) => event.data as ConfirmSignInInput,\n ...handleSignInResponse,\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n })\n\n return machineSetup.createMachine({\n id: 'signInActor',\n context: ({ input }) => ({ step: 'SIGN_IN', ...overridesContext, ...input }),\n initial: 'init',\n states: {\n init: {\n always: [\n { guard: 'shouldConfirmSignIn', target: '#signInActor.confirmSignIn' },\n { guard: 'shouldSetupTotp', target: '#signInActor.setupTotp' },\n { guard: 'shouldSetupEmail', target: '#signInActor.setupEmail' },\n { guard: 'shouldSelectMfaType', target: '#signInActor.selectMfaType' },\n { guard: 'isShouldConfirmSignInWithNewPassword', actions: 'setActorDoneData', target: '#signInActor.forceChangePassword' },\n { target: '#signInActor.signIn' },\n ],\n },\n federatedSignIn: {\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'signInWithRedirect',\n input: ({ event }) => event.data as SignInWithRedirectInput,\n onDone: { target: '#signInActor.signIn' },\n onError: { actions: 'setRemoteError', target: '#signInActor.signIn' },\n },\n },\n fetchUserAttributes: {\n invoke: {\n src: 'fetchUserAttributes',\n onDone: [\n {\n guard: 'shouldVerifyAttribute',\n actions: 'setShouldVerifyUserAttributeStep',\n target: '#signInActor.resolved',\n },\n { actions: 'setConfirmAttributeCompleteStep', target: '#signInActor.resolved' },\n ],\n onError: { actions: 'setConfirmAttributeCompleteStep', target: '#signInActor.resolved' },\n },\n },\n resendSignUpCode: {\n tags: 'pending',\n invoke: {\n src: 'resendSignUpCode',\n input: ({ context: { username }, event }) => ({ username, ...event.data }) as ResendSignUpCodeInput,\n onDone: { actions: 'setCodeDeliveryDetails', target: '#signInActor.resolved' },\n onError: { actions: 'setRemoteError', target: '#signInActor.signIn' },\n },\n },\n resetPassword: {\n invoke: {\n src: 'resetPassword',\n input: ({ context: { username }, event }) => ({ username, ...event.data }) as ResetPasswordInput,\n onDone: { actions: 'setCodeDeliveryDetails', target: '#signInActor.resolved' },\n onError: { actions: ['setRemoteError', 'sendUpdate'] },\n },\n },\n signIn: {\n initial: 'idle',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n FEDERATED_SIGN_IN: { target: '#signInActor.federatedSignIn' },\n SUBMIT: { target: 'submit' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'setUsername', 'clearError'],\n invoke: {\n src: 'signIn',\n input: ({ event }) => event.data as SignInInput,\n ...handleSignInResponse,\n onError: [\n { guard: 'shouldConfirmSignUpFromSignIn', actions: 'setConfirmSignUpStep', target: '#signInActor.resendSignUpCode' },\n { actions: 'setRemoteError', target: 'idle' },\n ],\n },\n },\n },\n },\n confirmSignIn: confirmSignInState,\n forceChangePassword: {\n initial: 'idle',\n entry: 'clearError',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: { SUBMIT: { target: 'submit' } },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmSignIn',\n input: ({ event }) => event.data as ConfirmSignInInput,\n ...handleSignInResponse,\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n setupTotp: confirmSignInState,\n setupEmail: confirmSignInState,\n selectMfaType: confirmSignInState,\n resolved: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;;;AAyCA,IAAa,eAAe,UAA0B,qBAAqC;CACzF,MAAM,eAAe,MAAM;EACzB,OAAO;GACL,SAAS,CAAC;GACV,QAAQ,CAAC;EACX;EACA,QAAQ;GACN,qBAAqB,EAAE,YAAY,mBAAmB,KAAK;GAC3D,uCAAuC,EAAE,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;GACA,eAAe;GACf,qBAAqB;IACnB,SAAS;IACT,OAAO;IACP,MAAM;IACN,QAAQ;KACN,MAAM;MACJ,OAAO;MACP,IAAI,EAAE,QAAQ,EAAE,QAAQ,SAAS,EAAE;KACrC;KACA,QAAQ;MACN,MAAM;MACN,OAAO,CAAC,cAAc,YAAY;MAClC,QAAQ;OACN,KAAK;OACL,QAAQ,EAAE,YAAY,MAAM;OAC5B,GAAG;OACH,SAAS;QAAE,SAAS;QAAkB,QAAQ;OAAO;MACvD;KACF;IACF;GACF;GACA,WAAW;GACX,YAAY;GACZ,eAAe;GACf,UAAU,EAAE,MAAM,QAAQ;EAC5B;EACA,SAAS,EAAE,cAAc;CAC3B,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor.js","names":[],"sources":["../../../src/machines/signOut/actor.ts"],"sourcesContent":["import { fromPromise, setup } from 'xstate'\nimport type { Handlers, SignOutContext } from '~/types/machines.js'\n\ntype SignOutHandlers = Pick<Handlers, 'signOut'>\n\n/**\n * @internal\n */\nexport const signOutActor = (handlers: SignOutHandlers) => {\n return setup({\n types: {\n context: {} as SignOutContext,\n },\n actors: {\n signOut: fromPromise(() => handlers.signOut()),\n },\n }).createMachine({\n id: 'signOutActor',\n initial: 'pending',\n context: {},\n states: {\n pending: {\n tags: 'pending',\n invoke: {\n src: 'signOut',\n onDone: 'resolved',\n onError: 'rejected',\n },\n },\n resolved: { type: 'final' },\n rejected: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;AAQA,IAAa,gBAAgB,aAA8B;
|
|
1
|
+
{"version":3,"file":"actor.js","names":[],"sources":["../../../src/machines/signOut/actor.ts"],"sourcesContent":["import { fromPromise, setup } from 'xstate'\nimport type { Handlers, SignOutContext } from '~/types/machines.js'\n\ntype SignOutHandlers = Pick<Handlers, 'signOut'>\n\n/**\n * @internal\n */\nexport const signOutActor = (handlers: SignOutHandlers) => {\n return setup({\n types: {\n context: {} as SignOutContext,\n },\n actors: {\n signOut: fromPromise(() => handlers.signOut()),\n },\n }).createMachine({\n id: 'signOutActor',\n initial: 'pending',\n context: {},\n states: {\n pending: {\n tags: 'pending',\n invoke: {\n src: 'signOut',\n onDone: 'resolved',\n onError: 'rejected',\n },\n },\n resolved: { type: 'final' },\n rejected: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;AAQA,IAAa,gBAAgB,aAA8B;CACzD,OAAO,MAAM;EACX,OAAO,EACL,SAAS,CAAC,EACZ;EACA,QAAQ,EACN,SAAS,kBAAkB,SAAS,QAAQ,CAAC,EAC/C;CACF,CAAC,EAAE,cAAc;EACf,IAAI;EACJ,SAAS;EACT,SAAS,CAAC;EACV,QAAQ;GACN,SAAS;IACP,MAAM;IACN,QAAQ;KACN,KAAK;KACL,QAAQ;KACR,SAAS;IACX;GACF;GACA,UAAU,EAAE,MAAM,QAAQ;GAC1B,UAAU,EAAE,MAAM,QAAQ;EAC5B;EACA,SAAS,EAAE,cAAc;CAC3B,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actor.js","names":[],"sources":["../../../src/machines/signUp/actor.ts"],"sourcesContent":["import type {\n ConfirmSignUpInput,\n ConfirmSignUpOutput,\n ResendSignUpCodeInput,\n ResendSignUpCodeOutput,\n ResetPasswordInput,\n ResetPasswordOutput,\n SignInWithRedirectInput,\n SignUpInput,\n SignUpOutput,\n} from '@aws-amplify/auth'\nimport { assign, fromPromise, sendParent, setup } from 'xstate'\nimport {\n setAllowedMfaTypes,\n setCodeDeliveryDetails,\n setNextSignInStep,\n setNextSignUpStep,\n setRemoteError,\n setTotpSecretCode,\n setUnverifiedUserAttributes,\n setUsername,\n} from '~/machines/actions.js'\nimport {\n hasCompletedSignIn,\n hasCompletedSignUp,\n isUserAlreadyConfirmed,\n shouldAutoSignIn,\n shouldConfirmSignInWithNewPassword,\n shouldConfirmSignUpFromSignIn,\n shouldManualSignIn,\n shouldResetPasswordFromSignIn,\n shouldVerifyAttribute,\n} from '~/machines/guards.js'\nimport type { AuthEvent, Handlers, SignUpContext } from '~/types/machines.js'\n\ntype SignUpHandlers = Pick<\n Handlers,\n 'autoSignIn' | 'confirmSignUp' | 'signInWithRedirect' | 'signUp' | 'resetPassword' | 'resendSignUpCode' | 'fetchUserAttributes'\n>\n\n/**\n * @internal\n */\nexport const signUpActor = (handlers: SignUpHandlers, overridesContext?: SignUpContext) => {\n return setup({\n types: {\n context: {} as SignUpContext,\n events: {} as AuthEvent,\n },\n guards: {\n hasCompletedSignIn: ({ event }) => hasCompletedSignIn(event),\n hasCompletedSignUp: ({ event }) => hasCompletedSignUp(event),\n isUserAlreadyConfirmed: ({ event }) => isUserAlreadyConfirmed(event),\n shouldAutoSignIn: ({ event }) => shouldAutoSignIn(event),\n shouldManualSignIn: ({ context, event }) => shouldManualSignIn(context, event),\n shouldConfirmSignInWithNewPassword: ({ event }) => shouldConfirmSignInWithNewPassword(event),\n shouldConfirmSignUp: ({ context: { step } }) => step === 'CONFIRM_SIGN_UP',\n shouldConfirmSignUpFromSignIn: ({ event }) => shouldConfirmSignUpFromSignIn(event),\n shouldResetPasswordFromSignIn: ({ event }) => shouldResetPasswordFromSignIn(event),\n shouldVerifyAttribute: ({ event }) => shouldVerifyAttribute(event),\n },\n actors: {\n autoSignIn: fromPromise(() => handlers.autoSignIn()),\n confirmSignUp: fromPromise<ConfirmSignUpOutput, ConfirmSignUpInput>(({ input }) => handlers.confirmSignUp(input)),\n fetchUserAttributes: fromPromise(() => handlers.fetchUserAttributes()),\n resetPassword: fromPromise<ResetPasswordOutput, ResetPasswordInput>(({ input }) => handlers.resetPassword(input)),\n resendSignUpCode: fromPromise<ResendSignUpCodeOutput, ResendSignUpCodeInput>(({ input }) => handlers.resendSignUpCode(input)),\n signUp: fromPromise<SignUpOutput, SignUpInput>(({ input }) => handlers.signUp(input)),\n signInWithRedirect: fromPromise<void, SignInWithRedirectInput>(({ input }) => handlers.signInWithRedirect(input)),\n },\n actions: {\n sendUpdate: sendParent({ type: 'CHILD_CHANGED' }),\n setShouldVerifyUserAttributeStep: assign({ step: 'SHOULD_CONFIRM_USER_ATTRIBUTE', unverifiedUserAttributes: setUnverifiedUserAttributes }),\n setConfirmAttributeCompleteStep: assign({ step: 'CONFIRM_ATTRIBUTE_COMPLETE' }),\n setSignInStep: assign({ step: 'SIGN_IN' }),\n setNextSignUpStep: assign({ step: setNextSignUpStep }),\n setNextSignInStep: assign({ step: setNextSignInStep }),\n setCodeDeliveryDetails: assign({ codeDeliveryDetails: setCodeDeliveryDetails }),\n setTotpSecretCode: assign({ totpSecretCode: setTotpSecretCode }),\n setAllowedMfaTypes: assign({ allowedMfaTypes: setAllowedMfaTypes }),\n setUsername: assign({ username: setUsername }),\n setRemoteError: assign({ remoteError: setRemoteError }),\n clearError: assign({ remoteError: undefined }),\n },\n }).createMachine({\n id: 'signUpActor',\n initial: 'init',\n context: ({ input }) => ({ step: 'SIGN_UP', ...overridesContext, ...input }),\n states: {\n init: {\n always: [{ guard: 'shouldConfirmSignUp', target: 'confirmSignUp' }, { target: '#signUpActor.signUp' }],\n },\n autoSignIn: {\n tags: 'pending',\n invoke: {\n src: 'autoSignIn',\n onDone: [\n { guard: 'hasCompletedSignIn', actions: 'setNextSignInStep', target: '#signUpActor.fetchUserAttributes' },\n { guard: 'shouldConfirmSignInWithNewPassword', actions: 'setNextSignInStep', target: '#signUpActor.resolved' },\n { guard: 'shouldResetPasswordFromSignIn', actions: 'setNextSignInStep', target: '#signUpActor.resetPassword' },\n { guard: 'shouldConfirmSignUpFromSignIn', actions: 'setNextSignInStep', target: '#signUpActor.resendSignUpCode' },\n { actions: ['setNextSignInStep', 'setTotpSecretCode', 'setAllowedMfaTypes'], target: '#signUpActor.resolved' },\n ],\n onError: { target: '#signUpActor.resolved' },\n },\n },\n fetchUserAttributes: {\n invoke: {\n src: 'fetchUserAttributes',\n onDone: [\n {\n guard: 'shouldVerifyAttribute',\n actions: 'setShouldVerifyUserAttributeStep',\n target: '#signUpActor.resolved',\n },\n { actions: 'setConfirmAttributeCompleteStep', target: '#signUpActor.resolved' },\n ],\n onError: { actions: 'setConfirmAttributeCompleteStep', target: '#signUpActor.resolved' },\n },\n },\n federatedSignIn: {\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'signInWithRedirect',\n input: ({ event }) => event.data as SignInWithRedirectInput,\n onDone: 'signUp',\n onError: { actions: 'setRemoteError', target: '#signUpActor.signUp' },\n },\n },\n resetPassword: {\n invoke: {\n src: 'resetPassword',\n input: ({ event }) => event.data as ResetPasswordInput,\n onDone: { actions: 'setCodeDeliveryDetails', target: '#signUpActor.resolved' },\n onError: { actions: 'setRemoteError' },\n },\n },\n resendSignUpCode: {\n tags: 'pending',\n entry: 'sendUpdate',\n exit: 'sendUpdate',\n invoke: {\n src: 'resendSignUpCode',\n input: ({ context: { username }, event }) => ({ username, ...event.data }) as ResendSignUpCodeInput,\n onDone: { actions: 'setCodeDeliveryDetails', target: '#signUpActor.confirmSignUp' },\n onError: [{ guard: 'isUserAlreadyConfirmed', target: '#signUpActor.resolved' }, { actions: 'setRemoteError' }],\n },\n },\n signUp: {\n initial: 'idle',\n exit: 'clearError',\n on: {\n FEDERATED_SIGN_IN: { target: '#signUpActor.federatedSignIn' },\n },\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'setUsername', 'clearError'],\n invoke: {\n src: 'signUp',\n input: ({ event }) => event.data as SignUpInput,\n onDone: [\n { guard: 'hasCompletedSignUp', actions: 'setNextSignUpStep', target: '#signUpActor.resolved' },\n { guard: 'shouldAutoSignIn', actions: 'setNextSignUpStep', target: '#signUpActor.autoSignIn' },\n { actions: ['setCodeDeliveryDetails', 'setNextSignUpStep'], target: '#signUpActor.init' },\n ],\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n confirmSignUp: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n RESEND: { target: '#signUpActor.resendSignUpCode' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmSignUp',\n input: ({ context: { username }, event }) => ({ username, ...event.data }) as ConfirmSignUpInput,\n onDone: [\n { guard: 'shouldAutoSignIn', actions: 'setNextSignUpStep', target: '#signUpActor.autoSignIn' },\n { guard: 'shouldManualSignIn', actions: 'setSignInStep', target: '#signUpActor.resolved' },\n { actions: 'setNextSignUpStep', target: '#signUpActor.init' },\n ],\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n resolved: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;;;AA2CA,IAAa,eAAe,UAA0B,qBAAqC;AACzF,QAAO,MAAM;EACX,OAAO;GACL,SAAS,EAAE;GACX,QAAQ,EAAE;GACX;EACD,QAAQ;GACN,qBAAqB,EAAE,YAAY,mBAAmB,MAAM;GAC5D,qBAAqB,EAAE,YAAY,mBAAmB,MAAM;GAC5D,yBAAyB,EAAE,YAAY,uBAAuB,MAAM;GACpE,mBAAmB,EAAE,YAAY,iBAAiB,MAAM;GACxD,qBAAqB,EAAE,SAAS,YAAY,mBAAmB,SAAS,MAAM;GAC9E,qCAAqC,EAAE,YAAY,mCAAmC,MAAM;GAC5F,sBAAsB,EAAE,SAAS,EAAE,aAAa,SAAS;GACzD,gCAAgC,EAAE,YAAY,8BAA8B,MAAM;GAClF,gCAAgC,EAAE,YAAY,8BAA8B,MAAM;GAClF,wBAAwB,EAAE,YAAY,sBAAsB,MAAM;GACnE;EACD,QAAQ;GACN,YAAY,kBAAkB,SAAS,YAAY,CAAC;GACpD,eAAe,aAAsD,EAAE,YAAY,SAAS,cAAc,MAAM,CAAC;GACjH,qBAAqB,kBAAkB,SAAS,qBAAqB,CAAC;GACtE,eAAe,aAAsD,EAAE,YAAY,SAAS,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ACN,KAAK;OACL,QAAQ,EAAE,YAAY,MAAM;OAC5B,QAAQ;QACN;SAAE,OAAO;SAAsB,SAAS;SAAqB,QAAQ;SAAyB;QAC9F;SAAE,OAAO;SAAoB,SAAS;SAAqB,QAAQ;SAA2B;QAC9F;SAAE,SAAS,CAAC,0BAA0B,oBAAoB;SAAE,QAAQ;SAAqB;QAC1F;OACD,SAAS;QAAE,SAAS;QAAkB,QAAQ;QAAQ;OACvD;MACF;KACF;IACF;GACD,eAAe;IACb,SAAS;IACT,MAAM;IACN,QAAQ;KACN,MAAM;MACJ,OAAO;MACP,IAAI;OACF,QAAQ,EAAE,QAAQ,UAAU;OAC5B,QAAQ,EAAE,QAAQ,iCAAiC;OACpD;MACF;KACD,QAAQ;MACN,MAAM;MACN,OAAO,CAAC,cAAc,aAAa;MACnC,QAAQ;OACN,KAAK;OACL,QAAQ,EAAE,SAAS,EAAE,YAAY,aAAa;QAAE;QAAU,GAAG,MAAM;QAAM;OACzE,QAAQ;QACN;SAAE,OAAO;SAAoB,SAAS;SAAqB,QAAQ;SAA2B;QAC9F;SAAE,OAAO;SAAsB,SAAS;SAAiB,QAAQ;SAAyB;QAC1F;SAAE,SAAS;SAAqB,QAAQ;SAAqB;QAC9D;OACD,SAAS;QAAE,SAAS;QAAkB,QAAQ;QAAQ;OACvD;MACF;KACF;IACF;GACD,UAAU,EAAE,MAAM,SAAS;GAC5B;EACD,SAAS,EAAE,cAAc;EAC1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"actor.js","names":[],"sources":["../../../src/machines/signUp/actor.ts"],"sourcesContent":["import type {\n ConfirmSignUpInput,\n ConfirmSignUpOutput,\n ResendSignUpCodeInput,\n ResendSignUpCodeOutput,\n ResetPasswordInput,\n ResetPasswordOutput,\n SignInWithRedirectInput,\n SignUpInput,\n SignUpOutput,\n} from '@aws-amplify/auth'\nimport { assign, fromPromise, sendParent, setup } from 'xstate'\nimport {\n setAllowedMfaTypes,\n setCodeDeliveryDetails,\n setNextSignInStep,\n setNextSignUpStep,\n setRemoteError,\n setTotpSecretCode,\n setUnverifiedUserAttributes,\n setUsername,\n} from '~/machines/actions.js'\nimport {\n hasCompletedSignIn,\n hasCompletedSignUp,\n isUserAlreadyConfirmed,\n shouldAutoSignIn,\n shouldConfirmSignInWithNewPassword,\n shouldConfirmSignUpFromSignIn,\n shouldManualSignIn,\n shouldResetPasswordFromSignIn,\n shouldVerifyAttribute,\n} from '~/machines/guards.js'\nimport type { AuthEvent, Handlers, SignUpContext } from '~/types/machines.js'\n\ntype SignUpHandlers = Pick<\n Handlers,\n 'autoSignIn' | 'confirmSignUp' | 'signInWithRedirect' | 'signUp' | 'resetPassword' | 'resendSignUpCode' | 'fetchUserAttributes'\n>\n\n/**\n * @internal\n */\nexport const signUpActor = (handlers: SignUpHandlers, overridesContext?: SignUpContext) => {\n return setup({\n types: {\n context: {} as SignUpContext,\n events: {} as AuthEvent,\n },\n guards: {\n hasCompletedSignIn: ({ event }) => hasCompletedSignIn(event),\n hasCompletedSignUp: ({ event }) => hasCompletedSignUp(event),\n isUserAlreadyConfirmed: ({ event }) => isUserAlreadyConfirmed(event),\n shouldAutoSignIn: ({ event }) => shouldAutoSignIn(event),\n shouldManualSignIn: ({ context, event }) => shouldManualSignIn(context, event),\n shouldConfirmSignInWithNewPassword: ({ event }) => shouldConfirmSignInWithNewPassword(event),\n shouldConfirmSignUp: ({ context: { step } }) => step === 'CONFIRM_SIGN_UP',\n shouldConfirmSignUpFromSignIn: ({ event }) => shouldConfirmSignUpFromSignIn(event),\n shouldResetPasswordFromSignIn: ({ event }) => shouldResetPasswordFromSignIn(event),\n shouldVerifyAttribute: ({ event }) => shouldVerifyAttribute(event),\n },\n actors: {\n autoSignIn: fromPromise(() => handlers.autoSignIn()),\n confirmSignUp: fromPromise<ConfirmSignUpOutput, ConfirmSignUpInput>(({ input }) => handlers.confirmSignUp(input)),\n fetchUserAttributes: fromPromise(() => handlers.fetchUserAttributes()),\n resetPassword: fromPromise<ResetPasswordOutput, ResetPasswordInput>(({ input }) => handlers.resetPassword(input)),\n resendSignUpCode: fromPromise<ResendSignUpCodeOutput, ResendSignUpCodeInput>(({ input }) => handlers.resendSignUpCode(input)),\n signUp: fromPromise<SignUpOutput, SignUpInput>(({ input }) => handlers.signUp(input)),\n signInWithRedirect: fromPromise<void, SignInWithRedirectInput>(({ input }) => handlers.signInWithRedirect(input)),\n },\n actions: {\n sendUpdate: sendParent({ type: 'CHILD_CHANGED' }),\n setShouldVerifyUserAttributeStep: assign({ step: 'SHOULD_CONFIRM_USER_ATTRIBUTE', unverifiedUserAttributes: setUnverifiedUserAttributes }),\n setConfirmAttributeCompleteStep: assign({ step: 'CONFIRM_ATTRIBUTE_COMPLETE' }),\n setSignInStep: assign({ step: 'SIGN_IN' }),\n setNextSignUpStep: assign({ step: setNextSignUpStep }),\n setNextSignInStep: assign({ step: setNextSignInStep }),\n setCodeDeliveryDetails: assign({ codeDeliveryDetails: setCodeDeliveryDetails }),\n setTotpSecretCode: assign({ totpSecretCode: setTotpSecretCode }),\n setAllowedMfaTypes: assign({ allowedMfaTypes: setAllowedMfaTypes }),\n setUsername: assign({ username: setUsername }),\n setRemoteError: assign({ remoteError: setRemoteError }),\n clearError: assign({ remoteError: undefined }),\n },\n }).createMachine({\n id: 'signUpActor',\n initial: 'init',\n context: ({ input }) => ({ step: 'SIGN_UP', ...overridesContext, ...input }),\n states: {\n init: {\n always: [{ guard: 'shouldConfirmSignUp', target: 'confirmSignUp' }, { target: '#signUpActor.signUp' }],\n },\n autoSignIn: {\n tags: 'pending',\n invoke: {\n src: 'autoSignIn',\n onDone: [\n { guard: 'hasCompletedSignIn', actions: 'setNextSignInStep', target: '#signUpActor.fetchUserAttributes' },\n { guard: 'shouldConfirmSignInWithNewPassword', actions: 'setNextSignInStep', target: '#signUpActor.resolved' },\n { guard: 'shouldResetPasswordFromSignIn', actions: 'setNextSignInStep', target: '#signUpActor.resetPassword' },\n { guard: 'shouldConfirmSignUpFromSignIn', actions: 'setNextSignInStep', target: '#signUpActor.resendSignUpCode' },\n { actions: ['setNextSignInStep', 'setTotpSecretCode', 'setAllowedMfaTypes'], target: '#signUpActor.resolved' },\n ],\n onError: { target: '#signUpActor.resolved' },\n },\n },\n fetchUserAttributes: {\n invoke: {\n src: 'fetchUserAttributes',\n onDone: [\n {\n guard: 'shouldVerifyAttribute',\n actions: 'setShouldVerifyUserAttributeStep',\n target: '#signUpActor.resolved',\n },\n { actions: 'setConfirmAttributeCompleteStep', target: '#signUpActor.resolved' },\n ],\n onError: { actions: 'setConfirmAttributeCompleteStep', target: '#signUpActor.resolved' },\n },\n },\n federatedSignIn: {\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'signInWithRedirect',\n input: ({ event }) => event.data as SignInWithRedirectInput,\n onDone: 'signUp',\n onError: { actions: 'setRemoteError', target: '#signUpActor.signUp' },\n },\n },\n resetPassword: {\n invoke: {\n src: 'resetPassword',\n input: ({ event }) => event.data as ResetPasswordInput,\n onDone: { actions: 'setCodeDeliveryDetails', target: '#signUpActor.resolved' },\n onError: { actions: 'setRemoteError' },\n },\n },\n resendSignUpCode: {\n tags: 'pending',\n entry: 'sendUpdate',\n exit: 'sendUpdate',\n invoke: {\n src: 'resendSignUpCode',\n input: ({ context: { username }, event }) => ({ username, ...event.data }) as ResendSignUpCodeInput,\n onDone: { actions: 'setCodeDeliveryDetails', target: '#signUpActor.confirmSignUp' },\n onError: [{ guard: 'isUserAlreadyConfirmed', target: '#signUpActor.resolved' }, { actions: 'setRemoteError' }],\n },\n },\n signUp: {\n initial: 'idle',\n exit: 'clearError',\n on: {\n FEDERATED_SIGN_IN: { target: '#signUpActor.federatedSignIn' },\n },\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'setUsername', 'clearError'],\n invoke: {\n src: 'signUp',\n input: ({ event }) => event.data as SignUpInput,\n onDone: [\n { guard: 'hasCompletedSignUp', actions: 'setNextSignUpStep', target: '#signUpActor.resolved' },\n { guard: 'shouldAutoSignIn', actions: 'setNextSignUpStep', target: '#signUpActor.autoSignIn' },\n { actions: ['setCodeDeliveryDetails', 'setNextSignUpStep'], target: '#signUpActor.init' },\n ],\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n confirmSignUp: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n RESEND: { target: '#signUpActor.resendSignUpCode' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmSignUp',\n input: ({ context: { username }, event }) => ({ username, ...event.data }) as ConfirmSignUpInput,\n onDone: [\n { guard: 'shouldAutoSignIn', actions: 'setNextSignUpStep', target: '#signUpActor.autoSignIn' },\n { guard: 'shouldManualSignIn', actions: 'setSignInStep', target: '#signUpActor.resolved' },\n { actions: 'setNextSignUpStep', target: '#signUpActor.init' },\n ],\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n resolved: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;;;AA2CA,IAAa,eAAe,UAA0B,qBAAqC;CACzF,OAAO,MAAM;EACX,OAAO;GACL,SAAS,CAAC;GACV,QAAQ,CAAC;EACX;EACA,QAAQ;GACN,qBAAqB,EAAE,YAAY,mBAAmB,KAAK;GAC3D,qBAAqB,EAAE,YAAY,mBAAmB,KAAK;GAC3D,yBAAyB,EAAE,YAAY,uBAAuB,KAAK;GACnE,mBAAmB,EAAE,YAAY,iBAAiB,KAAK;GACvD,qBAAqB,EAAE,SAAS,YAAY,mBAAmB,SAAS,KAAK;GAC7E,qCAAqC,EAAE,YAAY,mCAAmC,KAAK;GAC3F,sBAAsB,EAAE,SAAS,EAAE,aAAa,SAAS;GACzD,gCAAgC,EAAE,YAAY,8BAA8B,KAAK;GACjF,gCAAgC,EAAE,YAAY,8BAA8B,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ts"],"sourcesContent":["import type { ConfirmUserAttributeInput, SendUserAttributeVerificationCodeInput, SendUserAttributeVerificationCodeOutput } from '@aws-amplify/auth'\nimport { assign, fromPromise, sendParent, setup } from 'xstate'\nimport { setCodeDeliveryDetails, setRemoteError, setSelectedUserAttribute } from '~/machines/actions.js'\nimport type { AuthEvent, Handlers, VerifyUserContext } from '~/types/machines.js'\n\ntype VerifyUserAttributesHandlers = Pick<Handlers, 'sendUserAttributeVerificationCode' | 'confirmUserAttribute'>\n\n/**\n * @internal\n */\nexport const verifyUserAttributesActor = (handlers: VerifyUserAttributesHandlers, overridesContext?: VerifyUserContext) => {\n return setup({\n types: {\n context: {} as VerifyUserContext,\n events: {} as AuthEvent,\n },\n guards: {},\n actors: {\n sendUserAttributeVerificationCode: fromPromise<SendUserAttributeVerificationCodeOutput, SendUserAttributeVerificationCodeInput>(({ input }) =>\n handlers.sendUserAttributeVerificationCode(input),\n ),\n confirmVerifyUserAttribute: fromPromise<void, ConfirmUserAttributeInput>(({ input }) => handlers.confirmUserAttribute(input)),\n },\n actions: {\n sendUpdate: sendParent({ type: 'CHILD_CHANGED' }),\n setConfirmAttributeCompleteStep: assign({ step: 'CONFIRM_ATTRIBUTE_COMPLETE' }),\n setCodeDeliveryDetails: assign({ codeDeliveryDetails: setCodeDeliveryDetails }),\n setSelectedUserAttribute: assign({ selectedUserAttribute: setSelectedUserAttribute }),\n clearSelectedUserAttribute: assign({ selectedUserAttribute: undefined }),\n setRemoteError: assign({ remoteError: setRemoteError }),\n clearError: assign({ remoteError: undefined }),\n },\n }).createMachine({\n id: 'vefiryUserAttributesActor',\n initial: 'selectUserAttributes',\n context: ({ input }) => ({ step: 'SIGN_IN', ...overridesContext, ...input }),\n states: {\n selectUserAttributes: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SKIP: { target: '#vefiryUserAttributesActor.resolved' },\n SUBMIT: { target: 'submit' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'sendUserAttributeVerificationCode',\n input: ({ event }) => event.data as SendUserAttributeVerificationCodeInput,\n onDone: {\n actions: ['setSelectedUserAttribute', 'setCodeDeliveryDetails'],\n target: '#vefiryUserAttributesActor.confirmVerifyUserAttribute',\n },\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n confirmVerifyUserAttribute: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n RESEND: { target: 'resendCode' },\n SKIP: { target: '#vefiryUserAttributesActor.resolved' },\n },\n },\n resendCode: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'sendUserAttributeVerificationCode',\n input: ({ context, event }) =>\n ({ userAttributeKey: context.selectedUserAttribute, ...event.data }) as SendUserAttributeVerificationCodeInput,\n onDone: { target: 'idle' },\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmVerifyUserAttribute',\n input: ({ context, event }) => ({ userAttributeKey: context.selectedUserAttribute, ...event.data }) as ConfirmUserAttributeInput,\n onDone: { actions: ['setConfirmAttributeCompleteStep', 'clearSelectedUserAttribute'], target: '#vefiryUserAttributesActor.resolved' },\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n resolved: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;;AAUA,IAAa,6BAA6B,UAAwC,qBAAyC;
|
|
1
|
+
{"version":3,"file":"actor.js","names":[],"sources":["../../../src/machines/verifyUserAttributes/actor.ts"],"sourcesContent":["import type { ConfirmUserAttributeInput, SendUserAttributeVerificationCodeInput, SendUserAttributeVerificationCodeOutput } from '@aws-amplify/auth'\nimport { assign, fromPromise, sendParent, setup } from 'xstate'\nimport { setCodeDeliveryDetails, setRemoteError, setSelectedUserAttribute } from '~/machines/actions.js'\nimport type { AuthEvent, Handlers, VerifyUserContext } from '~/types/machines.js'\n\ntype VerifyUserAttributesHandlers = Pick<Handlers, 'sendUserAttributeVerificationCode' | 'confirmUserAttribute'>\n\n/**\n * @internal\n */\nexport const verifyUserAttributesActor = (handlers: VerifyUserAttributesHandlers, overridesContext?: VerifyUserContext) => {\n return setup({\n types: {\n context: {} as VerifyUserContext,\n events: {} as AuthEvent,\n },\n guards: {},\n actors: {\n sendUserAttributeVerificationCode: fromPromise<SendUserAttributeVerificationCodeOutput, SendUserAttributeVerificationCodeInput>(({ input }) =>\n handlers.sendUserAttributeVerificationCode(input),\n ),\n confirmVerifyUserAttribute: fromPromise<void, ConfirmUserAttributeInput>(({ input }) => handlers.confirmUserAttribute(input)),\n },\n actions: {\n sendUpdate: sendParent({ type: 'CHILD_CHANGED' }),\n setConfirmAttributeCompleteStep: assign({ step: 'CONFIRM_ATTRIBUTE_COMPLETE' }),\n setCodeDeliveryDetails: assign({ codeDeliveryDetails: setCodeDeliveryDetails }),\n setSelectedUserAttribute: assign({ selectedUserAttribute: setSelectedUserAttribute }),\n clearSelectedUserAttribute: assign({ selectedUserAttribute: undefined }),\n setRemoteError: assign({ remoteError: setRemoteError }),\n clearError: assign({ remoteError: undefined }),\n },\n }).createMachine({\n id: 'vefiryUserAttributesActor',\n initial: 'selectUserAttributes',\n context: ({ input }) => ({ step: 'SIGN_IN', ...overridesContext, ...input }),\n states: {\n selectUserAttributes: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SKIP: { target: '#vefiryUserAttributesActor.resolved' },\n SUBMIT: { target: 'submit' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'sendUserAttributeVerificationCode',\n input: ({ event }) => event.data as SendUserAttributeVerificationCodeInput,\n onDone: {\n actions: ['setSelectedUserAttribute', 'setCodeDeliveryDetails'],\n target: '#vefiryUserAttributesActor.confirmVerifyUserAttribute',\n },\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n confirmVerifyUserAttribute: {\n initial: 'idle',\n exit: 'clearError',\n states: {\n idle: {\n entry: 'sendUpdate',\n on: {\n SUBMIT: { target: 'submit' },\n RESEND: { target: 'resendCode' },\n SKIP: { target: '#vefiryUserAttributesActor.resolved' },\n },\n },\n resendCode: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'sendUserAttributeVerificationCode',\n input: ({ context, event }) =>\n ({ userAttributeKey: context.selectedUserAttribute, ...event.data }) as SendUserAttributeVerificationCodeInput,\n onDone: { target: 'idle' },\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n submit: {\n tags: 'pending',\n entry: ['sendUpdate', 'clearError'],\n invoke: {\n src: 'confirmVerifyUserAttribute',\n input: ({ context, event }) => ({ userAttributeKey: context.selectedUserAttribute, ...event.data }) as ConfirmUserAttributeInput,\n onDone: { actions: ['setConfirmAttributeCompleteStep', 'clearSelectedUserAttribute'], target: '#vefiryUserAttributesActor.resolved' },\n onError: { actions: 'setRemoteError', target: 'idle' },\n },\n },\n },\n },\n resolved: { type: 'final' },\n },\n output: ({ context }) => context,\n })\n}\n"],"mappings":";;;AAUA,IAAa,6BAA6B,UAAwC,qBAAyC;CACzH,OAAO,MAAM;EACX,OAAO;GACL,SAAS,CAAC;GACV,QAAQ,CAAC;EACX;EACA,QAAQ,CAAC;EACT,QAAQ;GACN,mCAAmC,aAA8F,EAAE,YACjI,SAAS,kCAAkC,KAAK,CAClD;GACA,4BAA4B,aAA8C,EAAE,YAAY,SAAS,qBAAqB,KAAK,CAAC;EAC9H;EACA,SAAS;GACP,YAAY,WAAW,EAAE,MAAM,gBAAgB,CAAC;GAChD,iCAAiC,OAAO,EAAE,MAAM,6BAA6B,CAAC;GAC9E,wBAAwB,OAAO,EAAE,qBAAqB,uBAAuB,CAAC;GAC9E,0BAA0B,OAAO,EAAE,uBAAuB,yBAAyB,CAAC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AQ;QAAuB,GAAG,MAAM;OAAK;OACjG,QAAQ;QAAE,SAAS,CAAC,mCAAmC,4BAA4B;QAAG,QAAQ;OAAsC;OACpI,SAAS;QAAE,SAAS;QAAkB,QAAQ;OAAO;MACvD;KACF;IACF;GACF;GACA,UAAU,EAAE,MAAM,QAAQ;EAC5B;EACA,SAAS,EAAE,cAAc;CAC3B,CAAC;AACH"}
|
package/dist/machines.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machines.js","names":[],"sources":["../src/machines/index.ts"],"sourcesContent":["import type { AuthUser } from '@aws-amplify/auth'\nimport { assign, forwardTo, fromPromise, setup } from 'xstate'\nimport { signInActor } from '~/machines/signIn/actor.js'\nimport type { AuthMachineHubHandlerOptions } from '~/types/authenticator.js'\nimport type { ActorDoneData, AuthContext, AuthEvent, Handlers } from '~/types/machines.js'\nimport { defaultHandlers } from './defaultHandlers.js'\nimport { forgotPasswordActor } from './forgotPassword/actor.js'\nimport {\n hasCompletedAttributeConfirmation,\n isConfirmSignUpStep,\n isConfirmUserAttributeStep,\n isResetPasswordStep,\n isShouldConfirmUserAttributeStep,\n} from './guards.js'\nimport { signOutActor } from './signOut/actor.js'\nimport { signUpActor } from './signUp/actor.js'\nimport { verifyUserAttributesActor } from './verifyUserAttributes/actor.js'\n\nexport type AuthenticatorMachineOptions = AuthContext['config'] & {\n handlers?: Partial<Handlers>\n} & AuthMachineHubHandlerOptions\n\n/**\n * @internal\n */\nexport const createAuthenticatorMachine = (options?: AuthenticatorMachineOptions) => {\n const { handlers: customHandlers, ...config } = options ?? {}\n const handlers = { ...defaultHandlers, ...customHandlers }\n\n return setup({\n types: {\n context: {} as AuthContext,\n events: {} as AuthEvent,\n },\n guards: {\n hasCompletedAttributeConfirmation: ({ event: { output } }) => hasCompletedAttributeConfirmation(output?.step),\n hasUser: ({ context }) => !!context.user,\n isInitialStateSignUp: ({ context }) => context.config?.initialState === 'signUp',\n isInitialStateResetPassword: ({ context }) => context.config?.initialState === 'forgotPassword',\n isConfirmSignUpStep: ({ event: { output } }) => isConfirmSignUpStep(output?.step),\n isConfirmUserAttributeStep: ({ event: { output } }) => isConfirmUserAttributeStep(output?.step),\n isShouldConfirmUserAttributeStep: ({ event: { output } }) => isShouldConfirmUserAttributeStep(output?.step),\n isResetPasswordStep: ({ event: { output } }) => isResetPasswordStep(output?.step),\n },\n actors: {\n getCurrentUser: fromPromise(() => handlers.getCurrentUser()),\n invokeSignInActor: signInActor(handlers),\n invokeSignUpActor: signUpActor(handlers),\n invokeForgotPasswordActor: forgotPasswordActor(handlers),\n invokeVerifyUserAttributesActor: verifyUserAttributesActor(handlers),\n invokeSignOutActor: signOutActor(handlers),\n },\n actions: {\n clearActorDoneData: assign({ actorDoneData: undefined }),\n clearUser: assign({ user: undefined }),\n forwardToActor: forwardTo('childActor'),\n setUser: assign({ user: ({ event }) => event.output as AuthUser }),\n setActorDoneData: assign({ actorDoneData: ({ event }) => event.output as ActorDoneData }),\n },\n }).createMachine({\n id: 'authenticator',\n initial: 'idle',\n context: {\n config,\n user: undefined,\n },\n states: {\n idle: {\n invoke: {\n src: 'getCurrentUser',\n onDone: { actions: 'setUser', target: '#authenticator.setup' },\n onError: { target: '#authenticator.setup' },\n },\n },\n setup: {\n initial: 'init',\n states: {\n init: {\n always: [\n { guard: 'hasUser', target: '#authenticator.authenticated' },\n { guard: 'isInitialStateSignUp', target: '#authenticator.signUpActor' },\n { guard: 'isInitialStateResetPassword', target: '#authenticator.forgotPasswordActor' },\n { target: '#authenticator.signInActor' },\n ],\n },\n },\n },\n getCurrentUser: {\n invoke: {\n src: 'getCurrentUser',\n onDone: { actions: 'setUser', target: '#authenticator.authenticated' },\n onError: { target: 'setup' },\n },\n },\n signInActor: {\n invoke: {\n id: 'childActor',\n src: 'invokeSignInActor',\n input: ({ context }) => context.actorDoneData,\n onDone: [\n { guard: 'hasCompletedAttributeConfirmation', target: '#authenticator.getCurrentUser' },\n { guard: 'isShouldConfirmUserAttributeStep', actions: 'setActorDoneData', target: '#authenticator.verifyUserAttributesActor' },\n { guard: 'isResetPasswordStep', actions: 'setActorDoneData', target: '#authenticator.forgotPasswordActor' },\n { guard: 'isConfirmSignUpStep', actions: 'setActorDoneData', target: '#authenticator.signUpActor' },\n ],\n },\n entry: 'clearActorDoneData',\n on: {\n FORGOT_PASSWORD: { target: '#authenticator.forgotPasswordActor' },\n SIGN_UP: { target: '#authenticator.signUpActor' },\n SIGN_IN: { actions: 'forwardToActor' },\n FEDERATED_SIGN_IN: { actions: 'forwardToActor' },\n SUBMIT: { actions: 'forwardToActor' },\n },\n },\n signUpActor: {\n invoke: {\n id: 'childActor',\n src: 'invokeSignUpActor',\n input: ({ context }) => context.actorDoneData,\n onDone: [\n { guard: 'hasCompletedAttributeConfirmation', actions: 'clearActorDoneData', target: '#authenticator.getCurrentUser' },\n { guard: 'isShouldConfirmUserAttributeStep', actions: 'setActorDoneData', target: '#authenticator.verifyUserAttributesActor' },\n { guard: 'isConfirmUserAttributeStep', actions: 'clearActorDoneData', target: '#authenticator.verifyUserAttributesActor' },\n { actions: 'setActorDoneData', target: '#authenticator.signInActor' },\n ],\n },\n on: {\n SIGN_IN: { target: '#authenticator.signInActor' },\n FEDERATED_SIGN_IN: { actions: 'forwardToActor' },\n RESEND: { actions: 'forwardToActor' },\n SUBMIT: { actions: 'forwardToActor' },\n },\n },\n forgotPasswordActor: {\n invoke: {\n id: 'childActor',\n src: 'invokeForgotPasswordActor',\n input: ({ context }) => context.actorDoneData,\n onDone: { target: '#authenticator.signInActor' },\n },\n exit: 'clearActorDoneData',\n on: {\n SIGN_IN: { target: '#authenticator.signInActor' },\n RESEND: { actions: 'forwardToActor' },\n SUBMIT: { actions: 'forwardToActor' },\n },\n },\n verifyUserAttributesActor: {\n invoke: {\n id: 'childActor',\n src: 'invokeVerifyUserAttributesActor',\n input: ({ context }) => context.actorDoneData,\n onDone: { actions: 'setActorDoneData', target: '#authenticator.getCurrentUser' },\n },\n on: {\n SKIP: { actions: 'forwardToActor' },\n RESEND: { actions: 'forwardToActor' },\n SUBMIT: { actions: 'forwardToActor' },\n },\n },\n authenticated: {\n initial: 'idle',\n on: {\n SIGN_OUT: { target: '#authenticator.signOut' },\n },\n states: {\n idle: {\n on: {\n TOKEN_REFRESH: { target: 'refreshUser' },\n },\n },\n refreshUser: {\n invoke: {\n src: 'getCurrentUser',\n onDone: { actions: 'setUser', target: 'idle' },\n onError: { target: '#authenticator.signOut' },\n },\n },\n },\n },\n signOut: {\n invoke: {\n id: 'childActor',\n src: 'invokeSignOutActor',\n onDone: { actions: 'clearUser', target: '#authenticator.setup' },\n },\n exit: 'clearActorDoneData',\n },\n },\n on: {\n CHILD_CHANGED: { actions: assign(({ context }) => context) },\n SIGN_IN_WITH_REDIRECT: { target: '#authenticator.getCurrentUser' },\n },\n })\n}\nexport type createAuthenticatorMachineReturnType = ReturnType<typeof createAuthenticatorMachine>\n"],"mappings":";;;;;;;;;AAyBA,IAAa,8BAA8B,YAA0C;CACnF,MAAM,EAAE,UAAU,gBAAgB,GAAG,WAAW,WAAW,EAAE;CAC7D,MAAM,WAAW;EAAE,GAAG;EAAiB,GAAG;EAAgB;AAE1D,QAAO,MAAM;EACX,OAAO;GACL,SAAS,EAAE;GACX,QAAQ,EAAE;GACX;EACD,QAAQ;GACN,oCAAoC,EAAE,OAAO,EAAE,eAAe,kCAAkC,QAAQ,KAAK;GAC7G,UAAU,EAAE,cAAc,CAAC,CAAC,QAAQ;GACpC,uBAAuB,EAAE,cAAc,QAAQ,QAAQ,iBAAiB;GACxE,8BAA8B,EAAE,cAAc,QAAQ,QAAQ,iBAAiB;GAC/E,sBAAsB,EAAE,OAAO,EAAE,eAAe,oBAAoB,QAAQ,KAAK;GACjF,6BAA6B,EAAE,OAAO,EAAE,eAAe,2BAA2B,QAAQ,KAAK;GAC/F,mCAAmC,EAAE,OAAO,EAAE,eAAe,iCAAiC,QAAQ,KAAK;GAC3G,sBAAsB,EAAE,OAAO,EAAE,eAAe,oBA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,EAAE,SAAS,kBAAkB;KACrC,QAAQ,EAAE,SAAS,kBAAkB;KACtC;IACF;GACD,eAAe;IACb,SAAS;IACT,IAAI,EACF,UAAU,EAAE,QAAQ,0BAA0B,EAC/C;IACD,QAAQ;KACN,MAAM,EACJ,IAAI,EACF,eAAe,EAAE,QAAQ,eAAe,EACzC,EACF;KACD,aAAa,EACX,QAAQ;MACN,KAAK;MACL,QAAQ;OAAE,SAAS;OAAW,QAAQ;OAAQ;MAC9C,SAAS,EAAE,QAAQ,0BAA0B;MAC9C,EACF;KACF;IACF;GACD,SAAS;IACP,QAAQ;KACN,IAAI;KACJ,KAAK;KACL,QAAQ;MAAE,SAAS;MAAa,QAAQ;MAAwB;KACjE;IACD,MAAM;IACP;GACF;EACD,IAAI;GACF,eAAe,EAAE,SAAS,QAAQ,EAAE,cAAc,QAAQ,EAAE;GAC5D,uBAAuB,EAAE,QAAQ,iCAAiC;GACnE;EACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"machines.js","names":[],"sources":["../src/machines/index.ts"],"sourcesContent":["import type { AuthUser } from '@aws-amplify/auth'\nimport { assign, forwardTo, fromPromise, setup } from 'xstate'\nimport { signInActor } from '~/machines/signIn/actor.js'\nimport type { AuthMachineHubHandlerOptions } from '~/types/authenticator.js'\nimport type { ActorDoneData, AuthContext, AuthEvent, Handlers } from '~/types/machines.js'\nimport { defaultHandlers } from './defaultHandlers.js'\nimport { forgotPasswordActor } from './forgotPassword/actor.js'\nimport {\n hasCompletedAttributeConfirmation,\n isConfirmSignUpStep,\n isConfirmUserAttributeStep,\n isResetPasswordStep,\n isShouldConfirmUserAttributeStep,\n} from './guards.js'\nimport { signOutActor } from './signOut/actor.js'\nimport { signUpActor } from './signUp/actor.js'\nimport { verifyUserAttributesActor } from './verifyUserAttributes/actor.js'\n\nexport type AuthenticatorMachineOptions = AuthContext['config'] & {\n handlers?: Partial<Handlers>\n} & AuthMachineHubHandlerOptions\n\n/**\n * @internal\n */\nexport const createAuthenticatorMachine = (options?: AuthenticatorMachineOptions) => {\n const { handlers: customHandlers, ...config } = options ?? {}\n const handlers = { ...defaultHandlers, ...customHandlers }\n\n return setup({\n types: {\n context: {} as AuthContext,\n events: {} as AuthEvent,\n },\n guards: {\n hasCompletedAttributeConfirmation: ({ event: { output } }) => hasCompletedAttributeConfirmation(output?.step),\n hasUser: ({ context }) => !!context.user,\n isInitialStateSignUp: ({ context }) => context.config?.initialState === 'signUp',\n isInitialStateResetPassword: ({ context }) => context.config?.initialState === 'forgotPassword',\n isConfirmSignUpStep: ({ event: { output } }) => isConfirmSignUpStep(output?.step),\n isConfirmUserAttributeStep: ({ event: { output } }) => isConfirmUserAttributeStep(output?.step),\n isShouldConfirmUserAttributeStep: ({ event: { output } }) => isShouldConfirmUserAttributeStep(output?.step),\n isResetPasswordStep: ({ event: { output } }) => isResetPasswordStep(output?.step),\n },\n actors: {\n getCurrentUser: fromPromise(() => handlers.getCurrentUser()),\n invokeSignInActor: signInActor(handlers),\n invokeSignUpActor: signUpActor(handlers),\n invokeForgotPasswordActor: forgotPasswordActor(handlers),\n invokeVerifyUserAttributesActor: verifyUserAttributesActor(handlers),\n invokeSignOutActor: signOutActor(handlers),\n },\n actions: {\n clearActorDoneData: assign({ actorDoneData: undefined }),\n clearUser: assign({ user: undefined }),\n forwardToActor: forwardTo('childActor'),\n setUser: assign({ user: ({ event }) => event.output as AuthUser }),\n setActorDoneData: assign({ actorDoneData: ({ event }) => event.output as ActorDoneData }),\n },\n }).createMachine({\n id: 'authenticator',\n initial: 'idle',\n context: {\n config,\n user: undefined,\n },\n states: {\n idle: {\n invoke: {\n src: 'getCurrentUser',\n onDone: { actions: 'setUser', target: '#authenticator.setup' },\n onError: { target: '#authenticator.setup' },\n },\n },\n setup: {\n initial: 'init',\n states: {\n init: {\n always: [\n { guard: 'hasUser', target: '#authenticator.authenticated' },\n { guard: 'isInitialStateSignUp', target: '#authenticator.signUpActor' },\n { guard: 'isInitialStateResetPassword', target: '#authenticator.forgotPasswordActor' },\n { target: '#authenticator.signInActor' },\n ],\n },\n },\n },\n getCurrentUser: {\n invoke: {\n src: 'getCurrentUser',\n onDone: { actions: 'setUser', target: '#authenticator.authenticated' },\n onError: { target: 'setup' },\n },\n },\n signInActor: {\n invoke: {\n id: 'childActor',\n src: 'invokeSignInActor',\n input: ({ context }) => context.actorDoneData,\n onDone: [\n { guard: 'hasCompletedAttributeConfirmation', target: '#authenticator.getCurrentUser' },\n { guard: 'isShouldConfirmUserAttributeStep', actions: 'setActorDoneData', target: '#authenticator.verifyUserAttributesActor' },\n { guard: 'isResetPasswordStep', actions: 'setActorDoneData', target: '#authenticator.forgotPasswordActor' },\n { guard: 'isConfirmSignUpStep', actions: 'setActorDoneData', target: '#authenticator.signUpActor' },\n ],\n },\n entry: 'clearActorDoneData',\n on: {\n FORGOT_PASSWORD: { target: '#authenticator.forgotPasswordActor' },\n SIGN_UP: { target: '#authenticator.signUpActor' },\n SIGN_IN: { actions: 'forwardToActor' },\n FEDERATED_SIGN_IN: { actions: 'forwardToActor' },\n SUBMIT: { actions: 'forwardToActor' },\n },\n },\n signUpActor: {\n invoke: {\n id: 'childActor',\n src: 'invokeSignUpActor',\n input: ({ context }) => context.actorDoneData,\n onDone: [\n { guard: 'hasCompletedAttributeConfirmation', actions: 'clearActorDoneData', target: '#authenticator.getCurrentUser' },\n { guard: 'isShouldConfirmUserAttributeStep', actions: 'setActorDoneData', target: '#authenticator.verifyUserAttributesActor' },\n { guard: 'isConfirmUserAttributeStep', actions: 'clearActorDoneData', target: '#authenticator.verifyUserAttributesActor' },\n { actions: 'setActorDoneData', target: '#authenticator.signInActor' },\n ],\n },\n on: {\n SIGN_IN: { target: '#authenticator.signInActor' },\n FEDERATED_SIGN_IN: { actions: 'forwardToActor' },\n RESEND: { actions: 'forwardToActor' },\n SUBMIT: { actions: 'forwardToActor' },\n },\n },\n forgotPasswordActor: {\n invoke: {\n id: 'childActor',\n src: 'invokeForgotPasswordActor',\n input: ({ context }) => context.actorDoneData,\n onDone: { target: '#authenticator.signInActor' },\n },\n exit: 'clearActorDoneData',\n on: {\n SIGN_IN: { target: '#authenticator.signInActor' },\n RESEND: { actions: 'forwardToActor' },\n SUBMIT: { actions: 'forwardToActor' },\n },\n },\n verifyUserAttributesActor: {\n invoke: {\n id: 'childActor',\n src: 'invokeVerifyUserAttributesActor',\n input: ({ context }) => context.actorDoneData,\n onDone: { actions: 'setActorDoneData', target: '#authenticator.getCurrentUser' },\n },\n on: {\n SKIP: { actions: 'forwardToActor' },\n RESEND: { actions: 'forwardToActor' },\n SUBMIT: { actions: 'forwardToActor' },\n },\n },\n authenticated: {\n initial: 'idle',\n on: {\n SIGN_OUT: { target: '#authenticator.signOut' },\n },\n states: {\n idle: {\n on: {\n TOKEN_REFRESH: { target: 'refreshUser' },\n },\n },\n refreshUser: {\n invoke: {\n src: 'getCurrentUser',\n onDone: { actions: 'setUser', target: 'idle' },\n onError: { target: '#authenticator.signOut' },\n },\n },\n },\n },\n signOut: {\n invoke: {\n id: 'childActor',\n src: 'invokeSignOutActor',\n onDone: { actions: 'clearUser', target: '#authenticator.setup' },\n },\n exit: 'clearActorDoneData',\n },\n },\n on: {\n CHILD_CHANGED: { actions: assign(({ context }) => context) },\n SIGN_IN_WITH_REDIRECT: { target: '#authenticator.getCurrentUser' },\n },\n })\n}\nexport type createAuthenticatorMachineReturnType = ReturnType<typeof createAuthenticatorMachine>\n"],"mappings":";;;;;;;;;AAyBA,IAAa,8BAA8B,YAA0C;CACnF,MAAM,EAAE,UAAU,gBAAgB,GAAG,WAAW,WAAW,CAAC;CAC5D,MAAM,WAAW;EAAE,GAAG;EAAiB,GAAG;CAAe;CAEzD,OAAO,MAAM;EACX,OAAO;GACL,SAAS,CAAC;GACV,QAAQ,CAAC;EACX;EACA,QAAQ;GACN,oCAAoC,EAAE,OAAO,EAAE,eAAe,kCAAkC,QAAQ,IAAI;GAC5G,UAAU,EAAE,cAAc,CAAC,CAAC,QAAQ;GACpC,uBAAuB,EAAE,cAAc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,IAAI;KACF,SAAS,EAAE,QAAQ,6BAA6B;KAChD,QAAQ,EAAE,SAAS,iBAAiB;KACpC,QAAQ,EAAE,SAAS,iBAAiB;IACtC;GACF;GACA,2BAA2B;IACzB,QAAQ;KACN,IAAI;KACJ,KAAK;KACL,QAAQ,EAAE,cAAc,QAAQ;KAChC,QAAQ;MAAE,SAAS;MAAoB,QAAQ;KAAgC;IACjF;IACA,IAAI;KACF,MAAM,EAAE,SAAS,iBAAiB;KAClC,QAAQ,EAAE,SAAS,iBAAiB;KACpC,QAAQ,EAAE,SAAS,iBAAiB;IACtC;GACF;GACA,eAAe;IACb,SAAS;IACT,IAAI,EACF,UAAU,EAAE,QAAQ,yBAAyB,EAC/C;IACA,QAAQ;KACN,MAAM,EACJ,IAAI,EACF,eAAe,EAAE,QAAQ,cAAc,EACzC,EACF;KACA,aAAa,EACX,QAAQ;MACN,KAAK;MACL,QAAQ;OAAE,SAAS;OAAW,QAAQ;MAAO;MAC7C,SAAS,EAAE,QAAQ,yBAAyB;KAC9C,EACF;IACF;GACF;GACA,SAAS;IACP,QAAQ;KACN,IAAI;KACJ,KAAK;KACL,QAAQ;MAAE,SAAS;MAAa,QAAQ;KAAuB;IACjE;IACA,MAAM;GACR;EACF;EACA,IAAI;GACF,eAAe,EAAE,SAAS,QAAQ,EAAE,cAAc,OAAO,EAAE;GAC3D,uBAAuB,EAAE,QAAQ,gCAAgC;EACnE;CACF,CAAC;AACH"}
|
package/dist/types/user.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.js","names":[],"sources":["../../src/types/user.ts"],"sourcesContent":["/** Federated IDPs that Authenticator supports */\nexport const FederatedIdentityProviders = {\n Apple: 'Apple',\n Amazon: 'Amazon',\n Facebook: 'Facebook',\n Google: 'Google',\n} as const\nexport type FederatedIdentityProviders = (typeof FederatedIdentityProviders)[keyof typeof FederatedIdentityProviders]\n\n/**\n * Cognito user contact method types that have not been verified as valid\n */\nexport const UnverifiedContactMethodTypes = ['email', 'phone_number'] as const\nexport type UnverifiedContactMethodType = (typeof UnverifiedContactMethodTypes)[number]\n\nexport type UnverifiedUserAttributes = Partial<Record<UnverifiedContactMethodType, string>>\n"],"mappings":";AACA,IAAa,6BAA6B;CACxC,OAAO;CACP,QAAQ;CACR,UAAU;CACV,QAAQ;
|
|
1
|
+
{"version":3,"file":"user.js","names":[],"sources":["../../src/types/user.ts"],"sourcesContent":["/** Federated IDPs that Authenticator supports */\nexport const FederatedIdentityProviders = {\n Apple: 'Apple',\n Amazon: 'Amazon',\n Facebook: 'Facebook',\n Google: 'Google',\n} as const\nexport type FederatedIdentityProviders = (typeof FederatedIdentityProviders)[keyof typeof FederatedIdentityProviders]\n\n/**\n * Cognito user contact method types that have not been verified as valid\n */\nexport const UnverifiedContactMethodTypes = ['email', 'phone_number'] as const\nexport type UnverifiedContactMethodType = (typeof UnverifiedContactMethodTypes)[number]\n\nexport type UnverifiedUserAttributes = Partial<Record<UnverifiedContactMethodType, string>>\n"],"mappings":";AACA,IAAa,6BAA6B;CACxC,OAAO;CACP,QAAQ;CACR,UAAU;CACV,QAAQ;AACV;AAMA,IAAa,+BAA+B,CAAC,SAAS,cAAc"}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export const getTotpCodeURL = (issuer: string, username: string, secret: string): string => {\n return encodeURI(`otpauth://totp/${issuer}:${username}?secret=${secret}&issuer=${issuer}`)\n}\n"],"mappings":";AAAA,IAAa,kBAAkB,QAAgB,UAAkB,WAA2B;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["export const getTotpCodeURL = (issuer: string, username: string, secret: string): string => {\n return encodeURI(`otpauth://totp/${issuer}:${username}?secret=${secret}&issuer=${issuer}`)\n}\n"],"mappings":";AAAA,IAAa,kBAAkB,QAAgB,UAAkB,WAA2B;CAC1F,OAAO,UAAU,kBAAkB,OAAO,GAAG,SAAS,UAAU,OAAO,UAAU,QAAQ;AAC3F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gahojin-inc/amplify-auth-hooks",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.6.1",
|
|
4
4
|
"description": "Hooks for Amplify Auth",
|
|
5
5
|
"author": "GAHOJIN, Inc.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@aws-amplify/auth": "6.20.0",
|
|
47
|
-
"@aws-amplify/core": "6.16.
|
|
47
|
+
"@aws-amplify/core": "6.16.4",
|
|
48
48
|
"@xstate/react": "6.1.0",
|
|
49
|
-
"xstate": "5.
|
|
49
|
+
"xstate": "5.32.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@testing-library/react": "16.3.2",
|
|
53
53
|
"jsdom": "29.1.1",
|
|
54
|
-
"react": "19.2.
|
|
55
|
-
"react-dom": "19.2.
|
|
54
|
+
"react": "19.2.7",
|
|
55
|
+
"react-dom": "19.2.7"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@aws-amplify/auth": "^6",
|
|
@@ -63,10 +63,9 @@
|
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "vite build",
|
|
66
|
-
"lint": "biome check --write
|
|
67
|
-
"lint:ci": "biome ci
|
|
66
|
+
"lint": "biome check --write",
|
|
67
|
+
"lint:ci": "biome ci",
|
|
68
68
|
"check": "tsc --noEmit",
|
|
69
|
-
"check:packagejson": "attw --pack . --profile esm-only --ignore-rules cjs-resolves-to-esm",
|
|
70
69
|
"test": "vitest --watch",
|
|
71
70
|
"test:unit": "vitest --passWithNoTests --run --coverage",
|
|
72
71
|
"storybook": "storybook dev -h 127.0.0.1 -p 6006"
|