@contember/react-client-tenant 2.0.0-alpha.32 → 2.0.0-alpha.35
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/development/src/components/IdentityProvider.cjs.map +1 -1
- package/dist/development/src/components/IdentityProvider.js.map +1 -1
- package/dist/development/src/components/IdentityState.cjs.map +1 -1
- package/dist/development/src/components/IdentityState.js.map +1 -1
- package/dist/development/src/components/forms/ChangeMyPasswordForm.cjs.map +1 -1
- package/dist/development/src/components/forms/ChangeMyPasswordForm.js.map +1 -1
- package/dist/development/src/components/forms/CreateApiKeyForm.cjs.map +1 -1
- package/dist/development/src/components/forms/CreateApiKeyForm.js.map +1 -1
- package/dist/development/src/components/forms/CreateSessionTokenForm.cjs.map +1 -1
- package/dist/development/src/components/forms/CreateSessionTokenForm.js.map +1 -1
- package/dist/development/src/components/forms/InviteForm.cjs.map +1 -1
- package/dist/development/src/components/forms/InviteForm.js.map +1 -1
- package/dist/development/src/components/forms/LoginForm.cjs.map +1 -1
- package/dist/development/src/components/forms/LoginForm.js.map +1 -1
- package/dist/development/src/components/forms/OtpConfirmForm.cjs.map +1 -1
- package/dist/development/src/components/forms/OtpConfirmForm.js.map +1 -1
- package/dist/development/src/components/forms/OtpPrepareForm.cjs.map +1 -1
- package/dist/development/src/components/forms/OtpPrepareForm.js.map +1 -1
- package/dist/development/src/components/forms/PasswordResetForm.cjs.map +1 -1
- package/dist/development/src/components/forms/PasswordResetForm.js.map +1 -1
- package/dist/development/src/components/forms/PasswordResetRequestForm.cjs.map +1 -1
- package/dist/development/src/components/forms/PasswordResetRequestForm.js.map +1 -1
- package/dist/development/src/components/forms/PasswordlessSignInForm.cjs.map +1 -1
- package/dist/development/src/components/forms/PasswordlessSignInForm.js.map +1 -1
- package/dist/development/src/components/forms/PasswordlessSignInInitForm.cjs.map +1 -1
- package/dist/development/src/components/forms/PasswordlessSignInInitForm.js.map +1 -1
- package/dist/development/src/components/forms/TenantForm.cjs.map +1 -1
- package/dist/development/src/components/forms/TenantForm.js.map +1 -1
- package/dist/development/src/components/forms/UpdateProjectMemberForm.cjs.map +1 -1
- package/dist/development/src/components/forms/UpdateProjectMemberForm.js.map +1 -1
- package/dist/development/src/components/idp/IDP.cjs.map +1 -1
- package/dist/development/src/components/idp/IDP.js.map +1 -1
- package/dist/development/src/components/idp/IDPInitTrigger.cjs.map +1 -1
- package/dist/development/src/components/idp/IDPInitTrigger.js.map +1 -1
- package/dist/development/src/components/idp/IDPState.cjs.map +1 -1
- package/dist/development/src/components/idp/IDPState.js.map +1 -1
- package/dist/development/src/components/triggers/DisableOtpTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/DisableOtpTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/LogoutTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/LogoutTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/RemoveProjectMemberTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/RemoveProjectMemberTrigger.js.map +1 -1
- package/dist/development/src/components/triggers/TenantActionTrigger.cjs.map +1 -1
- package/dist/development/src/components/triggers/TenantActionTrigger.js.map +1 -1
- package/dist/development/src/contexts.cjs.map +1 -1
- package/dist/development/src/hooks/mutations/auth/useSignInMutation.cjs.map +1 -1
- package/dist/development/src/hooks/mutations/idp/useInitSignInIDPMutation.cjs.map +1 -1
- package/dist/development/src/hooks/mutations/idp/useSignInIdpMutation.cjs.map +1 -1
- package/dist/development/src/hooks/mutations/passwordReset/useCreateResetPasswordRequestMutation.cjs.map +1 -1
- package/dist/development/src/hooks/mutations/passwordReset/useResetPasswordMutation.cjs.map +1 -1
- package/dist/development/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.cjs.map +1 -1
- package/dist/development/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.cjs.map +1 -1
- package/dist/development/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.cjs.map +1 -1
- package/dist/development/src/hooks/queries/useProjectMembersQuery.cjs.map +1 -1
- package/dist/development/src/hooks/queries/useProjectMembersQuery.js.map +1 -1
- package/dist/development/src/hooks/queries/useProjectMembershipsQuery.cjs.map +1 -1
- package/dist/development/src/hooks/queries/useProjectMembershipsQuery.js.map +1 -1
- package/dist/development/src/hooks/queries/useProjectRolesDefinitionQuery.cjs.map +1 -1
- package/dist/development/src/hooks/queries/useProjectRolesDefinitionQuery.js.map +1 -1
- package/dist/development/src/hooks/useFetchIdentity.cjs.map +1 -1
- package/dist/development/src/hooks/useFetchIdentity.js.map +1 -1
- package/dist/development/src/hooks/useLogout.cjs.map +1 -1
- package/dist/development/src/hooks/useLogout.js.map +1 -1
- package/dist/development/src/hooks/usePasswordlessOtpActivator.cjs.map +1 -1
- package/dist/development/src/hooks/usePasswordlessOtpActivator.js.map +1 -1
- package/dist/development/src/hooks/useTenantApi.cjs.map +1 -1
- package/dist/development/src/hooks/useTenantApi.js.map +1 -1
- package/dist/development/src/hooks/useTenantMutation.cjs.map +1 -1
- package/dist/development/src/hooks/useTenantMutation.js.map +1 -1
- package/dist/development/src/hooks/useTenantQueryLoader.cjs.map +1 -1
- package/dist/development/src/hooks/useTenantQueryLoader.js.map +1 -1
- package/dist/development/src/internal/hooks/useHandleIDPResponse.cjs.map +1 -1
- package/dist/development/src/internal/hooks/useHandleIDPResponse.js.map +1 -1
- package/dist/development/src/internal/hooks/useIDPAutoInit.cjs.map +1 -1
- package/dist/development/src/internal/hooks/useIDPAutoInit.js.map +1 -1
- package/dist/development/src/internal/hooks/useIDPStateStore.cjs.map +1 -1
- package/dist/development/src/internal/hooks/useIDPStateStore.js.map +1 -1
- package/dist/development/src/internal/hooks/useInitIDPRedirect.cjs.map +1 -1
- package/dist/development/src/internal/hooks/useInitIDPRedirect.js.map +1 -1
- package/dist/development/src/internal/hooks/useLogoutInternal.cjs.map +1 -1
- package/dist/development/src/internal/hooks/useLogoutInternal.js.map +1 -1
- package/dist/development/src/internal/hooks/useRedirectToBacklink.cjs.map +1 -1
- package/dist/development/src/internal/hooks/useRedirectToBacklink.js.map +1 -1
- package/dist/development/src/internal/utils/randomInt.cjs.map +1 -1
- package/dist/development/src/internal/utils/randomInt.js.map +1 -1
- package/dist/production/src/components/IdentityProvider.cjs.map +1 -1
- package/dist/production/src/components/IdentityProvider.js.map +1 -1
- package/dist/production/src/components/IdentityState.cjs.map +1 -1
- package/dist/production/src/components/IdentityState.js.map +1 -1
- package/dist/production/src/components/forms/ChangeMyPasswordForm.cjs.map +1 -1
- package/dist/production/src/components/forms/ChangeMyPasswordForm.js.map +1 -1
- package/dist/production/src/components/forms/CreateApiKeyForm.cjs.map +1 -1
- package/dist/production/src/components/forms/CreateApiKeyForm.js.map +1 -1
- package/dist/production/src/components/forms/CreateSessionTokenForm.cjs.map +1 -1
- package/dist/production/src/components/forms/CreateSessionTokenForm.js.map +1 -1
- package/dist/production/src/components/forms/InviteForm.cjs.map +1 -1
- package/dist/production/src/components/forms/InviteForm.js.map +1 -1
- package/dist/production/src/components/forms/LoginForm.cjs.map +1 -1
- package/dist/production/src/components/forms/LoginForm.js.map +1 -1
- package/dist/production/src/components/forms/OtpConfirmForm.cjs.map +1 -1
- package/dist/production/src/components/forms/OtpConfirmForm.js.map +1 -1
- package/dist/production/src/components/forms/OtpPrepareForm.cjs.map +1 -1
- package/dist/production/src/components/forms/OtpPrepareForm.js.map +1 -1
- package/dist/production/src/components/forms/PasswordResetForm.cjs.map +1 -1
- package/dist/production/src/components/forms/PasswordResetForm.js.map +1 -1
- package/dist/production/src/components/forms/PasswordResetRequestForm.cjs.map +1 -1
- package/dist/production/src/components/forms/PasswordResetRequestForm.js.map +1 -1
- package/dist/production/src/components/forms/PasswordlessSignInForm.cjs.map +1 -1
- package/dist/production/src/components/forms/PasswordlessSignInForm.js.map +1 -1
- package/dist/production/src/components/forms/PasswordlessSignInInitForm.cjs.map +1 -1
- package/dist/production/src/components/forms/PasswordlessSignInInitForm.js.map +1 -1
- package/dist/production/src/components/forms/TenantForm.cjs.map +1 -1
- package/dist/production/src/components/forms/TenantForm.js.map +1 -1
- package/dist/production/src/components/forms/UpdateProjectMemberForm.cjs.map +1 -1
- package/dist/production/src/components/forms/UpdateProjectMemberForm.js.map +1 -1
- package/dist/production/src/components/idp/IDP.cjs.map +1 -1
- package/dist/production/src/components/idp/IDP.js.map +1 -1
- package/dist/production/src/components/idp/IDPInitTrigger.cjs.map +1 -1
- package/dist/production/src/components/idp/IDPInitTrigger.js.map +1 -1
- package/dist/production/src/components/idp/IDPState.cjs.map +1 -1
- package/dist/production/src/components/idp/IDPState.js.map +1 -1
- package/dist/production/src/components/triggers/DisableOtpTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/DisableOtpTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/LogoutTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/LogoutTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/RemoveProjectMemberTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/RemoveProjectMemberTrigger.js.map +1 -1
- package/dist/production/src/components/triggers/TenantActionTrigger.cjs.map +1 -1
- package/dist/production/src/components/triggers/TenantActionTrigger.js.map +1 -1
- package/dist/production/src/contexts.cjs.map +1 -1
- package/dist/production/src/hooks/mutations/auth/useSignInMutation.cjs.map +1 -1
- package/dist/production/src/hooks/mutations/idp/useInitSignInIDPMutation.cjs.map +1 -1
- package/dist/production/src/hooks/mutations/idp/useSignInIdpMutation.cjs.map +1 -1
- package/dist/production/src/hooks/mutations/passwordReset/useCreateResetPasswordRequestMutation.cjs.map +1 -1
- package/dist/production/src/hooks/mutations/passwordReset/useResetPasswordMutation.cjs.map +1 -1
- package/dist/production/src/hooks/mutations/passwordless/useActivatePasswordlessOtpMutation.cjs.map +1 -1
- package/dist/production/src/hooks/mutations/passwordless/useInitSignInPasswordlessMutation.cjs.map +1 -1
- package/dist/production/src/hooks/mutations/passwordless/useSignInPasswordlessMutation.cjs.map +1 -1
- package/dist/production/src/hooks/queries/useProjectMembersQuery.cjs.map +1 -1
- package/dist/production/src/hooks/queries/useProjectMembersQuery.js.map +1 -1
- package/dist/production/src/hooks/queries/useProjectMembershipsQuery.cjs.map +1 -1
- package/dist/production/src/hooks/queries/useProjectMembershipsQuery.js.map +1 -1
- package/dist/production/src/hooks/queries/useProjectRolesDefinitionQuery.cjs.map +1 -1
- package/dist/production/src/hooks/queries/useProjectRolesDefinitionQuery.js.map +1 -1
- package/dist/production/src/hooks/useFetchIdentity.cjs.map +1 -1
- package/dist/production/src/hooks/useFetchIdentity.js.map +1 -1
- package/dist/production/src/hooks/useLogout.cjs.map +1 -1
- package/dist/production/src/hooks/useLogout.js.map +1 -1
- package/dist/production/src/hooks/usePasswordlessOtpActivator.cjs.map +1 -1
- package/dist/production/src/hooks/usePasswordlessOtpActivator.js.map +1 -1
- package/dist/production/src/hooks/useTenantApi.cjs.map +1 -1
- package/dist/production/src/hooks/useTenantApi.js.map +1 -1
- package/dist/production/src/hooks/useTenantMutation.cjs.map +1 -1
- package/dist/production/src/hooks/useTenantMutation.js.map +1 -1
- package/dist/production/src/hooks/useTenantQueryLoader.cjs.map +1 -1
- package/dist/production/src/hooks/useTenantQueryLoader.js.map +1 -1
- package/dist/production/src/internal/hooks/useHandleIDPResponse.cjs.map +1 -1
- package/dist/production/src/internal/hooks/useHandleIDPResponse.js.map +1 -1
- package/dist/production/src/internal/hooks/useIDPAutoInit.cjs.map +1 -1
- package/dist/production/src/internal/hooks/useIDPAutoInit.js.map +1 -1
- package/dist/production/src/internal/hooks/useIDPStateStore.cjs.map +1 -1
- package/dist/production/src/internal/hooks/useIDPStateStore.js.map +1 -1
- package/dist/production/src/internal/hooks/useInitIDPRedirect.cjs.map +1 -1
- package/dist/production/src/internal/hooks/useInitIDPRedirect.js.map +1 -1
- package/dist/production/src/internal/hooks/useLogoutInternal.cjs.map +1 -1
- package/dist/production/src/internal/hooks/useLogoutInternal.js.map +1 -1
- package/dist/production/src/internal/hooks/useRedirectToBacklink.cjs.map +1 -1
- package/dist/production/src/internal/hooks/useRedirectToBacklink.js.map +1 -1
- package/dist/production/src/internal/utils/randomInt.cjs.map +1 -1
- package/dist/production/src/internal/utils/randomInt.js.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePasswordlessOtpActivator.cjs","sources":["../../../../../packages/react-client-tenant/src/hooks/usePasswordlessOtpActivator.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../consts'\nimport { useActivatePasswordlessOtpMutation } from './mutations'\nimport { randomString } from '../internal/utils/randomInt'\nimport { calculateHash } from '../internal/utils/hashing'\nimport { ActivatePasswordlessOtpErrorCode } from '@contember/graphql-client-tenant'\n\nconst usePasswordlessParams = (): {localStorageRequestId: string | null; urlRequestId: string | null; urlToken: string | null} => {\n\tconst localStorageValue = localStorage.getItem(PASSWORDLESS_REQUEST_STORAGE_KEY) ?? null\n\tconst urlParams = new URLSearchParams(window.location.search)\n\tconst requestId = urlParams.get('request_id')\n\tconst token = urlParams.get('token')\n\n\treturn { localStorageRequestId: localStorageValue, urlRequestId: requestId, urlToken: token }\n}\n\nexport type PasswordlessResponseHandlerState =\n\t| { type: 'empty' }\n\t| { type: 'otp_activating' }\n\t| { type: 'otp_activated'; otp: string }\n\t| { type: 'otp_activation_failed'; error: ActivatePasswordlessOtpErrorCode | 'UNKNOWN_ERROR'}\n\t| { type: 'can_proceed_to_login' }\n\nexport const usePasswordlessOtpActivator = ({ otpLength = 6, otpChars = '0123456789ABCDEF' }: {\n\totpLength?: number\n\totpChars?: string\n} = {}) => {\n\tconst { localStorageRequestId, urlRequestId, urlToken } = usePasswordlessParams()\n\tconst activateOtp = useActivatePasswordlessOtpMutation()\n\n\tconst [state, setState] = useState<PasswordlessResponseHandlerState>(() => {\n\t\tif (urlRequestId && urlToken) {\n\t\t\tif (localStorageRequestId !== urlRequestId) {\n\t\t\t\treturn { type: 'otp_activating' }\n\t\t\t} else {\n\t\t\t\treturn { type: 'can_proceed_to_login' }\n\t\t\t}\n\t\t}\n\t\treturn { type: 'empty' }\n\t})\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (state.type === 'otp_activating') {\n\t\t\t\tconst otpCode = randomString(otpLength, otpChars)\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await activateOtp({\n\t\t\t\t\t\trequestId: urlRequestId!,\n\t\t\t\t\t\ttoken: urlToken!,\n\t\t\t\t\t\totpHash: await calculateHash('SHA-256', otpCode),\n\t\t\t\t\t})\n\t\t\t\t\tif (!result.ok) {\n\t\t\t\t\t\tsetState({ type: 'otp_activation_failed', error: result.error })\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsetState({ type: 'otp_activated', otp: otpCode })\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error(e)\n\t\t\t\t\tsetState({ type: 'otp_activation_failed', error: 'UNKNOWN_ERROR' })\n\t\t\t\t}\n\t\t\t}\n\t\t})()\n\t}, [activateOtp, localStorageRequestId, otpChars, otpLength, state.type, urlRequestId, urlToken])\n\n\treturn state\n}\n"],"names":["PASSWORDLESS_REQUEST_STORAGE_KEY","useActivatePasswordlessOtpMutation","useState","useEffect","randomString","calculateHash"],"mappings":";;;;;;;AAOA,MAAM,wBAAwB,MAAoG;AACjI,QAAM,oBAAoB,aAAa,QAAQA,
|
|
1
|
+
{"version":3,"file":"usePasswordlessOtpActivator.cjs","sources":["../../../../../packages/react-client-tenant/src/hooks/usePasswordlessOtpActivator.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../consts'\nimport { useActivatePasswordlessOtpMutation } from './mutations'\nimport { randomString } from '../internal/utils/randomInt'\nimport { calculateHash } from '../internal/utils/hashing'\nimport { ActivatePasswordlessOtpErrorCode } from '@contember/graphql-client-tenant'\n\nconst usePasswordlessParams = (): {localStorageRequestId: string | null; urlRequestId: string | null; urlToken: string | null} => {\n\tconst localStorageValue = localStorage.getItem(PASSWORDLESS_REQUEST_STORAGE_KEY) ?? null\n\tconst urlParams = new URLSearchParams(window.location.search)\n\tconst requestId = urlParams.get('request_id')\n\tconst token = urlParams.get('token')\n\n\treturn { localStorageRequestId: localStorageValue, urlRequestId: requestId, urlToken: token }\n}\n\nexport type PasswordlessResponseHandlerState =\n\t| { type: 'empty' }\n\t| { type: 'otp_activating' }\n\t| { type: 'otp_activated'; otp: string }\n\t| { type: 'otp_activation_failed'; error: ActivatePasswordlessOtpErrorCode | 'UNKNOWN_ERROR'}\n\t| { type: 'can_proceed_to_login' }\n\nexport const usePasswordlessOtpActivator = ({ otpLength = 6, otpChars = '0123456789ABCDEF' }: {\n\totpLength?: number\n\totpChars?: string\n} = {}) => {\n\tconst { localStorageRequestId, urlRequestId, urlToken } = usePasswordlessParams()\n\tconst activateOtp = useActivatePasswordlessOtpMutation()\n\n\tconst [state, setState] = useState<PasswordlessResponseHandlerState>(() => {\n\t\tif (urlRequestId && urlToken) {\n\t\t\tif (localStorageRequestId !== urlRequestId) {\n\t\t\t\treturn { type: 'otp_activating' }\n\t\t\t} else {\n\t\t\t\treturn { type: 'can_proceed_to_login' }\n\t\t\t}\n\t\t}\n\t\treturn { type: 'empty' }\n\t})\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (state.type === 'otp_activating') {\n\t\t\t\tconst otpCode = randomString(otpLength, otpChars)\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await activateOtp({\n\t\t\t\t\t\trequestId: urlRequestId!,\n\t\t\t\t\t\ttoken: urlToken!,\n\t\t\t\t\t\totpHash: await calculateHash('SHA-256', otpCode),\n\t\t\t\t\t})\n\t\t\t\t\tif (!result.ok) {\n\t\t\t\t\t\tsetState({ type: 'otp_activation_failed', error: result.error })\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsetState({ type: 'otp_activated', otp: otpCode })\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error(e)\n\t\t\t\t\tsetState({ type: 'otp_activation_failed', error: 'UNKNOWN_ERROR' })\n\t\t\t\t}\n\t\t\t}\n\t\t})()\n\t}, [activateOtp, localStorageRequestId, otpChars, otpLength, state.type, urlRequestId, urlToken])\n\n\treturn state\n}\n"],"names":["PASSWORDLESS_REQUEST_STORAGE_KEY","useActivatePasswordlessOtpMutation","useState","useEffect","randomString","calculateHash"],"mappings":";;;;;;;AAOA,MAAM,wBAAwB,MAAoG;AACjI,QAAM,oBAAoB,aAAa,QAAQA,OAAAA,gCAAgC,KAAK;AACpF,QAAM,YAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACtD,QAAA,YAAY,UAAU,IAAI,YAAY;AACtC,QAAA,QAAQ,UAAU,IAAI,OAAO;AAEnC,SAAO,EAAE,uBAAuB,mBAAmB,cAAc,WAAW,UAAU,MAAM;AAC7F;AASa,MAAA,8BAA8B,CAAC,EAAE,YAAY,GAAG,WAAW,mBAGpE,IAAA,OAAO;AACV,QAAM,EAAE,uBAAuB,cAAc,SAAA,IAAa,sBAAsB;AAChF,QAAM,cAAcC,mCAAAA,mCAAmC;AAEvD,QAAM,CAAC,OAAO,QAAQ,IAAIC,eAA2C,MAAM;AAC1E,QAAI,gBAAgB,UAAU;AAC7B,UAAI,0BAA0B,cAAc;AACpC,eAAA,EAAE,MAAM,iBAAiB;AAAA,MAAA,OAC1B;AACC,eAAA,EAAE,MAAM,uBAAuB;AAAA,MAAA;AAAA,IACvC;AAEM,WAAA,EAAE,MAAM,QAAQ;AAAA,EAAA,CACvB;AAEDC,QAAAA,UAAU,MAAM;AACf,KAAC,YAAY;AACR,UAAA,MAAM,SAAS,kBAAkB;AAC9B,cAAA,UAAUC,UAAAA,aAAa,WAAW,QAAQ;AAC5C,YAAA;AACG,gBAAA,SAAS,MAAM,YAAY;AAAA,YAChC,WAAW;AAAA,YACX,OAAO;AAAA,YACP,SAAS,MAAMC,sBAAc,WAAW,OAAO;AAAA,UAAA,CAC/C;AACG,cAAA,CAAC,OAAO,IAAI;AACf,qBAAS,EAAE,MAAM,yBAAyB,OAAO,OAAO,OAAO;AAAA,UAAA,OACzD;AACN,qBAAS,EAAE,MAAM,iBAAiB,KAAK,SAAS;AAAA,UAAA;AAAA,iBAEzC,GAAG;AACX,kBAAQ,MAAM,CAAC;AACf,mBAAS,EAAE,MAAM,yBAAyB,OAAO,iBAAiB;AAAA,QAAA;AAAA,MACnE;AAAA,IACD,GACE;AAAA,EAAA,GACD,CAAC,aAAa,uBAAuB,UAAU,WAAW,MAAM,MAAM,cAAc,QAAQ,CAAC;AAEzF,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePasswordlessOtpActivator.js","sources":["../../../../../packages/react-client-tenant/src/hooks/usePasswordlessOtpActivator.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../consts'\nimport { useActivatePasswordlessOtpMutation } from './mutations'\nimport { randomString } from '../internal/utils/randomInt'\nimport { calculateHash } from '../internal/utils/hashing'\nimport { ActivatePasswordlessOtpErrorCode } from '@contember/graphql-client-tenant'\n\nconst usePasswordlessParams = (): {localStorageRequestId: string | null; urlRequestId: string | null; urlToken: string | null} => {\n\tconst localStorageValue = localStorage.getItem(PASSWORDLESS_REQUEST_STORAGE_KEY) ?? null\n\tconst urlParams = new URLSearchParams(window.location.search)\n\tconst requestId = urlParams.get('request_id')\n\tconst token = urlParams.get('token')\n\n\treturn { localStorageRequestId: localStorageValue, urlRequestId: requestId, urlToken: token }\n}\n\nexport type PasswordlessResponseHandlerState =\n\t| { type: 'empty' }\n\t| { type: 'otp_activating' }\n\t| { type: 'otp_activated'; otp: string }\n\t| { type: 'otp_activation_failed'; error: ActivatePasswordlessOtpErrorCode | 'UNKNOWN_ERROR'}\n\t| { type: 'can_proceed_to_login' }\n\nexport const usePasswordlessOtpActivator = ({ otpLength = 6, otpChars = '0123456789ABCDEF' }: {\n\totpLength?: number\n\totpChars?: string\n} = {}) => {\n\tconst { localStorageRequestId, urlRequestId, urlToken } = usePasswordlessParams()\n\tconst activateOtp = useActivatePasswordlessOtpMutation()\n\n\tconst [state, setState] = useState<PasswordlessResponseHandlerState>(() => {\n\t\tif (urlRequestId && urlToken) {\n\t\t\tif (localStorageRequestId !== urlRequestId) {\n\t\t\t\treturn { type: 'otp_activating' }\n\t\t\t} else {\n\t\t\t\treturn { type: 'can_proceed_to_login' }\n\t\t\t}\n\t\t}\n\t\treturn { type: 'empty' }\n\t})\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (state.type === 'otp_activating') {\n\t\t\t\tconst otpCode = randomString(otpLength, otpChars)\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await activateOtp({\n\t\t\t\t\t\trequestId: urlRequestId!,\n\t\t\t\t\t\ttoken: urlToken!,\n\t\t\t\t\t\totpHash: await calculateHash('SHA-256', otpCode),\n\t\t\t\t\t})\n\t\t\t\t\tif (!result.ok) {\n\t\t\t\t\t\tsetState({ type: 'otp_activation_failed', error: result.error })\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsetState({ type: 'otp_activated', otp: otpCode })\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error(e)\n\t\t\t\t\tsetState({ type: 'otp_activation_failed', error: 'UNKNOWN_ERROR' })\n\t\t\t\t}\n\t\t\t}\n\t\t})()\n\t}, [activateOtp, localStorageRequestId, otpChars, otpLength, state.type, urlRequestId, urlToken])\n\n\treturn state\n}\n"],"names":[],"mappings":";;;;;AAOA,MAAM,wBAAwB,MAAoG;AACjI,QAAM,oBAAoB,aAAa,QAAQ,gCAAgC,KAAK;AACpF,QAAM,YAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACtD,QAAA,YAAY,UAAU,IAAI,YAAY;AACtC,QAAA,QAAQ,UAAU,IAAI,OAAO;AAEnC,SAAO,EAAE,uBAAuB,mBAAmB,cAAc,WAAW,UAAU;
|
|
1
|
+
{"version":3,"file":"usePasswordlessOtpActivator.js","sources":["../../../../../packages/react-client-tenant/src/hooks/usePasswordlessOtpActivator.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { PASSWORDLESS_REQUEST_STORAGE_KEY } from '../consts'\nimport { useActivatePasswordlessOtpMutation } from './mutations'\nimport { randomString } from '../internal/utils/randomInt'\nimport { calculateHash } from '../internal/utils/hashing'\nimport { ActivatePasswordlessOtpErrorCode } from '@contember/graphql-client-tenant'\n\nconst usePasswordlessParams = (): {localStorageRequestId: string | null; urlRequestId: string | null; urlToken: string | null} => {\n\tconst localStorageValue = localStorage.getItem(PASSWORDLESS_REQUEST_STORAGE_KEY) ?? null\n\tconst urlParams = new URLSearchParams(window.location.search)\n\tconst requestId = urlParams.get('request_id')\n\tconst token = urlParams.get('token')\n\n\treturn { localStorageRequestId: localStorageValue, urlRequestId: requestId, urlToken: token }\n}\n\nexport type PasswordlessResponseHandlerState =\n\t| { type: 'empty' }\n\t| { type: 'otp_activating' }\n\t| { type: 'otp_activated'; otp: string }\n\t| { type: 'otp_activation_failed'; error: ActivatePasswordlessOtpErrorCode | 'UNKNOWN_ERROR'}\n\t| { type: 'can_proceed_to_login' }\n\nexport const usePasswordlessOtpActivator = ({ otpLength = 6, otpChars = '0123456789ABCDEF' }: {\n\totpLength?: number\n\totpChars?: string\n} = {}) => {\n\tconst { localStorageRequestId, urlRequestId, urlToken } = usePasswordlessParams()\n\tconst activateOtp = useActivatePasswordlessOtpMutation()\n\n\tconst [state, setState] = useState<PasswordlessResponseHandlerState>(() => {\n\t\tif (urlRequestId && urlToken) {\n\t\t\tif (localStorageRequestId !== urlRequestId) {\n\t\t\t\treturn { type: 'otp_activating' }\n\t\t\t} else {\n\t\t\t\treturn { type: 'can_proceed_to_login' }\n\t\t\t}\n\t\t}\n\t\treturn { type: 'empty' }\n\t})\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (state.type === 'otp_activating') {\n\t\t\t\tconst otpCode = randomString(otpLength, otpChars)\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await activateOtp({\n\t\t\t\t\t\trequestId: urlRequestId!,\n\t\t\t\t\t\ttoken: urlToken!,\n\t\t\t\t\t\totpHash: await calculateHash('SHA-256', otpCode),\n\t\t\t\t\t})\n\t\t\t\t\tif (!result.ok) {\n\t\t\t\t\t\tsetState({ type: 'otp_activation_failed', error: result.error })\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsetState({ type: 'otp_activated', otp: otpCode })\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.error(e)\n\t\t\t\t\tsetState({ type: 'otp_activation_failed', error: 'UNKNOWN_ERROR' })\n\t\t\t\t}\n\t\t\t}\n\t\t})()\n\t}, [activateOtp, localStorageRequestId, otpChars, otpLength, state.type, urlRequestId, urlToken])\n\n\treturn state\n}\n"],"names":[],"mappings":";;;;;AAOA,MAAM,wBAAwB,MAAoG;AACjI,QAAM,oBAAoB,aAAa,QAAQ,gCAAgC,KAAK;AACpF,QAAM,YAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACtD,QAAA,YAAY,UAAU,IAAI,YAAY;AACtC,QAAA,QAAQ,UAAU,IAAI,OAAO;AAEnC,SAAO,EAAE,uBAAuB,mBAAmB,cAAc,WAAW,UAAU,MAAM;AAC7F;AASa,MAAA,8BAA8B,CAAC,EAAE,YAAY,GAAG,WAAW,mBAGpE,IAAA,OAAO;AACV,QAAM,EAAE,uBAAuB,cAAc,SAAA,IAAa,sBAAsB;AAChF,QAAM,cAAc,mCAAmC;AAEvD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA2C,MAAM;AAC1E,QAAI,gBAAgB,UAAU;AAC7B,UAAI,0BAA0B,cAAc;AACpC,eAAA,EAAE,MAAM,iBAAiB;AAAA,MAAA,OAC1B;AACC,eAAA,EAAE,MAAM,uBAAuB;AAAA,MAAA;AAAA,IACvC;AAEM,WAAA,EAAE,MAAM,QAAQ;AAAA,EAAA,CACvB;AAED,YAAU,MAAM;AACf,KAAC,YAAY;AACR,UAAA,MAAM,SAAS,kBAAkB;AAC9B,cAAA,UAAU,aAAa,WAAW,QAAQ;AAC5C,YAAA;AACG,gBAAA,SAAS,MAAM,YAAY;AAAA,YAChC,WAAW;AAAA,YACX,OAAO;AAAA,YACP,SAAS,MAAM,cAAc,WAAW,OAAO;AAAA,UAAA,CAC/C;AACG,cAAA,CAAC,OAAO,IAAI;AACf,qBAAS,EAAE,MAAM,yBAAyB,OAAO,OAAO,OAAO;AAAA,UAAA,OACzD;AACN,qBAAS,EAAE,MAAM,iBAAiB,KAAK,SAAS;AAAA,UAAA;AAAA,iBAEzC,GAAG;AACX,kBAAQ,MAAM,CAAC;AACf,mBAAS,EAAE,MAAM,yBAAyB,OAAO,iBAAiB;AAAA,QAAA;AAAA,MACnE;AAAA,IACD,GACE;AAAA,EAAA,GACD,CAAC,aAAa,uBAAuB,UAAU,WAAW,MAAM,MAAM,cAAc,QAAQ,CAAC;AAEzF,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTenantApi.cjs","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantApi.ts"],"sourcesContent":["import { useLoginToken, useTenantGraphQlClient } from '@contember/react-client'\nimport { useCallback } from 'react'\nimport { Fetcher, TextWriter, util } from 'graphql-ts-client-api'\n\nexport const LoginToken = Symbol('LoginToken')\n\nexport type TenantApiOptions = {\n\treadonly headers?: Record<string, string>\n\treadonly apiToken?: string | typeof LoginToken\n}\n\nexport const useTenantApi = ({ headers, apiToken }: TenantApiOptions = {}) => {\n\tconst client = useTenantGraphQlClient()\n\tconst loginToken = useLoginToken()\n\n\treturn useCallback(<TData extends object, TVariables extends object>(\n\t\tfetcher: Fetcher<'Query' | 'Mutation', TData, TVariables>,\n\t\toptions?: {\n\t\t\treadonly variables?: TVariables\n\t\t\treadonly headers?: Record<string, string>\n\t\t\treadonly apiToken?: string | typeof LoginToken\n\t\t},\n\t): Promise<TData> => {\n\n\t\tconst writer = new TextWriter()\n\t\twriter.text(`${fetcher.fetchableType.name.toLowerCase()}`)\n\t\tif (fetcher.variableTypeMap.size !== 0) {\n\t\t\twriter.scope({ type: 'ARGUMENTS', multiLines: fetcher.variableTypeMap.size > 2, suffix: ' ' }, () => {\n\t\t\t\tutil.iterateMap(fetcher.variableTypeMap, ([name, type]) => {\n\t\t\t\t\twriter.seperator()\n\t\t\t\t\twriter.text(`$${name}: ${type}`)\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t\twriter.text(fetcher.toString())\n\t\twriter.text(fetcher.toFragmentString())\n\n\t\tconst apiTokenResolved = apiToken ?? options?.apiToken\n\t\treturn client.execute(writer.toString(), {\n\t\t\tvariables: options?.variables,\n\t\t\theaders: {\n\t\t\t\t...headers,\n\t\t\t\t...options?.headers,\n\t\t\t},\n\t\t\tapiToken: apiTokenResolved === LoginToken ? loginToken : apiTokenResolved,\n\t\t})\n\t}, [apiToken, client, headers, loginToken])\n}\n"],"names":["useTenantGraphQlClient","useLoginToken","useCallback","TextWriter","util"],"mappings":";;;;;AAIa,MAAA,aAAa,OAAO,YAAY;AAOtC,MAAM,eAAe,CAAC,EAAE,SAAS,SAAS,IAAsB,CAAA,MAAO;AAC7E,QAAM,SAASA,YAAAA;
|
|
1
|
+
{"version":3,"file":"useTenantApi.cjs","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantApi.ts"],"sourcesContent":["import { useLoginToken, useTenantGraphQlClient } from '@contember/react-client'\nimport { useCallback } from 'react'\nimport { Fetcher, TextWriter, util } from 'graphql-ts-client-api'\n\nexport const LoginToken = Symbol('LoginToken')\n\nexport type TenantApiOptions = {\n\treadonly headers?: Record<string, string>\n\treadonly apiToken?: string | typeof LoginToken\n}\n\nexport const useTenantApi = ({ headers, apiToken }: TenantApiOptions = {}) => {\n\tconst client = useTenantGraphQlClient()\n\tconst loginToken = useLoginToken()\n\n\treturn useCallback(<TData extends object, TVariables extends object>(\n\t\tfetcher: Fetcher<'Query' | 'Mutation', TData, TVariables>,\n\t\toptions?: {\n\t\t\treadonly variables?: TVariables\n\t\t\treadonly headers?: Record<string, string>\n\t\t\treadonly apiToken?: string | typeof LoginToken\n\t\t},\n\t): Promise<TData> => {\n\n\t\tconst writer = new TextWriter()\n\t\twriter.text(`${fetcher.fetchableType.name.toLowerCase()}`)\n\t\tif (fetcher.variableTypeMap.size !== 0) {\n\t\t\twriter.scope({ type: 'ARGUMENTS', multiLines: fetcher.variableTypeMap.size > 2, suffix: ' ' }, () => {\n\t\t\t\tutil.iterateMap(fetcher.variableTypeMap, ([name, type]) => {\n\t\t\t\t\twriter.seperator()\n\t\t\t\t\twriter.text(`$${name}: ${type}`)\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t\twriter.text(fetcher.toString())\n\t\twriter.text(fetcher.toFragmentString())\n\n\t\tconst apiTokenResolved = apiToken ?? options?.apiToken\n\t\treturn client.execute(writer.toString(), {\n\t\t\tvariables: options?.variables,\n\t\t\theaders: {\n\t\t\t\t...headers,\n\t\t\t\t...options?.headers,\n\t\t\t},\n\t\t\tapiToken: apiTokenResolved === LoginToken ? loginToken : apiTokenResolved,\n\t\t})\n\t}, [apiToken, client, headers, loginToken])\n}\n"],"names":["useTenantGraphQlClient","useLoginToken","useCallback","TextWriter","util"],"mappings":";;;;;AAIa,MAAA,aAAa,OAAO,YAAY;AAOtC,MAAM,eAAe,CAAC,EAAE,SAAS,SAAS,IAAsB,CAAA,MAAO;AAC7E,QAAM,SAASA,YAAAA,uBAAuB;AACtC,QAAM,aAAaC,YAAAA,cAAc;AAE1B,SAAAC,MAAA,YAAY,CAClB,SACA,YAKoB;AAEd,UAAA,SAAS,IAAIC,8BAAW;AAC9B,WAAO,KAAK,GAAG,QAAQ,cAAc,KAAK,YAAa,CAAA,EAAE;AACrD,QAAA,QAAQ,gBAAgB,SAAS,GAAG;AACvC,aAAO,MAAM,EAAE,MAAM,aAAa,YAAY,QAAQ,gBAAgB,OAAO,GAAG,QAAQ,IAAI,GAAG,MAAM;AACpGC,2BAAA,KAAK,WAAW,QAAQ,iBAAiB,CAAC,CAAC,MAAM,IAAI,MAAM;AAC1D,iBAAO,UAAU;AACjB,iBAAO,KAAK,IAAI,IAAI,KAAK,IAAI,EAAE;AAAA,QAAA,CAC/B;AAAA,MAAA,CACD;AAAA,IAAA;AAEK,WAAA,KAAK,QAAQ,UAAU;AACvB,WAAA,KAAK,QAAQ,kBAAkB;AAEhC,UAAA,mBAAmB,YAAY,SAAS;AAC9C,WAAO,OAAO,QAAQ,OAAO,SAAA,GAAY;AAAA,MACxC,WAAW,SAAS;AAAA,MACpB,SAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAG,SAAS;AAAA,MACb;AAAA,MACA,UAAU,qBAAqB,aAAa,aAAa;AAAA,IAAA,CACzD;AAAA,KACC,CAAC,UAAU,QAAQ,SAAS,UAAU,CAAC;AAC3C;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTenantApi.js","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantApi.ts"],"sourcesContent":["import { useLoginToken, useTenantGraphQlClient } from '@contember/react-client'\nimport { useCallback } from 'react'\nimport { Fetcher, TextWriter, util } from 'graphql-ts-client-api'\n\nexport const LoginToken = Symbol('LoginToken')\n\nexport type TenantApiOptions = {\n\treadonly headers?: Record<string, string>\n\treadonly apiToken?: string | typeof LoginToken\n}\n\nexport const useTenantApi = ({ headers, apiToken }: TenantApiOptions = {}) => {\n\tconst client = useTenantGraphQlClient()\n\tconst loginToken = useLoginToken()\n\n\treturn useCallback(<TData extends object, TVariables extends object>(\n\t\tfetcher: Fetcher<'Query' | 'Mutation', TData, TVariables>,\n\t\toptions?: {\n\t\t\treadonly variables?: TVariables\n\t\t\treadonly headers?: Record<string, string>\n\t\t\treadonly apiToken?: string | typeof LoginToken\n\t\t},\n\t): Promise<TData> => {\n\n\t\tconst writer = new TextWriter()\n\t\twriter.text(`${fetcher.fetchableType.name.toLowerCase()}`)\n\t\tif (fetcher.variableTypeMap.size !== 0) {\n\t\t\twriter.scope({ type: 'ARGUMENTS', multiLines: fetcher.variableTypeMap.size > 2, suffix: ' ' }, () => {\n\t\t\t\tutil.iterateMap(fetcher.variableTypeMap, ([name, type]) => {\n\t\t\t\t\twriter.seperator()\n\t\t\t\t\twriter.text(`$${name}: ${type}`)\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t\twriter.text(fetcher.toString())\n\t\twriter.text(fetcher.toFragmentString())\n\n\t\tconst apiTokenResolved = apiToken ?? options?.apiToken\n\t\treturn client.execute(writer.toString(), {\n\t\t\tvariables: options?.variables,\n\t\t\theaders: {\n\t\t\t\t...headers,\n\t\t\t\t...options?.headers,\n\t\t\t},\n\t\t\tapiToken: apiTokenResolved === LoginToken ? loginToken : apiTokenResolved,\n\t\t})\n\t}, [apiToken, client, headers, loginToken])\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,aAAa,OAAO,YAAY;AAOtC,MAAM,eAAe,CAAC,EAAE,SAAS,SAAS,IAAsB,CAAA,MAAO;AAC7E,QAAM,SAAS;
|
|
1
|
+
{"version":3,"file":"useTenantApi.js","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantApi.ts"],"sourcesContent":["import { useLoginToken, useTenantGraphQlClient } from '@contember/react-client'\nimport { useCallback } from 'react'\nimport { Fetcher, TextWriter, util } from 'graphql-ts-client-api'\n\nexport const LoginToken = Symbol('LoginToken')\n\nexport type TenantApiOptions = {\n\treadonly headers?: Record<string, string>\n\treadonly apiToken?: string | typeof LoginToken\n}\n\nexport const useTenantApi = ({ headers, apiToken }: TenantApiOptions = {}) => {\n\tconst client = useTenantGraphQlClient()\n\tconst loginToken = useLoginToken()\n\n\treturn useCallback(<TData extends object, TVariables extends object>(\n\t\tfetcher: Fetcher<'Query' | 'Mutation', TData, TVariables>,\n\t\toptions?: {\n\t\t\treadonly variables?: TVariables\n\t\t\treadonly headers?: Record<string, string>\n\t\t\treadonly apiToken?: string | typeof LoginToken\n\t\t},\n\t): Promise<TData> => {\n\n\t\tconst writer = new TextWriter()\n\t\twriter.text(`${fetcher.fetchableType.name.toLowerCase()}`)\n\t\tif (fetcher.variableTypeMap.size !== 0) {\n\t\t\twriter.scope({ type: 'ARGUMENTS', multiLines: fetcher.variableTypeMap.size > 2, suffix: ' ' }, () => {\n\t\t\t\tutil.iterateMap(fetcher.variableTypeMap, ([name, type]) => {\n\t\t\t\t\twriter.seperator()\n\t\t\t\t\twriter.text(`$${name}: ${type}`)\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t\twriter.text(fetcher.toString())\n\t\twriter.text(fetcher.toFragmentString())\n\n\t\tconst apiTokenResolved = apiToken ?? options?.apiToken\n\t\treturn client.execute(writer.toString(), {\n\t\t\tvariables: options?.variables,\n\t\t\theaders: {\n\t\t\t\t...headers,\n\t\t\t\t...options?.headers,\n\t\t\t},\n\t\t\tapiToken: apiTokenResolved === LoginToken ? loginToken : apiTokenResolved,\n\t\t})\n\t}, [apiToken, client, headers, loginToken])\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,aAAa,OAAO,YAAY;AAOtC,MAAM,eAAe,CAAC,EAAE,SAAS,SAAS,IAAsB,CAAA,MAAO;AAC7E,QAAM,SAAS,uBAAuB;AACtC,QAAM,aAAa,cAAc;AAE1B,SAAA,YAAY,CAClB,SACA,YAKoB;AAEd,UAAA,SAAS,IAAI,WAAW;AAC9B,WAAO,KAAK,GAAG,QAAQ,cAAc,KAAK,YAAa,CAAA,EAAE;AACrD,QAAA,QAAQ,gBAAgB,SAAS,GAAG;AACvC,aAAO,MAAM,EAAE,MAAM,aAAa,YAAY,QAAQ,gBAAgB,OAAO,GAAG,QAAQ,IAAI,GAAG,MAAM;AACpG,aAAK,WAAW,QAAQ,iBAAiB,CAAC,CAAC,MAAM,IAAI,MAAM;AAC1D,iBAAO,UAAU;AACjB,iBAAO,KAAK,IAAI,IAAI,KAAK,IAAI,EAAE;AAAA,QAAA,CAC/B;AAAA,MAAA,CACD;AAAA,IAAA;AAEK,WAAA,KAAK,QAAQ,UAAU;AACvB,WAAA,KAAK,QAAQ,kBAAkB;AAEhC,UAAA,mBAAmB,YAAY,SAAS;AAC9C,WAAO,OAAO,QAAQ,OAAO,SAAA,GAAY;AAAA,MACxC,WAAW,SAAS;AAAA,MACpB,SAAS;AAAA,QACR,GAAG;AAAA,QACH,GAAG,SAAS;AAAA,MACb;AAAA,MACA,UAAU,qBAAqB,aAAa,aAAa;AAAA,IAAA,CACzD;AAAA,KACC,CAAC,UAAU,QAAQ,SAAS,UAAU,CAAC;AAC3C;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTenantMutation.cjs","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantMutation.ts"],"sourcesContent":["import { TenantApiOptions, useTenantApi } from './useTenantApi'\nimport { useCallback, useMemo } from 'react'\nimport { MutationFetcher } from '@contember/graphql-client-tenant'\n\nexport type TenantMutationOkResponse<Result> = { ok: true; result: Result }\nexport type TenantMutationErrorResponse<Error> = { ok: false; error: Error; developerMessage?: string }\nexport type TenantMutationResponse<Result, Error> = TenantMutationOkResponse<Result> | TenantMutationErrorResponse<Error>\n\nexport type TenantMutation<Result, Error> = { readonly mutation?: { readonly ok: boolean; readonly error?: { readonly code: Error; readonly developerMessage: string}; readonly result?: Result} }\n\nexport const useTenantMutation = <TResult, TError extends string = never, TVariables extends object = {}>(\n\tfetcher: MutationFetcher<TenantMutation<TResult, TError>, TVariables>,\n\t{ headers, apiToken }: TenantApiOptions = {},\n) => {\n\tconst tenantApi = useTenantApi({ headers, apiToken })\n\n\treturn useCallback(async (variables: TVariables): Promise<TenantMutationResponse<TResult, TError>> => {\n\t\tconst result = await tenantApi(\n\t\t\tfetcher,\n\t\t\t{\n\t\t\t\tvariables,\n\t\t\t},\n\t\t)\n\t\tif (!result.mutation?.ok) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: result.mutation?.error?.code as TError,\n\t\t\t\tdeveloperMessage: result.mutation?.error?.developerMessage,\n\t\t\t}\n\t\t} else {\n\t\t\treturn { ok: true, result: result.mutation.result as TResult }\n\t\t}\n\t}, [fetcher, tenantApi])\n}\n\n\nexport const createTenantMutation = <TResult, TError extends string = never, TVariables extends object = {}>(\n\tfetcher: MutationFetcher<TenantMutation<TResult, TError>, TVariables>,\n\tdefaultOptions?: TenantApiOptions,\n) => {\n\treturn ({ headers, apiToken }: TenantApiOptions = {}) => useTenantMutation(fetcher, {\n\t\theaders: useMemo(() => ({ ...defaultOptions?.headers, ...headers }), [headers]),\n\t\tapiToken: apiToken ?? defaultOptions?.apiToken,\n\t})\n}\n"],"names":["useTenantApi","useCallback","useMemo"],"mappings":";;;;AAUa,MAAA,oBAAoB,CAChC,SACA,EAAE,SAAS,SAAS,IAAsB,CAAA,MACtC;AACJ,QAAM,YAAYA,aAAA,aAAa,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"useTenantMutation.cjs","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantMutation.ts"],"sourcesContent":["import { TenantApiOptions, useTenantApi } from './useTenantApi'\nimport { useCallback, useMemo } from 'react'\nimport { MutationFetcher } from '@contember/graphql-client-tenant'\n\nexport type TenantMutationOkResponse<Result> = { ok: true; result: Result }\nexport type TenantMutationErrorResponse<Error> = { ok: false; error: Error; developerMessage?: string }\nexport type TenantMutationResponse<Result, Error> = TenantMutationOkResponse<Result> | TenantMutationErrorResponse<Error>\n\nexport type TenantMutation<Result, Error> = { readonly mutation?: { readonly ok: boolean; readonly error?: { readonly code: Error; readonly developerMessage: string}; readonly result?: Result} }\n\nexport const useTenantMutation = <TResult, TError extends string = never, TVariables extends object = {}>(\n\tfetcher: MutationFetcher<TenantMutation<TResult, TError>, TVariables>,\n\t{ headers, apiToken }: TenantApiOptions = {},\n) => {\n\tconst tenantApi = useTenantApi({ headers, apiToken })\n\n\treturn useCallback(async (variables: TVariables): Promise<TenantMutationResponse<TResult, TError>> => {\n\t\tconst result = await tenantApi(\n\t\t\tfetcher,\n\t\t\t{\n\t\t\t\tvariables,\n\t\t\t},\n\t\t)\n\t\tif (!result.mutation?.ok) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: result.mutation?.error?.code as TError,\n\t\t\t\tdeveloperMessage: result.mutation?.error?.developerMessage,\n\t\t\t}\n\t\t} else {\n\t\t\treturn { ok: true, result: result.mutation.result as TResult }\n\t\t}\n\t}, [fetcher, tenantApi])\n}\n\n\nexport const createTenantMutation = <TResult, TError extends string = never, TVariables extends object = {}>(\n\tfetcher: MutationFetcher<TenantMutation<TResult, TError>, TVariables>,\n\tdefaultOptions?: TenantApiOptions,\n) => {\n\treturn ({ headers, apiToken }: TenantApiOptions = {}) => useTenantMutation(fetcher, {\n\t\theaders: useMemo(() => ({ ...defaultOptions?.headers, ...headers }), [headers]),\n\t\tapiToken: apiToken ?? defaultOptions?.apiToken,\n\t})\n}\n"],"names":["useTenantApi","useCallback","useMemo"],"mappings":";;;;AAUa,MAAA,oBAAoB,CAChC,SACA,EAAE,SAAS,SAAS,IAAsB,CAAA,MACtC;AACJ,QAAM,YAAYA,aAAA,aAAa,EAAE,SAAS,UAAU;AAE7C,SAAAC,MAAAA,YAAY,OAAO,cAA4E;AACrG,UAAM,SAAS,MAAM;AAAA,MACpB;AAAA,MACA;AAAA,QACC;AAAA,MAAA;AAAA,IAEF;AACI,QAAA,CAAC,OAAO,UAAU,IAAI;AAClB,aAAA;AAAA,QACN,IAAI;AAAA,QACJ,OAAO,OAAO,UAAU,OAAO;AAAA,QAC/B,kBAAkB,OAAO,UAAU,OAAO;AAAA,MAC3C;AAAA,IAAA,OACM;AACN,aAAO,EAAE,IAAI,MAAM,QAAQ,OAAO,SAAS,OAAkB;AAAA,IAAA;AAAA,EAC9D,GACE,CAAC,SAAS,SAAS,CAAC;AACxB;AAGa,MAAA,uBAAuB,CACnC,SACA,mBACI;AACG,SAAA,CAAC,EAAE,SAAS,aAA+B,CAAC,MAAM,kBAAkB,SAAS;AAAA,IACnF,SAASC,MAAAA,QAAQ,OAAO,EAAE,GAAG,gBAAgB,SAAS,GAAG,QAAQ,IAAI,CAAC,OAAO,CAAC;AAAA,IAC9E,UAAU,YAAY,gBAAgB;AAAA,EAAA,CACtC;AACF;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTenantMutation.js","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantMutation.ts"],"sourcesContent":["import { TenantApiOptions, useTenantApi } from './useTenantApi'\nimport { useCallback, useMemo } from 'react'\nimport { MutationFetcher } from '@contember/graphql-client-tenant'\n\nexport type TenantMutationOkResponse<Result> = { ok: true; result: Result }\nexport type TenantMutationErrorResponse<Error> = { ok: false; error: Error; developerMessage?: string }\nexport type TenantMutationResponse<Result, Error> = TenantMutationOkResponse<Result> | TenantMutationErrorResponse<Error>\n\nexport type TenantMutation<Result, Error> = { readonly mutation?: { readonly ok: boolean; readonly error?: { readonly code: Error; readonly developerMessage: string}; readonly result?: Result} }\n\nexport const useTenantMutation = <TResult, TError extends string = never, TVariables extends object = {}>(\n\tfetcher: MutationFetcher<TenantMutation<TResult, TError>, TVariables>,\n\t{ headers, apiToken }: TenantApiOptions = {},\n) => {\n\tconst tenantApi = useTenantApi({ headers, apiToken })\n\n\treturn useCallback(async (variables: TVariables): Promise<TenantMutationResponse<TResult, TError>> => {\n\t\tconst result = await tenantApi(\n\t\t\tfetcher,\n\t\t\t{\n\t\t\t\tvariables,\n\t\t\t},\n\t\t)\n\t\tif (!result.mutation?.ok) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: result.mutation?.error?.code as TError,\n\t\t\t\tdeveloperMessage: result.mutation?.error?.developerMessage,\n\t\t\t}\n\t\t} else {\n\t\t\treturn { ok: true, result: result.mutation.result as TResult }\n\t\t}\n\t}, [fetcher, tenantApi])\n}\n\n\nexport const createTenantMutation = <TResult, TError extends string = never, TVariables extends object = {}>(\n\tfetcher: MutationFetcher<TenantMutation<TResult, TError>, TVariables>,\n\tdefaultOptions?: TenantApiOptions,\n) => {\n\treturn ({ headers, apiToken }: TenantApiOptions = {}) => useTenantMutation(fetcher, {\n\t\theaders: useMemo(() => ({ ...defaultOptions?.headers, ...headers }), [headers]),\n\t\tapiToken: apiToken ?? defaultOptions?.apiToken,\n\t})\n}\n"],"names":[],"mappings":";;AAUa,MAAA,oBAAoB,CAChC,SACA,EAAE,SAAS,SAAS,IAAsB,CAAA,MACtC;AACJ,QAAM,YAAY,aAAa,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"useTenantMutation.js","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantMutation.ts"],"sourcesContent":["import { TenantApiOptions, useTenantApi } from './useTenantApi'\nimport { useCallback, useMemo } from 'react'\nimport { MutationFetcher } from '@contember/graphql-client-tenant'\n\nexport type TenantMutationOkResponse<Result> = { ok: true; result: Result }\nexport type TenantMutationErrorResponse<Error> = { ok: false; error: Error; developerMessage?: string }\nexport type TenantMutationResponse<Result, Error> = TenantMutationOkResponse<Result> | TenantMutationErrorResponse<Error>\n\nexport type TenantMutation<Result, Error> = { readonly mutation?: { readonly ok: boolean; readonly error?: { readonly code: Error; readonly developerMessage: string}; readonly result?: Result} }\n\nexport const useTenantMutation = <TResult, TError extends string = never, TVariables extends object = {}>(\n\tfetcher: MutationFetcher<TenantMutation<TResult, TError>, TVariables>,\n\t{ headers, apiToken }: TenantApiOptions = {},\n) => {\n\tconst tenantApi = useTenantApi({ headers, apiToken })\n\n\treturn useCallback(async (variables: TVariables): Promise<TenantMutationResponse<TResult, TError>> => {\n\t\tconst result = await tenantApi(\n\t\t\tfetcher,\n\t\t\t{\n\t\t\t\tvariables,\n\t\t\t},\n\t\t)\n\t\tif (!result.mutation?.ok) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: result.mutation?.error?.code as TError,\n\t\t\t\tdeveloperMessage: result.mutation?.error?.developerMessage,\n\t\t\t}\n\t\t} else {\n\t\t\treturn { ok: true, result: result.mutation.result as TResult }\n\t\t}\n\t}, [fetcher, tenantApi])\n}\n\n\nexport const createTenantMutation = <TResult, TError extends string = never, TVariables extends object = {}>(\n\tfetcher: MutationFetcher<TenantMutation<TResult, TError>, TVariables>,\n\tdefaultOptions?: TenantApiOptions,\n) => {\n\treturn ({ headers, apiToken }: TenantApiOptions = {}) => useTenantMutation(fetcher, {\n\t\theaders: useMemo(() => ({ ...defaultOptions?.headers, ...headers }), [headers]),\n\t\tapiToken: apiToken ?? defaultOptions?.apiToken,\n\t})\n}\n"],"names":[],"mappings":";;AAUa,MAAA,oBAAoB,CAChC,SACA,EAAE,SAAS,SAAS,IAAsB,CAAA,MACtC;AACJ,QAAM,YAAY,aAAa,EAAE,SAAS,UAAU;AAE7C,SAAA,YAAY,OAAO,cAA4E;AACrG,UAAM,SAAS,MAAM;AAAA,MACpB;AAAA,MACA;AAAA,QACC;AAAA,MAAA;AAAA,IAEF;AACI,QAAA,CAAC,OAAO,UAAU,IAAI;AAClB,aAAA;AAAA,QACN,IAAI;AAAA,QACJ,OAAO,OAAO,UAAU,OAAO;AAAA,QAC/B,kBAAkB,OAAO,UAAU,OAAO;AAAA,MAC3C;AAAA,IAAA,OACM;AACN,aAAO,EAAE,IAAI,MAAM,QAAQ,OAAO,SAAS,OAAkB;AAAA,IAAA;AAAA,EAC9D,GACE,CAAC,SAAS,SAAS,CAAC;AACxB;AAGa,MAAA,uBAAuB,CACnC,SACA,mBACI;AACG,SAAA,CAAC,EAAE,SAAS,aAA+B,CAAC,MAAM,kBAAkB,SAAS;AAAA,IACnF,SAAS,QAAQ,OAAO,EAAE,GAAG,gBAAgB,SAAS,GAAG,QAAQ,IAAI,CAAC,OAAO,CAAC;AAAA,IAC9E,UAAU,YAAY,gBAAgB;AAAA,EAAA,CACtC;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTenantQueryLoader.cjs","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantQueryLoader.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\nimport { useObjectMemo } from '@contember/react-utils'\n\nexport type TenantQueryLoaderState<Result> =\n\t| { state: 'loading' }\n\t| { state: 'error'; error: unknown }\n\t| { state: 'success'; data: Result }\n\t| { state: 'refreshing'; data: Result }\n\nexport type TenantQueryLoaderMethods = {\n\trefresh: () => void\n}\n\nexport const useTenantQueryLoader = <TVariables extends object, Result>(fetcher: (variables: TVariables) => Promise<Result>, variables: TVariables): [TenantQueryLoaderState<Result>, TenantQueryLoaderMethods] => {\n\tconst [state, setState] = useState<TenantQueryLoaderState<Result>>({ state: 'loading' })\n\tconst stateRef = useRef(state)\n\tstateRef.current = state\n\tconst variablesMemo = useObjectMemo(variables)\n\n\tconst reqId = useRef(0)\n\n\tconst triggerLoad = useCallback(async () => {\n\t\tconst currentReqId = ++reqId.current\n\t\ttry {\n\t\t\tif (stateRef.current.state === 'success') {\n\t\t\t\tsetState({ state: 'refreshing', data: stateRef.current.data })\n\t\t\t}\n\t\t\tconst data = await fetcher(variablesMemo)\n\t\t\tif (reqId.current !== currentReqId) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetState({ state: 'success', data })\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\tif (reqId.current !== currentReqId) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetState({ state: 'error', error: e })\n\t\t}\n\n\t}, [fetcher, variablesMemo])\n\n\n\tuseEffect(() => {\n\t\ttriggerLoad()\n\t}, [triggerLoad])\n\n\treturn [state, { refresh: triggerLoad }]\n}\n"],"names":["useState","useRef","useObjectMemo","useCallback","useEffect"],"mappings":";;;;AAaa,MAAA,uBAAuB,CAAoC,SAAqD,cAAsF;AAC5M,QAAA,CAAC,OAAO,QAAQ,IAAIA,eAAyC,EAAE,OAAO,WAAW;AACjF,QAAA,WAAWC,aAAO,KAAK;AAC7B,WAAS,UAAU;AACb,QAAA,gBAAgBC,yBAAc,SAAS;AAEvC,QAAA,QAAQD,aAAO,CAAC;AAEhB,QAAA,cAAcE,MAAAA,YAAY,YAAY;AACrC,UAAA,eAAe,EAAE,MAAM;AACzB,QAAA;AACC,UAAA,SAAS,QAAQ,UAAU,WAAW;AACzC,iBAAS,EAAE,OAAO,cAAc,MAAM,SAAS,QAAQ,MAAM;AAAA,
|
|
1
|
+
{"version":3,"file":"useTenantQueryLoader.cjs","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantQueryLoader.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\nimport { useObjectMemo } from '@contember/react-utils'\n\nexport type TenantQueryLoaderState<Result> =\n\t| { state: 'loading' }\n\t| { state: 'error'; error: unknown }\n\t| { state: 'success'; data: Result }\n\t| { state: 'refreshing'; data: Result }\n\nexport type TenantQueryLoaderMethods = {\n\trefresh: () => void\n}\n\nexport const useTenantQueryLoader = <TVariables extends object, Result>(fetcher: (variables: TVariables) => Promise<Result>, variables: TVariables): [TenantQueryLoaderState<Result>, TenantQueryLoaderMethods] => {\n\tconst [state, setState] = useState<TenantQueryLoaderState<Result>>({ state: 'loading' })\n\tconst stateRef = useRef(state)\n\tstateRef.current = state\n\tconst variablesMemo = useObjectMemo(variables)\n\n\tconst reqId = useRef(0)\n\n\tconst triggerLoad = useCallback(async () => {\n\t\tconst currentReqId = ++reqId.current\n\t\ttry {\n\t\t\tif (stateRef.current.state === 'success') {\n\t\t\t\tsetState({ state: 'refreshing', data: stateRef.current.data })\n\t\t\t}\n\t\t\tconst data = await fetcher(variablesMemo)\n\t\t\tif (reqId.current !== currentReqId) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetState({ state: 'success', data })\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\tif (reqId.current !== currentReqId) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetState({ state: 'error', error: e })\n\t\t}\n\n\t}, [fetcher, variablesMemo])\n\n\n\tuseEffect(() => {\n\t\ttriggerLoad()\n\t}, [triggerLoad])\n\n\treturn [state, { refresh: triggerLoad }]\n}\n"],"names":["useState","useRef","useObjectMemo","useCallback","useEffect"],"mappings":";;;;AAaa,MAAA,uBAAuB,CAAoC,SAAqD,cAAsF;AAC5M,QAAA,CAAC,OAAO,QAAQ,IAAIA,eAAyC,EAAE,OAAO,WAAW;AACjF,QAAA,WAAWC,aAAO,KAAK;AAC7B,WAAS,UAAU;AACb,QAAA,gBAAgBC,yBAAc,SAAS;AAEvC,QAAA,QAAQD,aAAO,CAAC;AAEhB,QAAA,cAAcE,MAAAA,YAAY,YAAY;AACrC,UAAA,eAAe,EAAE,MAAM;AACzB,QAAA;AACC,UAAA,SAAS,QAAQ,UAAU,WAAW;AACzC,iBAAS,EAAE,OAAO,cAAc,MAAM,SAAS,QAAQ,MAAM;AAAA,MAAA;AAExD,YAAA,OAAO,MAAM,QAAQ,aAAa;AACpC,UAAA,MAAM,YAAY,cAAc;AACnC;AAAA,MAAA;AAED,eAAS,EAAE,OAAO,WAAW,KAAA,CAAM;AAAA,aAC3B,GAAG;AACX,cAAQ,MAAM,CAAC;AACX,UAAA,MAAM,YAAY,cAAc;AACnC;AAAA,MAAA;AAED,eAAS,EAAE,OAAO,SAAS,OAAO,GAAG;AAAA,IAAA;AAAA,EACtC,GAEE,CAAC,SAAS,aAAa,CAAC;AAG3BC,QAAAA,UAAU,MAAM;AACH,gBAAA;AAAA,EAAA,GACV,CAAC,WAAW,CAAC;AAEhB,SAAO,CAAC,OAAO,EAAE,SAAS,aAAa;AACxC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTenantQueryLoader.js","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantQueryLoader.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\nimport { useObjectMemo } from '@contember/react-utils'\n\nexport type TenantQueryLoaderState<Result> =\n\t| { state: 'loading' }\n\t| { state: 'error'; error: unknown }\n\t| { state: 'success'; data: Result }\n\t| { state: 'refreshing'; data: Result }\n\nexport type TenantQueryLoaderMethods = {\n\trefresh: () => void\n}\n\nexport const useTenantQueryLoader = <TVariables extends object, Result>(fetcher: (variables: TVariables) => Promise<Result>, variables: TVariables): [TenantQueryLoaderState<Result>, TenantQueryLoaderMethods] => {\n\tconst [state, setState] = useState<TenantQueryLoaderState<Result>>({ state: 'loading' })\n\tconst stateRef = useRef(state)\n\tstateRef.current = state\n\tconst variablesMemo = useObjectMemo(variables)\n\n\tconst reqId = useRef(0)\n\n\tconst triggerLoad = useCallback(async () => {\n\t\tconst currentReqId = ++reqId.current\n\t\ttry {\n\t\t\tif (stateRef.current.state === 'success') {\n\t\t\t\tsetState({ state: 'refreshing', data: stateRef.current.data })\n\t\t\t}\n\t\t\tconst data = await fetcher(variablesMemo)\n\t\t\tif (reqId.current !== currentReqId) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetState({ state: 'success', data })\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\tif (reqId.current !== currentReqId) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetState({ state: 'error', error: e })\n\t\t}\n\n\t}, [fetcher, variablesMemo])\n\n\n\tuseEffect(() => {\n\t\ttriggerLoad()\n\t}, [triggerLoad])\n\n\treturn [state, { refresh: triggerLoad }]\n}\n"],"names":[],"mappings":";;AAaa,MAAA,uBAAuB,CAAoC,SAAqD,cAAsF;AAC5M,QAAA,CAAC,OAAO,QAAQ,IAAI,SAAyC,EAAE,OAAO,WAAW;AACjF,QAAA,WAAW,OAAO,KAAK;AAC7B,WAAS,UAAU;AACb,QAAA,gBAAgB,cAAc,SAAS;AAEvC,QAAA,QAAQ,OAAO,CAAC;AAEhB,QAAA,cAAc,YAAY,YAAY;AACrC,UAAA,eAAe,EAAE,MAAM;AACzB,QAAA;AACC,UAAA,SAAS,QAAQ,UAAU,WAAW;AACzC,iBAAS,EAAE,OAAO,cAAc,MAAM,SAAS,QAAQ,MAAM;AAAA,
|
|
1
|
+
{"version":3,"file":"useTenantQueryLoader.js","sources":["../../../../../packages/react-client-tenant/src/hooks/useTenantQueryLoader.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\nimport { useObjectMemo } from '@contember/react-utils'\n\nexport type TenantQueryLoaderState<Result> =\n\t| { state: 'loading' }\n\t| { state: 'error'; error: unknown }\n\t| { state: 'success'; data: Result }\n\t| { state: 'refreshing'; data: Result }\n\nexport type TenantQueryLoaderMethods = {\n\trefresh: () => void\n}\n\nexport const useTenantQueryLoader = <TVariables extends object, Result>(fetcher: (variables: TVariables) => Promise<Result>, variables: TVariables): [TenantQueryLoaderState<Result>, TenantQueryLoaderMethods] => {\n\tconst [state, setState] = useState<TenantQueryLoaderState<Result>>({ state: 'loading' })\n\tconst stateRef = useRef(state)\n\tstateRef.current = state\n\tconst variablesMemo = useObjectMemo(variables)\n\n\tconst reqId = useRef(0)\n\n\tconst triggerLoad = useCallback(async () => {\n\t\tconst currentReqId = ++reqId.current\n\t\ttry {\n\t\t\tif (stateRef.current.state === 'success') {\n\t\t\t\tsetState({ state: 'refreshing', data: stateRef.current.data })\n\t\t\t}\n\t\t\tconst data = await fetcher(variablesMemo)\n\t\t\tif (reqId.current !== currentReqId) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetState({ state: 'success', data })\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\tif (reqId.current !== currentReqId) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetState({ state: 'error', error: e })\n\t\t}\n\n\t}, [fetcher, variablesMemo])\n\n\n\tuseEffect(() => {\n\t\ttriggerLoad()\n\t}, [triggerLoad])\n\n\treturn [state, { refresh: triggerLoad }]\n}\n"],"names":[],"mappings":";;AAaa,MAAA,uBAAuB,CAAoC,SAAqD,cAAsF;AAC5M,QAAA,CAAC,OAAO,QAAQ,IAAI,SAAyC,EAAE,OAAO,WAAW;AACjF,QAAA,WAAW,OAAO,KAAK;AAC7B,WAAS,UAAU;AACb,QAAA,gBAAgB,cAAc,SAAS;AAEvC,QAAA,QAAQ,OAAO,CAAC;AAEhB,QAAA,cAAc,YAAY,YAAY;AACrC,UAAA,eAAe,EAAE,MAAM;AACzB,QAAA;AACC,UAAA,SAAS,QAAQ,UAAU,WAAW;AACzC,iBAAS,EAAE,OAAO,cAAc,MAAM,SAAS,QAAQ,MAAM;AAAA,MAAA;AAExD,YAAA,OAAO,MAAM,QAAQ,aAAa;AACpC,UAAA,MAAM,YAAY,cAAc;AACnC;AAAA,MAAA;AAED,eAAS,EAAE,OAAO,WAAW,KAAA,CAAM;AAAA,aAC3B,GAAG;AACX,cAAQ,MAAM,CAAC;AACX,UAAA,MAAM,YAAY,cAAc;AACnC;AAAA,MAAA;AAED,eAAS,EAAE,OAAO,SAAS,OAAO,GAAG;AAAA,IAAA;AAAA,EACtC,GAEE,CAAC,SAAS,aAAa,CAAC;AAG3B,YAAU,MAAM;AACH,gBAAA;AAAA,EAAA,GACV,CAAC,WAAW,CAAC;AAEhB,SAAO,CAAC,OAAO,EAAE,SAAS,aAAa;AACxC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHandleIDPResponse.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useHandleIDPResponse.ts"],"sourcesContent":["import { SetStateAction, useEffect, useRef } from 'react'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { useIDPStateStore } from './useIDPStateStore'\nimport { getBaseHref } from '../utils/getBaseHref'\nimport { IDPStateValue } from '../../types/idp'\nimport { useSignInIDPMutation } from '../../hooks'\nimport { useRedirectToBacklinkCallback } from './useRedirectToBacklink'\n\nexport interface UseHandleIDPResponseProps {\n\tonLogin?: () => void\n\texpiration?: number\n\n\tsetState: (state: SetStateAction<IDPStateValue>) => void\n\thasOauthResponse: boolean\n}\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\n\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const useHandleIDPResponse = ({ onLogin, expiration = DEFAULT_LOGIN_EXPIRATION, setState, hasOauthResponse }: UseHandleIDPResponseProps): void => {\n\tconst idpSignIn = useSignInIDPMutation({ headers })\n\tconst setSessionToken = useSetSessionToken()\n\n\tconst firstRenderRef = useRef(true)\n\n\tconst { get: loadIdpState } = useIDPStateStore()\n\tconst redirectToBackLink = useRedirectToBacklinkCallback()\n\n\tuseEffect(() => {\n\t\tif (!hasOauthResponse || !firstRenderRef.current) {\n\t\t\treturn\n\t\t}\n\t\tfirstRenderRef.current = false\n\t\t;(async () => {\n\t\t\tconst idpState = loadIdpState()\n\t\t\tif (!idpState) {\n\t\t\t\tsetState({ type: 'response_failed', error: 'INVALID_LOCAL_STATE' })\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst response = await idpSignIn({\n\t\t\t\tdata: {\n\t\t\t\t\turl: window.location.href,\n\t\t\t\t\tredirectUrl: getBaseHref(),\n\t\t\t\t\tsessionData: idpState.sessionData,\n\t\t\t\t},\n\t\t\t\tidentityProvider: idpState.provider,\n\t\t\t\texpiration,\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\tsetState({ type: 'response_failed', error: response.error || 'UNKNOWN_ERROR' })\n\t\t\t} else {\n\t\t\t\tsetSessionToken(response.result.token)\n\t\t\t\tsetState({ type: 'success' })\n\n\t\t\t\tonLogin?.()\n\t\t\t\tredirectToBackLink()\n\t\t\t}\n\t\t})()\n\t}, [idpSignIn, onLogin, setSessionToken, hasOauthResponse, loadIdpState, expiration, setState, redirectToBackLink])\n}\n"],"names":["useSignInIDPMutation","useSetSessionToken","useRef","useIDPStateStore","useRedirectToBacklinkCallback","useEffect","getBaseHref"],"mappings":";;;;;;;;AAgBA,MAAM,UAAU;AAAA,EACf,0BAA0B;AAC3B;AAEA,MAAM,2BAA2B,KAAK,KAAK;AAE9B,MAAA,uBAAuB,CAAC,EAAE,SAAS,aAAa,0BAA0B,UAAU,uBAAwD;AACxJ,QAAM,YAAYA,qBAAAA,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"useHandleIDPResponse.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useHandleIDPResponse.ts"],"sourcesContent":["import { SetStateAction, useEffect, useRef } from 'react'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { useIDPStateStore } from './useIDPStateStore'\nimport { getBaseHref } from '../utils/getBaseHref'\nimport { IDPStateValue } from '../../types/idp'\nimport { useSignInIDPMutation } from '../../hooks'\nimport { useRedirectToBacklinkCallback } from './useRedirectToBacklink'\n\nexport interface UseHandleIDPResponseProps {\n\tonLogin?: () => void\n\texpiration?: number\n\n\tsetState: (state: SetStateAction<IDPStateValue>) => void\n\thasOauthResponse: boolean\n}\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\n\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const useHandleIDPResponse = ({ onLogin, expiration = DEFAULT_LOGIN_EXPIRATION, setState, hasOauthResponse }: UseHandleIDPResponseProps): void => {\n\tconst idpSignIn = useSignInIDPMutation({ headers })\n\tconst setSessionToken = useSetSessionToken()\n\n\tconst firstRenderRef = useRef(true)\n\n\tconst { get: loadIdpState } = useIDPStateStore()\n\tconst redirectToBackLink = useRedirectToBacklinkCallback()\n\n\tuseEffect(() => {\n\t\tif (!hasOauthResponse || !firstRenderRef.current) {\n\t\t\treturn\n\t\t}\n\t\tfirstRenderRef.current = false\n\t\t;(async () => {\n\t\t\tconst idpState = loadIdpState()\n\t\t\tif (!idpState) {\n\t\t\t\tsetState({ type: 'response_failed', error: 'INVALID_LOCAL_STATE' })\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst response = await idpSignIn({\n\t\t\t\tdata: {\n\t\t\t\t\turl: window.location.href,\n\t\t\t\t\tredirectUrl: getBaseHref(),\n\t\t\t\t\tsessionData: idpState.sessionData,\n\t\t\t\t},\n\t\t\t\tidentityProvider: idpState.provider,\n\t\t\t\texpiration,\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\tsetState({ type: 'response_failed', error: response.error || 'UNKNOWN_ERROR' })\n\t\t\t} else {\n\t\t\t\tsetSessionToken(response.result.token)\n\t\t\t\tsetState({ type: 'success' })\n\n\t\t\t\tonLogin?.()\n\t\t\t\tredirectToBackLink()\n\t\t\t}\n\t\t})()\n\t}, [idpSignIn, onLogin, setSessionToken, hasOauthResponse, loadIdpState, expiration, setState, redirectToBackLink])\n}\n"],"names":["useSignInIDPMutation","useSetSessionToken","useRef","useIDPStateStore","useRedirectToBacklinkCallback","useEffect","getBaseHref"],"mappings":";;;;;;;;AAgBA,MAAM,UAAU;AAAA,EACf,0BAA0B;AAC3B;AAEA,MAAM,2BAA2B,KAAK,KAAK;AAE9B,MAAA,uBAAuB,CAAC,EAAE,SAAS,aAAa,0BAA0B,UAAU,uBAAwD;AACxJ,QAAM,YAAYA,qBAAAA,qBAAqB,EAAE,SAAS;AAClD,QAAM,kBAAkBC,YAAAA,mBAAmB;AAErC,QAAA,iBAAiBC,aAAO,IAAI;AAElC,QAAM,EAAE,KAAK,aAAa,IAAIC,kCAAiB;AAC/C,QAAM,qBAAqBC,sBAAAA,8BAA8B;AAEzDC,QAAAA,UAAU,MAAM;AACf,QAAI,CAAC,oBAAoB,CAAC,eAAe,SAAS;AACjD;AAAA,IAAA;AAED,mBAAe,UAAU;AACxB,KAAC,YAAY;AACb,YAAM,WAAW,aAAa;AAC9B,UAAI,CAAC,UAAU;AACd,iBAAS,EAAE,MAAM,mBAAmB,OAAO,uBAAuB;AAClE;AAAA,MAAA;AAGK,YAAA,WAAW,MAAM,UAAU;AAAA,QAChC,MAAM;AAAA,UACL,KAAK,OAAO,SAAS;AAAA,UACrB,aAAaC,YAAAA,YAAY;AAAA,UACzB,aAAa,SAAS;AAAA,QACvB;AAAA,QACA,kBAAkB,SAAS;AAAA,QAC3B;AAAA,MAAA,CACA;AACG,UAAA,CAAC,SAAS,IAAI;AACjB,iBAAS,EAAE,MAAM,mBAAmB,OAAO,SAAS,SAAS,iBAAiB;AAAA,MAAA,OACxE;AACU,wBAAA,SAAS,OAAO,KAAK;AAC5B,iBAAA,EAAE,MAAM,WAAW;AAElB,kBAAA;AACS,2BAAA;AAAA,MAAA;AAAA,IACpB,GACE;AAAA,EAAA,GACD,CAAC,WAAW,SAAS,iBAAiB,kBAAkB,cAAc,YAAY,UAAU,kBAAkB,CAAC;AACnH;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHandleIDPResponse.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useHandleIDPResponse.ts"],"sourcesContent":["import { SetStateAction, useEffect, useRef } from 'react'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { useIDPStateStore } from './useIDPStateStore'\nimport { getBaseHref } from '../utils/getBaseHref'\nimport { IDPStateValue } from '../../types/idp'\nimport { useSignInIDPMutation } from '../../hooks'\nimport { useRedirectToBacklinkCallback } from './useRedirectToBacklink'\n\nexport interface UseHandleIDPResponseProps {\n\tonLogin?: () => void\n\texpiration?: number\n\n\tsetState: (state: SetStateAction<IDPStateValue>) => void\n\thasOauthResponse: boolean\n}\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\n\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const useHandleIDPResponse = ({ onLogin, expiration = DEFAULT_LOGIN_EXPIRATION, setState, hasOauthResponse }: UseHandleIDPResponseProps): void => {\n\tconst idpSignIn = useSignInIDPMutation({ headers })\n\tconst setSessionToken = useSetSessionToken()\n\n\tconst firstRenderRef = useRef(true)\n\n\tconst { get: loadIdpState } = useIDPStateStore()\n\tconst redirectToBackLink = useRedirectToBacklinkCallback()\n\n\tuseEffect(() => {\n\t\tif (!hasOauthResponse || !firstRenderRef.current) {\n\t\t\treturn\n\t\t}\n\t\tfirstRenderRef.current = false\n\t\t;(async () => {\n\t\t\tconst idpState = loadIdpState()\n\t\t\tif (!idpState) {\n\t\t\t\tsetState({ type: 'response_failed', error: 'INVALID_LOCAL_STATE' })\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst response = await idpSignIn({\n\t\t\t\tdata: {\n\t\t\t\t\turl: window.location.href,\n\t\t\t\t\tredirectUrl: getBaseHref(),\n\t\t\t\t\tsessionData: idpState.sessionData,\n\t\t\t\t},\n\t\t\t\tidentityProvider: idpState.provider,\n\t\t\t\texpiration,\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\tsetState({ type: 'response_failed', error: response.error || 'UNKNOWN_ERROR' })\n\t\t\t} else {\n\t\t\t\tsetSessionToken(response.result.token)\n\t\t\t\tsetState({ type: 'success' })\n\n\t\t\t\tonLogin?.()\n\t\t\t\tredirectToBackLink()\n\t\t\t}\n\t\t})()\n\t}, [idpSignIn, onLogin, setSessionToken, hasOauthResponse, loadIdpState, expiration, setState, redirectToBackLink])\n}\n"],"names":[],"mappings":";;;;;;AAgBA,MAAM,UAAU;AAAA,EACf,0BAA0B;AAC3B;AAEA,MAAM,2BAA2B,KAAK,KAAK;AAE9B,MAAA,uBAAuB,CAAC,EAAE,SAAS,aAAa,0BAA0B,UAAU,uBAAwD;AACxJ,QAAM,YAAY,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"useHandleIDPResponse.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useHandleIDPResponse.ts"],"sourcesContent":["import { SetStateAction, useEffect, useRef } from 'react'\nimport { useSetSessionToken } from '@contember/react-client'\nimport { useIDPStateStore } from './useIDPStateStore'\nimport { getBaseHref } from '../utils/getBaseHref'\nimport { IDPStateValue } from '../../types/idp'\nimport { useSignInIDPMutation } from '../../hooks'\nimport { useRedirectToBacklinkCallback } from './useRedirectToBacklink'\n\nexport interface UseHandleIDPResponseProps {\n\tonLogin?: () => void\n\texpiration?: number\n\n\tsetState: (state: SetStateAction<IDPStateValue>) => void\n\thasOauthResponse: boolean\n}\n\nconst headers = {\n\t'X-Contember-Token-Path': 'data.mutation.result.token',\n}\n\nconst DEFAULT_LOGIN_EXPIRATION = 14 * 24 * 60 // 14 days\n\nexport const useHandleIDPResponse = ({ onLogin, expiration = DEFAULT_LOGIN_EXPIRATION, setState, hasOauthResponse }: UseHandleIDPResponseProps): void => {\n\tconst idpSignIn = useSignInIDPMutation({ headers })\n\tconst setSessionToken = useSetSessionToken()\n\n\tconst firstRenderRef = useRef(true)\n\n\tconst { get: loadIdpState } = useIDPStateStore()\n\tconst redirectToBackLink = useRedirectToBacklinkCallback()\n\n\tuseEffect(() => {\n\t\tif (!hasOauthResponse || !firstRenderRef.current) {\n\t\t\treturn\n\t\t}\n\t\tfirstRenderRef.current = false\n\t\t;(async () => {\n\t\t\tconst idpState = loadIdpState()\n\t\t\tif (!idpState) {\n\t\t\t\tsetState({ type: 'response_failed', error: 'INVALID_LOCAL_STATE' })\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tconst response = await idpSignIn({\n\t\t\t\tdata: {\n\t\t\t\t\turl: window.location.href,\n\t\t\t\t\tredirectUrl: getBaseHref(),\n\t\t\t\t\tsessionData: idpState.sessionData,\n\t\t\t\t},\n\t\t\t\tidentityProvider: idpState.provider,\n\t\t\t\texpiration,\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\tsetState({ type: 'response_failed', error: response.error || 'UNKNOWN_ERROR' })\n\t\t\t} else {\n\t\t\t\tsetSessionToken(response.result.token)\n\t\t\t\tsetState({ type: 'success' })\n\n\t\t\t\tonLogin?.()\n\t\t\t\tredirectToBackLink()\n\t\t\t}\n\t\t})()\n\t}, [idpSignIn, onLogin, setSessionToken, hasOauthResponse, loadIdpState, expiration, setState, redirectToBackLink])\n}\n"],"names":[],"mappings":";;;;;;AAgBA,MAAM,UAAU;AAAA,EACf,0BAA0B;AAC3B;AAEA,MAAM,2BAA2B,KAAK,KAAK;AAE9B,MAAA,uBAAuB,CAAC,EAAE,SAAS,aAAa,0BAA0B,UAAU,uBAAwD;AACxJ,QAAM,YAAY,qBAAqB,EAAE,SAAS;AAClD,QAAM,kBAAkB,mBAAmB;AAErC,QAAA,iBAAiB,OAAO,IAAI;AAElC,QAAM,EAAE,KAAK,aAAa,IAAI,iBAAiB;AAC/C,QAAM,qBAAqB,8BAA8B;AAEzD,YAAU,MAAM;AACf,QAAI,CAAC,oBAAoB,CAAC,eAAe,SAAS;AACjD;AAAA,IAAA;AAED,mBAAe,UAAU;AACxB,KAAC,YAAY;AACb,YAAM,WAAW,aAAa;AAC9B,UAAI,CAAC,UAAU;AACd,iBAAS,EAAE,MAAM,mBAAmB,OAAO,uBAAuB;AAClE;AAAA,MAAA;AAGK,YAAA,WAAW,MAAM,UAAU;AAAA,QAChC,MAAM;AAAA,UACL,KAAK,OAAO,SAAS;AAAA,UACrB,aAAa,YAAY;AAAA,UACzB,aAAa,SAAS;AAAA,QACvB;AAAA,QACA,kBAAkB,SAAS;AAAA,QAC3B;AAAA,MAAA,CACA;AACG,UAAA,CAAC,SAAS,IAAI;AACjB,iBAAS,EAAE,MAAM,mBAAmB,OAAO,SAAS,SAAS,iBAAiB;AAAA,MAAA,OACxE;AACU,wBAAA,SAAS,OAAO,KAAK;AAC5B,iBAAA,EAAE,MAAM,WAAW;AAElB,kBAAA;AACS,2BAAA;AAAA,MAAA;AAAA,IACpB,GACE;AAAA,EAAA,GACD,CAAC,WAAW,SAAS,iBAAiB,kBAAkB,cAAc,YAAY,UAAU,kBAAkB,CAAC;AACnH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIDPAutoInit.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useIDPAutoInit.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nexport const useIDPAutoInitProvider = () => {\n\treturn useMemo(() => {\n\t\tconst params = new URLSearchParams(window.location.search)\n\t\tconst idp = params.get('idp')\n\t\tif (idp !== null) {\n\t\t\treturn idp\n\t\t}\n\t\tconst backlink = params.get('backlink')\n\n\t\tif (backlink !== null) {\n\t\t\tconst resolvedBacklink = new URL(backlink, window.location.href)\n\t\t\treturn resolvedBacklink.searchParams.get('idp')\n\t\t}\n\t}, [])\n}\n\n"],"names":["useMemo"],"mappings":";;;AAEO,MAAM,yBAAyB,MAAM;AAC3C,SAAOA,cAAQ,MAAM;AACpB,UAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACnD,UAAA,MAAM,OAAO,IAAI,KAAK;AAC5B,QAAI,QAAQ,MAAM;AACV,aAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"useIDPAutoInit.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useIDPAutoInit.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nexport const useIDPAutoInitProvider = () => {\n\treturn useMemo(() => {\n\t\tconst params = new URLSearchParams(window.location.search)\n\t\tconst idp = params.get('idp')\n\t\tif (idp !== null) {\n\t\t\treturn idp\n\t\t}\n\t\tconst backlink = params.get('backlink')\n\n\t\tif (backlink !== null) {\n\t\t\tconst resolvedBacklink = new URL(backlink, window.location.href)\n\t\t\treturn resolvedBacklink.searchParams.get('idp')\n\t\t}\n\t}, [])\n}\n\n"],"names":["useMemo"],"mappings":";;;AAEO,MAAM,yBAAyB,MAAM;AAC3C,SAAOA,cAAQ,MAAM;AACpB,UAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACnD,UAAA,MAAM,OAAO,IAAI,KAAK;AAC5B,QAAI,QAAQ,MAAM;AACV,aAAA;AAAA,IAAA;AAEF,UAAA,WAAW,OAAO,IAAI,UAAU;AAEtC,QAAI,aAAa,MAAM;AACtB,YAAM,mBAAmB,IAAI,IAAI,UAAU,OAAO,SAAS,IAAI;AACxD,aAAA,iBAAiB,aAAa,IAAI,KAAK;AAAA,IAAA;AAAA,EAEhD,GAAG,EAAE;AACN;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIDPAutoInit.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useIDPAutoInit.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nexport const useIDPAutoInitProvider = () => {\n\treturn useMemo(() => {\n\t\tconst params = new URLSearchParams(window.location.search)\n\t\tconst idp = params.get('idp')\n\t\tif (idp !== null) {\n\t\t\treturn idp\n\t\t}\n\t\tconst backlink = params.get('backlink')\n\n\t\tif (backlink !== null) {\n\t\t\tconst resolvedBacklink = new URL(backlink, window.location.href)\n\t\t\treturn resolvedBacklink.searchParams.get('idp')\n\t\t}\n\t}, [])\n}\n\n"],"names":[],"mappings":";AAEO,MAAM,yBAAyB,MAAM;AAC3C,SAAO,QAAQ,MAAM;AACpB,UAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACnD,UAAA,MAAM,OAAO,IAAI,KAAK;AAC5B,QAAI,QAAQ,MAAM;AACV,aAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"useIDPAutoInit.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useIDPAutoInit.ts"],"sourcesContent":["import { useMemo } from 'react'\n\nexport const useIDPAutoInitProvider = () => {\n\treturn useMemo(() => {\n\t\tconst params = new URLSearchParams(window.location.search)\n\t\tconst idp = params.get('idp')\n\t\tif (idp !== null) {\n\t\t\treturn idp\n\t\t}\n\t\tconst backlink = params.get('backlink')\n\n\t\tif (backlink !== null) {\n\t\t\tconst resolvedBacklink = new URL(backlink, window.location.href)\n\t\t\treturn resolvedBacklink.searchParams.get('idp')\n\t\t}\n\t}, [])\n}\n\n"],"names":[],"mappings":";AAEO,MAAM,yBAAyB,MAAM;AAC3C,SAAO,QAAQ,MAAM;AACpB,UAAM,SAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM;AACnD,UAAA,MAAM,OAAO,IAAI,KAAK;AAC5B,QAAI,QAAQ,MAAM;AACV,aAAA;AAAA,IAAA;AAEF,UAAA,WAAW,OAAO,IAAI,UAAU;AAEtC,QAAI,aAAa,MAAM;AACtB,YAAM,mBAAmB,IAAI,IAAI,UAAU,OAAO,SAAS,IAAI;AACxD,aAAA,iBAAiB,aAAa,IAAI,KAAK;AAAA,IAAA;AAAA,EAEhD,GAAG,EAAE;AACN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIDPStateStore.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useIDPStateStore.ts"],"sourcesContent":["import { useCallback } from 'react'\n\nexport type IDPState = { provider: string; sessionData: any }\n\nexport const useIDPStateStore = (): {get: () => IDPState | null; set: (state: IDPState) => void} => {\n\treturn {\n\t\tget: useCallback(() => {\n\t\t\tconst item = sessionStorage.getItem('idp')\n\t\t\tif (!item) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn JSON.parse(item)\n\t\t}, []),\n\t\tset: useCallback((state: IDPState) => {\n\t\t\tsessionStorage.setItem('idp', JSON.stringify(state))\n\t\t}, []),\n\t}\n}\n"],"names":["useCallback"],"mappings":";;;AAIO,MAAM,mBAAmB,MAAoE;AAC5F,SAAA;AAAA,IACN,KAAKA,kBAAY,MAAM;AAChB,YAAA,OAAO,eAAe,QAAQ,KAAK;AACzC,UAAI,CAAC,MAAM;AACH,eAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"useIDPStateStore.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useIDPStateStore.ts"],"sourcesContent":["import { useCallback } from 'react'\n\nexport type IDPState = { provider: string; sessionData: any }\n\nexport const useIDPStateStore = (): {get: () => IDPState | null; set: (state: IDPState) => void} => {\n\treturn {\n\t\tget: useCallback(() => {\n\t\t\tconst item = sessionStorage.getItem('idp')\n\t\t\tif (!item) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn JSON.parse(item)\n\t\t}, []),\n\t\tset: useCallback((state: IDPState) => {\n\t\t\tsessionStorage.setItem('idp', JSON.stringify(state))\n\t\t}, []),\n\t}\n}\n"],"names":["useCallback"],"mappings":";;;AAIO,MAAM,mBAAmB,MAAoE;AAC5F,SAAA;AAAA,IACN,KAAKA,kBAAY,MAAM;AAChB,YAAA,OAAO,eAAe,QAAQ,KAAK;AACzC,UAAI,CAAC,MAAM;AACH,eAAA;AAAA,MAAA;AAED,aAAA,KAAK,MAAM,IAAI;AAAA,IACvB,GAAG,EAAE;AAAA,IACL,KAAKA,MAAAA,YAAY,CAAC,UAAoB;AACrC,qBAAe,QAAQ,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,IAAA,GACjD,CAAE,CAAA;AAAA,EACN;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIDPStateStore.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useIDPStateStore.ts"],"sourcesContent":["import { useCallback } from 'react'\n\nexport type IDPState = { provider: string; sessionData: any }\n\nexport const useIDPStateStore = (): {get: () => IDPState | null; set: (state: IDPState) => void} => {\n\treturn {\n\t\tget: useCallback(() => {\n\t\t\tconst item = sessionStorage.getItem('idp')\n\t\t\tif (!item) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn JSON.parse(item)\n\t\t}, []),\n\t\tset: useCallback((state: IDPState) => {\n\t\t\tsessionStorage.setItem('idp', JSON.stringify(state))\n\t\t}, []),\n\t}\n}\n"],"names":[],"mappings":";AAIO,MAAM,mBAAmB,MAAoE;AAC5F,SAAA;AAAA,IACN,KAAK,YAAY,MAAM;AAChB,YAAA,OAAO,eAAe,QAAQ,KAAK;AACzC,UAAI,CAAC,MAAM;AACH,eAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"useIDPStateStore.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useIDPStateStore.ts"],"sourcesContent":["import { useCallback } from 'react'\n\nexport type IDPState = { provider: string; sessionData: any }\n\nexport const useIDPStateStore = (): {get: () => IDPState | null; set: (state: IDPState) => void} => {\n\treturn {\n\t\tget: useCallback(() => {\n\t\t\tconst item = sessionStorage.getItem('idp')\n\t\t\tif (!item) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\treturn JSON.parse(item)\n\t\t}, []),\n\t\tset: useCallback((state: IDPState) => {\n\t\t\tsessionStorage.setItem('idp', JSON.stringify(state))\n\t\t}, []),\n\t}\n}\n"],"names":[],"mappings":";AAIO,MAAM,mBAAmB,MAAoE;AAC5F,SAAA;AAAA,IACN,KAAK,YAAY,MAAM;AAChB,YAAA,OAAO,eAAe,QAAQ,KAAK;AACzC,UAAI,CAAC,MAAM;AACH,eAAA;AAAA,MAAA;AAED,aAAA,KAAK,MAAM,IAAI;AAAA,IACvB,GAAG,EAAE;AAAA,IACL,KAAK,YAAY,CAAC,UAAoB;AACrC,qBAAe,QAAQ,OAAO,KAAK,UAAU,KAAK,CAAC;AAAA,IAAA,GACjD,CAAE,CAAA;AAAA,EACN;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitIDPRedirect.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useInitIDPRedirect.ts"],"sourcesContent":["import { SetStateAction, useCallback } from 'react'\nimport { useIDPStateStore } from './useIDPStateStore'\nimport { getBaseHref } from '../utils/getBaseHref'\nimport { IDPInitError, IDPStateValue } from '../../types/idp'\nimport { useInitSignInIDPMutation } from '../../hooks'\nimport { useSaveBacklink } from './useRedirectToBacklink'\n\nexport interface UseInitIDPRedirectProps {\n\tonRedirect?: (url: string) => void\n\tsetState: (state: SetStateAction<IDPStateValue>) => void\n}\n\nexport const useInitIDPRedirect = ({ onRedirect, setState }: UseInitIDPRedirectProps) => {\n\tconst initRequest = useInitSignInIDPMutation()\n\tconst saveBacklink = useSaveBacklink()\n\tconst { set: saveIdpState } = useIDPStateStore()\n\n\treturn useCallback(async ({ provider }: { provider: string }): Promise<{ ok: true } | { ok: false; error: IDPInitError }> => {\n\t\tconst fail = (error: IDPInitError) => {\n\t\t\tsetState({ type: 'init_failed', error })\n\t\t\treturn { ok: false, error }\n\t\t}\n\t\ttry {\n\t\t\tsetState({ type: 'processing_init' })\n\t\t\tconst response = await initRequest({\n\t\t\t\tdata: {\n\t\t\t\t\tredirectUrl: getBaseHref(),\n\t\t\t\t},\n\t\t\t\tidentityProvider: provider,\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\treturn fail(response.error || 'UNKNOWN_ERROR')\n\t\t\t} else {\n\t\t\t\tsaveIdpState({ provider, sessionData: response.result.sessionData as string })\n\t\t\t\tsaveBacklink()\n\t\t\t\tif (onRedirect) {\n\t\t\t\t\tonRedirect(response.result.authUrl as string)\n\t\t\t\t} else {\n\t\t\t\t\twindow.location.href = response.result.authUrl as string\n\t\t\t\t}\n\t\t\t\treturn { ok: true }\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn fail('UNKNOWN_ERROR')\n\t\t}\n\t}, [initRequest, onRedirect, saveBacklink, saveIdpState, setState])\n}\n"],"names":["useInitSignInIDPMutation","useSaveBacklink","useIDPStateStore","useCallback","getBaseHref"],"mappings":";;;;;;;AAYO,MAAM,qBAAqB,CAAC,EAAE,YAAY,eAAwC;AACxF,QAAM,cAAcA,yBAAAA;
|
|
1
|
+
{"version":3,"file":"useInitIDPRedirect.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useInitIDPRedirect.ts"],"sourcesContent":["import { SetStateAction, useCallback } from 'react'\nimport { useIDPStateStore } from './useIDPStateStore'\nimport { getBaseHref } from '../utils/getBaseHref'\nimport { IDPInitError, IDPStateValue } from '../../types/idp'\nimport { useInitSignInIDPMutation } from '../../hooks'\nimport { useSaveBacklink } from './useRedirectToBacklink'\n\nexport interface UseInitIDPRedirectProps {\n\tonRedirect?: (url: string) => void\n\tsetState: (state: SetStateAction<IDPStateValue>) => void\n}\n\nexport const useInitIDPRedirect = ({ onRedirect, setState }: UseInitIDPRedirectProps) => {\n\tconst initRequest = useInitSignInIDPMutation()\n\tconst saveBacklink = useSaveBacklink()\n\tconst { set: saveIdpState } = useIDPStateStore()\n\n\treturn useCallback(async ({ provider }: { provider: string }): Promise<{ ok: true } | { ok: false; error: IDPInitError }> => {\n\t\tconst fail = (error: IDPInitError) => {\n\t\t\tsetState({ type: 'init_failed', error })\n\t\t\treturn { ok: false, error }\n\t\t}\n\t\ttry {\n\t\t\tsetState({ type: 'processing_init' })\n\t\t\tconst response = await initRequest({\n\t\t\t\tdata: {\n\t\t\t\t\tredirectUrl: getBaseHref(),\n\t\t\t\t},\n\t\t\t\tidentityProvider: provider,\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\treturn fail(response.error || 'UNKNOWN_ERROR')\n\t\t\t} else {\n\t\t\t\tsaveIdpState({ provider, sessionData: response.result.sessionData as string })\n\t\t\t\tsaveBacklink()\n\t\t\t\tif (onRedirect) {\n\t\t\t\t\tonRedirect(response.result.authUrl as string)\n\t\t\t\t} else {\n\t\t\t\t\twindow.location.href = response.result.authUrl as string\n\t\t\t\t}\n\t\t\t\treturn { ok: true }\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn fail('UNKNOWN_ERROR')\n\t\t}\n\t}, [initRequest, onRedirect, saveBacklink, saveIdpState, setState])\n}\n"],"names":["useInitSignInIDPMutation","useSaveBacklink","useIDPStateStore","useCallback","getBaseHref"],"mappings":";;;;;;;AAYO,MAAM,qBAAqB,CAAC,EAAE,YAAY,eAAwC;AACxF,QAAM,cAAcA,yBAAAA,yBAAyB;AAC7C,QAAM,eAAeC,sBAAAA,gBAAgB;AACrC,QAAM,EAAE,KAAK,aAAa,IAAIC,kCAAiB;AAE/C,SAAOC,MAAY,YAAA,OAAO,EAAE,eAAiG;AACtH,UAAA,OAAO,CAAC,UAAwB;AACrC,eAAS,EAAE,MAAM,eAAe,MAAA,CAAO;AAChC,aAAA,EAAE,IAAI,OAAO,MAAM;AAAA,IAC3B;AACI,QAAA;AACM,eAAA,EAAE,MAAM,mBAAmB;AAC9B,YAAA,WAAW,MAAM,YAAY;AAAA,QAClC,MAAM;AAAA,UACL,aAAaC,YAAY,YAAA;AAAA,QAC1B;AAAA,QACA,kBAAkB;AAAA,MAAA,CAClB;AACG,UAAA,CAAC,SAAS,IAAI;AACV,eAAA,KAAK,SAAS,SAAS,eAAe;AAAA,MAAA,OACvC;AACN,qBAAa,EAAE,UAAU,aAAa,SAAS,OAAO,aAAuB;AAChE,qBAAA;AACb,YAAI,YAAY;AACJ,qBAAA,SAAS,OAAO,OAAiB;AAAA,QAAA,OACtC;AACC,iBAAA,SAAS,OAAO,SAAS,OAAO;AAAA,QAAA;AAEjC,eAAA,EAAE,IAAI,KAAK;AAAA,MAAA;AAAA,aAEX,GAAG;AACX,cAAQ,MAAM,CAAC;AACf,aAAO,KAAK,eAAe;AAAA,IAAA;AAAA,EAC5B,GACE,CAAC,aAAa,YAAY,cAAc,cAAc,QAAQ,CAAC;AACnE;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitIDPRedirect.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useInitIDPRedirect.ts"],"sourcesContent":["import { SetStateAction, useCallback } from 'react'\nimport { useIDPStateStore } from './useIDPStateStore'\nimport { getBaseHref } from '../utils/getBaseHref'\nimport { IDPInitError, IDPStateValue } from '../../types/idp'\nimport { useInitSignInIDPMutation } from '../../hooks'\nimport { useSaveBacklink } from './useRedirectToBacklink'\n\nexport interface UseInitIDPRedirectProps {\n\tonRedirect?: (url: string) => void\n\tsetState: (state: SetStateAction<IDPStateValue>) => void\n}\n\nexport const useInitIDPRedirect = ({ onRedirect, setState }: UseInitIDPRedirectProps) => {\n\tconst initRequest = useInitSignInIDPMutation()\n\tconst saveBacklink = useSaveBacklink()\n\tconst { set: saveIdpState } = useIDPStateStore()\n\n\treturn useCallback(async ({ provider }: { provider: string }): Promise<{ ok: true } | { ok: false; error: IDPInitError }> => {\n\t\tconst fail = (error: IDPInitError) => {\n\t\t\tsetState({ type: 'init_failed', error })\n\t\t\treturn { ok: false, error }\n\t\t}\n\t\ttry {\n\t\t\tsetState({ type: 'processing_init' })\n\t\t\tconst response = await initRequest({\n\t\t\t\tdata: {\n\t\t\t\t\tredirectUrl: getBaseHref(),\n\t\t\t\t},\n\t\t\t\tidentityProvider: provider,\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\treturn fail(response.error || 'UNKNOWN_ERROR')\n\t\t\t} else {\n\t\t\t\tsaveIdpState({ provider, sessionData: response.result.sessionData as string })\n\t\t\t\tsaveBacklink()\n\t\t\t\tif (onRedirect) {\n\t\t\t\t\tonRedirect(response.result.authUrl as string)\n\t\t\t\t} else {\n\t\t\t\t\twindow.location.href = response.result.authUrl as string\n\t\t\t\t}\n\t\t\t\treturn { ok: true }\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn fail('UNKNOWN_ERROR')\n\t\t}\n\t}, [initRequest, onRedirect, saveBacklink, saveIdpState, setState])\n}\n"],"names":[],"mappings":";;;;;AAYO,MAAM,qBAAqB,CAAC,EAAE,YAAY,eAAwC;AACxF,QAAM,cAAc;
|
|
1
|
+
{"version":3,"file":"useInitIDPRedirect.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useInitIDPRedirect.ts"],"sourcesContent":["import { SetStateAction, useCallback } from 'react'\nimport { useIDPStateStore } from './useIDPStateStore'\nimport { getBaseHref } from '../utils/getBaseHref'\nimport { IDPInitError, IDPStateValue } from '../../types/idp'\nimport { useInitSignInIDPMutation } from '../../hooks'\nimport { useSaveBacklink } from './useRedirectToBacklink'\n\nexport interface UseInitIDPRedirectProps {\n\tonRedirect?: (url: string) => void\n\tsetState: (state: SetStateAction<IDPStateValue>) => void\n}\n\nexport const useInitIDPRedirect = ({ onRedirect, setState }: UseInitIDPRedirectProps) => {\n\tconst initRequest = useInitSignInIDPMutation()\n\tconst saveBacklink = useSaveBacklink()\n\tconst { set: saveIdpState } = useIDPStateStore()\n\n\treturn useCallback(async ({ provider }: { provider: string }): Promise<{ ok: true } | { ok: false; error: IDPInitError }> => {\n\t\tconst fail = (error: IDPInitError) => {\n\t\t\tsetState({ type: 'init_failed', error })\n\t\t\treturn { ok: false, error }\n\t\t}\n\t\ttry {\n\t\t\tsetState({ type: 'processing_init' })\n\t\t\tconst response = await initRequest({\n\t\t\t\tdata: {\n\t\t\t\t\tredirectUrl: getBaseHref(),\n\t\t\t\t},\n\t\t\t\tidentityProvider: provider,\n\t\t\t})\n\t\t\tif (!response.ok) {\n\t\t\t\treturn fail(response.error || 'UNKNOWN_ERROR')\n\t\t\t} else {\n\t\t\t\tsaveIdpState({ provider, sessionData: response.result.sessionData as string })\n\t\t\t\tsaveBacklink()\n\t\t\t\tif (onRedirect) {\n\t\t\t\t\tonRedirect(response.result.authUrl as string)\n\t\t\t\t} else {\n\t\t\t\t\twindow.location.href = response.result.authUrl as string\n\t\t\t\t}\n\t\t\t\treturn { ok: true }\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn fail('UNKNOWN_ERROR')\n\t\t}\n\t}, [initRequest, onRedirect, saveBacklink, saveIdpState, setState])\n}\n"],"names":[],"mappings":";;;;;AAYO,MAAM,qBAAqB,CAAC,EAAE,YAAY,eAAwC;AACxF,QAAM,cAAc,yBAAyB;AAC7C,QAAM,eAAe,gBAAgB;AACrC,QAAM,EAAE,KAAK,aAAa,IAAI,iBAAiB;AAE/C,SAAO,YAAY,OAAO,EAAE,eAAiG;AACtH,UAAA,OAAO,CAAC,UAAwB;AACrC,eAAS,EAAE,MAAM,eAAe,MAAA,CAAO;AAChC,aAAA,EAAE,IAAI,OAAO,MAAM;AAAA,IAC3B;AACI,QAAA;AACM,eAAA,EAAE,MAAM,mBAAmB;AAC9B,YAAA,WAAW,MAAM,YAAY;AAAA,QAClC,MAAM;AAAA,UACL,aAAa,YAAY;AAAA,QAC1B;AAAA,QACA,kBAAkB;AAAA,MAAA,CAClB;AACG,UAAA,CAAC,SAAS,IAAI;AACV,eAAA,KAAK,SAAS,SAAS,eAAe;AAAA,MAAA,OACvC;AACN,qBAAa,EAAE,UAAU,aAAa,SAAS,OAAO,aAAuB;AAChE,qBAAA;AACb,YAAI,YAAY;AACJ,qBAAA,SAAS,OAAO,OAAiB;AAAA,QAAA,OACtC;AACC,iBAAA,SAAS,OAAO,SAAS,OAAO;AAAA,QAAA;AAEjC,eAAA,EAAE,IAAI,KAAK;AAAA,MAAA;AAAA,aAEX,GAAG;AACX,cAAQ,MAAM,CAAC;AACf,aAAO,KAAK,eAAe;AAAA,IAAA;AAAA,EAC5B,GACE,CAAC,aAAa,YAAY,cAAc,cAAc,QAAQ,CAAC;AACnE;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLogoutInternal.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useLogoutInternal.ts"],"sourcesContent":["import { useSetSessionToken } from '@contember/react-client'\nimport { useCallback } from 'react'\nimport { useSignOutMutation } from '../../hooks'\n\nexport const useLogoutInternal = (clearIdentity?: () => void) => {\n\tconst tenantLogout = useSignOutMutation()\n\tconst setSessionToken = useSetSessionToken()\n\n\treturn useCallback(\n\t\tasync ({ noRedirect = false }: { noRedirect?: boolean } = {}) => {\n\t\t\tif (navigator.credentials && navigator.credentials.preventSilentAccess) {\n\t\t\t\ttry {\n\t\t\t\t\tawait navigator.credentials.preventSilentAccess()\n\t\t\t\t} catch {\n\t\t\t\t\t// actually, not implemented in safari:\n\t\t\t\t\t// https://github.com/WebKit/WebKit/blob/414f4e45b0e82bbfcee783d08a9642be1afa8f72/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp#L132\n\t\t\t\t}\n\t\t\t}\n\t\t\tclearIdentity?.()\n\t\t\tsetSessionToken(undefined)\n\t\t\ttry {\n\t\t\t\tconst response = await tenantLogout({})\n\t\t\t\tif (!response?.ok) {\n\t\t\t\t\tconsole.warn(response?.error)\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.warn(e)\n\t\t\t}\n\t\t\tif (!noRedirect) {\n\t\t\t\twindow.location.href = '/' // todo better redirect?\n\t\t\t}\n\t\t},\n\t\t[clearIdentity, setSessionToken, tenantLogout],\n\t)\n}\n"],"names":["useSignOutMutation","useSetSessionToken","useCallback"],"mappings":";;;;;AAIa,MAAA,oBAAoB,CAAC,kBAA+B;AAChE,QAAM,eAAeA,mBAAAA;
|
|
1
|
+
{"version":3,"file":"useLogoutInternal.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useLogoutInternal.ts"],"sourcesContent":["import { useSetSessionToken } from '@contember/react-client'\nimport { useCallback } from 'react'\nimport { useSignOutMutation } from '../../hooks'\n\nexport const useLogoutInternal = (clearIdentity?: () => void) => {\n\tconst tenantLogout = useSignOutMutation()\n\tconst setSessionToken = useSetSessionToken()\n\n\treturn useCallback(\n\t\tasync ({ noRedirect = false }: { noRedirect?: boolean } = {}) => {\n\t\t\tif (navigator.credentials && navigator.credentials.preventSilentAccess) {\n\t\t\t\ttry {\n\t\t\t\t\tawait navigator.credentials.preventSilentAccess()\n\t\t\t\t} catch {\n\t\t\t\t\t// actually, not implemented in safari:\n\t\t\t\t\t// https://github.com/WebKit/WebKit/blob/414f4e45b0e82bbfcee783d08a9642be1afa8f72/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp#L132\n\t\t\t\t}\n\t\t\t}\n\t\t\tclearIdentity?.()\n\t\t\tsetSessionToken(undefined)\n\t\t\ttry {\n\t\t\t\tconst response = await tenantLogout({})\n\t\t\t\tif (!response?.ok) {\n\t\t\t\t\tconsole.warn(response?.error)\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.warn(e)\n\t\t\t}\n\t\t\tif (!noRedirect) {\n\t\t\t\twindow.location.href = '/' // todo better redirect?\n\t\t\t}\n\t\t},\n\t\t[clearIdentity, setSessionToken, tenantLogout],\n\t)\n}\n"],"names":["useSignOutMutation","useSetSessionToken","useCallback"],"mappings":";;;;;AAIa,MAAA,oBAAoB,CAAC,kBAA+B;AAChE,QAAM,eAAeA,mBAAAA,mBAAmB;AACxC,QAAM,kBAAkBC,YAAAA,mBAAmB;AAEpC,SAAAC,MAAA;AAAA,IACN,OAAO,EAAE,aAAa,MAAM,IAA8B,OAAO;AAChE,UAAI,UAAU,eAAe,UAAU,YAAY,qBAAqB;AACnE,YAAA;AACG,gBAAA,UAAU,YAAY,oBAAoB;AAAA,QAAA,QACzC;AAAA,QAAA;AAAA,MAGR;AAEe,sBAAA;AAChB,sBAAgB,MAAS;AACrB,UAAA;AACH,cAAM,WAAW,MAAM,aAAa,EAAE;AAClC,YAAA,CAAC,UAAU,IAAI;AACV,kBAAA,KAAK,UAAU,KAAK;AAAA,QAAA;AAAA,eAErB,GAAG;AACX,gBAAQ,KAAK,CAAC;AAAA,MAAA;AAEf,UAAI,CAAC,YAAY;AAChB,eAAO,SAAS,OAAO;AAAA,MAAA;AAAA,IAEzB;AAAA,IACA,CAAC,eAAe,iBAAiB,YAAY;AAAA,EAC9C;AACD;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLogoutInternal.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useLogoutInternal.ts"],"sourcesContent":["import { useSetSessionToken } from '@contember/react-client'\nimport { useCallback } from 'react'\nimport { useSignOutMutation } from '../../hooks'\n\nexport const useLogoutInternal = (clearIdentity?: () => void) => {\n\tconst tenantLogout = useSignOutMutation()\n\tconst setSessionToken = useSetSessionToken()\n\n\treturn useCallback(\n\t\tasync ({ noRedirect = false }: { noRedirect?: boolean } = {}) => {\n\t\t\tif (navigator.credentials && navigator.credentials.preventSilentAccess) {\n\t\t\t\ttry {\n\t\t\t\t\tawait navigator.credentials.preventSilentAccess()\n\t\t\t\t} catch {\n\t\t\t\t\t// actually, not implemented in safari:\n\t\t\t\t\t// https://github.com/WebKit/WebKit/blob/414f4e45b0e82bbfcee783d08a9642be1afa8f72/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp#L132\n\t\t\t\t}\n\t\t\t}\n\t\t\tclearIdentity?.()\n\t\t\tsetSessionToken(undefined)\n\t\t\ttry {\n\t\t\t\tconst response = await tenantLogout({})\n\t\t\t\tif (!response?.ok) {\n\t\t\t\t\tconsole.warn(response?.error)\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.warn(e)\n\t\t\t}\n\t\t\tif (!noRedirect) {\n\t\t\t\twindow.location.href = '/' // todo better redirect?\n\t\t\t}\n\t\t},\n\t\t[clearIdentity, setSessionToken, tenantLogout],\n\t)\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,oBAAoB,CAAC,kBAA+B;AAChE,QAAM,eAAe;
|
|
1
|
+
{"version":3,"file":"useLogoutInternal.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useLogoutInternal.ts"],"sourcesContent":["import { useSetSessionToken } from '@contember/react-client'\nimport { useCallback } from 'react'\nimport { useSignOutMutation } from '../../hooks'\n\nexport const useLogoutInternal = (clearIdentity?: () => void) => {\n\tconst tenantLogout = useSignOutMutation()\n\tconst setSessionToken = useSetSessionToken()\n\n\treturn useCallback(\n\t\tasync ({ noRedirect = false }: { noRedirect?: boolean } = {}) => {\n\t\t\tif (navigator.credentials && navigator.credentials.preventSilentAccess) {\n\t\t\t\ttry {\n\t\t\t\t\tawait navigator.credentials.preventSilentAccess()\n\t\t\t\t} catch {\n\t\t\t\t\t// actually, not implemented in safari:\n\t\t\t\t\t// https://github.com/WebKit/WebKit/blob/414f4e45b0e82bbfcee783d08a9642be1afa8f72/Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp#L132\n\t\t\t\t}\n\t\t\t}\n\t\t\tclearIdentity?.()\n\t\t\tsetSessionToken(undefined)\n\t\t\ttry {\n\t\t\t\tconst response = await tenantLogout({})\n\t\t\t\tif (!response?.ok) {\n\t\t\t\t\tconsole.warn(response?.error)\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\tconsole.warn(e)\n\t\t\t}\n\t\t\tif (!noRedirect) {\n\t\t\t\twindow.location.href = '/' // todo better redirect?\n\t\t\t}\n\t\t},\n\t\t[clearIdentity, setSessionToken, tenantLogout],\n\t)\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,oBAAoB,CAAC,kBAA+B;AAChE,QAAM,eAAe,mBAAmB;AACxC,QAAM,kBAAkB,mBAAmB;AAEpC,SAAA;AAAA,IACN,OAAO,EAAE,aAAa,MAAM,IAA8B,OAAO;AAChE,UAAI,UAAU,eAAe,UAAU,YAAY,qBAAqB;AACnE,YAAA;AACG,gBAAA,UAAU,YAAY,oBAAoB;AAAA,QAAA,QACzC;AAAA,QAAA;AAAA,MAGR;AAEe,sBAAA;AAChB,sBAAgB,MAAS;AACrB,UAAA;AACH,cAAM,WAAW,MAAM,aAAa,EAAE;AAClC,YAAA,CAAC,UAAU,IAAI;AACV,kBAAA,KAAK,UAAU,KAAK;AAAA,QAAA;AAAA,eAErB,GAAG;AACX,gBAAQ,KAAK,CAAC;AAAA,MAAA;AAEf,UAAI,CAAC,YAAY;AAChB,eAAO,SAAS,OAAO;AAAA,MAAA;AAAA,IAEzB;AAAA,IACA,CAAC,eAAe,iBAAiB,YAAY;AAAA,EAC9C;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedirectToBacklink.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useRedirectToBacklink.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useIdentity } from '../../contexts'\n\nconst getBacklinkFromUrl = () => {\n\treturn new URLSearchParams(window.location.search).get('backlink')\n}\n\nexport const useSaveBacklink = () => {\n\treturn useCallback(() => {\n\t\tconst backlink = getBacklinkFromUrl()\n\t\tif (!backlink) {\n\t\t\treturn\n\t\t}\n\t\tsessionStorage.setItem('backlink', backlink)\n\t}, [])\n}\n\nexport const useRedirectToBacklinkCallback = () => {\n\treturn useCallback(() => {\n\t\tconst backlink = getBacklinkFromUrl() ?? sessionStorage.getItem('backlink')\n\t\tif (!backlink) {\n\t\t\treturn\n\t\t}\n\t\tsessionStorage.removeItem('backlink')\n\t\tconst resolvedBacklink = new URL(backlink, window.location.href)\n\t\tif (resolvedBacklink.origin === window.location.origin) {\n\t\t\twindow.location.href = resolvedBacklink.toString()\n\t\t}\n\t}, [])\n}\n\nexport const useRedirectToBacklink = () => {\n\tconst identity = useIdentity()\n\tconst redirect = useRedirectToBacklinkCallback()\n\tuseEffect(() => {\n\t\tif (!identity) {\n\t\t\treturn\n\t\t}\n\t\tredirect()\n\t}, [identity, redirect])\n\n}\n"],"names":["useCallback"],"mappings":";;;AAGA,MAAM,qBAAqB,MAAM;AAChC,SAAO,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,UAAU;AAClE;AAEO,MAAM,kBAAkB,MAAM;AACpC,SAAOA,kBAAY,MAAM;AACxB,UAAM,WAAW;
|
|
1
|
+
{"version":3,"file":"useRedirectToBacklink.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useRedirectToBacklink.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useIdentity } from '../../contexts'\n\nconst getBacklinkFromUrl = () => {\n\treturn new URLSearchParams(window.location.search).get('backlink')\n}\n\nexport const useSaveBacklink = () => {\n\treturn useCallback(() => {\n\t\tconst backlink = getBacklinkFromUrl()\n\t\tif (!backlink) {\n\t\t\treturn\n\t\t}\n\t\tsessionStorage.setItem('backlink', backlink)\n\t}, [])\n}\n\nexport const useRedirectToBacklinkCallback = () => {\n\treturn useCallback(() => {\n\t\tconst backlink = getBacklinkFromUrl() ?? sessionStorage.getItem('backlink')\n\t\tif (!backlink) {\n\t\t\treturn\n\t\t}\n\t\tsessionStorage.removeItem('backlink')\n\t\tconst resolvedBacklink = new URL(backlink, window.location.href)\n\t\tif (resolvedBacklink.origin === window.location.origin) {\n\t\t\twindow.location.href = resolvedBacklink.toString()\n\t\t}\n\t}, [])\n}\n\nexport const useRedirectToBacklink = () => {\n\tconst identity = useIdentity()\n\tconst redirect = useRedirectToBacklinkCallback()\n\tuseEffect(() => {\n\t\tif (!identity) {\n\t\t\treturn\n\t\t}\n\t\tredirect()\n\t}, [identity, redirect])\n\n}\n"],"names":["useCallback"],"mappings":";;;AAGA,MAAM,qBAAqB,MAAM;AAChC,SAAO,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,UAAU;AAClE;AAEO,MAAM,kBAAkB,MAAM;AACpC,SAAOA,kBAAY,MAAM;AACxB,UAAM,WAAW,mBAAmB;AACpC,QAAI,CAAC,UAAU;AACd;AAAA,IAAA;AAEc,mBAAA,QAAQ,YAAY,QAAQ;AAAA,EAC5C,GAAG,EAAE;AACN;AAEO,MAAM,gCAAgC,MAAM;AAClD,SAAOA,kBAAY,MAAM;AACxB,UAAM,WAAW,mBAAA,KAAwB,eAAe,QAAQ,UAAU;AAC1E,QAAI,CAAC,UAAU;AACd;AAAA,IAAA;AAED,mBAAe,WAAW,UAAU;AACpC,UAAM,mBAAmB,IAAI,IAAI,UAAU,OAAO,SAAS,IAAI;AAC/D,QAAI,iBAAiB,WAAW,OAAO,SAAS,QAAQ;AAChD,aAAA,SAAS,OAAO,iBAAiB,SAAS;AAAA,IAAA;AAAA,EAEnD,GAAG,EAAE;AACN;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedirectToBacklink.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useRedirectToBacklink.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useIdentity } from '../../contexts'\n\nconst getBacklinkFromUrl = () => {\n\treturn new URLSearchParams(window.location.search).get('backlink')\n}\n\nexport const useSaveBacklink = () => {\n\treturn useCallback(() => {\n\t\tconst backlink = getBacklinkFromUrl()\n\t\tif (!backlink) {\n\t\t\treturn\n\t\t}\n\t\tsessionStorage.setItem('backlink', backlink)\n\t}, [])\n}\n\nexport const useRedirectToBacklinkCallback = () => {\n\treturn useCallback(() => {\n\t\tconst backlink = getBacklinkFromUrl() ?? sessionStorage.getItem('backlink')\n\t\tif (!backlink) {\n\t\t\treturn\n\t\t}\n\t\tsessionStorage.removeItem('backlink')\n\t\tconst resolvedBacklink = new URL(backlink, window.location.href)\n\t\tif (resolvedBacklink.origin === window.location.origin) {\n\t\t\twindow.location.href = resolvedBacklink.toString()\n\t\t}\n\t}, [])\n}\n\nexport const useRedirectToBacklink = () => {\n\tconst identity = useIdentity()\n\tconst redirect = useRedirectToBacklinkCallback()\n\tuseEffect(() => {\n\t\tif (!identity) {\n\t\t\treturn\n\t\t}\n\t\tredirect()\n\t}, [identity, redirect])\n\n}\n"],"names":[],"mappings":";AAGA,MAAM,qBAAqB,MAAM;AAChC,SAAO,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,UAAU;AAClE;AAEO,MAAM,kBAAkB,MAAM;AACpC,SAAO,YAAY,MAAM;AACxB,UAAM,WAAW;
|
|
1
|
+
{"version":3,"file":"useRedirectToBacklink.js","sources":["../../../../../../packages/react-client-tenant/src/internal/hooks/useRedirectToBacklink.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useIdentity } from '../../contexts'\n\nconst getBacklinkFromUrl = () => {\n\treturn new URLSearchParams(window.location.search).get('backlink')\n}\n\nexport const useSaveBacklink = () => {\n\treturn useCallback(() => {\n\t\tconst backlink = getBacklinkFromUrl()\n\t\tif (!backlink) {\n\t\t\treturn\n\t\t}\n\t\tsessionStorage.setItem('backlink', backlink)\n\t}, [])\n}\n\nexport const useRedirectToBacklinkCallback = () => {\n\treturn useCallback(() => {\n\t\tconst backlink = getBacklinkFromUrl() ?? sessionStorage.getItem('backlink')\n\t\tif (!backlink) {\n\t\t\treturn\n\t\t}\n\t\tsessionStorage.removeItem('backlink')\n\t\tconst resolvedBacklink = new URL(backlink, window.location.href)\n\t\tif (resolvedBacklink.origin === window.location.origin) {\n\t\t\twindow.location.href = resolvedBacklink.toString()\n\t\t}\n\t}, [])\n}\n\nexport const useRedirectToBacklink = () => {\n\tconst identity = useIdentity()\n\tconst redirect = useRedirectToBacklinkCallback()\n\tuseEffect(() => {\n\t\tif (!identity) {\n\t\t\treturn\n\t\t}\n\t\tredirect()\n\t}, [identity, redirect])\n\n}\n"],"names":[],"mappings":";AAGA,MAAM,qBAAqB,MAAM;AAChC,SAAO,IAAI,gBAAgB,OAAO,SAAS,MAAM,EAAE,IAAI,UAAU;AAClE;AAEO,MAAM,kBAAkB,MAAM;AACpC,SAAO,YAAY,MAAM;AACxB,UAAM,WAAW,mBAAmB;AACpC,QAAI,CAAC,UAAU;AACd;AAAA,IAAA;AAEc,mBAAA,QAAQ,YAAY,QAAQ;AAAA,EAC5C,GAAG,EAAE;AACN;AAEO,MAAM,gCAAgC,MAAM;AAClD,SAAO,YAAY,MAAM;AACxB,UAAM,WAAW,mBAAA,KAAwB,eAAe,QAAQ,UAAU;AAC1E,QAAI,CAAC,UAAU;AACd;AAAA,IAAA;AAED,mBAAe,WAAW,UAAU;AACpC,UAAM,mBAAmB,IAAI,IAAI,UAAU,OAAO,SAAS,IAAI;AAC/D,QAAI,iBAAiB,WAAW,OAAO,SAAS,QAAQ;AAChD,aAAA,SAAS,OAAO,iBAAiB,SAAS;AAAA,IAAA;AAAA,EAEnD,GAAG,EAAE;AACN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomInt.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/utils/randomInt.ts"],"sourcesContent":["export const randomInt = (min: number, max: number) => {\n\tif (min >= max) {\n\t\tthrow new Error('The min value must be less than the max value.')\n\t}\n\n\tif (max > 0xFFFFFFFF) {\n\t\tthrow new Error('The max value exceeds the limit for this implementation.')\n\t}\n\n\tconst range = max - min + 1\n\tconst maxValidValue = Math.floor(0xFFFFFFFF / range) * range\n\tlet randomInt\n\n\tdo {\n\t\tconst array = new Uint32Array(1)\n\t\twindow.crypto.getRandomValues(array)\n\t\trandomInt = array[0]\n\t} while (randomInt >= maxValidValue)\n\n\treturn min + (randomInt % range)\n}\n\n\nexport const randomString = (length: number, charset: string): string => {\n\tlet result = ''\n\tfor (let i = 0; i < length; i++) {\n\t\tresult += charset[randomInt(0, charset.length - 1)]\n\t}\n\treturn result\n}\n"],"names":["randomInt"],"mappings":";;AAAa,MAAA,YAAY,CAAC,KAAa,QAAgB;AACtD,MAAI,OAAO,KAAK;AACT,UAAA,IAAI,MAAM,gDAAgD;AAAA,
|
|
1
|
+
{"version":3,"file":"randomInt.cjs","sources":["../../../../../../packages/react-client-tenant/src/internal/utils/randomInt.ts"],"sourcesContent":["export const randomInt = (min: number, max: number) => {\n\tif (min >= max) {\n\t\tthrow new Error('The min value must be less than the max value.')\n\t}\n\n\tif (max > 0xFFFFFFFF) {\n\t\tthrow new Error('The max value exceeds the limit for this implementation.')\n\t}\n\n\tconst range = max - min + 1\n\tconst maxValidValue = Math.floor(0xFFFFFFFF / range) * range\n\tlet randomInt\n\n\tdo {\n\t\tconst array = new Uint32Array(1)\n\t\twindow.crypto.getRandomValues(array)\n\t\trandomInt = array[0]\n\t} while (randomInt >= maxValidValue)\n\n\treturn min + (randomInt % range)\n}\n\n\nexport const randomString = (length: number, charset: string): string => {\n\tlet result = ''\n\tfor (let i = 0; i < length; i++) {\n\t\tresult += charset[randomInt(0, charset.length - 1)]\n\t}\n\treturn result\n}\n"],"names":["randomInt"],"mappings":";;AAAa,MAAA,YAAY,CAAC,KAAa,QAAgB;AACtD,MAAI,OAAO,KAAK;AACT,UAAA,IAAI,MAAM,gDAAgD;AAAA,EAAA;AAGjE,MAAI,MAAM,YAAY;AACf,UAAA,IAAI,MAAM,0DAA0D;AAAA,EAAA;AAGrE,QAAA,QAAQ,MAAM,MAAM;AAC1B,QAAM,gBAAgB,KAAK,MAAM,aAAa,KAAK,IAAI;AACnDA,MAAAA;AAED,KAAA;AACI,UAAA,QAAQ,IAAI,YAAY,CAAC;AACxB,WAAA,OAAO,gBAAgB,KAAK;AACnCA,iBAAY,MAAM,CAAC;AAAA,WACXA,cAAa;AAEtB,SAAO,MAAOA,aAAY;AAC3B;AAGa,MAAA,eAAe,CAAC,QAAgB,YAA4B;AACxE,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAChC,cAAU,QAAQ,UAAU,GAAG,QAAQ,SAAS,CAAC,CAAC;AAAA,EAAA;AAE5C,SAAA;AACR;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomInt.js","sources":["../../../../../../packages/react-client-tenant/src/internal/utils/randomInt.ts"],"sourcesContent":["export const randomInt = (min: number, max: number) => {\n\tif (min >= max) {\n\t\tthrow new Error('The min value must be less than the max value.')\n\t}\n\n\tif (max > 0xFFFFFFFF) {\n\t\tthrow new Error('The max value exceeds the limit for this implementation.')\n\t}\n\n\tconst range = max - min + 1\n\tconst maxValidValue = Math.floor(0xFFFFFFFF / range) * range\n\tlet randomInt\n\n\tdo {\n\t\tconst array = new Uint32Array(1)\n\t\twindow.crypto.getRandomValues(array)\n\t\trandomInt = array[0]\n\t} while (randomInt >= maxValidValue)\n\n\treturn min + (randomInt % range)\n}\n\n\nexport const randomString = (length: number, charset: string): string => {\n\tlet result = ''\n\tfor (let i = 0; i < length; i++) {\n\t\tresult += charset[randomInt(0, charset.length - 1)]\n\t}\n\treturn result\n}\n"],"names":["randomInt"],"mappings":"AAAa,MAAA,YAAY,CAAC,KAAa,QAAgB;AACtD,MAAI,OAAO,KAAK;AACT,UAAA,IAAI,MAAM,gDAAgD;AAAA,
|
|
1
|
+
{"version":3,"file":"randomInt.js","sources":["../../../../../../packages/react-client-tenant/src/internal/utils/randomInt.ts"],"sourcesContent":["export const randomInt = (min: number, max: number) => {\n\tif (min >= max) {\n\t\tthrow new Error('The min value must be less than the max value.')\n\t}\n\n\tif (max > 0xFFFFFFFF) {\n\t\tthrow new Error('The max value exceeds the limit for this implementation.')\n\t}\n\n\tconst range = max - min + 1\n\tconst maxValidValue = Math.floor(0xFFFFFFFF / range) * range\n\tlet randomInt\n\n\tdo {\n\t\tconst array = new Uint32Array(1)\n\t\twindow.crypto.getRandomValues(array)\n\t\trandomInt = array[0]\n\t} while (randomInt >= maxValidValue)\n\n\treturn min + (randomInt % range)\n}\n\n\nexport const randomString = (length: number, charset: string): string => {\n\tlet result = ''\n\tfor (let i = 0; i < length; i++) {\n\t\tresult += charset[randomInt(0, charset.length - 1)]\n\t}\n\treturn result\n}\n"],"names":["randomInt"],"mappings":"AAAa,MAAA,YAAY,CAAC,KAAa,QAAgB;AACtD,MAAI,OAAO,KAAK;AACT,UAAA,IAAI,MAAM,gDAAgD;AAAA,EAAA;AAGjE,MAAI,MAAM,YAAY;AACf,UAAA,IAAI,MAAM,0DAA0D;AAAA,EAAA;AAGrE,QAAA,QAAQ,MAAM,MAAM;AAC1B,QAAM,gBAAgB,KAAK,MAAM,aAAa,KAAK,IAAI;AACnDA,MAAAA;AAED,KAAA;AACI,UAAA,QAAQ,IAAI,YAAY,CAAC;AACxB,WAAA,OAAO,gBAAgB,KAAK;AACnCA,iBAAY,MAAM,CAAC;AAAA,WACXA,cAAa;AAEtB,SAAO,MAAOA,aAAY;AAC3B;AAGa,MAAA,eAAe,CAAC,QAAgB,YAA4B;AACxE,MAAI,SAAS;AACb,WAAS,IAAI,GAAG,IAAI,QAAQ,KAAK;AAChC,cAAU,QAAQ,UAAU,GAAG,QAAQ,SAAS,CAAC,CAAC;AAAA,EAAA;AAE5C,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProvider.cjs","sources":["../../../../../packages/react-client-tenant/src/components/IdentityProvider.tsx"],"sourcesContent":["import { useSessionToken } from '@contember/react-client'\nimport { ReactNode, useEffect } from 'react'\nimport { useFetchIdentity } from '../hooks'\nimport { IdentityContext, IdentityMethodsContext, IdentityStateContext } from '../contexts'\n\n\nexport interface IdentityProviderProps {\n\tchildren: ReactNode\n}\n\nexport const IdentityProvider: React.FC<IdentityProviderProps> = ({ children }) => {\n\tconst sessionToken = useSessionToken()\n\tconst [{ identity, state }, methods] = useFetchIdentity()\n\n\tconst { refreshIdentity, clearIdentity } = methods\n\tuseEffect(() => {\n\t\tif (sessionToken !== undefined) {\n\t\t\trefreshIdentity()\n\t\t}\n\t}, [sessionToken, refreshIdentity])\n\n\n\tconst hasIdentity = identity !== undefined\n\tuseEffect(() => {\n\t\tif (sessionToken === undefined && hasIdentity) {\n\t\t\tclearIdentity()\n\t\t}\n\t}, [sessionToken, clearIdentity, hasIdentity])\n\n\treturn (\n\t\t<IdentityStateContext.Provider value={state}>\n\t\t\t<IdentityContext.Provider value={identity}>\n\t\t\t\t<IdentityMethodsContext.Provider value={methods}>\n\t\t\t\t\t{children}\n\t\t\t\t</IdentityMethodsContext.Provider>\n\t\t\t</IdentityContext.Provider>\n\t\t</IdentityStateContext.Provider>\n\t)\n}\n"],"names":["useSessionToken","useFetchIdentity","useEffect","jsx","IdentityStateContext","IdentityContext","IdentityMethodsContext"],"mappings":";;;;;;;AAUO,MAAM,mBAAoD,CAAC,EAAE,eAAe;AAClF,QAAM,eAAeA,YAAAA;
|
|
1
|
+
{"version":3,"file":"IdentityProvider.cjs","sources":["../../../../../packages/react-client-tenant/src/components/IdentityProvider.tsx"],"sourcesContent":["import { useSessionToken } from '@contember/react-client'\nimport { ReactNode, useEffect } from 'react'\nimport { useFetchIdentity } from '../hooks'\nimport { IdentityContext, IdentityMethodsContext, IdentityStateContext } from '../contexts'\n\n\nexport interface IdentityProviderProps {\n\tchildren: ReactNode\n}\n\nexport const IdentityProvider: React.FC<IdentityProviderProps> = ({ children }) => {\n\tconst sessionToken = useSessionToken()\n\tconst [{ identity, state }, methods] = useFetchIdentity()\n\n\tconst { refreshIdentity, clearIdentity } = methods\n\tuseEffect(() => {\n\t\tif (sessionToken !== undefined) {\n\t\t\trefreshIdentity()\n\t\t}\n\t}, [sessionToken, refreshIdentity])\n\n\n\tconst hasIdentity = identity !== undefined\n\tuseEffect(() => {\n\t\tif (sessionToken === undefined && hasIdentity) {\n\t\t\tclearIdentity()\n\t\t}\n\t}, [sessionToken, clearIdentity, hasIdentity])\n\n\treturn (\n\t\t<IdentityStateContext.Provider value={state}>\n\t\t\t<IdentityContext.Provider value={identity}>\n\t\t\t\t<IdentityMethodsContext.Provider value={methods}>\n\t\t\t\t\t{children}\n\t\t\t\t</IdentityMethodsContext.Provider>\n\t\t\t</IdentityContext.Provider>\n\t\t</IdentityStateContext.Provider>\n\t)\n}\n"],"names":["useSessionToken","useFetchIdentity","useEffect","jsx","IdentityStateContext","IdentityContext","IdentityMethodsContext"],"mappings":";;;;;;;AAUO,MAAM,mBAAoD,CAAC,EAAE,eAAe;AAClF,QAAM,eAAeA,YAAAA,gBAAgB;AACrC,QAAM,CAAC,EAAE,UAAU,MAAS,GAAA,OAAO,IAAIC,iBAAAA,iBAAiB;AAElD,QAAA,EAAE,iBAAiB,cAAA,IAAkB;AAC3CC,QAAAA,UAAU,MAAM;AACf,QAAI,iBAAiB,QAAW;AACf,sBAAA;AAAA,IAAA;AAAA,EACjB,GACE,CAAC,cAAc,eAAe,CAAC;AAGlC,QAAM,cAAc,aAAa;AACjCA,QAAAA,UAAU,MAAM;AACX,QAAA,iBAAiB,UAAa,aAAa;AAChC,oBAAA;AAAA,IAAA;AAAA,EAEb,GAAA,CAAC,cAAc,eAAe,WAAW,CAAC;AAG5C,SAAAC,+BAACC,SAAAA,qBAAqB,UAArB,EAA8B,OAAO,OACrC,UAAAD,2BAAA,IAACE,yBAAgB,UAAhB,EAAyB,OAAO,UAChC,UAAAF,2BAAAA,IAACG,gCAAuB,UAAvB,EAAgC,OAAO,SACtC,SAAA,CACF,EACD,CAAA,GACD;AAEF;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityProvider.js","sources":["../../../../../packages/react-client-tenant/src/components/IdentityProvider.tsx"],"sourcesContent":["import { useSessionToken } from '@contember/react-client'\nimport { ReactNode, useEffect } from 'react'\nimport { useFetchIdentity } from '../hooks'\nimport { IdentityContext, IdentityMethodsContext, IdentityStateContext } from '../contexts'\n\n\nexport interface IdentityProviderProps {\n\tchildren: ReactNode\n}\n\nexport const IdentityProvider: React.FC<IdentityProviderProps> = ({ children }) => {\n\tconst sessionToken = useSessionToken()\n\tconst [{ identity, state }, methods] = useFetchIdentity()\n\n\tconst { refreshIdentity, clearIdentity } = methods\n\tuseEffect(() => {\n\t\tif (sessionToken !== undefined) {\n\t\t\trefreshIdentity()\n\t\t}\n\t}, [sessionToken, refreshIdentity])\n\n\n\tconst hasIdentity = identity !== undefined\n\tuseEffect(() => {\n\t\tif (sessionToken === undefined && hasIdentity) {\n\t\t\tclearIdentity()\n\t\t}\n\t}, [sessionToken, clearIdentity, hasIdentity])\n\n\treturn (\n\t\t<IdentityStateContext.Provider value={state}>\n\t\t\t<IdentityContext.Provider value={identity}>\n\t\t\t\t<IdentityMethodsContext.Provider value={methods}>\n\t\t\t\t\t{children}\n\t\t\t\t</IdentityMethodsContext.Provider>\n\t\t\t</IdentityContext.Provider>\n\t\t</IdentityStateContext.Provider>\n\t)\n}\n"],"names":[],"mappings":";;;;;AAUO,MAAM,mBAAoD,CAAC,EAAE,eAAe;AAClF,QAAM,eAAe;
|
|
1
|
+
{"version":3,"file":"IdentityProvider.js","sources":["../../../../../packages/react-client-tenant/src/components/IdentityProvider.tsx"],"sourcesContent":["import { useSessionToken } from '@contember/react-client'\nimport { ReactNode, useEffect } from 'react'\nimport { useFetchIdentity } from '../hooks'\nimport { IdentityContext, IdentityMethodsContext, IdentityStateContext } from '../contexts'\n\n\nexport interface IdentityProviderProps {\n\tchildren: ReactNode\n}\n\nexport const IdentityProvider: React.FC<IdentityProviderProps> = ({ children }) => {\n\tconst sessionToken = useSessionToken()\n\tconst [{ identity, state }, methods] = useFetchIdentity()\n\n\tconst { refreshIdentity, clearIdentity } = methods\n\tuseEffect(() => {\n\t\tif (sessionToken !== undefined) {\n\t\t\trefreshIdentity()\n\t\t}\n\t}, [sessionToken, refreshIdentity])\n\n\n\tconst hasIdentity = identity !== undefined\n\tuseEffect(() => {\n\t\tif (sessionToken === undefined && hasIdentity) {\n\t\t\tclearIdentity()\n\t\t}\n\t}, [sessionToken, clearIdentity, hasIdentity])\n\n\treturn (\n\t\t<IdentityStateContext.Provider value={state}>\n\t\t\t<IdentityContext.Provider value={identity}>\n\t\t\t\t<IdentityMethodsContext.Provider value={methods}>\n\t\t\t\t\t{children}\n\t\t\t\t</IdentityMethodsContext.Provider>\n\t\t\t</IdentityContext.Provider>\n\t\t</IdentityStateContext.Provider>\n\t)\n}\n"],"names":[],"mappings":";;;;;AAUO,MAAM,mBAAoD,CAAC,EAAE,eAAe;AAClF,QAAM,eAAe,gBAAgB;AACrC,QAAM,CAAC,EAAE,UAAU,MAAS,GAAA,OAAO,IAAI,iBAAiB;AAElD,QAAA,EAAE,iBAAiB,cAAA,IAAkB;AAC3C,YAAU,MAAM;AACf,QAAI,iBAAiB,QAAW;AACf,sBAAA;AAAA,IAAA;AAAA,EACjB,GACE,CAAC,cAAc,eAAe,CAAC;AAGlC,QAAM,cAAc,aAAa;AACjC,YAAU,MAAM;AACX,QAAA,iBAAiB,UAAa,aAAa;AAChC,oBAAA;AAAA,IAAA;AAAA,EAEb,GAAA,CAAC,cAAc,eAAe,WAAW,CAAC;AAG5C,SAAA,oBAAC,qBAAqB,UAArB,EAA8B,OAAO,OACrC,UAAA,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,UAChC,UAAA,oBAAC,uBAAuB,UAAvB,EAAgC,OAAO,SACtC,SAAA,CACF,EACD,CAAA,GACD;AAEF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityState.cjs","sources":["../../../../../packages/react-client-tenant/src/components/IdentityState.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { IdentityStateValue } from '../types'\nimport { useIdentityState } from '../contexts'\n\nexport interface IdentityStateProps {\n\tstate: IdentityStateValue | IdentityStateValue[]\n\tchildren: ReactNode\n}\n\nexport const IdentityState = ({ state, children }: IdentityStateProps) => {\n\tconst currentState = useIdentityState()\n\n\treturn state === currentState || (Array.isArray(state) && state.includes(currentState)) ? <>{children}</> : null\n}\n"],"names":["useIdentityState","jsx","Fragment"],"mappings":";;;;AASO,MAAM,gBAAgB,CAAC,EAAE,OAAO,eAAmC;AACzE,QAAM,eAAeA,SAAAA;
|
|
1
|
+
{"version":3,"file":"IdentityState.cjs","sources":["../../../../../packages/react-client-tenant/src/components/IdentityState.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { IdentityStateValue } from '../types'\nimport { useIdentityState } from '../contexts'\n\nexport interface IdentityStateProps {\n\tstate: IdentityStateValue | IdentityStateValue[]\n\tchildren: ReactNode\n}\n\nexport const IdentityState = ({ state, children }: IdentityStateProps) => {\n\tconst currentState = useIdentityState()\n\n\treturn state === currentState || (Array.isArray(state) && state.includes(currentState)) ? <>{children}</> : null\n}\n"],"names":["useIdentityState","jsx","Fragment"],"mappings":";;;;AASO,MAAM,gBAAgB,CAAC,EAAE,OAAO,eAAmC;AACzE,QAAM,eAAeA,SAAAA,iBAAiB;AAEtC,SAAO,UAAU,gBAAiB,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,YAAY,IAAQC,2BAAAA,IAAAC,WAAAA,UAAA,EAAA,SAAA,CAAS,IAAM;AAC7G;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityState.js","sources":["../../../../../packages/react-client-tenant/src/components/IdentityState.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { IdentityStateValue } from '../types'\nimport { useIdentityState } from '../contexts'\n\nexport interface IdentityStateProps {\n\tstate: IdentityStateValue | IdentityStateValue[]\n\tchildren: ReactNode\n}\n\nexport const IdentityState = ({ state, children }: IdentityStateProps) => {\n\tconst currentState = useIdentityState()\n\n\treturn state === currentState || (Array.isArray(state) && state.includes(currentState)) ? <>{children}</> : null\n}\n"],"names":[],"mappings":";;AASO,MAAM,gBAAgB,CAAC,EAAE,OAAO,eAAmC;AACzE,QAAM,eAAe;
|
|
1
|
+
{"version":3,"file":"IdentityState.js","sources":["../../../../../packages/react-client-tenant/src/components/IdentityState.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\nimport { IdentityStateValue } from '../types'\nimport { useIdentityState } from '../contexts'\n\nexport interface IdentityStateProps {\n\tstate: IdentityStateValue | IdentityStateValue[]\n\tchildren: ReactNode\n}\n\nexport const IdentityState = ({ state, children }: IdentityStateProps) => {\n\tconst currentState = useIdentityState()\n\n\treturn state === currentState || (Array.isArray(state) && state.includes(currentState)) ? <>{children}</> : null\n}\n"],"names":[],"mappings":";;AASO,MAAM,gBAAgB,CAAC,EAAE,OAAO,eAAmC;AACzE,QAAM,eAAe,iBAAiB;AAEtC,SAAO,UAAU,gBAAiB,MAAM,QAAQ,KAAK,KAAK,MAAM,SAAS,YAAY,IAAQ,oBAAA,UAAA,EAAA,SAAA,CAAS,IAAM;AAC7G;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeMyPasswordForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/ChangeMyPasswordForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { ChangeMyPasswordErrorCode } from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { useChangeMyPasswordMutation } from '../../hooks'\n\nexport type ChangeMyPasswordFormValues = {\n\tcurrentPassword: string\n\tnewPassword: string\n\tpasswordConfirmation: string\n}\n\nexport type ChangeMyPasswordFormErrorCode =\n\t| ChangeMyPasswordErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'PASSWORD_MISMATCH'\n\t| 'UNKNOWN_ERROR'\n\nexport type ChangeMyPasswordFormState = FormState\n\nexport type ChangeMyPasswordFormError = FormError<ChangeMyPasswordFormValues, ChangeMyPasswordFormErrorCode>\n\nexport type ChangeMyPasswordFormContextValue = FormContextValue<ChangeMyPasswordFormValues, ChangeMyPasswordFormErrorCode>\n\nexport interface ChangeMyPasswordFormProps {\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const useChangeMyPasswordForm = useForm as () => ChangeMyPasswordFormContextValue\n\nexport const ChangeMyPasswordForm = ({ children, onSuccess }: ChangeMyPasswordFormProps) => {\n\tconst changePassword = useChangeMyPasswordMutation()\n\treturn (\n\t\t<TenantForm<ChangeMyPasswordFormContextValue>\n\t\t\tonSuccess={onSuccess}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\tcurrentPassword: '',\n\t\t\t\tnewPassword: '',\n\t\t\t\tpasswordConfirmation: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: ChangeMyPasswordFormError[] = []\n\t\t\t\tif (!values.currentPassword) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'currentPassword' })\n\t\t\t\t}\n\t\t\t\tif (!values.newPassword) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'newPassword' })\n\t\t\t\t} else if (values.newPassword.length < 6) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'newPassword' })\n\t\t\t\t} else if (!values.passwordConfirmation) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'passwordConfirmation' })\n\t\t\t\t} else if (values.newPassword !== values.passwordConfirmation) {\n\t\t\t\t\terrors.push({ code: 'PASSWORD_MISMATCH', field: 'passwordConfirmation' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await changePassword(values)\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n\n}\nconst errorToField: Partial<Record<ChangeMyPasswordFormErrorCode, keyof ChangeMyPasswordFormValues | undefined>> = {\n\tPASSWORD_MISMATCH: 'passwordConfirmation',\n\tTOO_WEAK: 'newPassword',\n\tNO_PASSWORD_SET: 'currentPassword',\n\tINVALID_PASSWORD: 'currentPassword',\n}\n"],"names":["useForm","useChangeMyPasswordMutation","jsx","TenantForm"],"mappings":";;;;;;AA+BO,MAAM,0BAA0BA,
|
|
1
|
+
{"version":3,"file":"ChangeMyPasswordForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/ChangeMyPasswordForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { ChangeMyPasswordErrorCode } from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { useChangeMyPasswordMutation } from '../../hooks'\n\nexport type ChangeMyPasswordFormValues = {\n\tcurrentPassword: string\n\tnewPassword: string\n\tpasswordConfirmation: string\n}\n\nexport type ChangeMyPasswordFormErrorCode =\n\t| ChangeMyPasswordErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'PASSWORD_MISMATCH'\n\t| 'UNKNOWN_ERROR'\n\nexport type ChangeMyPasswordFormState = FormState\n\nexport type ChangeMyPasswordFormError = FormError<ChangeMyPasswordFormValues, ChangeMyPasswordFormErrorCode>\n\nexport type ChangeMyPasswordFormContextValue = FormContextValue<ChangeMyPasswordFormValues, ChangeMyPasswordFormErrorCode>\n\nexport interface ChangeMyPasswordFormProps {\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const useChangeMyPasswordForm = useForm as () => ChangeMyPasswordFormContextValue\n\nexport const ChangeMyPasswordForm = ({ children, onSuccess }: ChangeMyPasswordFormProps) => {\n\tconst changePassword = useChangeMyPasswordMutation()\n\treturn (\n\t\t<TenantForm<ChangeMyPasswordFormContextValue>\n\t\t\tonSuccess={onSuccess}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\tcurrentPassword: '',\n\t\t\t\tnewPassword: '',\n\t\t\t\tpasswordConfirmation: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: ChangeMyPasswordFormError[] = []\n\t\t\t\tif (!values.currentPassword) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'currentPassword' })\n\t\t\t\t}\n\t\t\t\tif (!values.newPassword) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'newPassword' })\n\t\t\t\t} else if (values.newPassword.length < 6) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'newPassword' })\n\t\t\t\t} else if (!values.passwordConfirmation) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'passwordConfirmation' })\n\t\t\t\t} else if (values.newPassword !== values.passwordConfirmation) {\n\t\t\t\t\terrors.push({ code: 'PASSWORD_MISMATCH', field: 'passwordConfirmation' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await changePassword(values)\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n\n}\nconst errorToField: Partial<Record<ChangeMyPasswordFormErrorCode, keyof ChangeMyPasswordFormValues | undefined>> = {\n\tPASSWORD_MISMATCH: 'passwordConfirmation',\n\tTOO_WEAK: 'newPassword',\n\tNO_PASSWORD_SET: 'currentPassword',\n\tINVALID_PASSWORD: 'currentPassword',\n}\n"],"names":["useForm","useChangeMyPasswordMutation","jsx","TenantForm"],"mappings":";;;;;;AA+BO,MAAM,0BAA0BA,SAAAA;AAEhC,MAAM,uBAAuB,CAAC,EAAE,UAAU,gBAA2C;AAC3F,QAAM,iBAAiBC,4BAAAA,4BAA4B;AAElD,SAAAC,2BAAA;AAAA,IAACC,WAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,eAAe;AAAA,QACd,iBAAiB;AAAA,QACjB,aAAa;AAAA,QACb,sBAAsB;AAAA,MACvB;AAAA,MACA,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAAsC,CAAC;AACzC,YAAA,CAAC,OAAO,iBAAiB;AAC5B,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,mBAAmB;AAAA,QAAA;AAE7D,YAAA,CAAC,OAAO,aAAa;AACxB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,eAAe;AAAA,QAClD,WAAA,OAAO,YAAY,SAAS,GAAG;AACzC,iBAAO,KAAK,EAAE,MAAM,iBAAiB,OAAO,eAAe;AAAA,QAAA,WACjD,CAAC,OAAO,sBAAsB;AACxC,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,wBAAwB;AAAA,QAC3D,WAAA,OAAO,gBAAgB,OAAO,sBAAsB;AAC9D,iBAAO,KAAK,EAAE,MAAM,qBAAqB,OAAO,wBAAwB;AAAA,QAAA;AAElE,eAAA;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AACvB,eAAA,MAAM,eAAe,MAAM;AAAA,MACnC;AAAA,MAEC;AAAA,IAAA;AAAA,EACF;AAGF;AACA,MAAM,eAA6G;AAAA,EAClH,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,kBAAkB;AACnB;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangeMyPasswordForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/ChangeMyPasswordForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { ChangeMyPasswordErrorCode } from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { useChangeMyPasswordMutation } from '../../hooks'\n\nexport type ChangeMyPasswordFormValues = {\n\tcurrentPassword: string\n\tnewPassword: string\n\tpasswordConfirmation: string\n}\n\nexport type ChangeMyPasswordFormErrorCode =\n\t| ChangeMyPasswordErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'PASSWORD_MISMATCH'\n\t| 'UNKNOWN_ERROR'\n\nexport type ChangeMyPasswordFormState = FormState\n\nexport type ChangeMyPasswordFormError = FormError<ChangeMyPasswordFormValues, ChangeMyPasswordFormErrorCode>\n\nexport type ChangeMyPasswordFormContextValue = FormContextValue<ChangeMyPasswordFormValues, ChangeMyPasswordFormErrorCode>\n\nexport interface ChangeMyPasswordFormProps {\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const useChangeMyPasswordForm = useForm as () => ChangeMyPasswordFormContextValue\n\nexport const ChangeMyPasswordForm = ({ children, onSuccess }: ChangeMyPasswordFormProps) => {\n\tconst changePassword = useChangeMyPasswordMutation()\n\treturn (\n\t\t<TenantForm<ChangeMyPasswordFormContextValue>\n\t\t\tonSuccess={onSuccess}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\tcurrentPassword: '',\n\t\t\t\tnewPassword: '',\n\t\t\t\tpasswordConfirmation: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: ChangeMyPasswordFormError[] = []\n\t\t\t\tif (!values.currentPassword) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'currentPassword' })\n\t\t\t\t}\n\t\t\t\tif (!values.newPassword) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'newPassword' })\n\t\t\t\t} else if (values.newPassword.length < 6) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'newPassword' })\n\t\t\t\t} else if (!values.passwordConfirmation) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'passwordConfirmation' })\n\t\t\t\t} else if (values.newPassword !== values.passwordConfirmation) {\n\t\t\t\t\terrors.push({ code: 'PASSWORD_MISMATCH', field: 'passwordConfirmation' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await changePassword(values)\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n\n}\nconst errorToField: Partial<Record<ChangeMyPasswordFormErrorCode, keyof ChangeMyPasswordFormValues | undefined>> = {\n\tPASSWORD_MISMATCH: 'passwordConfirmation',\n\tTOO_WEAK: 'newPassword',\n\tNO_PASSWORD_SET: 'currentPassword',\n\tINVALID_PASSWORD: 'currentPassword',\n}\n"],"names":[],"mappings":";;;;AA+BO,MAAM,0BAA0B;AAEhC,MAAM,uBAAuB,CAAC,EAAE,UAAU,gBAA2C;AAC3F,QAAM,iBAAiB;
|
|
1
|
+
{"version":3,"file":"ChangeMyPasswordForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/ChangeMyPasswordForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { ChangeMyPasswordErrorCode } from '@contember/graphql-client-tenant'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { useChangeMyPasswordMutation } from '../../hooks'\n\nexport type ChangeMyPasswordFormValues = {\n\tcurrentPassword: string\n\tnewPassword: string\n\tpasswordConfirmation: string\n}\n\nexport type ChangeMyPasswordFormErrorCode =\n\t| ChangeMyPasswordErrorCode\n\t| 'FIELD_REQUIRED'\n\t| 'INVALID_VALUE'\n\t| 'PASSWORD_MISMATCH'\n\t| 'UNKNOWN_ERROR'\n\nexport type ChangeMyPasswordFormState = FormState\n\nexport type ChangeMyPasswordFormError = FormError<ChangeMyPasswordFormValues, ChangeMyPasswordFormErrorCode>\n\nexport type ChangeMyPasswordFormContextValue = FormContextValue<ChangeMyPasswordFormValues, ChangeMyPasswordFormErrorCode>\n\nexport interface ChangeMyPasswordFormProps {\n\tchildren: ReactElement\n\tonSuccess?: () => void\n}\n\nexport const useChangeMyPasswordForm = useForm as () => ChangeMyPasswordFormContextValue\n\nexport const ChangeMyPasswordForm = ({ children, onSuccess }: ChangeMyPasswordFormProps) => {\n\tconst changePassword = useChangeMyPasswordMutation()\n\treturn (\n\t\t<TenantForm<ChangeMyPasswordFormContextValue>\n\t\t\tonSuccess={onSuccess}\n\t\t\terrorMapping={errorToField}\n\t\t\tinitialValues={{\n\t\t\t\tcurrentPassword: '',\n\t\t\t\tnewPassword: '',\n\t\t\t\tpasswordConfirmation: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: ChangeMyPasswordFormError[] = []\n\t\t\t\tif (!values.currentPassword) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'currentPassword' })\n\t\t\t\t}\n\t\t\t\tif (!values.newPassword) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'newPassword' })\n\t\t\t\t} else if (values.newPassword.length < 6) {\n\t\t\t\t\terrors.push({ code: 'INVALID_VALUE', field: 'newPassword' })\n\t\t\t\t} else if (!values.passwordConfirmation) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'passwordConfirmation' })\n\t\t\t\t} else if (values.newPassword !== values.passwordConfirmation) {\n\t\t\t\t\terrors.push({ code: 'PASSWORD_MISMATCH', field: 'passwordConfirmation' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await changePassword(values)\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n\n}\nconst errorToField: Partial<Record<ChangeMyPasswordFormErrorCode, keyof ChangeMyPasswordFormValues | undefined>> = {\n\tPASSWORD_MISMATCH: 'passwordConfirmation',\n\tTOO_WEAK: 'newPassword',\n\tNO_PASSWORD_SET: 'currentPassword',\n\tINVALID_PASSWORD: 'currentPassword',\n}\n"],"names":[],"mappings":";;;;AA+BO,MAAM,0BAA0B;AAEhC,MAAM,uBAAuB,CAAC,EAAE,UAAU,gBAA2C;AAC3F,QAAM,iBAAiB,4BAA4B;AAElD,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,eAAe;AAAA,QACd,iBAAiB;AAAA,QACjB,aAAa;AAAA,QACb,sBAAsB;AAAA,MACvB;AAAA,MACA,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAAsC,CAAC;AACzC,YAAA,CAAC,OAAO,iBAAiB;AAC5B,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,mBAAmB;AAAA,QAAA;AAE7D,YAAA,CAAC,OAAO,aAAa;AACxB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,eAAe;AAAA,QAClD,WAAA,OAAO,YAAY,SAAS,GAAG;AACzC,iBAAO,KAAK,EAAE,MAAM,iBAAiB,OAAO,eAAe;AAAA,QAAA,WACjD,CAAC,OAAO,sBAAsB;AACxC,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,wBAAwB;AAAA,QAC3D,WAAA,OAAO,gBAAgB,OAAO,sBAAsB;AAC9D,iBAAO,KAAK,EAAE,MAAM,qBAAqB,OAAO,wBAAwB;AAAA,QAAA;AAElE,eAAA;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AACvB,eAAA,MAAM,eAAe,MAAM;AAAA,MACnC;AAAA,MAEC;AAAA,IAAA;AAAA,EACF;AAGF;AACA,MAAM,eAA6G;AAAA,EAClH,mBAAmB;AAAA,EACnB,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,kBAAkB;AACnB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateApiKeyForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/CreateApiKeyForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { CreateApiKeyErrorCode, MembershipInput } from '@contember/graphql-client-tenant'\nimport { CreateApiKeyMutationResult, useCreateApiKeyMutation } from '../../hooks'\n\nexport type CreateApiKeyFormValues = {\n\tdescription: string\n\tmemberships: readonly MembershipInput[]\n}\n\nexport type CreateApiKeyFormErrorCode =\n\t| CreateApiKeyErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type CreateApiKeyFormState = FormState\n\nexport type CreateApiKeyFormError = FormError<CreateApiKeyFormValues, CreateApiKeyFormErrorCode>\n\nexport type CreateApiKeyFormContextValue = FormContextValue<CreateApiKeyFormValues, CreateApiKeyFormErrorCode>\n\nexport interface CreateApiKeyFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinitialMemberships?: readonly MembershipInput[]\n\tonSuccess?: (args: { result: CreateApiKeyMutationResult }) => void\n}\n\nexport const useCreateApiKeyForm = useForm as () => CreateApiKeyFormContextValue\n\nexport const CreateApiKeyForm = ({ children, onSuccess, projectSlug, initialMemberships }: CreateApiKeyFormProps) => {\n\tconst createApiKey = useCreateApiKeyMutation()\n\treturn (\n\t\t<TenantForm<CreateApiKeyFormContextValue, CreateApiKeyMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\tdescription: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: CreateApiKeyFormError[] = []\n\t\t\t\tif (!values.description) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'description' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await createApiKey({\n\t\t\t\t\tdescription: values.description,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<CreateApiKeyErrorCode, keyof CreateApiKeyFormValues | undefined> = {\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":["useForm","useCreateApiKeyMutation","jsx","TenantForm"],"mappings":";;;;;;AA8BO,MAAM,sBAAsBA,
|
|
1
|
+
{"version":3,"file":"CreateApiKeyForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/CreateApiKeyForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { CreateApiKeyErrorCode, MembershipInput } from '@contember/graphql-client-tenant'\nimport { CreateApiKeyMutationResult, useCreateApiKeyMutation } from '../../hooks'\n\nexport type CreateApiKeyFormValues = {\n\tdescription: string\n\tmemberships: readonly MembershipInput[]\n}\n\nexport type CreateApiKeyFormErrorCode =\n\t| CreateApiKeyErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type CreateApiKeyFormState = FormState\n\nexport type CreateApiKeyFormError = FormError<CreateApiKeyFormValues, CreateApiKeyFormErrorCode>\n\nexport type CreateApiKeyFormContextValue = FormContextValue<CreateApiKeyFormValues, CreateApiKeyFormErrorCode>\n\nexport interface CreateApiKeyFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinitialMemberships?: readonly MembershipInput[]\n\tonSuccess?: (args: { result: CreateApiKeyMutationResult }) => void\n}\n\nexport const useCreateApiKeyForm = useForm as () => CreateApiKeyFormContextValue\n\nexport const CreateApiKeyForm = ({ children, onSuccess, projectSlug, initialMemberships }: CreateApiKeyFormProps) => {\n\tconst createApiKey = useCreateApiKeyMutation()\n\treturn (\n\t\t<TenantForm<CreateApiKeyFormContextValue, CreateApiKeyMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\tdescription: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: CreateApiKeyFormError[] = []\n\t\t\t\tif (!values.description) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'description' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await createApiKey({\n\t\t\t\t\tdescription: values.description,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<CreateApiKeyErrorCode, keyof CreateApiKeyFormValues | undefined> = {\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":["useForm","useCreateApiKeyMutation","jsx","TenantForm"],"mappings":";;;;;;AA8BO,MAAM,sBAAsBA,SAAAA;AAE5B,MAAM,mBAAmB,CAAC,EAAE,UAAU,WAAW,aAAa,yBAAgD;AACpH,QAAM,eAAeC,wBAAAA,wBAAwB;AAE5C,SAAAC,2BAAA;AAAA,IAACC,WAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,QACd,aAAa;AAAA,QACb,aAAa,sBAAsB,CAAA;AAAA,MACpC;AAAA,MACA,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAAkC,CAAC;AACrC,YAAA,CAAC,OAAO,aAAa;AACxB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,eAAe;AAAA,QAAA;AAEzD,YAAA,OAAO,YAAY,WAAW,GAAG;AACpC,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,eAAe;AAAA,QAAA;AAEtD,eAAA;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,eAAO,MAAM,aAAa;AAAA,UACzB,aAAa,OAAO;AAAA,UACpB;AAAA,UACA,aAAa,OAAO;AAAA,QAAA,CACpB;AAAA,MACF;AAAA,MACA,cAAc;AAAA,MAEb;AAAA,IAAA;AAAA,EACF;AAEF;AAEA,MAAM,eAAwF;AAAA,EAC7F,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,oBAAoB;AACrB;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateApiKeyForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/CreateApiKeyForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { CreateApiKeyErrorCode, MembershipInput } from '@contember/graphql-client-tenant'\nimport { CreateApiKeyMutationResult, useCreateApiKeyMutation } from '../../hooks'\n\nexport type CreateApiKeyFormValues = {\n\tdescription: string\n\tmemberships: readonly MembershipInput[]\n}\n\nexport type CreateApiKeyFormErrorCode =\n\t| CreateApiKeyErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type CreateApiKeyFormState = FormState\n\nexport type CreateApiKeyFormError = FormError<CreateApiKeyFormValues, CreateApiKeyFormErrorCode>\n\nexport type CreateApiKeyFormContextValue = FormContextValue<CreateApiKeyFormValues, CreateApiKeyFormErrorCode>\n\nexport interface CreateApiKeyFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinitialMemberships?: readonly MembershipInput[]\n\tonSuccess?: (args: { result: CreateApiKeyMutationResult }) => void\n}\n\nexport const useCreateApiKeyForm = useForm as () => CreateApiKeyFormContextValue\n\nexport const CreateApiKeyForm = ({ children, onSuccess, projectSlug, initialMemberships }: CreateApiKeyFormProps) => {\n\tconst createApiKey = useCreateApiKeyMutation()\n\treturn (\n\t\t<TenantForm<CreateApiKeyFormContextValue, CreateApiKeyMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\tdescription: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: CreateApiKeyFormError[] = []\n\t\t\t\tif (!values.description) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'description' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await createApiKey({\n\t\t\t\t\tdescription: values.description,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<CreateApiKeyErrorCode, keyof CreateApiKeyFormValues | undefined> = {\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":[],"mappings":";;;;AA8BO,MAAM,sBAAsB;AAE5B,MAAM,mBAAmB,CAAC,EAAE,UAAU,WAAW,aAAa,yBAAgD;AACpH,QAAM,eAAe;
|
|
1
|
+
{"version":3,"file":"CreateApiKeyForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/CreateApiKeyForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { CreateApiKeyErrorCode, MembershipInput } from '@contember/graphql-client-tenant'\nimport { CreateApiKeyMutationResult, useCreateApiKeyMutation } from '../../hooks'\n\nexport type CreateApiKeyFormValues = {\n\tdescription: string\n\tmemberships: readonly MembershipInput[]\n}\n\nexport type CreateApiKeyFormErrorCode =\n\t| CreateApiKeyErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type CreateApiKeyFormState = FormState\n\nexport type CreateApiKeyFormError = FormError<CreateApiKeyFormValues, CreateApiKeyFormErrorCode>\n\nexport type CreateApiKeyFormContextValue = FormContextValue<CreateApiKeyFormValues, CreateApiKeyFormErrorCode>\n\nexport interface CreateApiKeyFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinitialMemberships?: readonly MembershipInput[]\n\tonSuccess?: (args: { result: CreateApiKeyMutationResult }) => void\n}\n\nexport const useCreateApiKeyForm = useForm as () => CreateApiKeyFormContextValue\n\nexport const CreateApiKeyForm = ({ children, onSuccess, projectSlug, initialMemberships }: CreateApiKeyFormProps) => {\n\tconst createApiKey = useCreateApiKeyMutation()\n\treturn (\n\t\t<TenantForm<CreateApiKeyFormContextValue, CreateApiKeyMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\tdescription: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: CreateApiKeyFormError[] = []\n\t\t\t\tif (!values.description) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'description' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await createApiKey({\n\t\t\t\t\tdescription: values.description,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<CreateApiKeyErrorCode, keyof CreateApiKeyFormValues | undefined> = {\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":[],"mappings":";;;;AA8BO,MAAM,sBAAsB;AAE5B,MAAM,mBAAmB,CAAC,EAAE,UAAU,WAAW,aAAa,yBAAgD;AACpH,QAAM,eAAe,wBAAwB;AAE5C,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,QACd,aAAa;AAAA,QACb,aAAa,sBAAsB,CAAA;AAAA,MACpC;AAAA,MACA,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAAkC,CAAC;AACrC,YAAA,CAAC,OAAO,aAAa;AACxB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,eAAe;AAAA,QAAA;AAEzD,YAAA,OAAO,YAAY,WAAW,GAAG;AACpC,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,eAAe;AAAA,QAAA;AAEtD,eAAA;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,eAAO,MAAM,aAAa;AAAA,UACzB,aAAa,OAAO;AAAA,UACpB;AAAA,UACA,aAAa,OAAO;AAAA,QAAA,CACpB;AAAA,MACF;AAAA,MACA,cAAc;AAAA,MAEb;AAAA,IAAA;AAAA,EACF;AAEF;AAEA,MAAM,eAAwF;AAAA,EAC7F,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,oBAAoB;AACrB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateSessionTokenForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/CreateSessionTokenForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { CreateSessionTokenErrorCode } from '@contember/graphql-client-tenant'\nimport { CreateSessionTokenMutationResult, useCreateSessionTokenMutation } from '../../hooks'\n\nexport type CreateSessionTokenFormValues = {\n\temail: string\n}\n\nexport type CreateSessionTokenFormErrorCode =\n\t| CreateSessionTokenErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type CreateSessionTokenFormState = FormState\n\nexport type CreateSessionTokenFormError = FormError<CreateSessionTokenFormValues, CreateSessionTokenFormErrorCode>\n\nexport type CreateSessionTokenFormContextValue = FormContextValue<CreateSessionTokenFormValues, CreateSessionTokenFormErrorCode>\n\nexport interface CreateSessionTokenFormProps {\n\tchildren: ReactElement\n\texpiration?: number\n\tapiToken?: string\n\tonSuccess?: (args: { result: CreateSessionTokenMutationResult }) => void\n}\n\nexport const useCreateSessionTokenForm = useForm as () => CreateSessionTokenFormContextValue\n\nexport const CreateSessionTokenForm = ({ children, onSuccess, expiration, apiToken }: CreateSessionTokenFormProps) => {\n\tconst createSessionToken = useCreateSessionTokenMutation({ apiToken })\n\treturn (\n\t\t<TenantForm<CreateSessionTokenFormContextValue, CreateSessionTokenMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: CreateSessionTokenFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await createSessionToken({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\texpiration,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<CreateSessionTokenErrorCode, keyof CreateSessionTokenFormValues | undefined> = {\n\tPERSON_DISABLED: 'email',\n\tUNKNOWN_EMAIL: 'email',\n\tUNKNOWN_PERSON_ID: 'email',\n}\n"],"names":["useForm","useCreateSessionTokenMutation","jsx","TenantForm"],"mappings":";;;;;;AA6BO,MAAM,4BAA4BA,
|
|
1
|
+
{"version":3,"file":"CreateSessionTokenForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/CreateSessionTokenForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { CreateSessionTokenErrorCode } from '@contember/graphql-client-tenant'\nimport { CreateSessionTokenMutationResult, useCreateSessionTokenMutation } from '../../hooks'\n\nexport type CreateSessionTokenFormValues = {\n\temail: string\n}\n\nexport type CreateSessionTokenFormErrorCode =\n\t| CreateSessionTokenErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type CreateSessionTokenFormState = FormState\n\nexport type CreateSessionTokenFormError = FormError<CreateSessionTokenFormValues, CreateSessionTokenFormErrorCode>\n\nexport type CreateSessionTokenFormContextValue = FormContextValue<CreateSessionTokenFormValues, CreateSessionTokenFormErrorCode>\n\nexport interface CreateSessionTokenFormProps {\n\tchildren: ReactElement\n\texpiration?: number\n\tapiToken?: string\n\tonSuccess?: (args: { result: CreateSessionTokenMutationResult }) => void\n}\n\nexport const useCreateSessionTokenForm = useForm as () => CreateSessionTokenFormContextValue\n\nexport const CreateSessionTokenForm = ({ children, onSuccess, expiration, apiToken }: CreateSessionTokenFormProps) => {\n\tconst createSessionToken = useCreateSessionTokenMutation({ apiToken })\n\treturn (\n\t\t<TenantForm<CreateSessionTokenFormContextValue, CreateSessionTokenMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: CreateSessionTokenFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await createSessionToken({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\texpiration,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<CreateSessionTokenErrorCode, keyof CreateSessionTokenFormValues | undefined> = {\n\tPERSON_DISABLED: 'email',\n\tUNKNOWN_EMAIL: 'email',\n\tUNKNOWN_PERSON_ID: 'email',\n}\n"],"names":["useForm","useCreateSessionTokenMutation","jsx","TenantForm"],"mappings":";;;;;;AA6BO,MAAM,4BAA4BA,SAAAA;AAElC,MAAM,yBAAyB,CAAC,EAAE,UAAU,WAAW,YAAY,eAA4C;AACrH,QAAM,qBAAqBC,8BAAAA,8BAA8B,EAAE,UAAU;AAEpE,SAAAC,2BAAA;AAAA,IAACC,WAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,QACd,OAAO;AAAA,MACR;AAAA,MACA,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAAwC,CAAC;AAC3C,YAAA,CAAC,OAAO,OAAO;AAClB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QAAA;AAEhD,eAAA;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,eAAO,MAAM,mBAAmB;AAAA,UAC/B,OAAO,OAAO;AAAA,UACd;AAAA,QAAA,CACA;AAAA,MACF;AAAA,MACA,cAAc;AAAA,MAEb;AAAA,IAAA;AAAA,EACF;AAEF;AAEA,MAAM,eAAoG;AAAA,EACzG,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,mBAAmB;AACpB;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateSessionTokenForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/CreateSessionTokenForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { CreateSessionTokenErrorCode } from '@contember/graphql-client-tenant'\nimport { CreateSessionTokenMutationResult, useCreateSessionTokenMutation } from '../../hooks'\n\nexport type CreateSessionTokenFormValues = {\n\temail: string\n}\n\nexport type CreateSessionTokenFormErrorCode =\n\t| CreateSessionTokenErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type CreateSessionTokenFormState = FormState\n\nexport type CreateSessionTokenFormError = FormError<CreateSessionTokenFormValues, CreateSessionTokenFormErrorCode>\n\nexport type CreateSessionTokenFormContextValue = FormContextValue<CreateSessionTokenFormValues, CreateSessionTokenFormErrorCode>\n\nexport interface CreateSessionTokenFormProps {\n\tchildren: ReactElement\n\texpiration?: number\n\tapiToken?: string\n\tonSuccess?: (args: { result: CreateSessionTokenMutationResult }) => void\n}\n\nexport const useCreateSessionTokenForm = useForm as () => CreateSessionTokenFormContextValue\n\nexport const CreateSessionTokenForm = ({ children, onSuccess, expiration, apiToken }: CreateSessionTokenFormProps) => {\n\tconst createSessionToken = useCreateSessionTokenMutation({ apiToken })\n\treturn (\n\t\t<TenantForm<CreateSessionTokenFormContextValue, CreateSessionTokenMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: CreateSessionTokenFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await createSessionToken({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\texpiration,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<CreateSessionTokenErrorCode, keyof CreateSessionTokenFormValues | undefined> = {\n\tPERSON_DISABLED: 'email',\n\tUNKNOWN_EMAIL: 'email',\n\tUNKNOWN_PERSON_ID: 'email',\n}\n"],"names":[],"mappings":";;;;AA6BO,MAAM,4BAA4B;AAElC,MAAM,yBAAyB,CAAC,EAAE,UAAU,WAAW,YAAY,eAA4C;AACrH,QAAM,qBAAqB,8BAA8B,EAAE,
|
|
1
|
+
{"version":3,"file":"CreateSessionTokenForm.js","sources":["../../../../../../packages/react-client-tenant/src/components/forms/CreateSessionTokenForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { CreateSessionTokenErrorCode } from '@contember/graphql-client-tenant'\nimport { CreateSessionTokenMutationResult, useCreateSessionTokenMutation } from '../../hooks'\n\nexport type CreateSessionTokenFormValues = {\n\temail: string\n}\n\nexport type CreateSessionTokenFormErrorCode =\n\t| CreateSessionTokenErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type CreateSessionTokenFormState = FormState\n\nexport type CreateSessionTokenFormError = FormError<CreateSessionTokenFormValues, CreateSessionTokenFormErrorCode>\n\nexport type CreateSessionTokenFormContextValue = FormContextValue<CreateSessionTokenFormValues, CreateSessionTokenFormErrorCode>\n\nexport interface CreateSessionTokenFormProps {\n\tchildren: ReactElement\n\texpiration?: number\n\tapiToken?: string\n\tonSuccess?: (args: { result: CreateSessionTokenMutationResult }) => void\n}\n\nexport const useCreateSessionTokenForm = useForm as () => CreateSessionTokenFormContextValue\n\nexport const CreateSessionTokenForm = ({ children, onSuccess, expiration, apiToken }: CreateSessionTokenFormProps) => {\n\tconst createSessionToken = useCreateSessionTokenMutation({ apiToken })\n\treturn (\n\t\t<TenantForm<CreateSessionTokenFormContextValue, CreateSessionTokenMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: CreateSessionTokenFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await createSessionToken({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\texpiration,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<CreateSessionTokenErrorCode, keyof CreateSessionTokenFormValues | undefined> = {\n\tPERSON_DISABLED: 'email',\n\tUNKNOWN_EMAIL: 'email',\n\tUNKNOWN_PERSON_ID: 'email',\n}\n"],"names":[],"mappings":";;;;AA6BO,MAAM,4BAA4B;AAElC,MAAM,yBAAyB,CAAC,EAAE,UAAU,WAAW,YAAY,eAA4C;AACrH,QAAM,qBAAqB,8BAA8B,EAAE,UAAU;AAEpE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,QACd,OAAO;AAAA,MACR;AAAA,MACA,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAAwC,CAAC;AAC3C,YAAA,CAAC,OAAO,OAAO;AAClB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QAAA;AAEhD,eAAA;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,eAAO,MAAM,mBAAmB;AAAA,UAC/B,OAAO,OAAO;AAAA,UACd;AAAA,QAAA,CACA;AAAA,MACF;AAAA,MACA,cAAc;AAAA,MAEb;AAAA,IAAA;AAAA,EACF;AAEF;AAEA,MAAM,eAAoG;AAAA,EACzG,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,mBAAmB;AACpB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InviteForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/InviteForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { InviteErrorCode, InviteOptions, MembershipInput } from '@contember/graphql-client-tenant'\nimport { InviteMutationResult, useInviteMutation } from '../../hooks'\n\nexport type InviteFormValues = {\n\temail: string\n\tname: string\n\tmemberships: readonly MembershipInput[]\n}\n\nexport type InviteFormErrorCode =\n\t| InviteErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type InviteFormState = FormState\n\nexport type InviteFormError = FormError<InviteFormValues, InviteFormErrorCode>\n\nexport type InviteFormContextValue = FormContextValue<InviteFormValues, InviteFormErrorCode>\n\nexport interface InviteFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinviteOptions?: InviteOptions\n\tinitialMemberships?: readonly MembershipInput[]\n\tonSuccess?: (args: { result: InviteMutationResult }) => void\n}\n\nexport const useInviteForm = useForm as () => InviteFormContextValue\n\nexport const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, inviteOptions }: InviteFormProps) => {\n\tconst invite = useInviteMutation()\n\treturn (\n\t\t<TenantForm<InviteFormContextValue, InviteMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tname: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: InviteFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await invite({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\tname: values.name,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\toptions: inviteOptions,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<InviteErrorCode, keyof InviteFormValues | undefined> = {\n\tALREADY_MEMBER: 'email',\n\tINVALID_EMAIL_FORMAT: 'email',\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":["useForm","useInviteMutation","jsx","TenantForm"],"mappings":";;;;;;AAgCO,MAAM,gBAAgBA,
|
|
1
|
+
{"version":3,"file":"InviteForm.cjs","sources":["../../../../../../packages/react-client-tenant/src/components/forms/InviteForm.tsx"],"sourcesContent":["import { ReactElement } from 'react'\nimport { TenantForm } from './TenantForm'\nimport { FormContextValue, FormError, FormState } from '../../types'\nimport { useForm } from '../../contexts'\nimport { InviteErrorCode, InviteOptions, MembershipInput } from '@contember/graphql-client-tenant'\nimport { InviteMutationResult, useInviteMutation } from '../../hooks'\n\nexport type InviteFormValues = {\n\temail: string\n\tname: string\n\tmemberships: readonly MembershipInput[]\n}\n\nexport type InviteFormErrorCode =\n\t| InviteErrorCode\n\t| 'UNKNOWN_ERROR'\n\t| 'FIELD_REQUIRED'\n\nexport type InviteFormState = FormState\n\nexport type InviteFormError = FormError<InviteFormValues, InviteFormErrorCode>\n\nexport type InviteFormContextValue = FormContextValue<InviteFormValues, InviteFormErrorCode>\n\nexport interface InviteFormProps {\n\tchildren: ReactElement\n\tprojectSlug: string\n\tinviteOptions?: InviteOptions\n\tinitialMemberships?: readonly MembershipInput[]\n\tonSuccess?: (args: { result: InviteMutationResult }) => void\n}\n\nexport const useInviteForm = useForm as () => InviteFormContextValue\n\nexport const InviteForm = ({ children, onSuccess, projectSlug, initialMemberships, inviteOptions }: InviteFormProps) => {\n\tconst invite = useInviteMutation()\n\treturn (\n\t\t<TenantForm<InviteFormContextValue, InviteMutationResult>\n\t\t\tonSuccess={onSuccess}\n\t\t\tinitialValues={{\n\t\t\t\temail: '',\n\t\t\t\tname: '',\n\t\t\t\tmemberships: initialMemberships || [],\n\t\t\t}}\n\t\t\tvalidate={({ values }) => {\n\t\t\t\tconst errors: InviteFormError[] = []\n\t\t\t\tif (!values.email) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'email' })\n\t\t\t\t}\n\t\t\t\tif (values.memberships.length === 0) {\n\t\t\t\t\terrors.push({ code: 'FIELD_REQUIRED', field: 'memberships' })\n\t\t\t\t}\n\t\t\t\treturn errors\n\t\t\t}}\n\t\t\texecute={async ({ values }) => {\n\t\t\t\treturn await invite({\n\t\t\t\t\temail: values.email,\n\t\t\t\t\tname: values.name,\n\t\t\t\t\tprojectSlug,\n\t\t\t\t\toptions: inviteOptions,\n\t\t\t\t\tmemberships: values.memberships,\n\t\t\t\t})\n\t\t\t}}\n\t\t\terrorMapping={errorToField}\n\t\t>\n\t\t\t{children}\n\t\t</TenantForm>\n\t)\n}\n\nconst errorToField: Record<InviteErrorCode, keyof InviteFormValues | undefined> = {\n\tALREADY_MEMBER: 'email',\n\tINVALID_EMAIL_FORMAT: 'email',\n\tINVALID_MEMBERSHIP: 'memberships',\n\tPROJECT_NOT_FOUND: undefined,\n\tROLE_NOT_FOUND: 'memberships',\n\tVARIABLE_EMPTY: 'memberships',\n\tVARIABLE_NOT_FOUND: 'memberships',\n}\n"],"names":["useForm","useInviteMutation","jsx","TenantForm"],"mappings":";;;;;;AAgCO,MAAM,gBAAgBA,SAAAA;AAEhB,MAAA,aAAa,CAAC,EAAE,UAAU,WAAW,aAAa,oBAAoB,oBAAqC;AACvH,QAAM,SAASC,kBAAAA,kBAAkB;AAEhC,SAAAC,2BAAA;AAAA,IAACC,WAAA;AAAA,IAAA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,QACd,OAAO;AAAA,QACP,MAAM;AAAA,QACN,aAAa,sBAAsB,CAAA;AAAA,MACpC;AAAA,MACA,UAAU,CAAC,EAAE,aAAa;AACzB,cAAM,SAA4B,CAAC;AAC/B,YAAA,CAAC,OAAO,OAAO;AAClB,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,SAAS;AAAA,QAAA;AAEnD,YAAA,OAAO,YAAY,WAAW,GAAG;AACpC,iBAAO,KAAK,EAAE,MAAM,kBAAkB,OAAO,eAAe;AAAA,QAAA;AAEtD,eAAA;AAAA,MACR;AAAA,MACA,SAAS,OAAO,EAAE,aAAa;AAC9B,eAAO,MAAM,OAAO;AAAA,UACnB,OAAO,OAAO;AAAA,UACd,MAAM,OAAO;AAAA,UACb;AAAA,UACA,SAAS;AAAA,UACT,aAAa,OAAO;AAAA,QAAA,CACpB;AAAA,MACF;AAAA,MACA,cAAc;AAAA,MAEb;AAAA,IAAA;AAAA,EACF;AAEF;AAEA,MAAM,eAA4E;AAAA,EACjF,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,oBAAoB;AACrB;;;"}
|