@vectoriox/iox-ui 5.98.0 → 5.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/vectoriox-iox-ui-identity-core.mjs +535 -0
- package/fesm2022/vectoriox-iox-ui-identity-core.mjs.map +1 -0
- package/identity-core/index.d.ts +364 -0
- package/identity-core/package.json +3 -0
- package/package.json +5 -1
- package/src/identity-core/guards.ts +87 -0
- package/src/identity-core/public-api.ts +13 -0
- package/src/identity-core/sign-in.ts +223 -0
- package/src/identity-core/site-auth.ts +172 -0
- package/src/identity-core/words.ts +194 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectoriox-iox-ui-identity-core.mjs","sources":["../../../projects/iox-ui/src/identity-core/sign-in.ts","../../../projects/iox-ui/src/identity-core/guards.ts","../../../projects/iox-ui/src/identity-core/site-auth.ts","../../../projects/iox-ui/src/identity-core/words.ts","../../../projects/iox-ui/src/identity-core/public-api.ts","../../../projects/iox-ui/src/identity-core/vectoriox-iox-ui-identity-core.ts"],"sourcesContent":["/**\n * Who signs in, with what, and the broker's two faces (commerce plan §3c \"The broker, step by step\", C-D6, C-D22).\n * The broker (iox-control-plane, `auth.iox.studio`) and the studios (iox-cms) speak THESE shapes; a provider is one\n * adapter on the broker and one `customerIdentities.provider` value in a studio. Email codes never touch the broker.\n */\n\n/** Who the sign-in is for. */\nexport enum SignInPurpose {\n /** A buyer on a studio's site. */\n Site = 'site',\n /** A studio's team member — existing users only (wave 2). */\n Admin = 'admin',\n /** portal.iox.studio. */\n Portal = 'portal',\n}\n\n/** A provider the broker runs. Google is live; the rest join one adapter at a time (board 18). */\nexport enum SignInProvider {\n Google = 'google',\n Meta = 'meta',\n GitHub = 'github',\n LinkedIn = 'linkedin',\n}\n\n/** How a provider answers (board 18): OpenID Connect gives a SIGNED ID token; OAuth 2 needs a profile call. */\nexport enum SignInProtocol {\n Oidc = 'oidc',\n OAuth2 = 'oauth2',\n}\n\nexport interface SignInProviderSpec {\n readonly protocol: SignInProtocol;\n /** The answer is signed, so a studio can check it itself — the only kind an admin may sign in with (C-D6). */\n readonly signedAnswer: boolean;\n /** Running on the broker today. */\n readonly live: boolean;\n}\n\nexport const SIGN_IN_PROVIDER_SPECS: Readonly<Record<SignInProvider, SignInProviderSpec>> = Object.freeze({\n [SignInProvider.Google]: { protocol: SignInProtocol.Oidc, signedAnswer: true, live: true },\n [SignInProvider.LinkedIn]: { protocol: SignInProtocol.Oidc, signedAnswer: true, live: false },\n [SignInProvider.Meta]: { protocol: SignInProtocol.OAuth2, signedAnswer: false, live: false },\n [SignInProvider.GitHub]: { protocol: SignInProtocol.OAuth2, signedAnswer: false, live: false },\n});\n\nexport function isSignInProvider(value: unknown): value is SignInProvider {\n return typeof value === 'string' && (Object.values(SignInProvider) as string[]).includes(value);\n}\n\nexport function isSignInPurpose(value: unknown): value is SignInPurpose {\n return typeof value === 'string' && (Object.values(SignInPurpose) as string[]).includes(value);\n}\n\n/** May `provider` serve `purpose`? Buyers and the portal take any provider; a team member only a signed answer (C-D6). */\nexport function providerServes(provider: SignInProvider, purpose: SignInPurpose): boolean {\n const spec = SIGN_IN_PROVIDER_SPECS[provider];\n if (!spec) return false;\n return purpose === SignInPurpose.Admin ? spec.signedAnswer : true;\n}\n\n// ── the broker ──────────────────────────────────────────────────────────────────────────────────\n\n/** The broker's public host (its own ingress; ops.iox.studio is unchanged). */\nexport const BROKER_HOST = 'auth.iox.studio';\nexport const BROKER_ORIGIN = `https://${BROKER_HOST}`;\n\n/** A ticket lives 60 s and is used once; so does a hand-off code. */\nexport const SIGN_IN_TICKET_TTL_SECONDS = 60;\nexport const SIGN_IN_HANDOFF_TTL_SECONDS = 60;\n\n/** The server-to-server routes on the control plane's API host (bearer: the studio's INSTANCE_TOKEN). */\nexport enum BrokerApiRoute {\n Tickets = 'instances/me/sign-in/tickets',\n Redeem = 'instances/me/sign-in/redeem',\n}\n\n/** The browser's routes on `auth.iox.studio`, one pair per provider. */\nexport enum BrokerBrowserRoute {\n Start = 'start',\n Callback = 'callback',\n}\n\n/** `/<route>` on the control plane's API host, root-relative. */\nexport function brokerApiPath(route: BrokerApiRoute): string {\n return `/${route}`;\n}\n\n/** `https://auth.iox.studio/<provider>/<route>`. */\nexport function brokerBrowserUrl(provider: SignInProvider, route: BrokerBrowserRoute, origin: string = BROKER_ORIGIN): string {\n return `${origin.replace(/\\/+$/, '')}/${encodeURIComponent(provider)}/${route}`;\n}\n\n/** Where the browser goes to begin: `https://auth.iox.studio/<provider>/start?ticket=<ticket>`. */\nexport function brokerStartUrl(provider: SignInProvider, ticket: string, origin: string = BROKER_ORIGIN): string {\n return `${brokerBrowserUrl(provider, BrokerBrowserRoute.Start, origin)}?${BROKER_TICKET_PARAM}=${encodeURIComponent(ticket)}`;\n}\n\n/** The ONE address registered with each provider: `https://auth.iox.studio/<provider>/callback`. */\nexport function brokerCallbackUrl(provider: SignInProvider, origin: string = BROKER_ORIGIN): string {\n return brokerBrowserUrl(provider, BrokerBrowserRoute.Callback, origin);\n}\n\nexport const BROKER_TICKET_PARAM = 'ticket';\n\n/** `POST instances/me/sign-in/tickets` — body. */\nexport interface SignInTicketRequest {\n provider: SignInProvider;\n purpose: SignInPurpose;\n /** Where the broker sends the browser back; its host must be one of the asking tenant's. */\n returnUrl: string;\n}\n\n/** 201 — `expiresAt` is an ISO date. */\nexport interface SignInTicketAnswer {\n ticket: string;\n startUrl: string;\n expiresAt: string;\n}\n\n/** `POST instances/me/sign-in/redeem` — body: the hand-off code the browser brought back. */\nexport interface SignInRedeemRequest {\n code: string;\n}\n\n/** 200 — the person the provider vouched for. Only the tenant (or the portal) that asked for the ticket gets it. */\nexport interface SignInRedeemAnswer {\n provider: SignInProvider;\n purpose: SignInPurpose;\n /** The provider's stable id for the person (`customerIdentities.subject`). */\n subject: string;\n email: string;\n /** Link to an existing customer by email ONLY when true (board 18's one security rule). */\n emailVerified: boolean;\n name?: string;\n picture?: string;\n returnUrl: string;\n}\n\n/** What the broker refuses, in its answer body `{ code }`. */\nexport enum BrokerRefusalCode {\n /** 403 — the return address is not one of this tenant's hosts. */\n ReturnHostRefused = 'return-host-refused',\n /** 400 */\n UnknownProvider = 'unknown-provider',\n /** 503 — no client id/secret for the provider in the broker's environment. */\n ProviderNotConfigured = 'provider-not-configured',\n /** 404 */\n CodeUnknown = 'code-unknown',\n /** 410 */\n CodeUsedOrExpired = 'code-used-or-expired',\n /** 403 — another tenant's code. */\n NotYours = 'not-yours',\n}\n\nexport const BROKER_REFUSAL_STATUS: Readonly<Record<BrokerRefusalCode, number>> = Object.freeze({\n [BrokerRefusalCode.ReturnHostRefused]: 403,\n [BrokerRefusalCode.UnknownProvider]: 400,\n [BrokerRefusalCode.ProviderNotConfigured]: 503,\n [BrokerRefusalCode.CodeUnknown]: 404,\n [BrokerRefusalCode.CodeUsedOrExpired]: 410,\n [BrokerRefusalCode.NotYours]: 403,\n});\n\nexport function isBrokerRefusalCode(value: unknown): value is BrokerRefusalCode {\n return typeof value === 'string' && (Object.values(BrokerRefusalCode) as string[]).includes(value);\n}\n\n// ── back from the broker ───────────────────────────────────────────────────────────────────────\n\n/** The hand-off code's query parameter on the return address. Never a name or an email in an address. */\nexport const SIGN_IN_HANDOFF_PARAM = 'iox_signin';\n/** The failure's query parameter on the return address. */\nexport const SIGN_IN_ERROR_PARAM = 'iox_signin_error';\n\n/** Why the browser came back without a person. */\nexport enum SignInReturnError {\n /** The person pressed Cancel on the provider's screen. */\n Cancelled = 'cancelled',\n /** The provider's answer failed a check (issuer, audience, nonce, an unverified email). */\n Refused = 'refused',\n /** The ticket or the provider's state had expired. */\n Expired = 'expired',\n Failed = 'failed',\n}\n\nexport function isSignInReturnError(value: unknown): value is SignInReturnError {\n return typeof value === 'string' && (Object.values(SignInReturnError) as string[]).includes(value);\n}\n\n/** The return address with `?iox_signin=<code>` added (its own query, `next`, kept). */\nexport function withSignInHandoff(returnUrl: string, code: string): string {\n return withParam(returnUrl, SIGN_IN_HANDOFF_PARAM, code);\n}\n\n/** The return address with `?iox_signin_error=<error>` added. */\nexport function withSignInError(returnUrl: string, error: SignInReturnError): string {\n return withParam(returnUrl, SIGN_IN_ERROR_PARAM, error);\n}\n\nfunction withParam(address: string, name: string, value: string): string {\n const url = new URL(address);\n url.searchParams.delete(SIGN_IN_HANDOFF_PARAM);\n url.searchParams.delete(SIGN_IN_ERROR_PARAM);\n url.searchParams.set(name, value);\n return url.toString();\n}\n\nexport type SignInReturn =\n | { readonly code: string; readonly error?: undefined }\n | { readonly code?: undefined; readonly error: SignInReturnError };\n\n/**\n * What came back on a return address's query (`?iox_signin=` or `?iox_signin_error=`), or null when neither did. An\n * error wins over a code; an unknown error reads `failed`; an empty code is no code.\n */\nexport function readSignInReturn(search: string | URLSearchParams | null | undefined): SignInReturn | null {\n const params = typeof search === 'string' ? new URLSearchParams(search.startsWith('?') ? search.slice(1) : search) : search;\n if (!params) return null;\n const error = params.get(SIGN_IN_ERROR_PARAM);\n if (error !== null) return { error: isSignInReturnError(error) ? error : SignInReturnError.Failed };\n const code = params.get(SIGN_IN_HANDOFF_PARAM)?.trim();\n return code ? { code } : null;\n}\n","/**\n * The two address checks every sign-in step leans on. Both REFUSE when in doubt: a sign-in that sends a person to the\n * wrong place is worse than one that sends them home.\n */\n\n/** Longer than any page path a site has; a longer `next` is refused. */\nexport const NEXT_PATH_MAX_LENGTH = 2048;\n\nconst PROBE_ORIGIN = 'https://same-origin.invalid';\n// Tab, newline and other control characters are stripped by browsers from a URL, so `/\\t/evil` becomes `//evil`.\nconst CONTROL = /[\\u0000-\\u001f\\u007f]/;\n\nfunction decodedOnce(value: string): string | null {\n try {\n return decodeURIComponent(value);\n } catch {\n return null;\n }\n}\n\n/**\n * True only for a path on THIS site — the `next` a sign-in returns to (the open-redirect guard). It must start with ONE\n * `/`, hold no backslash and no control character (raw or percent-encoded), and stay on the origin when a browser\n * resolves it. `//evil.com`, `/\\evil.com`, `/%2F%2Fevil.com`, `https://evil.com`, `javascript:` — all refused.\n */\nexport function isSameOriginPath(next: unknown): next is string {\n if (typeof next !== 'string' || !next || next.length > NEXT_PATH_MAX_LENGTH) return false;\n if (next[0] !== '/') return false;\n if (CONTROL.test(next) || next.includes('\\\\')) return false;\n const decoded = decodedOnce(next);\n if (decoded === null) return false;\n if (CONTROL.test(decoded) || decoded.includes('\\\\') || decoded.startsWith('//')) return false;\n if (next.startsWith('//')) return false;\n try {\n const url = new URL(next, PROBE_ORIGIN);\n return url.origin === PROBE_ORIGIN;\n } catch {\n return false;\n }\n}\n\n/** `next` when it is a same-origin path, else `fallback` (the site's home). */\nexport function safeNextPath(next: unknown, fallback = '/'): string {\n return isSameOriginPath(next) ? next : fallback;\n}\n\nconst LOOPBACK_HOSTS: ReadonlySet<string> = new Set(['localhost', '127.0.0.1', '[::1]']);\n\nexport function isLoopbackHost(hostname: string): boolean {\n return LOOPBACK_HOSTS.has(hostname.toLowerCase());\n}\n\nexport interface ReturnHostOptions {\n /** Accept `http:` on a loopback host (tests and local stacks only — never in production). */\n allowLoopbackHttp?: boolean;\n}\n\n/** A host as `URL` normalises it (lower case, punycode, the default port dropped), or null when it is not one. */\nexport function normalizeHost(host: string): string | null {\n const value = String(host ?? '').trim();\n if (!value || /[\\s/\\\\?#@]/.test(value)) return null;\n try {\n return new URL(`https://${value}`).host;\n } catch {\n return null;\n }\n}\n\n/**\n * True when `url` returns to one of `hosts` EXACTLY (the broker's return-host check, C-D22): `https:` only (`http:` on a\n * loopback host when asked), no user or password in it, and its host — punycode, with any non-default port — equal to\n * one allowed host. Never a suffix or a prefix: `evil.idos.iox.studio` and `idos.iox.studio.evil.com` are other hosts.\n */\nexport function isAllowedReturnHost(url: unknown, hosts: ReadonlyArray<string>, options: ReturnHostOptions = {}): boolean {\n if (typeof url !== 'string' || !url || CONTROL.test(url) || url.includes('\\\\')) return false;\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return false;\n }\n if (parsed.username || parsed.password) return false;\n const loopback = isLoopbackHost(parsed.hostname);\n if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && loopback && options.allowLoopbackHttp)) return false;\n const host = parsed.host.toLowerCase();\n return hosts.some(allowed => normalizeHost(allowed) === host);\n}\n","import { safeNextPath } from './guards';\nimport { SignInProvider } from './sign-in';\n\n/**\n * A buyer's sign-in on a studio's site (commerce plan §3c, C-D5): iox-cms's public routes under `api/site/:orgId/`, the\n * session it issues, and the cookies it sets. A customer is not a user — its token has its OWN secret and audience and\n * every admin route refuses it (trap T3).\n */\n\nexport enum SiteAuthRoute {\n /** `POST { email }` → 202 always (never says whether the email is known). */\n Code = 'auth/code',\n /** `POST { email, code }` → the session. */\n CodeVerify = 'auth/code/verify',\n Refresh = 'auth/refresh',\n SignOut = 'auth/signout',\n /** `GET` → `{ customer }` (null when signed out). */\n Me = 'me',\n MyOrders = 'me/orders',\n}\n\n/** Every route a site's sign-in calls, by name (the provider pair is per provider — `siteProviderPath`). */\nexport const SITE_AUTH_ROUTES: Readonly<Record<keyof typeof SiteAuthRoute, SiteAuthRoute>> = Object.freeze({ ...SiteAuthRoute });\n\n/** A provider's two routes on the studio: start (`POST { returnPath }` → `{ startUrl }`) and return (the broker's GET). */\nexport enum SiteProviderRoute {\n Start = 'start',\n Return = 'return',\n}\n\nfunction siteBase(orgId: string): string {\n return `/api/site/${encodeURIComponent(orgId)}`;\n}\n\n/** A sign-in route of one org, ROOT-relative: `/api/site/<org>/<route>`. */\nexport function siteAuthPath(orgId: string, route: SiteAuthRoute): string {\n return `${siteBase(orgId)}/${route}`;\n}\n\n/** `/api/site/<org>/auth/<provider>/<start|return>`. */\nexport function siteProviderPath(orgId: string, provider: SignInProvider, route: SiteProviderRoute): string {\n return `${siteBase(orgId)}/auth/${encodeURIComponent(provider)}/${route}`;\n}\n\n/** The `next` query parameter of the return route — where the buyer lands after signing in. */\nexport const SIGN_IN_NEXT_PARAM = 'next';\n\n/**\n * The address the studio asks the broker to send the browser back to:\n * `https://<host>/api/site/<org>/auth/<provider>/return?next=<path>`. `origin` is the studio's own (`https://<host>`);\n * a `next` that is not a same-origin path becomes `/`.\n */\nexport function siteProviderReturnUrl(origin: string, orgId: string, provider: SignInProvider, next: string | null | undefined): string {\n const path = siteProviderPath(orgId, provider, SiteProviderRoute.Return);\n return `${origin.replace(/\\/+$/, '')}${path}?${SIGN_IN_NEXT_PARAM}=${encodeURIComponent(safeNextPath(next))}`;\n}\n\n// ── the requests and answers ───────────────────────────────────────────────────────────────────\n\nexport interface SiteProviderStartRequest {\n /** The page to come back to (a same-origin path). */\n returnPath: string;\n}\n\nexport interface SiteProviderStartAnswer {\n startUrl: string;\n}\n\nexport interface SiteCodeRequest {\n email: string;\n}\n\nexport interface SiteCodeVerifyRequest {\n email: string;\n code: string;\n}\n\n/** What a site may know about the signed-in buyer — nothing else (pages stay cacheable; personal parts fill in later). */\nexport interface SiteCustomer {\n id: string;\n email: string;\n name: string | null;\n}\n\n/** `GET me`, `POST auth/code/verify`, `POST auth/refresh`. */\nexport interface SiteMeAnswer {\n customer: SiteCustomer | null;\n}\n\n// ── the session ────────────────────────────────────────────────────────────────────────────────\n\n/** The buyer token's audience — never an admin token's. */\nexport const SITE_AUDIENCE = 'site';\n\n/** The buyer session's JWT claims. */\nexport interface SiteSessionClaims {\n /** The customer id. */\n sub: string;\n aud: typeof SITE_AUDIENCE;\n /** The org the customer belongs to — a session is good on ONE org's routes. */\n org: string;\n iat?: number;\n exp?: number;\n}\n\n/** True when `claims` carry the site audience and both ids — the shape `CustomerGuard` accepts (it checks the signature). */\nexport function isSiteSessionClaims(claims: unknown): claims is SiteSessionClaims {\n if (!claims || typeof claims !== 'object') return false;\n const c = claims as Record<string, unknown>;\n const aud = Array.isArray(c['aud']) ? c['aud'] : [c['aud']];\n return aud.includes(SITE_AUDIENCE) && typeof c['sub'] === 'string' && !!c['sub'] && typeof c['org'] === 'string' && !!c['org'];\n}\n\n/** True when a token's claims carry the site audience at all — what the admin guard refuses (T3). */\nexport function hasSiteAudience(claims: unknown): boolean {\n if (!claims || typeof claims !== 'object') return false;\n const aud = (claims as Record<string, unknown>)['aud'];\n return Array.isArray(aud) ? aud.includes(SITE_AUDIENCE) : aud === SITE_AUDIENCE;\n}\n\n// ── the cookies (per org: many orgs share one host — trap T10) ────────────────────────────────\n\n/** The buyer session: httpOnly, `Path=/` (the site's SSR reads it — the cart cookie's reason), SameSite=Lax. */\nexport const CUSTOMER_COOKIE_PREFIX = 'iox_c_';\n/** A Google sign-in in flight: httpOnly, short, holds a hash binding the ticket — a forged return fails without it. */\nexport const SIGN_IN_STATE_COOKIE_PREFIX = 'iox_si_';\nexport const SITE_COOKIE_PATH = '/';\n/** Long enough for a person on the provider's screen; the ticket inside expires long before. */\nexport const SIGN_IN_STATE_MAX_AGE_SECONDS = 600;\n\nexport function customerCookieName(orgId: string): string {\n return `${CUSTOMER_COOKIE_PREFIX}${orgId}`;\n}\n\nexport function signInStateCookieName(orgId: string): string {\n return `${SIGN_IN_STATE_COOKIE_PREFIX}${orgId}`;\n}\n\n// ── the email code ─────────────────────────────────────────────────────────────────────────────\n\nexport const EMAIL_CODE_LENGTH = 6;\nexport const EMAIL_CODE_TTL_MINUTES = 10;\nexport const EMAIL_CODE_TTL_MS = EMAIL_CODE_TTL_MINUTES * 60_000;\n/** Wrong codes before the code is spent and a new one must be sent. */\nexport const EMAIL_CODE_MAX_TRIES = 5;\n\nconst EMAIL_CODE = new RegExp(`^\\\\d{${EMAIL_CODE_LENGTH}}$`);\n\n/** A typed or pasted code as digits only (\"481 203\", \"481-203\" → \"481203\"); anything else is kept, to be refused. */\nexport function normalizeEmailCode(input: unknown): string {\n return String(input ?? '').replace(/[\\s-]/g, '');\n}\n\n/** Exactly six ASCII digits. */\nexport function isEmailCodeShape(code: unknown): boolean {\n return typeof code === 'string' && EMAIL_CODE.test(code);\n}\n\n/** An email as a studio keys its customers by (unique per org): trimmed, lower case. */\nexport function normalizeSignInEmail(email: unknown): string {\n return String(email ?? '').trim().toLowerCase();\n}\n\n/** Has the code outlived its ten minutes? `now` is the caller's — the core reads no clock. */\nexport function emailCodeExpired(sentAt: number | Date, now: number | Date): boolean {\n return +now - +sentAt >= EMAIL_CODE_TTL_MS;\n}\n\n/** How many more codes may be tried after `wrongTries` wrong ones (0 = the code is spent). */\nexport function emailCodeTriesLeft(wrongTries: number): number {\n return Math.max(0, EMAIL_CODE_MAX_TRIES - Math.max(0, Math.floor(wrongTries || 0)));\n}\n","import { BrokerRefusalCode, SignInReturnError } from './sign-in';\n\n/**\n * The sign-in dialog's words and its refusals, in English and Hebrew. A string-rendered site has no translation\n * service, so the core carries both itself (commerce-core `CHECKOUT_WORDS` precedent); a host with its own translations\n * may key them by the stable codes instead.\n */\n\nexport interface SignInLabel {\n readonly en: string;\n readonly he: string;\n}\n\nexport enum SignInLanguage {\n En = 'en',\n He = 'he',\n}\n\nexport function signInLanguage(lang: string | null | undefined): SignInLanguage {\n const primary = String(lang ?? '').trim().toLowerCase().split(/[-_]/)[0];\n return primary === 'he' || primary === 'iw' ? SignInLanguage.He : SignInLanguage.En;\n}\n\nfunction fillIn(words: string, fill: Readonly<Record<string, string | number>>): string {\n return words.replace(/\\{(\\w+)\\}/g, (all, key) => (key in fill ? String(fill[key]) : all));\n}\n\nexport enum SignInWord {\n SignIn = 'signIn',\n SignInTo = 'signInTo',\n Why = 'why',\n ContinueWithGoogle = 'continueWithGoogle',\n Or = 'or',\n Email = 'email',\n EmailPlaceholder = 'emailPlaceholder',\n SendCode = 'sendCode',\n CodeSent = 'codeSent',\n Code = 'code',\n CodeValid = 'codeValid',\n SendAgain = 'sendAgain',\n Verify = 'verify',\n OtherEmail = 'otherEmail',\n Working = 'working',\n Close = 'close',\n SignOut = 'signOut',\n Account = 'account',\n YourOrders = 'yourOrders',\n Hello = 'hello',\n SignedIn = 'signedIn',\n SignedOut = 'signedOut',\n NoPassword = 'noPassword',\n}\n\n/** `{site}`, `{email}`, `{name}`, `{minutes}` are filled by `signInWord`. */\nexport const SIGN_IN_WORDS: Readonly<Record<SignInWord, SignInLabel>> = Object.freeze({\n [SignInWord.SignIn]: { en: 'Sign in', he: 'התחברות' },\n [SignInWord.SignInTo]: { en: 'Sign in to {site}', he: 'התחברות ל־{site}' },\n [SignInWord.Why]: { en: 'See your orders and check out faster.', he: 'לראות את ההזמנות שלך ולשלם מהר יותר.' },\n [SignInWord.ContinueWithGoogle]: { en: 'Continue with Google', he: 'המשך עם Google' },\n [SignInWord.Or]: { en: 'or', he: 'או' },\n [SignInWord.Email]: { en: 'Email', he: 'אימייל' },\n [SignInWord.EmailPlaceholder]: { en: 'name@example.com', he: 'name@example.com' },\n [SignInWord.SendCode]: { en: 'Send me a code', he: 'שלחו לי קוד' },\n [SignInWord.CodeSent]: { en: 'We sent a 6-digit code to {email}', he: 'שלחנו קוד בן 6 ספרות אל {email}' },\n [SignInWord.Code]: { en: 'Code', he: 'קוד' },\n [SignInWord.CodeValid]: { en: 'Valid for {minutes} minutes', he: 'בתוקף ל־{minutes} דקות' },\n [SignInWord.SendAgain]: { en: 'Send again', he: 'שליחה חוזרת' },\n [SignInWord.Verify]: { en: 'Sign in', he: 'התחברות' },\n [SignInWord.OtherEmail]: { en: 'Use another email', he: 'אימייל אחר' },\n [SignInWord.Working]: { en: 'One moment…', he: 'רגע…' },\n [SignInWord.Close]: { en: 'Close', he: 'סגירה' },\n [SignInWord.SignOut]: { en: 'Sign out', he: 'התנתקות' },\n [SignInWord.Account]: { en: 'Account', he: 'החשבון שלי' },\n [SignInWord.YourOrders]: { en: 'Your orders', he: 'ההזמנות שלך' },\n [SignInWord.Hello]: { en: 'Hello, {name}', he: 'שלום, {name}' },\n [SignInWord.SignedIn]: { en: 'You are signed in.', he: 'התחברת.' },\n [SignInWord.SignedOut]: { en: 'You are signed out.', he: 'התנתקת.' },\n [SignInWord.NoPassword]: { en: 'No password — we email you a code.', he: 'בלי סיסמה — נשלח לך קוד במייל.' },\n});\n\nexport function signInWord(word: SignInWord, lang: string | null | undefined, fill: Readonly<Record<string, string | number>> = {}): string {\n return fillIn(SIGN_IN_WORDS[word][signInLanguage(lang)], fill);\n}\n\n// ── a refusal, said on its field ─────────────────────────────────────────────────────────────\n\n/** Where in the sign-in dialog a refusal is said. */\nexport enum SignInSlot {\n Email = 'email',\n Code = 'code',\n /** Under \"Continue with Google\". */\n Provider = 'provider',\n /** The dialog as a whole. */\n Dialog = 'dialog',\n}\n\n/**\n * Every code a site's sign-in can hear: iox-cms's answers, the broker's return errors (`?iox_signin_error=`), and\n * `network` for no answer at all.\n */\nexport enum SiteSignInRefusalCode {\n InvalidEmail = 'invalid-email',\n CodeWrong = 'code-wrong',\n CodeExpired = 'code-expired',\n TooManyTries = 'too-many-tries',\n RateLimited = 'rate-limited',\n /** The broker cannot run the provider (down, not configured, the host refused). */\n ProviderUnavailable = 'provider-unavailable',\n Cancelled = 'cancelled',\n Refused = 'refused',\n Expired = 'expired',\n Failed = 'failed',\n /** The return came back without this browser's sign-in cookie — a forged or stale return. */\n StateMismatch = 'state-mismatch',\n Blocked = 'blocked',\n NotSignedIn = 'not-signed-in',\n Network = 'network',\n}\n\ninterface SignInRefusalRule {\n readonly slot: SignInSlot;\n readonly label: SignInLabel;\n}\n\nconst TRY_GOOGLE_AGAIN: SignInLabel = { en: 'Google sign-in did not work. Try again, or use an email code.', he: 'ההתחברות עם Google לא הצליחה. נסו שוב, או התחברו עם קוד במייל.' };\nconst SEND_NEW_CODE: SignInLabel = { en: 'This code has expired. Send a new one.', he: 'תוקף הקוד פג. שלחו קוד חדש.' };\n\nexport const SIGN_IN_REFUSALS: Readonly<Record<SiteSignInRefusalCode, SignInRefusalRule>> = Object.freeze({\n [SiteSignInRefusalCode.InvalidEmail]: { slot: SignInSlot.Email, label: { en: 'Enter an email address, like name@example.com.', he: 'הקלידו כתובת אימייל, למשל name@example.com.' } },\n [SiteSignInRefusalCode.CodeWrong]: { slot: SignInSlot.Code, label: { en: 'That code is not right. Check it and try again.', he: 'הקוד לא נכון. בדקו ונסו שוב.' } },\n [SiteSignInRefusalCode.CodeExpired]: { slot: SignInSlot.Code, label: SEND_NEW_CODE },\n [SiteSignInRefusalCode.TooManyTries]: { slot: SignInSlot.Code, label: { en: 'Too many wrong codes. Send a new one.', he: 'יותר מדי קודים שגויים. שלחו קוד חדש.' } },\n [SiteSignInRefusalCode.RateLimited]: { slot: SignInSlot.Dialog, label: { en: 'Too many tries. Wait a minute and try again.', he: 'יותר מדי ניסיונות. המתינו דקה ונסו שוב.' } },\n [SiteSignInRefusalCode.ProviderUnavailable]: { slot: SignInSlot.Provider, label: { en: 'Google sign-in is not available right now. Use an email code.', he: 'ההתחברות עם Google לא זמינה כרגע. התחברו עם קוד במייל.' } },\n [SiteSignInRefusalCode.Cancelled]: { slot: SignInSlot.Provider, label: { en: 'Google sign-in was cancelled.', he: 'ההתחברות עם Google בוטלה.' } },\n [SiteSignInRefusalCode.Refused]: { slot: SignInSlot.Provider, label: { en: 'Google could not confirm this account. Use an email code.', he: 'Google לא אישר את החשבון הזה. התחברו עם קוד במייל.' } },\n [SiteSignInRefusalCode.Expired]: { slot: SignInSlot.Provider, label: { en: 'The sign-in took too long. Try again.', he: 'ההתחברות ארכה יותר מדי. נסו שוב.' } },\n [SiteSignInRefusalCode.Failed]: { slot: SignInSlot.Provider, label: TRY_GOOGLE_AGAIN },\n [SiteSignInRefusalCode.StateMismatch]: { slot: SignInSlot.Provider, label: TRY_GOOGLE_AGAIN },\n [SiteSignInRefusalCode.Blocked]: { slot: SignInSlot.Dialog, label: { en: 'This account cannot sign in here. Contact the business.', he: 'החשבון הזה לא יכול להתחבר כאן. פנו לעסק.' } },\n [SiteSignInRefusalCode.NotSignedIn]: { slot: SignInSlot.Dialog, label: { en: 'You are signed out. Sign in again.', he: 'התנתקת. התחברו שוב.' } },\n [SiteSignInRefusalCode.Network]: { slot: SignInSlot.Dialog, label: { en: 'We could not reach the site. Try again.', he: 'לא הצלחנו להגיע לאתר. נסו שוב.' } },\n});\n\nexport function isSiteSignInRefusalCode(code: unknown): code is SiteSignInRefusalCode {\n return typeof code === 'string' && (Object.values(SiteSignInRefusalCode) as string[]).includes(code);\n}\n\n/** A broker refusal as the site says it: a person never hears \"return-host-refused\". */\nconst FROM_BROKER: Readonly<Record<BrokerRefusalCode, SiteSignInRefusalCode>> = Object.freeze({\n [BrokerRefusalCode.ReturnHostRefused]: SiteSignInRefusalCode.ProviderUnavailable,\n [BrokerRefusalCode.UnknownProvider]: SiteSignInRefusalCode.ProviderUnavailable,\n [BrokerRefusalCode.ProviderNotConfigured]: SiteSignInRefusalCode.ProviderUnavailable,\n [BrokerRefusalCode.CodeUnknown]: SiteSignInRefusalCode.Expired,\n [BrokerRefusalCode.CodeUsedOrExpired]: SiteSignInRefusalCode.Expired,\n [BrokerRefusalCode.NotYours]: SiteSignInRefusalCode.Failed,\n});\n\nconst FROM_RETURN: Readonly<Record<SignInReturnError, SiteSignInRefusalCode>> = Object.freeze({\n [SignInReturnError.Cancelled]: SiteSignInRefusalCode.Cancelled,\n [SignInReturnError.Refused]: SiteSignInRefusalCode.Refused,\n [SignInReturnError.Expired]: SiteSignInRefusalCode.Expired,\n [SignInReturnError.Failed]: SiteSignInRefusalCode.Failed,\n});\n\n/** Any code a sign-in heard, as the site's own: a site code as is, a broker code or a return error mapped, else `failed`. */\nexport function siteSignInCodeOf(code: unknown): SiteSignInRefusalCode {\n if (isSiteSignInRefusalCode(code)) return code;\n if (typeof code === 'string' && code in FROM_BROKER) return FROM_BROKER[code as BrokerRefusalCode];\n if (typeof code === 'string' && code in FROM_RETURN) return FROM_RETURN[code as SignInReturnError];\n return SiteSignInRefusalCode.Failed;\n}\n\nexport interface SignInRefusal {\n code: SiteSignInRefusalCode;\n slot: SignInSlot;\n words: string;\n}\n\n/** One refusal, on its slot, in the visitor's words. */\nexport function signInRefusal(code: unknown, lang: string | null | undefined): SignInRefusal {\n const known = siteSignInCodeOf(code);\n const rule = SIGN_IN_REFUSALS[known];\n return { code: known, slot: rule.slot, words: rule.label[signInLanguage(lang)] };\n}\n\n/** A refused call's body (`{ code }`) — or nothing at all (`network`) — as one refusal. The body's `message` is a log\n * line and is never shown. A 429 with no code is `rate-limited`. */\nexport function signInRefusalOf(body: unknown, lang: string | null | undefined, status?: number | null): SignInRefusal {\n const code = body && typeof body === 'object' ? (body as { code?: unknown }).code : undefined;\n if (code !== undefined) return signInRefusal(code, lang);\n if (status === 429) return signInRefusal(SiteSignInRefusalCode.RateLimited, lang);\n return signInRefusal(body === undefined || body === null ? SiteSignInRefusalCode.Network : SiteSignInRefusalCode.Failed, lang);\n}\n","/**\n * @vectoriox/iox-ui/identity-core — the shared, FRAMEWORK-FREE vocabulary of signing in (commerce plan §3c, C-D5,\n * C-D6, C-D22): who signs in and with what, the broker's ticket / redeem shapes and refusals, a studio's site sign-in\n * routes, session claims and cookies, the email-code rules, the two address guards (open redirect, return host) and\n * the sign-in dialog's words. The broker (iox-control-plane), the studios (iox-cms), the engine and the builder speak it.\n * It imports nothing — a consumer maps this one entry.\n * ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets,\n * jest moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.\n */\nexport * from './sign-in';\nexport * from './guards';\nexport * from './site-auth';\nexport * from './words';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;;AAIG;AAEH;IACY;AAAZ,CAAA,UAAY,aAAa,EAAA;;AAErB,IAAA,aAAA,CAAA,MAAA,CAAA,GAAA,MAAa;;AAEb,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,OAAe;;AAEf,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACrB,CAAC,EAPW,aAAa,KAAb,aAAa,GAAA,EAAA,CAAA,CAAA;AASzB;IACY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACtB,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAA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C,WAAW,EAAE,IAAI,CAAC;IACjF,OAAO,aAAa,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,GAAG,qBAAqB,CAAC,OAAO,GAAG,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC;AAClI;;ACjMA;;;;;;;;AAQG;;ACRH;;AAEG;;;;"}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who signs in, with what, and the broker's two faces (commerce plan §3c "The broker, step by step", C-D6, C-D22).
|
|
3
|
+
* The broker (iox-control-plane, `auth.iox.studio`) and the studios (iox-cms) speak THESE shapes; a provider is one
|
|
4
|
+
* adapter on the broker and one `customerIdentities.provider` value in a studio. Email codes never touch the broker.
|
|
5
|
+
*/
|
|
6
|
+
/** Who the sign-in is for. */
|
|
7
|
+
declare enum SignInPurpose {
|
|
8
|
+
/** A buyer on a studio's site. */
|
|
9
|
+
Site = "site",
|
|
10
|
+
/** A studio's team member — existing users only (wave 2). */
|
|
11
|
+
Admin = "admin",
|
|
12
|
+
/** portal.iox.studio. */
|
|
13
|
+
Portal = "portal"
|
|
14
|
+
}
|
|
15
|
+
/** A provider the broker runs. Google is live; the rest join one adapter at a time (board 18). */
|
|
16
|
+
declare enum SignInProvider {
|
|
17
|
+
Google = "google",
|
|
18
|
+
Meta = "meta",
|
|
19
|
+
GitHub = "github",
|
|
20
|
+
LinkedIn = "linkedin"
|
|
21
|
+
}
|
|
22
|
+
/** How a provider answers (board 18): OpenID Connect gives a SIGNED ID token; OAuth 2 needs a profile call. */
|
|
23
|
+
declare enum SignInProtocol {
|
|
24
|
+
Oidc = "oidc",
|
|
25
|
+
OAuth2 = "oauth2"
|
|
26
|
+
}
|
|
27
|
+
interface SignInProviderSpec {
|
|
28
|
+
readonly protocol: SignInProtocol;
|
|
29
|
+
/** The answer is signed, so a studio can check it itself — the only kind an admin may sign in with (C-D6). */
|
|
30
|
+
readonly signedAnswer: boolean;
|
|
31
|
+
/** Running on the broker today. */
|
|
32
|
+
readonly live: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare const SIGN_IN_PROVIDER_SPECS: Readonly<Record<SignInProvider, SignInProviderSpec>>;
|
|
35
|
+
declare function isSignInProvider(value: unknown): value is SignInProvider;
|
|
36
|
+
declare function isSignInPurpose(value: unknown): value is SignInPurpose;
|
|
37
|
+
/** May `provider` serve `purpose`? Buyers and the portal take any provider; a team member only a signed answer (C-D6). */
|
|
38
|
+
declare function providerServes(provider: SignInProvider, purpose: SignInPurpose): boolean;
|
|
39
|
+
/** The broker's public host (its own ingress; ops.iox.studio is unchanged). */
|
|
40
|
+
declare const BROKER_HOST = "auth.iox.studio";
|
|
41
|
+
declare const BROKER_ORIGIN = "https://auth.iox.studio";
|
|
42
|
+
/** A ticket lives 60 s and is used once; so does a hand-off code. */
|
|
43
|
+
declare const SIGN_IN_TICKET_TTL_SECONDS = 60;
|
|
44
|
+
declare const SIGN_IN_HANDOFF_TTL_SECONDS = 60;
|
|
45
|
+
/** The server-to-server routes on the control plane's API host (bearer: the studio's INSTANCE_TOKEN). */
|
|
46
|
+
declare enum BrokerApiRoute {
|
|
47
|
+
Tickets = "instances/me/sign-in/tickets",
|
|
48
|
+
Redeem = "instances/me/sign-in/redeem"
|
|
49
|
+
}
|
|
50
|
+
/** The browser's routes on `auth.iox.studio`, one pair per provider. */
|
|
51
|
+
declare enum BrokerBrowserRoute {
|
|
52
|
+
Start = "start",
|
|
53
|
+
Callback = "callback"
|
|
54
|
+
}
|
|
55
|
+
/** `/<route>` on the control plane's API host, root-relative. */
|
|
56
|
+
declare function brokerApiPath(route: BrokerApiRoute): string;
|
|
57
|
+
/** `https://auth.iox.studio/<provider>/<route>`. */
|
|
58
|
+
declare function brokerBrowserUrl(provider: SignInProvider, route: BrokerBrowserRoute, origin?: string): string;
|
|
59
|
+
/** Where the browser goes to begin: `https://auth.iox.studio/<provider>/start?ticket=<ticket>`. */
|
|
60
|
+
declare function brokerStartUrl(provider: SignInProvider, ticket: string, origin?: string): string;
|
|
61
|
+
/** The ONE address registered with each provider: `https://auth.iox.studio/<provider>/callback`. */
|
|
62
|
+
declare function brokerCallbackUrl(provider: SignInProvider, origin?: string): string;
|
|
63
|
+
declare const BROKER_TICKET_PARAM = "ticket";
|
|
64
|
+
/** `POST instances/me/sign-in/tickets` — body. */
|
|
65
|
+
interface SignInTicketRequest {
|
|
66
|
+
provider: SignInProvider;
|
|
67
|
+
purpose: SignInPurpose;
|
|
68
|
+
/** Where the broker sends the browser back; its host must be one of the asking tenant's. */
|
|
69
|
+
returnUrl: string;
|
|
70
|
+
}
|
|
71
|
+
/** 201 — `expiresAt` is an ISO date. */
|
|
72
|
+
interface SignInTicketAnswer {
|
|
73
|
+
ticket: string;
|
|
74
|
+
startUrl: string;
|
|
75
|
+
expiresAt: string;
|
|
76
|
+
}
|
|
77
|
+
/** `POST instances/me/sign-in/redeem` — body: the hand-off code the browser brought back. */
|
|
78
|
+
interface SignInRedeemRequest {
|
|
79
|
+
code: string;
|
|
80
|
+
}
|
|
81
|
+
/** 200 — the person the provider vouched for. Only the tenant (or the portal) that asked for the ticket gets it. */
|
|
82
|
+
interface SignInRedeemAnswer {
|
|
83
|
+
provider: SignInProvider;
|
|
84
|
+
purpose: SignInPurpose;
|
|
85
|
+
/** The provider's stable id for the person (`customerIdentities.subject`). */
|
|
86
|
+
subject: string;
|
|
87
|
+
email: string;
|
|
88
|
+
/** Link to an existing customer by email ONLY when true (board 18's one security rule). */
|
|
89
|
+
emailVerified: boolean;
|
|
90
|
+
name?: string;
|
|
91
|
+
picture?: string;
|
|
92
|
+
returnUrl: string;
|
|
93
|
+
}
|
|
94
|
+
/** What the broker refuses, in its answer body `{ code }`. */
|
|
95
|
+
declare enum BrokerRefusalCode {
|
|
96
|
+
/** 403 — the return address is not one of this tenant's hosts. */
|
|
97
|
+
ReturnHostRefused = "return-host-refused",
|
|
98
|
+
/** 400 */
|
|
99
|
+
UnknownProvider = "unknown-provider",
|
|
100
|
+
/** 503 — no client id/secret for the provider in the broker's environment. */
|
|
101
|
+
ProviderNotConfigured = "provider-not-configured",
|
|
102
|
+
/** 404 */
|
|
103
|
+
CodeUnknown = "code-unknown",
|
|
104
|
+
/** 410 */
|
|
105
|
+
CodeUsedOrExpired = "code-used-or-expired",
|
|
106
|
+
/** 403 — another tenant's code. */
|
|
107
|
+
NotYours = "not-yours"
|
|
108
|
+
}
|
|
109
|
+
declare const BROKER_REFUSAL_STATUS: Readonly<Record<BrokerRefusalCode, number>>;
|
|
110
|
+
declare function isBrokerRefusalCode(value: unknown): value is BrokerRefusalCode;
|
|
111
|
+
/** The hand-off code's query parameter on the return address. Never a name or an email in an address. */
|
|
112
|
+
declare const SIGN_IN_HANDOFF_PARAM = "iox_signin";
|
|
113
|
+
/** The failure's query parameter on the return address. */
|
|
114
|
+
declare const SIGN_IN_ERROR_PARAM = "iox_signin_error";
|
|
115
|
+
/** Why the browser came back without a person. */
|
|
116
|
+
declare enum SignInReturnError {
|
|
117
|
+
/** The person pressed Cancel on the provider's screen. */
|
|
118
|
+
Cancelled = "cancelled",
|
|
119
|
+
/** The provider's answer failed a check (issuer, audience, nonce, an unverified email). */
|
|
120
|
+
Refused = "refused",
|
|
121
|
+
/** The ticket or the provider's state had expired. */
|
|
122
|
+
Expired = "expired",
|
|
123
|
+
Failed = "failed"
|
|
124
|
+
}
|
|
125
|
+
declare function isSignInReturnError(value: unknown): value is SignInReturnError;
|
|
126
|
+
/** The return address with `?iox_signin=<code>` added (its own query, `next`, kept). */
|
|
127
|
+
declare function withSignInHandoff(returnUrl: string, code: string): string;
|
|
128
|
+
/** The return address with `?iox_signin_error=<error>` added. */
|
|
129
|
+
declare function withSignInError(returnUrl: string, error: SignInReturnError): string;
|
|
130
|
+
type SignInReturn = {
|
|
131
|
+
readonly code: string;
|
|
132
|
+
readonly error?: undefined;
|
|
133
|
+
} | {
|
|
134
|
+
readonly code?: undefined;
|
|
135
|
+
readonly error: SignInReturnError;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* What came back on a return address's query (`?iox_signin=` or `?iox_signin_error=`), or null when neither did. An
|
|
139
|
+
* error wins over a code; an unknown error reads `failed`; an empty code is no code.
|
|
140
|
+
*/
|
|
141
|
+
declare function readSignInReturn(search: string | URLSearchParams | null | undefined): SignInReturn | null;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The two address checks every sign-in step leans on. Both REFUSE when in doubt: a sign-in that sends a person to the
|
|
145
|
+
* wrong place is worse than one that sends them home.
|
|
146
|
+
*/
|
|
147
|
+
/** Longer than any page path a site has; a longer `next` is refused. */
|
|
148
|
+
declare const NEXT_PATH_MAX_LENGTH = 2048;
|
|
149
|
+
/**
|
|
150
|
+
* True only for a path on THIS site — the `next` a sign-in returns to (the open-redirect guard). It must start with ONE
|
|
151
|
+
* `/`, hold no backslash and no control character (raw or percent-encoded), and stay on the origin when a browser
|
|
152
|
+
* resolves it. `//evil.com`, `/\evil.com`, `/%2F%2Fevil.com`, `https://evil.com`, `javascript:` — all refused.
|
|
153
|
+
*/
|
|
154
|
+
declare function isSameOriginPath(next: unknown): next is string;
|
|
155
|
+
/** `next` when it is a same-origin path, else `fallback` (the site's home). */
|
|
156
|
+
declare function safeNextPath(next: unknown, fallback?: string): string;
|
|
157
|
+
declare function isLoopbackHost(hostname: string): boolean;
|
|
158
|
+
interface ReturnHostOptions {
|
|
159
|
+
/** Accept `http:` on a loopback host (tests and local stacks only — never in production). */
|
|
160
|
+
allowLoopbackHttp?: boolean;
|
|
161
|
+
}
|
|
162
|
+
/** A host as `URL` normalises it (lower case, punycode, the default port dropped), or null when it is not one. */
|
|
163
|
+
declare function normalizeHost(host: string): string | null;
|
|
164
|
+
/**
|
|
165
|
+
* True when `url` returns to one of `hosts` EXACTLY (the broker's return-host check, C-D22): `https:` only (`http:` on a
|
|
166
|
+
* loopback host when asked), no user or password in it, and its host — punycode, with any non-default port — equal to
|
|
167
|
+
* one allowed host. Never a suffix or a prefix: `evil.idos.iox.studio` and `idos.iox.studio.evil.com` are other hosts.
|
|
168
|
+
*/
|
|
169
|
+
declare function isAllowedReturnHost(url: unknown, hosts: ReadonlyArray<string>, options?: ReturnHostOptions): boolean;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* A buyer's sign-in on a studio's site (commerce plan §3c, C-D5): iox-cms's public routes under `api/site/:orgId/`, the
|
|
173
|
+
* session it issues, and the cookies it sets. A customer is not a user — its token has its OWN secret and audience and
|
|
174
|
+
* every admin route refuses it (trap T3).
|
|
175
|
+
*/
|
|
176
|
+
declare enum SiteAuthRoute {
|
|
177
|
+
/** `POST { email }` → 202 always (never says whether the email is known). */
|
|
178
|
+
Code = "auth/code",
|
|
179
|
+
/** `POST { email, code }` → the session. */
|
|
180
|
+
CodeVerify = "auth/code/verify",
|
|
181
|
+
Refresh = "auth/refresh",
|
|
182
|
+
SignOut = "auth/signout",
|
|
183
|
+
/** `GET` → `{ customer }` (null when signed out). */
|
|
184
|
+
Me = "me",
|
|
185
|
+
MyOrders = "me/orders"
|
|
186
|
+
}
|
|
187
|
+
/** Every route a site's sign-in calls, by name (the provider pair is per provider — `siteProviderPath`). */
|
|
188
|
+
declare const SITE_AUTH_ROUTES: Readonly<Record<keyof typeof SiteAuthRoute, SiteAuthRoute>>;
|
|
189
|
+
/** A provider's two routes on the studio: start (`POST { returnPath }` → `{ startUrl }`) and return (the broker's GET). */
|
|
190
|
+
declare enum SiteProviderRoute {
|
|
191
|
+
Start = "start",
|
|
192
|
+
Return = "return"
|
|
193
|
+
}
|
|
194
|
+
/** A sign-in route of one org, ROOT-relative: `/api/site/<org>/<route>`. */
|
|
195
|
+
declare function siteAuthPath(orgId: string, route: SiteAuthRoute): string;
|
|
196
|
+
/** `/api/site/<org>/auth/<provider>/<start|return>`. */
|
|
197
|
+
declare function siteProviderPath(orgId: string, provider: SignInProvider, route: SiteProviderRoute): string;
|
|
198
|
+
/** The `next` query parameter of the return route — where the buyer lands after signing in. */
|
|
199
|
+
declare const SIGN_IN_NEXT_PARAM = "next";
|
|
200
|
+
/**
|
|
201
|
+
* The address the studio asks the broker to send the browser back to:
|
|
202
|
+
* `https://<host>/api/site/<org>/auth/<provider>/return?next=<path>`. `origin` is the studio's own (`https://<host>`);
|
|
203
|
+
* a `next` that is not a same-origin path becomes `/`.
|
|
204
|
+
*/
|
|
205
|
+
declare function siteProviderReturnUrl(origin: string, orgId: string, provider: SignInProvider, next: string | null | undefined): string;
|
|
206
|
+
interface SiteProviderStartRequest {
|
|
207
|
+
/** The page to come back to (a same-origin path). */
|
|
208
|
+
returnPath: string;
|
|
209
|
+
}
|
|
210
|
+
interface SiteProviderStartAnswer {
|
|
211
|
+
startUrl: string;
|
|
212
|
+
}
|
|
213
|
+
interface SiteCodeRequest {
|
|
214
|
+
email: string;
|
|
215
|
+
}
|
|
216
|
+
interface SiteCodeVerifyRequest {
|
|
217
|
+
email: string;
|
|
218
|
+
code: string;
|
|
219
|
+
}
|
|
220
|
+
/** What a site may know about the signed-in buyer — nothing else (pages stay cacheable; personal parts fill in later). */
|
|
221
|
+
interface SiteCustomer {
|
|
222
|
+
id: string;
|
|
223
|
+
email: string;
|
|
224
|
+
name: string | null;
|
|
225
|
+
}
|
|
226
|
+
/** `GET me`, `POST auth/code/verify`, `POST auth/refresh`. */
|
|
227
|
+
interface SiteMeAnswer {
|
|
228
|
+
customer: SiteCustomer | null;
|
|
229
|
+
}
|
|
230
|
+
/** The buyer token's audience — never an admin token's. */
|
|
231
|
+
declare const SITE_AUDIENCE = "site";
|
|
232
|
+
/** The buyer session's JWT claims. */
|
|
233
|
+
interface SiteSessionClaims {
|
|
234
|
+
/** The customer id. */
|
|
235
|
+
sub: string;
|
|
236
|
+
aud: typeof SITE_AUDIENCE;
|
|
237
|
+
/** The org the customer belongs to — a session is good on ONE org's routes. */
|
|
238
|
+
org: string;
|
|
239
|
+
iat?: number;
|
|
240
|
+
exp?: number;
|
|
241
|
+
}
|
|
242
|
+
/** True when `claims` carry the site audience and both ids — the shape `CustomerGuard` accepts (it checks the signature). */
|
|
243
|
+
declare function isSiteSessionClaims(claims: unknown): claims is SiteSessionClaims;
|
|
244
|
+
/** True when a token's claims carry the site audience at all — what the admin guard refuses (T3). */
|
|
245
|
+
declare function hasSiteAudience(claims: unknown): boolean;
|
|
246
|
+
/** The buyer session: httpOnly, `Path=/` (the site's SSR reads it — the cart cookie's reason), SameSite=Lax. */
|
|
247
|
+
declare const CUSTOMER_COOKIE_PREFIX = "iox_c_";
|
|
248
|
+
/** A Google sign-in in flight: httpOnly, short, holds a hash binding the ticket — a forged return fails without it. */
|
|
249
|
+
declare const SIGN_IN_STATE_COOKIE_PREFIX = "iox_si_";
|
|
250
|
+
declare const SITE_COOKIE_PATH = "/";
|
|
251
|
+
/** Long enough for a person on the provider's screen; the ticket inside expires long before. */
|
|
252
|
+
declare const SIGN_IN_STATE_MAX_AGE_SECONDS = 600;
|
|
253
|
+
declare function customerCookieName(orgId: string): string;
|
|
254
|
+
declare function signInStateCookieName(orgId: string): string;
|
|
255
|
+
declare const EMAIL_CODE_LENGTH = 6;
|
|
256
|
+
declare const EMAIL_CODE_TTL_MINUTES = 10;
|
|
257
|
+
declare const EMAIL_CODE_TTL_MS: number;
|
|
258
|
+
/** Wrong codes before the code is spent and a new one must be sent. */
|
|
259
|
+
declare const EMAIL_CODE_MAX_TRIES = 5;
|
|
260
|
+
/** A typed or pasted code as digits only ("481 203", "481-203" → "481203"); anything else is kept, to be refused. */
|
|
261
|
+
declare function normalizeEmailCode(input: unknown): string;
|
|
262
|
+
/** Exactly six ASCII digits. */
|
|
263
|
+
declare function isEmailCodeShape(code: unknown): boolean;
|
|
264
|
+
/** An email as a studio keys its customers by (unique per org): trimmed, lower case. */
|
|
265
|
+
declare function normalizeSignInEmail(email: unknown): string;
|
|
266
|
+
/** Has the code outlived its ten minutes? `now` is the caller's — the core reads no clock. */
|
|
267
|
+
declare function emailCodeExpired(sentAt: number | Date, now: number | Date): boolean;
|
|
268
|
+
/** How many more codes may be tried after `wrongTries` wrong ones (0 = the code is spent). */
|
|
269
|
+
declare function emailCodeTriesLeft(wrongTries: number): number;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* The sign-in dialog's words and its refusals, in English and Hebrew. A string-rendered site has no translation
|
|
273
|
+
* service, so the core carries both itself (commerce-core `CHECKOUT_WORDS` precedent); a host with its own translations
|
|
274
|
+
* may key them by the stable codes instead.
|
|
275
|
+
*/
|
|
276
|
+
interface SignInLabel {
|
|
277
|
+
readonly en: string;
|
|
278
|
+
readonly he: string;
|
|
279
|
+
}
|
|
280
|
+
declare enum SignInLanguage {
|
|
281
|
+
En = "en",
|
|
282
|
+
He = "he"
|
|
283
|
+
}
|
|
284
|
+
declare function signInLanguage(lang: string | null | undefined): SignInLanguage;
|
|
285
|
+
declare enum SignInWord {
|
|
286
|
+
SignIn = "signIn",
|
|
287
|
+
SignInTo = "signInTo",
|
|
288
|
+
Why = "why",
|
|
289
|
+
ContinueWithGoogle = "continueWithGoogle",
|
|
290
|
+
Or = "or",
|
|
291
|
+
Email = "email",
|
|
292
|
+
EmailPlaceholder = "emailPlaceholder",
|
|
293
|
+
SendCode = "sendCode",
|
|
294
|
+
CodeSent = "codeSent",
|
|
295
|
+
Code = "code",
|
|
296
|
+
CodeValid = "codeValid",
|
|
297
|
+
SendAgain = "sendAgain",
|
|
298
|
+
Verify = "verify",
|
|
299
|
+
OtherEmail = "otherEmail",
|
|
300
|
+
Working = "working",
|
|
301
|
+
Close = "close",
|
|
302
|
+
SignOut = "signOut",
|
|
303
|
+
Account = "account",
|
|
304
|
+
YourOrders = "yourOrders",
|
|
305
|
+
Hello = "hello",
|
|
306
|
+
SignedIn = "signedIn",
|
|
307
|
+
SignedOut = "signedOut",
|
|
308
|
+
NoPassword = "noPassword"
|
|
309
|
+
}
|
|
310
|
+
/** `{site}`, `{email}`, `{name}`, `{minutes}` are filled by `signInWord`. */
|
|
311
|
+
declare const SIGN_IN_WORDS: Readonly<Record<SignInWord, SignInLabel>>;
|
|
312
|
+
declare function signInWord(word: SignInWord, lang: string | null | undefined, fill?: Readonly<Record<string, string | number>>): string;
|
|
313
|
+
/** Where in the sign-in dialog a refusal is said. */
|
|
314
|
+
declare enum SignInSlot {
|
|
315
|
+
Email = "email",
|
|
316
|
+
Code = "code",
|
|
317
|
+
/** Under "Continue with Google". */
|
|
318
|
+
Provider = "provider",
|
|
319
|
+
/** The dialog as a whole. */
|
|
320
|
+
Dialog = "dialog"
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Every code a site's sign-in can hear: iox-cms's answers, the broker's return errors (`?iox_signin_error=`), and
|
|
324
|
+
* `network` for no answer at all.
|
|
325
|
+
*/
|
|
326
|
+
declare enum SiteSignInRefusalCode {
|
|
327
|
+
InvalidEmail = "invalid-email",
|
|
328
|
+
CodeWrong = "code-wrong",
|
|
329
|
+
CodeExpired = "code-expired",
|
|
330
|
+
TooManyTries = "too-many-tries",
|
|
331
|
+
RateLimited = "rate-limited",
|
|
332
|
+
/** The broker cannot run the provider (down, not configured, the host refused). */
|
|
333
|
+
ProviderUnavailable = "provider-unavailable",
|
|
334
|
+
Cancelled = "cancelled",
|
|
335
|
+
Refused = "refused",
|
|
336
|
+
Expired = "expired",
|
|
337
|
+
Failed = "failed",
|
|
338
|
+
/** The return came back without this browser's sign-in cookie — a forged or stale return. */
|
|
339
|
+
StateMismatch = "state-mismatch",
|
|
340
|
+
Blocked = "blocked",
|
|
341
|
+
NotSignedIn = "not-signed-in",
|
|
342
|
+
Network = "network"
|
|
343
|
+
}
|
|
344
|
+
interface SignInRefusalRule {
|
|
345
|
+
readonly slot: SignInSlot;
|
|
346
|
+
readonly label: SignInLabel;
|
|
347
|
+
}
|
|
348
|
+
declare const SIGN_IN_REFUSALS: Readonly<Record<SiteSignInRefusalCode, SignInRefusalRule>>;
|
|
349
|
+
declare function isSiteSignInRefusalCode(code: unknown): code is SiteSignInRefusalCode;
|
|
350
|
+
/** Any code a sign-in heard, as the site's own: a site code as is, a broker code or a return error mapped, else `failed`. */
|
|
351
|
+
declare function siteSignInCodeOf(code: unknown): SiteSignInRefusalCode;
|
|
352
|
+
interface SignInRefusal {
|
|
353
|
+
code: SiteSignInRefusalCode;
|
|
354
|
+
slot: SignInSlot;
|
|
355
|
+
words: string;
|
|
356
|
+
}
|
|
357
|
+
/** One refusal, on its slot, in the visitor's words. */
|
|
358
|
+
declare function signInRefusal(code: unknown, lang: string | null | undefined): SignInRefusal;
|
|
359
|
+
/** A refused call's body (`{ code }`) — or nothing at all (`network`) — as one refusal. The body's `message` is a log
|
|
360
|
+
* line and is never shown. A 429 with no code is `rate-limited`. */
|
|
361
|
+
declare function signInRefusalOf(body: unknown, lang: string | null | undefined, status?: number | null): SignInRefusal;
|
|
362
|
+
|
|
363
|
+
export { BROKER_HOST, BROKER_ORIGIN, BROKER_REFUSAL_STATUS, BROKER_TICKET_PARAM, BrokerApiRoute, BrokerBrowserRoute, BrokerRefusalCode, CUSTOMER_COOKIE_PREFIX, EMAIL_CODE_LENGTH, EMAIL_CODE_MAX_TRIES, EMAIL_CODE_TTL_MINUTES, EMAIL_CODE_TTL_MS, NEXT_PATH_MAX_LENGTH, SIGN_IN_ERROR_PARAM, SIGN_IN_HANDOFF_PARAM, SIGN_IN_HANDOFF_TTL_SECONDS, SIGN_IN_NEXT_PARAM, SIGN_IN_PROVIDER_SPECS, SIGN_IN_REFUSALS, SIGN_IN_STATE_COOKIE_PREFIX, SIGN_IN_STATE_MAX_AGE_SECONDS, SIGN_IN_TICKET_TTL_SECONDS, SIGN_IN_WORDS, SITE_AUDIENCE, SITE_AUTH_ROUTES, SITE_COOKIE_PATH, SignInLanguage, SignInProtocol, SignInProvider, SignInPurpose, SignInReturnError, SignInSlot, SignInWord, SiteAuthRoute, SiteProviderRoute, SiteSignInRefusalCode, brokerApiPath, brokerBrowserUrl, brokerCallbackUrl, brokerStartUrl, customerCookieName, emailCodeExpired, emailCodeTriesLeft, hasSiteAudience, isAllowedReturnHost, isBrokerRefusalCode, isEmailCodeShape, isLoopbackHost, isSameOriginPath, isSignInProvider, isSignInPurpose, isSignInReturnError, isSiteSessionClaims, isSiteSignInRefusalCode, normalizeEmailCode, normalizeHost, normalizeSignInEmail, providerServes, readSignInReturn, safeNextPath, signInLanguage, signInRefusal, signInRefusalOf, signInStateCookieName, signInWord, siteAuthPath, siteProviderPath, siteProviderReturnUrl, siteSignInCodeOf, withSignInError, withSignInHandoff };
|
|
364
|
+
export type { ReturnHostOptions, SignInLabel, SignInProviderSpec, SignInRedeemAnswer, SignInRedeemRequest, SignInRefusal, SignInReturn, SignInTicketAnswer, SignInTicketRequest, SiteCodeRequest, SiteCodeVerifyRequest, SiteCustomer, SiteMeAnswer, SiteProviderStartAnswer, SiteProviderStartRequest, SiteSessionClaims };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectoriox/iox-ui",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.99.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": ">=20.0.0",
|
|
6
6
|
"@angular/core": ">=20.0.0",
|
|
@@ -55,6 +55,10 @@
|
|
|
55
55
|
"types": "./harness-core/index.d.ts",
|
|
56
56
|
"default": "./fesm2022/vectoriox-iox-ui-harness-core.mjs"
|
|
57
57
|
},
|
|
58
|
+
"./identity-core": {
|
|
59
|
+
"types": "./identity-core/index.d.ts",
|
|
60
|
+
"default": "./fesm2022/vectoriox-iox-ui-identity-core.mjs"
|
|
61
|
+
},
|
|
58
62
|
"./media-core": {
|
|
59
63
|
"types": "./media-core/index.d.ts",
|
|
60
64
|
"default": "./fesm2022/vectoriox-iox-ui-media-core.mjs"
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two address checks every sign-in step leans on. Both REFUSE when in doubt: a sign-in that sends a person to the
|
|
3
|
+
* wrong place is worse than one that sends them home.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Longer than any page path a site has; a longer `next` is refused. */
|
|
7
|
+
export const NEXT_PATH_MAX_LENGTH = 2048;
|
|
8
|
+
|
|
9
|
+
const PROBE_ORIGIN = 'https://same-origin.invalid';
|
|
10
|
+
// Tab, newline and other control characters are stripped by browsers from a URL, so `/\t/evil` becomes `//evil`.
|
|
11
|
+
const CONTROL = /[\u0000-\u001f\u007f]/;
|
|
12
|
+
|
|
13
|
+
function decodedOnce(value: string): string | null {
|
|
14
|
+
try {
|
|
15
|
+
return decodeURIComponent(value);
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* True only for a path on THIS site — the `next` a sign-in returns to (the open-redirect guard). It must start with ONE
|
|
23
|
+
* `/`, hold no backslash and no control character (raw or percent-encoded), and stay on the origin when a browser
|
|
24
|
+
* resolves it. `//evil.com`, `/\evil.com`, `/%2F%2Fevil.com`, `https://evil.com`, `javascript:` — all refused.
|
|
25
|
+
*/
|
|
26
|
+
export function isSameOriginPath(next: unknown): next is string {
|
|
27
|
+
if (typeof next !== 'string' || !next || next.length > NEXT_PATH_MAX_LENGTH) return false;
|
|
28
|
+
if (next[0] !== '/') return false;
|
|
29
|
+
if (CONTROL.test(next) || next.includes('\\')) return false;
|
|
30
|
+
const decoded = decodedOnce(next);
|
|
31
|
+
if (decoded === null) return false;
|
|
32
|
+
if (CONTROL.test(decoded) || decoded.includes('\\') || decoded.startsWith('//')) return false;
|
|
33
|
+
if (next.startsWith('//')) return false;
|
|
34
|
+
try {
|
|
35
|
+
const url = new URL(next, PROBE_ORIGIN);
|
|
36
|
+
return url.origin === PROBE_ORIGIN;
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** `next` when it is a same-origin path, else `fallback` (the site's home). */
|
|
43
|
+
export function safeNextPath(next: unknown, fallback = '/'): string {
|
|
44
|
+
return isSameOriginPath(next) ? next : fallback;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const LOOPBACK_HOSTS: ReadonlySet<string> = new Set(['localhost', '127.0.0.1', '[::1]']);
|
|
48
|
+
|
|
49
|
+
export function isLoopbackHost(hostname: string): boolean {
|
|
50
|
+
return LOOPBACK_HOSTS.has(hostname.toLowerCase());
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ReturnHostOptions {
|
|
54
|
+
/** Accept `http:` on a loopback host (tests and local stacks only — never in production). */
|
|
55
|
+
allowLoopbackHttp?: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A host as `URL` normalises it (lower case, punycode, the default port dropped), or null when it is not one. */
|
|
59
|
+
export function normalizeHost(host: string): string | null {
|
|
60
|
+
const value = String(host ?? '').trim();
|
|
61
|
+
if (!value || /[\s/\\?#@]/.test(value)) return null;
|
|
62
|
+
try {
|
|
63
|
+
return new URL(`https://${value}`).host;
|
|
64
|
+
} catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* True when `url` returns to one of `hosts` EXACTLY (the broker's return-host check, C-D22): `https:` only (`http:` on a
|
|
71
|
+
* loopback host when asked), no user or password in it, and its host — punycode, with any non-default port — equal to
|
|
72
|
+
* one allowed host. Never a suffix or a prefix: `evil.idos.iox.studio` and `idos.iox.studio.evil.com` are other hosts.
|
|
73
|
+
*/
|
|
74
|
+
export function isAllowedReturnHost(url: unknown, hosts: ReadonlyArray<string>, options: ReturnHostOptions = {}): boolean {
|
|
75
|
+
if (typeof url !== 'string' || !url || CONTROL.test(url) || url.includes('\\')) return false;
|
|
76
|
+
let parsed: URL;
|
|
77
|
+
try {
|
|
78
|
+
parsed = new URL(url);
|
|
79
|
+
} catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (parsed.username || parsed.password) return false;
|
|
83
|
+
const loopback = isLoopbackHost(parsed.hostname);
|
|
84
|
+
if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && loopback && options.allowLoopbackHttp)) return false;
|
|
85
|
+
const host = parsed.host.toLowerCase();
|
|
86
|
+
return hosts.some(allowed => normalizeHost(allowed) === host);
|
|
87
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vectoriox/iox-ui/identity-core — the shared, FRAMEWORK-FREE vocabulary of signing in (commerce plan §3c, C-D5,
|
|
3
|
+
* C-D6, C-D22): who signs in and with what, the broker's ticket / redeem shapes and refusals, a studio's site sign-in
|
|
4
|
+
* routes, session claims and cookies, the email-code rules, the two address guards (open redirect, return host) and
|
|
5
|
+
* the sign-in dialog's words. The broker (iox-control-plane), the studios (iox-cms), the engine and the builder speak it.
|
|
6
|
+
* It imports nothing — a consumer maps this one entry.
|
|
7
|
+
* ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets,
|
|
8
|
+
* jest moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.
|
|
9
|
+
*/
|
|
10
|
+
export * from './sign-in';
|
|
11
|
+
export * from './guards';
|
|
12
|
+
export * from './site-auth';
|
|
13
|
+
export * from './words';
|