@yielded/auth 0.1.0-beta.2 → 0.1.0-beta.3

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.
Files changed (32) hide show
  1. package/dist/DrizzleD1.d.mts +12 -12
  2. package/dist/DrizzleMysql2.d.mts +2 -2
  3. package/dist/DrizzlePglite.d.mts +2 -2
  4. package/dist/DrizzlePostgres.d.mts +14 -14
  5. package/dist/DrizzleSqliteBun.d.mts +8 -8
  6. package/dist/DrizzleSqliteNode.d.mts +2 -2
  7. package/dist/DrizzleSqliteWasm.d.mts +14 -14
  8. package/dist/GitHub.d.mts +2 -2
  9. package/dist/GitHub.mjs +2 -2
  10. package/dist/OpenIdClientConnected.d.mts +1 -1
  11. package/dist/drizzle/d1-oauth.d.mts +4 -4
  12. package/dist/oauth/github/protocol.d.mts +7 -3
  13. package/dist/oauth/github/protocol.mjs +22 -9
  14. package/dist/oauth/github/protocol.mjs.map +1 -1
  15. package/dist/oauth/openid-client/compatibility.d.mts +22 -1
  16. package/dist/oauth/openid-client/compatibility.mjs +6 -1
  17. package/dist/oauth/openid-client/compatibility.mjs.map +1 -1
  18. package/dist/oauth/openid-client/configuration.mjs +2 -0
  19. package/dist/oauth/openid-client/configuration.mjs.map +1 -1
  20. package/dist/oauth/openid-client/connected/protocol.d.mts +1 -1
  21. package/dist/oauth/openid-client/models.d.mts +3 -0
  22. package/dist/oauth/openid-client/models.mjs.map +1 -1
  23. package/dist/oauth/openid-client/protocol.d.mts +0 -1
  24. package/dist/oauth/openid-client/protocol.mjs +7 -7
  25. package/dist/oauth/openid-client/protocol.mjs.map +1 -1
  26. package/package.json +1 -1
  27. package/src/GitHub.ts +1 -0
  28. package/src/oauth/github/protocol.ts +27 -8
  29. package/src/oauth/openid-client/compatibility.ts +13 -0
  30. package/src/oauth/openid-client/configuration.ts +2 -0
  31. package/src/oauth/openid-client/models.ts +3 -0
  32. package/src/oauth/openid-client/protocol.ts +6 -22
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.mjs","names":[],"sources":["../../../src/oauth/github/protocol.ts"],"sourcesContent":["import { Effect, Encoding, Layer, Predicate, Redacted, Schema } from \"effect\";\nimport type { CustomFetch } from \"openid-client\";\n\nimport { OAuthConnectedProfile } from \"../connectedModels\";\nimport { OAuthConnectedProtocol } from \"../OAuthConnectedProtocol\";\nimport { OAuthProtocol } from \"../OAuthProtocol\";\nimport {\n DefiniteTokenRejection,\n type ConnectedCompatibility,\n} from \"../openid-client/compatibility\";\nimport { makeConnectedProtocolWithCompatibility } from \"../openid-client/connected/protocol\";\nimport {\n OpenIdClientConfigurationError,\n type OpenIdClientOAuthProvider,\n} from \"../openid-client/models\";\nimport { makeOAuthProtocolWithCompatibility } from \"../openid-client/protocol\";\nimport { ProviderRevocation } from \"../openid-client/ProviderRevocation\";\nimport { boundedFetch } from \"../openid-client/transport\";\nimport { OAuthUnavailable } from \"../signInErrors\";\nimport { OAuthCallbackId, OAuthGeneration, OAuthIssuer, OAuthRedirectUri } from \"../signInModels\";\nimport { snapshotOAuthSync } from \"../signInSnapshot\";\nimport { decodeGitHubIdentity, gitHubOAuthAppProviderKey } from \"./identity\";\nimport type {\n GitHubOAuthAppConnectedProtocolOptions,\n GitHubOAuthAppGeneration,\n GitHubOAuthAppProtocolOptions,\n} from \"./models\";\n\nconst unavailable = () => OAuthUnavailable.make({});\nconst invalid = () => OpenIdClientConfigurationError.make({ reason: \"provider\" });\nconst issuer = OAuthIssuer.make(\"https://github.com\");\n\nconst headers = Object.freeze({\n Accept: \"application/vnd.github+json\",\n \"User-Agent\": \"effect-auth-github-oauth-app\",\n \"X-GitHub-Api-Version\": \"2026-03-10\",\n});\n\nconst generation = Schema.Struct({\n configurationGeneration: OAuthGeneration,\n issuance: Schema.Literals([\"active\", \"retired\"]),\n clientId: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9._-]{1,256}$/)),\n clientSecret: Schema.RedactedFromValue(Schema.NonEmptyString.check(Schema.isMaxLength(4096))),\n callbacks: Schema.Array(\n Schema.Struct({ callbackId: OAuthCallbackId, redirectUri: OAuthRedirectUri }),\n ).check(Schema.isMinLength(1), Schema.isMaxLength(16)),\n});\n\nconst generations = Schema.Array(generation).check(Schema.isMinLength(1), Schema.isMaxLength(64));\n\nconst connectedGenerations = Schema.Array(\n Schema.Struct({\n ...generation.fields,\n profiles: Schema.Array(OAuthConnectedProfile).check(\n Schema.isMinLength(1),\n Schema.isMaxLength(64),\n ),\n }),\n).check(Schema.isMinLength(1), Schema.isMaxLength(64));\n\nconst timeout = Schema.Finite.check(Schema.isBetween({ minimum: 1, maximum: 30 }));\nconst isTimeout = Schema.is(timeout);\n\nconst capture = <S extends Schema.Codec<unknown, unknown, never, never>>(\n schema: S,\n registrations: S[\"Type\"],\n options: {\n readonly timeoutSeconds: number;\n readonly fetch?: GitHubOAuthAppProtocolOptions[\"fetch\"];\n },\n) =>\n Effect.try({\n try: () => {\n const result = snapshotOAuthSync(schema, registrations);\n const fetch = options.fetch;\n const timeoutSeconds = options.timeoutSeconds;\n\n if (!isTimeout(timeoutSeconds) || (fetch !== undefined && !Predicate.isFunction(fetch)))\n throw invalid();\n\n return { registrations: result, timeoutSeconds, ...(fetch === undefined ? {} : { fetch }) };\n },\n catch: invalid,\n });\n\nconst provider = (\n registration: GitHubOAuthAppGeneration,\n): Omit<OpenIdClientOAuthProvider, \"scopes\"> => ({\n provider: gitHubOAuthAppProviderKey,\n configurationGeneration: registration.configurationGeneration,\n issuance: registration.issuance,\n issuer,\n protocol: \"oauth\",\n responseIssuerMode: \"unsupported\",\n clientId: registration.clientId,\n authentication: { method: \"client_secret_post\", secret: registration.clientSecret },\n callbacks: registration.callbacks,\n authorizationEndpoint: \"https://github.com/login/oauth/authorize\",\n tokenEndpoint: \"https://github.com/login/oauth/access_token\",\n pkceS256: true,\n identitySource: {\n url: \"https://api.github.com/user\",\n headers,\n decodeIdentity: decodeGitHubIdentity,\n },\n});\n\nconst csvCell = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_:-]{1,256}$/));\nconst isCell = Schema.is(csvCell);\n\n/** GitHub's receipt is comma-delimited, unlike the generic OAuth scope string. */\nconst scopes = (\n receipt: string | undefined,\n expected: ReadonlyArray<string>,\n): ReadonlyArray<string> => {\n if (receipt === undefined || receipt.length > 16447) throw unavailable();\n\n const result =\n receipt === \"\" ? [] : receipt.split(\",\").map((cell) => cell.replace(/^[ \\t]+|[ \\t]+$/g, \"\"));\n\n if (\n result.length > 64 ||\n result.some((cell) => !isCell(cell)) ||\n new Set(result).size !== result.length ||\n result.length !== expected.length ||\n result.some((cell) => !expected.includes(cell))\n )\n throw unavailable();\n\n return result;\n};\n\nconst token = Schema.NonEmptyString.check(Schema.isMaxLength(16384));\nconst expiry = Schema.Finite.check(Schema.isGreaterThan(0));\n\nconst receiptSchema = Schema.Struct({\n access_token: token,\n token_type: Schema.String.check(Schema.isPattern(/^[Bb][Ee][Aa][Rr][Ee][Rr]$/)),\n scope: Schema.String.check(Schema.isMaxLength(16447)),\n expires_in: Schema.optionalKey(expiry),\n refresh_token: Schema.optionalKey(token),\n refresh_token_expires_in: Schema.optionalKey(expiry),\n});\n\n// oxlint-disable-next-line no-restricted-properties -- Inspect the bounded raw receipt before the maintained parser can coerce expiry fields.\nconst decodeReceipt = Schema.decodeUnknownSync(receiptSchema);\n\nconst encodeRevocation = Schema.encodeSync(\n Schema.fromJsonString(Schema.Struct({ access_token: token })),\n);\n\nconst terminalReceipt = Schema.Struct({\n error: Schema.NonEmptyString.check(Schema.isMaxLength(128)),\n error_description: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(4096))),\n error_uri: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(2048))),\n});\n\n// oxlint-disable-next-line no-restricted-properties -- Fully validate the raw terminal receipt before classifying a provider rejection.\nconst decodeTerminalReceipt = Schema.decodeUnknownSync(terminalReceipt);\n\nconst successKeys = [\n \"access_token\",\n \"token_type\",\n \"scope\",\n \"expires_in\",\n \"refresh_token\",\n \"refresh_token_expires_in\",\n \"id_token\",\n];\n\nconst compatibility: ConnectedCompatibility = Object.freeze<ConnectedCompatibility>({\n inspectReceipt: ({ body, status, contentType }, input) => {\n if (contentType?.split(\";\", 1)[0]?.trim().toLowerCase() !== \"application/json\")\n throw unavailable();\n if (!Predicate.isObject(body)) throw unavailable();\n if (Object.hasOwn(body, \"error\")) {\n if (successKeys.some((key) => Object.hasOwn(body, key))) throw unavailable();\n const terminal = decodeTerminalReceipt(body);\n\n if (\n (status === 200 || status === 400) &&\n terminal.error ===\n (input.operation === \"authorization_code\" ? \"bad_verification_code\" : \"bad_refresh_token\")\n ) {\n throw new DefiniteTokenRejection();\n }\n throw unavailable();\n }\n if (\n status !== 200 ||\n [\"error_description\", \"error_uri\", \"id_token\"].some((key) => Object.hasOwn(body, key))\n )\n throw unavailable();\n const receipt = decodeReceipt(body);\n\n scopes(receipt.scope, input.scopes);\n if (\n input.refreshRequired &&\n (receipt.refresh_token === undefined ||\n receipt.expires_in === undefined ||\n receipt.refresh_token_expires_in === undefined)\n )\n throw unavailable();\n },\n authorizationScopes: (permissions, refresh) =>\n refresh ? [...permissions, \"offline_access\"] : permissions,\n decodeScopes: scopes,\n includeRefreshScope: false,\n});\n\nconst revocationLayer = (\n options: Pick<GitHubOAuthAppConnectedProtocolOptions, \"fetch\" | \"timeoutSeconds\">,\n) => {\n const fetch: CustomFetch =\n options.fetch ??\n ((url, init) =>\n globalThis.fetch(url, {\n ...init,\n body: init.body instanceof Uint8Array ? new Uint8Array(init.body) : init.body,\n }));\n\n const timeoutSeconds = options.timeoutSeconds;\n\n return Layer.succeed(\n ProviderRevocation,\n ProviderRevocation.of({\n revoke: Effect.fn(\"GitHubOAuthApp.revoke\")(function* (input) {\n yield* Effect.tryPromise({\n try: async (effectSignal) => {\n if (\n input.authentication.method !== \"client_secret_post\" ||\n input.context.configuration.profile.clientRegistrationId !== input.clientId ||\n input.context.identity.provider !== gitHubOAuthAppProviderKey ||\n input.context.identity.issuer !== issuer\n )\n throw unavailable();\n const url = `https://api.github.com/applications/${encodeURIComponent(input.clientId)}/grant`;\n\n const signal = AbortSignal.any([\n effectSignal,\n AbortSignal.timeout(Math.ceil(timeoutSeconds * 1000)),\n ]);\n\n const transport = boundedFetch(fetch, signal, new Set([url]));\n\n const response = await transport(url, {\n method: \"DELETE\",\n redirect: \"manual\",\n headers: {\n ...headers,\n \"Content-Type\": \"application/json\",\n Authorization: `Basic ${Encoding.encodeBase64(`${input.clientId}:${Redacted.value(input.authentication.secret)}`)}`,\n },\n body: encodeRevocation({ access_token: Redacted.value(input.material.accessToken) }),\n signal,\n });\n\n signal.throwIfAborted();\n if (response.status !== 204) throw unavailable();\n },\n catch: unavailable,\n });\n }),\n }),\n );\n};\n\nexport const makeGitHubOAuthAppProtocol = Effect.fn(\"makeGitHubOAuthAppProtocol\")(function* (\n options: GitHubOAuthAppProtocolOptions,\n) {\n const saved = yield* capture(generations, options.registrations, options);\n\n if (saved.registrations.filter((item) => item.issuance === \"active\").length !== 1)\n return yield* invalid();\n\n return yield* makeOAuthProtocolWithCompatibility(\n {\n ...saved,\n providers: saved.registrations.map((item) => ({ ...provider(item), scopes: [\"read:user\"] })),\n },\n compatibility,\n );\n});\n\nexport const makeGitHubOAuthAppConnectedProtocol = Effect.fn(\"makeGitHubOAuthAppConnectedProtocol\")(\n function* (options: GitHubOAuthAppConnectedProtocolOptions) {\n const saved = yield* capture(connectedGenerations, options.registrations, options);\n\n if (saved.registrations.filter((item) => item.issuance === \"active\").length !== 1)\n return yield* invalid();\n for (const registration of saved.registrations) {\n for (const profile of registration.profiles) {\n if (\n profile.provider !== gitHubOAuthAppProviderKey ||\n profile.clientRegistrationId !== registration.clientId ||\n profile.resources.length !== 0 ||\n profile.scopes.some((scope) => scope === \"offline_access\" || !isCell(scope)) ||\n (profile.retention === \"access-only\"\n ? profile.refresh !== \"unsupported\" ||\n profile.maximumRefreshLifetimeMillis !== undefined\n : profile.refresh !== \"rotating\" || profile.maximumRefreshLifetimeMillis === undefined)\n )\n return yield* invalid();\n }\n }\n\n return yield* makeConnectedProtocolWithCompatibility(\n {\n ...saved,\n providers: saved.registrations.map((item) => ({\n ...provider(item),\n profiles: item.profiles,\n clientRegistrationId: item.clientId,\n resourceIndicators: \"unsupported\",\n refreshExpiry: { field: \"refresh_token_expires_in\", zero: \"expired\" },\n revocation: { mode: \"provider-cohort\" },\n })),\n },\n compatibility,\n ).pipe(Effect.provide(revocationLayer(saved)));\n },\n);\n\nexport const gitHubOAuthAppProtocolLayer = (options: GitHubOAuthAppProtocolOptions) =>\n Layer.effect(OAuthProtocol, makeGitHubOAuthAppProtocol(options));\n\nexport const gitHubOAuthAppConnectedProtocolLayer = (\n options: GitHubOAuthAppConnectedProtocolOptions,\n) => Layer.effect(OAuthConnectedProtocol, makeGitHubOAuthAppConnectedProtocol(options));\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAM,oBAAoB,iBAAiB,KAAK,CAAC,CAAC;AAClD,MAAM,gBAAgB,+BAA+B,KAAK,EAAE,QAAQ,WAAW,CAAC;AAChF,MAAM,SAAS,YAAY,KAAK,oBAAoB;AAEpD,MAAM,UAAU,OAAO,OAAO;CAC5B,QAAQ;CACR,cAAc;CACd,wBAAwB;AAC1B,CAAC;AAED,MAAM,aAAa,OAAO,OAAO;CAC/B,yBAAyB;CACzB,UAAU,OAAO,SAAS,CAAC,UAAU,SAAS,CAAC;CAC/C,UAAU,OAAO,OAAO,MAAM,OAAO,UAAU,yBAAyB,CAAC;CACzE,cAAc,OAAO,kBAAkB,OAAO,eAAe,MAAM,OAAO,YAAY,IAAI,CAAC,CAAC;CAC5F,WAAW,OAAO,MAChB,OAAO,OAAO;EAAE,YAAY;EAAiB,aAAa;CAAiB,CAAC,CAC9E,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,GAAG,OAAO,YAAY,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,cAAc,OAAO,MAAM,UAAU,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,G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AC;AAED,MAAa,sCAAsC,OAAO,GAAG,qCAAqC,CAAC,CACjG,WAAW,SAAiD;CAC1D,MAAM,QAAQ,OAAO,QAAQ,sBAAsB,QAAQ,eAAe,OAAO;CAEjF,IAAI,MAAM,cAAc,QAAQ,SAAS,KAAK,aAAa,QAAQ,CAAC,CAAC,WAAW,GAC9E,OAAO,OAAO,QAAQ;CACxB,KAAK,MAAM,gBAAgB,MAAM,eAC/B,KAAK,MAAM,WAAW,aAAa,UACjC,IACE,QAAQ,aAAa,6BACrB,QAAQ,yBAAyB,aAAa,YAC9C,QAAQ,UAAU,WAAW,KAC7B,QAAQ,OAAO,MAAM,UAAU,UAAU,oBAAoB,CAAC,OAAO,KAAK,CAAC,MAC1E,QAAQ,cAAc,gBACnB,QAAQ,YAAY,iBACpB,QAAQ,iCAAiC,KAAA,IACzC,QAAQ,YAAY,cAAc,QAAQ,iCAAiC,KAAA,IAE/E,OAAO,OAAO,QAAQ;CAI5B,OAAO,OAAO,uCACZ;EACE,GAAG;EACH,WAAW,MAAM,cAAc,KAAK,UAAU;GAC5C,GAAG,SAAS,IAAI;GAChB,UAAU,KAAK;GACf,sBAAsB,KAAK;GAC3B,oBAAoB;GACpB,eAAe;IAAE,OAAO;IAA4B,MAAM;GAAU;GACpE,YAAY,EAAE,MAAM,kBAAkB;EACxC,EAAE;CACJ,GACA,aACF,CAAC,CAAC,KAAK,OAAO,QAAQ,gBAAgB,KAAK,CAAC,CAAC;AAC/C,CACF;AAEA,MAAa,+BAA+B,YAC1C,MAAM,OAAO,eAAe,2BAA2B,OAAO,CAAC;AAEjE,MAAa,wCACX,YACG,MAAM,OAAO,wBAAwB,oCAAoC,OAAO,CAAC"}
1
+ {"version":3,"file":"protocol.mjs","names":[],"sources":["../../../src/oauth/github/protocol.ts"],"sourcesContent":["import { Effect, Encoding, Layer, Predicate, Redacted, Schema } from \"effect\";\nimport type { CustomFetch } from \"openid-client\";\n\nimport { OAuthConnectedProfile } from \"../connectedModels\";\nimport { OAuthConnectedProtocol } from \"../OAuthConnectedProtocol\";\nimport { OAuthProtocol } from \"../OAuthProtocol\";\nimport {\n DefiniteTokenRejection,\n tokenCompatibility,\n type ConnectedCompatibility,\n} from \"../openid-client/compatibility\";\nimport { makeConnectedProtocolWithCompatibility } from \"../openid-client/connected/protocol\";\nimport {\n OpenIdClientConfigurationError,\n type OpenIdClientOAuthProvider,\n} from \"../openid-client/models\";\nimport { makeOpenIdClientOAuthProtocol } from \"../openid-client/protocol\";\nimport { ProviderRevocation } from \"../openid-client/ProviderRevocation\";\nimport { boundedFetch } from \"../openid-client/transport\";\nimport { OAuthUnavailable } from \"../signInErrors\";\nimport { OAuthCallbackId, OAuthGeneration, OAuthIssuer, OAuthRedirectUri } from \"../signInModels\";\nimport { snapshotOAuthSync } from \"../signInSnapshot\";\nimport { decodeGitHubIdentity, gitHubOAuthAppProviderKey } from \"./identity\";\nimport type {\n GitHubOAuthAppConnectedProtocolOptions,\n GitHubOAuthAppGeneration,\n GitHubOAuthAppProtocolOptions,\n} from \"./models\";\n\nconst unavailable = () => OAuthUnavailable.make({});\nconst invalid = () => OpenIdClientConfigurationError.make({ reason: \"provider\" });\nconst issuer = OAuthIssuer.make(\"https://github.com\");\n\nconst headers = Object.freeze({\n Accept: \"application/vnd.github+json\",\n \"User-Agent\": \"effect-auth-github-oauth-app\",\n \"X-GitHub-Api-Version\": \"2026-03-10\",\n});\n\nconst generation = Schema.Struct({\n configurationGeneration: OAuthGeneration,\n issuance: Schema.Literals([\"active\", \"retired\"]),\n clientId: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9._-]{1,256}$/)),\n clientSecret: Schema.RedactedFromValue(Schema.NonEmptyString.check(Schema.isMaxLength(4096))),\n callbacks: Schema.Array(\n Schema.Struct({ callbackId: OAuthCallbackId, redirectUri: OAuthRedirectUri }),\n ).check(Schema.isMinLength(1), Schema.isMaxLength(16)),\n});\n\nconst generations = Schema.Array(generation).check(Schema.isMinLength(1), Schema.isMaxLength(64));\n\nconst connectedGenerations = Schema.Array(\n Schema.Struct({\n ...generation.fields,\n profiles: Schema.Array(OAuthConnectedProfile).check(\n Schema.isMinLength(1),\n Schema.isMaxLength(64),\n ),\n }),\n).check(Schema.isMinLength(1), Schema.isMaxLength(64));\n\nconst timeout = Schema.Finite.check(Schema.isBetween({ minimum: 1, maximum: 30 }));\nconst isTimeout = Schema.is(timeout);\n\nconst capture = <S extends Schema.Codec<unknown, unknown, never, never>>(\n schema: S,\n registrations: S[\"Type\"],\n options: {\n readonly timeoutSeconds: number;\n readonly fetch?: GitHubOAuthAppProtocolOptions[\"fetch\"];\n },\n) =>\n Effect.try({\n try: () => {\n const result = snapshotOAuthSync(schema, registrations);\n const fetch = options.fetch;\n const timeoutSeconds = options.timeoutSeconds;\n\n if (!isTimeout(timeoutSeconds) || (fetch !== undefined && !Predicate.isFunction(fetch)))\n throw invalid();\n\n return { registrations: result, timeoutSeconds, ...(fetch === undefined ? {} : { fetch }) };\n },\n catch: invalid,\n });\n\nconst provider = (\n registration: GitHubOAuthAppGeneration,\n): Omit<OpenIdClientOAuthProvider, \"scopes\"> => ({\n provider: gitHubOAuthAppProviderKey,\n configurationGeneration: registration.configurationGeneration,\n issuance: registration.issuance,\n issuer,\n protocol: \"oauth\",\n responseIssuerMode: \"unsupported\",\n clientId: registration.clientId,\n authentication: { method: \"client_secret_post\", secret: registration.clientSecret },\n callbacks: registration.callbacks,\n authorizationEndpoint: \"https://github.com/login/oauth/authorize\",\n tokenEndpoint: \"https://github.com/login/oauth/access_token\",\n pkceS256: true,\n identitySource: {\n url: \"https://api.github.com/user\",\n headers,\n decodeIdentity: decodeGitHubIdentity,\n },\n});\n\nconst csvCell = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_:-]{1,256}$/));\nconst isCell = Schema.is(csvCell);\n\n/** GitHub's receipt is comma-delimited, unlike the generic OAuth scope string. */\nconst scopes = (\n receipt: string | undefined,\n expected: ReadonlyArray<string>,\n): ReadonlyArray<string> => {\n if (receipt === undefined || receipt.length > 16447) throw unavailable();\n\n const result =\n receipt === \"\" ? [] : receipt.split(\",\").map((cell) => cell.replace(/^[ \\t]+|[ \\t]+$/g, \"\"));\n\n if (\n result.length > 64 ||\n result.some((cell) => !isCell(cell)) ||\n new Set(result).size !== result.length ||\n result.length !== expected.length ||\n result.some((cell) => !expected.includes(cell))\n )\n throw unavailable();\n\n return result;\n};\n\nconst token = Schema.NonEmptyString.check(Schema.isMaxLength(16384));\nconst expiry = Schema.Finite.check(Schema.isGreaterThan(0));\n\nconst receiptSchema = Schema.Struct({\n access_token: token,\n token_type: Schema.String.check(Schema.isPattern(/^[Bb][Ee][Aa][Rr][Ee][Rr]$/)),\n scope: Schema.String.check(Schema.isMaxLength(16447)),\n expires_in: Schema.optionalKey(expiry),\n refresh_token: Schema.optionalKey(token),\n refresh_token_expires_in: Schema.optionalKey(expiry),\n});\n\n// oxlint-disable-next-line no-restricted-properties -- Inspect the bounded raw receipt before the maintained parser can coerce expiry fields.\nconst decodeReceipt = Schema.decodeUnknownSync(receiptSchema);\n\nconst encodeRevocation = Schema.encodeSync(\n Schema.fromJsonString(Schema.Struct({ access_token: token })),\n);\n\nconst terminalReceipt = Schema.Struct({\n error: Schema.NonEmptyString.check(Schema.isMaxLength(128)),\n error_description: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(4096))),\n error_uri: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(2048))),\n});\n\n// oxlint-disable-next-line no-restricted-properties -- Fully validate the raw terminal receipt before classifying a provider rejection.\nconst decodeTerminalReceipt = Schema.decodeUnknownSync(terminalReceipt);\n\nconst successKeys = [\n \"access_token\",\n \"token_type\",\n \"scope\",\n \"expires_in\",\n \"refresh_token\",\n \"refresh_token_expires_in\",\n \"id_token\",\n];\n\nconst compatibility: ConnectedCompatibility = Object.freeze<ConnectedCompatibility>({\n inspectReceipt: ({ body, status, contentType }, input) => {\n if (contentType?.split(\";\", 1)[0]?.trim().toLowerCase() !== \"application/json\")\n throw unavailable();\n if (!Predicate.isObject(body)) throw unavailable();\n if (Object.hasOwn(body, \"error\")) {\n if (successKeys.some((key) => Object.hasOwn(body, key))) throw unavailable();\n const terminal = decodeTerminalReceipt(body);\n\n if (\n (status === 200 || status === 400) &&\n terminal.error ===\n (input.operation === \"authorization_code\" ? \"bad_verification_code\" : \"bad_refresh_token\")\n ) {\n throw new DefiniteTokenRejection();\n }\n throw unavailable();\n }\n if (\n status !== 200 ||\n [\"error_description\", \"error_uri\", \"id_token\"].some((key) => Object.hasOwn(body, key))\n )\n throw unavailable();\n const receipt = decodeReceipt(body);\n\n scopes(receipt.scope, input.scopes);\n if (\n input.refreshRequired &&\n (receipt.refresh_token === undefined ||\n receipt.expires_in === undefined ||\n receipt.refresh_token_expires_in === undefined)\n )\n throw unavailable();\n },\n authorizationScopes: (permissions, refresh) =>\n refresh ? [...permissions, \"offline_access\"] : permissions,\n decodeScopes: scopes,\n includeRefreshScope: false,\n});\n\nconst revocationLayer = (\n options: Pick<GitHubOAuthAppConnectedProtocolOptions, \"fetch\" | \"timeoutSeconds\">,\n) => {\n const fetch: CustomFetch =\n options.fetch ??\n ((url, init) =>\n globalThis.fetch(url, {\n ...init,\n body: init.body instanceof Uint8Array ? new Uint8Array(init.body) : init.body,\n }));\n\n const timeoutSeconds = options.timeoutSeconds;\n\n return Layer.succeed(\n ProviderRevocation,\n ProviderRevocation.of({\n revoke: Effect.fn(\"GitHubOAuthApp.revoke\")(function* (input) {\n yield* Effect.tryPromise({\n try: async (effectSignal) => {\n if (\n input.authentication.method !== \"client_secret_post\" ||\n input.context.configuration.profile.clientRegistrationId !== input.clientId ||\n input.context.identity.provider !== gitHubOAuthAppProviderKey ||\n input.context.identity.issuer !== issuer\n )\n throw unavailable();\n const url = `https://api.github.com/applications/${encodeURIComponent(input.clientId)}/grant`;\n\n const signal = AbortSignal.any([\n effectSignal,\n AbortSignal.timeout(Math.ceil(timeoutSeconds * 1000)),\n ]);\n\n const transport = boundedFetch(fetch, signal, new Set([url]));\n\n const response = await transport(url, {\n method: \"DELETE\",\n redirect: \"manual\",\n headers: {\n ...headers,\n \"Content-Type\": \"application/json\",\n Authorization: `Basic ${Encoding.encodeBase64(`${input.clientId}:${Redacted.value(input.authentication.secret)}`)}`,\n },\n body: encodeRevocation({ access_token: Redacted.value(input.material.accessToken) }),\n signal,\n });\n\n signal.throwIfAborted();\n if (response.status !== 204) throw unavailable();\n },\n catch: unavailable,\n });\n }),\n }),\n );\n};\n\n/** A GitHub.com OAuth App generation for the same provider list as generic OIDC.\n * Retains GitHub receipt/error rules and requests read:user, with no repository access.\n * Construction performs no I/O; invalid configuration throws the typed configuration error. */\nexport const gitHubOAuthAppProvider = (\n registration: GitHubOAuthAppGeneration,\n): OpenIdClientOAuthProvider => {\n let saved: GitHubOAuthAppGeneration;\n\n try {\n saved = snapshotOAuthSync(generation, registration);\n } catch {\n throw invalid();\n }\n\n return {\n ...provider(saved),\n scopes: [\"read:user\"],\n [tokenCompatibility]: compatibility,\n };\n};\n\nexport const makeGitHubOAuthAppProtocol = Effect.fn(\"makeGitHubOAuthAppProtocol\")(function* (\n options: GitHubOAuthAppProtocolOptions,\n) {\n const saved = yield* capture(generations, options.registrations, options);\n\n if (saved.registrations.filter((item) => item.issuance === \"active\").length !== 1)\n return yield* invalid();\n\n return yield* makeOpenIdClientOAuthProtocol({\n ...saved,\n providers: saved.registrations.map(gitHubOAuthAppProvider),\n });\n});\n\nexport const makeGitHubOAuthAppConnectedProtocol = Effect.fn(\"makeGitHubOAuthAppConnectedProtocol\")(\n function* (options: GitHubOAuthAppConnectedProtocolOptions) {\n const saved = yield* capture(connectedGenerations, options.registrations, options);\n\n if (saved.registrations.filter((item) => item.issuance === \"active\").length !== 1)\n return yield* invalid();\n for (const registration of saved.registrations) {\n for (const profile of registration.profiles) {\n if (\n profile.provider !== gitHubOAuthAppProviderKey ||\n profile.clientRegistrationId !== registration.clientId ||\n profile.resources.length !== 0 ||\n profile.scopes.some((scope) => scope === \"offline_access\" || !isCell(scope)) ||\n (profile.retention === \"access-only\"\n ? profile.refresh !== \"unsupported\" ||\n profile.maximumRefreshLifetimeMillis !== undefined\n : profile.refresh !== \"rotating\" || profile.maximumRefreshLifetimeMillis === undefined)\n )\n return yield* invalid();\n }\n }\n\n return yield* makeConnectedProtocolWithCompatibility(\n {\n ...saved,\n providers: saved.registrations.map((item) => ({\n ...provider(item),\n profiles: item.profiles,\n clientRegistrationId: item.clientId,\n resourceIndicators: \"unsupported\",\n refreshExpiry: { field: \"refresh_token_expires_in\", zero: \"expired\" },\n revocation: { mode: \"provider-cohort\" },\n })),\n },\n compatibility,\n ).pipe(Effect.provide(revocationLayer(saved)));\n },\n);\n\nexport const gitHubOAuthAppProtocolLayer = (options: GitHubOAuthAppProtocolOptions) =>\n Layer.effect(OAuthProtocol, makeGitHubOAuthAppProtocol(options));\n\nexport const gitHubOAuthAppConnectedProtocolLayer = (\n options: GitHubOAuthAppConnectedProtocolOptions,\n) => Layer.effect(OAuthConnectedProtocol, makeGitHubOAuthAppConnectedProtocol(options));\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,oBAAoB,iBAAiB,KAAK,CAAC,CAAC;AAClD,MAAM,gBAAgB,+BAA+B,KAAK,EAAE,QAAQ,WAAW,CAAC;AAChF,MAAM,SAAS,YAAY,KAAK,oBAAoB;AAEpD,MAAM,UAAU,OAAO,OAAO;CAC5B,QAAQ;CACR,cAAc;CACd,wBAAwB;AAC1B,CAAC;AAED,MAAM,aAAa,OAAO,OAAO;CAC/B,yBAAyB;CACzB,UAAU,OAAO,SAAS,CAAC,UAAU,SAAS,CAAC;CAC/C,UAAU,OAAO,OAAO,MAAM,OAAO,UAAU,yBAAyB,CAAC;CACzE,cAAc,OAAO,kBAAkB,OAAO,eAAe,MAAM,OAAO,YAAY,IAAI,CAAC,CAAC;CAC5F,WAAW,OAAO,MAChB,OAAO,OAAO;EAAE,YAAY;EAAiB,aAAa;CAAiB,CAAC,CAC9E,CAAC,CAAC,MAAM,OAAO,YA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Ae,2BAA2B,OAAO,CAAC;AAEjE,MAAa,wCACX,YACG,MAAM,OAAO,wBAAwB,oCAAoC,OAAO,CAAC"}
@@ -1 +1,22 @@
1
- import "./connected/models.mjs";
1
+ import "./connected/models.mjs";
2
+ import { Schema } from "effect";
3
+ //#region src/oauth/openid-client/compatibility.d.ts
4
+ /** Pure private provider rules, never part of the generic public options. */
5
+ interface TokenCompatibility {
6
+ readonly inspectReceipt: (receipt: {
7
+ readonly body: unknown;
8
+ readonly status: number;
9
+ readonly contentType: string | null;
10
+ }, input: {
11
+ readonly scopes: ReadonlyArray<string>;
12
+ readonly refreshRequired: boolean;
13
+ readonly operation: "authorization_code" | "refresh_token";
14
+ }) => void;
15
+ }
16
+ /** First-party rules travel with the exact provider generation. The symbol stays
17
+ * private so generic provider options do not expose grant-bearing hooks. */
18
+ declare const tokenCompatibility: unique symbol;
19
+ declare const TokenCompatibility: Schema.declare<TokenCompatibility, TokenCompatibility>;
20
+ //#endregion
21
+ export { TokenCompatibility, tokenCompatibility };
22
+ //# sourceMappingURL=compatibility.d.mts.map
@@ -1,6 +1,11 @@
1
+ import { Predicate, Schema } from "effect";
1
2
  //#region src/oauth/openid-client/compatibility.ts
3
+ /** First-party rules travel with the exact provider generation. The symbol stays
4
+ * private so generic provider options do not expose grant-bearing hooks. */
5
+ const tokenCompatibility = Symbol("effect-auth/OpenIdClient/tokenCompatibility");
6
+ const TokenCompatibility = Schema.declare((input) => Predicate.isObject(input) && "inspectReceipt" in input && Predicate.isFunction(input.inspectReceipt));
2
7
  var DefiniteTokenRejection = class extends Error {};
3
8
  //#endregion
4
- export { DefiniteTokenRejection };
9
+ export { DefiniteTokenRejection, TokenCompatibility, tokenCompatibility };
5
10
 
6
11
  //# sourceMappingURL=compatibility.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compatibility.mjs","names":[],"sources":["../../../src/oauth/openid-client/compatibility.ts"],"sourcesContent":["import type {\n OpenIdClientConnectedOAuthProvider,\n OpenIdClientConnectedProtocolOptions,\n} from \"./connected/models\";\n\n/** Pure private provider rules, never part of the generic public options. */\nexport interface TokenCompatibility {\n readonly inspectReceipt: (\n receipt: {\n readonly body: unknown;\n readonly status: number;\n readonly contentType: string | null;\n },\n input: {\n readonly scopes: ReadonlyArray<string>;\n readonly refreshRequired: boolean;\n readonly operation: \"authorization_code\" | \"refresh_token\";\n },\n ) => void;\n}\n\nexport class DefiniteTokenRejection extends Error {}\n\nexport interface ConnectedCompatibility extends TokenCompatibility {\n readonly authorizationScopes: (\n scopes: ReadonlyArray<string>,\n refresh: boolean,\n ) => ReadonlyArray<string>;\n readonly decodeScopes: (\n receipt: string | undefined,\n expected: ReadonlyArray<string>,\n ) => ReadonlyArray<string>;\n readonly includeRefreshScope: boolean;\n}\n\nexport type ProviderConnectedOAuth<R> = Omit<\n OpenIdClientConnectedOAuthProvider<R>,\n \"revocation\"\n> & {\n readonly revocation: { readonly mode: \"provider-cohort\" };\n};\n\nexport type ConnectedOptions<R> = Omit<OpenIdClientConnectedProtocolOptions<R>, \"providers\"> & {\n readonly providers: ReadonlyArray<\n OpenIdClientConnectedProtocolOptions<R>[\"providers\"][number] | ProviderConnectedOAuth<R>\n >;\n};\n"],"mappings":";AAqBA,IAAa,yBAAb,cAA4C,MAAM,CAAC"}
1
+ {"version":3,"file":"compatibility.mjs","names":[],"sources":["../../../src/oauth/openid-client/compatibility.ts"],"sourcesContent":["import { Predicate, Schema } from \"effect\";\n\nimport type {\n OpenIdClientConnectedOAuthProvider,\n OpenIdClientConnectedProtocolOptions,\n} from \"./connected/models\";\n\n/** Pure private provider rules, never part of the generic public options. */\nexport interface TokenCompatibility {\n readonly inspectReceipt: (\n receipt: {\n readonly body: unknown;\n readonly status: number;\n readonly contentType: string | null;\n },\n input: {\n readonly scopes: ReadonlyArray<string>;\n readonly refreshRequired: boolean;\n readonly operation: \"authorization_code\" | \"refresh_token\";\n },\n ) => void;\n}\n\n/** First-party rules travel with the exact provider generation. The symbol stays\n * private so generic provider options do not expose grant-bearing hooks. */\nexport const tokenCompatibility = Symbol(\"effect-auth/OpenIdClient/tokenCompatibility\");\n\nexport const TokenCompatibility = Schema.declare<TokenCompatibility>(\n (input): input is TokenCompatibility =>\n Predicate.isObject(input) &&\n \"inspectReceipt\" in input &&\n Predicate.isFunction(input.inspectReceipt),\n);\n\nexport class DefiniteTokenRejection extends Error {}\n\nexport interface ConnectedCompatibility extends TokenCompatibility {\n readonly authorizationScopes: (\n scopes: ReadonlyArray<string>,\n refresh: boolean,\n ) => ReadonlyArray<string>;\n readonly decodeScopes: (\n receipt: string | undefined,\n expected: ReadonlyArray<string>,\n ) => ReadonlyArray<string>;\n readonly includeRefreshScope: boolean;\n}\n\nexport type ProviderConnectedOAuth<R> = Omit<\n OpenIdClientConnectedOAuthProvider<R>,\n \"revocation\"\n> & {\n readonly revocation: { readonly mode: \"provider-cohort\" };\n};\n\nexport type ConnectedOptions<R> = Omit<OpenIdClientConnectedProtocolOptions<R>, \"providers\"> & {\n readonly providers: ReadonlyArray<\n OpenIdClientConnectedProtocolOptions<R>[\"providers\"][number] | ProviderConnectedOAuth<R>\n >;\n};\n"],"mappings":";;;;AAyBA,MAAa,qBAAqB,OAAO,6CAA6C;AAEtF,MAAa,qBAAqB,OAAO,SACtC,UACC,UAAU,SAAS,KAAK,KACxB,oBAAoB,SACpB,UAAU,WAAW,MAAM,cAAc,CAC7C;AAEA,IAAa,yBAAb,cAA4C,MAAM,CAAC"}
@@ -3,6 +3,7 @@ import { OAuthAuthorizationUrl, OAuthCallbackId, OAuthGeneration, OAuthIssuer, O
3
3
  import { OAuthUnavailable } from "../signInErrors.mjs";
4
4
  import { freezeOAuth } from "../signInSnapshot.mjs";
5
5
  import { OpenIdClientConfigurationError } from "./models.mjs";
6
+ import { TokenCompatibility, tokenCompatibility } from "./compatibility.mjs";
6
7
  import { boundedFetch } from "./transport.mjs";
7
8
  import { Effect, Predicate, Redacted, Schema } from "effect";
8
9
  import * as client from "openid-client";
@@ -52,6 +53,7 @@ const optionsSchema = () => Schema.toType(Schema.Struct({
52
53
  }), Schema.Struct({
53
54
  ...common,
54
55
  protocol: Schema.Literal("oauth"),
56
+ [tokenCompatibility]: Schema.optionalKey(TokenCompatibility),
55
57
  authorizationEndpoint: boundedString(2048),
56
58
  tokenEndpoint: boundedString(2048),
57
59
  pkceS256: Schema.Literal(true),
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.mjs","names":[],"sources":["../../../src/oauth/openid-client/configuration.ts"],"sourcesContent":["import { Effect, Predicate, Redacted, Schema } from \"effect\";\nimport * as client from \"openid-client\";\n\nimport { OAuthProviderKey } from \"../schema\";\nimport { OAuthUnavailable } from \"../signInErrors\";\nimport {\n OAuthAuthorizationUrl,\n OAuthCallbackId,\n OAuthGeneration,\n OAuthIssuer,\n OAuthRedirectUri,\n} from \"../signInModels\";\nimport { freezeOAuth } from \"../signInSnapshot\";\nimport {\n OpenIdClientConfigurationError,\n type OpenIdClientAuthentication,\n type OpenIdClientOAuthProvider,\n type OpenIdClientOAuthProtocolOptions,\n type OpenIdClientOidcProvider,\n} from \"./models\";\nimport { boundedFetch } from \"./transport\";\n\nconst boundedString = (maximum: number) =>\n Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(maximum));\n\nconst fields = Schema.Record(\n Schema.String.check(Schema.isPattern(/^[A-Za-z][A-Za-z0-9._~-]{0,63}$/)),\n Schema.String.check(Schema.isMaxLength(2048)),\n).check(Schema.makeFilter((record) => Object.keys(record).length <= 16));\n\nconst secret = Schema.RedactedFromValue(boundedString(4096));\n\nconst authentication = Schema.Union([\n Schema.Struct({ method: Schema.Literal(\"client_secret_basic\"), secret }),\n Schema.Struct({ method: Schema.Literal(\"client_secret_post\"), secret }),\n Schema.Struct({ method: Schema.Literal(\"none\"), publicClient: Schema.Literal(true) }),\n]);\n\nconst common = {\n provider: OAuthProviderKey,\n configurationGeneration: OAuthGeneration,\n issuance: Schema.Literals([\"active\", \"retired\"]),\n issuer: OAuthIssuer,\n responseIssuerMode: Schema.Literals([\"required\", \"unsupported\"]),\n clientId: boundedString(1024),\n authentication,\n callbacks: Schema.Array(\n Schema.Struct({ callbackId: OAuthCallbackId, redirectUri: OAuthRedirectUri }),\n ).check(Schema.isMinLength(1), Schema.isMaxLength(16)),\n scopes: Schema.Array(\n Schema.String.check(Schema.isPattern(/^[\\x21\\x23-\\x5b\\x5d-\\x7e]{1,128}$/)),\n ).check(Schema.isMaxLength(32)),\n authorizationParameters: Schema.optionalKey(fields),\n tokenParameters: Schema.optionalKey(fields),\n};\n\nconst optionsSchema = <R>() =>\n Schema.toType(\n Schema.Struct({\n providers: Schema.Array(\n Schema.Union([\n Schema.Struct({\n ...common,\n protocol: Schema.Literal(\"oidc\"),\n idTokenSignedResponseAlg: Schema.Literal(\"RS256\"),\n maxAgeSeconds: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 86400 })),\n ),\n }),\n Schema.Struct({\n ...common,\n protocol: Schema.Literal(\"oauth\"),\n authorizationEndpoint: boundedString(2048),\n tokenEndpoint: boundedString(2048),\n pkceS256: Schema.Literal(true),\n identitySource: Schema.Struct({\n url: boundedString(2048),\n headers: Schema.optionalKey(fields),\n // A configured function is trusted application code; its result has a separate schema boundary.\n decodeIdentity: Schema.declare<\n OpenIdClientOAuthProvider<R>[\"identitySource\"][\"decodeIdentity\"]\n >(\n (\n input,\n ): input is OpenIdClientOAuthProvider<R>[\"identitySource\"][\"decodeIdentity\"] =>\n Predicate.isFunction(input),\n ),\n }),\n }),\n ]),\n ).check(Schema.isMinLength(1), Schema.isMaxLength(64)),\n timeoutSeconds: Schema.Finite.check(Schema.isBetween({ minimum: 1, maximum: 30 })),\n fetch: Schema.optionalKey(\n Schema.declare<client.CustomFetch>((input): input is client.CustomFetch =>\n Predicate.isFunction(input),\n ),\n ),\n }),\n );\n\nconst reserved = new Set([\n \"client_id\",\n \"client_secret\",\n \"client_assertion\",\n \"client_assertion_type\",\n \"redirect_uri\",\n \"response_type\",\n \"response_mode\",\n \"state\",\n \"code\",\n \"code_verifier\",\n \"code_challenge\",\n \"code_challenge_method\",\n \"nonce\",\n \"scope\",\n \"iss\",\n \"grant_type\",\n \"max_age\",\n \"request\",\n \"request_uri\",\n \"authorization_details\",\n \"id_token_hint\",\n \"login_hint\",\n \"login_hint_token\",\n \"subject_token\",\n \"subject_token_type\",\n \"actor_token\",\n \"actor_token_type\",\n \"requested_token_type\",\n]);\n\nconst forbiddenHeaders = new Set([\n \"authorization\",\n \"proxy-authorization\",\n \"cookie\",\n \"host\",\n \"content-length\",\n \"content-type\",\n \"transfer-encoding\",\n \"connection\",\n \"upgrade\",\n \"trailer\",\n \"te\",\n]);\n\nconst configError = (reason: OpenIdClientConfigurationError[\"reason\"]) =>\n OpenIdClientConfigurationError.make({ reason });\n\nexport const endpoint = (value: string): URL => {\n const url = new URL(value);\n\n if (\n url.protocol !== \"https:\" ||\n url.username !== \"\" ||\n url.password !== \"\" ||\n value.includes(\"#\") ||\n // oxlint-disable-next-line no-control-regex -- Reject ambiguous protocol URL control characters.\n /[\\s\\\\\\u0000-\\u001f\\u007f]/u.test(value)\n )\n throw configError(\"metadata\");\n\n return url;\n};\n\nconst checkParameters = (parameters: Readonly<Record<string, string>> | undefined) => {\n for (const key of Object.keys(parameters ?? {})) {\n if (reserved.has(key.toLowerCase())) throw configError(\"parameters\");\n }\n};\n\nexport const clientAuthentication = (\n authentication: OpenIdClientAuthentication,\n): client.ClientAuth => {\n switch (authentication.method) {\n case \"client_secret_basic\":\n return client.ClientSecretBasic(Redacted.value(authentication.secret));\n case \"client_secret_post\":\n return client.ClientSecretPost(Redacted.value(authentication.secret));\n case \"none\":\n return client.None();\n }\n};\n\nexport type Provider<R> = OpenIdClientOidcProvider | OpenIdClientOAuthProvider<R>;\n\nexport interface InstalledProvider<R> {\n readonly provider: Provider<R>;\n readonly metadata: client.ServerMetadata;\n readonly allowedUrls: ReadonlySet<string>;\n}\n\nexport const makeAuthorizationParameters = (\n configuration: {\n readonly protocol: \"oauth\" | \"oidc\";\n readonly authorizationParameters?: Readonly<Record<string, string>>;\n readonly scopes: ReadonlyArray<string>;\n readonly maxAgeSeconds?: number;\n },\n redirectUri: string,\n generated: { readonly state: string; readonly challenge: string; readonly nonce?: string },\n): Record<string, string> => ({\n ...configuration.authorizationParameters,\n response_type: \"code\",\n response_mode: \"query\",\n redirect_uri: redirectUri,\n scope: configuration.scopes.join(\" \"),\n state: generated.state,\n code_challenge: generated.challenge,\n code_challenge_method: \"S256\",\n ...(generated.nonce === undefined ? {} : { nonce: generated.nonce }),\n ...(configuration.protocol === \"oidc\" && configuration.maxAgeSeconds !== undefined\n ? { max_age: String(configuration.maxAgeSeconds) }\n : {}),\n});\n\nconst metadataSchema = Schema.Struct({\n issuer: OAuthIssuer,\n authorization_endpoint: boundedString(2048),\n token_endpoint: boundedString(2048),\n jwks_uri: Schema.optionalKey(boundedString(2048)),\n code_challenge_methods_supported: Schema.optionalKey(Schema.Array(boundedString(64))),\n response_types_supported: Schema.optionalKey(Schema.Array(boundedString(64))),\n id_token_signing_alg_values_supported: Schema.optionalKey(Schema.Array(boundedString(64))),\n token_endpoint_auth_methods_supported: Schema.optionalKey(Schema.Array(boundedString(64))),\n authorization_response_iss_parameter_supported: Schema.optionalKey(Schema.Boolean),\n});\n\nexport const installConfigurations = Effect.fn(\"OpenIdClient.installConfigurations\")(function* <R>(\n input: OpenIdClientOAuthProtocolOptions<R>,\n) {\n const options = yield* Schema.decodeEffect(optionsSchema<R>())(input).pipe(\n Effect.mapError(() => configError(\"provider\")),\n );\n\n // Detach secrets as well as arrays and records before retaining configuration.\n const providers = options.providers.map((provider): Provider<R> => {\n const detached = {\n callbacks: provider.callbacks.map((callback) => ({ ...callback })),\n scopes: [...provider.scopes],\n ...(provider.authorizationParameters === undefined\n ? {}\n : { authorizationParameters: { ...provider.authorizationParameters } }),\n ...(provider.tokenParameters === undefined\n ? {}\n : { tokenParameters: { ...provider.tokenParameters } }),\n authentication:\n provider.authentication.method === \"none\"\n ? { ...provider.authentication }\n : {\n ...provider.authentication,\n secret: Redacted.make(Redacted.value(provider.authentication.secret)),\n },\n };\n\n return provider.protocol === \"oidc\"\n ? { ...provider, ...detached }\n : {\n ...provider,\n ...detached,\n identitySource: {\n ...provider.identitySource,\n ...(provider.identitySource.headers === undefined\n ? {}\n : { headers: { ...provider.identitySource.headers } }),\n },\n };\n });\n\n const fetch: client.CustomFetch =\n options.fetch ??\n ((url, init) =>\n globalThis.fetch(url, {\n ...init,\n body: init.body instanceof Uint8Array ? new Uint8Array(init.body) : init.body,\n }));\n\n yield* Effect.try({\n try: () => {\n const generations = new Set<string>();\n const active = new Set<string>();\n const names = new Set<string>();\n\n for (const provider of providers) {\n const generation = `${provider.provider.length}:${provider.provider}:${provider.configurationGeneration}`;\n\n if (generations.has(generation)) throw configError(\"generation\");\n generations.add(generation);\n names.add(provider.provider);\n if (provider.issuance === \"active\") {\n if (active.has(provider.provider)) throw configError(\"generation\");\n active.add(provider.provider);\n }\n const issuer = endpoint(provider.issuer);\n\n if (provider.issuer.includes(\"?\") || issuer.pathname.includes(\"/.well-known/\"))\n throw configError(\"issuer\");\n if (new Set(provider.scopes).size !== provider.scopes.length)\n throw configError(\"parameters\");\n if ((provider.protocol === \"oidc\") !== provider.scopes.includes(\"openid\"))\n throw configError(\"parameters\");\n checkParameters(provider.authorizationParameters);\n checkParameters(provider.tokenParameters);\n const callbacks = new Set<string>();\n\n for (const callback of provider.callbacks) {\n const url = endpoint(callback.redirectUri);\n\n if (\n url.href !== callback.redirectUri ||\n callback.redirectUri.includes(\"?\") ||\n callbacks.has(callback.callbackId)\n )\n throw configError(\"callback\");\n callbacks.add(callback.callbackId);\n for (const other of providers) {\n if (provider.issuer === other.issuer) continue;\n if (\n provider.responseIssuerMode === \"required\" &&\n other.responseIssuerMode === \"required\"\n )\n continue;\n if (other.callbacks.some((candidate) => candidate.redirectUri === callback.redirectUri))\n throw configError(\"callback\");\n }\n }\n if (provider.protocol === \"oauth\") {\n endpoint(provider.identitySource.url);\n for (const key of Object.keys(provider.identitySource.headers ?? {})) {\n if (forbiddenHeaders.has(key.toLowerCase())) throw configError(\"identity-source\");\n }\n new Headers(provider.identitySource.headers);\n }\n freezeOAuth(provider);\n }\n if (active.size !== names.size) throw configError(\"generation\");\n },\n catch: (error) =>\n Schema.is(OpenIdClientConfigurationError)(error) ? error : configError(\"provider\"),\n });\n const installed: InstalledProvider<R>[] = [];\n\n for (const provider of providers) {\n let raw: client.ServerMetadata;\n\n if (provider.protocol === \"oidc\") {\n const discoveryUrl = new URL(provider.issuer);\n\n discoveryUrl.pathname = `${discoveryUrl.pathname.replace(/\\/$/u, \"\")}/.well-known/openid-configuration`;\n\n const configuration = yield* Effect.tryPromise({\n try: (signal) =>\n client.discovery(\n new URL(provider.issuer),\n provider.clientId,\n {\n id_token_signed_response_alg: provider.idTokenSignedResponseAlg,\n [client.clockSkew]: 0,\n [client.clockTolerance]: 0,\n },\n clientAuthentication(provider.authentication),\n {\n timeout: options.timeoutSeconds,\n execute: [client.enableNonRepudiationChecks],\n [client.customFetch]: boundedFetch(fetch, signal, new Set([discoveryUrl.href])),\n },\n ),\n catch: () => OAuthUnavailable.make({}),\n });\n\n raw = configuration.serverMetadata();\n } else {\n raw = {\n issuer: provider.issuer,\n authorization_endpoint: provider.authorizationEndpoint,\n token_endpoint: provider.tokenEndpoint,\n authorization_response_iss_parameter_supported: provider.responseIssuerMode === \"required\",\n };\n }\n\n // oxlint-disable-next-line no-restricted-properties -- Discovered foreign metadata is not yet validated for this adapter profile.\n const metadata = yield* Schema.decodeUnknownEffect(metadataSchema)(raw).pipe(\n Effect.mapError(() => configError(\"metadata\")),\n );\n\n const allowedUrls = yield* Effect.try({\n try: () => {\n if (metadata.issuer !== provider.issuer) throw configError(\"issuer\");\n if (\n (metadata.authorization_response_iss_parameter_supported === true) !==\n (provider.responseIssuerMode === \"required\")\n )\n throw configError(\"metadata\");\n const auth = endpoint(metadata.authorization_endpoint);\n\n for (const key of auth.searchParams.keys()) {\n if (reserved.has(key.toLowerCase())) throw configError(\"parameters\");\n }\n const token = endpoint(metadata.token_endpoint);\n\n const supportedAuthentication =\n metadata.token_endpoint_auth_methods_supported ??\n (provider.protocol === \"oidc\" ? [\"client_secret_basic\"] : undefined);\n\n if (\n supportedAuthentication !== undefined &&\n !supportedAuthentication.includes(provider.authentication.method)\n )\n throw configError(\"authentication\");\n const urls = new Set([token.href]);\n\n if (provider.protocol === \"oidc\") {\n if (\n !metadata.code_challenge_methods_supported?.includes(\"S256\") ||\n !metadata.response_types_supported?.includes(\"code\") ||\n !metadata.id_token_signing_alg_values_supported?.includes(\"RS256\") ||\n metadata.jwks_uri === undefined\n )\n throw configError(\"metadata\");\n urls.add(endpoint(metadata.jwks_uri).href);\n } else {\n urls.add(endpoint(provider.identitySource.url).href);\n }\n freezeOAuth(metadata);\n\n return urls;\n },\n catch: (error) =>\n Schema.is(OpenIdClientConfigurationError)(error) ? error : configError(\"metadata\"),\n });\n\n const serverMetadata: client.ServerMetadata = {\n ...metadata,\n code_challenge_methods_supported: metadata.code_challenge_methods_supported?.slice(),\n response_types_supported: metadata.response_types_supported?.slice(),\n id_token_signing_alg_values_supported:\n metadata.id_token_signing_alg_values_supported?.slice(),\n token_endpoint_auth_methods_supported:\n metadata.token_endpoint_auth_methods_supported?.slice(),\n };\n\n // The SDK encodes each generated 32-byte state/challenge/nonce in 43 URL-safe characters.\n const placeholder = \"a\".repeat(43);\n\n const authorization = yield* Effect.try({\n try: () => new client.Configuration(serverMetadata, provider.clientId),\n catch: () => configError(\"parameters\"),\n });\n\n for (const callback of provider.callbacks) {\n const url = yield* Effect.try({\n try: () =>\n client.buildAuthorizationUrl(\n authorization,\n makeAuthorizationParameters(provider, callback.redirectUri, {\n state: placeholder,\n challenge: placeholder,\n ...(provider.protocol === \"oidc\" ? { nonce: placeholder } : {}),\n }),\n ),\n catch: () => configError(\"parameters\"),\n });\n\n yield* Schema.decodeEffect(OAuthAuthorizationUrl)(url.href).pipe(\n Effect.mapError(() => configError(\"parameters\")),\n );\n }\n freezeOAuth(serverMetadata);\n installed.push({ provider, metadata: serverMetadata, allowedUrls });\n }\n\n return { installed, fetch, timeoutSeconds: options.timeoutSeconds };\n});\n"],"mappings":";;;;;;;;;AAsBA,MAAM,iBAAiB,YACrB,OAAO,OAAO,MAAM,OAAO,YAAY,CAAC,GAAG,OAAO,YAAY,OAAO,CAAC;AAExE,MAAM,SAAS,OAAO,OACpB,OAAO,OAAO,MAAM,OAAO,UAAU,iCAAiC,CAAC,GACvE,OAAO,OAAO,MAAM,OAAO,YAAY,IAAI,CAAC,CAC9C,CAAC,CAAC,MAAM,OAAO,YAAY,WAAW,OAAO,KAAK,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;AAEvE,MAAM,SAAS,OAAO,kBAAkB,cAAc,IAAI,CAAC;AAE3D,MAAM,iBAAiB,OAAO,MAAM;CAClC,OAAO,OAAO;EAAE,QAAQ,OAAO,QAAQ,qBAAqB;EAAG;CAAO,CAAC;CACvE,OAAO,OAAO;EAAE,QAAQ,OAAO,QAAQ,oBAAoB;EAAG;CAAO,CAAC;CACtE,OAAO,OAAO;EAAE,QAAQ,OAAO,QAAQ,MAAM;EAAG,cAAc,OAAO,QAAQ,IAAI;CAAE,CAAC;AACtF,CAAC;AAED,MAAM,SAAS;CACb,UAAU;CACV,yBAAyB;CACzB,UAAU,OAAO,SAAS,CAAC,UAAU,SAAS,CAAC;CAC/C,QAAQ;CACR,oBAAoB,OAAO,SAAS,CAAC,YAAY,aAAa,CAAC;CAC/D,UAAU,cAAc,IAAI;CAC5B;CACA,WAAW,OAAO,MAChB,OAAO,OAAO;EAAE,YAAY;EAAiB,aAAa;CAAiB,CAAC,CAC9E,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,GAAG,OAAO,YAAY,EAAE,CAAC;CACrD,QAAQ,OAAO,MACb,OAAO,OAAO,MAAM,OAAO,UAAU,mCAAmC,CAAC,CAC3E,CAAC,CAAC,MAAM,OAAO,YAAY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C5C,GAAG;GACH,kCAAkC,SAAS,kCAAkC,MAAM;GACnF,0BAA0B,SAAS,0BAA0B,MAAM;GACnE,uCACE,SAAS,uCAAuC,MAAM;GACxD,uCACE,SAAS,uCAAuC,MAAM;EAC1D;EAGA,MAAM,cAAc,IAAI,OAAO,EAAE;EAEjC,MAAM,gBAAgB,OAAO,OAAO,IAAI;GACtC,WAAW,IAAI,OAAO,cAAc,gBAAgB,SAAS,QAAQ;GACrE,aAAa,YAAY,YAAY;EACvC,CAAC;EAED,KAAK,MAAM,YAAY,SAAS,WAAW;GACzC,MAAM,MAAM,OAAO,OAAO,IAAI;IAC5B,WACE,OAAO,sBACL,eACA,4BAA4B,UAAU,SAAS,aAAa;KAC1D,OAAO;KACP,WAAW;KACX,GAAI,SAAS,aAAa,SAAS,EAAE,OAAO,YAAY,IAAI,CAAC;IAC/D,CAAC,CACH;IACF,aAAa,YAAY,YAAY;GACvC,CAAC;GAED,OAAO,OAAO,aAAa,qBAAqB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAC1D,OAAO,eAAe,YAAY,YAAY,CAAC,CACjD;EACF;EACA,YAAY,cAAc;EAC1B,UAAU,KAAK;GAAE;GAAU,UAAU;GAAgB;EAAY,CAAC;CACpE;CAEA,OAAO;EAAE;EAAW;EAAO,gBAAgB,QAAQ;CAAe;AACpE,CAAC"}
1
+ {"version":3,"file":"configuration.mjs","names":[],"sources":["../../../src/oauth/openid-client/configuration.ts"],"sourcesContent":["import { Effect, Predicate, Redacted, Schema } from \"effect\";\nimport * as client from \"openid-client\";\n\nimport { OAuthProviderKey } from \"../schema\";\nimport { OAuthUnavailable } from \"../signInErrors\";\nimport {\n OAuthAuthorizationUrl,\n OAuthCallbackId,\n OAuthGeneration,\n OAuthIssuer,\n OAuthRedirectUri,\n} from \"../signInModels\";\nimport { freezeOAuth } from \"../signInSnapshot\";\nimport { TokenCompatibility, tokenCompatibility } from \"./compatibility\";\nimport {\n OpenIdClientConfigurationError,\n type OpenIdClientAuthentication,\n type OpenIdClientOAuthProvider,\n type OpenIdClientOAuthProtocolOptions,\n type OpenIdClientOidcProvider,\n} from \"./models\";\nimport { boundedFetch } from \"./transport\";\n\nconst boundedString = (maximum: number) =>\n Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(maximum));\n\nconst fields = Schema.Record(\n Schema.String.check(Schema.isPattern(/^[A-Za-z][A-Za-z0-9._~-]{0,63}$/)),\n Schema.String.check(Schema.isMaxLength(2048)),\n).check(Schema.makeFilter((record) => Object.keys(record).length <= 16));\n\nconst secret = Schema.RedactedFromValue(boundedString(4096));\n\nconst authentication = Schema.Union([\n Schema.Struct({ method: Schema.Literal(\"client_secret_basic\"), secret }),\n Schema.Struct({ method: Schema.Literal(\"client_secret_post\"), secret }),\n Schema.Struct({ method: Schema.Literal(\"none\"), publicClient: Schema.Literal(true) }),\n]);\n\nconst common = {\n provider: OAuthProviderKey,\n configurationGeneration: OAuthGeneration,\n issuance: Schema.Literals([\"active\", \"retired\"]),\n issuer: OAuthIssuer,\n responseIssuerMode: Schema.Literals([\"required\", \"unsupported\"]),\n clientId: boundedString(1024),\n authentication,\n callbacks: Schema.Array(\n Schema.Struct({ callbackId: OAuthCallbackId, redirectUri: OAuthRedirectUri }),\n ).check(Schema.isMinLength(1), Schema.isMaxLength(16)),\n scopes: Schema.Array(\n Schema.String.check(Schema.isPattern(/^[\\x21\\x23-\\x5b\\x5d-\\x7e]{1,128}$/)),\n ).check(Schema.isMaxLength(32)),\n authorizationParameters: Schema.optionalKey(fields),\n tokenParameters: Schema.optionalKey(fields),\n};\n\nconst optionsSchema = <R>() =>\n Schema.toType(\n Schema.Struct({\n providers: Schema.Array(\n Schema.Union([\n Schema.Struct({\n ...common,\n protocol: Schema.Literal(\"oidc\"),\n idTokenSignedResponseAlg: Schema.Literal(\"RS256\"),\n maxAgeSeconds: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: 86400 })),\n ),\n }),\n Schema.Struct({\n ...common,\n protocol: Schema.Literal(\"oauth\"),\n [tokenCompatibility]: Schema.optionalKey(TokenCompatibility),\n authorizationEndpoint: boundedString(2048),\n tokenEndpoint: boundedString(2048),\n pkceS256: Schema.Literal(true),\n identitySource: Schema.Struct({\n url: boundedString(2048),\n headers: Schema.optionalKey(fields),\n // A configured function is trusted application code; its result has a separate schema boundary.\n decodeIdentity: Schema.declare<\n OpenIdClientOAuthProvider<R>[\"identitySource\"][\"decodeIdentity\"]\n >(\n (\n input,\n ): input is OpenIdClientOAuthProvider<R>[\"identitySource\"][\"decodeIdentity\"] =>\n Predicate.isFunction(input),\n ),\n }),\n }),\n ]),\n ).check(Schema.isMinLength(1), Schema.isMaxLength(64)),\n timeoutSeconds: Schema.Finite.check(Schema.isBetween({ minimum: 1, maximum: 30 })),\n fetch: Schema.optionalKey(\n Schema.declare<client.CustomFetch>((input): input is client.CustomFetch =>\n Predicate.isFunction(input),\n ),\n ),\n }),\n );\n\nconst reserved = new Set([\n \"client_id\",\n \"client_secret\",\n \"client_assertion\",\n \"client_assertion_type\",\n \"redirect_uri\",\n \"response_type\",\n \"response_mode\",\n \"state\",\n \"code\",\n \"code_verifier\",\n \"code_challenge\",\n \"code_challenge_method\",\n \"nonce\",\n \"scope\",\n \"iss\",\n \"grant_type\",\n \"max_age\",\n \"request\",\n \"request_uri\",\n \"authorization_details\",\n \"id_token_hint\",\n \"login_hint\",\n \"login_hint_token\",\n \"subject_token\",\n \"subject_token_type\",\n \"actor_token\",\n \"actor_token_type\",\n \"requested_token_type\",\n]);\n\nconst forbiddenHeaders = new Set([\n \"authorization\",\n \"proxy-authorization\",\n \"cookie\",\n \"host\",\n \"content-length\",\n \"content-type\",\n \"transfer-encoding\",\n \"connection\",\n \"upgrade\",\n \"trailer\",\n \"te\",\n]);\n\nconst configError = (reason: OpenIdClientConfigurationError[\"reason\"]) =>\n OpenIdClientConfigurationError.make({ reason });\n\nexport const endpoint = (value: string): URL => {\n const url = new URL(value);\n\n if (\n url.protocol !== \"https:\" ||\n url.username !== \"\" ||\n url.password !== \"\" ||\n value.includes(\"#\") ||\n // oxlint-disable-next-line no-control-regex -- Reject ambiguous protocol URL control characters.\n /[\\s\\\\\\u0000-\\u001f\\u007f]/u.test(value)\n )\n throw configError(\"metadata\");\n\n return url;\n};\n\nconst checkParameters = (parameters: Readonly<Record<string, string>> | undefined) => {\n for (const key of Object.keys(parameters ?? {})) {\n if (reserved.has(key.toLowerCase())) throw configError(\"parameters\");\n }\n};\n\nexport const clientAuthentication = (\n authentication: OpenIdClientAuthentication,\n): client.ClientAuth => {\n switch (authentication.method) {\n case \"client_secret_basic\":\n return client.ClientSecretBasic(Redacted.value(authentication.secret));\n case \"client_secret_post\":\n return client.ClientSecretPost(Redacted.value(authentication.secret));\n case \"none\":\n return client.None();\n }\n};\n\nexport type Provider<R> = OpenIdClientOidcProvider | OpenIdClientOAuthProvider<R>;\n\nexport interface InstalledProvider<R> {\n readonly provider: Provider<R>;\n readonly metadata: client.ServerMetadata;\n readonly allowedUrls: ReadonlySet<string>;\n}\n\nexport const makeAuthorizationParameters = (\n configuration: {\n readonly protocol: \"oauth\" | \"oidc\";\n readonly authorizationParameters?: Readonly<Record<string, string>>;\n readonly scopes: ReadonlyArray<string>;\n readonly maxAgeSeconds?: number;\n },\n redirectUri: string,\n generated: { readonly state: string; readonly challenge: string; readonly nonce?: string },\n): Record<string, string> => ({\n ...configuration.authorizationParameters,\n response_type: \"code\",\n response_mode: \"query\",\n redirect_uri: redirectUri,\n scope: configuration.scopes.join(\" \"),\n state: generated.state,\n code_challenge: generated.challenge,\n code_challenge_method: \"S256\",\n ...(generated.nonce === undefined ? {} : { nonce: generated.nonce }),\n ...(configuration.protocol === \"oidc\" && configuration.maxAgeSeconds !== undefined\n ? { max_age: String(configuration.maxAgeSeconds) }\n : {}),\n});\n\nconst metadataSchema = Schema.Struct({\n issuer: OAuthIssuer,\n authorization_endpoint: boundedString(2048),\n token_endpoint: boundedString(2048),\n jwks_uri: Schema.optionalKey(boundedString(2048)),\n code_challenge_methods_supported: Schema.optionalKey(Schema.Array(boundedString(64))),\n response_types_supported: Schema.optionalKey(Schema.Array(boundedString(64))),\n id_token_signing_alg_values_supported: Schema.optionalKey(Schema.Array(boundedString(64))),\n token_endpoint_auth_methods_supported: Schema.optionalKey(Schema.Array(boundedString(64))),\n authorization_response_iss_parameter_supported: Schema.optionalKey(Schema.Boolean),\n});\n\nexport const installConfigurations = Effect.fn(\"OpenIdClient.installConfigurations\")(function* <R>(\n input: OpenIdClientOAuthProtocolOptions<R>,\n) {\n const options = yield* Schema.decodeEffect(optionsSchema<R>())(input).pipe(\n Effect.mapError(() => configError(\"provider\")),\n );\n\n // Detach secrets as well as arrays and records before retaining configuration.\n const providers = options.providers.map((provider): Provider<R> => {\n const detached = {\n callbacks: provider.callbacks.map((callback) => ({ ...callback })),\n scopes: [...provider.scopes],\n ...(provider.authorizationParameters === undefined\n ? {}\n : { authorizationParameters: { ...provider.authorizationParameters } }),\n ...(provider.tokenParameters === undefined\n ? {}\n : { tokenParameters: { ...provider.tokenParameters } }),\n authentication:\n provider.authentication.method === \"none\"\n ? { ...provider.authentication }\n : {\n ...provider.authentication,\n secret: Redacted.make(Redacted.value(provider.authentication.secret)),\n },\n };\n\n return provider.protocol === \"oidc\"\n ? { ...provider, ...detached }\n : {\n ...provider,\n ...detached,\n identitySource: {\n ...provider.identitySource,\n ...(provider.identitySource.headers === undefined\n ? {}\n : { headers: { ...provider.identitySource.headers } }),\n },\n };\n });\n\n const fetch: client.CustomFetch =\n options.fetch ??\n ((url, init) =>\n globalThis.fetch(url, {\n ...init,\n body: init.body instanceof Uint8Array ? new Uint8Array(init.body) : init.body,\n }));\n\n yield* Effect.try({\n try: () => {\n const generations = new Set<string>();\n const active = new Set<string>();\n const names = new Set<string>();\n\n for (const provider of providers) {\n const generation = `${provider.provider.length}:${provider.provider}:${provider.configurationGeneration}`;\n\n if (generations.has(generation)) throw configError(\"generation\");\n generations.add(generation);\n names.add(provider.provider);\n if (provider.issuance === \"active\") {\n if (active.has(provider.provider)) throw configError(\"generation\");\n active.add(provider.provider);\n }\n const issuer = endpoint(provider.issuer);\n\n if (provider.issuer.includes(\"?\") || issuer.pathname.includes(\"/.well-known/\"))\n throw configError(\"issuer\");\n if (new Set(provider.scopes).size !== provider.scopes.length)\n throw configError(\"parameters\");\n if ((provider.protocol === \"oidc\") !== provider.scopes.includes(\"openid\"))\n throw configError(\"parameters\");\n checkParameters(provider.authorizationParameters);\n checkParameters(provider.tokenParameters);\n const callbacks = new Set<string>();\n\n for (const callback of provider.callbacks) {\n const url = endpoint(callback.redirectUri);\n\n if (\n url.href !== callback.redirectUri ||\n callback.redirectUri.includes(\"?\") ||\n callbacks.has(callback.callbackId)\n )\n throw configError(\"callback\");\n callbacks.add(callback.callbackId);\n for (const other of providers) {\n if (provider.issuer === other.issuer) continue;\n if (\n provider.responseIssuerMode === \"required\" &&\n other.responseIssuerMode === \"required\"\n )\n continue;\n if (other.callbacks.some((candidate) => candidate.redirectUri === callback.redirectUri))\n throw configError(\"callback\");\n }\n }\n if (provider.protocol === \"oauth\") {\n endpoint(provider.identitySource.url);\n for (const key of Object.keys(provider.identitySource.headers ?? {})) {\n if (forbiddenHeaders.has(key.toLowerCase())) throw configError(\"identity-source\");\n }\n new Headers(provider.identitySource.headers);\n }\n freezeOAuth(provider);\n }\n if (active.size !== names.size) throw configError(\"generation\");\n },\n catch: (error) =>\n Schema.is(OpenIdClientConfigurationError)(error) ? error : configError(\"provider\"),\n });\n const installed: InstalledProvider<R>[] = [];\n\n for (const provider of providers) {\n let raw: client.ServerMetadata;\n\n if (provider.protocol === \"oidc\") {\n const discoveryUrl = new URL(provider.issuer);\n\n discoveryUrl.pathname = `${discoveryUrl.pathname.replace(/\\/$/u, \"\")}/.well-known/openid-configuration`;\n\n const configuration = yield* Effect.tryPromise({\n try: (signal) =>\n client.discovery(\n new URL(provider.issuer),\n provider.clientId,\n {\n id_token_signed_response_alg: provider.idTokenSignedResponseAlg,\n [client.clockSkew]: 0,\n [client.clockTolerance]: 0,\n },\n clientAuthentication(provider.authentication),\n {\n timeout: options.timeoutSeconds,\n execute: [client.enableNonRepudiationChecks],\n [client.customFetch]: boundedFetch(fetch, signal, new Set([discoveryUrl.href])),\n },\n ),\n catch: () => OAuthUnavailable.make({}),\n });\n\n raw = configuration.serverMetadata();\n } else {\n raw = {\n issuer: provider.issuer,\n authorization_endpoint: provider.authorizationEndpoint,\n token_endpoint: provider.tokenEndpoint,\n authorization_response_iss_parameter_supported: provider.responseIssuerMode === \"required\",\n };\n }\n\n // oxlint-disable-next-line no-restricted-properties -- Discovered foreign metadata is not yet validated for this adapter profile.\n const metadata = yield* Schema.decodeUnknownEffect(metadataSchema)(raw).pipe(\n Effect.mapError(() => configError(\"metadata\")),\n );\n\n const allowedUrls = yield* Effect.try({\n try: () => {\n if (metadata.issuer !== provider.issuer) throw configError(\"issuer\");\n if (\n (metadata.authorization_response_iss_parameter_supported === true) !==\n (provider.responseIssuerMode === \"required\")\n )\n throw configError(\"metadata\");\n const auth = endpoint(metadata.authorization_endpoint);\n\n for (const key of auth.searchParams.keys()) {\n if (reserved.has(key.toLowerCase())) throw configError(\"parameters\");\n }\n const token = endpoint(metadata.token_endpoint);\n\n const supportedAuthentication =\n metadata.token_endpoint_auth_methods_supported ??\n (provider.protocol === \"oidc\" ? [\"client_secret_basic\"] : undefined);\n\n if (\n supportedAuthentication !== undefined &&\n !supportedAuthentication.includes(provider.authentication.method)\n )\n throw configError(\"authentication\");\n const urls = new Set([token.href]);\n\n if (provider.protocol === \"oidc\") {\n if (\n !metadata.code_challenge_methods_supported?.includes(\"S256\") ||\n !metadata.response_types_supported?.includes(\"code\") ||\n !metadata.id_token_signing_alg_values_supported?.includes(\"RS256\") ||\n metadata.jwks_uri === undefined\n )\n throw configError(\"metadata\");\n urls.add(endpoint(metadata.jwks_uri).href);\n } else {\n urls.add(endpoint(provider.identitySource.url).href);\n }\n freezeOAuth(metadata);\n\n return urls;\n },\n catch: (error) =>\n Schema.is(OpenIdClientConfigurationError)(error) ? error : configError(\"metadata\"),\n });\n\n const serverMetadata: client.ServerMetadata = {\n ...metadata,\n code_challenge_methods_supported: metadata.code_challenge_methods_supported?.slice(),\n response_types_supported: metadata.response_types_supported?.slice(),\n id_token_signing_alg_values_supported:\n metadata.id_token_signing_alg_values_supported?.slice(),\n token_endpoint_auth_methods_supported:\n metadata.token_endpoint_auth_methods_supported?.slice(),\n };\n\n // The SDK encodes each generated 32-byte state/challenge/nonce in 43 URL-safe characters.\n const placeholder = \"a\".repeat(43);\n\n const authorization = yield* Effect.try({\n try: () => new client.Configuration(serverMetadata, provider.clientId),\n catch: () => configError(\"parameters\"),\n });\n\n for (const callback of provider.callbacks) {\n const url = yield* Effect.try({\n try: () =>\n client.buildAuthorizationUrl(\n authorization,\n makeAuthorizationParameters(provider, callback.redirectUri, {\n state: placeholder,\n challenge: placeholder,\n ...(provider.protocol === \"oidc\" ? { nonce: placeholder } : {}),\n }),\n ),\n catch: () => configError(\"parameters\"),\n });\n\n yield* Schema.decodeEffect(OAuthAuthorizationUrl)(url.href).pipe(\n Effect.mapError(() => configError(\"parameters\")),\n );\n }\n freezeOAuth(serverMetadata);\n installed.push({ provider, metadata: serverMetadata, allowedUrls });\n }\n\n return { installed, fetch, timeoutSeconds: options.timeoutSeconds };\n});\n"],"mappings":";;;;;;;;;;AAuBA,MAAM,iBAAiB,YACrB,OAAO,OAAO,MAAM,OAAO,YAAY,CAAC,GAAG,OAAO,YAAY,OAAO,CAAC;AAExE,MAAM,SAAS,OAAO,OACpB,OAAO,OAAO,MAAM,OAAO,UAAU,iCAAiC,CAAC,GACvE,OAAO,OAAO,MAAM,OAAO,YAAY,IAAI,CAAC,CAC9C,CAAC,CAAC,MAAM,OAAO,YAAY,WAAW,OAAO,KAAK,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;AAEvE,MAAM,SAAS,OAAO,kBAAkB,cAAc,IAAI,CAAC;AAE3D,MAAM,iBAAiB,OAAO,MA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YAAY,IAAI,CAAC;IAC/D,CAAC,CACH;IACF,aAAa,YAAY,YAAY;GACvC,CAAC;GAED,OAAO,OAAO,aAAa,qBAAqB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,KAC1D,OAAO,eAAe,YAAY,YAAY,CAAC,CACjD;EACF;EACA,YAAY,cAAc;EAC1B,UAAU,KAAK;GAAE;GAAU,UAAU;GAAgB;EAAY,CAAC;CACpE;CAEA,OAAO;EAAE;EAAW;EAAO,gBAAgB,QAAQ;CAAe;AACpE,CAAC"}
@@ -3,9 +3,9 @@ import { OAuthUnavailable } from "../../signInErrors.mjs";
3
3
  import "../../signInModels.mjs";
4
4
  import "../../connectedModels.mjs";
5
5
  import { OAuthConnectedProtocol } from "../../OAuthConnectedProtocol.mjs";
6
- import { OpenIdClientConfigurationError } from "../models.mjs";
7
6
  import { OpenIdClientConnectedProtocolOptions } from "./models.mjs";
8
7
  import "../compatibility.mjs";
8
+ import { OpenIdClientConfigurationError } from "../models.mjs";
9
9
  import "../ProviderRevocation.mjs";
10
10
  import { DateTime, Effect, Layer } from "effect";
11
11
  //#region src/oauth/openid-client/connected/protocol.d.ts
@@ -1,5 +1,6 @@
1
1
  import { OAuthProtocolRejected } from "../signInErrors.mjs";
2
2
  import { OAuthProtocolConfiguration, OAuthVerifiedExternalIdentity } from "../signInModels.mjs";
3
+ import { TokenCompatibility, tokenCompatibility } from "./compatibility.mjs";
3
4
  import { Effect, Redacted, Schema } from "effect";
4
5
  import { CustomFetch } from "openid-client";
5
6
  //#region src/oauth/openid-client/models.d.ts
@@ -44,6 +45,8 @@ interface OpenIdClientOidcProvider extends ProviderGeneration {
44
45
  readonly maxAgeSeconds?: number;
45
46
  }
46
47
  interface OpenIdClientOAuthProvider<R = never> extends ProviderGeneration {
48
+ /** @internal First-party provider behavior, retained by the configuration codec. */
49
+ readonly [tokenCompatibility]?: TokenCompatibility;
47
50
  readonly protocol: "oauth";
48
51
  readonly authorizationEndpoint: string;
49
52
  readonly tokenEndpoint: string;
@@ -1 +1 @@
1
- {"version":3,"file":"models.mjs","names":[],"sources":["../../../src/oauth/openid-client/models.ts"],"sourcesContent":["import { type Effect, type Redacted, Schema } from \"effect\";\nimport type { CustomFetch } from \"openid-client\";\n\nimport type { OAuthProtocolRejected } from \"../signInErrors\";\nimport type { OAuthProtocolConfiguration, OAuthVerifiedExternalIdentity } from \"../signInModels\";\n\nexport class OpenIdClientConfigurationError extends Schema.TaggedError<OpenIdClientConfigurationError>()(\n \"OpenIdClientConfigurationError\",\n {\n reason: Schema.Literals([\n \"provider\",\n \"generation\",\n \"issuer\",\n \"callback\",\n \"authentication\",\n \"parameters\",\n \"metadata\",\n \"identity-source\",\n ]),\n },\n) {}\n\nexport type OpenIdClientAuthentication =\n | { readonly method: \"client_secret_basic\"; readonly secret: Redacted.Redacted<string> }\n | { readonly method: \"client_secret_post\"; readonly secret: Redacted.Redacted<string> }\n | { readonly method: \"none\"; readonly publicClient: true };\n\nexport interface PlainOAuthIdentity {\n readonly subject: string;\n readonly profile?: OAuthVerifiedExternalIdentity[\"profile\"];\n}\n\ninterface ProviderGeneration {\n readonly provider: OAuthProtocolConfiguration[\"provider\"];\n readonly configurationGeneration: OAuthProtocolConfiguration[\"configurationGeneration\"];\n readonly issuance: \"active\" | \"retired\";\n /** Preserve this exact issuer identifier, including an optional trailing slash. */\n readonly issuer: OAuthProtocolConfiguration[\"issuer\"];\n readonly responseIssuerMode: OAuthProtocolConfiguration[\"responseIssuerMode\"];\n readonly clientId: string;\n readonly authentication: OpenIdClientAuthentication;\n readonly callbacks: ReadonlyArray<{\n readonly callbackId: OAuthProtocolConfiguration[\"callbackId\"];\n readonly redirectUri: OAuthProtocolConfiguration[\"redirectUri\"];\n }>;\n readonly scopes: ReadonlyArray<string>;\n readonly authorizationParameters?: Readonly<Record<string, string>>;\n readonly tokenParameters?: Readonly<Record<string, string>>;\n}\n\nexport interface OpenIdClientOidcProvider extends ProviderGeneration {\n readonly protocol: \"oidc\";\n readonly idTokenSignedResponseAlg: \"RS256\";\n readonly maxAgeSeconds?: number;\n}\n\nexport interface OpenIdClientOAuthProvider<R = never> extends ProviderGeneration {\n readonly protocol: \"oauth\";\n readonly authorizationEndpoint: string;\n readonly tokenEndpoint: string;\n readonly pkceS256: true;\n readonly identitySource: {\n readonly url: string;\n readonly headers?: Readonly<Record<string, string>>;\n /** Receives only the freshly fetched authenticated identity body, never a grant. */\n readonly decodeIdentity: (\n body: unknown,\n ) => Effect.Effect<PlainOAuthIdentity, OAuthProtocolRejected, R>;\n };\n}\n\nexport interface OpenIdClientOAuthProtocolOptions<R = never> {\n readonly providers: ReadonlyArray<OpenIdClientOidcProvider | OpenIdClientOAuthProvider<R>>;\n /** Per-request deadline; the method separately limits the complete exchange. */\n readonly timeoutSeconds: number;\n /** Trusted server transport. Must honor abort and must not retry or log credentials. */\n readonly fetch?: CustomFetch;\n}\n"],"mappings":";;AAMA,IAAa,iCAAb,cAAoD,OAAO,YAA4C,CAAC,CACtG,kCACA,EACE,QAAQ,OAAO,SAAS;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,EACH,CACF,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"models.mjs","names":[],"sources":["../../../src/oauth/openid-client/models.ts"],"sourcesContent":["import { type Effect, type Redacted, Schema } from \"effect\";\nimport type { CustomFetch } from \"openid-client\";\n\nimport type { OAuthProtocolRejected } from \"../signInErrors\";\nimport type { OAuthProtocolConfiguration, OAuthVerifiedExternalIdentity } from \"../signInModels\";\nimport type { TokenCompatibility, tokenCompatibility } from \"./compatibility\";\n\nexport class OpenIdClientConfigurationError extends Schema.TaggedError<OpenIdClientConfigurationError>()(\n \"OpenIdClientConfigurationError\",\n {\n reason: Schema.Literals([\n \"provider\",\n \"generation\",\n \"issuer\",\n \"callback\",\n \"authentication\",\n \"parameters\",\n \"metadata\",\n \"identity-source\",\n ]),\n },\n) {}\n\nexport type OpenIdClientAuthentication =\n | { readonly method: \"client_secret_basic\"; readonly secret: Redacted.Redacted<string> }\n | { readonly method: \"client_secret_post\"; readonly secret: Redacted.Redacted<string> }\n | { readonly method: \"none\"; readonly publicClient: true };\n\nexport interface PlainOAuthIdentity {\n readonly subject: string;\n readonly profile?: OAuthVerifiedExternalIdentity[\"profile\"];\n}\n\ninterface ProviderGeneration {\n readonly provider: OAuthProtocolConfiguration[\"provider\"];\n readonly configurationGeneration: OAuthProtocolConfiguration[\"configurationGeneration\"];\n readonly issuance: \"active\" | \"retired\";\n /** Preserve this exact issuer identifier, including an optional trailing slash. */\n readonly issuer: OAuthProtocolConfiguration[\"issuer\"];\n readonly responseIssuerMode: OAuthProtocolConfiguration[\"responseIssuerMode\"];\n readonly clientId: string;\n readonly authentication: OpenIdClientAuthentication;\n readonly callbacks: ReadonlyArray<{\n readonly callbackId: OAuthProtocolConfiguration[\"callbackId\"];\n readonly redirectUri: OAuthProtocolConfiguration[\"redirectUri\"];\n }>;\n readonly scopes: ReadonlyArray<string>;\n readonly authorizationParameters?: Readonly<Record<string, string>>;\n readonly tokenParameters?: Readonly<Record<string, string>>;\n}\n\nexport interface OpenIdClientOidcProvider extends ProviderGeneration {\n readonly protocol: \"oidc\";\n readonly idTokenSignedResponseAlg: \"RS256\";\n readonly maxAgeSeconds?: number;\n}\n\nexport interface OpenIdClientOAuthProvider<R = never> extends ProviderGeneration {\n /** @internal First-party provider behavior, retained by the configuration codec. */\n readonly [tokenCompatibility]?: TokenCompatibility;\n readonly protocol: \"oauth\";\n readonly authorizationEndpoint: string;\n readonly tokenEndpoint: string;\n readonly pkceS256: true;\n readonly identitySource: {\n readonly url: string;\n readonly headers?: Readonly<Record<string, string>>;\n /** Receives only the freshly fetched authenticated identity body, never a grant. */\n readonly decodeIdentity: (\n body: unknown,\n ) => Effect.Effect<PlainOAuthIdentity, OAuthProtocolRejected, R>;\n };\n}\n\nexport interface OpenIdClientOAuthProtocolOptions<R = never> {\n readonly providers: ReadonlyArray<OpenIdClientOidcProvider | OpenIdClientOAuthProvider<R>>;\n /** Per-request deadline; the method separately limits the complete exchange. */\n readonly timeoutSeconds: number;\n /** Trusted server transport. Must honor abort and must not retry or log credentials. */\n readonly fetch?: CustomFetch;\n}\n"],"mappings":";;AAOA,IAAa,iCAAb,cAAoD,OAAO,YAA4C,CAAC,CACtG,kCACA,EACE,QAAQ,OAAO,SAAS;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,EACH,CACF,CAAC,CAAC,CAAC"}
@@ -5,7 +5,6 @@ import { OAuthProtocolRejected, OAuthRejected, OAuthUnavailable } from "../signI
5
5
  import { OAuthCallbackId, OAuthCodeResponse, OAuthProtocolConfiguration, OAuthProtocolPreparation, OAuthTransactionSecrets, OAuthVerifiedExternalIdentity } from "../signInModels.mjs";
6
6
  import { OAuthProtocol } from "../OAuthProtocol.mjs";
7
7
  import { OpenIdClientConfigurationError, OpenIdClientOAuthProtocolOptions } from "./models.mjs";
8
- import "./compatibility.mjs";
9
8
  import { DateTime, Effect, Layer } from "effect";
10
9
  //#region src/oauth/openid-client/protocol.d.ts
11
10
  declare const makeOpenIdClientOAuthProtocol: <R = never>(options: OpenIdClientOAuthProtocolOptions<R>) => Effect.Effect<{
@@ -5,7 +5,7 @@ import { OAuthCallbackId, OAuthCodeResponse, OAuthDisplayProfile, OAuthProtocolC
5
5
  import { OAuthProtocolRejected, OAuthRejected, OAuthUnavailable } from "../signInErrors.mjs";
6
6
  import { snapshotOAuth } from "../signInSnapshot.mjs";
7
7
  import { OAuthProtocol } from "../OAuthProtocol.mjs";
8
- import { DefiniteTokenRejection } from "./compatibility.mjs";
8
+ import { DefiniteTokenRejection, tokenCompatibility } from "./compatibility.mjs";
9
9
  import { boundedFetch } from "./transport.mjs";
10
10
  import { clientAuthentication, installConfigurations, makeAuthorizationParameters } from "./configuration.mjs";
11
11
  import { Cause, DateTime, Effect, Layer, Redacted, Schema } from "effect";
@@ -55,8 +55,9 @@ const grantError = (error) => {
55
55
  if (error instanceof client.ResponseBodyError && error.status === 400 && error.error === "invalid_grant") return rejected();
56
56
  return unavailable();
57
57
  };
58
- const privateConfiguration = (entry, timeout, fetch, signal, compatibility) => {
58
+ const privateConfiguration = (entry, timeout, fetch, signal) => {
59
59
  const provider = entry.provider;
60
+ const compatibility = provider.protocol === "oauth" ? provider[tokenCompatibility] : void 0;
60
61
  const configuration = new client.Configuration(entry.metadata, provider.clientId, {
61
62
  [client.clockSkew]: 0,
62
63
  [client.clockTolerance]: 0,
@@ -85,7 +86,7 @@ const privateConfiguration = (entry, timeout, fetch, signal, compatibility) => {
85
86
  if (provider.protocol === "oidc") client.enableNonRepudiationChecks(configuration);
86
87
  return configuration;
87
88
  };
88
- const makeOAuthProtocolWithCompatibility = Effect.fn("makeOpenIdClientOAuthProtocol")(function* (options, compatibility) {
89
+ const makeOpenIdClientOAuthProtocol = Effect.fn("makeOpenIdClientOAuthProtocol")(function* (options) {
89
90
  const context = yield* Effect.context();
90
91
  const { installed, fetch, timeoutSeconds } = yield* installConfigurations(options);
91
92
  const prepareAuthorization = Effect.fn("OpenIdClient.prepareAuthorization")(function* (input) {
@@ -96,7 +97,7 @@ const makeOAuthProtocolWithCompatibility = Effect.fn("makeOpenIdClientOAuthProto
96
97
  if (entry === void 0 || provider === void 0 || callback === void 0) return yield* OAuthRejected.make({});
97
98
  const result = yield* Effect.tryPromise({
98
99
  try: async (signal) => {
99
- const configuration = privateConfiguration(entry, timeoutSeconds, fetch, signal, compatibility);
100
+ const configuration = privateConfiguration(entry, timeoutSeconds, fetch, signal);
100
101
  const state = client.randomState();
101
102
  const verifier = client.randomPKCECodeVerifier();
102
103
  const nonce = provider.protocol === "oidc" ? client.randomNonce() : void 0;
@@ -143,7 +144,7 @@ const makeOAuthProtocolWithCompatibility = Effect.fn("makeOpenIdClientOAuthProto
143
144
  if (startedAt < 0 || startedAt > DateTime.toEpochMillis(yield* DateTime.now)) return yield* rejected();
144
145
  const exchanged = yield* Effect.tryPromise({
145
146
  try: async (signal) => {
146
- const configuration = privateConfiguration(entry, timeoutSeconds, fetch, signal, compatibility);
147
+ const configuration = privateConfiguration(entry, timeoutSeconds, fetch, signal);
147
148
  const currentUrl = new URL(saved.redirectUri);
148
149
  currentUrl.searchParams.set("code", Redacted.value(request.response.code));
149
150
  currentUrl.searchParams.set("state", Redacted.value(request.response.state));
@@ -210,9 +211,8 @@ const makeOAuthProtocolWithCompatibility = Effect.fn("makeOpenIdClientOAuthProto
210
211
  exchangeVerifiedIdentity: (input) => unavailableOnDefect(exchangeVerifiedIdentity(input))
211
212
  });
212
213
  }, unavailableOnDefect);
213
- const makeOpenIdClientOAuthProtocol = (options) => makeOAuthProtocolWithCompatibility(options);
214
214
  const openIdClientOAuthProtocolLayer = (options) => Layer.effect(OAuthProtocol, makeOpenIdClientOAuthProtocol(options));
215
215
  //#endregion
216
- export { makeOAuthProtocolWithCompatibility, makeOpenIdClientOAuthProtocol, openIdClientOAuthProtocolLayer };
216
+ export { makeOpenIdClientOAuthProtocol, openIdClientOAuthProtocolLayer };
217
217
 
218
218
  //# sourceMappingURL=protocol.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.mjs","names":[],"sources":["../../../src/oauth/openid-client/protocol.ts"],"sourcesContent":["import { Cause, DateTime, Effect, Layer, Redacted, Schema } from \"effect\";\nimport * as client from \"openid-client\";\n\nimport { reportAuthFailure } from \"../../internal/diagnostics\";\nimport { RequestBindingFlowId } from \"../../operations/requestBinding\";\nimport { OAuthProtocol } from \"../OAuthProtocol\";\nimport { OAuthProviderKey } from \"../schema\";\nimport { OAuthProtocolRejected, OAuthRejected, OAuthUnavailable } from \"../signInErrors\";\nimport {\n OAuthCallbackId,\n OAuthCodeResponse,\n OAuthDisplayProfile,\n OAuthProtocolConfiguration,\n OAuthProtocolPreparation,\n OAuthTransactionSecrets,\n OAuthVerifiedExternalIdentity,\n} from \"../signInModels\";\nimport { snapshotOAuth } from \"../signInSnapshot\";\nimport { DefiniteTokenRejection, type TokenCompatibility } from \"./compatibility\";\nimport {\n clientAuthentication,\n installConfigurations,\n makeAuthorizationParameters,\n type InstalledProvider,\n} from \"./configuration\";\nimport {\n type OpenIdClientConfigurationError,\n type OpenIdClientOAuthProtocolOptions,\n} from \"./models\";\nimport { boundedFetch } from \"./transport\";\n\nconst beginInput = Schema.Struct({\n provider: OAuthProviderKey,\n callbackId: OAuthCallbackId,\n flowId: RequestBindingFlowId,\n});\n\nconst exchangeInput = Schema.toType(\n Schema.Struct({\n configuration: OAuthProtocolConfiguration,\n response: OAuthCodeResponse,\n secrets: OAuthTransactionSecrets,\n verificationStartedAt: Schema.DateTimeUtcFromMillis,\n }),\n);\n\nconst numericDate = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 8640000000000 }));\n\nconst claimsSchema = Schema.Struct({\n iss: Schema.String,\n sub: OAuthVerifiedExternalIdentity.fields.identity.fields.subject,\n aud: Schema.Union([\n Schema.String,\n Schema.Array(Schema.String).check(Schema.isMinLength(1), Schema.isMaxLength(1)),\n ]),\n azp: Schema.optionalKey(Schema.String),\n exp: numericDate,\n iat: numericDate,\n nbf: Schema.optionalKey(numericDate),\n auth_time: Schema.optionalKey(numericDate),\n});\n\nconst plainIdentitySchema = Schema.Struct({\n subject: OAuthVerifiedExternalIdentity.fields.identity.fields.subject,\n profile: Schema.optionalKey(OAuthDisplayProfile),\n});\n\nconst unavailable = () => OAuthUnavailable.make({});\nconst rejected = () => OAuthProtocolRejected.make({});\n\nconst unavailableOnDefect = <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n effect.pipe(\n Effect.tapCause((cause) =>\n Cause.hasDies(cause) ? reportAuthFailure(\"oauth-protocol\", cause) : Effect.void,\n ),\n Effect.catchCause((cause): Effect.Effect<never, E | OAuthUnavailable> => {\n if (Cause.hasInterrupts(cause)) return Effect.interrupt;\n if (Cause.hasDies(cause)) return Effect.fail(unavailable());\n\n return Effect.failCause(cause);\n }),\n );\n\n/** Only precise claim errors and a fully parsed invalid_grant are definite.\n * INVALID_RESPONSE also covers signature/key/transport faults; keep it ambiguous. */\nconst grantError = (error: unknown) => {\n if (\n error instanceof DefiniteTokenRejection ||\n (error instanceof client.ClientError && error.cause instanceof DefiniteTokenRejection)\n )\n return rejected();\n if (\n error instanceof client.ClientError &&\n (error.code === \"OAUTH_JWT_CLAIM_COMPARISON_FAILED\" ||\n error.code === \"OAUTH_JWT_TIMESTAMP_CHECK_FAILED\")\n )\n return rejected();\n if (\n error instanceof client.ResponseBodyError &&\n error.status === 400 &&\n error.error === \"invalid_grant\"\n )\n return rejected();\n\n return unavailable();\n};\n\nconst privateConfiguration = <R>(\n entry: InstalledProvider<R>,\n timeout: number,\n fetch: client.CustomFetch,\n signal: AbortSignal,\n compatibility?: TokenCompatibility,\n) => {\n const provider = entry.provider;\n\n const configuration = new client.Configuration(\n entry.metadata,\n provider.clientId,\n {\n [client.clockSkew]: 0,\n [client.clockTolerance]: 0,\n ...(provider.protocol === \"oidc\"\n ? { id_token_signed_response_alg: provider.idTokenSignedResponseAlg }\n : {}),\n },\n clientAuthentication(provider.authentication),\n );\n\n configuration.timeout = timeout;\n const transport = boundedFetch(fetch, signal, entry.allowedUrls);\n\n configuration[client.customFetch] =\n compatibility === undefined\n ? transport\n : async (url, options) => {\n const response = await transport(url, options);\n\n if (url === new URL(entry.metadata.token_endpoint!).href) {\n const body: unknown = await response.clone().json();\n\n signal.throwIfAborted();\n compatibility.inspectReceipt(\n { body, status: response.status, contentType: response.headers.get(\"content-type\") },\n {\n scopes: provider.scopes,\n refreshRequired: false,\n operation: \"authorization_code\",\n },\n );\n signal.throwIfAborted();\n }\n\n return response;\n };\n if (provider.protocol === \"oidc\") client.enableNonRepudiationChecks(configuration);\n\n return configuration;\n};\n\nexport const makeOAuthProtocolWithCompatibility = Effect.fn(\"makeOpenIdClientOAuthProtocol\")(\n function* <R = never>(\n options: OpenIdClientOAuthProtocolOptions<R>,\n compatibility?: TokenCompatibility,\n ): Effect.fn.Return<\n OAuthProtocol[\"Service\"],\n OpenIdClientConfigurationError | OAuthUnavailable,\n R\n > {\n const context = yield* Effect.context<R>();\n const { installed, fetch, timeoutSeconds } = yield* installConfigurations(options);\n\n const prepareAuthorization: OAuthProtocol[\"Service\"][\"prepareAuthorization\"] = Effect.fn(\n \"OpenIdClient.prepareAuthorization\",\n )(function* (input) {\n const request = yield* Schema.decodeEffect(beginInput)(input).pipe(\n Effect.mapError(() => OAuthRejected.make({})),\n );\n\n const entry = installed.find(\n ({ provider }) => provider.issuance === \"active\" && provider.provider === request.provider,\n );\n\n const provider = entry?.provider;\n\n const callback = provider?.callbacks.find(\n (candidate) => candidate.callbackId === request.callbackId,\n );\n\n if (entry === undefined || provider === undefined || callback === undefined)\n return yield* OAuthRejected.make({});\n\n const result = yield* Effect.tryPromise({\n try: async (signal) => {\n const configuration = privateConfiguration(\n entry,\n timeoutSeconds,\n fetch,\n signal,\n compatibility,\n );\n\n const state = client.randomState();\n const verifier = client.randomPKCECodeVerifier();\n const nonce = provider.protocol === \"oidc\" ? client.randomNonce() : undefined;\n const challenge = await client.calculatePKCECodeChallenge(verifier);\n\n signal.throwIfAborted();\n\n const url = client.buildAuthorizationUrl(\n configuration,\n makeAuthorizationParameters(provider, callback.redirectUri, {\n state,\n challenge,\n ...(nonce === undefined ? {} : { nonce }),\n }),\n );\n\n return {\n configuration: {\n provider: provider.provider,\n protocol: provider.protocol,\n configurationGeneration: provider.configurationGeneration,\n issuer: provider.issuer,\n responseIssuerMode: provider.responseIssuerMode,\n callbackId: callback.callbackId,\n redirectUri: callback.redirectUri,\n },\n authorizationUrl: Redacted.make(url.href),\n secrets: {\n namespace: \"effect-auth/oauth-transaction-secrets/v1\" as const,\n state: Redacted.make(state),\n pkceVerifier: Redacted.make(verifier),\n ...(nonce === undefined ? {} : { oidcNonce: Redacted.make(nonce) }),\n },\n };\n },\n catch: unavailable,\n });\n\n return yield* snapshotOAuth(OAuthProtocolPreparation, result);\n });\n\n const exchangeVerifiedIdentity: OAuthProtocol[\"Service\"][\"exchangeVerifiedIdentity\"] =\n Effect.fn(\"OpenIdClient.exchangeVerifiedIdentity\")(function* (input) {\n const request = yield* snapshotOAuth(exchangeInput, input);\n const saved = request.configuration;\n\n const entry = installed.find(\n ({ provider }) =>\n provider.provider === saved.provider &&\n provider.configurationGeneration === saved.configurationGeneration,\n );\n\n if (entry === undefined) return yield* unavailable();\n const provider = entry.provider;\n\n const callback = provider.callbacks.find(\n (candidate) => candidate.callbackId === saved.callbackId,\n );\n\n if (\n provider.protocol !== saved.protocol ||\n provider.issuer !== saved.issuer ||\n provider.responseIssuerMode !== saved.responseIssuerMode ||\n callback?.redirectUri !== saved.redirectUri\n )\n return yield* unavailable();\n if (\n (provider.protocol === \"oidc\") !== (request.secrets.oidcNonce !== undefined) ||\n Redacted.value(request.response.state) !== Redacted.value(request.secrets.state) ||\n (provider.responseIssuerMode === \"required\"\n ? request.response.issuer !== provider.issuer\n : request.response.issuer !== undefined)\n )\n return yield* rejected();\n const startedAt = DateTime.toEpochMillis(request.verificationStartedAt);\n\n if (startedAt < 0 || startedAt > DateTime.toEpochMillis(yield* DateTime.now))\n return yield* rejected();\n\n const exchanged = yield* Effect.tryPromise({\n try: async (signal) => {\n const configuration = privateConfiguration(\n entry,\n timeoutSeconds,\n fetch,\n signal,\n compatibility,\n );\n\n const currentUrl = new URL(saved.redirectUri);\n\n currentUrl.searchParams.set(\"code\", Redacted.value(request.response.code));\n currentUrl.searchParams.set(\"state\", Redacted.value(request.response.state));\n if (request.response.issuer !== undefined)\n currentUrl.searchParams.set(\"iss\", request.response.issuer);\n\n const tokens = await client.authorizationCodeGrant(\n configuration,\n currentUrl,\n {\n pkceCodeVerifier: Redacted.value(request.secrets.pkceVerifier),\n expectedState: Redacted.value(request.secrets.state),\n ...(provider.protocol === \"oidc\"\n ? {\n expectedNonce: Redacted.value(request.secrets.oidcNonce!),\n idTokenExpected: true,\n ...(provider.maxAgeSeconds === undefined\n ? {}\n : { maxAge: provider.maxAgeSeconds }),\n }\n : {}),\n },\n provider.tokenParameters,\n );\n\n signal.throwIfAborted();\n if (provider.protocol === \"oidc\")\n return { protocol: \"oidc\" as const, claims: tokens.claims() };\n if (tokens.token_type !== \"bearer\") throw unavailable();\n\n const response = await client.fetchProtectedResource(\n configuration,\n tokens.access_token,\n new URL(provider.identitySource.url),\n \"GET\",\n undefined,\n new Headers(provider.identitySource.headers),\n );\n\n signal.throwIfAborted();\n if (\n response.status !== 200 ||\n response.headers.get(\"content-type\")?.split(\";\", 1)[0]?.trim().toLowerCase() !==\n \"application/json\"\n )\n throw unavailable();\n const body: unknown = await response.json();\n\n signal.throwIfAborted();\n\n return { protocol: \"oauth\" as const, body };\n },\n catch: grantError,\n });\n\n if (exchanged.protocol === \"oidc\") {\n // oxlint-disable-next-line no-restricted-properties -- Project validated foreign ID-token claims into the adapter's stricter bounded profile.\n const claims = yield* Schema.decodeUnknownEffect(claimsSchema)(exchanged.claims).pipe(\n Effect.mapError(rejected),\n );\n\n const now = DateTime.toEpochMillis(yield* DateTime.now) / 1000;\n const audience = typeof claims.aud === \"string\" ? claims.aud : claims.aud[0];\n\n if (\n provider.protocol !== \"oidc\" ||\n claims.iss !== provider.issuer ||\n audience !== provider.clientId ||\n (claims.azp !== undefined && claims.azp !== provider.clientId) ||\n claims.exp <= now ||\n claims.iat > now ||\n (claims.nbf !== undefined && claims.nbf > now) ||\n (claims.auth_time !== undefined && claims.auth_time > now) ||\n (provider.maxAgeSeconds !== undefined &&\n (claims.auth_time === undefined ||\n claims.auth_time + provider.maxAgeSeconds < Math.floor(now)))\n )\n return yield* rejected();\n\n return yield* snapshotOAuth(OAuthVerifiedExternalIdentity, {\n identity: { provider: provider.provider, issuer: provider.issuer, subject: claims.sub },\n ...(claims.auth_time === undefined\n ? {}\n : {\n upstreamAuthenticatedAt: DateTime.makeUnsafe(\n Math.min(startedAt, claims.auth_time * 1000),\n ),\n }),\n });\n }\n if (provider.protocol !== \"oauth\") return yield* unavailable();\n\n const decoded = yield* Effect.suspend(() =>\n provider.identitySource.decodeIdentity(exchanged.body),\n ).pipe(\n Effect.provideContext(context),\n Effect.catchCause(\n (cause): Effect.Effect<never, OAuthProtocolRejected | OAuthUnavailable> => {\n if (Cause.hasInterrupts(cause))\n return reportAuthFailure(\"oauth-identity\", cause).pipe(\n Effect.andThen(Effect.interrupt),\n );\n if (\n cause.reasons.length === 1 &&\n cause.reasons[0]?._tag === \"Fail\" &&\n Schema.is(OAuthProtocolRejected)(cause.reasons[0].error)\n )\n return Effect.fail(rejected());\n\n return reportAuthFailure(\"oauth-identity\", cause).pipe(\n Effect.andThen(Effect.fail(unavailable())),\n );\n },\n ),\n );\n\n const identity = yield* Schema.decodeEffect(plainIdentitySchema)(decoded).pipe(\n Effect.mapError(rejected),\n );\n\n return yield* snapshotOAuth(OAuthVerifiedExternalIdentity, {\n identity: {\n provider: provider.provider,\n issuer: provider.issuer,\n subject: identity.subject,\n },\n ...(identity.profile === undefined ? {} : { profile: identity.profile }),\n });\n });\n\n return OAuthProtocol.of({\n prepareAuthorization: (input) => unavailableOnDefect(prepareAuthorization(input)),\n exchangeVerifiedIdentity: (input) => unavailableOnDefect(exchangeVerifiedIdentity(input)),\n });\n },\n unavailableOnDefect,\n);\n\nexport const makeOpenIdClientOAuthProtocol = <R = never>(\n options: OpenIdClientOAuthProtocolOptions<R>,\n) => makeOAuthProtocolWithCompatibility(options);\n\nexport const openIdClientOAuthProtocolLayer = <R = never>(\n options: OpenIdClientOAuthProtocolOptions<R>,\n) => Layer.effect(OAuthProtocol, makeOpenIdClientOAuthProtocol(options));\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,aAAa,OAAO,OAAO;CAC/B,UAAU;CACV,YAAY;CACZ,QAAQ;AACV,CAAC;AAED,MAAM,gBAAgB,OAAO,OAC3B,OAAO,OAAO;CACZ,eAAe;CACf,UAAU;CACV,SAAS;CACT,uBAAuB,OAAO;AAChC,CAAC,CACH;AAEA,MAAM,cAAc,OAAO,OAAO,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS;AAA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ACR,UAAU,SAAS;IACnB,QAAQ,SAAS;IACjB,SAAS,SAAS;GACpB;GACA,GAAI,SAAS,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,SAAS,QAAQ;EACxE,CAAC;CACH,CAAC;CAEH,OAAO,cAAc,GAAG;EACtB,uBAAuB,UAAU,oBAAoB,qBAAqB,KAAK,CAAC;EAChF,2BAA2B,UAAU,oBAAoB,yBAAyB,KAAK,CAAC;CAC1F,CAAC;AACH,GACA,mBACF;AAEA,MAAa,iCACX,YACG,mCAAmC,OAAO;AAE/C,MAAa,kCACX,YACG,MAAM,OAAO,eAAe,8BAA8B,OAAO,CAAC"}
1
+ {"version":3,"file":"protocol.mjs","names":[],"sources":["../../../src/oauth/openid-client/protocol.ts"],"sourcesContent":["import { Cause, DateTime, Effect, Layer, Redacted, Schema } from \"effect\";\nimport * as client from \"openid-client\";\n\nimport { reportAuthFailure } from \"../../internal/diagnostics\";\nimport { RequestBindingFlowId } from \"../../operations/requestBinding\";\nimport { OAuthProtocol } from \"../OAuthProtocol\";\nimport { OAuthProviderKey } from \"../schema\";\nimport { OAuthProtocolRejected, OAuthRejected, OAuthUnavailable } from \"../signInErrors\";\nimport {\n OAuthCallbackId,\n OAuthCodeResponse,\n OAuthDisplayProfile,\n OAuthProtocolConfiguration,\n OAuthProtocolPreparation,\n OAuthTransactionSecrets,\n OAuthVerifiedExternalIdentity,\n} from \"../signInModels\";\nimport { snapshotOAuth } from \"../signInSnapshot\";\nimport { DefiniteTokenRejection, tokenCompatibility } from \"./compatibility\";\nimport {\n clientAuthentication,\n installConfigurations,\n makeAuthorizationParameters,\n type InstalledProvider,\n} from \"./configuration\";\nimport {\n type OpenIdClientConfigurationError,\n type OpenIdClientOAuthProtocolOptions,\n} from \"./models\";\nimport { boundedFetch } from \"./transport\";\n\nconst beginInput = Schema.Struct({\n provider: OAuthProviderKey,\n callbackId: OAuthCallbackId,\n flowId: RequestBindingFlowId,\n});\n\nconst exchangeInput = Schema.toType(\n Schema.Struct({\n configuration: OAuthProtocolConfiguration,\n response: OAuthCodeResponse,\n secrets: OAuthTransactionSecrets,\n verificationStartedAt: Schema.DateTimeUtcFromMillis,\n }),\n);\n\nconst numericDate = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 8640000000000 }));\n\nconst claimsSchema = Schema.Struct({\n iss: Schema.String,\n sub: OAuthVerifiedExternalIdentity.fields.identity.fields.subject,\n aud: Schema.Union([\n Schema.String,\n Schema.Array(Schema.String).check(Schema.isMinLength(1), Schema.isMaxLength(1)),\n ]),\n azp: Schema.optionalKey(Schema.String),\n exp: numericDate,\n iat: numericDate,\n nbf: Schema.optionalKey(numericDate),\n auth_time: Schema.optionalKey(numericDate),\n});\n\nconst plainIdentitySchema = Schema.Struct({\n subject: OAuthVerifiedExternalIdentity.fields.identity.fields.subject,\n profile: Schema.optionalKey(OAuthDisplayProfile),\n});\n\nconst unavailable = () => OAuthUnavailable.make({});\nconst rejected = () => OAuthProtocolRejected.make({});\n\nconst unavailableOnDefect = <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n effect.pipe(\n Effect.tapCause((cause) =>\n Cause.hasDies(cause) ? reportAuthFailure(\"oauth-protocol\", cause) : Effect.void,\n ),\n Effect.catchCause((cause): Effect.Effect<never, E | OAuthUnavailable> => {\n if (Cause.hasInterrupts(cause)) return Effect.interrupt;\n if (Cause.hasDies(cause)) return Effect.fail(unavailable());\n\n return Effect.failCause(cause);\n }),\n );\n\n/** Only precise claim errors and a fully parsed invalid_grant are definite.\n * INVALID_RESPONSE also covers signature/key/transport faults; keep it ambiguous. */\nconst grantError = (error: unknown) => {\n if (\n error instanceof DefiniteTokenRejection ||\n (error instanceof client.ClientError && error.cause instanceof DefiniteTokenRejection)\n )\n return rejected();\n if (\n error instanceof client.ClientError &&\n (error.code === \"OAUTH_JWT_CLAIM_COMPARISON_FAILED\" ||\n error.code === \"OAUTH_JWT_TIMESTAMP_CHECK_FAILED\")\n )\n return rejected();\n if (\n error instanceof client.ResponseBodyError &&\n error.status === 400 &&\n error.error === \"invalid_grant\"\n )\n return rejected();\n\n return unavailable();\n};\n\nconst privateConfiguration = <R>(\n entry: InstalledProvider<R>,\n timeout: number,\n fetch: client.CustomFetch,\n signal: AbortSignal,\n) => {\n const provider = entry.provider;\n const compatibility = provider.protocol === \"oauth\" ? provider[tokenCompatibility] : undefined;\n\n const configuration = new client.Configuration(\n entry.metadata,\n provider.clientId,\n {\n [client.clockSkew]: 0,\n [client.clockTolerance]: 0,\n ...(provider.protocol === \"oidc\"\n ? { id_token_signed_response_alg: provider.idTokenSignedResponseAlg }\n : {}),\n },\n clientAuthentication(provider.authentication),\n );\n\n configuration.timeout = timeout;\n const transport = boundedFetch(fetch, signal, entry.allowedUrls);\n\n configuration[client.customFetch] =\n compatibility === undefined\n ? transport\n : async (url, options) => {\n const response = await transport(url, options);\n\n if (url === new URL(entry.metadata.token_endpoint!).href) {\n const body: unknown = await response.clone().json();\n\n signal.throwIfAborted();\n compatibility.inspectReceipt(\n { body, status: response.status, contentType: response.headers.get(\"content-type\") },\n {\n scopes: provider.scopes,\n refreshRequired: false,\n operation: \"authorization_code\",\n },\n );\n signal.throwIfAborted();\n }\n\n return response;\n };\n if (provider.protocol === \"oidc\") client.enableNonRepudiationChecks(configuration);\n\n return configuration;\n};\n\nexport const makeOpenIdClientOAuthProtocol = Effect.fn(\"makeOpenIdClientOAuthProtocol\")(\n // Capture one provider table; each generation retains its own receipt rules.\n function* <R = never>(\n options: OpenIdClientOAuthProtocolOptions<R>,\n ): Effect.fn.Return<\n OAuthProtocol[\"Service\"],\n OpenIdClientConfigurationError | OAuthUnavailable,\n R\n > {\n const context = yield* Effect.context<R>();\n const { installed, fetch, timeoutSeconds } = yield* installConfigurations(options);\n\n const prepareAuthorization: OAuthProtocol[\"Service\"][\"prepareAuthorization\"] = Effect.fn(\n \"OpenIdClient.prepareAuthorization\",\n )(function* (input) {\n const request = yield* Schema.decodeEffect(beginInput)(input).pipe(\n Effect.mapError(() => OAuthRejected.make({})),\n );\n\n const entry = installed.find(\n ({ provider }) => provider.issuance === \"active\" && provider.provider === request.provider,\n );\n\n const provider = entry?.provider;\n\n const callback = provider?.callbacks.find(\n (candidate) => candidate.callbackId === request.callbackId,\n );\n\n if (entry === undefined || provider === undefined || callback === undefined)\n return yield* OAuthRejected.make({});\n\n const result = yield* Effect.tryPromise({\n try: async (signal) => {\n const configuration = privateConfiguration(entry, timeoutSeconds, fetch, signal);\n\n const state = client.randomState();\n const verifier = client.randomPKCECodeVerifier();\n const nonce = provider.protocol === \"oidc\" ? client.randomNonce() : undefined;\n const challenge = await client.calculatePKCECodeChallenge(verifier);\n\n signal.throwIfAborted();\n\n const url = client.buildAuthorizationUrl(\n configuration,\n makeAuthorizationParameters(provider, callback.redirectUri, {\n state,\n challenge,\n ...(nonce === undefined ? {} : { nonce }),\n }),\n );\n\n return {\n configuration: {\n provider: provider.provider,\n protocol: provider.protocol,\n configurationGeneration: provider.configurationGeneration,\n issuer: provider.issuer,\n responseIssuerMode: provider.responseIssuerMode,\n callbackId: callback.callbackId,\n redirectUri: callback.redirectUri,\n },\n authorizationUrl: Redacted.make(url.href),\n secrets: {\n namespace: \"effect-auth/oauth-transaction-secrets/v1\" as const,\n state: Redacted.make(state),\n pkceVerifier: Redacted.make(verifier),\n ...(nonce === undefined ? {} : { oidcNonce: Redacted.make(nonce) }),\n },\n };\n },\n catch: unavailable,\n });\n\n return yield* snapshotOAuth(OAuthProtocolPreparation, result);\n });\n\n const exchangeVerifiedIdentity: OAuthProtocol[\"Service\"][\"exchangeVerifiedIdentity\"] =\n Effect.fn(\"OpenIdClient.exchangeVerifiedIdentity\")(function* (input) {\n const request = yield* snapshotOAuth(exchangeInput, input);\n const saved = request.configuration;\n\n const entry = installed.find(\n ({ provider }) =>\n provider.provider === saved.provider &&\n provider.configurationGeneration === saved.configurationGeneration,\n );\n\n if (entry === undefined) return yield* unavailable();\n const provider = entry.provider;\n\n const callback = provider.callbacks.find(\n (candidate) => candidate.callbackId === saved.callbackId,\n );\n\n if (\n provider.protocol !== saved.protocol ||\n provider.issuer !== saved.issuer ||\n provider.responseIssuerMode !== saved.responseIssuerMode ||\n callback?.redirectUri !== saved.redirectUri\n )\n return yield* unavailable();\n if (\n (provider.protocol === \"oidc\") !== (request.secrets.oidcNonce !== undefined) ||\n Redacted.value(request.response.state) !== Redacted.value(request.secrets.state) ||\n (provider.responseIssuerMode === \"required\"\n ? request.response.issuer !== provider.issuer\n : request.response.issuer !== undefined)\n )\n return yield* rejected();\n const startedAt = DateTime.toEpochMillis(request.verificationStartedAt);\n\n if (startedAt < 0 || startedAt > DateTime.toEpochMillis(yield* DateTime.now))\n return yield* rejected();\n\n const exchanged = yield* Effect.tryPromise({\n try: async (signal) => {\n const configuration = privateConfiguration(entry, timeoutSeconds, fetch, signal);\n\n const currentUrl = new URL(saved.redirectUri);\n\n currentUrl.searchParams.set(\"code\", Redacted.value(request.response.code));\n currentUrl.searchParams.set(\"state\", Redacted.value(request.response.state));\n if (request.response.issuer !== undefined)\n currentUrl.searchParams.set(\"iss\", request.response.issuer);\n\n const tokens = await client.authorizationCodeGrant(\n configuration,\n currentUrl,\n {\n pkceCodeVerifier: Redacted.value(request.secrets.pkceVerifier),\n expectedState: Redacted.value(request.secrets.state),\n ...(provider.protocol === \"oidc\"\n ? {\n expectedNonce: Redacted.value(request.secrets.oidcNonce!),\n idTokenExpected: true,\n ...(provider.maxAgeSeconds === undefined\n ? {}\n : { maxAge: provider.maxAgeSeconds }),\n }\n : {}),\n },\n provider.tokenParameters,\n );\n\n signal.throwIfAborted();\n if (provider.protocol === \"oidc\")\n return { protocol: \"oidc\" as const, claims: tokens.claims() };\n if (tokens.token_type !== \"bearer\") throw unavailable();\n\n const response = await client.fetchProtectedResource(\n configuration,\n tokens.access_token,\n new URL(provider.identitySource.url),\n \"GET\",\n undefined,\n new Headers(provider.identitySource.headers),\n );\n\n signal.throwIfAborted();\n if (\n response.status !== 200 ||\n response.headers.get(\"content-type\")?.split(\";\", 1)[0]?.trim().toLowerCase() !==\n \"application/json\"\n )\n throw unavailable();\n const body: unknown = await response.json();\n\n signal.throwIfAborted();\n\n return { protocol: \"oauth\" as const, body };\n },\n catch: grantError,\n });\n\n if (exchanged.protocol === \"oidc\") {\n // oxlint-disable-next-line no-restricted-properties -- Project validated foreign ID-token claims into the adapter's stricter bounded profile.\n const claims = yield* Schema.decodeUnknownEffect(claimsSchema)(exchanged.claims).pipe(\n Effect.mapError(rejected),\n );\n\n const now = DateTime.toEpochMillis(yield* DateTime.now) / 1000;\n const audience = typeof claims.aud === \"string\" ? claims.aud : claims.aud[0];\n\n if (\n provider.protocol !== \"oidc\" ||\n claims.iss !== provider.issuer ||\n audience !== provider.clientId ||\n (claims.azp !== undefined && claims.azp !== provider.clientId) ||\n claims.exp <= now ||\n claims.iat > now ||\n (claims.nbf !== undefined && claims.nbf > now) ||\n (claims.auth_time !== undefined && claims.auth_time > now) ||\n (provider.maxAgeSeconds !== undefined &&\n (claims.auth_time === undefined ||\n claims.auth_time + provider.maxAgeSeconds < Math.floor(now)))\n )\n return yield* rejected();\n\n return yield* snapshotOAuth(OAuthVerifiedExternalIdentity, {\n identity: { provider: provider.provider, issuer: provider.issuer, subject: claims.sub },\n ...(claims.auth_time === undefined\n ? {}\n : {\n upstreamAuthenticatedAt: DateTime.makeUnsafe(\n Math.min(startedAt, claims.auth_time * 1000),\n ),\n }),\n });\n }\n if (provider.protocol !== \"oauth\") return yield* unavailable();\n\n const decoded = yield* Effect.suspend(() =>\n provider.identitySource.decodeIdentity(exchanged.body),\n ).pipe(\n Effect.provideContext(context),\n Effect.catchCause(\n (cause): Effect.Effect<never, OAuthProtocolRejected | OAuthUnavailable> => {\n if (Cause.hasInterrupts(cause))\n return reportAuthFailure(\"oauth-identity\", cause).pipe(\n Effect.andThen(Effect.interrupt),\n );\n if (\n cause.reasons.length === 1 &&\n cause.reasons[0]?._tag === \"Fail\" &&\n Schema.is(OAuthProtocolRejected)(cause.reasons[0].error)\n )\n return Effect.fail(rejected());\n\n return reportAuthFailure(\"oauth-identity\", cause).pipe(\n Effect.andThen(Effect.fail(unavailable())),\n );\n },\n ),\n );\n\n const identity = yield* Schema.decodeEffect(plainIdentitySchema)(decoded).pipe(\n Effect.mapError(rejected),\n );\n\n return yield* snapshotOAuth(OAuthVerifiedExternalIdentity, {\n identity: {\n provider: provider.provider,\n issuer: provider.issuer,\n subject: identity.subject,\n },\n ...(identity.profile === undefined ? {} : { profile: identity.profile }),\n });\n });\n\n return OAuthProtocol.of({\n prepareAuthorization: (input) => unavailableOnDefect(prepareAuthorization(input)),\n exchangeVerifiedIdentity: (input) => unavailableOnDefect(exchangeVerifiedIdentity(input)),\n });\n },\n unavailableOnDefect,\n);\n\nexport const openIdClientOAuthProtocolLayer = <R = never>(\n options: OpenIdClientOAuthProtocolOptions<R>,\n) => Layer.effect(OAuthProtocol, makeOpenIdClientOAuthProtocol(options));\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,aAAa,OAAO,OAAO;CAC/B,UAAU;CACV,YAAY;CACZ,QAAQ;AACV,CAAC;AAED,MAAM,gBAAgB,OAAO,OAC3B,OAAO,OAAO;CACZ,eAAe;CACf,UAAU;CACV,SAAS;CACT,uBAAuB,OAAO;AAChC,CAAC,CACH;AAEA,MAAM,cAAc,OAAO,OAAO,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS;AAAc,CAAC,CAAC;AAEhG,MAAM,eAAe,OAAO,OAAO;CACjC,KAAK,OAAO;CACZ,KAAK,8BAA8B,OAAO,SAAS,OAAO;CAC1D,KAAK,OAAO,MAAM,CAChB,OAAO,QACP,OAAO,MAAM,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,GAAG,OAAO,YAAY,CAAC,CAAC,CAChF,CAAC;CACD,KAAK,OAAO,YAAY,OAAO,MAAM;CACrC,KAAK;CACL,KAAK;CACL,KAAK,OAAO,YAAY,WAAW;CACnC,WAAW,OAAO,YAAY,WAAW;AAC3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a,kCACX,YACG,MAAM,OAAO,eAAe,8BAA8B,OAAO,CAAC"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@yielded/auth","version":"0.1.0-beta.2","dependencies":{"@noble/ciphers":"2.1.1","@noble/hashes":"2.3.0"},"devDependencies":{"@cloudflare/workers-types":"5.20260825.1","@effect/platform-bun":"4.0.0-rc.112","@effect/platform-node":"4.0.0-rc.112","@effect/sql-d1":"4.0.0-rc.112","@effect/sql-libsql":"4.0.0-rc.112","@effect/sql-mysql2":"4.0.0-rc.112","@effect/sql-pg":"4.0.0-rc.112","@effect/sql-pglite":"4.0.0-rc.112","@effect/sql-sqlite-bun":"4.0.0-rc.112","@effect/sql-sqlite-do":"4.0.0-rc.112","@effect/sql-sqlite-node":"4.0.0-rc.112","@effect/sql-sqlite-wasm":"4.0.0-rc.112","@effect/vitest":"4.0.0-rc.112","@simplewebauthn/browser":"14.0.0","@simplewebauthn/server":"14.0.1","drizzle-orm":"1.0.0-rc.5-ab785fc","effect":"4.0.0-rc.112","effect-cf":"0.40.0","openid-client":"6.8.8","tldts":"7.4.11","typescript":"7.0.2","vite-plus":"0.3.0"},"peerDependencies":{"@effect/sql-d1":">=4.0.0-rc.112","@effect/sql-libsql":">=4.0.0-rc.112","@effect/sql-mysql2":">=4.0.0-rc.112","@effect/sql-pg":">=4.0.0-rc.112","@effect/sql-pglite":">=4.0.0-rc.112","@effect/sql-sqlite-bun":">=4.0.0-rc.112","@effect/sql-sqlite-do":">=4.0.0-rc.112","@effect/sql-sqlite-node":">=4.0.0-rc.112","@effect/sql-sqlite-wasm":">=4.0.0-rc.112","@simplewebauthn/browser":">=14.0.0 <15","@simplewebauthn/server":">=14.0.1 <15","drizzle-orm":">=1.0.0-rc.5-ab785fc","effect":"^4.0.0-rc.112","effect-cf":"^0.40.0","openid-client":">=6.8.8 <7","tldts":">=7.4.11 <8"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./Auth":{"types":"./dist/Auth.d.mts","default":"./dist/Auth.mjs"},"./Drizzle":{"types":"./dist/Drizzle.d.mts","default":"./dist/Drizzle.mjs"},"./DrizzleD1":{"types":"./dist/DrizzleD1.d.mts","default":"./dist/DrizzleD1.mjs"},"./DrizzleLibsql":{"types":"./dist/DrizzleLibsql.d.mts","default":"./dist/DrizzleLibsql.mjs"},"./DrizzleMysql2":{"types":"./dist/DrizzleMysql2.d.mts","default":"./dist/DrizzleMysql2.mjs"},"./DrizzlePglite":{"types":"./dist/DrizzlePglite.d.mts","default":"./dist/DrizzlePglite.mjs"},"./DrizzlePostgres":{"types":"./dist/DrizzlePostgres.d.mts","default":"./dist/DrizzlePostgres.mjs"},"./DrizzleSqliteBun":{"types":"./dist/DrizzleSqliteBun.d.mts","default":"./dist/DrizzleSqliteBun.mjs"},"./DrizzleSqliteDo":{"types":"./dist/DrizzleSqliteDo.d.mts","default":"./dist/DrizzleSqliteDo.mjs"},"./DrizzleSqliteNode":{"types":"./dist/DrizzleSqliteNode.d.mts","default":"./dist/DrizzleSqliteNode.mjs"},"./DrizzleSqliteWasm":{"types":"./dist/DrizzleSqliteWasm.d.mts","default":"./dist/DrizzleSqliteWasm.mjs"},"./Cloudflare":{"types":"./dist/Cloudflare.d.mts","default":"./dist/Cloudflare.mjs"},"./Http":{"types":"./dist/Http.d.mts","default":"./dist/Http.mjs"},"./HttpServer":{"types":"./dist/HttpServer.d.mts","default":"./dist/HttpServer.mjs"},"./OperationHttp":{"types":"./dist/OperationHttp.d.mts","default":"./dist/OperationHttp.mjs"},"./OperationHttpClient":{"types":"./dist/OperationHttpClient.d.mts","default":"./dist/OperationHttpClient.mjs"},"./OperationHttpServer":{"types":"./dist/OperationHttpServer.d.mts","default":"./dist/OperationHttpServer.mjs"},"./Atom":{"types":"./dist/Atom.d.mts","default":"./dist/Atom.mjs"},"./Hooks":{"types":"./dist/Hooks.d.mts","default":"./dist/Hooks.mjs"},"./Identity":{"types":"./dist/Identity.d.mts","default":"./dist/Identity.mjs"},"./OAuth":{"types":"./dist/OAuth.d.mts","default":"./dist/OAuth.mjs"},"./Operations":{"types":"./dist/Operations.d.mts","default":"./dist/Operations.mjs"},"./Rpc":{"types":"./dist/Rpc.d.mts","default":"./dist/Rpc.mjs"},"./Schema":{"types":"./dist/Schema.d.mts","default":"./dist/Schema.mjs"},"./Testing":{"types":"./dist/Testing.d.mts","default":"./dist/Testing.mjs"},"./WebCrypto":{"types":"./dist/WebCrypto.d.mts","default":"./dist/WebCrypto.mjs"},"./Sessions":{"types":"./dist/Sessions.d.mts","default":"./dist/Sessions.mjs"},"./SessionContract":{"types":"./dist/SessionContract.d.mts","default":"./dist/SessionContract.mjs"},"./Proofs":{"types":"./dist/Proofs.d.mts","default":"./dist/Proofs.mjs"},"./Password":{"types":"./dist/Password.d.mts","default":"./dist/Password.mjs"},"./Email":{"types":"./dist/Email.d.mts","default":"./dist/Email.mjs"},"./OpenIdClient":{"types":"./dist/OpenIdClient.d.mts","default":"./dist/OpenIdClient.mjs"},"./OpenIdClientConnected":{"types":"./dist/OpenIdClientConnected.d.mts","default":"./dist/OpenIdClientConnected.mjs"},"./Passkey":{"types":"./dist/Passkey.d.mts","default":"./dist/Passkey.mjs"},"./PasskeyPassword":{"types":"./dist/PasskeyPassword.d.mts","default":"./dist/PasskeyPassword.mjs"},"./PasskeySimpleWebAuthn":{"types":"./dist/PasskeySimpleWebAuthn.d.mts","default":"./dist/PasskeySimpleWebAuthn.mjs"},"./PasskeyBrowser":{"types":"./dist/PasskeyBrowser.d.mts","default":"./dist/PasskeyBrowser.mjs"},"./GitHub":{"types":"./dist/GitHub.d.mts","default":"./dist/GitHub.mjs"},"./AuthSession":{"types":"./dist/AuthSession.d.mts","default":"./dist/AuthSession.mjs"},"./Errors":{"types":"./dist/Errors.d.mts","default":"./dist/Errors.mjs"},"./Workflows":{"types":"./dist/Workflows.d.mts","default":"./dist/Workflows.mjs"},"./PasswordHasher":{"types":"./dist/PasswordHasher.d.mts","default":"./dist/PasswordHasher.mjs"},"./EmailOtp":{"types":"./dist/EmailOtp.d.mts","default":"./dist/EmailOtp.mjs"},"./AuthStore":{"types":"./dist/AuthStore.d.mts","default":"./dist/AuthStore.mjs"},"./PasswordAuth":{"types":"./dist/PasswordAuth.d.mts","default":"./dist/PasswordAuth.mjs"},"./Policy":{"types":"./dist/Policy.d.mts","default":"./dist/Policy.mjs"},"./EmailOtpSender":{"types":"./dist/EmailOtpSender.d.mts","default":"./dist/EmailOtpSender.mjs"},"./AuthTokenCodec":{"types":"./dist/AuthTokenCodec.d.mts","default":"./dist/AuthTokenCodec.mjs"},"./IdentityResolver":{"types":"./dist/IdentityResolver.d.mts","default":"./dist/IdentityResolver.mjs"},"./PasswordCredentialStore":{"types":"./dist/PasswordCredentialStore.d.mts","default":"./dist/PasswordCredentialStore.mjs"},"./PhoneOtp":{"types":"./dist/PhoneOtp.d.mts","default":"./dist/PhoneOtp.mjs"},"./Totp":{"types":"./dist/Totp.d.mts","default":"./dist/Totp.mjs"},"./PasskeyContract":{"types":"./dist/PasskeyContract.d.mts","default":"./dist/PasskeyContract.mjs"},"./TotpContract":{"types":"./dist/TotpContract.d.mts","default":"./dist/TotpContract.mjs"},"./AuthContract":{"types":"./dist/AuthContract.d.mts","default":"./dist/AuthContract.mjs"},"./Client":{"types":"./dist/Client.d.mts","default":"./dist/Client.mjs"}},"description":"Composable authentication, sessions, and identity workflows for Effect.","keywords":["authentication","effect","oauth","passkeys","sessions","typescript"],"homepage":"https://yielded.dev/auth/","bugs":{"url":"https://github.com/yielded-dev/auth/issues"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/yielded-dev/auth.git","directory":"packages/effect-auth"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json","test":"vp test --passWithNoTests","e2e":"bun test/e2e/harness.ts","example:totp":"bun test/fixtures/totp-sqlite-bun.ts"},"peerDependenciesMeta":{"@effect/sql-d1":{"optional":true},"@effect/sql-libsql":{"optional":true},"@effect/sql-mysql2":{"optional":true},"@effect/sql-pg":{"optional":true},"@effect/sql-pglite":{"optional":true},"@effect/sql-sqlite-bun":{"optional":true},"@effect/sql-sqlite-do":{"optional":true},"@effect/sql-sqlite-node":{"optional":true},"@effect/sql-sqlite-wasm":{"optional":true},"@simplewebauthn/browser":{"optional":true},"@simplewebauthn/server":{"optional":true},"drizzle-orm":{"optional":true},"effect-cf":{"optional":true},"openid-client":{"optional":true},"tldts":{"optional":true}}}
1
+ {"name":"@yielded/auth","version":"0.1.0-beta.3","dependencies":{"@noble/ciphers":"2.1.1","@noble/hashes":"2.3.0"},"devDependencies":{"@cloudflare/workers-types":"5.20260825.1","@effect/platform-bun":"4.0.0-rc.112","@effect/platform-node":"4.0.0-rc.112","@effect/sql-d1":"4.0.0-rc.112","@effect/sql-libsql":"4.0.0-rc.112","@effect/sql-mysql2":"4.0.0-rc.112","@effect/sql-pg":"4.0.0-rc.112","@effect/sql-pglite":"4.0.0-rc.112","@effect/sql-sqlite-bun":"4.0.0-rc.112","@effect/sql-sqlite-do":"4.0.0-rc.112","@effect/sql-sqlite-node":"4.0.0-rc.112","@effect/sql-sqlite-wasm":"4.0.0-rc.112","@effect/vitest":"4.0.0-rc.112","@simplewebauthn/browser":"14.0.0","@simplewebauthn/server":"14.0.1","drizzle-orm":"1.0.0-rc.5-ab785fc","effect":"4.0.0-rc.112","effect-cf":"0.40.0","openid-client":"6.8.8","tldts":"7.4.11","typescript":"7.0.2","vite-plus":"0.3.0"},"peerDependencies":{"@effect/sql-d1":">=4.0.0-rc.112","@effect/sql-libsql":">=4.0.0-rc.112","@effect/sql-mysql2":">=4.0.0-rc.112","@effect/sql-pg":">=4.0.0-rc.112","@effect/sql-pglite":">=4.0.0-rc.112","@effect/sql-sqlite-bun":">=4.0.0-rc.112","@effect/sql-sqlite-do":">=4.0.0-rc.112","@effect/sql-sqlite-node":">=4.0.0-rc.112","@effect/sql-sqlite-wasm":">=4.0.0-rc.112","@simplewebauthn/browser":">=14.0.0 <15","@simplewebauthn/server":">=14.0.1 <15","drizzle-orm":">=1.0.0-rc.5-ab785fc","effect":"^4.0.0-rc.112","effect-cf":"^0.40.0","openid-client":">=6.8.8 <7","tldts":">=7.4.11 <8"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./Auth":{"types":"./dist/Auth.d.mts","default":"./dist/Auth.mjs"},"./Drizzle":{"types":"./dist/Drizzle.d.mts","default":"./dist/Drizzle.mjs"},"./DrizzleD1":{"types":"./dist/DrizzleD1.d.mts","default":"./dist/DrizzleD1.mjs"},"./DrizzleLibsql":{"types":"./dist/DrizzleLibsql.d.mts","default":"./dist/DrizzleLibsql.mjs"},"./DrizzleMysql2":{"types":"./dist/DrizzleMysql2.d.mts","default":"./dist/DrizzleMysql2.mjs"},"./DrizzlePglite":{"types":"./dist/DrizzlePglite.d.mts","default":"./dist/DrizzlePglite.mjs"},"./DrizzlePostgres":{"types":"./dist/DrizzlePostgres.d.mts","default":"./dist/DrizzlePostgres.mjs"},"./DrizzleSqliteBun":{"types":"./dist/DrizzleSqliteBun.d.mts","default":"./dist/DrizzleSqliteBun.mjs"},"./DrizzleSqliteDo":{"types":"./dist/DrizzleSqliteDo.d.mts","default":"./dist/DrizzleSqliteDo.mjs"},"./DrizzleSqliteNode":{"types":"./dist/DrizzleSqliteNode.d.mts","default":"./dist/DrizzleSqliteNode.mjs"},"./DrizzleSqliteWasm":{"types":"./dist/DrizzleSqliteWasm.d.mts","default":"./dist/DrizzleSqliteWasm.mjs"},"./Cloudflare":{"types":"./dist/Cloudflare.d.mts","default":"./dist/Cloudflare.mjs"},"./Http":{"types":"./dist/Http.d.mts","default":"./dist/Http.mjs"},"./HttpServer":{"types":"./dist/HttpServer.d.mts","default":"./dist/HttpServer.mjs"},"./OperationHttp":{"types":"./dist/OperationHttp.d.mts","default":"./dist/OperationHttp.mjs"},"./OperationHttpClient":{"types":"./dist/OperationHttpClient.d.mts","default":"./dist/OperationHttpClient.mjs"},"./OperationHttpServer":{"types":"./dist/OperationHttpServer.d.mts","default":"./dist/OperationHttpServer.mjs"},"./Atom":{"types":"./dist/Atom.d.mts","default":"./dist/Atom.mjs"},"./Hooks":{"types":"./dist/Hooks.d.mts","default":"./dist/Hooks.mjs"},"./Identity":{"types":"./dist/Identity.d.mts","default":"./dist/Identity.mjs"},"./OAuth":{"types":"./dist/OAuth.d.mts","default":"./dist/OAuth.mjs"},"./Operations":{"types":"./dist/Operations.d.mts","default":"./dist/Operations.mjs"},"./Rpc":{"types":"./dist/Rpc.d.mts","default":"./dist/Rpc.mjs"},"./Schema":{"types":"./dist/Schema.d.mts","default":"./dist/Schema.mjs"},"./Testing":{"types":"./dist/Testing.d.mts","default":"./dist/Testing.mjs"},"./WebCrypto":{"types":"./dist/WebCrypto.d.mts","default":"./dist/WebCrypto.mjs"},"./Sessions":{"types":"./dist/Sessions.d.mts","default":"./dist/Sessions.mjs"},"./SessionContract":{"types":"./dist/SessionContract.d.mts","default":"./dist/SessionContract.mjs"},"./Proofs":{"types":"./dist/Proofs.d.mts","default":"./dist/Proofs.mjs"},"./Password":{"types":"./dist/Password.d.mts","default":"./dist/Password.mjs"},"./Email":{"types":"./dist/Email.d.mts","default":"./dist/Email.mjs"},"./OpenIdClient":{"types":"./dist/OpenIdClient.d.mts","default":"./dist/OpenIdClient.mjs"},"./OpenIdClientConnected":{"types":"./dist/OpenIdClientConnected.d.mts","default":"./dist/OpenIdClientConnected.mjs"},"./Passkey":{"types":"./dist/Passkey.d.mts","default":"./dist/Passkey.mjs"},"./PasskeyPassword":{"types":"./dist/PasskeyPassword.d.mts","default":"./dist/PasskeyPassword.mjs"},"./PasskeySimpleWebAuthn":{"types":"./dist/PasskeySimpleWebAuthn.d.mts","default":"./dist/PasskeySimpleWebAuthn.mjs"},"./PasskeyBrowser":{"types":"./dist/PasskeyBrowser.d.mts","default":"./dist/PasskeyBrowser.mjs"},"./GitHub":{"types":"./dist/GitHub.d.mts","default":"./dist/GitHub.mjs"},"./AuthSession":{"types":"./dist/AuthSession.d.mts","default":"./dist/AuthSession.mjs"},"./Errors":{"types":"./dist/Errors.d.mts","default":"./dist/Errors.mjs"},"./Workflows":{"types":"./dist/Workflows.d.mts","default":"./dist/Workflows.mjs"},"./PasswordHasher":{"types":"./dist/PasswordHasher.d.mts","default":"./dist/PasswordHasher.mjs"},"./EmailOtp":{"types":"./dist/EmailOtp.d.mts","default":"./dist/EmailOtp.mjs"},"./AuthStore":{"types":"./dist/AuthStore.d.mts","default":"./dist/AuthStore.mjs"},"./PasswordAuth":{"types":"./dist/PasswordAuth.d.mts","default":"./dist/PasswordAuth.mjs"},"./Policy":{"types":"./dist/Policy.d.mts","default":"./dist/Policy.mjs"},"./EmailOtpSender":{"types":"./dist/EmailOtpSender.d.mts","default":"./dist/EmailOtpSender.mjs"},"./AuthTokenCodec":{"types":"./dist/AuthTokenCodec.d.mts","default":"./dist/AuthTokenCodec.mjs"},"./IdentityResolver":{"types":"./dist/IdentityResolver.d.mts","default":"./dist/IdentityResolver.mjs"},"./PasswordCredentialStore":{"types":"./dist/PasswordCredentialStore.d.mts","default":"./dist/PasswordCredentialStore.mjs"},"./PhoneOtp":{"types":"./dist/PhoneOtp.d.mts","default":"./dist/PhoneOtp.mjs"},"./Totp":{"types":"./dist/Totp.d.mts","default":"./dist/Totp.mjs"},"./PasskeyContract":{"types":"./dist/PasskeyContract.d.mts","default":"./dist/PasskeyContract.mjs"},"./TotpContract":{"types":"./dist/TotpContract.d.mts","default":"./dist/TotpContract.mjs"},"./AuthContract":{"types":"./dist/AuthContract.d.mts","default":"./dist/AuthContract.mjs"},"./Client":{"types":"./dist/Client.d.mts","default":"./dist/Client.mjs"}},"description":"Composable authentication, sessions, and identity workflows for Effect.","keywords":["authentication","effect","oauth","passkeys","sessions","typescript"],"homepage":"https://yielded.dev/auth/","bugs":{"url":"https://github.com/yielded-dev/auth/issues"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/yielded-dev/auth.git","directory":"packages/effect-auth"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json","test":"vp test --passWithNoTests","e2e":"bun test/e2e/harness.ts","example:totp":"bun test/fixtures/totp-sqlite-bun.ts"},"peerDependenciesMeta":{"@effect/sql-d1":{"optional":true},"@effect/sql-libsql":{"optional":true},"@effect/sql-mysql2":{"optional":true},"@effect/sql-pg":{"optional":true},"@effect/sql-pglite":{"optional":true},"@effect/sql-sqlite-bun":{"optional":true},"@effect/sql-sqlite-do":{"optional":true},"@effect/sql-sqlite-node":{"optional":true},"@effect/sql-sqlite-wasm":{"optional":true},"@simplewebauthn/browser":{"optional":true},"@simplewebauthn/server":{"optional":true},"drizzle-orm":{"optional":true},"effect-cf":{"optional":true},"openid-client":{"optional":true},"tldts":{"optional":true}}}