@sanity/access-ui 6.23.0-next.26 → 6.23.0-next.38

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/lib/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { c } from "react/compiler-runtime";
2
2
  import { LaunchIcon } from "@sanity/icons/Launch";
3
- import { Avatar, Button, Card, Spinner, Text, TextArea } from "@sanity/ui";
3
+ import { Avatar, Button, Card, Spinner, TextArea } from "@sanity/ui";
4
4
  import { Suspense, use, useId, useState, useTransition } from "react";
5
5
  import { useObservablePromise } from "react-rx";
6
6
  import { catchError, combineLatest, defer, of } from "rxjs";
7
- import { Box, Flex, VStack } from "ui5";
7
+ import { Box, Flex, Text, VStack } from "ui5";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  /**
10
10
  * The Access API only accepts notes up to this length.
@@ -323,7 +323,7 @@ function RequestAccessFormContent(props) {
323
323
  labels
324
324
  }), submitFailed = submitAccessRequestResult?.type === "error", t2;
325
325
  $[2] !== client || $[3] !== isSubmitting || $[4] !== note || $[5] !== onRequestSubmitted || $[6] !== resourceId || $[7] !== resourceType ? (t2 = (event) => {
326
- event.preventDefault(), !isSubmitting && startSubmit(async () => {
326
+ event.preventDefault(), isSubmitting || startSubmit(async () => {
327
327
  let trimmedNote = note.trim() || void 0, result = await submitAccessRequest({
328
328
  client,
329
329
  resourceType,
@@ -355,12 +355,14 @@ function RequestAccessFormContent(props) {
355
355
  id: titleId,
356
356
  size: 2,
357
357
  weight: "semibold",
358
+ trim: !0,
358
359
  children: state.title
359
360
  }),
360
361
  state.description === null ? null : /* @__PURE__ */ jsx(Text, {
361
362
  as: "p",
362
363
  muted: !0,
363
364
  size: 1,
365
+ trim: !0,
364
366
  children: state.description
365
367
  }),
366
368
  state.view === "blocked" || state.view === "sso-enforced" ? /* @__PURE__ */ jsxs(VStack, {
@@ -375,6 +377,8 @@ function RequestAccessFormContent(props) {
375
377
  as: "p",
376
378
  muted: !0,
377
379
  size: 1,
380
+ trim: !0,
381
+ tone: "caution",
378
382
  children: state.message
379
383
  })
380
384
  }), state.view === "sso-enforced" && state.redirectUrl ? /* @__PURE__ */ jsx(Button, {
@@ -395,6 +399,7 @@ function RequestAccessFormContent(props) {
395
399
  /* @__PURE__ */ jsx(Text, {
396
400
  as: "p",
397
401
  size: 1,
402
+ trim: !0,
398
403
  children: state.expired ? labels.expiredMessage : resourceType === "organization" ? labels.promptOrganization : labels.promptProject
399
404
  }),
400
405
  /* @__PURE__ */ jsxs(VStack, {
@@ -412,6 +417,8 @@ function RequestAccessFormContent(props) {
412
417
  align: "right",
413
418
  muted: !0,
414
419
  size: 0,
420
+ as: "div",
421
+ trim: !0,
415
422
  children: `${note.length}/150`
416
423
  })]
417
424
  }),
@@ -425,6 +432,8 @@ function RequestAccessFormContent(props) {
425
432
  as: "p",
426
433
  muted: !0,
427
434
  size: 1,
435
+ trim: !0,
436
+ tone: "critical",
428
437
  children: labels.submitFailedMessage
429
438
  })
430
439
  }) : null,
@@ -457,7 +466,9 @@ function RequestAccessFormContent(props) {
457
466
  }), /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Text, {
458
467
  muted: !0,
459
468
  size: 1,
460
- textOverflow: "ellipsis",
469
+ truncate: 1,
470
+ as: "div",
471
+ trim: !0,
461
472
  children: [currentUser.email ?? currentUser.name, providerTitle ? ` · ${providerTitle}` : ""]
462
473
  }) })]
