@udibo/oauth2 0.14.1 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -24
- package/{esm → dist}/adapters/hono/_common.d.ts +5 -5
- package/{esm → dist}/adapters/hono/_common.js +1 -1
- package/{esm → dist}/adapters/hono/authorization-server.d.ts +6 -7
- package/{esm → dist}/adapters/hono/authorization-server.js +0 -1
- package/{esm → dist}/adapters/hono/bff/auth-request-store.d.ts +2 -2
- package/{esm → dist}/adapters/hono/bff/auth-request-store.js +2 -2
- package/{esm → dist}/adapters/hono/bff/bff.d.ts +8 -8
- package/{esm → dist}/adapters/hono/bff/bff.js +33 -27
- package/{esm → dist}/adapters/hono/bff/cookie-prefix.js +1 -2
- package/{esm → dist}/adapters/hono/bff/mod.d.ts +5 -6
- package/{esm → dist}/adapters/hono/bff/mod.js +1 -2
- package/{esm → dist}/adapters/hono/bff/proxy.js +2 -1
- package/{esm → dist}/adapters/hono/bff/session-store.d.ts +2 -2
- package/{esm → dist}/adapters/hono/bff/session-store.js +7 -6
- package/{esm → dist}/adapters/hono/bff/testing.d.ts +7 -8
- package/{esm → dist}/adapters/hono/bff/testing.js +19 -22
- package/{esm → dist}/adapters/hono/identity.d.ts +1 -2
- package/{esm → dist}/adapters/hono/identity.js +10 -10
- package/{esm → dist}/adapters/hono/log.d.ts +0 -1
- package/{esm → dist}/adapters/hono/log.js +0 -6
- package/{esm → dist}/adapters/hono/resource-server.d.ts +5 -6
- package/{esm → dist}/adapters/hono/resource-server.js +0 -1
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +3 -0
- package/dist/cli/idp/config.d.ts +110 -0
- package/dist/cli/idp/config.js +269 -0
- package/dist/cli/idp/mod.d.ts +20 -0
- package/dist/cli/idp/mod.js +175 -0
- package/dist/cli/idp/pages.d.ts +56 -0
- package/dist/cli/idp/pages.js +190 -0
- package/dist/cli/idp/server.d.ts +93 -0
- package/dist/cli/idp/server.js +559 -0
- package/dist/cli/keygen.d.ts +13 -0
- package/dist/cli/keygen.js +30 -0
- package/dist/cli/mod.d.ts +34 -0
- package/dist/cli/mod.js +94 -0
- package/{esm → dist}/client/_http.d.ts +1 -1
- package/{esm → dist}/client/base.d.ts +1 -1
- package/{esm → dist}/client/bff-client.d.ts +1 -1
- package/{esm → dist}/client/bff-client.js +7 -6
- package/{esm → dist}/client/browser-storage.d.ts +1 -1
- package/{esm → dist}/client/check.js +1 -1
- package/{esm → dist}/client/direct-client.d.ts +6 -6
- package/{esm → dist}/client/direct-client.js +11 -13
- package/{esm → dist}/client/discovery-cache.d.ts +1 -1
- package/{esm → dist}/client/discovery-cache.js +2 -2
- package/{esm → dist}/client/events.d.ts +1 -1
- package/{esm → dist}/client/mod.d.ts +11 -12
- package/{esm → dist}/client/mod.js +1 -1
- package/{esm → dist}/errors.d.ts +1 -1
- package/{esm → dist}/errors.js +1 -1
- package/{esm → dist}/identity/events.d.ts +1 -1
- package/{esm → dist}/identity/external/_shared.d.ts +1 -1
- package/{esm → dist}/identity/external/_shared.js +1 -2
- package/{esm → dist}/identity/external/apple-client-secret.d.ts +1 -1
- package/{esm → dist}/identity/external/apple-client-secret.js +6 -7
- package/{esm → dist}/identity/external/apple.d.ts +5 -5
- package/{esm → dist}/identity/external/apple.js +10 -11
- package/{esm → dist}/identity/external/discord.d.ts +3 -3
- package/{esm → dist}/identity/external/discord.js +2 -2
- package/{esm → dist}/identity/external/flow.d.ts +1 -1
- package/{esm → dist}/identity/external/flow.js +2 -2
- package/{esm → dist}/identity/external/github.d.ts +3 -3
- package/{esm → dist}/identity/external/github.js +12 -17
- package/{esm → dist}/identity/external/google.d.ts +5 -5
- package/{esm → dist}/identity/external/google.js +2 -2
- package/{esm → dist}/identity/external/mod.d.ts +12 -13
- package/{esm → dist}/identity/external/mod.js +0 -1
- package/{esm → dist}/identity/external/oauth2.d.ts +1 -1
- package/{esm → dist}/identity/external/oauth2.js +8 -8
- package/{esm → dist}/identity/external/oidc.d.ts +4 -4
- package/{esm → dist}/identity/external/oidc.js +9 -8
- package/{esm → dist}/identity/hibp.d.ts +1 -1
- package/{esm → dist}/identity/hibp.js +1 -1
- package/{esm → dist}/identity/lockout.js +1 -2
- package/{esm → dist}/identity/mfa/mod.d.ts +4 -5
- package/{esm → dist}/identity/mfa/mod.js +1 -2
- package/{esm → dist}/identity/mfa/service.d.ts +3 -3
- package/{esm → dist}/identity/mfa/service.js +4 -3
- package/{esm → dist}/identity/mfa/totp.d.ts +1 -1
- package/{esm → dist}/identity/mfa/totp.js +2 -2
- package/{esm → dist}/identity/migration.d.ts +2 -3
- package/{esm → dist}/identity/migration.js +3 -4
- package/{esm → dist}/identity/mod.d.ts +14 -15
- package/{esm → dist}/identity/mod.js +0 -1
- package/{esm → dist}/identity/otp.d.ts +1 -1
- package/{esm → dist}/identity/otp.js +4 -2
- package/{esm → dist}/identity/password.js +8 -5
- package/{esm → dist}/identity/rate-limit.d.ts +1 -1
- package/{esm → dist}/identity/service.d.ts +10 -10
- package/{esm → dist}/identity/service.js +17 -18
- package/{esm → dist}/identity/session.js +2 -2
- package/{esm → dist}/identity/token-flow.js +3 -2
- package/{esm → dist}/models/authorization-code.d.ts +3 -3
- package/{esm → dist}/models/authorization.d.ts +1 -1
- package/{esm → dist}/models/authorization.js +1 -2
- package/{esm → dist}/models/device-authorization.d.ts +2 -2
- package/{esm → dist}/models/token.d.ts +3 -3
- package/{esm → dist}/react/callback.d.ts +1 -1
- package/{esm → dist}/react/callback.js +0 -1
- package/{esm → dist}/react/components/class-names.d.ts +1 -1
- package/{esm → dist}/react/components/class-names.js +3 -2
- package/{esm → dist}/react/components/internal.d.ts +2 -2
- package/{esm → dist}/react/components/internal.js +5 -11
- package/{esm → dist}/react/components/mfa-challenge-form.d.ts +2 -2
- package/{esm → dist}/react/components/mfa-challenge-form.js +4 -6
- package/{esm → dist}/react/components/mfa-enrollment-form.d.ts +2 -2
- package/{esm → dist}/react/components/mfa-enrollment-form.js +2 -6
- package/{esm → dist}/react/components/mod.d.ts +20 -21
- package/{esm → dist}/react/components/mod.js +1 -2
- package/{esm → dist}/react/components/request-password-reset-form.d.ts +2 -2
- package/{esm → dist}/react/components/request-password-reset-form.js +1 -3
- package/{esm → dist}/react/components/reset-password-form.d.ts +2 -2
- package/{esm → dist}/react/components/reset-password-form.js +2 -2
- package/{esm → dist}/react/components/sign-in-form.d.ts +2 -2
- package/{esm → dist}/react/components/sign-in-form.js +1 -5
- package/{esm → dist}/react/components/sign-up-form.d.ts +2 -2
- package/{esm → dist}/react/components/sign-up-form.js +4 -10
- package/{esm → dist}/react/components/types.d.ts +2 -2
- package/{esm → dist}/react/components/use-auth-form.d.ts +3 -3
- package/{esm → dist}/react/components/use-auth-form.js +4 -7
- package/{esm → dist}/react/components/user-menu.d.ts +2 -2
- package/{esm → dist}/react/components/user-menu.js +9 -14
- package/{esm → dist}/react/context.d.ts +1 -1
- package/{esm → dist}/react/mod.d.ts +6 -7
- package/{esm → dist}/react/mod.js +0 -1
- package/{esm → dist}/react/provider.d.ts +2 -2
- package/{esm → dist}/react/require-auth.js +1 -3
- package/{esm → dist}/react/testing.d.ts +2 -3
- package/{esm → dist}/react/testing.js +1 -2
- package/{esm → dist}/react/use-authorization.d.ts +1 -1
- package/{esm → dist}/react/use-oauth2.d.ts +8 -1
- package/{esm → dist}/react/use-oauth2.js +0 -1
- package/{esm → dist}/server/_clock-skew.js +2 -1
- package/{esm → dist}/server/authorization-server.d.ts +40 -41
- package/{esm → dist}/server/authorization-server.js +32 -42
- package/{esm → dist}/server/client-authentication.d.ts +2 -2
- package/{esm → dist}/server/grants/authorization-code.d.ts +9 -9
- package/{esm → dist}/server/grants/authorization-code.js +5 -6
- package/{esm → dist}/server/grants/client-credentials.d.ts +4 -4
- package/{esm → dist}/server/grants/device-authorization.d.ts +6 -6
- package/{esm → dist}/server/grants/device-authorization.js +4 -4
- package/{esm → dist}/server/grants/grant.d.ts +7 -7
- package/{esm → dist}/server/grants/grant.js +7 -7
- package/{esm → dist}/server/grants/password.d.ts +5 -5
- package/{esm → dist}/server/grants/refresh-token.d.ts +4 -4
- package/{esm → dist}/server/grants/refresh-token.js +5 -6
- package/{esm → dist}/server/introspection-token-reader.d.ts +5 -5
- package/{esm → dist}/server/introspection-token-reader.js +4 -4
- package/{esm → dist}/server/jwks-token-reader.d.ts +5 -5
- package/{esm → dist}/server/jwks-token-reader.js +4 -4
- package/{esm → dist}/server/mod.d.ts +12 -13
- package/{esm → dist}/server/mod.js +0 -1
- package/{esm → dist}/server/public-suffix/mod.d.ts +2 -3
- package/{esm → dist}/server/public-suffix/mod.js +1 -2
- package/{esm → dist}/server/public-suffix/rules.d.ts +1 -1
- package/{esm → dist}/server/public-suffix/rules.js +1 -1
- package/{esm → dist}/server/redirect-uri.js +5 -4
- package/{esm → dist}/server/resource-server.d.ts +11 -12
- package/{esm → dist}/server/resource-server.js +12 -14
- package/{esm → dist}/server/services/authorization-code.d.ts +5 -5
- package/{esm → dist}/server/services/client.d.ts +1 -1
- package/{esm → dist}/server/services/device-authorization.d.ts +3 -3
- package/{esm → dist}/server/services/token.d.ts +6 -6
- package/{esm → dist}/server/services/token.js +3 -1
- package/{esm → dist}/server/services/user.d.ts +1 -1
- package/{esm → dist}/server/signing-keys.d.ts +1 -1
- package/{esm → dist}/server/signing-keys.js +8 -2
- package/{esm → dist}/server/utils/hash.js +1 -1
- package/{esm → dist}/testing/contract/auth-request-storage.d.ts +1 -1
- package/{esm → dist}/testing/contract/auth-request-storage.js +24 -29
- package/{esm → dist}/testing/contract/authorization-code.d.ts +6 -6
- package/{esm → dist}/testing/contract/authorization-code.js +16 -17
- package/{esm → dist}/testing/contract/client.d.ts +4 -4
- package/{esm → dist}/testing/contract/client.js +14 -15
- package/{esm → dist}/testing/contract/device-authorization.d.ts +6 -6
- package/{esm → dist}/testing/contract/device-authorization.js +37 -39
- package/{esm → dist}/testing/contract/identity-session.d.ts +6 -1
- package/{esm → dist}/testing/contract/identity-session.js +44 -36
- package/{esm → dist}/testing/contract/identity-user-store.d.ts +8 -2
- package/{esm → dist}/testing/contract/identity-user-store.js +48 -46
- package/{esm → dist}/testing/contract/lockout-store.d.ts +1 -1
- package/{esm → dist}/testing/contract/lockout-store.js +23 -24
- package/{esm → dist}/testing/contract/mfa-store.d.ts +1 -1
- package/{esm → dist}/testing/contract/mfa-store.js +53 -54
- package/{esm → dist}/testing/contract/mod.d.ts +15 -16
- package/{esm → dist}/testing/contract/mod.js +0 -1
- package/{esm → dist}/testing/contract/otp-store.d.ts +1 -1
- package/{esm → dist}/testing/contract/otp-store.js +33 -34
- package/{esm → dist}/testing/contract/rate-limit-store.d.ts +1 -1
- package/{esm → dist}/testing/contract/rate-limit-store.js +15 -16
- package/{esm → dist}/testing/contract/tenant.js +361 -330
- package/{esm → dist}/testing/contract/token-flow-store.d.ts +1 -1
- package/{esm → dist}/testing/contract/token-flow-store.js +27 -32
- package/{esm → dist}/testing/contract/token-reader.d.ts +3 -3
- package/{esm → dist}/testing/contract/token-reader.js +6 -7
- package/{esm → dist}/testing/contract/token.d.ts +7 -7
- package/{esm → dist}/testing/contract/token.js +48 -53
- package/{esm → dist}/testing/contract/user.d.ts +2 -2
- package/{esm → dist}/testing/contract/user.js +8 -9
- package/{esm → dist}/testing/mod.d.ts +5 -6
- package/{esm → dist}/testing/mod.js +2 -3
- package/{esm → dist}/testing/server.d.ts +7 -6
- package/{esm → dist}/testing/server.js +2 -1
- package/{esm → dist}/testing/services.d.ts +11 -11
- package/{esm → dist}/testing/services.js +8 -8
- package/{esm → dist}/testing/tenant.d.ts +11 -7
- package/{esm → dist}/testing/tenant.js +109 -94
- package/dist/utils/_constant-time.d.ts +12 -0
- package/dist/utils/_constant-time.js +19 -0
- package/{esm → dist}/utils/_default-fetch.js +4 -1
- package/dist/utils/_delay.d.ts +13 -0
- package/dist/utils/_delay.js +28 -0
- package/dist/utils/_encoding.d.ts +39 -0
- package/dist/utils/_encoding.js +126 -0
- package/dist/utils/_inbound-request.d.ts +15 -0
- package/dist/utils/_inbound-request.js +25 -0
- package/{esm → dist}/utils/authentication-context.d.ts +1 -1
- package/{esm → dist}/utils/crypto.d.ts +2 -3
- package/{esm → dist}/utils/crypto.js +3 -4
- package/{esm → dist}/utils/pkce.js +1 -1
- package/{esm → dist}/utils/text.js +1 -1
- package/{esm → dist}/utils/url.d.ts +0 -1
- package/{esm → dist}/utils/url.js +0 -1
- package/package.json +156 -33
- package/esm/_dnt.polyfills.d.ts +0 -31
- package/esm/_dnt.polyfills.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.19/almost_equals.d.ts +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.19/almost_equals.js +0 -47
- package/esm/deps/jsr.io/@std/assert/1.0.19/array_includes.d.ts +0 -28
- package/esm/deps/jsr.io/@std/assert/1.0.19/array_includes.js +0 -65
- package/esm/deps/jsr.io/@std/assert/1.0.19/assert.d.ts +0 -16
- package/esm/deps/jsr.io/@std/assert/1.0.19/assert.js +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.19/assertion_error.d.ts +0 -25
- package/esm/deps/jsr.io/@std/assert/1.0.19/assertion_error.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.19/equal.d.ts +0 -24
- package/esm/deps/jsr.io/@std/assert/1.0.19/equal.js +0 -193
- package/esm/deps/jsr.io/@std/assert/1.0.19/equals.d.ts +0 -36
- package/esm/deps/jsr.io/@std/assert/1.0.19/equals.js +0 -61
- package/esm/deps/jsr.io/@std/assert/1.0.19/exists.d.ts +0 -17
- package/esm/deps/jsr.io/@std/assert/1.0.19/exists.js +0 -27
- package/esm/deps/jsr.io/@std/assert/1.0.19/fail.d.ts +0 -14
- package/esm/deps/jsr.io/@std/assert/1.0.19/fail.js +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.19/false.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.19/false.js +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.19/greater.d.ts +0 -19
- package/esm/deps/jsr.io/@std/assert/1.0.19/greater.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.d.ts +0 -19
- package/esm/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.19/instance_of.d.ts +0 -22
- package/esm/deps/jsr.io/@std/assert/1.0.19/instance_of.js +0 -52
- package/esm/deps/jsr.io/@std/assert/1.0.19/is_error.d.ts +0 -24
- package/esm/deps/jsr.io/@std/assert/1.0.19/is_error.js +0 -53
- package/esm/deps/jsr.io/@std/assert/1.0.19/less.d.ts +0 -18
- package/esm/deps/jsr.io/@std/assert/1.0.19/less.js +0 -28
- package/esm/deps/jsr.io/@std/assert/1.0.19/less_or_equal.d.ts +0 -19
- package/esm/deps/jsr.io/@std/assert/1.0.19/less_or_equal.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.19/match.d.ts +0 -17
- package/esm/deps/jsr.io/@std/assert/1.0.19/match.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.19/mod.d.ts +0 -43
- package/esm/deps/jsr.io/@std/assert/1.0.19/mod.js +0 -45
- package/esm/deps/jsr.io/@std/assert/1.0.19/not_equals.d.ts +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.19/not_equals.js +0 -39
- package/esm/deps/jsr.io/@std/assert/1.0.19/not_instance_of.d.ts +0 -19
- package/esm/deps/jsr.io/@std/assert/1.0.19/not_instance_of.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.19/not_match.d.ts +0 -17
- package/esm/deps/jsr.io/@std/assert/1.0.19/not_match.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.d.ts +0 -22
- package/esm/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.js +0 -32
- package/esm/deps/jsr.io/@std/assert/1.0.19/object_match.d.ts +0 -28
- package/esm/deps/jsr.io/@std/assert/1.0.19/object_match.js +0 -177
- package/esm/deps/jsr.io/@std/assert/1.0.19/rejects.d.ts +0 -41
- package/esm/deps/jsr.io/@std/assert/1.0.19/rejects.js +0 -53
- package/esm/deps/jsr.io/@std/assert/1.0.19/strict_equals.d.ts +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.19/strict_equals.js +0 -58
- package/esm/deps/jsr.io/@std/assert/1.0.19/string_includes.d.ts +0 -17
- package/esm/deps/jsr.io/@std/assert/1.0.19/string_includes.js +0 -26
- package/esm/deps/jsr.io/@std/assert/1.0.19/throws.d.ts +0 -44
- package/esm/deps/jsr.io/@std/assert/1.0.19/throws.js +0 -44
- package/esm/deps/jsr.io/@std/assert/1.0.19/unimplemented.d.ts +0 -14
- package/esm/deps/jsr.io/@std/assert/1.0.19/unimplemented.js +0 -20
- package/esm/deps/jsr.io/@std/assert/1.0.19/unreachable.d.ts +0 -14
- package/esm/deps/jsr.io/@std/assert/1.0.19/unreachable.js +0 -20
- package/esm/deps/jsr.io/@std/async/1.5.0/delay.d.ts +0 -44
- package/esm/deps/jsr.io/@std/async/1.5.0/delay.js +0 -84
- package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.d.ts +0 -39
- package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.js +0 -61
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_common16.d.ts +0 -22
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_common16.js +0 -51
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_common32.d.ts +0 -34
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_common32.js +0 -192
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_common64.d.ts +0 -34
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_common64.js +0 -113
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_common_detach.d.ts +0 -3
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_common_detach.js +0 -13
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_types.d.ts +0 -8
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_types.js +0 -2
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_validate_binary_like.d.ts +0 -1
- package/esm/deps/jsr.io/@std/encoding/1.0.11/_validate_binary_like.js +0 -26
- package/esm/deps/jsr.io/@std/encoding/1.0.11/ascii85.d.ts +0 -60
- package/esm/deps/jsr.io/@std/encoding/1.0.11/ascii85.js +0 -152
- package/esm/deps/jsr.io/@std/encoding/1.0.11/base32.d.ts +0 -39
- package/esm/deps/jsr.io/@std/encoding/1.0.11/base32.js +0 -87
- package/esm/deps/jsr.io/@std/encoding/1.0.11/base58.d.ts +0 -39
- package/esm/deps/jsr.io/@std/encoding/1.0.11/base58.js +0 -131
- package/esm/deps/jsr.io/@std/encoding/1.0.11/base64.d.ts +0 -39
- package/esm/deps/jsr.io/@std/encoding/1.0.11/base64.js +0 -82
- package/esm/deps/jsr.io/@std/encoding/1.0.11/base64url.d.ts +0 -39
- package/esm/deps/jsr.io/@std/encoding/1.0.11/base64url.js +0 -72
- package/esm/deps/jsr.io/@std/encoding/1.0.11/hex.d.ts +0 -38
- package/esm/deps/jsr.io/@std/encoding/1.0.11/hex.js +0 -87
- package/esm/deps/jsr.io/@std/encoding/1.0.11/mod.d.ts +0 -97
- package/esm/deps/jsr.io/@std/encoding/1.0.11/mod.js +0 -99
- package/esm/deps/jsr.io/@std/encoding/1.0.11/varint.d.ts +0 -119
- package/esm/deps/jsr.io/@std/encoding/1.0.11/varint.js +0 -209
- package/esm/deps/jsr.io/@std/http/1.1.3/status.d.ts +0 -343
- package/esm/deps/jsr.io/@std/http/1.1.3/status.js +0 -343
- package/esm/deps/jsr.io/@std/internal/1.0.14/assertion_state.d.ts +0 -159
- package/esm/deps/jsr.io/@std/internal/1.0.14/assertion_state.js +0 -223
- package/esm/deps/jsr.io/@std/internal/1.0.14/build_message.d.ts +0 -79
- package/esm/deps/jsr.io/@std/internal/1.0.14/build_message.js +0 -116
- package/esm/deps/jsr.io/@std/internal/1.0.14/diff.d.ts +0 -139
- package/esm/deps/jsr.io/@std/internal/1.0.14/diff.js +0 -277
- package/esm/deps/jsr.io/@std/internal/1.0.14/diff_str.d.ts +0 -98
- package/esm/deps/jsr.io/@std/internal/1.0.14/diff_str.js +0 -181
- package/esm/deps/jsr.io/@std/internal/1.0.14/format.d.ts +0 -29
- package/esm/deps/jsr.io/@std/internal/1.0.14/format.js +0 -68
- package/esm/deps/jsr.io/@std/internal/1.0.14/styles.d.ts +0 -158
- package/esm/deps/jsr.io/@std/internal/1.0.14/styles.js +0 -206
- package/esm/deps/jsr.io/@std/internal/1.0.14/types.d.ts +0 -24
- package/esm/deps/jsr.io/@std/internal/1.0.14/types.js +0 -3
- package/esm/deps/jsr.io/@std/testing/1.0.20/_test_suite.d.ts +0 -91
- package/esm/deps/jsr.io/@std/testing/1.0.20/_test_suite.js +0 -347
- package/esm/deps/jsr.io/@std/testing/1.0.20/bdd.d.ts +0 -382
- package/esm/deps/jsr.io/@std/testing/1.0.20/bdd.js +0 -1110
- package/esm/deps/jsr.io/@udibo/http-error/0.11.1/mod.d.ts +0 -363
- package/esm/deps/jsr.io/@udibo/http-error/0.11.1/mod.js +0 -616
- package/esm/package.json +0 -3
- /package/{esm → dist}/adapters/hono/bff/cookie-prefix.d.ts +0 -0
- /package/{esm → dist}/adapters/hono/bff/proxy.d.ts +0 -0
- /package/{esm → dist}/client/_http.js +0 -0
- /package/{esm → dist}/client/base.js +0 -0
- /package/{esm → dist}/client/browser-storage.js +0 -0
- /package/{esm → dist}/client/check.d.ts +0 -0
- /package/{esm → dist}/client/events.js +0 -0
- /package/{esm → dist}/client/storage.d.ts +0 -0
- /package/{esm → dist}/client/storage.js +0 -0
- /package/{esm → dist}/identity/captcha.d.ts +0 -0
- /package/{esm → dist}/identity/captcha.js +0 -0
- /package/{esm → dist}/identity/delivery.d.ts +0 -0
- /package/{esm → dist}/identity/delivery.js +0 -0
- /package/{esm → dist}/identity/errors.d.ts +0 -0
- /package/{esm → dist}/identity/errors.js +0 -0
- /package/{esm → dist}/identity/events.js +0 -0
- /package/{esm → dist}/identity/external/_token-exchange.d.ts +0 -0
- /package/{esm → dist}/identity/external/_token-exchange.js +0 -0
- /package/{esm → dist}/identity/external/errors.d.ts +0 -0
- /package/{esm → dist}/identity/external/errors.js +0 -0
- /package/{esm → dist}/identity/external/provider.d.ts +0 -0
- /package/{esm → dist}/identity/external/provider.js +0 -0
- /package/{esm → dist}/identity/identifier.d.ts +0 -0
- /package/{esm → dist}/identity/identifier.js +0 -0
- /package/{esm → dist}/identity/lockout.d.ts +0 -0
- /package/{esm → dist}/identity/mfa/recovery-codes.d.ts +0 -0
- /package/{esm → dist}/identity/mfa/recovery-codes.js +0 -0
- /package/{esm → dist}/identity/password-policy.d.ts +0 -0
- /package/{esm → dist}/identity/password-policy.js +0 -0
- /package/{esm → dist}/identity/password.d.ts +0 -0
- /package/{esm → dist}/identity/rate-limit.js +0 -0
- /package/{esm → dist}/identity/session.d.ts +0 -0
- /package/{esm → dist}/identity/token-flow.d.ts +0 -0
- /package/{esm → dist}/models/authentication.d.ts +0 -0
- /package/{esm → dist}/models/authentication.js +0 -0
- /package/{esm → dist}/models/authorization-code.js +0 -0
- /package/{esm → dist}/models/client.d.ts +0 -0
- /package/{esm → dist}/models/client.js +0 -0
- /package/{esm → dist}/models/device-authorization.js +0 -0
- /package/{esm → dist}/models/responses.d.ts +0 -0
- /package/{esm → dist}/models/responses.js +0 -0
- /package/{esm → dist}/models/scope.d.ts +0 -0
- /package/{esm → dist}/models/scope.js +0 -0
- /package/{esm → dist}/models/token.js +0 -0
- /package/{esm → dist}/react/components/types.js +0 -0
- /package/{esm → dist}/react/context.js +0 -0
- /package/{esm → dist}/react/provider.js +0 -0
- /package/{esm → dist}/react/require-auth.d.ts +0 -0
- /package/{esm → dist}/react/use-authorization.js +0 -0
- /package/{esm → dist}/server/_clock-skew.d.ts +0 -0
- /package/{esm → dist}/server/client-authentication.js +0 -0
- /package/{esm → dist}/server/grants/client-credentials.js +0 -0
- /package/{esm → dist}/server/grants/password.js +0 -0
- /package/{esm → dist}/server/redirect-uri.d.ts +0 -0
- /package/{esm → dist}/server/services/authorization-code.js +0 -0
- /package/{esm → dist}/server/services/client.js +0 -0
- /package/{esm → dist}/server/services/device-authorization.js +0 -0
- /package/{esm → dist}/server/services/user.js +0 -0
- /package/{esm → dist}/server/utils/hash.d.ts +0 -0
- /package/{esm → dist}/testing/contract/_race.d.ts +0 -0
- /package/{esm → dist}/testing/contract/_race.js +0 -0
- /package/{esm → dist}/testing/contract/tenant.d.ts +0 -0
- /package/{esm → dist}/utils/_body.d.ts +0 -0
- /package/{esm → dist}/utils/_body.js +0 -0
- /package/{esm → dist}/utils/_buffer.d.ts +0 -0
- /package/{esm → dist}/utils/_buffer.js +0 -0
- /package/{esm → dist}/utils/_default-fetch.d.ts +0 -0
- /package/{esm → dist}/utils/_timing-safe.d.ts +0 -0
- /package/{esm → dist}/utils/_timing-safe.js +0 -0
- /package/{esm → dist}/utils/authentication-context.js +0 -0
- /package/{esm → dist}/utils/basic-auth.d.ts +0 -0
- /package/{esm → dist}/utils/basic-auth.js +0 -0
- /package/{esm → dist}/utils/pkce.d.ts +0 -0
- /package/{esm → dist}/utils/text.d.ts +0 -0
package/dist/cli/mod.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command table for the `udibo-oauth2` executable: the one-off operator
|
|
3
|
+
* commands a deployment needs, so generating key material never means pasting
|
|
4
|
+
* a scratch script into a terminal.
|
|
5
|
+
*
|
|
6
|
+
* ```sh
|
|
7
|
+
* npx udibo-oauth2 oidc keygen
|
|
8
|
+
* npx udibo-oauth2 idp dev
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* No command writes to disk. `idp dev` serves a socket and reads its config
|
|
12
|
+
* file and `OIDC_SIGNING_KEY` from the environment.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import { idpDev } from "./idp/mod.js";
|
|
17
|
+
import { oidcKeygen } from "./keygen.js";
|
|
18
|
+
const commands = new Map([
|
|
19
|
+
[
|
|
20
|
+
"oidc keygen",
|
|
21
|
+
{
|
|
22
|
+
summary: "Generate an ES256 OIDC signing key for OIDC_SIGNING_KEY.",
|
|
23
|
+
run: oidcKeygen,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
"idp dev",
|
|
28
|
+
{
|
|
29
|
+
summary: "Run a local identity provider for development and CI.",
|
|
30
|
+
run: idpDev,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
]);
|
|
34
|
+
function usage() {
|
|
35
|
+
const width = Math.max(...commands.keys().map((name) => name.length));
|
|
36
|
+
return [
|
|
37
|
+
"@udibo/oauth2 — operator commands for OAuth2/OIDC deployments.",
|
|
38
|
+
"",
|
|
39
|
+
"Usage:",
|
|
40
|
+
" udibo-oauth2 <command>",
|
|
41
|
+
"",
|
|
42
|
+
"Commands:",
|
|
43
|
+
...commands
|
|
44
|
+
.entries()
|
|
45
|
+
.map(([name, { summary }]) => ` ${name.padEnd(width)} ${summary}`),
|
|
46
|
+
"",
|
|
47
|
+
"Options:",
|
|
48
|
+
` ${"-h, --help".padEnd(width)} Show this help.`,
|
|
49
|
+
].join("\n");
|
|
50
|
+
}
|
|
51
|
+
function matchCommand(args) {
|
|
52
|
+
for (const depth of [2, 1]) {
|
|
53
|
+
const command = commands.get(args.slice(0, depth).join(" "));
|
|
54
|
+
if (command)
|
|
55
|
+
return { command, args: args.slice(depth) };
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Runs one CLI invocation and resolves with the exit code the process should
|
|
61
|
+
* use: `0` when the command succeeded or help was requested, `1` for no
|
|
62
|
+
* command, an unknown command, a bad argument, or a command failure.
|
|
63
|
+
*
|
|
64
|
+
* Help text and development-provider banners use stdout. Missing or unknown
|
|
65
|
+
* commands and command failures report on stderr. Successful `oidc keygen`
|
|
66
|
+
* without help writes one JWK line on stdout and guidance on stderr. Use that
|
|
67
|
+
* exact invocation and check its exit code before storing stdout as a secret.
|
|
68
|
+
*
|
|
69
|
+
* The `udibo-oauth2` executable calls this with `process.argv.slice(2)` and
|
|
70
|
+
* sets `process.exitCode` to the result.
|
|
71
|
+
*/
|
|
72
|
+
export async function runCli(args, options = {}) {
|
|
73
|
+
if (args.length === 0) {
|
|
74
|
+
console.error(usage());
|
|
75
|
+
return 1;
|
|
76
|
+
}
|
|
77
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
78
|
+
console.log(usage());
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
const match = matchCommand(args);
|
|
82
|
+
if (!match) {
|
|
83
|
+
console.error(`error: unknown command "${args.join(" ")}"\n\n${usage()}`);
|
|
84
|
+
return 1;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
await match.command.run(match.args, options.signal);
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.error(`error: ${error instanceof Error ? error.message : String(error)}`);
|
|
92
|
+
return 1;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import { type OAuth2Error } from "../errors.
|
|
9
|
+
import { type OAuth2Error } from "../errors.ts";
|
|
10
10
|
/** Response bytes accepted from an endpoint before the call is refused. */
|
|
11
11
|
export declare const MAX_RESPONSE_BYTES: number;
|
|
12
12
|
/** Wall-clock budget for one call, covering the connect and the body read. */
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
|
-
import { type OAuth2ClientEvent, type OAuth2ClientEventListener } from "./events.
|
|
14
|
+
import { type OAuth2ClientEvent, type OAuth2ClientEventListener } from "./events.ts";
|
|
15
15
|
/** Generic user-info claims returned by the userinfo or `id_token` helpers. */
|
|
16
16
|
export type UserInfoClaims = Record<string, unknown>;
|
|
17
17
|
/**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
-
import { type BaseLoginOptions, type BaseOptions, type LoginRedirect, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, type UserInfoClaims } from "./base.
|
|
11
|
+
import { type BaseLoginOptions, type BaseOptions, type LoginRedirect, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, type UserInfoClaims } from "./base.ts";
|
|
12
12
|
/** Paths (or absolute URLs) for the BFF session endpoints. */
|
|
13
13
|
export interface BffEndpoints {
|
|
14
14
|
/** Base URL the BFF is mounted under (e.g. `""` for same-origin). */
|
|
@@ -67,14 +67,15 @@ export class BffClient extends OAuth2ClientBase {
|
|
|
67
67
|
session: endpoints.session ?? "/auth/session",
|
|
68
68
|
};
|
|
69
69
|
this.#authorizePath = options.authorizePath;
|
|
70
|
-
this.#csrfHeader =
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
this.#csrfHeader =
|
|
71
|
+
options.csrfHeader === false
|
|
72
|
+
? {}
|
|
73
|
+
: {
|
|
74
|
+
[options.csrfHeader?.name ?? "x-csrf"]: options.csrfHeader?.value ?? "1",
|
|
75
|
+
};
|
|
73
76
|
}
|
|
74
77
|
#url(path) {
|
|
75
|
-
const origin = typeof location !== "undefined"
|
|
76
|
-
? location.origin
|
|
77
|
-
: "http://localhost";
|
|
78
|
+
const origin = typeof location !== "undefined" ? location.origin : "http://localhost";
|
|
78
79
|
return new URL(`${this.#endpoints.baseUrl}${path}`, origin).toString();
|
|
79
80
|
}
|
|
80
81
|
/**
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
|
-
import type { AuthRequestRecord, AuthRequestStorage, RefreshTokenStorage } from "./storage.
|
|
12
|
+
import type { AuthRequestRecord, AuthRequestStorage, RefreshTokenStorage } from "./storage.ts";
|
|
13
13
|
/** Options for {@link IndexedDBRefreshTokenStorage}. */
|
|
14
14
|
export interface IndexedDBRefreshTokenStorageOptions {
|
|
15
15
|
/**
|
|
@@ -94,5 +94,5 @@ export async function checkPermissions(options) {
|
|
|
94
94
|
await response.body?.cancel();
|
|
95
95
|
throw new ServerError(`check request refused: ${response.status}`);
|
|
96
96
|
}
|
|
97
|
-
return await receiveJson(response, CHECK_ENDPOINT);
|
|
97
|
+
return (await receiveJson(response, CHECK_ENDPOINT));
|
|
98
98
|
}
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
|
-
import type { AuthorizationServerMetadata, DeviceAuthorizationResponse } from "../models/responses.
|
|
14
|
-
import type { IntrospectionResponse, TokenResponse } from "../models/token.
|
|
15
|
-
import { type BaseLoginOptions, type BaseOptions, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, type UserInfoClaims } from "./base.
|
|
16
|
-
import { type DiscoveryCache } from "./discovery-cache.
|
|
17
|
-
import { type AuthRequestStorage, type RefreshTokenStorage, type TokenBundle, type TokenStorage } from "./storage.
|
|
13
|
+
import type { AuthorizationServerMetadata, DeviceAuthorizationResponse } from "../models/responses.ts";
|
|
14
|
+
import type { IntrospectionResponse, TokenResponse } from "../models/token.ts";
|
|
15
|
+
import { type BaseLoginOptions, type BaseOptions, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, type UserInfoClaims } from "./base.ts";
|
|
16
|
+
import { type DiscoveryCache } from "./discovery-cache.ts";
|
|
17
|
+
import { type AuthRequestStorage, type RefreshTokenStorage, type TokenBundle, type TokenStorage } from "./storage.ts";
|
|
18
18
|
/** Endpoints resolved via discovery or provided explicitly by the caller. */
|
|
19
19
|
export interface AuthorizationServerEndpoints {
|
|
20
20
|
/** URL of the authorization endpoint (required for the auth-code flow). */
|
|
@@ -236,7 +236,7 @@ export interface ExchangeResult {
|
|
|
236
236
|
*
|
|
237
237
|
* const client = new DirectClient({
|
|
238
238
|
* clientId: "worker",
|
|
239
|
-
* clientSecret:
|
|
239
|
+
* clientSecret: process.env.CLIENT_SECRET!,
|
|
240
240
|
* endpoints: { token: "https://auth.example.com/token" },
|
|
241
241
|
* });
|
|
242
242
|
*
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
|
-
import { delay } from "../deps/jsr.io/@std/async/1.5.0/delay.js";
|
|
14
13
|
import { AccessDeniedError, InvalidGrantError, isOAuth2Error, OAuth2Error as OAuth2ErrorClass, ServerError, } from "../errors.js";
|
|
15
14
|
import { challengeMethods, generateCodeVerifier, generateState, } from "../utils/pkce.js";
|
|
16
15
|
import { encodeBasicAuth } from "../utils/basic-auth.js";
|
|
17
16
|
import { base64urlDecode } from "../utils/crypto.js";
|
|
17
|
+
import { delay } from "../utils/_delay.js";
|
|
18
18
|
import { sanitizeProviderText } from "../utils/text.js";
|
|
19
19
|
import { assertField, assertTokenResponse, errorFromResponse, receiveJson, sendGuarded, } from "./_http.js";
|
|
20
20
|
import { mergedHeaders, OAuth2ClientBase, SIGNED_OUT, } from "./base.js";
|
|
@@ -66,7 +66,7 @@ const REFRESH_SKEW_MS = 30_000;
|
|
|
66
66
|
*
|
|
67
67
|
* const client = new DirectClient({
|
|
68
68
|
* clientId: "worker",
|
|
69
|
-
* clientSecret:
|
|
69
|
+
* clientSecret: process.env.CLIENT_SECRET!,
|
|
70
70
|
* endpoints: { token: "https://auth.example.com/token" },
|
|
71
71
|
* });
|
|
72
72
|
*
|
|
@@ -119,11 +119,12 @@ export class DirectClient extends OAuth2ClientBase {
|
|
|
119
119
|
this.#discoveryCache = options.discoveryCache;
|
|
120
120
|
this.#endpoints = { ...options.endpoints };
|
|
121
121
|
this.#tokenStorage = options.tokenStorage ?? new MemoryTokenStorage();
|
|
122
|
-
this.#refreshTokenStorage =
|
|
123
|
-
new MemoryRefreshTokenStorage();
|
|
122
|
+
this.#refreshTokenStorage =
|
|
123
|
+
options.refreshTokenStorage ?? new MemoryRefreshTokenStorage();
|
|
124
124
|
this.#authRequestTtlMs = options.authRequestTtlMs ?? 10 * 60 * 1000;
|
|
125
|
-
this.#authRequestStorage =
|
|
126
|
-
|
|
125
|
+
this.#authRequestStorage =
|
|
126
|
+
options.authRequestStorage ??
|
|
127
|
+
defaultAuthRequestStorage(this.#authRequestTtlMs);
|
|
127
128
|
}
|
|
128
129
|
/** True when the client was given a secret and authenticates via Basic. */
|
|
129
130
|
get isConfidential() {
|
|
@@ -335,8 +336,7 @@ export class DirectClient extends OAuth2ClientBase {
|
|
|
335
336
|
const codeVerifier = generateCodeVerifier();
|
|
336
337
|
const codeChallenge = await challengeMethods.S256(codeVerifier);
|
|
337
338
|
const scope = options.scope ?? this.#scope;
|
|
338
|
-
const authRequestStorage = options.authRequestStorage ??
|
|
339
|
-
this.#authRequestStorage;
|
|
339
|
+
const authRequestStorage = options.authRequestStorage ?? this.#authRequestStorage;
|
|
340
340
|
await authRequestStorage.set(state, {
|
|
341
341
|
codeVerifier,
|
|
342
342
|
returnTo: options.returnTo,
|
|
@@ -463,8 +463,7 @@ export class DirectClient extends OAuth2ClientBase {
|
|
|
463
463
|
* `cause` is the transport failure.
|
|
464
464
|
*/
|
|
465
465
|
async exchangeAuthorizationCode(code, state, options = {}) {
|
|
466
|
-
const authRequestStorage = options.authRequestStorage ??
|
|
467
|
-
this.#authRequestStorage;
|
|
466
|
+
const authRequestStorage = options.authRequestStorage ?? this.#authRequestStorage;
|
|
468
467
|
const record = await claimAuthRequest(authRequestStorage, state);
|
|
469
468
|
if (!record)
|
|
470
469
|
throw new InvalidGrantError("unknown state parameter");
|
|
@@ -609,7 +608,7 @@ export class DirectClient extends OAuth2ClientBase {
|
|
|
609
608
|
}
|
|
610
609
|
async #doRefresh(reportTransient, snapshot) {
|
|
611
610
|
const { version, refreshToken } = await this.#mutateSession(async () => {
|
|
612
|
-
const version = snapshot.version = this.#sessionVersion;
|
|
611
|
+
const version = (snapshot.version = this.#sessionVersion);
|
|
613
612
|
return {
|
|
614
613
|
version,
|
|
615
614
|
refreshToken: await this.#readRefreshToken(reportTransient),
|
|
@@ -1221,8 +1220,7 @@ function toSearchParams(input) {
|
|
|
1221
1220
|
}
|
|
1222
1221
|
}
|
|
1223
1222
|
function defaultAuthRequestStorage(ttlMs) {
|
|
1224
|
-
const inBrowserDocument = typeof document !== "undefined" &&
|
|
1225
|
-
typeof sessionStorage !== "undefined";
|
|
1223
|
+
const inBrowserDocument = typeof document !== "undefined" && typeof sessionStorage !== "undefined";
|
|
1226
1224
|
return inBrowserDocument
|
|
1227
1225
|
? new SessionStorageAuthRequestStorage({ ttlMs })
|
|
1228
1226
|
: new MemoryAuthRequestStorage({ ttlMs });
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
-
import type { AuthorizationServerMetadata } from "../models/responses.
|
|
7
|
+
import type { AuthorizationServerMetadata } from "../models/responses.ts";
|
|
8
8
|
/**
|
|
9
9
|
* Default discovery-document lifetime, one hour: the TTL of a
|
|
10
10
|
* {@link MemoryDiscoveryCache}, and how long a `DirectClient` without a
|
|
@@ -47,8 +47,8 @@ export class MemoryDiscoveryCache {
|
|
|
47
47
|
/** Creates a cache with the given TTL and entry ceiling. */
|
|
48
48
|
constructor(options = {}) {
|
|
49
49
|
this.#ttlMs = options.ttlMs ?? DEFAULT_DISCOVERY_TTL_MS;
|
|
50
|
-
this.#maxEntries =
|
|
51
|
-
DEFAULT_DISCOVERY_CACHE_MAX_ENTRIES;
|
|
50
|
+
this.#maxEntries =
|
|
51
|
+
options.maxEntries ?? DEFAULT_DISCOVERY_CACHE_MAX_ENTRIES;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Returns the fresh cached entry for `issuer`, joins the in-flight `load`
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import type { TokenBundle } from "./storage.
|
|
9
|
+
import type { TokenBundle } from "./storage.ts";
|
|
10
10
|
/** The authenticated user has been resolved or has changed. */
|
|
11
11
|
export interface AuthenticatedEvent {
|
|
12
12
|
/** Discriminant tag for this event variant. */
|
|
@@ -23,15 +23,14 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @module
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export { type
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
35
|
-
export
|
|
36
|
-
export {
|
|
37
|
-
export { IndexedDBRefreshTokenStorage, type IndexedDBRefreshTokenStorageOptions, SessionStorageAuthRequestStorage, type SessionStorageAuthRequestStorageOptions, } from "./browser-storage.js";
|
|
26
|
+
export { type BaseLoginOptions, type BaseOptions, type LoginRedirect, type LogoutOptions, type LogoutRedirect, OAuth2ClientBase, type SessionState, SIGNED_OUT, type UserInfoClaims, } from "./base.ts";
|
|
27
|
+
export { BffClient, type BffClientOptions, type BffEndpoints, } from "./bff-client.ts";
|
|
28
|
+
export { type AuthorizationCallbackResult, type AuthorizationRedirect, type AuthorizationServerEndpoints, type DeviceAuthorizationOptions, DirectClient, type DirectClientOptions, type ExchangeOptions, type ExchangeResult, type IntrospectionResult, type LoginOptions, type PollDeviceTokenOptions, } from "./direct-client.ts";
|
|
29
|
+
export { DEFAULT_DISCOVERY_CACHE_MAX_ENTRIES, DEFAULT_DISCOVERY_TTL_MS, type DiscoveryCache, type DiscoveryCacheEntry, MemoryDiscoveryCache, type MemoryDiscoveryCacheOptions, } from "./discovery-cache.ts";
|
|
30
|
+
export { type AuthenticatedEvent, type ErrorEvent, type LoggedOutEvent, type OAuth2ClientEvent, type OAuth2ClientEventListener, type TokenRefreshedEvent, } from "./events.ts";
|
|
31
|
+
export { type AuthRequestRecord, type AuthRequestStorage, MemoryAuthRequestStorage, type MemoryAuthRequestStorageOptions, MemoryRefreshTokenStorage, MemoryTokenStorage, type RefreshTokenStorage, type TokenBundle, type TokenStorage, } from "./storage.ts";
|
|
32
|
+
export { checkPermissions, type CheckPermissionsOptions, type CheckPermissionsResult, type CheckResource, } from "./check.ts";
|
|
33
|
+
export { Authorization, authorizationFromClaims, } from "../models/authorization.ts";
|
|
34
|
+
export type { OrganizationContext } from "../models/authorization.ts";
|
|
35
|
+
export { isOAuth2Error, OAuth2Error } from "../errors.ts";
|
|
36
|
+
export { IndexedDBRefreshTokenStorage, type IndexedDBRefreshTokenStorageOptions, SessionStorageAuthRequestStorage, type SessionStorageAuthRequestStorageOptions, } from "./browser-storage.ts";
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @module
|
|
25
25
|
*/
|
|
26
|
-
import "../_dnt.polyfills.js";
|
|
27
26
|
export { OAuth2ClientBase, SIGNED_OUT, } from "./base.js";
|
|
28
27
|
export { BffClient, } from "./bff-client.js";
|
|
29
28
|
export { DirectClient, } from "./direct-client.js";
|
|
30
29
|
export { DEFAULT_DISCOVERY_CACHE_MAX_ENTRIES, DEFAULT_DISCOVERY_TTL_MS, MemoryDiscoveryCache, } from "./discovery-cache.js";
|
|
30
|
+
export {} from "./events.js";
|
|
31
31
|
export { MemoryAuthRequestStorage, MemoryRefreshTokenStorage, MemoryTokenStorage, } from "./storage.js";
|
|
32
32
|
export { checkPermissions, } from "./check.js";
|
|
33
33
|
export { Authorization, authorizationFromClaims, } from "../models/authorization.js";
|
package/{esm → dist}/errors.d.ts
RENAMED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @see https://datatracker.ietf.org/doc/html/rfc6750#section-3.1
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
|
-
import { HttpError, type HttpErrorOptions } from "
|
|
14
|
+
import { HttpError, type HttpErrorOptions } from "@udibo/http-error";
|
|
15
15
|
/**
|
|
16
16
|
* Problem Details extension members carried by every {@linkcode OAuth2Error}.
|
|
17
17
|
*
|
package/{esm → dist}/errors.js
RENAMED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @see https://datatracker.ietf.org/doc/html/rfc6750#section-3.1
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
|
-
import { createHttpErrorClass, HttpError, } from "
|
|
14
|
+
import { createHttpErrorClass, HttpError, } from "@udibo/http-error";
|
|
15
15
|
/**
|
|
16
16
|
* The base OAuth2 error class, an {@linkcode HttpError} subclass that defaults
|
|
17
17
|
* to the `server_error` code. Used as a catch-all and as the value-side
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*
|
|
25
25
|
* @module
|
|
26
26
|
*/
|
|
27
|
-
import type { DeliveryHooks } from "./delivery.
|
|
27
|
+
import type { DeliveryHooks } from "./delivery.ts";
|
|
28
28
|
/** Why a sign-in attempt failed. Internal detail — never shown to the user. */
|
|
29
29
|
export type SignInFailureReason = "unknown_identifier" | "no_password" | "wrong_password";
|
|
30
30
|
/**
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
-
import { PROVIDER_TEXT_MAX_LENGTH, sanitizeProviderText } from "../../utils/text.
|
|
11
|
+
import { PROVIDER_TEXT_MAX_LENGTH, sanitizeProviderText } from "../../utils/text.ts";
|
|
12
12
|
export { PROVIDER_TEXT_MAX_LENGTH, sanitizeProviderText };
|
|
13
13
|
/**
|
|
14
14
|
* Clock-skew allowance, in seconds, when checking an id_token's `exp` claim.
|
|
@@ -75,8 +75,7 @@ export function assertIdTokenClaims(input) {
|
|
|
75
75
|
`configured issuer points at a proxy or the wrong tenant.`);
|
|
76
76
|
}
|
|
77
77
|
const aud = claims.aud;
|
|
78
|
-
const audienceOk = aud === clientId ||
|
|
79
|
-
(Array.isArray(aud) && aud.includes(clientId));
|
|
78
|
+
const audienceOk = aud === clientId || (Array.isArray(aud) && aud.includes(clientId));
|
|
80
79
|
if (!audienceOk) {
|
|
81
80
|
throw new ExternalAuthError(provider, "provider_error", `id_token "aud" (${JSON.stringify(aud)}) does not include clientId ` +
|
|
82
81
|
`"${clientId}" — the token was issued to a different client ` +
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import { decodeBase64 } from "../../deps/jsr.io/@std/encoding/1.0.11/base64.js";
|
|
10
9
|
import { toArrayBuffer } from "../../utils/_buffer.js";
|
|
10
|
+
import { decodeBase64 } from "../../utils/_encoding.js";
|
|
11
11
|
import { base64urlEncode } from "../../utils/crypto.js";
|
|
12
12
|
import { ExternalAuthError } from "./errors.js";
|
|
13
13
|
/** Apple's audience for the client-secret JWT. */
|
|
@@ -76,7 +76,7 @@ async function importPrivateKey(providerId, pem) {
|
|
|
76
76
|
* teamId: "ABCDE12345",
|
|
77
77
|
* keyId: "KEY1234567",
|
|
78
78
|
* clientId: "com.example.web",
|
|
79
|
-
* privateKey:
|
|
79
|
+
* privateKey: process.env.APPLE_PRIVATE_KEY!,
|
|
80
80
|
* });
|
|
81
81
|
* ```
|
|
82
82
|
*/
|
|
@@ -85,9 +85,9 @@ export async function generateAppleClientSecret(options) {
|
|
|
85
85
|
const teamId = requireNonEmpty(providerId, options.teamId, "team id");
|
|
86
86
|
const keyId = requireNonEmpty(providerId, options.keyId, "key id");
|
|
87
87
|
const clientId = requireNonEmpty(providerId, options.clientId, "client id (Services ID)");
|
|
88
|
-
const ttl = options.expiresInSeconds ??
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
const ttl = options.expiresInSeconds ?? DEFAULT_APPLE_CLIENT_SECRET_TTL_SECONDS;
|
|
89
|
+
if (!Number.isFinite(ttl) ||
|
|
90
|
+
ttl <= 0 ||
|
|
91
91
|
ttl > APPLE_CLIENT_SECRET_MAX_TTL_SECONDS) {
|
|
92
92
|
throw configError(providerId, `Apple client secret TTL must be between 1 and ` +
|
|
93
93
|
`${APPLE_CLIENT_SECRET_MAX_TTL_SECONDS} seconds (6 months); ` +
|
|
@@ -120,8 +120,7 @@ function encodeSegment(value) {
|
|
|
120
120
|
* {@link ExternalAuthError}; a failed call caches nothing.
|
|
121
121
|
*/
|
|
122
122
|
export function createAppleClientSecretFactory(options) {
|
|
123
|
-
const ttl = options.expiresInSeconds ??
|
|
124
|
-
DEFAULT_APPLE_CLIENT_SECRET_TTL_SECONDS;
|
|
123
|
+
const ttl = options.expiresInSeconds ?? DEFAULT_APPLE_CLIENT_SECRET_TTL_SECONDS;
|
|
125
124
|
const renewBefore = options.renewBeforeSeconds ?? 60 * 60;
|
|
126
125
|
let cached = null;
|
|
127
126
|
return async () => {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @module
|
|
17
17
|
*/
|
|
18
|
-
import { type AppleClientSecretFactory, type AppleClientSecretOptions } from "./apple-client-secret.
|
|
19
|
-
import type { ExternalProvider } from "./provider.
|
|
18
|
+
import { type AppleClientSecretFactory, type AppleClientSecretOptions } from "./apple-client-secret.ts";
|
|
19
|
+
import type { ExternalProvider } from "./provider.ts";
|
|
20
20
|
/** Options for {@link appleProvider}. */
|
|
21
21
|
export interface AppleProviderOptions extends Pick<AppleClientSecretOptions, "teamId" | "keyId" | "privateKey"> {
|
|
22
22
|
/** The Services ID configured for web Sign in with Apple (the `client_id`). */
|
|
@@ -61,9 +61,9 @@ export interface AppleProviderOptions extends Pick<AppleClientSecretOptions, "te
|
|
|
61
61
|
* const flow = new ExternalAuthFlow({
|
|
62
62
|
* provider: appleProvider({
|
|
63
63
|
* clientId: "com.example.web",
|
|
64
|
-
* teamId:
|
|
65
|
-
* keyId:
|
|
66
|
-
* privateKey:
|
|
64
|
+
* teamId: process.env.APPLE_TEAM_ID!,
|
|
65
|
+
* keyId: process.env.APPLE_KEY_ID!,
|
|
66
|
+
* privateKey: process.env.APPLE_PRIVATE_KEY!,
|
|
67
67
|
* }),
|
|
68
68
|
* });
|
|
69
69
|
* ```
|
|
@@ -52,9 +52,9 @@ const SIGNATURE_NOT_VERIFIED = `Apple id_token signature did not verify against
|
|
|
52
52
|
* const flow = new ExternalAuthFlow({
|
|
53
53
|
* provider: appleProvider({
|
|
54
54
|
* clientId: "com.example.web",
|
|
55
|
-
* teamId:
|
|
56
|
-
* keyId:
|
|
57
|
-
* privateKey:
|
|
55
|
+
* teamId: process.env.APPLE_TEAM_ID!,
|
|
56
|
+
* keyId: process.env.APPLE_KEY_ID!,
|
|
57
|
+
* privateKey: process.env.APPLE_PRIVATE_KEY!,
|
|
58
58
|
* }),
|
|
59
59
|
* });
|
|
60
60
|
* ```
|
|
@@ -178,8 +178,7 @@ export function appleProvider(options) {
|
|
|
178
178
|
match = pick(await loadJwks());
|
|
179
179
|
}
|
|
180
180
|
if (!match) {
|
|
181
|
-
throw new ExternalAuthError(id, "provider_error", `Apple's JWKS has no key with kid "${String(kid)}" — the id_token was ` +
|
|
182
|
-
`signed by a key Apple no longer publishes.`);
|
|
181
|
+
throw new ExternalAuthError(id, "provider_error", `Apple's JWKS has no key with kid "${String(kid)}" — the id_token was ` + `signed by a key Apple no longer publishes.`);
|
|
183
182
|
}
|
|
184
183
|
return match;
|
|
185
184
|
}
|
|
@@ -231,16 +230,16 @@ function appleTokenErrorHint(error) {
|
|
|
231
230
|
return `Ensure the sign-in requested the "openid" flow scopes.`;
|
|
232
231
|
}
|
|
233
232
|
if (error === "invalid_client") {
|
|
234
|
-
return `The client-secret JWT is wrong — check the team id, key id, and ` +
|
|
235
|
-
`Services ID (client id)
|
|
233
|
+
return (`The client-secret JWT is wrong — check the team id, key id, and ` +
|
|
234
|
+
`Services ID (client id).`);
|
|
236
235
|
}
|
|
237
236
|
if (error === "invalid_grant") {
|
|
238
|
-
return `Apple rejected the code — it expired, was already used, or the ` +
|
|
237
|
+
return (`Apple rejected the code — it expired, was already used, or the ` +
|
|
239
238
|
`redirect URI does not match the Services ID configuration. Ask the ` +
|
|
240
|
-
`user to start again
|
|
239
|
+
`user to start again.`);
|
|
241
240
|
}
|
|
242
|
-
return `See Apple's "Generate and validate tokens" documentation for the ` +
|
|
243
|
-
`error's meaning
|
|
241
|
+
return (`See Apple's "Generate and validate tokens" documentation for the ` +
|
|
242
|
+
`error's meaning.`);
|
|
244
243
|
}
|
|
245
244
|
function decodeJson(providerId, segment, what) {
|
|
246
245
|
try {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type { ExternalProvider } from "./provider.
|
|
6
|
+
import type { ExternalProvider } from "./provider.ts";
|
|
7
7
|
/** Options for {@link discordProvider}. */
|
|
8
8
|
export interface DiscordProviderOptions {
|
|
9
9
|
/** Client ID of the Discord application (OAuth2 tab). */
|
|
@@ -33,8 +33,8 @@ export interface DiscordProviderOptions {
|
|
|
33
33
|
* ```ts
|
|
34
34
|
* const flow = new ExternalAuthFlow({
|
|
35
35
|
* provider: discordProvider({
|
|
36
|
-
* clientId:
|
|
37
|
-
* clientSecret:
|
|
36
|
+
* clientId: process.env.DISCORD_CLIENT_ID!,
|
|
37
|
+
* clientSecret: process.env.DISCORD_CLIENT_SECRET!,
|
|
38
38
|
* }),
|
|
39
39
|
* });
|
|
40
40
|
* ```
|
|
@@ -30,8 +30,8 @@ function avatarUrl(user) {
|
|
|
30
30
|
* ```ts
|
|
31
31
|
* const flow = new ExternalAuthFlow({
|
|
32
32
|
* provider: discordProvider({
|
|
33
|
-
* clientId:
|
|
34
|
-
* clientSecret:
|
|
33
|
+
* clientId: process.env.DISCORD_CLIENT_ID!,
|
|
34
|
+
* clientSecret: process.env.DISCORD_CLIENT_SECRET!,
|
|
35
35
|
* }),
|
|
36
36
|
* });
|
|
37
37
|
* ```
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
|
-
import type { ExternalAuthTransient, ExternalProfile, ExternalProvider } from "./provider.
|
|
9
|
+
import type { ExternalAuthTransient, ExternalProfile, ExternalProvider } from "./provider.ts";
|
|
10
10
|
/** Default {@link ExternalAuthFlowOptions.maxTransientAgeMs}: 10 minutes. */
|
|
11
11
|
export declare const DEFAULT_MAX_TRANSIENT_AGE_MS: number;
|
|
12
12
|
/** Options for {@link ExternalAuthFlow}. */
|
|
@@ -48,8 +48,8 @@ export class ExternalAuthFlow {
|
|
|
48
48
|
/** Creates a flow for one configured provider. */
|
|
49
49
|
constructor(options) {
|
|
50
50
|
this.provider = options.provider;
|
|
51
|
-
this.#maxTransientAgeMs =
|
|
52
|
-
DEFAULT_MAX_TRANSIENT_AGE_MS;
|
|
51
|
+
this.#maxTransientAgeMs =
|
|
52
|
+
options.maxTransientAgeMs ?? DEFAULT_MAX_TRANSIENT_AGE_MS;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Begins a sign-in attempt: generates the per-attempt `state` (plus a PKCE
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
-
import type { ExternalProvider } from "./provider.
|
|
7
|
+
import type { ExternalProvider } from "./provider.ts";
|
|
8
8
|
/** Options for {@link githubProvider}. */
|
|
9
9
|
export interface GithubProviderOptions {
|
|
10
10
|
/** Client ID of the GitHub OAuth App (or GitHub App). */
|
|
@@ -37,8 +37,8 @@ export interface GithubProviderOptions {
|
|
|
37
37
|
* ```ts
|
|
38
38
|
* const flow = new ExternalAuthFlow({
|
|
39
39
|
* provider: githubProvider({
|
|
40
|
-
* clientId:
|
|
41
|
-
* clientSecret:
|
|
40
|
+
* clientId: process.env.GITHUB_CLIENT_ID!,
|
|
41
|
+
* clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
42
42
|
* }),
|
|
43
43
|
* });
|
|
44
44
|
* ```
|