@voyant-travel/auth 0.140.2 → 0.141.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.
@@ -1 +1 @@
1
- {"version":3,"file":"storefront-local-adapter.js","sourceRoot":"","sources":["../src/storefront-local-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAML,iBAAiB,EACjB,iCAAiC,EACjC,WAAW,GACZ,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EAEL,kCAAkC,GACnC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,gCAAgC,EAChC,iCAAiC,EACjC,wCAAwC,EACxC,sCAAsC,EACtC,oBAAoB,GACrB,MAAM,yBAAyB,CAAA;AAahC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAEnE,SAAS,eAAe,CAAC,GAAqB;IAC5C,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI;QAC1B,cAAc,EAAE,CAAC,GAAG,GAAG,CAAC,cAAc,CAAC;QACvC,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,eAAe,EAAE,GAAG,CAAC,eAAe;QACpC,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE;QACtC,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE;KACvC,CAAA;AACH,C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CAAC,EAAE;iBACb,MAAM,CAAC,iCAAiC,CAAC;iBACzC,KAAK,CACJ,GAAG,CACD,EAAE,CAAC,iCAAiC,CAAC,YAAY,EAAE,YAAY,CAAC,EAChE,EAAE,CAAC,iCAAiC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACzD,CACF,CAAA;QACL,CAAC;QAED,KAAK,CAAC,0BAA0B,CAC9B,OAAiC,EACjC,YAAoB,EACpB,SAA0D;YAE1D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,EAAE,CAAA;YACrC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,EAAE;iBAC1B,MAAM,EAAE;iBACR,IAAI,CAAC,iCAAiC,CAAC;iBACvC,KAAK,CAAC,EAAE,CAAC,iCAAiC,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAA;YAC1E,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;YAC9C,MAAM,QAAQ,GAA0C,EAAE,CAAA;YAC1D,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;oBAAE,SAAQ;gBAC/C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;gBAChE,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAA2B,CAAA;YAC1E,CAAC;YACD,OAAO,QAAQ,CAAA;QACjB,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["/**\n * Local storefront runtime provider — backs {@link storefrontRuntimePort} with\n * the deployment's own runtime DB (self-host). Mirrors the team-management\n * local adapter: every operator write is bounded to `context.organizationId`,\n * and request-time resolution (`resolveStorefrontByApiKey`) is org-agnostic.\n */\nimport {\n type InsertStorefront,\n type SelectStorefront,\n type SelectStorefrontApiKey,\n type SelectStorefrontCustomerAuthCredential,\n type StorefrontCustomerAuthSocialProvider,\n storefrontApiKeys,\n storefrontCustomerAuthCredentials,\n storefronts,\n} from \"@voyant-travel/db/schema/iam\"\nimport { and, desc, eq } from \"drizzle-orm\"\n\nimport {\n type StorefrontCredentialCipher,\n validateStorefrontCredentialBundle,\n} from \"./storefront-credentials.js\"\nimport {\n classifyStorefrontApiKey,\n generateStorefrontApiKey,\n hashStorefrontApiKey,\n} from \"./storefront-keys.js\"\nimport {\n enabledStorefrontSocialProviders,\n normalizeStorefrontAllowedOrigins,\n normalizeStorefrontCustomerAccountPolicy,\n normalizeStorefrontCustomerAuthMethods,\n StorefrontInputError,\n} from \"./storefront-origins.js\"\nimport type {\n IssuedStorefrontApiKeyDto,\n ResolvedStorefrontApiKey,\n ResolvedStorefrontProviderCredentials,\n StorefrontApiKeyDto,\n StorefrontDto,\n StorefrontProviderCredentialStatusDto,\n StorefrontRequestContext,\n StorefrontResolveContext,\n StorefrontRuntimeProvider,\n} from \"./storefront-runtime-port.js\"\n\nexport { isStorefrontOriginAllowed } from \"./storefront-origins.js\"\n\nfunction toStorefrontDto(row: SelectStorefront): StorefrontDto {\n return {\n id: row.id,\n organizationId: row.organizationId,\n name: row.name,\n slug: row.slug,\n hostingKind: row.hostingKind,\n siteId: row.siteId ?? null,\n allowedOrigins: [...row.allowedOrigins],\n methods: row.methods,\n accountPolicy: row.accountPolicy,\n hostOnlyCookies: row.hostOnlyCookies,\n createdAt: row.createdAt.toISOString(),\n updatedAt: row.updatedAt.toISOString(),\n }\n}\n\nfunction toApiKeyDto(row: SelectStorefrontApiKey): StorefrontApiKeyDto {\n return {\n id: row.id,\n storefrontId: row.storefrontId,\n kind: row.kind,\n tokenPreview: row.tokenPreview,\n name: row.name ?? null,\n lastUsedAt: row.lastUsedAt?.toISOString() ?? null,\n revokedAt: row.revokedAt?.toISOString() ?? null,\n createdAt: row.createdAt.toISOString(),\n }\n}\n\nexport function createLocalStorefrontAdapter(options: {\n /**\n * Resolve the KMS-backed credential cipher for a deployment. Called with the\n * request bindings so per-deployment KMS config is honoured; the self-host\n * host passes `createKmsStorefrontCredentialCipher(env)`.\n */\n resolveCipher: (bindings: Record<string, unknown>) => StorefrontCredentialCipher\n}): StorefrontRuntimeProvider {\n const { resolveCipher } = options\n\n /** Load a storefront and prove it belongs to the acting organization. */\n async function requireOwnedStorefront(\n context: StorefrontRequestContext,\n storefrontId: string,\n ): Promise<SelectStorefront> {\n const [row] = await context.db\n .select()\n .from(storefronts)\n .where(\n and(\n eq(storefronts.id, storefrontId),\n eq(storefronts.organizationId, context.organizationId),\n ),\n )\n .limit(1)\n if (!row) throw new StorefrontInputError(\"Storefront was not found.\")\n return row\n }\n\n async function requireCredentialsForEnabledSocialMethods(\n context: StorefrontRequestContext,\n storefrontId: string,\n methods: StorefrontDto[\"methods\"],\n ): Promise<void> {\n const providers = enabledStorefrontSocialProviders(methods)\n if (providers.length === 0) return\n const rows = await context.db\n .select({ provider: storefrontCustomerAuthCredentials.provider })\n .from(storefrontCustomerAuthCredentials)\n .where(eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId))\n const configured = new Set(rows.map((row) => row.provider))\n for (const provider of providers) {\n if (!configured.has(provider)) {\n throw new StorefrontInputError(\n `Customer auth provider ${provider} cannot be enabled without a stored credential.`,\n )\n }\n }\n }\n\n async function persistStorefrontPatch(\n context: StorefrontRequestContext,\n storefrontId: string,\n patch: Partial<InsertStorefront>,\n ): Promise<StorefrontDto> {\n const [row] = await context.db\n .update(storefronts)\n .set({ ...patch, updatedAt: new Date() })\n .where(\n and(\n eq(storefronts.id, storefrontId),\n eq(storefronts.organizationId, context.organizationId),\n ),\n )\n .returning()\n if (!row) throw new StorefrontInputError(\"Storefront was not found.\")\n return toStorefrontDto(row)\n }\n\n async function issueKeyRow(\n context: StorefrontRequestContext,\n storefront: SelectStorefront,\n kind: StorefrontApiKeyDto[\"kind\"],\n name?: string | null,\n ): Promise<IssuedStorefrontApiKeyDto> {\n const generated = await generateStorefrontApiKey(kind)\n const [row] = await context.db\n .insert(storefrontApiKeys)\n .values({\n storefrontId: storefront.id,\n organizationId: storefront.organizationId,\n kind,\n tokenHash: generated.tokenHash,\n tokenPreview: generated.tokenPreview,\n name: name?.trim() || null,\n })\n .returning()\n if (!row) throw new StorefrontInputError(\"Failed to issue storefront access key.\")\n return { ...toApiKeyDto(row), token: generated.token }\n }\n\n return {\n async listStorefronts(context) {\n const rows = await context.db\n .select()\n .from(storefronts)\n .where(eq(storefronts.organizationId, context.organizationId))\n .orderBy(desc(storefronts.createdAt))\n return rows.map(toStorefrontDto)\n },\n\n async getStorefront(context, storefrontId) {\n return toStorefrontDto(await requireOwnedStorefront(context, storefrontId))\n },\n\n async createStorefront(context, input) {\n const methods = normalizeStorefrontCustomerAuthMethods(input.methods)\n if (enabledStorefrontSocialProviders(methods).length > 0) {\n throw new StorefrontInputError(\n \"Add the provider credential before creating a storefront with a social method enabled.\",\n )\n }\n const accountPolicy = normalizeStorefrontCustomerAccountPolicy(\n input.accountPolicy ?? {\n allowedKinds: [\"personal\"],\n personalSignup: \"open\",\n businessOnboarding: \"disabled\",\n },\n )\n const allowedOrigins = normalizeStorefrontAllowedOrigins(input.allowedOrigins)\n if (input.hostingKind === \"external\" && input.siteId) {\n throw new StorefrontInputError(\"External storefronts cannot reference a hosting site.\")\n }\n const slug = input.slug.trim()\n if (!slug) throw new StorefrontInputError(\"Storefront slug is required.\")\n const [row] = await context.db\n .insert(storefronts)\n .values({\n organizationId: context.organizationId,\n name: input.name.trim(),\n slug,\n hostingKind: input.hostingKind,\n siteId: input.hostingKind === \"cloud_site\" ? (input.siteId ?? null) : null,\n methods,\n accountPolicy,\n allowedOrigins,\n hostOnlyCookies: true,\n })\n .returning()\n if (!row) throw new StorefrontInputError(\"Failed to create storefront.\")\n return toStorefrontDto(row)\n },\n\n async updateStorefront(context, storefrontId, patch) {\n await requireOwnedStorefront(context, storefrontId)\n const update: Partial<InsertStorefront> = {}\n if (patch.name !== undefined) update.name = patch.name.trim()\n if (patch.allowedOrigins !== undefined) {\n update.allowedOrigins = normalizeStorefrontAllowedOrigins(patch.allowedOrigins)\n }\n if (patch.accountPolicy !== undefined) {\n update.accountPolicy = normalizeStorefrontCustomerAccountPolicy(patch.accountPolicy)\n }\n if (patch.methods !== undefined) {\n const methods = normalizeStorefrontCustomerAuthMethods(patch.methods)\n await requireCredentialsForEnabledSocialMethods(context, storefrontId, methods)\n update.methods = methods\n }\n return persistStorefrontPatch(context, storefrontId, update)\n },\n\n async deleteStorefront(context, storefrontId) {\n await requireOwnedStorefront(context, storefrontId)\n await context.db\n .delete(storefronts)\n .where(\n and(\n eq(storefronts.id, storefrontId),\n eq(storefronts.organizationId, context.organizationId),\n ),\n )\n },\n\n async setAllowedOrigins(context, storefrontId, origins) {\n await requireOwnedStorefront(context, storefrontId)\n return persistStorefrontPatch(context, storefrontId, {\n allowedOrigins: normalizeStorefrontAllowedOrigins(origins),\n })\n },\n\n async listApiKeys(context, storefrontId) {\n await requireOwnedStorefront(context, storefrontId)\n const rows = await context.db\n .select()\n .from(storefrontApiKeys)\n .where(eq(storefrontApiKeys.storefrontId, storefrontId))\n .orderBy(desc(storefrontApiKeys.createdAt))\n return rows.map(toApiKeyDto)\n },\n\n async issueApiKey(context, storefrontId, kind, name) {\n const storefront = await requireOwnedStorefront(context, storefrontId)\n return issueKeyRow(context, storefront, kind, name)\n },\n\n async rotateApiKey(context, storefrontId, keyId) {\n const storefront = await requireOwnedStorefront(context, storefrontId)\n const [existing] = await context.db\n .select()\n .from(storefrontApiKeys)\n .where(\n and(eq(storefrontApiKeys.id, keyId), eq(storefrontApiKeys.storefrontId, storefrontId)),\n )\n .limit(1)\n if (!existing) throw new StorefrontInputError(\"Storefront access key was not found.\")\n await context.db\n .update(storefrontApiKeys)\n .set({ revokedAt: new Date(), updatedAt: new Date() })\n .where(eq(storefrontApiKeys.id, keyId))\n return issueKeyRow(context, storefront, existing.kind, existing.name)\n },\n\n async revokeApiKey(context, storefrontId, keyId) {\n await requireOwnedStorefront(context, storefrontId)\n await context.db\n .update(storefrontApiKeys)\n .set({ revokedAt: new Date(), updatedAt: new Date() })\n .where(\n and(eq(storefrontApiKeys.id, keyId), eq(storefrontApiKeys.storefrontId, storefrontId)),\n )\n },\n\n async resolveStorefrontByApiKey(\n context: StorefrontResolveContext,\n token: string,\n ): Promise<ResolvedStorefrontApiKey | null> {\n if (classifyStorefrontApiKey(token) === null) return null\n const tokenHash = await hashStorefrontApiKey(token)\n const [key] = await context.db\n .select()\n .from(storefrontApiKeys)\n .where(eq(storefrontApiKeys.tokenHash, tokenHash))\n .limit(1)\n if (!key || key.revokedAt) return null\n const [storefront] = await context.db\n .select()\n .from(storefronts)\n .where(eq(storefronts.id, key.storefrontId))\n .limit(1)\n if (!storefront) return null\n try {\n await context.db\n .update(storefrontApiKeys)\n .set({ lastUsedAt: new Date() })\n .where(eq(storefrontApiKeys.id, key.id))\n } catch {\n // Best-effort usage stamping; never fail the request on it.\n }\n return { storefront: toStorefrontDto(storefront), key: toApiKeyDto(key) }\n },\n\n async updateAccountPolicy(context, storefrontId, policy) {\n await requireOwnedStorefront(context, storefrontId)\n return persistStorefrontPatch(context, storefrontId, {\n accountPolicy: normalizeStorefrontCustomerAccountPolicy(policy),\n })\n },\n\n async updateMethods(context, storefrontId, methods) {\n await requireOwnedStorefront(context, storefrontId)\n const normalized = normalizeStorefrontCustomerAuthMethods(methods)\n await requireCredentialsForEnabledSocialMethods(context, storefrontId, normalized)\n return persistStorefrontPatch(context, storefrontId, { methods: normalized })\n },\n\n async listProviderCredentials(context, storefrontId) {\n await requireOwnedStorefront(context, storefrontId)\n const rows = await context.db\n .select()\n .from(storefrontCustomerAuthCredentials)\n .where(eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId))\n const byProvider = new Map<\n StorefrontCustomerAuthSocialProvider,\n SelectStorefrontCustomerAuthCredential\n >(rows.map((row) => [row.provider, row]))\n return ([\"google\", \"facebook\", \"apple\"] as const).map(\n (provider): StorefrontProviderCredentialStatusDto => {\n const row = byProvider.get(provider)\n return {\n provider,\n configured: Boolean(row),\n updatedAt: row?.updatedAt.toISOString() ?? null,\n }\n },\n )\n },\n\n async putProviderCredential(context, storefrontId, provider, credentials) {\n const storefront = await requireOwnedStorefront(context, storefrontId)\n const bundle = validateStorefrontCredentialBundle(provider, credentials)\n const encrypted = await resolveCipher(context.bindings).encrypt(JSON.stringify(bundle))\n const [existing] = await context.db\n .select({ id: storefrontCustomerAuthCredentials.id })\n .from(storefrontCustomerAuthCredentials)\n .where(\n and(\n eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId),\n eq(storefrontCustomerAuthCredentials.provider, provider),\n ),\n )\n .limit(1)\n if (existing) {\n await context.db\n .update(storefrontCustomerAuthCredentials)\n .set({ encryptedCredentials: encrypted, updatedAt: new Date() })\n .where(eq(storefrontCustomerAuthCredentials.id, existing.id))\n return\n }\n await context.db.insert(storefrontCustomerAuthCredentials).values({\n storefrontId,\n organizationId: storefront.organizationId,\n provider,\n encryptedCredentials: encrypted,\n })\n },\n\n async deleteProviderCredential(context, storefrontId, provider) {\n await requireOwnedStorefront(context, storefrontId)\n await context.db\n .delete(storefrontCustomerAuthCredentials)\n .where(\n and(\n eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId),\n eq(storefrontCustomerAuthCredentials.provider, provider),\n ),\n )\n },\n\n async resolveProviderCredentials(\n context: StorefrontResolveContext,\n storefrontId: string,\n providers: readonly StorefrontCustomerAuthSocialProvider[],\n ): Promise<ResolvedStorefrontProviderCredentials> {\n if (providers.length === 0) return {}\n const rows = await context.db\n .select()\n .from(storefrontCustomerAuthCredentials)\n .where(eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId))\n const cipher = resolveCipher(context.bindings)\n const resolved: ResolvedStorefrontProviderCredentials = {}\n for (const row of rows) {\n if (!providers.includes(row.provider)) continue\n const plaintext = await cipher.decrypt(row.encryptedCredentials)\n resolved[row.provider] = JSON.parse(plaintext) as Record<string, string>\n }\n return resolved\n },\n }\n}\n"]}
1
+ {"version":3,"file":"storefront-local-adapter.js","sourceRoot":"","sources":["../src/storefront-local-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAML,iBAAiB,EACjB,iCAAiC,EACjC,WAAW,GACZ,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAEL,kCAAkC,GACnC,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EACL,gCAAgC,EAChC,yBAAyB,EACzB,iCAAiC,EACjC,wCAAwC,EACxC,sCAAsC,EACtC,oBAAoB,GACrB,MAAM,yBAAyB,CAAA;AAahC,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAEnE,SAAS,eAAe,CAAC,GAAqB;IAC5C,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,cAAc,EAAE,GAAG,CAAC,cAAc;QAClC,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI;QAC1B,cAAc,EAAE,CAAC,GAAG,GAAG,CAAC,cAAc,CAAC;QACvC,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,eAAe,EAAE,GAAG,CAAC,eAAe;QACpC,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE;QACtC,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE;KACvC,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAAC,GAA2B;IAC9C,OAAO;QACL,EAAE,EA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AE,CAAC,iCAAiC,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAA;YAC1E,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;YAC9C,MAAM,QAAQ,GAA0C,EAAE,CAAA;YAC1D,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;oBAAE,SAAQ;gBAC/C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;gBAChE,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAA2B,CAAA;YAC1E,CAAC;YACD,OAAO,QAAQ,CAAA;QACjB,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["/**\n * Local storefront runtime provider — backs {@link storefrontRuntimePort} with\n * the deployment's own runtime DB (self-host). Mirrors the team-management\n * local adapter: every operator write is bounded to `context.organizationId`,\n * and request-time resolution (`resolveStorefrontByApiKey`) is org-agnostic.\n */\nimport {\n type InsertStorefront,\n type SelectStorefront,\n type SelectStorefrontApiKey,\n type SelectStorefrontCustomerAuthCredential,\n type StorefrontCustomerAuthSocialProvider,\n storefrontApiKeys,\n storefrontCustomerAuthCredentials,\n storefronts,\n} from \"@voyant-travel/db/schema/iam\"\nimport { and, desc, eq, sql } from \"drizzle-orm\"\n\nimport {\n type StorefrontCredentialCipher,\n validateStorefrontCredentialBundle,\n} from \"./storefront-credentials.js\"\nimport {\n classifyStorefrontApiKey,\n generateStorefrontApiKey,\n hashStorefrontApiKey,\n} from \"./storefront-keys.js\"\nimport {\n enabledStorefrontSocialProviders,\n isStorefrontOriginAllowed,\n normalizeStorefrontAllowedOrigins,\n normalizeStorefrontCustomerAccountPolicy,\n normalizeStorefrontCustomerAuthMethods,\n StorefrontInputError,\n} from \"./storefront-origins.js\"\nimport type {\n IssuedStorefrontApiKeyDto,\n ResolvedStorefrontApiKey,\n ResolvedStorefrontProviderCredentials,\n StorefrontApiKeyDto,\n StorefrontDto,\n StorefrontProviderCredentialStatusDto,\n StorefrontRequestContext,\n StorefrontResolveContext,\n StorefrontRuntimeProvider,\n} from \"./storefront-runtime-port.js\"\n\nexport { isStorefrontOriginAllowed } from \"./storefront-origins.js\"\n\nfunction toStorefrontDto(row: SelectStorefront): StorefrontDto {\n return {\n id: row.id,\n organizationId: row.organizationId,\n name: row.name,\n slug: row.slug,\n hostingKind: row.hostingKind,\n siteId: row.siteId ?? null,\n allowedOrigins: [...row.allowedOrigins],\n methods: row.methods,\n accountPolicy: row.accountPolicy,\n hostOnlyCookies: row.hostOnlyCookies,\n createdAt: row.createdAt.toISOString(),\n updatedAt: row.updatedAt.toISOString(),\n }\n}\n\nfunction toApiKeyDto(row: SelectStorefrontApiKey): StorefrontApiKeyDto {\n return {\n id: row.id,\n storefrontId: row.storefrontId,\n kind: row.kind,\n tokenPreview: row.tokenPreview,\n name: row.name ?? null,\n lastUsedAt: row.lastUsedAt?.toISOString() ?? null,\n revokedAt: row.revokedAt?.toISOString() ?? null,\n createdAt: row.createdAt.toISOString(),\n }\n}\n\nexport function createLocalStorefrontAdapter(options: {\n /**\n * Resolve the KMS-backed credential cipher for a deployment. Called with the\n * request bindings so per-deployment KMS config is honoured; the self-host\n * host passes `createKmsStorefrontCredentialCipher(env)`.\n */\n resolveCipher: (bindings: Record<string, unknown>) => StorefrontCredentialCipher\n}): StorefrontRuntimeProvider {\n const { resolveCipher } = options\n\n /** Load a storefront and prove it belongs to the acting organization. */\n async function requireOwnedStorefront(\n context: StorefrontRequestContext,\n storefrontId: string,\n ): Promise<SelectStorefront> {\n const [row] = await context.db\n .select()\n .from(storefronts)\n .where(\n and(\n eq(storefronts.id, storefrontId),\n eq(storefronts.organizationId, context.organizationId),\n ),\n )\n .limit(1)\n if (!row) throw new StorefrontInputError(\"Storefront was not found.\")\n return row\n }\n\n async function requireCredentialsForEnabledSocialMethods(\n context: StorefrontRequestContext,\n storefrontId: string,\n methods: StorefrontDto[\"methods\"],\n ): Promise<void> {\n const providers = enabledStorefrontSocialProviders(methods)\n if (providers.length === 0) return\n const rows = await context.db\n .select({ provider: storefrontCustomerAuthCredentials.provider })\n .from(storefrontCustomerAuthCredentials)\n .where(eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId))\n const configured = new Set(rows.map((row) => row.provider))\n for (const provider of providers) {\n if (!configured.has(provider)) {\n throw new StorefrontInputError(\n `Customer auth provider ${provider} cannot be enabled without a stored credential.`,\n )\n }\n }\n }\n\n async function persistStorefrontPatch(\n context: StorefrontRequestContext,\n storefrontId: string,\n patch: Partial<InsertStorefront>,\n ): Promise<StorefrontDto> {\n const [row] = await context.db\n .update(storefronts)\n .set({ ...patch, updatedAt: new Date() })\n .where(\n and(\n eq(storefronts.id, storefrontId),\n eq(storefronts.organizationId, context.organizationId),\n ),\n )\n .returning()\n if (!row) throw new StorefrontInputError(\"Storefront was not found.\")\n return toStorefrontDto(row)\n }\n\n async function issueKeyRow(\n context: StorefrontRequestContext,\n storefront: SelectStorefront,\n kind: StorefrontApiKeyDto[\"kind\"],\n name?: string | null,\n ): Promise<IssuedStorefrontApiKeyDto> {\n const generated = await generateStorefrontApiKey(kind)\n const [row] = await context.db\n .insert(storefrontApiKeys)\n .values({\n storefrontId: storefront.id,\n organizationId: storefront.organizationId,\n kind,\n tokenHash: generated.tokenHash,\n tokenPreview: generated.tokenPreview,\n name: name?.trim() || null,\n })\n .returning()\n if (!row) throw new StorefrontInputError(\"Failed to issue storefront access key.\")\n return { ...toApiKeyDto(row), token: generated.token }\n }\n\n return {\n async listStorefronts(context) {\n const rows = await context.db\n .select()\n .from(storefronts)\n .where(eq(storefronts.organizationId, context.organizationId))\n .orderBy(desc(storefronts.createdAt))\n return rows.map(toStorefrontDto)\n },\n\n async getStorefront(context, storefrontId) {\n return toStorefrontDto(await requireOwnedStorefront(context, storefrontId))\n },\n\n async createStorefront(context, input) {\n const methods = normalizeStorefrontCustomerAuthMethods(input.methods)\n if (enabledStorefrontSocialProviders(methods).length > 0) {\n throw new StorefrontInputError(\n \"Add the provider credential before creating a storefront with a social method enabled.\",\n )\n }\n const accountPolicy = normalizeStorefrontCustomerAccountPolicy(\n input.accountPolicy ?? {\n allowedKinds: [\"personal\"],\n personalSignup: \"open\",\n businessOnboarding: \"disabled\",\n },\n )\n const allowedOrigins = normalizeStorefrontAllowedOrigins(input.allowedOrigins)\n if (input.hostingKind === \"external\" && input.siteId) {\n throw new StorefrontInputError(\"External storefronts cannot reference a hosting site.\")\n }\n const slug = input.slug.trim()\n if (!slug) throw new StorefrontInputError(\"Storefront slug is required.\")\n const [row] = await context.db\n .insert(storefronts)\n .values({\n organizationId: context.organizationId,\n name: input.name.trim(),\n slug,\n hostingKind: input.hostingKind,\n siteId: input.hostingKind === \"cloud_site\" ? (input.siteId ?? null) : null,\n methods,\n accountPolicy,\n allowedOrigins,\n hostOnlyCookies: true,\n })\n .returning()\n if (!row) throw new StorefrontInputError(\"Failed to create storefront.\")\n return toStorefrontDto(row)\n },\n\n async updateStorefront(context, storefrontId, patch) {\n await requireOwnedStorefront(context, storefrontId)\n const update: Partial<InsertStorefront> = {}\n if (patch.name !== undefined) update.name = patch.name.trim()\n if (patch.allowedOrigins !== undefined) {\n update.allowedOrigins = normalizeStorefrontAllowedOrigins(patch.allowedOrigins)\n }\n if (patch.accountPolicy !== undefined) {\n update.accountPolicy = normalizeStorefrontCustomerAccountPolicy(patch.accountPolicy)\n }\n if (patch.methods !== undefined) {\n const methods = normalizeStorefrontCustomerAuthMethods(patch.methods)\n await requireCredentialsForEnabledSocialMethods(context, storefrontId, methods)\n update.methods = methods\n }\n return persistStorefrontPatch(context, storefrontId, update)\n },\n\n async deleteStorefront(context, storefrontId) {\n await requireOwnedStorefront(context, storefrontId)\n await context.db\n .delete(storefronts)\n .where(\n and(\n eq(storefronts.id, storefrontId),\n eq(storefronts.organizationId, context.organizationId),\n ),\n )\n },\n\n async setAllowedOrigins(context, storefrontId, origins) {\n await requireOwnedStorefront(context, storefrontId)\n return persistStorefrontPatch(context, storefrontId, {\n allowedOrigins: normalizeStorefrontAllowedOrigins(origins),\n })\n },\n\n async listApiKeys(context, storefrontId) {\n await requireOwnedStorefront(context, storefrontId)\n const rows = await context.db\n .select()\n .from(storefrontApiKeys)\n .where(eq(storefrontApiKeys.storefrontId, storefrontId))\n .orderBy(desc(storefrontApiKeys.createdAt))\n return rows.map(toApiKeyDto)\n },\n\n async issueApiKey(context, storefrontId, kind, name) {\n const storefront = await requireOwnedStorefront(context, storefrontId)\n return issueKeyRow(context, storefront, kind, name)\n },\n\n async rotateApiKey(context, storefrontId, keyId) {\n const storefront = await requireOwnedStorefront(context, storefrontId)\n const [existing] = await context.db\n .select()\n .from(storefrontApiKeys)\n .where(\n and(eq(storefrontApiKeys.id, keyId), eq(storefrontApiKeys.storefrontId, storefrontId)),\n )\n .limit(1)\n if (!existing) throw new StorefrontInputError(\"Storefront access key was not found.\")\n await context.db\n .update(storefrontApiKeys)\n .set({ revokedAt: new Date(), updatedAt: new Date() })\n .where(eq(storefrontApiKeys.id, keyId))\n return issueKeyRow(context, storefront, existing.kind, existing.name)\n },\n\n async revokeApiKey(context, storefrontId, keyId) {\n await requireOwnedStorefront(context, storefrontId)\n await context.db\n .update(storefrontApiKeys)\n .set({ revokedAt: new Date(), updatedAt: new Date() })\n .where(\n and(eq(storefrontApiKeys.id, keyId), eq(storefrontApiKeys.storefrontId, storefrontId)),\n )\n },\n\n async resolveStorefrontByApiKey(\n context: StorefrontResolveContext,\n token: string,\n ): Promise<ResolvedStorefrontApiKey | null> {\n if (classifyStorefrontApiKey(token) === null) return null\n const tokenHash = await hashStorefrontApiKey(token)\n const [key] = await context.db\n .select()\n .from(storefrontApiKeys)\n .where(eq(storefrontApiKeys.tokenHash, tokenHash))\n .limit(1)\n if (!key || key.revokedAt) return null\n const [storefront] = await context.db\n .select()\n .from(storefronts)\n .where(eq(storefronts.id, key.storefrontId))\n .limit(1)\n if (!storefront) return null\n try {\n await context.db\n .update(storefrontApiKeys)\n .set({ lastUsedAt: new Date() })\n .where(eq(storefrontApiKeys.id, key.id))\n } catch {\n // Best-effort usage stamping; never fail the request on it.\n }\n return { storefront: toStorefrontDto(storefront), key: toApiKeyDto(key) }\n },\n\n async resolveStorefrontByOrigin(\n context: StorefrontResolveContext,\n origin: string,\n ): Promise<StorefrontDto | null> {\n // Preflight authorization is keyless, so it cannot select a single\n // storefront up front. Exact-origin entries are filtered in SQL via array\n // containment; wildcard (`https://*.host`) declarations are matched in\n // memory over the small self-host storefront set. First match wins — a\n // browser origin resolves to at most one storefront in practice.\n const [exactMatch] = await context.db\n .select()\n .from(storefronts)\n // agent-quality: raw-sql reviewed -- Postgres text[] containment authorizes the exact declared origin without loading every row.\n .where(sql`${storefronts.allowedOrigins} @> ARRAY[${origin}]::text[]`)\n .limit(1)\n if (exactMatch) return toStorefrontDto(exactMatch)\n\n const wildcardCandidates = await context.db\n .select()\n .from(storefronts)\n // agent-quality: raw-sql reviewed -- Only rows carrying a wildcard origin declaration are considered for the in-memory match.\n .where(\n sql`EXISTS (SELECT 1 FROM unnest(${storefronts.allowedOrigins}) AS o WHERE o LIKE 'https://*.%')`,\n )\n for (const row of wildcardCandidates) {\n if (isStorefrontOriginAllowed(origin, row.allowedOrigins)) return toStorefrontDto(row)\n }\n return null\n },\n\n async updateAccountPolicy(context, storefrontId, policy) {\n await requireOwnedStorefront(context, storefrontId)\n return persistStorefrontPatch(context, storefrontId, {\n accountPolicy: normalizeStorefrontCustomerAccountPolicy(policy),\n })\n },\n\n async updateMethods(context, storefrontId, methods) {\n await requireOwnedStorefront(context, storefrontId)\n const normalized = normalizeStorefrontCustomerAuthMethods(methods)\n await requireCredentialsForEnabledSocialMethods(context, storefrontId, normalized)\n return persistStorefrontPatch(context, storefrontId, { methods: normalized })\n },\n\n async listProviderCredentials(context, storefrontId) {\n await requireOwnedStorefront(context, storefrontId)\n const rows = await context.db\n .select()\n .from(storefrontCustomerAuthCredentials)\n .where(eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId))\n const byProvider = new Map<\n StorefrontCustomerAuthSocialProvider,\n SelectStorefrontCustomerAuthCredential\n >(rows.map((row) => [row.provider, row]))\n return ([\"google\", \"facebook\", \"apple\"] as const).map(\n (provider): StorefrontProviderCredentialStatusDto => {\n const row = byProvider.get(provider)\n return {\n provider,\n configured: Boolean(row),\n updatedAt: row?.updatedAt.toISOString() ?? null,\n }\n },\n )\n },\n\n async putProviderCredential(context, storefrontId, provider, credentials) {\n const storefront = await requireOwnedStorefront(context, storefrontId)\n const bundle = validateStorefrontCredentialBundle(provider, credentials)\n const encrypted = await resolveCipher(context.bindings).encrypt(JSON.stringify(bundle))\n const [existing] = await context.db\n .select({ id: storefrontCustomerAuthCredentials.id })\n .from(storefrontCustomerAuthCredentials)\n .where(\n and(\n eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId),\n eq(storefrontCustomerAuthCredentials.provider, provider),\n ),\n )\n .limit(1)\n if (existing) {\n await context.db\n .update(storefrontCustomerAuthCredentials)\n .set({ encryptedCredentials: encrypted, updatedAt: new Date() })\n .where(eq(storefrontCustomerAuthCredentials.id, existing.id))\n return\n }\n await context.db.insert(storefrontCustomerAuthCredentials).values({\n storefrontId,\n organizationId: storefront.organizationId,\n provider,\n encryptedCredentials: encrypted,\n })\n },\n\n async deleteProviderCredential(context, storefrontId, provider) {\n await requireOwnedStorefront(context, storefrontId)\n await context.db\n .delete(storefrontCustomerAuthCredentials)\n .where(\n and(\n eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId),\n eq(storefrontCustomerAuthCredentials.provider, provider),\n ),\n )\n },\n\n async resolveProviderCredentials(\n context: StorefrontResolveContext,\n storefrontId: string,\n providers: readonly StorefrontCustomerAuthSocialProvider[],\n ): Promise<ResolvedStorefrontProviderCredentials> {\n if (providers.length === 0) return {}\n const rows = await context.db\n .select()\n .from(storefrontCustomerAuthCredentials)\n .where(eq(storefrontCustomerAuthCredentials.storefrontId, storefrontId))\n const cipher = resolveCipher(context.bindings)\n const resolved: ResolvedStorefrontProviderCredentials = {}\n for (const row of rows) {\n if (!providers.includes(row.provider)) continue\n const plaintext = await cipher.decrypt(row.encryptedCredentials)\n resolved[row.provider] = JSON.parse(plaintext) as Record<string, string>\n }\n return resolved\n },\n }\n}\n"]}
@@ -82,6 +82,12 @@ export interface StorefrontRuntimeProvider {
82
82
  rotateApiKey(context: StorefrontRequestContext, storefrontId: string, keyId: string): Promise<IssuedStorefrontApiKeyDto>;
83
83
  revokeApiKey(context: StorefrontRequestContext, storefrontId: string, keyId: string): Promise<void>;
84
84
  resolveStorefrontByApiKey(context: StorefrontResolveContext, token: string): Promise<ResolvedStorefrontApiKey | null>;
85
+ /**
86
+ * Resolve a storefront that declares `origin` as an allowed browser origin
87
+ * (exact or `https://*.host` wildcard). Used to authorize keyless CORS
88
+ * preflight requests, which carry an `Origin` but no storefront key.
89
+ */
90
+ resolveStorefrontByOrigin(context: StorefrontResolveContext, origin: string): Promise<StorefrontDto | null>;
85
91
  updateAccountPolicy(context: StorefrontRequestContext, storefrontId: string, policy: StorefrontCustomerAccountPolicy): Promise<StorefrontDto>;
86
92
  updateMethods(context: StorefrontRequestContext, storefrontId: string, methods: StorefrontCustomerAuthMethods): Promise<StorefrontDto>;
87
93
  listProviderCredentials(context: StorefrontRequestContext, storefrontId: string): Promise<StorefrontProviderCredentialStatusDto[]>;
@@ -11,6 +11,7 @@ const REQUIRED_METHODS = [
11
11
  "rotateApiKey",
12
12
  "revokeApiKey",
13
13
  "resolveStorefrontByApiKey",
14
+ "resolveStorefrontByOrigin",
14
15
  "updateAccountPolicy",
15
16
  "updateMethods",
16
17
  "listProviderCredentials",
@@ -1 +1 @@
1
- {"version":3,"file":"storefront-runtime-port.js","sourceRoot":"","sources":["../src/storefront-runtime-port.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AA4KxD,MAAM,gBAAgB,GAAG;IACvB,iBAAiB;IACjB,eAAe;IACf,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,aAAa;IACb,aAAa;IACb,cAAc;IACd,cAAc;IACd,2BAA2B;IAC3B,qBAAqB;IACrB,eAAe;IACf,yBAAyB;IACzB,uBAAuB;IACvB,0BAA0B;IAC1B,4BAA4B;CACpB,CAAA;AAEV,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAA4B;IACzE,EAAE,EAAE,yBAAyB;IAC7B,IAAI,CAAC,QAAQ;QACX,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;QACxE,CAAC;QACD,MAAM,IAAI,GAAG,QAA8C,CAAA;QAC3D,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;YACtC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CAAC,mDAAmD,MAAM,KAAK,CAAC,CAAA;YACjF,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { definePort } from \"@voyant-travel/core/project\"\nimport type {\n StorefrontApiKeyKind,\n StorefrontCustomerAccountPolicy,\n StorefrontCustomerAuthMethods,\n StorefrontCustomerAuthSocialProvider,\n StorefrontHostingKind,\n} from \"@voyant-travel/db/schema/iam\"\nimport type { VoyantDb } from \"@voyant-travel/hono\"\n\nexport interface StorefrontDto {\n id: string\n organizationId: string\n name: string\n slug: string\n hostingKind: StorefrontHostingKind\n siteId: string | null\n allowedOrigins: string[]\n methods: StorefrontCustomerAuthMethods\n accountPolicy: StorefrontCustomerAccountPolicy\n hostOnlyCookies: boolean\n createdAt: string\n updatedAt: string\n}\n\nexport interface StorefrontApiKeyDto {\n id: string\n storefrontId: string\n kind: StorefrontApiKeyKind\n tokenPreview: string\n name: string | null\n lastUsedAt: string | null\n revokedAt: string | null\n createdAt: string\n}\n\n/** Issuance/rotation result: the plaintext token is present exactly once. */\nexport interface IssuedStorefrontApiKeyDto extends StorefrontApiKeyDto {\n token: string\n}\n\nexport interface StorefrontProviderCredentialStatusDto {\n provider: StorefrontCustomerAuthSocialProvider\n configured: boolean\n updatedAt: string | null\n}\n\nexport interface CreateStorefrontInput {\n name: string\n slug: string\n hostingKind: StorefrontHostingKind\n siteId?: string | null\n allowedOrigins: readonly string[]\n methods: StorefrontCustomerAuthMethods\n accountPolicy?: StorefrontCustomerAccountPolicy\n}\n\nexport interface UpdateStorefrontInput {\n name?: string\n allowedOrigins?: readonly string[]\n methods?: StorefrontCustomerAuthMethods\n accountPolicy?: StorefrontCustomerAccountPolicy\n}\n\n/** Operator-scoped admin context: every write is bounded to one organization. */\nexport interface StorefrontRequestContext {\n bindings: Record<string, unknown>\n db: VoyantDb\n organizationId: string\n}\n\n/**\n * Request-time resolve context. Customer-auth resolution runs without an\n * operator user, so no organization scope is present — a token selects its\n * storefront globally, then the declared-origin check authorizes it.\n */\nexport interface StorefrontResolveContext {\n bindings: Record<string, unknown>\n db: VoyantDb\n}\n\n/** A token resolved to its storefront + the key row it authenticated with. */\nexport interface ResolvedStorefrontApiKey {\n storefront: StorefrontDto\n key: StorefrontApiKeyDto\n}\n\n/** Decrypted provider secrets, keyed by provider, for enabled social methods. */\nexport type ResolvedStorefrontProviderCredentials = Partial<\n Record<StorefrontCustomerAuthSocialProvider, Record<string, string>>\n>\n\nexport interface StorefrontRuntimeProvider {\n // storefront CRUD ------------------------------------------------------\n listStorefronts(context: StorefrontRequestContext): Promise<StorefrontDto[]>\n getStorefront(context: StorefrontRequestContext, storefrontId: string): Promise<StorefrontDto>\n createStorefront(\n context: StorefrontRequestContext,\n input: CreateStorefrontInput,\n ): Promise<StorefrontDto>\n updateStorefront(\n context: StorefrontRequestContext,\n storefrontId: string,\n patch: UpdateStorefrontInput,\n ): Promise<StorefrontDto>\n deleteStorefront(context: StorefrontRequestContext, storefrontId: string): Promise<void>\n // allowed origins ------------------------------------------------------\n setAllowedOrigins(\n context: StorefrontRequestContext,\n storefrontId: string,\n origins: readonly string[],\n ): Promise<StorefrontDto>\n // access keys ----------------------------------------------------------\n listApiKeys(\n context: StorefrontRequestContext,\n storefrontId: string,\n ): Promise<StorefrontApiKeyDto[]>\n issueApiKey(\n context: StorefrontRequestContext,\n storefrontId: string,\n kind: StorefrontApiKeyKind,\n name?: string | null,\n ): Promise<IssuedStorefrontApiKeyDto>\n rotateApiKey(\n context: StorefrontRequestContext,\n storefrontId: string,\n keyId: string,\n ): Promise<IssuedStorefrontApiKeyDto>\n revokeApiKey(\n context: StorefrontRequestContext,\n storefrontId: string,\n keyId: string,\n ): Promise<void>\n resolveStorefrontByApiKey(\n context: StorefrontResolveContext,\n token: string,\n ): Promise<ResolvedStorefrontApiKey | null>\n // account policy + methods --------------------------------------------\n updateAccountPolicy(\n context: StorefrontRequestContext,\n storefrontId: string,\n policy: StorefrontCustomerAccountPolicy,\n ): Promise<StorefrontDto>\n updateMethods(\n context: StorefrontRequestContext,\n storefrontId: string,\n methods: StorefrontCustomerAuthMethods,\n ): Promise<StorefrontDto>\n // provider credentials -------------------------------------------------\n listProviderCredentials(\n context: StorefrontRequestContext,\n storefrontId: string,\n ): Promise<StorefrontProviderCredentialStatusDto[]>\n putProviderCredential(\n context: StorefrontRequestContext,\n storefrontId: string,\n provider: StorefrontCustomerAuthSocialProvider,\n credentials: Record<string, unknown>,\n ): Promise<void>\n deleteProviderCredential(\n context: StorefrontRequestContext,\n storefrontId: string,\n provider: StorefrontCustomerAuthSocialProvider,\n ): Promise<void>\n /** Decrypt the stored secrets for the given providers (request-time seam). */\n resolveProviderCredentials(\n context: StorefrontResolveContext,\n storefrontId: string,\n providers: readonly StorefrontCustomerAuthSocialProvider[],\n ): Promise<ResolvedStorefrontProviderCredentials>\n}\n\nconst REQUIRED_METHODS = [\n \"listStorefronts\",\n \"getStorefront\",\n \"createStorefront\",\n \"updateStorefront\",\n \"deleteStorefront\",\n \"setAllowedOrigins\",\n \"listApiKeys\",\n \"issueApiKey\",\n \"rotateApiKey\",\n \"revokeApiKey\",\n \"resolveStorefrontByApiKey\",\n \"updateAccountPolicy\",\n \"updateMethods\",\n \"listProviderCredentials\",\n \"putProviderCredential\",\n \"deleteProviderCredential\",\n \"resolveProviderCredentials\",\n] as const\n\nexport const storefrontRuntimePort = definePort<StorefrontRuntimeProvider>({\n id: \"auth.storefront-runtime\",\n test(provider) {\n if (provider === null || typeof provider !== \"object\") {\n throw new Error(\"auth.storefront-runtime provider must be an object.\")\n }\n const impl = provider as unknown as Record<string, unknown>\n for (const method of REQUIRED_METHODS) {\n if (typeof impl[method] !== \"function\") {\n throw new Error(`auth.storefront-runtime provider must implement ${method}().`)\n }\n }\n },\n})\n"]}
1
+ {"version":3,"file":"storefront-runtime-port.js","sourceRoot":"","sources":["../src/storefront-runtime-port.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAqLxD,MAAM,gBAAgB,GAAG;IACvB,iBAAiB;IACjB,eAAe;IACf,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,aAAa;IACb,aAAa;IACb,cAAc;IACd,cAAc;IACd,2BAA2B;IAC3B,2BAA2B;IAC3B,qBAAqB;IACrB,eAAe;IACf,yBAAyB;IACzB,uBAAuB;IACvB,0BAA0B;IAC1B,4BAA4B;CACpB,CAAA;AAEV,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAA4B;IACzE,EAAE,EAAE,yBAAyB;IAC7B,IAAI,CAAC,QAAQ;QACX,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAA;QACxE,CAAC;QACD,MAAM,IAAI,GAAG,QAA8C,CAAA;QAC3D,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;YACtC,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;gBACvC,MAAM,IAAI,KAAK,CAAC,mDAAmD,MAAM,KAAK,CAAC,CAAA;YACjF,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { definePort } from \"@voyant-travel/core/project\"\nimport type {\n StorefrontApiKeyKind,\n StorefrontCustomerAccountPolicy,\n StorefrontCustomerAuthMethods,\n StorefrontCustomerAuthSocialProvider,\n StorefrontHostingKind,\n} from \"@voyant-travel/db/schema/iam\"\nimport type { VoyantDb } from \"@voyant-travel/hono\"\n\nexport interface StorefrontDto {\n id: string\n organizationId: string\n name: string\n slug: string\n hostingKind: StorefrontHostingKind\n siteId: string | null\n allowedOrigins: string[]\n methods: StorefrontCustomerAuthMethods\n accountPolicy: StorefrontCustomerAccountPolicy\n hostOnlyCookies: boolean\n createdAt: string\n updatedAt: string\n}\n\nexport interface StorefrontApiKeyDto {\n id: string\n storefrontId: string\n kind: StorefrontApiKeyKind\n tokenPreview: string\n name: string | null\n lastUsedAt: string | null\n revokedAt: string | null\n createdAt: string\n}\n\n/** Issuance/rotation result: the plaintext token is present exactly once. */\nexport interface IssuedStorefrontApiKeyDto extends StorefrontApiKeyDto {\n token: string\n}\n\nexport interface StorefrontProviderCredentialStatusDto {\n provider: StorefrontCustomerAuthSocialProvider\n configured: boolean\n updatedAt: string | null\n}\n\nexport interface CreateStorefrontInput {\n name: string\n slug: string\n hostingKind: StorefrontHostingKind\n siteId?: string | null\n allowedOrigins: readonly string[]\n methods: StorefrontCustomerAuthMethods\n accountPolicy?: StorefrontCustomerAccountPolicy\n}\n\nexport interface UpdateStorefrontInput {\n name?: string\n allowedOrigins?: readonly string[]\n methods?: StorefrontCustomerAuthMethods\n accountPolicy?: StorefrontCustomerAccountPolicy\n}\n\n/** Operator-scoped admin context: every write is bounded to one organization. */\nexport interface StorefrontRequestContext {\n bindings: Record<string, unknown>\n db: VoyantDb\n organizationId: string\n}\n\n/**\n * Request-time resolve context. Customer-auth resolution runs without an\n * operator user, so no organization scope is present — a token selects its\n * storefront globally, then the declared-origin check authorizes it.\n */\nexport interface StorefrontResolveContext {\n bindings: Record<string, unknown>\n db: VoyantDb\n}\n\n/** A token resolved to its storefront + the key row it authenticated with. */\nexport interface ResolvedStorefrontApiKey {\n storefront: StorefrontDto\n key: StorefrontApiKeyDto\n}\n\n/** Decrypted provider secrets, keyed by provider, for enabled social methods. */\nexport type ResolvedStorefrontProviderCredentials = Partial<\n Record<StorefrontCustomerAuthSocialProvider, Record<string, string>>\n>\n\nexport interface StorefrontRuntimeProvider {\n // storefront CRUD ------------------------------------------------------\n listStorefronts(context: StorefrontRequestContext): Promise<StorefrontDto[]>\n getStorefront(context: StorefrontRequestContext, storefrontId: string): Promise<StorefrontDto>\n createStorefront(\n context: StorefrontRequestContext,\n input: CreateStorefrontInput,\n ): Promise<StorefrontDto>\n updateStorefront(\n context: StorefrontRequestContext,\n storefrontId: string,\n patch: UpdateStorefrontInput,\n ): Promise<StorefrontDto>\n deleteStorefront(context: StorefrontRequestContext, storefrontId: string): Promise<void>\n // allowed origins ------------------------------------------------------\n setAllowedOrigins(\n context: StorefrontRequestContext,\n storefrontId: string,\n origins: readonly string[],\n ): Promise<StorefrontDto>\n // access keys ----------------------------------------------------------\n listApiKeys(\n context: StorefrontRequestContext,\n storefrontId: string,\n ): Promise<StorefrontApiKeyDto[]>\n issueApiKey(\n context: StorefrontRequestContext,\n storefrontId: string,\n kind: StorefrontApiKeyKind,\n name?: string | null,\n ): Promise<IssuedStorefrontApiKeyDto>\n rotateApiKey(\n context: StorefrontRequestContext,\n storefrontId: string,\n keyId: string,\n ): Promise<IssuedStorefrontApiKeyDto>\n revokeApiKey(\n context: StorefrontRequestContext,\n storefrontId: string,\n keyId: string,\n ): Promise<void>\n resolveStorefrontByApiKey(\n context: StorefrontResolveContext,\n token: string,\n ): Promise<ResolvedStorefrontApiKey | null>\n /**\n * Resolve a storefront that declares `origin` as an allowed browser origin\n * (exact or `https://*.host` wildcard). Used to authorize keyless CORS\n * preflight requests, which carry an `Origin` but no storefront key.\n */\n resolveStorefrontByOrigin(\n context: StorefrontResolveContext,\n origin: string,\n ): Promise<StorefrontDto | null>\n // account policy + methods --------------------------------------------\n updateAccountPolicy(\n context: StorefrontRequestContext,\n storefrontId: string,\n policy: StorefrontCustomerAccountPolicy,\n ): Promise<StorefrontDto>\n updateMethods(\n context: StorefrontRequestContext,\n storefrontId: string,\n methods: StorefrontCustomerAuthMethods,\n ): Promise<StorefrontDto>\n // provider credentials -------------------------------------------------\n listProviderCredentials(\n context: StorefrontRequestContext,\n storefrontId: string,\n ): Promise<StorefrontProviderCredentialStatusDto[]>\n putProviderCredential(\n context: StorefrontRequestContext,\n storefrontId: string,\n provider: StorefrontCustomerAuthSocialProvider,\n credentials: Record<string, unknown>,\n ): Promise<void>\n deleteProviderCredential(\n context: StorefrontRequestContext,\n storefrontId: string,\n provider: StorefrontCustomerAuthSocialProvider,\n ): Promise<void>\n /** Decrypt the stored secrets for the given providers (request-time seam). */\n resolveProviderCredentials(\n context: StorefrontResolveContext,\n storefrontId: string,\n providers: readonly StorefrontCustomerAuthSocialProvider[],\n ): Promise<ResolvedStorefrontProviderCredentials>\n}\n\nconst REQUIRED_METHODS = [\n \"listStorefronts\",\n \"getStorefront\",\n \"createStorefront\",\n \"updateStorefront\",\n \"deleteStorefront\",\n \"setAllowedOrigins\",\n \"listApiKeys\",\n \"issueApiKey\",\n \"rotateApiKey\",\n \"revokeApiKey\",\n \"resolveStorefrontByApiKey\",\n \"resolveStorefrontByOrigin\",\n \"updateAccountPolicy\",\n \"updateMethods\",\n \"listProviderCredentials\",\n \"putProviderCredential\",\n \"deleteProviderCredential\",\n \"resolveProviderCredentials\",\n] as const\n\nexport const storefrontRuntimePort = definePort<StorefrontRuntimeProvider>({\n id: \"auth.storefront-runtime\",\n test(provider) {\n if (provider === null || typeof provider !== \"object\") {\n throw new Error(\"auth.storefront-runtime provider must be an object.\")\n }\n const impl = provider as unknown as Record<string, unknown>\n for (const method of REQUIRED_METHODS) {\n if (typeof impl[method] !== \"function\") {\n throw new Error(`auth.storefront-runtime provider must implement ${method}().`)\n }\n }\n },\n})\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyant-travel/auth",
3
- "version": "0.140.2",
3
+ "version": "0.141.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",