@arbidocs/react 0.5.196 → 0.5.198
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/account/identity.js +3 -1
- package/dist/account/identity.js.map +2 -2
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/workforce.js +2 -1
- package/dist/workforce.js.map +2 -2
- package/dist/workspaces/shell-workspaces.js +1 -1
- package/dist/workspaces/shell-workspaces.js.map +2 -2
- package/package.json +3 -3
package/dist/account/identity.js
CHANGED
|
@@ -216,6 +216,7 @@ function useIdentityVerificationFlow(api, {
|
|
|
216
216
|
() => apiRef.current.remove()
|
|
217
217
|
);
|
|
218
218
|
if (next) apply(next);
|
|
219
|
+
return !!next;
|
|
219
220
|
}, [run, apply]);
|
|
220
221
|
const price = useMemo(() => status ? formatPrice(status) : null, [status, formatPrice]);
|
|
221
222
|
return {
|
|
@@ -242,7 +243,8 @@ function useIdentityVerificationFlow(api, {
|
|
|
242
243
|
checkResult: () => void refresh(),
|
|
243
244
|
retry: () => void startVerify(),
|
|
244
245
|
acceptName: () => void acceptName(),
|
|
245
|
-
|
|
246
|
+
// Not closing the dialog: a name that differs from the ID is changed or the verification cancelled.
|
|
247
|
+
keepName: () => void remove().then((ok) => ok && close()),
|
|
246
248
|
remove: () => void remove()
|
|
247
249
|
};
|
|
248
250
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/account/identity.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Identity verification: the optional, paid ID check behind the verified tick (Pro plans only).\n *\n * Two layers, like `profile.ts`. `useIdentityVerificationFlow` owns the dialog's state and takes\n * the backend calls as functions, so an app with its own API layer (ARBI-frontend) binds the same\n * `IdentityVerificationCard` / `IdentityVerificationDialog` blocks without a provider.\n * `useIdentityVerification` binds it to the SDK (`arbi.identity`).\n *\n * Steps: pay the one-time fee (charged to the user's Pro project card) \u2192 verify inside Didit's\n * embedded frame \u2192 result (verified, declined, in review, or the name on the document differs from\n * the account name, offered as the new name). No webhooks: completing Didit's flow calls `refresh`.\n */\n\nimport { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { identityErrorCode } from '@arbidocs/sdk/browser'\nimport { useAccountClient } from './client'\nimport { arbiQueryKeys } from '../hooks'\nimport { mountDiditVerification } from './didit'\nimport type {\n IdentityBusy,\n IdentityProblem,\n IdentityPurchase,\n IdentityStatus,\n IdentityStep,\n IdentityVerificationFlow,\n} from './identity-types'\n\nexport type {\n IdentityBusy,\n IdentityProblem,\n IdentityPurchase,\n IdentityState,\n IdentityStatus,\n IdentityStep,\n IdentityVerificationFlow,\n} from './identity-types'\n\n/** The backend calls of the flow, as functions (see the module comment). */\nexport interface IdentityVerificationApi {\n status: () => Promise<IdentityStatus>\n purchase: () => Promise<IdentityPurchase>\n /** The Didit session URL. */\n startSession: () => Promise<string>\n refresh: () => Promise<IdentityStatus>\n acceptName: () => Promise<IdentityStatus>\n remove: () => Promise<IdentityStatus>\n}\n\nexport interface UseIdentityVerificationFlowOptions {\n /** Load the status (default true; e.g. false while signed out). */\n enabled?: boolean\n /** The tick changed (granted, renamed away, removed): update the host's copy of the user. */\n onVerifiedChange?: (verified: boolean) => void\n /** The account name became the name on the document. */\n onNameAccepted?: (name: { givenName: string; familyName: string | null }) => void\n /** The host's price format (e.g. its billing helpers); default `formatIdentityPrice`. */\n formatPrice?: (status: IdentityStatus) => string\n}\n\nfunction problemOf(error: unknown, fallback: string): IdentityProblem {\n const code = identityErrorCode(error) ?? (error as { code?: unknown } | null)?.code\n const message = error instanceof Error && error.message ? error.message : fallback\n return { code: typeof code === 'string' ? code : undefined, message }\n}\n\n/** Which step the dialog opens on for a status. */\nexport function identityStepFor(status: IdentityStatus | undefined): IdentityStep {\n if (!status) return 'pay'\n // Free check: nothing to pay, so any state without a result goes straight to a (new) session.\n if (status.free && ['none', 'in_progress'].includes(status.state)) return 'verify'\n if (['name_mismatch', 'in_review', 'verified'].includes(status.state)) return 'result'\n if (status.state === 'declined') return status.attempts_left > 0 || status.free ? 'result' : 'pay'\n if (status.state === 'in_progress' || status.attempts_left > 0) return 'verify'\n return 'pay'\n}\n\n/** \"\u00A35.00 incl. VAT\": the fee is quoted including UK VAT. */\nexport function formatIdentityPrice(status: IdentityStatus): string {\n let amount: string\n try {\n amount = new Intl.NumberFormat('en-GB', {\n style: 'currency',\n currency: status.currency,\n }).format(status.price_pence / 100)\n } catch {\n amount = `${(status.price_pence / 100).toFixed(2)} ${status.currency}`\n }\n return `${amount} incl. VAT`\n}\n\n/** The identity verification dialog's state, bound to the backend calls in `api`. */\nexport function useIdentityVerificationFlow(\n api: IdentityVerificationApi,\n {\n enabled = true,\n onVerifiedChange,\n onNameAccepted,\n formatPrice = formatIdentityPrice,\n }: UseIdentityVerificationFlowOptions = {}\n): IdentityVerificationFlow {\n const qc = useQueryClient()\n const apiRef = useRef(api)\n apiRef.current = api\n const query = useQuery({\n queryKey: arbiQueryKeys.identity(),\n queryFn: () => apiRef.current.status(),\n enabled,\n staleTime: 60_000,\n })\n const status = query.data\n const statusRef = useRef(status)\n statusRef.current = status\n\n const [isOpen, setIsOpen] = useState(false)\n const [step, setStep] = useState<IdentityStep>('pay')\n const [busy, setBusy] = useState<IdentityBusy>(null)\n const [problem, setProblem] = useState<IdentityProblem | null>(null)\n const [paymentUrl, setPaymentUrl] = useState<string | null>(null)\n const [sessionUrl, setSessionUrl] = useState<string | null>(null)\n const [container, setContainer] = useState<HTMLElement | null>(null)\n const [embedFailed, setEmbedFailed] = useState(false)\n const verifyContainerId = `didit-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`\n\n const lastVerified = useRef<boolean | undefined>(undefined)\n const apply = useCallback(\n (next: IdentityStatus) => {\n qc.setQueryData(arbiQueryKeys.identity(), next)\n if (lastVerified.current !== undefined && lastVerified.current !== next.verified) {\n onVerifiedChange?.(next.verified)\n }\n lastVerified.current = next.verified\n return next\n },\n [qc, onVerifiedChange]\n )\n useEffect(() => {\n if (status && lastVerified.current === undefined) lastVerified.current = status.verified\n }, [status])\n\n const run = useCallback(\n async <T>(kind: Exclude<IdentityBusy, null>, fallback: string, fn: () => Promise<T>) => {\n setBusy(kind)\n setProblem(null)\n try {\n return await fn()\n } catch (e) {\n setProblem(problemOf(e, fallback))\n return undefined\n } finally {\n setBusy(null)\n }\n },\n []\n )\n\n const isOpenRef = useRef(false)\n const closeRef = useRef<() => void>(() => {})\n const startVerifyRef = useRef<() => Promise<void>>(async () => {})\n\n const refresh = useCallback(async () => {\n const next = await run('refresh', 'Could not read the verification result', () =>\n apiRef.current.refresh()\n )\n if (!next) return\n apply(next)\n if (next.state === 'in_progress') return\n setSessionUrl(null)\n const nextStep = next.state === 'declined' ? 'result' : identityStepFor(next)\n // An abandoned or expired session (state none, attempts left): open a fresh one.\n if (nextStep === 'verify' && isOpenRef.current) void startVerifyRef.current()\n else setStep(nextStep)\n }, [run, apply])\n\n // A check left open (closed tab, reload, manual review): ask for its result once on load.\n const refreshedOnLoad = useRef(false)\n useEffect(() => {\n if (refreshedOnLoad.current || !status) return\n refreshedOnLoad.current = true\n if (status.state === 'in_progress' || status.state === 'in_review') void refresh()\n }, [status, refresh])\n\n const startVerify = useCallback(async () => {\n setStep('verify')\n setEmbedFailed(false)\n const url = await run('start', 'Could not start identity verification', () =>\n apiRef.current.startSession()\n )\n if (url) {\n setSessionUrl(url)\n return\n }\n // Still unpaid (a 3-D Secure payment not confirmed yet): back to the payment step. A free\n // check has no payment step: stay, with the problem shown and a retry.\n if (!statusRef.current?.free) setStep('pay')\n }, [run])\n startVerifyRef.current = startVerify\n\n // Mount Didit once the session is open and its host element is on screen.\n useEffect(() => {\n if (!isOpen || step !== 'verify' || !sessionUrl || !container || embedFailed) return\n let teardown: (() => void) | undefined\n let cancelled = false\n mountDiditVerification({\n url: sessionUrl,\n containerId: container.id,\n onResult: (result) => {\n if (result.type === 'failed' && result.error?.type === 'cameraAccessDenied') {\n setEmbedFailed(true)\n return\n }\n if (result.type === 'cancelled') {\n closeRef.current()\n return\n }\n void refresh()\n },\n })\n .then((stop) => {\n if (cancelled) stop()\n else teardown = stop\n })\n .catch(() => setEmbedFailed(true))\n return () => {\n cancelled = true\n teardown?.()\n }\n }, [isOpen, step, sessionUrl, container, embedFailed, refresh])\n\n // Verifying in another tab: look for the result when the user comes back.\n const [waitingInTab, setWaitingInTab] = useState(false)\n useEffect(() => {\n if (!waitingInTab || typeof window === 'undefined') return\n const onFocus = () => void refresh()\n window.addEventListener('focus', onFocus)\n return () => window.removeEventListener('focus', onFocus)\n }, [waitingInTab, refresh])\n\n const open = useCallback(() => {\n isOpenRef.current = true\n setProblem(null)\n setPaymentUrl(status?.pending_payment_url ?? null)\n const first = identityStepFor(status)\n setStep(first)\n setIsOpen(true)\n if (first === 'verify') void startVerify()\n }, [status, startVerify])\n\n const close = useCallback(() => {\n isOpenRef.current = false\n setIsOpen(false)\n setSessionUrl(null)\n setWaitingInTab(false)\n setEmbedFailed(false)\n setProblem(null)\n }, [])\n closeRef.current = close\n\n const pay = useCallback(async () => {\n const result = await run('pay', 'Payment could not be completed', () =>\n apiRef.current.purchase()\n )\n if (!result) return\n if (result.status === 'requires_action') {\n setPaymentUrl(result.payment_url ?? null)\n return\n }\n setPaymentUrl(null)\n void query.refetch()\n void startVerify()\n }, [run, query, startVerify])\n\n const acceptName = useCallback(async () => {\n const offered = status\n const next = await run('accept', 'Could not change your name', () =>\n apiRef.current.acceptName()\n )\n if (!next) return\n apply(next)\n if (offered?.document_given_name) {\n onNameAccepted?.({\n givenName: offered.document_given_name,\n familyName: offered.document_family_name ?? null,\n })\n }\n }, [run, apply, status, onNameAccepted])\n\n const remove = useCallback(async () => {\n const next = await run('remove', 'Could not remove the verification', () =>\n apiRef.current.remove()\n )\n if (next) apply(next)\n }, [run, apply])\n\n const price = useMemo(() => (status ? formatPrice(status) : null), [status, formatPrice])\n\n return {\n status,\n isLoading: query.isLoading,\n price,\n isOpen,\n open,\n close,\n step,\n busy,\n problem,\n paymentUrl,\n pay: () => void pay(),\n recheckPayment: () => void startVerify(),\n verifyContainerId,\n verifyContainerRef: setContainer,\n embedFailed,\n openInNewTab: () => {\n if (!sessionUrl || typeof window === 'undefined') return\n window.open(sessionUrl, '_blank', 'noopener')\n setWaitingInTab(true)\n },\n checkResult: () => void refresh(),\n retry: () => void startVerify(),\n acceptName: () => void acceptName(),\n keepName: close,\n remove: () => void remove(),\n }\n}\n\n// \u2500\u2500 Bound \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * The identity verification flow over the account client in scope; the profile query follows the\n * tick and name.\n */\nexport function useIdentityVerification(\n options: Omit<UseIdentityVerificationFlowOptions, 'enabled'> = {}\n): IdentityVerificationFlow {\n const { client, enabled } = useAccountClient()\n const qc = useQueryClient()\n const { onVerifiedChange, onNameAccepted, formatPrice } = options\n return useIdentityVerificationFlow(client.identity, {\n enabled,\n formatPrice,\n onVerifiedChange: (verified) => {\n void qc.invalidateQueries({ queryKey: arbiQueryKeys.profile() })\n onVerifiedChange?.(verified)\n },\n onNameAccepted: (name) => {\n void qc.invalidateQueries({ queryKey: arbiQueryKeys.profile() })\n void qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() })\n onNameAccepted?.(name)\n },\n })\n}\n"],
|
|
5
|
-
"mappings": "AAaA,SAAS,aAAa,WAAW,OAAO,SAAS,QAAQ,gB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AACpB,eAAW,IAAI;AAAA,EACjB,GAAG,CAAC,CAAC;AACL,WAAS,UAAU;AAEnB,QAAM,MAAM,YAAY,YAAY;AAClC,UAAM,SAAS,MAAM;AAAA,MAAI;AAAA,MAAO;AAAA,MAAkC,MAChE,OAAO,QAAQ,SAAS;AAAA,IAC1B;AACA,QAAI,CAAC,OAAQ;AACb,QAAI,OAAO,WAAW,mBAAmB;AACvC,oBAAc,OAAO,eAAe,IAAI;AACxC;AAAA,IACF;AACA,kBAAc,IAAI;AAClB,SAAK,MAAM,QAAQ;AACnB,SAAK,YAAY;AAAA,EACnB,GAAG,CAAC,KAAK,OAAO,WAAW,CAAC;AAE5B,QAAM,aAAa,YAAY,YAAY;AACzC,UAAM,UAAU;AAChB,UAAM,OAAO,MAAM;AAAA,MAAI;AAAA,MAAU;AAAA,MAA8B,MAC7D,OAAO,QAAQ,WAAW;AAAA,IAC5B;AACA,QAAI,CAAC,KAAM;AACX,UAAM,IAAI;AACV,QAAI,SAAS,qBAAqB;AAChC,uBAAiB;AAAA,QACf,WAAW,QAAQ;AAAA,QACnB,YAAY,QAAQ,wBAAwB;AAAA,MAC9C,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,KAAK,OAAO,QAAQ,cAAc,CAAC;AAEvC,QAAM,SAAS,YAAY,YAAY;AACrC,UAAM,OAAO,MAAM;AAAA,MAAI;AAAA,MAAU;AAAA,MAAqC,MACpE,OAAO,QAAQ,OAAO;AAAA,IACxB;AACA,QAAI,KAAM,OAAM,IAAI;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * Identity verification: the optional, paid ID check behind the verified tick (Pro plans only).\n *\n * Two layers, like `profile.ts`. `useIdentityVerificationFlow` owns the dialog's state and takes\n * the backend calls as functions, so an app with its own API layer (ARBI-frontend) binds the same\n * `IdentityVerificationCard` / `IdentityVerificationDialog` blocks without a provider.\n * `useIdentityVerification` binds it to the SDK (`arbi.identity`).\n *\n * Steps: pay the one-time fee (charged to the user's Pro project card) \u2192 verify inside Didit's\n * embedded frame \u2192 result (verified, declined, in review, or the name on the document differs from\n * the account name, offered as the new name). No webhooks: completing Didit's flow calls `refresh`.\n */\n\nimport { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { identityErrorCode } from '@arbidocs/sdk/browser'\nimport { useAccountClient } from './client'\nimport { arbiQueryKeys } from '../hooks'\nimport { mountDiditVerification } from './didit'\nimport type {\n IdentityBusy,\n IdentityProblem,\n IdentityPurchase,\n IdentityStatus,\n IdentityStep,\n IdentityVerificationFlow,\n} from './identity-types'\n\nexport type {\n IdentityBusy,\n IdentityProblem,\n IdentityPurchase,\n IdentityState,\n IdentityStatus,\n IdentityStep,\n IdentityVerificationFlow,\n} from './identity-types'\n\n/** The backend calls of the flow, as functions (see the module comment). */\nexport interface IdentityVerificationApi {\n status: () => Promise<IdentityStatus>\n purchase: () => Promise<IdentityPurchase>\n /** The Didit session URL. */\n startSession: () => Promise<string>\n refresh: () => Promise<IdentityStatus>\n acceptName: () => Promise<IdentityStatus>\n remove: () => Promise<IdentityStatus>\n}\n\nexport interface UseIdentityVerificationFlowOptions {\n /** Load the status (default true; e.g. false while signed out). */\n enabled?: boolean\n /** The tick changed (granted, renamed away, removed): update the host's copy of the user. */\n onVerifiedChange?: (verified: boolean) => void\n /** The account name became the name on the document. */\n onNameAccepted?: (name: { givenName: string; familyName: string | null }) => void\n /** The host's price format (e.g. its billing helpers); default `formatIdentityPrice`. */\n formatPrice?: (status: IdentityStatus) => string\n}\n\nfunction problemOf(error: unknown, fallback: string): IdentityProblem {\n const code = identityErrorCode(error) ?? (error as { code?: unknown } | null)?.code\n const message = error instanceof Error && error.message ? error.message : fallback\n return { code: typeof code === 'string' ? code : undefined, message }\n}\n\n/** Which step the dialog opens on for a status. */\nexport function identityStepFor(status: IdentityStatus | undefined): IdentityStep {\n if (!status) return 'pay'\n // Free check: nothing to pay, so any state without a result goes straight to a (new) session.\n if (status.free && ['none', 'in_progress'].includes(status.state)) return 'verify'\n if (['name_mismatch', 'in_review', 'verified'].includes(status.state)) return 'result'\n if (status.state === 'declined') return status.attempts_left > 0 || status.free ? 'result' : 'pay'\n if (status.state === 'in_progress' || status.attempts_left > 0) return 'verify'\n return 'pay'\n}\n\n/** \"\u00A35.00 incl. VAT\": the fee is quoted including UK VAT. */\nexport function formatIdentityPrice(status: IdentityStatus): string {\n let amount: string\n try {\n amount = new Intl.NumberFormat('en-GB', {\n style: 'currency',\n currency: status.currency,\n }).format(status.price_pence / 100)\n } catch {\n amount = `${(status.price_pence / 100).toFixed(2)} ${status.currency}`\n }\n return `${amount} incl. VAT`\n}\n\n/** The identity verification dialog's state, bound to the backend calls in `api`. */\nexport function useIdentityVerificationFlow(\n api: IdentityVerificationApi,\n {\n enabled = true,\n onVerifiedChange,\n onNameAccepted,\n formatPrice = formatIdentityPrice,\n }: UseIdentityVerificationFlowOptions = {}\n): IdentityVerificationFlow {\n const qc = useQueryClient()\n const apiRef = useRef(api)\n apiRef.current = api\n const query = useQuery({\n queryKey: arbiQueryKeys.identity(),\n queryFn: () => apiRef.current.status(),\n enabled,\n staleTime: 60_000,\n })\n const status = query.data\n const statusRef = useRef(status)\n statusRef.current = status\n\n const [isOpen, setIsOpen] = useState(false)\n const [step, setStep] = useState<IdentityStep>('pay')\n const [busy, setBusy] = useState<IdentityBusy>(null)\n const [problem, setProblem] = useState<IdentityProblem | null>(null)\n const [paymentUrl, setPaymentUrl] = useState<string | null>(null)\n const [sessionUrl, setSessionUrl] = useState<string | null>(null)\n const [container, setContainer] = useState<HTMLElement | null>(null)\n const [embedFailed, setEmbedFailed] = useState(false)\n const verifyContainerId = `didit-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`\n\n const lastVerified = useRef<boolean | undefined>(undefined)\n const apply = useCallback(\n (next: IdentityStatus) => {\n qc.setQueryData(arbiQueryKeys.identity(), next)\n if (lastVerified.current !== undefined && lastVerified.current !== next.verified) {\n onVerifiedChange?.(next.verified)\n }\n lastVerified.current = next.verified\n return next\n },\n [qc, onVerifiedChange]\n )\n useEffect(() => {\n if (status && lastVerified.current === undefined) lastVerified.current = status.verified\n }, [status])\n\n const run = useCallback(\n async <T>(kind: Exclude<IdentityBusy, null>, fallback: string, fn: () => Promise<T>) => {\n setBusy(kind)\n setProblem(null)\n try {\n return await fn()\n } catch (e) {\n setProblem(problemOf(e, fallback))\n return undefined\n } finally {\n setBusy(null)\n }\n },\n []\n )\n\n const isOpenRef = useRef(false)\n const closeRef = useRef<() => void>(() => {})\n const startVerifyRef = useRef<() => Promise<void>>(async () => {})\n\n const refresh = useCallback(async () => {\n const next = await run('refresh', 'Could not read the verification result', () =>\n apiRef.current.refresh()\n )\n if (!next) return\n apply(next)\n if (next.state === 'in_progress') return\n setSessionUrl(null)\n const nextStep = next.state === 'declined' ? 'result' : identityStepFor(next)\n // An abandoned or expired session (state none, attempts left): open a fresh one.\n if (nextStep === 'verify' && isOpenRef.current) void startVerifyRef.current()\n else setStep(nextStep)\n }, [run, apply])\n\n // A check left open (closed tab, reload, manual review): ask for its result once on load.\n const refreshedOnLoad = useRef(false)\n useEffect(() => {\n if (refreshedOnLoad.current || !status) return\n refreshedOnLoad.current = true\n if (status.state === 'in_progress' || status.state === 'in_review') void refresh()\n }, [status, refresh])\n\n const startVerify = useCallback(async () => {\n setStep('verify')\n setEmbedFailed(false)\n const url = await run('start', 'Could not start identity verification', () =>\n apiRef.current.startSession()\n )\n if (url) {\n setSessionUrl(url)\n return\n }\n // Still unpaid (a 3-D Secure payment not confirmed yet): back to the payment step. A free\n // check has no payment step: stay, with the problem shown and a retry.\n if (!statusRef.current?.free) setStep('pay')\n }, [run])\n startVerifyRef.current = startVerify\n\n // Mount Didit once the session is open and its host element is on screen.\n useEffect(() => {\n if (!isOpen || step !== 'verify' || !sessionUrl || !container || embedFailed) return\n let teardown: (() => void) | undefined\n let cancelled = false\n mountDiditVerification({\n url: sessionUrl,\n containerId: container.id,\n onResult: (result) => {\n if (result.type === 'failed' && result.error?.type === 'cameraAccessDenied') {\n setEmbedFailed(true)\n return\n }\n if (result.type === 'cancelled') {\n closeRef.current()\n return\n }\n void refresh()\n },\n })\n .then((stop) => {\n if (cancelled) stop()\n else teardown = stop\n })\n .catch(() => setEmbedFailed(true))\n return () => {\n cancelled = true\n teardown?.()\n }\n }, [isOpen, step, sessionUrl, container, embedFailed, refresh])\n\n // Verifying in another tab: look for the result when the user comes back.\n const [waitingInTab, setWaitingInTab] = useState(false)\n useEffect(() => {\n if (!waitingInTab || typeof window === 'undefined') return\n const onFocus = () => void refresh()\n window.addEventListener('focus', onFocus)\n return () => window.removeEventListener('focus', onFocus)\n }, [waitingInTab, refresh])\n\n const open = useCallback(() => {\n isOpenRef.current = true\n setProblem(null)\n setPaymentUrl(status?.pending_payment_url ?? null)\n const first = identityStepFor(status)\n setStep(first)\n setIsOpen(true)\n if (first === 'verify') void startVerify()\n }, [status, startVerify])\n\n const close = useCallback(() => {\n isOpenRef.current = false\n setIsOpen(false)\n setSessionUrl(null)\n setWaitingInTab(false)\n setEmbedFailed(false)\n setProblem(null)\n }, [])\n closeRef.current = close\n\n const pay = useCallback(async () => {\n const result = await run('pay', 'Payment could not be completed', () =>\n apiRef.current.purchase()\n )\n if (!result) return\n if (result.status === 'requires_action') {\n setPaymentUrl(result.payment_url ?? null)\n return\n }\n setPaymentUrl(null)\n void query.refetch()\n void startVerify()\n }, [run, query, startVerify])\n\n const acceptName = useCallback(async () => {\n const offered = status\n const next = await run('accept', 'Could not change your name', () =>\n apiRef.current.acceptName()\n )\n if (!next) return\n apply(next)\n if (offered?.document_given_name) {\n onNameAccepted?.({\n givenName: offered.document_given_name,\n familyName: offered.document_family_name ?? null,\n })\n }\n }, [run, apply, status, onNameAccepted])\n\n const remove = useCallback(async () => {\n const next = await run('remove', 'Could not remove the verification', () =>\n apiRef.current.remove()\n )\n if (next) apply(next)\n return !!next\n }, [run, apply])\n\n const price = useMemo(() => (status ? formatPrice(status) : null), [status, formatPrice])\n\n return {\n status,\n isLoading: query.isLoading,\n price,\n isOpen,\n open,\n close,\n step,\n busy,\n problem,\n paymentUrl,\n pay: () => void pay(),\n recheckPayment: () => void startVerify(),\n verifyContainerId,\n verifyContainerRef: setContainer,\n embedFailed,\n openInNewTab: () => {\n if (!sessionUrl || typeof window === 'undefined') return\n window.open(sessionUrl, '_blank', 'noopener')\n setWaitingInTab(true)\n },\n checkResult: () => void refresh(),\n retry: () => void startVerify(),\n acceptName: () => void acceptName(),\n // Not closing the dialog: a name that differs from the ID is changed or the verification cancelled.\n keepName: () => void remove().then((ok) => ok && close()),\n remove: () => void remove(),\n }\n}\n\n// \u2500\u2500 Bound \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n/**\n * The identity verification flow over the account client in scope; the profile query follows the\n * tick and name.\n */\nexport function useIdentityVerification(\n options: Omit<UseIdentityVerificationFlowOptions, 'enabled'> = {}\n): IdentityVerificationFlow {\n const { client, enabled } = useAccountClient()\n const qc = useQueryClient()\n const { onVerifiedChange, onNameAccepted, formatPrice } = options\n return useIdentityVerificationFlow(client.identity, {\n enabled,\n formatPrice,\n onVerifiedChange: (verified) => {\n void qc.invalidateQueries({ queryKey: arbiQueryKeys.profile() })\n onVerifiedChange?.(verified)\n },\n onNameAccepted: (name) => {\n void qc.invalidateQueries({ queryKey: arbiQueryKeys.profile() })\n void qc.invalidateQueries({ queryKey: arbiQueryKeys.workspaces() })\n onNameAccepted?.(name)\n },\n })\n}\n"],
|
|
5
|
+
"mappings": "AAaA,SAAS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
503
503
|
const arbi = chunkSJZRVX7T_cjs.useArbi();
|
|
504
|
+
chunkBEOHXA2Z_cjs.useArbiSessionState((s) => s.workspaceStatus);
|
|
504
505
|
const workspaceId = arbi.hasWorkspace ? arbi.getWorkspaceId() : "";
|
|
505
506
|
return reactQuery.useQuery({
|
|
506
507
|
queryKey: chunkSJZRVX7T_cjs.arbiQueryKeys.skillList(workspaceId, options?.includeHidden ?? false),
|
|
@@ -509,7 +510,7 @@ function useSkills(options) {
|
|
|
509
510
|
workspaceId: workspaceId || void 0
|
|
510
511
|
}),
|
|
511
512
|
refetchInterval: options?.live ? 5e3 : false,
|
|
512
|
-
enabled: (options?.enabled ?? true) && arbi.isLoggedIn,
|
|
513
|
+
enabled: (options?.enabled ?? true) && arbi.isLoggedIn && workspaceId !== "",
|
|
513
514
|
staleTime: 3e4
|
|
514
515
|
});
|
|
515
516
|
}
|
|
@@ -9260,7 +9261,7 @@ function resolveActiveWorkspace(items, selectedId, options = {}) {
|
|
|
9260
9261
|
const seeded = items.find((w) => w.id === options.seedActiveId);
|
|
9261
9262
|
if (seeded) return seeded;
|
|
9262
9263
|
}
|
|
9263
|
-
return
|
|
9264
|
+
return void 0;
|
|
9264
9265
|
}
|
|
9265
9266
|
function pickRecentWorkspaces(items, activeId, options = {}) {
|
|
9266
9267
|
const { limit = 4, lastOpened, formatLastSeen } = options;
|
|
@@ -14162,6 +14163,7 @@ function useIdentityVerificationFlow(api, {
|
|
|
14162
14163
|
() => apiRef.current.remove()
|
|
14163
14164
|
);
|
|
14164
14165
|
if (next) apply(next);
|
|
14166
|
+
return !!next;
|
|
14165
14167
|
}, [run2, apply]);
|
|
14166
14168
|
const price = React.useMemo(() => status ? formatPrice(status) : null, [status, formatPrice]);
|
|
14167
14169
|
return {
|
|
@@ -14188,7 +14190,8 @@ function useIdentityVerificationFlow(api, {
|
|
|
14188
14190
|
checkResult: () => void refresh(),
|
|
14189
14191
|
retry: () => void startVerify(),
|
|
14190
14192
|
acceptName: () => void acceptName(),
|
|
14191
|
-
|
|
14193
|
+
// Not closing the dialog: a name that differs from the ID is changed or the verification cancelled.
|
|
14194
|
+
keepName: () => void remove().then((ok) => ok && close()),
|
|
14192
14195
|
remove: () => void remove()
|
|
14193
14196
|
};
|
|
14194
14197
|
}
|