463
474
  }), onSignOut ? /* @__PURE__ */ jsx(Button, {
@@ -469,6 +480,8 @@ function RequestAccessFormContent(props) {
469
480
  children: /* @__PURE__ */ jsxs(Text, {
470
481
  muted: !0,
471
482
  size: 1,
483
+ as: "div",
484
+ trim: !0,
472
485
  children: [
473
486
  labels.wrongAccount,
474
487
  " ",
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_Fragment","resourceType = 'project'","() =>\n combineLatest({\n accessRequestsHistory: defer(() => listMyAccessRequests(client)).pipe(\n catchError(() => of(null)),\n ),\n accessRequestEligibilityState: defer(() =>\n fetchAccessRequestStatus({client, resourceType, resourceId, origin: getRequestUrl()}),\n ),\n })","() => of(null)","<Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\" padding={5}>\n <Spinner muted />\n </Flex>","<Card border height=\"fill\" overflow=\"hidden\" radius={3} tone=\"default\">\n <Suspense\n fallback={\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\" padding={5}>\n <Spinner muted />\n </Flex>\n }\n >\n <RequestAccessFormContent {...props} loadPromise={loadPromise} />\n </Suspense>\n </Card>","currentUser?.provider?.startsWith('saml-')","provider","(event: SubmitEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (isSubmitting) return\n startSubmit(async () => {\n const trimmedNote = note.trim() || undefined\n const result = await submitAccessRequest({\n client,\n resourceType,\n resourceId,\n note: trimmedNote,\n requestUrl: getRequestUrl(),\n })\n setSubmitAccessRequestResult(result)\n if (result.type === 'submitted') onRequestSubmitted?.({note: trimmedNote})\n })\n }","preview ? (\n <Flex justifyContent=\"center\" padding={2}>\n {preview}\n </Flex>\n ) : null","event","_c"],"sources":["../src/accessRequests.ts","../src/deriveAccessRequestState.ts","../src/providerTitle.ts","../src/labels.tsx","../src/RequestAccessForm.tsx"],"sourcesContent":["import {type SanityClient} from '@sanity/client'\n\nimport {\n type AccessRequest,\n type AccessRequestEligibilityState,\n type AccessResourceType,\n type SubmitAccessRequestResult,\n} from './types'\n\n/**\n * The Access API only accepts notes up to this length.\n *\n * @public\n */\nexport const MAX_ACCESS_REQUEST_NOTE_LENGTH = 150\n\nconst ACCESS_API_VERSION = '2024-07-01'\n\n/**\n * Structured 403 code thrown by the Access API when the target organization\n * only admits members through its SSO login flow.\n */\nconst SAML_ENFORCEMENT_REQUIRED = 'saml_enforcement_required'\n\nfunction withAccessApiVersion(client: SanityClient): SanityClient {\n return client.withConfig({apiVersion: ACCESS_API_VERSION})\n}\n\n/**\n * Fetches the caller's own access requests across all resources\n * (`GET /access/requests/me`).\n *\n * @public\n */\nexport async function listMyAccessRequests(client: SanityClient): Promise<AccessRequest[]> {\n const requests = await withAccessApiVersion(client).request<AccessRequest[] | null>({\n url: '/access/requests/me',\n tag: 'access-ui.list-requests',\n })\n return requests ?? []\n}\n\n/**\n * Asks what the request-access screen should show\n * (`GET /access/{resourceType}/{resourceId}/requests/state`).\n *\n * Runs before the form is offered, so a user in a SAML-enforced organization is\n * pointed at SSO instead of writing a note no administrator can action.\n *\n * `origin` is carried opaquely to the login page so the user returns where they\n * started. Never throws: an unreachable or older API answers `eligible`,\n * leaving the form in place and the submit-time 403 as the backstop.\n *\n * @public\n */\nexport async function fetchAccessRequestStatus(options: {\n client: SanityClient\n resourceType: AccessResourceType\n resourceId: string\n origin?: string\n}): Promise<AccessRequestEligibilityState> {\n const {client, resourceType, resourceId, origin} = options\n try {\n const status = await withAccessApiVersion(client).request<AccessRequestEligibilityState | null>(\n {\n url: `/access/${resourceType}/${resourceId}/requests/state`,\n tag: 'access-ui.request-state',\n query: origin ? {returnQuery: new URLSearchParams({origin}).toString()} : undefined,\n },\n )\n return status ?? {state: 'eligible'}\n } catch {\n return {state: 'eligible'}\n }\n}\n\ninterface ErrorResponseDetails {\n statusCode?: number\n message?: string\n code?: string\n redirectUrl?: string\n}\n\nfunction getErrorResponseDetails(err: unknown): ErrorResponseDetails {\n if (typeof err !== 'object' || err === null) return {}\n const response = (err as {response?: unknown}).response\n if (typeof response !== 'object' || response === null) return {}\n const {statusCode} = response as {statusCode?: unknown}\n const body = (response as {body?: unknown}).body\n const details: ErrorResponseDetails = {\n statusCode: typeof statusCode === 'number' ? statusCode : undefined,\n }\n if (typeof body === 'object' && body !== null) {\n const {message, code, redirectUrl} = body as {\n message?: unknown\n code?: unknown\n redirectUrl?: unknown\n }\n details.message = typeof message === 'string' ? message : undefined\n details.code = typeof code === 'string' ? code : undefined\n details.redirectUrl = typeof redirectUrl === 'string' ? redirectUrl : undefined\n }\n return details\n}\n\nfunction mapSubmitError(err: unknown): SubmitAccessRequestResult {\n const {statusCode, message, code, redirectUrl} = getErrorResponseDetails(err)\n\n if (statusCode === 403 && code === SAML_ENFORCEMENT_REQUIRED) {\n return {type: 'sso-enforced', redirectUrl, message}\n }\n if (statusCode === 429) {\n return {type: 'over-limit', message}\n }\n if (statusCode === 409) {\n if (message?.includes('email domain')) return {type: 'email-domain-blocked', message}\n if (message?.includes('disabled for organization')) return {type: 'requests-disabled', message}\n return {type: 'denied', message: message?.replace(/^Conflict -\\s*/, '')}\n }\n return {type: 'error', error: err}\n}\n\n/**\n * Submits an access request (`POST /access/{resourceType}/{resourceId}/requests`)\n * and maps the Access API's error contract to a {@link SubmitAccessRequestResult}.\n * Never throws for API rejections; unexpected failures come back as\n * `{type: 'error'}` so callers decide how to surface them.\n *\n * @public\n */\nexport async function submitAccessRequest(options: {\n client: SanityClient\n resourceType: AccessResourceType\n resourceId: string\n note?: string\n requestUrl?: string\n}): Promise<SubmitAccessRequestResult> {\n const {client, resourceType, resourceId, note, requestUrl} = options\n try {\n const request = await withAccessApiVersion(client).request<AccessRequest | null>({\n url: `/access/${resourceType}/${resourceId}/requests`,\n method: 'post',\n tag: 'access-ui.submit-request',\n body: {note, requestUrl, type: 'access'},\n })\n return {type: 'submitted', request}\n } catch (err) {\n return mapSubmitError(err)\n }\n}\n","import {type AccessRequest, type AccessRequestState} from './types'\n\n/**\n * Access requests are considered active for two weeks, matching the Access\n * API's request lifetime.\n */\nconst REQUEST_LIFETIME_MS = 14 * 24 * 60 * 60 * 1000\n\n/**\n * Derives where the caller stands on requesting access to a resource from\n * their existing access requests.\n *\n * A declined request blocks re-requesting for two weeks. A pending request\n * younger than two weeks is in review; older pending requests count as\n * expired, and the caller may request again.\n *\n * @public\n */\nexport function deriveAccessRequestState(\n requests: AccessRequest[] | null | undefined,\n resourceId: string,\n now: number = Date.now(),\n): AccessRequestState {\n if (!requests || requests.length === 0) return 'none'\n\n const isRecent = (request: AccessRequest) =>\n now - new Date(request.createdAt).getTime() < REQUEST_LIFETIME_MS\n\n const forResource = requests.filter((request) => request.resourceId === resourceId)\n\n if (forResource.some((request) => request.status === 'declined' && isRecent(request))) {\n return 'denied'\n }\n if (forResource.some((request) => request.status === 'pending' && isRecent(request))) {\n return 'pending'\n }\n if (forResource.some((request) => request.status === 'pending')) {\n return 'expired'\n }\n return 'none'\n}\n","/**\n * Human-readable title for a login provider id, e.g. `google` → `Google`,\n * `saml-xyz` → `SAML/SSO`.\n *\n * @public\n */\nexport function getProviderTitle(provider?: string): string | undefined {\n if (provider === 'google') return 'Google'\n if (provider === 'github') return 'GitHub'\n if (provider === 'sanity') return 'Sanity'\n if (provider === 'vercel') return 'Vercel'\n if (provider?.startsWith('saml-')) return 'SAML/SSO'\n return undefined\n}\n","import {type ReactNode} from 'react'\n\n/**\n * All user-facing strings in the request-access screen. Every label can be\n * overridden, so hosts with their own i18n stack (studio i18n, react-i18next)\n * inject translated copy while standalone hosts get the English defaults.\n *\n * @public\n */\nexport interface RequestAccessLabels {\n title: ReactNode\n sentTitle: ReactNode\n deniedTitle: ReactNode\n errorTitle: ReactNode\n describeNoAccess: (context: {email?: string}) => ReactNode\n promptProject: ReactNode\n promptOrganization: ReactNode\n notePlaceholder: string\n noteAriaLabel: string\n submit: ReactNode\n sentDescription: ReactNode\n pendingMessage: ReactNode\n deniedMessage: (context: {message?: string}) => ReactNode\n overLimitMessage: (context: {message?: string}) => ReactNode\n expiredMessage: ReactNode\n ssoEnforcedTitle: ReactNode\n ssoEnforcedMessage: (context: {providerTitle?: string; signedInWithSso?: boolean}) => ReactNode\n ssoSignInCta: ReactNode\n resourceNotAvailableTitle: ReactNode\n resourceNotAvailableMessage: ReactNode\n submitFailedMessage: ReactNode\n wrongAccount: ReactNode\n signOut: ReactNode\n}\n\n/** @internal */\nexport const defaultLabels: RequestAccessLabels = {\n title: 'Request access',\n sentTitle: 'Access request sent',\n deniedTitle: 'Access request declined',\n errorTitle: 'Access request couldn’t be sent',\n describeNoAccess: ({email}) =>\n email ? (\n <>\n Your account <strong>({email})</strong> doesn’t have access to this content.\n </>\n ) : (\n <>Your account doesn’t have access to this content.</>\n ),\n promptProject: 'Send a request to the project admin(s).',\n promptOrganization: 'Send a request to the organization admin(s).',\n notePlaceholder: 'Message (optional)',\n noteAriaLabel: 'Message',\n submit: 'Request access',\n sentDescription:\n 'Your request has been sent. You will receive a notification if access is approved.',\n pendingMessage: 'Your request to access this content is pending approval.',\n deniedMessage: ({message}) => message ?? 'Your request to access this content has been declined.',\n overLimitMessage: ({message}) =>\n message ??\n 'You’ve reached the limit for access requests across all projects. Please wait before submitting more requests, or contact an admin.',\n expiredMessage: 'Your previous request has expired. You may request access again below.',\n // Reached both before and after a submit, so it must not claim a send failed.\n ssoEnforcedTitle: 'Organization SSO required',\n ssoEnforcedMessage: () =>\n 'This organization requires you to sign in with its SSO. Sign out, then sign in again with your organization’s SSO. If that still doesn’t work, contact your organization’s administrator.',\n ssoSignInCta: 'Sign in with SSO',\n resourceNotAvailableTitle: 'Access can’t be requested',\n resourceNotAvailableMessage: 'The resource currently being requested is no longer available.',\n submitFailedMessage: 'There was a problem submitting your request. Please try again.',\n wrongAccount: 'Wrong account?',\n signOut: 'Sign out',\n}\n","import {type SanityClient} from '@sanity/client'\nimport {LaunchIcon} from '@sanity/icons/Launch'\nimport {Avatar, Button, Card, Spinner, Text, TextArea} from '@sanity/ui'\nimport {\n type ReactNode,\n type SubmitEvent,\n Suspense,\n use,\n useId,\n useState,\n useTransition,\n} from 'react'\nimport {type ObservablePromise, useObservablePromise} from 'react-rx'\nimport {catchError, combineLatest, defer, of} from 'rxjs'\nimport {Flex, Box, VStack} from 'ui5'\n\nimport {\n fetchAccessRequestStatus,\n listMyAccessRequests,\n MAX_ACCESS_REQUEST_NOTE_LENGTH,\n submitAccessRequest,\n} from './accessRequests'\nimport {deriveAccessRequestState} from './deriveAccessRequestState'\nimport {defaultLabels, type RequestAccessLabels} from './labels'\nimport {getProviderTitle} from './providerTitle'\nimport {\n type AccessRequest,\n type AccessRequestEligibilityState,\n type AccessResourceType,\n type AccessUser,\n type SubmitAccessRequestResult,\n} from './types'\n\n/** @public */\nexport interface RequestAccessFormProps {\n /** Client authenticated as the requesting user. The Access API version is applied internally. */\n client: SanityClient\n resourceType?: AccessResourceType\n /** Project or organization id to request access to. */\n resourceId: string\n /** The signed-in user, rendered in the description and account footer. */\n currentUser?: AccessUser | null\n /**\n * Called when the user chooses \"Sign out\". The account footer's sign-out\n * action is only rendered when provided; hosts own the actual sign-out\n * mechanism (studio: `auth.logout()`, dashboard: logout route navigation).\n */\n onSignOut?: () => void\n /** Called after a request is successfully submitted, e.g. for analytics. */\n onRequestSubmitted?: (details: {note?: string}) => void\n /** Optional slot rendered above the title, e.g. a resource preview. */\n preview?: ReactNode\n /**\n * Renders an optional action area at the bottom of the card's content, e.g.\n * a navigation CTA. Called with the current view so the action can differ\n * per state (or be omitted for some); return null to render nothing.\n */\n renderAction?: (context: {view: RequestAccessView}) => ReactNode\n /** Label overrides for hosts with their own i18n stack. */\n labels?: Partial<RequestAccessLabels>\n}\n\n/**\n * The shared request-access screen: explains that the signed-in account lacks\n * access, lets the user request it with an optional note, and reflects the\n * request lifecycle (pending, denied, expired, over-limit, SSO-enforced).\n *\n * Fetches the caller's existing requests once it is mounted and suspends while\n * loading; an internal `Suspense` boundary renders a spinner, so hosts can\n * mount it directly. The fetch starts when the card commits, not while it\n * renders, so a host whose own `Suspense` boundary retries around it does not\n * refetch, and the result is kept while a hidden `<Activity>` conceals the\n * card. Remount with a `key` when `client` or `resourceId` change.\n *\n * @public\n */\nexport function RequestAccessForm(props: RequestAccessFormProps) {\n const {client, resourceType = 'project', resourceId} = props\n\n // Frozen at first render, so a new client for the same resource neither\n // refetches nor resets the form; hosts remount with `key` to reload. `defer`\n // keeps the requests out of render: react-rx subscribes once this component\n // commits, so a render React discards never fetches, and one subscription is\n // shared across StrictMode's double effects and an `<Activity>` hide/show.\n // Both requests complete, so the hook never resubscribes the source and\n // keeps the settled promise for the life of this instance.\n const [load$] = useState(() =>\n combineLatest({\n accessRequestsHistory: defer(() => listMyAccessRequests(client)).pipe(\n catchError(() => of(null)),\n ),\n accessRequestEligibilityState: defer(() =>\n fetchAccessRequestStatus({client, resourceType, resourceId, origin: getRequestUrl()}),\n ),\n }),\n )\n // Read with `use()` in the child below the boundary, never here: suspending\n // this component would stop the commit that starts the fetch.\n const loadPromise = useObservablePromise(load$)\n\n return (\n <Card border height=\"fill\" overflow=\"hidden\" radius={3} tone=\"default\">\n <Suspense\n fallback={\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\" padding={5}>\n <Spinner muted />\n </Flex>\n }\n >\n <RequestAccessFormContent {...props} loadPromise={loadPromise} />\n </Suspense>\n </Card>\n )\n}\n\ninterface LoadedAccessRequestData {\n accessRequestsHistory: AccessRequest[] | null\n accessRequestEligibilityState: AccessRequestEligibilityState\n}\n\n/**\n * The view the request-access card is currently showing.\n *\n * @public\n */\nexport type RequestAccessView = 'form' | 'sent' | 'pending' | 'blocked' | 'sso-enforced'\n\n/**\n * Everything the card renders, copy included: the same state that picks a view\n * is the only thing that knows which words that view needs. Keying copy off\n * `view` alone cannot work, because `blocked` covers a prior decline, a gone\n * resource and four submit failures, each with its own copy.\n */\ntype ViewState = {title: ReactNode; description: ReactNode | null} & (\n | {view: 'form'; expired: boolean}\n | {view: 'sent'}\n | {view: 'pending'}\n | {view: 'blocked'; message: ReactNode}\n | {view: 'sso-enforced'; message: ReactNode; redirectUrl?: string}\n)\n\n/**\n * The server's verdict. `null` hands the decision back to the caller's own\n * request history, which resolves the states this endpoint does not.\n */\nfunction deriveServerViewState(\n status: AccessRequestEligibilityState,\n labels: RequestAccessLabels,\n providerTitle?: string,\n signedInWithSso?: boolean,\n): ViewState | null {\n switch (status.state) {\n case 'saml-required':\n return ssoEnforcedState({\n labels,\n providerTitle,\n signedInWithSso,\n redirectUrl: status.redirectUrl,\n })\n case 'resource-not-available':\n // Nothing was submitted, so the submit-failure copy would misdescribe it.\n return {\n view: 'blocked',\n title: labels.resourceNotAvailableTitle,\n description: null,\n message: labels.resourceNotAvailableMessage,\n }\n case 'eligible':\n return null\n default:\n return null\n }\n}\n\n// Reached on mount and after a submit 403, so the title claims neither.\nfunction ssoEnforcedState(options: {\n labels: RequestAccessLabels\n providerTitle?: string\n signedInWithSso?: boolean\n redirectUrl?: string\n}): ViewState {\n const {labels, providerTitle, signedInWithSso, redirectUrl} = options\n return {\n view: 'sso-enforced',\n title: labels.ssoEnforcedTitle,\n description: null,\n message: labels.ssoEnforcedMessage({providerTitle, signedInWithSso}),\n redirectUrl,\n }\n}\n\nfunction deriveViewState(options: {\n accessRequestsHistory: AccessRequest[] | null\n accessRequestEligibilityState: AccessRequestEligibilityState\n resourceId: string\n submitAccessRequestResult: SubmitAccessRequestResult | null\n currentUser?: AccessUser | null\n providerTitle?: string\n signedInWithSso?: boolean\n labels: RequestAccessLabels\n}): ViewState {\n const {\n accessRequestsHistory,\n accessRequestEligibilityState,\n resourceId,\n submitAccessRequestResult,\n currentUser,\n providerTitle,\n signedInWithSso,\n labels,\n } = options\n const submitFailure = (message: ReactNode): ViewState => ({\n view: 'blocked',\n title: labels.errorTitle,\n description: null,\n message,\n })\n\n if (submitAccessRequestResult) {\n switch (submitAccessRequestResult.type) {\n case 'submitted':\n return {view: 'sent', title: labels.sentTitle, description: labels.sentDescription}\n case 'sso-enforced':\n return ssoEnforcedState({\n labels,\n providerTitle,\n signedInWithSso,\n redirectUrl: submitAccessRequestResult.redirectUrl,\n })\n case 'denied':\n return submitFailure(labels.deniedMessage({message: submitAccessRequestResult.message}))\n case 'over-limit':\n return submitFailure(labels.overLimitMessage({message: submitAccessRequestResult.message}))\n case 'email-domain-blocked':\n case 'requests-disabled':\n return submitFailure(submitAccessRequestResult.message)\n case 'error':\n // Fall through to the fetched state; the form stays up with an inline error.\n break\n default:\n }\n }\n\n // The server's verdict outranks the request history: a pending request in an\n // enforced org is already dead, so \"pending approval\" would be a false\n // promise. It answers `eligible` when it has nothing to say.\n const serverState = deriveServerViewState(\n accessRequestEligibilityState,\n labels,\n providerTitle,\n signedInWithSso,\n )\n if (serverState) return serverState\n\n // TODO: `pending` and `denied` will be replaced by future content in `accessRequestEligibilityState`\n const state = deriveAccessRequestState(accessRequestsHistory, resourceId)\n if (state === 'pending') {\n return {view: 'pending', title: labels.sentTitle, description: labels.pendingMessage}\n }\n // Derived from prefetch: the user hasn't submitted anything this session,\n // so the title must describe the prior decline, not a failed send.\n if (state === 'denied') {\n return {\n view: 'blocked',\n title: labels.deniedTitle,\n description: null,\n message: labels.deniedMessage({}),\n }\n }\n return {\n view: 'form',\n title: labels.title,\n description: labels.describeNoAccess({email: currentUser?.email}),\n expired: state === 'expired',\n }\n}\n\nfunction RequestAccessFormContent(\n props: RequestAccessFormProps & {loadPromise: ObservablePromise<LoadedAccessRequestData>},\n) {\n const {\n client,\n resourceType = 'project',\n resourceId,\n currentUser,\n onSignOut,\n onRequestSubmitted,\n preview,\n renderAction,\n loadPromise,\n } = props\n const {accessRequestsHistory, accessRequestEligibilityState} = use(loadPromise)\n\n const labels = {...defaultLabels, ...props.labels}\n const titleId = useId()\n\n const [note, setNote] = useState('')\n const [submitAccessRequestResult, setSubmitAccessRequestResult] =\n useState<SubmitAccessRequestResult | null>(null)\n const [isSubmitting, startSubmit] = useTransition()\n\n const providerTitle = getProviderTitle(currentUser?.provider)\n const signedInWithSso = currentUser?.provider?.startsWith('saml-') === true\n const state = deriveViewState({\n accessRequestsHistory,\n accessRequestEligibilityState,\n resourceId,\n submitAccessRequestResult,\n currentUser,\n providerTitle: signedInWithSso ? undefined : providerTitle,\n signedInWithSso,\n labels,\n })\n\n const submitFailed = submitAccessRequestResult?.type === 'error'\n\n const handleSubmit = (event: SubmitEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (isSubmitting) return\n startSubmit(async () => {\n const trimmedNote = note.trim() || undefined\n const result = await submitAccessRequest({\n client,\n resourceType,\n resourceId,\n note: trimmedNote,\n requestUrl: getRequestUrl(),\n })\n setSubmitAccessRequestResult(result)\n if (result.type === 'submitted') onRequestSubmitted?.({note: trimmedNote})\n })\n }\n\n return (\n <Flex flexDirection=\"column\" height=\"100%\">\n <Flex flexDirection=\"column\" flexBasis=\"0%\" flexGrow={1} gap={4} padding={4}>\n {preview ? (\n <Flex justifyContent=\"center\" padding={2}>\n {preview}\n </Flex>\n ) : null}\n\n <Text as=\"h1\" id={titleId} size={2} weight=\"semibold\">\n {state.title}\n </Text>\n\n {state.description !== null ? (\n <Text as=\"p\" muted size={1}>\n {state.description}\n </Text>\n ) : null}\n\n {state.view === 'blocked' || state.view === 'sso-enforced' ? (\n <VStack gap={4}>\n <Card border padding={3} radius={2} role=\"alert\" tone=\"caution\">\n <Text as=\"p\" muted size={1}>\n {state.message}\n </Text>\n </Card>\n {state.view === 'sso-enforced' && state.redirectUrl ? (\n <Button\n as=\"a\"\n href={state.redirectUrl}\n iconRight={LaunchIcon}\n mode=\"ghost\"\n text={labels.ssoSignInCta}\n width=\"fill\"\n />\n ) : null}\n </VStack>\n ) : null}\n\n {state.view === 'form' ? (\n <VStack as=\"form\" aria-labelledby={titleId} onSubmit={handleSubmit} gap={4}>\n <Text as=\"p\" size={1}>\n {state.expired\n ? labels.expiredMessage\n : resourceType === 'organization'\n ? labels.promptOrganization\n : labels.promptProject}\n </Text>\n <VStack gap={2}>\n <TextArea\n aria-label={labels.noteAriaLabel}\n disabled={isSubmitting}\n fontSize={1}\n maxLength={MAX_ACCESS_REQUEST_NOTE_LENGTH}\n onChange={(event) => setNote(event.currentTarget.value)}\n placeholder={labels.notePlaceholder}\n rows={3}\n value={note}\n />\n <Text align=\"right\" muted size={0}>\n {`${note.length}/${MAX_ACCESS_REQUEST_NOTE_LENGTH}`}\n </Text>\n </VStack>\n {submitFailed ? (\n <Card border padding={3} radius={2} role=\"alert\" tone=\"critical\">\n <Text as=\"p\" muted size={1}>\n {labels.submitFailedMessage}\n </Text>\n </Card>\n ) : null}\n <Button\n disabled={isSubmitting}\n loading={isSubmitting}\n text={labels.submit}\n type=\"submit\"\n width=\"fill\"\n />\n </VStack>\n ) : null}\n\n {renderAction?.({view: state.view})}\n </Flex>\n\n {currentUser ? (\n <Card borderTop padding={3}>\n <Flex alignItems=\"center\" flexDirection=\"column\" gap={3}>\n <Flex alignItems=\"center\" gap={2} justifyContent=\"center\">\n <Avatar initials={getInitials(currentUser)} size={0} src={currentUser.profileImage} />\n <Box>\n <Text muted size={1} textOverflow=\"ellipsis\">\n {currentUser.email ?? currentUser.name}\n {providerTitle ? ` · ${providerTitle}` : ''}\n </Text>\n </Box>\n </Flex>\n {onSignOut ? (\n <Button\n fontSize={0}\n mode=\"bleed\"\n onClick={onSignOut}\n padding={2}\n textWeight=\"regular\"\n >\n <Text muted size={1}>\n {labels.wrongAccount} <strong>{labels.signOut}</strong>\n </Text>\n </Button>\n ) : null}\n </Flex>\n </Card>\n ) : null}\n </Flex>\n )\n}\n\n// The URL fragment can carry auth tokens (e.g. the #token= login handoff),\n// so it must never reach the Access API's logs.\nfunction getRequestUrl(): string | undefined {\n if (typeof window === 'undefined') return undefined\n const url = new URL(window.location.href)\n url.hash = ''\n return url.toString()\n}\n\nfunction getInitials(user: AccessUser): string | undefined {\n const source = user.name ?? user.email\n if (!source) return undefined\n const parts = source.trim().split(/\\s+/)\n const initials = parts\n .slice(0, 2)\n .map((part) => part[0])\n .join('')\n return initials ? initials.toUpperCase() : undefined\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,iCAAiC;AAU9C,SAAS,qBAAqB,QAAoC;CAChE,OAAO,OAAO,WAAW,EAAC,YAAY,aAAkB,CAAC;AAC3D;;;;;;;AAQA,eAAsB,qBAAqB,QAAgD;CAKzF,OAAO,MAJgB,qBAAqB,MAAM,CAAC,CAAC,QAAgC;EAClF,KAAK;EACL,KAAK;CACP,CAAC,KACkB,CAAC;AACtB;;;;;;;;;;;;;;AAeA,eAAsB,yBAAyB,SAKJ;CACzC,IAAM,EAAC,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;MAAM,OAAA;MAAM,MAAM;MAAG,cAAa;MAAlC,UAAA,CACG,YAAY,SAAS,YAAY,MACjC,gBAAgB,MAAM,kBAAkB,EACrC;KACH,CAAA,EAAA,CAAA,CACD;IACL,CAAA,GAAA,YACC,oBAAC,QAAD;KACE,UAAU;KACV,MAAK;KACL,SAAS;KACT,SAAS;KACT,YAAW;KAEX,UAAA,qBAAC,MAAD;MAAM,OAAA;MAAM,MAAM;MAAlB,UAAA;OACG,OAAO;OAAa;OAAC,oBAAC,UAAD,EAAA,UAAS,OAAO,QAAgB,CAAA;MAClD;;IACA,CAAA,IACN,IACA;;EACF,CAAA,IACJ,IACA;;AAEV;AAIA,SAAS,gBAAoC;CAC3C,IAAI,OAAO,SAAW,KAAa;CACnC,IAAM,MAAM,IAAI,IAAI,OAAO,SAAS,IAAI;CAExC,OADA,IAAI,OAAO,IACJ,IAAI,SAAS;AACtB;AAEA,SAAS,YAAY,MAAsC;CACzD,IAAM,SAAS,KAAK,QAAQ,KAAK;CACjC,IAAI,CAAC,QAAQ;CAEb,IAAM,WADQ,OAAO,KAAK,CAAC,CAAC,MAAM,KACjB,CAAA,CACd,MAAM,GAAG,CAAC,CAAC,CACX,KAAK,SAAS,KAAK,EAAE,CAAC,CACtB,KAAK,EAAE;CACV,OAAO,WAAW,SAAS,YAAY,IAAI,KAAA;AAC7C"}
1
+ {"version":3,"file":"index.js","names":["_Fragment","resourceType = 'project'","() =>\n combineLatest({\n accessRequestsHistory: defer(() => listMyAccessRequests(client)).pipe(\n catchError(() => of(null)),\n ),\n accessRequestEligibilityState: defer(() =>\n fetchAccessRequestStatus({client, resourceType, resourceId, origin: getRequestUrl()}),\n ),\n })","() => of(null)","<Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\" padding={5}>\n <Spinner muted />\n </Flex>","<Card border height=\"fill\" overflow=\"hidden\" radius={3} tone=\"default\">\n <Suspense\n fallback={\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\" padding={5}>\n <Spinner muted />\n </Flex>\n }\n >\n <RequestAccessFormContent {...props} loadPromise={loadPromise} />\n </Suspense>\n </Card>","currentUser?.provider?.startsWith('saml-')","provider","(event: SubmitEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (isSubmitting) return\n startSubmit(async () => {\n const trimmedNote = note.trim() || undefined\n const result = await submitAccessRequest({\n client,\n resourceType,\n resourceId,\n note: trimmedNote,\n requestUrl: getRequestUrl(),\n })\n setSubmitAccessRequestResult(result)\n if (result.type === 'submitted') onRequestSubmitted?.({note: trimmedNote})\n })\n }","preview ? (\n <Flex justifyContent=\"center\" padding={2}>\n {preview}\n </Flex>\n ) : null","event","_c"],"sources":["../src/accessRequests.ts","../src/deriveAccessRequestState.ts","../src/providerTitle.ts","../src/labels.tsx","../src/RequestAccessForm.tsx"],"sourcesContent":["import {type SanityClient} from '@sanity/client'\n\nimport {\n type AccessRequest,\n type AccessRequestEligibilityState,\n type AccessResourceType,\n type SubmitAccessRequestResult,\n} from './types'\n\n/**\n * The Access API only accepts notes up to this length.\n *\n * @public\n */\nexport const MAX_ACCESS_REQUEST_NOTE_LENGTH = 150\n\nconst ACCESS_API_VERSION = '2024-07-01'\n\n/**\n * Structured 403 code thrown by the Access API when the target organization\n * only admits members through its SSO login flow.\n */\nconst SAML_ENFORCEMENT_REQUIRED = 'saml_enforcement_required'\n\nfunction withAccessApiVersion(client: SanityClient): SanityClient {\n return client.withConfig({apiVersion: ACCESS_API_VERSION})\n}\n\n/**\n * Fetches the caller's own access requests across all resources\n * (`GET /access/requests/me`).\n *\n * @public\n */\nexport async function listMyAccessRequests(client: SanityClient): Promise<AccessRequest[]> {\n const requests = await withAccessApiVersion(client).request<AccessRequest[] | null>({\n url: '/access/requests/me',\n tag: 'access-ui.list-requests',\n })\n return requests ?? []\n}\n\n/**\n * Asks what the request-access screen should show\n * (`GET /access/{resourceType}/{resourceId}/requests/state`).\n *\n * Runs before the form is offered, so a user in a SAML-enforced organization is\n * pointed at SSO instead of writing a note no administrator can action.\n *\n * `origin` is carried opaquely to the login page so the user returns where they\n * started. Never throws: an unreachable or older API answers `eligible`,\n * leaving the form in place and the submit-time 403 as the backstop.\n *\n * @public\n */\nexport async function fetchAccessRequestStatus(options: {\n client: SanityClient\n resourceType: AccessResourceType\n resourceId: string\n origin?: string\n}): Promise<AccessRequestEligibilityState> {\n const {client, resourceType, resourceId, origin} = options\n try {\n const status = await withAccessApiVersion(client).request<AccessRequestEligibilityState | null>(\n {\n url: `/access/${resourceType}/${resourceId}/requests/state`,\n tag: 'access-ui.request-state',\n query: origin ? {returnQuery: new URLSearchParams({origin}).toString()} : undefined,\n },\n )\n return status ?? {state: 'eligible'}\n } catch {\n return {state: 'eligible'}\n }\n}\n\ninterface ErrorResponseDetails {\n statusCode?: number\n message?: string\n code?: string\n redirectUrl?: string\n}\n\nfunction getErrorResponseDetails(err: unknown): ErrorResponseDetails {\n if (typeof err !== 'object' || err === null) return {}\n const response = (err as {response?: unknown}).response\n if (typeof response !== 'object' || response === null) return {}\n const {statusCode} = response as {statusCode?: unknown}\n const body = (response as {body?: unknown}).body\n const details: ErrorResponseDetails = {\n statusCode: typeof statusCode === 'number' ? statusCode : undefined,\n }\n if (typeof body === 'object' && body !== null) {\n const {message, code, redirectUrl} = body as {\n message?: unknown\n code?: unknown\n redirectUrl?: unknown\n }\n details.message = typeof message === 'string' ? message : undefined\n details.code = typeof code === 'string' ? code : undefined\n details.redirectUrl = typeof redirectUrl === 'string' ? redirectUrl : undefined\n }\n return details\n}\n\nfunction mapSubmitError(err: unknown): SubmitAccessRequestResult {\n const {statusCode, message, code, redirectUrl} = getErrorResponseDetails(err)\n\n if (statusCode === 403 && code === SAML_ENFORCEMENT_REQUIRED) {\n return {type: 'sso-enforced', redirectUrl, message}\n }\n if (statusCode === 429) {\n return {type: 'over-limit', message}\n }\n if (statusCode === 409) {\n if (message?.includes('email domain')) return {type: 'email-domain-blocked', message}\n if (message?.includes('disabled for organization')) return {type: 'requests-disabled', message}\n return {type: 'denied', message: message?.replace(/^Conflict -\\s*/, '')}\n }\n return {type: 'error', error: err}\n}\n\n/**\n * Submits an access request (`POST /access/{resourceType}/{resourceId}/requests`)\n * and maps the Access API's error contract to a {@link SubmitAccessRequestResult}.\n * Never throws for API rejections; unexpected failures come back as\n * `{type: 'error'}` so callers decide how to surface them.\n *\n * @public\n */\nexport async function submitAccessRequest(options: {\n client: SanityClient\n resourceType: AccessResourceType\n resourceId: string\n note?: string\n requestUrl?: string\n}): Promise<SubmitAccessRequestResult> {\n const {client, resourceType, resourceId, note, requestUrl} = options\n try {\n const request = await withAccessApiVersion(client).request<AccessRequest | null>({\n url: `/access/${resourceType}/${resourceId}/requests`,\n method: 'post',\n tag: 'access-ui.submit-request',\n body: {note, requestUrl, type: 'access'},\n })\n return {type: 'submitted', request}\n } catch (err) {\n return mapSubmitError(err)\n }\n}\n","import {type AccessRequest, type AccessRequestState} from './types'\n\n/**\n * Access requests are considered active for two weeks, matching the Access\n * API's request lifetime.\n */\nconst REQUEST_LIFETIME_MS = 14 * 24 * 60 * 60 * 1000\n\n/**\n * Derives where the caller stands on requesting access to a resource from\n * their existing access requests.\n *\n * A declined request blocks re-requesting for two weeks. A pending request\n * younger than two weeks is in review; older pending requests count as\n * expired, and the caller may request again.\n *\n * @public\n */\nexport function deriveAccessRequestState(\n requests: AccessRequest[] | null | undefined,\n resourceId: string,\n now: number = Date.now(),\n): AccessRequestState {\n if (!requests || requests.length === 0) return 'none'\n\n const isRecent = (request: AccessRequest) =>\n now - new Date(request.createdAt).getTime() < REQUEST_LIFETIME_MS\n\n const forResource = requests.filter((request) => request.resourceId === resourceId)\n\n if (forResource.some((request) => request.status === 'declined' && isRecent(request))) {\n return 'denied'\n }\n if (forResource.some((request) => request.status === 'pending' && isRecent(request))) {\n return 'pending'\n }\n if (forResource.some((request) => request.status === 'pending')) {\n return 'expired'\n }\n return 'none'\n}\n","/**\n * Human-readable title for a login provider id, e.g. `google` → `Google`,\n * `saml-xyz` → `SAML/SSO`.\n *\n * @public\n */\nexport function getProviderTitle(provider?: string): string | undefined {\n if (provider === 'google') return 'Google'\n if (provider === 'github') return 'GitHub'\n if (provider === 'sanity') return 'Sanity'\n if (provider === 'vercel') return 'Vercel'\n if (provider?.startsWith('saml-')) return 'SAML/SSO'\n return undefined\n}\n","import {type ReactNode} from 'react'\n\n/**\n * All user-facing strings in the request-access screen. Every label can be\n * overridden, so hosts with their own i18n stack (studio i18n, react-i18next)\n * inject translated copy while standalone hosts get the English defaults.\n *\n * @public\n */\nexport interface RequestAccessLabels {\n title: ReactNode\n sentTitle: ReactNode\n deniedTitle: ReactNode\n errorTitle: ReactNode\n describeNoAccess: (context: {email?: string}) => ReactNode\n promptProject: ReactNode\n promptOrganization: ReactNode\n notePlaceholder: string\n noteAriaLabel: string\n submit: ReactNode\n sentDescription: ReactNode\n pendingMessage: ReactNode\n deniedMessage: (context: {message?: string}) => ReactNode\n overLimitMessage: (context: {message?: string}) => ReactNode\n expiredMessage: ReactNode\n ssoEnforcedTitle: ReactNode\n ssoEnforcedMessage: (context: {providerTitle?: string; signedInWithSso?: boolean}) => ReactNode\n ssoSignInCta: ReactNode\n resourceNotAvailableTitle: ReactNode\n resourceNotAvailableMessage: ReactNode\n submitFailedMessage: ReactNode\n wrongAccount: ReactNode\n signOut: ReactNode\n}\n\n/** @internal */\nexport const defaultLabels: RequestAccessLabels = {\n title: 'Request access',\n sentTitle: 'Access request sent',\n deniedTitle: 'Access request declined',\n errorTitle: 'Access request couldn’t be sent',\n describeNoAccess: ({email}) =>\n email ? (\n <>\n Your account <strong>({email})</strong> doesn’t have access to this content.\n </>\n ) : (\n <>Your account doesn’t have access to this content.</>\n ),\n promptProject: 'Send a request to the project admin(s).',\n promptOrganization: 'Send a request to the organization admin(s).',\n notePlaceholder: 'Message (optional)',\n noteAriaLabel: 'Message',\n submit: 'Request access',\n sentDescription:\n 'Your request has been sent. You will receive a notification if access is approved.',\n pendingMessage: 'Your request to access this content is pending approval.',\n deniedMessage: ({message}) => message ?? 'Your request to access this content has been declined.',\n overLimitMessage: ({message}) =>\n message ??\n 'You’ve reached the limit for access requests across all projects. Please wait before submitting more requests, or contact an admin.',\n expiredMessage: 'Your previous request has expired. You may request access again below.',\n // Reached both before and after a submit, so it must not claim a send failed.\n ssoEnforcedTitle: 'Organization SSO required',\n ssoEnforcedMessage: () =>\n 'This organization requires you to sign in with its SSO. Sign out, then sign in again with your organization’s SSO. If that still doesn’t work, contact your organization’s administrator.',\n ssoSignInCta: 'Sign in with SSO',\n resourceNotAvailableTitle: 'Access can’t be requested',\n resourceNotAvailableMessage: 'The resource currently being requested is no longer available.',\n submitFailedMessage: 'There was a problem submitting your request. Please try again.',\n wrongAccount: 'Wrong account?',\n signOut: 'Sign out',\n}\n","import {type SanityClient} from '@sanity/client'\nimport {LaunchIcon} from '@sanity/icons/Launch'\nimport {Avatar, Button, Card, Spinner, TextArea} from '@sanity/ui'\nimport {\n type ReactNode,\n type SubmitEvent,\n Suspense,\n use,\n useId,\n useState,\n useTransition,\n} from 'react'\nimport {type ObservablePromise, useObservablePromise} from 'react-rx'\nimport {catchError, combineLatest, defer, of} from 'rxjs'\nimport {Text, Flex, Box, VStack} from 'ui5'\n\nimport {\n fetchAccessRequestStatus,\n listMyAccessRequests,\n MAX_ACCESS_REQUEST_NOTE_LENGTH,\n submitAccessRequest,\n} from './accessRequests'\nimport {deriveAccessRequestState} from './deriveAccessRequestState'\nimport {defaultLabels, type RequestAccessLabels} from './labels'\nimport {getProviderTitle} from './providerTitle'\nimport {\n type AccessRequest,\n type AccessRequestEligibilityState,\n type AccessResourceType,\n type AccessUser,\n type SubmitAccessRequestResult,\n} from './types'\n\n/** @public */\nexport interface RequestAccessFormProps {\n /** Client authenticated as the requesting user. The Access API version is applied internally. */\n client: SanityClient\n resourceType?: AccessResourceType\n /** Project or organization id to request access to. */\n resourceId: string\n /** The signed-in user, rendered in the description and account footer. */\n currentUser?: AccessUser | null\n /**\n * Called when the user chooses \"Sign out\". The account footer's sign-out\n * action is only rendered when provided; hosts own the actual sign-out\n * mechanism (studio: `auth.logout()`, dashboard: logout route navigation).\n */\n onSignOut?: () => void\n /** Called after a request is successfully submitted, e.g. for analytics. */\n onRequestSubmitted?: (details: {note?: string}) => void\n /** Optional slot rendered above the title, e.g. a resource preview. */\n preview?: ReactNode\n /**\n * Renders an optional action area at the bottom of the card's content, e.g.\n * a navigation CTA. Called with the current view so the action can differ\n * per state (or be omitted for some); return null to render nothing.\n */\n renderAction?: (context: {view: RequestAccessView}) => ReactNode\n /** Label overrides for hosts with their own i18n stack. */\n labels?: Partial<RequestAccessLabels>\n}\n\n/**\n * The shared request-access screen: explains that the signed-in account lacks\n * access, lets the user request it with an optional note, and reflects the\n * request lifecycle (pending, denied, expired, over-limit, SSO-enforced).\n *\n * Fetches the caller's existing requests once it is mounted and suspends while\n * loading; an internal `Suspense` boundary renders a spinner, so hosts can\n * mount it directly. The fetch starts when the card commits, not while it\n * renders, so a host whose own `Suspense` boundary retries around it does not\n * refetch, and the result is kept while a hidden `<Activity>` conceals the\n * card. Remount with a `key` when `client` or `resourceId` change.\n *\n * @public\n */\nexport function RequestAccessForm(props: RequestAccessFormProps) {\n const {client, resourceType = 'project', resourceId} = props\n\n // Frozen at first render, so a new client for the same resource neither\n // refetches nor resets the form; hosts remount with `key` to reload. `defer`\n // keeps the requests out of render: react-rx subscribes once this component\n // commits, so a render React discards never fetches, and one subscription is\n // shared across StrictMode's double effects and an `<Activity>` hide/show.\n // Both requests complete, so the hook never resubscribes the source and\n // keeps the settled promise for the life of this instance.\n const [load$] = useState(() =>\n combineLatest({\n accessRequestsHistory: defer(() => listMyAccessRequests(client)).pipe(\n catchError(() => of(null)),\n ),\n accessRequestEligibilityState: defer(() =>\n fetchAccessRequestStatus({client, resourceType, resourceId, origin: getRequestUrl()}),\n ),\n }),\n )\n // Read with `use()` in the child below the boundary, never here: suspending\n // this component would stop the commit that starts the fetch.\n const loadPromise = useObservablePromise(load$)\n\n return (\n <Card border height=\"fill\" overflow=\"hidden\" radius={3} tone=\"default\">\n <Suspense\n fallback={\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\" padding={5}>\n <Spinner muted />\n </Flex>\n }\n >\n <RequestAccessFormContent {...props} loadPromise={loadPromise} />\n </Suspense>\n </Card>\n )\n}\n\ninterface LoadedAccessRequestData {\n accessRequestsHistory: AccessRequest[] | null\n accessRequestEligibilityState: AccessRequestEligibilityState\n}\n\n/**\n * The view the request-access card is currently showing.\n *\n * @public\n */\nexport type RequestAccessView = 'form' | 'sent' | 'pending' | 'blocked' | 'sso-enforced'\n\n/**\n * Everything the card renders, copy included: the same state that picks a view\n * is the only thing that knows which words that view needs. Keying copy off\n * `view` alone cannot work, because `blocked` covers a prior decline, a gone\n * resource and four submit failures, each with its own copy.\n */\ntype ViewState = {title: ReactNode; description: ReactNode | null} & (\n | {view: 'form'; expired: boolean}\n | {view: 'sent'}\n | {view: 'pending'}\n | {view: 'blocked'; message: ReactNode}\n | {view: 'sso-enforced'; message: ReactNode; redirectUrl?: string}\n)\n\n/**\n * The server's verdict. `null` hands the decision back to the caller's own\n * request history, which resolves the states this endpoint does not.\n */\nfunction deriveServerViewState(\n status: AccessRequestEligibilityState,\n labels: RequestAccessLabels,\n providerTitle?: string,\n signedInWithSso?: boolean,\n): ViewState | null {\n switch (status.state) {\n case 'saml-required':\n return ssoEnforcedState({\n labels,\n providerTitle,\n signedInWithSso,\n redirectUrl: status.redirectUrl,\n })\n case 'resource-not-available':\n // Nothing was submitted, so the submit-failure copy would misdescribe it.\n return {\n view: 'blocked',\n title: labels.resourceNotAvailableTitle,\n description: null,\n message: labels.resourceNotAvailableMessage,\n }\n case 'eligible':\n return null\n default:\n return null\n }\n}\n\n// Reached on mount and after a submit 403, so the title claims neither.\nfunction ssoEnforcedState(options: {\n labels: RequestAccessLabels\n providerTitle?: string\n signedInWithSso?: boolean\n redirectUrl?: string\n}): ViewState {\n const {labels, providerTitle, signedInWithSso, redirectUrl} = options\n return {\n view: 'sso-enforced',\n title: labels.ssoEnforcedTitle,\n description: null,\n message: labels.ssoEnforcedMessage({providerTitle, signedInWithSso}),\n redirectUrl,\n }\n}\n\nfunction deriveViewState(options: {\n accessRequestsHistory: AccessRequest[] | null\n accessRequestEligibilityState: AccessRequestEligibilityState\n resourceId: string\n submitAccessRequestResult: SubmitAccessRequestResult | null\n currentUser?: AccessUser | null\n providerTitle?: string\n signedInWithSso?: boolean\n labels: RequestAccessLabels\n}): ViewState {\n const {\n accessRequestsHistory,\n accessRequestEligibilityState,\n resourceId,\n submitAccessRequestResult,\n currentUser,\n providerTitle,\n signedInWithSso,\n labels,\n } = options\n const submitFailure = (message: ReactNode): ViewState => ({\n view: 'blocked',\n title: labels.errorTitle,\n description: null,\n message,\n })\n\n if (submitAccessRequestResult) {\n switch (submitAccessRequestResult.type) {\n case 'submitted':\n return {view: 'sent', title: labels.sentTitle, description: labels.sentDescription}\n case 'sso-enforced':\n return ssoEnforcedState({\n labels,\n providerTitle,\n signedInWithSso,\n redirectUrl: submitAccessRequestResult.redirectUrl,\n })\n case 'denied':\n return submitFailure(labels.deniedMessage({message: submitAccessRequestResult.message}))\n case 'over-limit':\n return submitFailure(labels.overLimitMessage({message: submitAccessRequestResult.message}))\n case 'email-domain-blocked':\n case 'requests-disabled':\n return submitFailure(submitAccessRequestResult.message)\n case 'error':\n // Fall through to the fetched state; the form stays up with an inline error.\n break\n default:\n }\n }\n\n // The server's verdict outranks the request history: a pending request in an\n // enforced org is already dead, so \"pending approval\" would be a false\n // promise. It answers `eligible` when it has nothing to say.\n const serverState = deriveServerViewState(\n accessRequestEligibilityState,\n labels,\n providerTitle,\n signedInWithSso,\n )\n if (serverState) return serverState\n\n // TODO: `pending` and `denied` will be replaced by future content in `accessRequestEligibilityState`\n const state = deriveAccessRequestState(accessRequestsHistory, resourceId)\n if (state === 'pending') {\n return {view: 'pending', title: labels.sentTitle, description: labels.pendingMessage}\n }\n // Derived from prefetch: the user hasn't submitted anything this session,\n // so the title must describe the prior decline, not a failed send.\n if (state === 'denied') {\n return {\n view: 'blocked',\n title: labels.deniedTitle,\n description: null,\n message: labels.deniedMessage({}),\n }\n }\n return {\n view: 'form',\n title: labels.title,\n description: labels.describeNoAccess({email: currentUser?.email}),\n expired: state === 'expired',\n }\n}\n\nfunction RequestAccessFormContent(\n props: RequestAccessFormProps & {loadPromise: ObservablePromise<LoadedAccessRequestData>},\n) {\n const {\n client,\n resourceType = 'project',\n resourceId,\n currentUser,\n onSignOut,\n onRequestSubmitted,\n preview,\n renderAction,\n loadPromise,\n } = props\n const {accessRequestsHistory, accessRequestEligibilityState} = use(loadPromise)\n\n const labels = {...defaultLabels, ...props.labels}\n const titleId = useId()\n\n const [note, setNote] = useState('')\n const [submitAccessRequestResult, setSubmitAccessRequestResult] =\n useState<SubmitAccessRequestResult | null>(null)\n const [isSubmitting, startSubmit] = useTransition()\n\n const providerTitle = getProviderTitle(currentUser?.provider)\n const signedInWithSso = currentUser?.provider?.startsWith('saml-') === true\n const state = deriveViewState({\n accessRequestsHistory,\n accessRequestEligibilityState,\n resourceId,\n submitAccessRequestResult,\n currentUser,\n providerTitle: signedInWithSso ? undefined : providerTitle,\n signedInWithSso,\n labels,\n })\n\n const submitFailed = submitAccessRequestResult?.type === 'error'\n\n const handleSubmit = (event: SubmitEvent<HTMLFormElement>) => {\n event.preventDefault()\n if (isSubmitting) return\n startSubmit(async () => {\n const trimmedNote = note.trim() || undefined\n const result = await submitAccessRequest({\n client,\n resourceType,\n resourceId,\n note: trimmedNote,\n requestUrl: getRequestUrl(),\n })\n setSubmitAccessRequestResult(result)\n if (result.type === 'submitted') onRequestSubmitted?.({note: trimmedNote})\n })\n }\n\n return (\n <Flex flexDirection=\"column\" height=\"100%\">\n <Flex flexDirection=\"column\" flexBasis=\"0%\" flexGrow={1} gap={4} padding={4}>\n {preview ? (\n <Flex justifyContent=\"center\" padding={2}>\n {preview}\n </Flex>\n ) : null}\n\n <Text as=\"h1\" id={titleId} size={2} weight=\"semibold\" trim={true}>\n {state.title}\n </Text>\n\n {state.description !== null ? (\n <Text as=\"p\" muted size={1} trim={true}>\n {state.description}\n </Text>\n ) : null}\n\n {state.view === 'blocked' || state.view === 'sso-enforced' ? (\n <VStack gap={4}>\n <Card border padding={3} radius={2} role=\"alert\" tone=\"caution\">\n <Text as=\"p\" muted size={1} trim={true} tone=\"caution\">\n {state.message}\n </Text>\n </Card>\n {state.view === 'sso-enforced' && state.redirectUrl ? (\n <Button\n as=\"a\"\n href={state.redirectUrl}\n iconRight={LaunchIcon}\n mode=\"ghost\"\n text={labels.ssoSignInCta}\n width=\"fill\"\n />\n ) : null}\n </VStack>\n ) : null}\n\n {state.view === 'form' ? (\n <VStack as=\"form\" aria-labelledby={titleId} onSubmit={handleSubmit} gap={4}>\n <Text as=\"p\" size={1} trim={true}>\n {state.expired\n ? labels.expiredMessage\n : resourceType === 'organization'\n ? labels.promptOrganization\n : labels.promptProject}\n </Text>\n <VStack gap={2}>\n <TextArea\n aria-label={labels.noteAriaLabel}\n disabled={isSubmitting}\n fontSize={1}\n maxLength={MAX_ACCESS_REQUEST_NOTE_LENGTH}\n onChange={(event) => setNote(event.currentTarget.value)}\n placeholder={labels.notePlaceholder}\n rows={3}\n value={note}\n />\n <Text align=\"right\" muted size={0} as=\"div\" trim={true}>\n {`${note.length}/${MAX_ACCESS_REQUEST_NOTE_LENGTH}`}\n </Text>\n </VStack>\n {submitFailed ? (\n <Card border padding={3} radius={2} role=\"alert\" tone=\"critical\">\n <Text as=\"p\" muted size={1} trim={true} tone=\"critical\">\n {labels.submitFailedMessage}\n </Text>\n </Card>\n ) : null}\n <Button\n disabled={isSubmitting}\n loading={isSubmitting}\n text={labels.submit}\n type=\"submit\"\n width=\"fill\"\n />\n </VStack>\n ) : null}\n\n {renderAction?.({view: state.view})}\n </Flex>\n\n {currentUser ? (\n <Card borderTop padding={3}>\n <Flex alignItems=\"center\" flexDirection=\"column\" gap={3}>\n <Flex alignItems=\"center\" gap={2} justifyContent=\"center\">\n <Avatar initials={getInitials(currentUser)} size={0} src={currentUser.profileImage} />\n <Box>\n <Text muted size={1} truncate={1} as=\"div\" trim={true}>\n {currentUser.email ?? currentUser.name}\n {providerTitle ? ` · ${providerTitle}` : ''}\n </Text>\n </Box>\n </Flex>\n {onSignOut ? (\n <Button\n fontSize={0}\n mode=\"bleed\"\n onClick={onSignOut}\n padding={2}\n textWeight=\"regular\"\n >\n <Text muted size={1} as=\"div\" trim={true}>\n {labels.wrongAccount} <strong>{labels.signOut}</strong>\n </Text>\n </Button>\n ) : null}\n </Flex>\n </Card>\n ) : null}\n </Flex>\n )\n}\n\n// The URL fragment can carry auth tokens (e.g. the #token= login handoff),\n// so it must never reach the Access API's logs.\nfunction getRequestUrl(): string | undefined {\n if (typeof window === 'undefined') return undefined\n const url = new URL(window.location.href)\n url.hash = ''\n return url.toString()\n}\n\nfunction getInitials(user: AccessUser): string | undefined {\n const source = user.name ?? user.email\n if (!source) return undefined\n const parts = source.trim().split(/\\s+/)\n const initials = parts\n .slice(0, 2)\n .map((part) => part[0])\n .join('')\n return initials ? initials.toUpperCase() : undefined\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,iCAAiC;AAU9C,SAAS,qBAAqB,QAAoC;CAChE,OAAO,OAAO,WAAW,EAAC,YAAY,aAAkB,CAAC;AAC3D;;;;;;;AAQA,eAAsB,qBAAqB,QAAgD;CAKzF,OAAO,MAJgB,qBAAqB,MAAM,CAAC,CAAC,QAAgC;EAClF,KAAK;EACL,KAAK;CACP,CAAC,KACkB,CAAC;AACtB;;;;;;;;;;;;;;AAeA,eAAsB,yBAAyB,SAKJ;CACzC,IAAM,EAAC,QAAQ,cAAc,YAAY,WAAU;CACnD,IAAI;EAQF,OAAO,MAPc,qBAAqB,MAAM,CAAC,CAAC,QAChD;GACE,KAAK,WAAW,aAAa,GAAG,WAAW;GAC3C,KAAK;GACL,OAAO,SAAS,EAAC,aAAa,IAAI,gBAAgB,EAAC,OAAM,CAAC,CAAC,CAAC,SAAS,E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BAAgB,MAAM,kBAAkB,EACrC;KACH,CAAA,EAAA,CAAA,CACD;IACL,CAAA,GAAA,YACC,oBAAC,QAAD;KACE,UAAU;KACV,MAAK;KACL,SAAS;KACT,SAAS;KACT,YAAW;KAEX,UAAA,qBAAC,MAAD;MAAM,OAAA;MAAM,MAAM;MAAG,IAAG;MAAM,MAAM;MAApC,UAAA;OACG,OAAO;OAAa;OAAC,oBAAC,UAAD,EAAA,UAAS,OAAO,QAAgB,CAAA;MAClD;;IACA,CAAA,IACN,IACA;;EACF,CAAA,IACJ,IACA;;AAEV;AAIA,SAAS,gBAAoC;CAC3C,IAAI,OAAO,SAAW,KAAa;CACnC,IAAM,MAAM,IAAI,IAAI,OAAO,SAAS,IAAI;CAExC,OADA,IAAI,OAAO,IACJ,IAAI,SAAS;AACtB;AAEA,SAAS,YAAY,MAAsC;CACzD,IAAM,SAAS,KAAK,QAAQ,KAAK;CACjC,IAAI,CAAC,QAAQ;CAEb,IAAM,WADQ,OAAO,KAAK,CAAC,CAAC,MAAM,KACjB,CAAA,CACd,MAAM,GAAG,CAAC,CAAC,CACX,KAAK,SAAS,KAAK,EAAE,CAAC,CACtB,KAAK,EAAE;CACV,OAAO,WAAW,SAAS,YAAY,IAAI,KAAA;AAC7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/access-ui",
3
- "version": "6.23.0-next.26",
3
+ "version": "6.23.0-next.38",
4
4
  "description": "Shared request-access screen and access-request logic for Sanity applications",
5
5
  "keywords": [
6
6
  "access",