@atproto/oauth-provider 0.6.6 → 0.7.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/CHANGELOG.md +49 -0
- package/dist/access-token/access-token-mode.d.ts +5 -0
- package/dist/access-token/access-token-mode.d.ts.map +1 -0
- package/dist/access-token/access-token-mode.js +9 -0
- package/dist/access-token/access-token-mode.js.map +1 -0
- package/dist/account/account-manager.d.ts +13 -7
- package/dist/account/account-manager.d.ts.map +1 -1
- package/dist/account/account-manager.js +69 -52
- package/dist/account/account-manager.js.map +1 -1
- package/dist/account/account-store.d.ts +88 -77
- package/dist/account/account-store.d.ts.map +1 -1
- package/dist/account/account-store.js +24 -73
- package/dist/account/account-store.js.map +1 -1
- package/dist/account/sign-in-data.d.ts +4 -13
- package/dist/account/sign-in-data.d.ts.map +1 -1
- package/dist/account/sign-in-data.js +9 -9
- package/dist/account/sign-in-data.js.map +1 -1
- package/dist/account/sign-up-input.d.ts +4 -5
- package/dist/account/sign-up-input.d.ts.map +1 -1
- package/dist/account/sign-up-input.js +13 -3
- package/dist/account/sign-up-input.js.map +1 -1
- package/dist/client/client-manager.d.ts +4 -1
- package/dist/client/client-manager.d.ts.map +1 -1
- package/dist/client/client-manager.js +13 -1
- package/dist/client/client-manager.js.map +1 -1
- package/dist/client/client-store.d.ts +1 -1
- package/dist/client/client-store.d.ts.map +1 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -2
- package/dist/constants.js.map +1 -1
- package/dist/customization/branding.d.ts +54 -0
- package/dist/customization/branding.d.ts.map +1 -0
- package/dist/customization/branding.js +13 -0
- package/dist/customization/branding.js.map +1 -0
- package/dist/customization/build-customization-css.d.ts +3 -0
- package/dist/customization/build-customization-css.d.ts.map +1 -0
- package/dist/customization/build-customization-css.js +27 -0
- package/dist/customization/build-customization-css.js.map +1 -0
- package/dist/customization/build-customization-data.d.ts +4 -0
- package/dist/customization/build-customization-data.d.ts.map +1 -0
- package/dist/customization/build-customization-data.js +18 -0
- package/dist/customization/build-customization-data.js.map +1 -0
- package/dist/customization/colors.d.ts +7 -0
- package/dist/customization/colors.d.ts.map +1 -0
- package/dist/customization/colors.js +27 -0
- package/dist/customization/colors.js.map +1 -0
- package/dist/customization/customization.d.ts +129 -0
- package/dist/customization/customization.d.ts.map +1 -0
- package/dist/customization/customization.js +26 -0
- package/dist/customization/customization.js.map +1 -0
- package/dist/customization/links.d.ts +26 -0
- package/dist/customization/links.d.ts.map +1 -0
- package/dist/customization/links.js +12 -0
- package/dist/customization/links.js.map +1 -0
- package/dist/device/device-id.d.ts +1 -0
- package/dist/device/device-id.d.ts.map +1 -1
- package/dist/device/device-id.js +4 -0
- package/dist/device/device-id.js.map +1 -1
- package/dist/device/device-manager.d.ts +6 -36
- package/dist/device/device-manager.d.ts.map +1 -1
- package/dist/device/device-manager.js +49 -43
- package/dist/device/device-manager.js.map +1 -1
- package/dist/device/device-store.d.ts +1 -0
- package/dist/device/device-store.d.ts.map +1 -1
- package/dist/device/device-store.js.map +1 -1
- package/dist/dpop/dpop-manager.d.ts +3 -3
- package/dist/dpop/dpop-nonce.d.ts +3 -3
- package/dist/dpop/dpop-nonce.d.ts.map +1 -1
- package/dist/errors/access-denied-error.d.ts +4 -3
- package/dist/errors/access-denied-error.d.ts.map +1 -1
- package/dist/errors/access-denied-error.js +5 -6
- package/dist/errors/access-denied-error.js.map +1 -1
- package/dist/{output/build-error-payload.d.ts → errors/error-parser.d.ts} +1 -1
- package/dist/errors/error-parser.d.ts.map +1 -0
- package/dist/{output/build-error-payload.js → errors/error-parser.js} +2 -2
- package/dist/errors/error-parser.js.map +1 -0
- package/dist/errors/invalid-grant-error.d.ts +1 -0
- package/dist/errors/invalid-grant-error.d.ts.map +1 -1
- package/dist/errors/invalid-grant-error.js +5 -0
- package/dist/errors/invalid-grant-error.js.map +1 -1
- package/dist/errors/login-required-error.d.ts +1 -0
- package/dist/errors/login-required-error.d.ts.map +1 -1
- package/dist/errors/login-required-error.js +5 -0
- package/dist/errors/login-required-error.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/html/build-document.d.ts +2 -2
- package/dist/lib/html/build-document.d.ts.map +1 -1
- package/dist/lib/html/build-document.js +4 -0
- package/dist/lib/html/build-document.js.map +1 -1
- package/dist/lib/html/hydration-data.d.ts +4 -0
- package/dist/lib/html/hydration-data.d.ts.map +1 -0
- package/dist/{output/backend-data.js → lib/html/hydration-data.js} +8 -8
- package/dist/lib/html/hydration-data.js.map +1 -0
- package/dist/lib/html/tags.d.ts +1 -1
- package/dist/lib/html/tags.d.ts.map +1 -1
- package/dist/lib/html/tags.js +1 -1
- package/dist/lib/html/tags.js.map +1 -1
- package/dist/lib/http/accept.d.ts +2 -2
- package/dist/lib/http/accept.d.ts.map +1 -1
- package/dist/lib/http/accept.js +1 -1
- package/dist/lib/http/accept.js.map +1 -1
- package/dist/lib/http/context.d.ts +2 -4
- package/dist/lib/http/context.d.ts.map +1 -1
- package/dist/lib/http/context.js +29 -4
- package/dist/lib/http/context.js.map +1 -1
- package/dist/lib/http/headers.d.ts +3 -0
- package/dist/lib/http/headers.d.ts.map +1 -0
- package/dist/lib/http/headers.js +14 -0
- package/dist/lib/http/headers.js.map +1 -0
- package/dist/lib/http/index.d.ts +1 -0
- package/dist/lib/http/index.d.ts.map +1 -1
- package/dist/lib/http/index.js +1 -0
- package/dist/lib/http/index.js.map +1 -1
- package/dist/lib/http/middleware.d.ts +1 -1
- package/dist/lib/http/middleware.d.ts.map +1 -1
- package/dist/lib/http/middleware.js +8 -24
- package/dist/lib/http/middleware.js.map +1 -1
- package/dist/lib/http/parser.d.ts +3 -3
- package/dist/lib/http/parser.d.ts.map +1 -1
- package/dist/lib/http/request.d.ts +13 -9
- package/dist/lib/http/request.d.ts.map +1 -1
- package/dist/lib/http/request.js +27 -49
- package/dist/lib/http/request.js.map +1 -1
- package/dist/lib/http/response.d.ts +6 -2
- package/dist/lib/http/response.d.ts.map +1 -1
- package/dist/lib/http/response.js +31 -11
- package/dist/lib/http/response.js.map +1 -1
- package/dist/lib/http/route.d.ts +3 -3
- package/dist/lib/http/route.d.ts.map +1 -1
- package/dist/lib/http/route.js +1 -1
- package/dist/lib/http/route.js.map +1 -1
- package/dist/lib/http/router.d.ts +12 -11
- package/dist/lib/http/router.d.ts.map +1 -1
- package/dist/lib/http/router.js +26 -34
- package/dist/lib/http/router.js.map +1 -1
- package/dist/lib/http/security-headers.js +1 -1
- package/dist/lib/http/security-headers.js.map +1 -1
- package/dist/lib/http/stream.d.ts +3 -3
- package/dist/lib/http/stream.d.ts.map +1 -1
- package/dist/lib/http/types.d.ts +1 -1
- package/dist/lib/http/types.d.ts.map +1 -1
- package/dist/lib/send-web-page.d.ts +8 -0
- package/dist/lib/send-web-page.d.ts.map +1 -0
- package/dist/{output → lib}/send-web-page.js +9 -7
- package/dist/lib/send-web-page.js.map +1 -0
- package/dist/lib/util/authorization-header.d.ts.map +1 -1
- package/dist/lib/util/color.d.ts +32 -0
- package/dist/lib/util/color.d.ts.map +1 -0
- package/dist/lib/util/color.js +116 -0
- package/dist/lib/util/color.js.map +1 -0
- package/dist/lib/util/crypto.d.ts +1 -0
- package/dist/lib/util/crypto.d.ts.map +1 -1
- package/dist/lib/util/crypto.js +8 -3
- package/dist/lib/util/crypto.js.map +1 -1
- package/dist/lib/util/function.d.ts +1 -0
- package/dist/lib/util/function.d.ts.map +1 -1
- package/dist/lib/util/function.js +12 -0
- package/dist/lib/util/function.js.map +1 -1
- package/dist/lib/util/locale.d.ts +20 -0
- package/dist/lib/util/locale.d.ts.map +1 -0
- package/dist/lib/util/locale.js +14 -0
- package/dist/lib/util/locale.js.map +1 -0
- package/dist/lib/util/time.d.ts +1 -1
- package/dist/lib/util/time.d.ts.map +1 -1
- package/dist/lib/util/time.js +1 -1
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/type.d.ts +22 -0
- package/dist/lib/util/type.d.ts.map +1 -1
- package/dist/lib/util/type.js.map +1 -1
- package/dist/lib/util/ui8.d.ts +4 -0
- package/dist/lib/util/ui8.d.ts.map +1 -0
- package/dist/lib/util/ui8.js +17 -0
- package/dist/lib/util/ui8.js.map +1 -0
- package/dist/lib/util/zod-error.d.ts +2 -0
- package/dist/lib/util/zod-error.d.ts.map +1 -0
- package/dist/lib/util/zod-error.js +16 -0
- package/dist/lib/util/zod-error.js.map +1 -0
- package/dist/oauth-errors.d.ts +22 -22
- package/dist/oauth-errors.d.ts.map +1 -1
- package/dist/oauth-errors.js +37 -45
- package/dist/oauth-errors.js.map +1 -1
- package/dist/oauth-hooks.d.ts +11 -23
- package/dist/oauth-hooks.d.ts.map +1 -1
- package/dist/oauth-hooks.js.map +1 -1
- package/dist/oauth-middleware.d.ts +12 -0
- package/dist/oauth-middleware.d.ts.map +1 -0
- package/dist/oauth-middleware.js +32 -0
- package/dist/oauth-middleware.js.map +1 -0
- package/dist/oauth-provider.d.ts +109 -113
- package/dist/oauth-provider.d.ts.map +1 -1
- package/dist/oauth-provider.js +124 -542
- package/dist/oauth-provider.js.map +1 -1
- package/dist/oauth-verifier.d.ts +7 -26
- package/dist/oauth-verifier.d.ts.map +1 -1
- package/dist/oauth-verifier.js +6 -16
- package/dist/oauth-verifier.js.map +1 -1
- package/dist/request/code.d.ts.map +1 -1
- package/dist/request/request-data.d.ts +2 -4
- package/dist/request/request-data.d.ts.map +1 -1
- package/dist/request/request-data.js.map +1 -1
- package/dist/request/request-manager.d.ts +4 -2
- package/dist/request/request-manager.d.ts.map +1 -1
- package/dist/request/request-manager.js +9 -8
- package/dist/request/request-manager.js.map +1 -1
- package/dist/request/request-store.d.ts +6 -0
- package/dist/request/request-store.d.ts.map +1 -1
- package/dist/request/request-store.js +3 -1
- package/dist/request/request-store.js.map +1 -1
- package/dist/result/authorization-redirect-parameters.d.ts +18 -0
- package/dist/result/authorization-redirect-parameters.d.ts.map +1 -0
- package/dist/result/authorization-redirect-parameters.js +3 -0
- package/dist/result/authorization-redirect-parameters.js.map +1 -0
- package/dist/result/authorization-result-authorize-page.d.ts +13 -0
- package/dist/result/authorization-result-authorize-page.d.ts.map +1 -0
- package/dist/result/authorization-result-authorize-page.js +3 -0
- package/dist/result/authorization-result-authorize-page.js.map +1 -0
- package/dist/result/authorization-result-redirect.d.ts +8 -0
- package/dist/result/authorization-result-redirect.d.ts.map +1 -0
- package/dist/result/authorization-result-redirect.js +3 -0
- package/dist/result/authorization-result-redirect.js.map +1 -0
- package/dist/router/assets/assets-manifest.d.ts +10 -0
- package/dist/router/assets/assets-manifest.d.ts.map +1 -0
- package/dist/router/assets/assets-manifest.js +77 -0
- package/dist/router/assets/assets-manifest.js.map +1 -0
- package/dist/router/assets/assets.d.ts +16 -0
- package/dist/router/assets/assets.d.ts.map +1 -0
- package/dist/router/assets/assets.js +43 -0
- package/dist/router/assets/assets.js.map +1 -0
- package/dist/router/assets/csrf.d.ts +4 -0
- package/dist/router/assets/csrf.d.ts.map +1 -0
- package/dist/router/assets/csrf.js +51 -0
- package/dist/router/assets/csrf.js.map +1 -0
- package/dist/router/assets/send-account-page.d.ts +7 -0
- package/dist/router/assets/send-account-page.d.ts.map +1 -0
- package/dist/router/assets/send-account-page.js +34 -0
- package/dist/router/assets/send-account-page.js.map +1 -0
- package/dist/router/assets/send-authorization-page.d.ts +5 -0
- package/dist/router/assets/send-authorization-page.d.ts.map +1 -0
- package/dist/router/assets/send-authorization-page.js +49 -0
- package/dist/router/assets/send-authorization-page.js.map +1 -0
- package/dist/router/assets/send-error-page.d.ts +4 -0
- package/dist/router/assets/send-error-page.d.ts.map +1 -0
- package/dist/router/assets/send-error-page.js +34 -0
- package/dist/router/assets/send-error-page.js.map +1 -0
- package/dist/router/create-account-page-middleware.d.ts +6 -0
- package/dist/router/create-account-page-middleware.d.ts.map +1 -0
- package/dist/router/create-account-page-middleware.js +39 -0
- package/dist/router/create-account-page-middleware.js.map +1 -0
- package/dist/router/create-api-middleware.d.ts +8 -0
- package/dist/router/create-api-middleware.d.ts.map +1 -0
- package/dist/router/create-api-middleware.js +501 -0
- package/dist/router/create-api-middleware.js.map +1 -0
- package/dist/router/create-authorization-page-middleware.d.ts +6 -0
- package/dist/router/create-authorization-page-middleware.d.ts.map +1 -0
- package/dist/router/create-authorization-page-middleware.js +104 -0
- package/dist/router/create-authorization-page-middleware.js.map +1 -0
- package/dist/router/create-oauth-middleware.d.ts +6 -0
- package/dist/router/create-oauth-middleware.d.ts.map +1 -0
- package/dist/router/create-oauth-middleware.js +142 -0
- package/dist/router/create-oauth-middleware.js.map +1 -0
- package/dist/router/error-handler.d.ts +3 -0
- package/dist/router/error-handler.d.ts.map +1 -0
- package/dist/{account/account.js → router/error-handler.js} +1 -1
- package/dist/router/error-handler.js.map +1 -0
- package/dist/router/middleware-options.d.ts +6 -0
- package/dist/router/middleware-options.d.ts.map +1 -0
- package/dist/router/middleware-options.js +3 -0
- package/dist/router/middleware-options.js.map +1 -0
- package/dist/router/send-redirect.d.ts +16 -0
- package/dist/router/send-redirect.d.ts.map +1 -0
- package/dist/{output/send-authorize-redirect.js → router/send-redirect.js} +40 -24
- package/dist/router/send-redirect.js.map +1 -0
- package/dist/{token/token-claims.d.ts → signer/api-token-payload.d.ts} +237 -232
- package/dist/signer/api-token-payload.d.ts.map +1 -0
- package/dist/signer/api-token-payload.js +17 -0
- package/dist/signer/api-token-payload.js.map +1 -0
- package/dist/signer/signed-token-payload.d.ts +164 -159
- package/dist/signer/signed-token-payload.d.ts.map +1 -1
- package/dist/signer/signed-token-payload.js +10 -16
- package/dist/signer/signed-token-payload.js.map +1 -1
- package/dist/signer/signer.d.ts +42 -11246
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/signer/signer.js +30 -15
- package/dist/signer/signer.js.map +1 -1
- package/dist/token/refresh-token.d.ts.map +1 -1
- package/dist/token/token-data.d.ts +1 -1
- package/dist/token/token-data.d.ts.map +1 -1
- package/dist/token/token-id.d.ts.map +1 -1
- package/dist/token/token-manager.d.ts +28 -26
- package/dist/token/token-manager.d.ts.map +1 -1
- package/dist/token/token-manager.js +138 -196
- package/dist/token/token-manager.js.map +1 -1
- package/dist/token/token-store.d.ts +4 -4
- package/dist/token/token-store.d.ts.map +1 -1
- package/dist/token/token-store.js +1 -0
- package/dist/token/token-store.js.map +1 -1
- package/dist/token/verify-token-claims.d.ts +3 -3
- package/dist/token/verify-token-claims.d.ts.map +1 -1
- package/dist/token/verify-token-claims.js +1 -1
- package/dist/token/verify-token-claims.js.map +1 -1
- package/dist/types/email-otp.d.ts +3 -0
- package/dist/types/email-otp.d.ts.map +1 -0
- package/dist/types/email-otp.js +6 -0
- package/dist/types/email-otp.js.map +1 -0
- package/dist/types/email.d.ts +3 -0
- package/dist/types/email.d.ts.map +1 -0
- package/dist/types/email.js +29 -0
- package/dist/types/email.js.map +1 -0
- package/dist/types/handle.d.ts +3 -0
- package/dist/types/handle.d.ts.map +1 -0
- package/dist/types/handle.js +22 -0
- package/dist/types/handle.js.map +1 -0
- package/dist/types/invite-code.d.ts +4 -0
- package/dist/types/invite-code.d.ts.map +1 -0
- package/dist/types/invite-code.js +6 -0
- package/dist/types/invite-code.js.map +1 -0
- package/dist/types/password.d.ts +4 -0
- package/dist/types/password.d.ts.map +1 -0
- package/dist/types/password.js +7 -0
- package/dist/types/password.js.map +1 -0
- package/package.json +11 -14
- package/src/access-token/access-token-mode.ts +4 -0
- package/src/account/account-manager.ts +105 -75
- package/src/account/account-store.ts +118 -114
- package/src/account/sign-in-data.ts +10 -10
- package/src/account/sign-up-input.ts +13 -4
- package/src/client/client-manager.ts +34 -2
- package/src/client/client-store.ts +1 -1
- package/src/constants.ts +6 -1
- package/src/customization/branding.ts +12 -0
- package/src/customization/build-customization-css.ts +30 -0
- package/src/customization/build-customization-data.ts +22 -0
- package/src/customization/colors.ts +30 -0
- package/src/customization/customization.ts +25 -0
- package/src/customization/links.ts +10 -0
- package/src/device/device-id.ts +5 -0
- package/src/device/device-manager.ts +76 -66
- package/src/device/device-store.ts +2 -0
- package/src/errors/access-denied-error.ts +24 -17
- package/src/{output/build-error-payload.ts → errors/error-parser.ts} +1 -1
- package/src/errors/invalid-grant-error.ts +5 -0
- package/src/errors/login-required-error.ts +10 -0
- package/src/index.ts +1 -0
- package/src/lib/html/build-document.ts +6 -4
- package/src/{output/backend-data.ts → lib/html/hydration-data.ts} +7 -5
- package/src/lib/html/tags.ts +2 -2
- package/src/lib/http/accept.ts +3 -3
- package/src/lib/http/context.ts +41 -10
- package/src/lib/http/headers.ts +15 -0
- package/src/lib/http/index.ts +1 -0
- package/src/lib/http/middleware.ts +8 -23
- package/src/lib/http/request.ts +40 -75
- package/src/lib/http/response.ts +39 -15
- package/src/lib/http/route.ts +8 -5
- package/src/lib/http/router.ts +40 -46
- package/src/lib/http/security-headers.ts +1 -1
- package/src/lib/http/types.ts +1 -6
- package/src/{output → lib}/send-web-page.ts +10 -9
- package/src/lib/util/color.ts +132 -0
- package/src/lib/util/crypto.ts +9 -4
- package/src/lib/util/function.ts +14 -0
- package/src/lib/util/locale.ts +18 -0
- package/src/lib/util/time.ts +3 -4
- package/src/lib/util/type.ts +24 -0
- package/src/lib/util/ui8.ts +14 -0
- package/src/lib/util/zod-error.ts +14 -0
- package/src/oauth-errors.ts +22 -22
- package/src/oauth-hooks.ts +11 -24
- package/src/oauth-middleware.ts +53 -0
- package/src/oauth-provider.ts +290 -1061
- package/src/oauth-verifier.ts +9 -55
- package/src/request/request-data.ts +5 -4
- package/src/request/request-manager.ts +11 -11
- package/src/request/request-store.ts +7 -0
- package/src/result/authorization-redirect-parameters.ts +24 -0
- package/src/result/authorization-result-authorize-page.ts +14 -0
- package/src/result/authorization-result-redirect.ts +8 -0
- package/src/router/assets/assets-manifest.ts +115 -0
- package/src/router/assets/assets.ts +54 -0
- package/src/router/assets/csrf.ts +63 -0
- package/src/router/assets/send-account-page.ts +43 -0
- package/src/router/assets/send-authorization-page.ts +62 -0
- package/src/router/assets/send-error-page.ts +42 -0
- package/src/router/create-account-page-middleware.ts +69 -0
- package/src/router/create-api-middleware.ts +814 -0
- package/src/router/create-authorization-page-middleware.ts +173 -0
- package/src/router/create-oauth-middleware.ts +247 -0
- package/src/router/error-handler.ts +6 -0
- package/src/router/middleware-options.ts +9 -0
- package/src/router/send-redirect.ts +142 -0
- package/src/signer/api-token-payload.ts +18 -0
- package/src/signer/signed-token-payload.ts +18 -28
- package/src/signer/signer.ts +49 -34
- package/src/token/token-data.ts +1 -1
- package/src/token/token-manager.ts +190 -239
- package/src/token/token-store.ts +6 -4
- package/src/token/verify-token-claims.ts +4 -4
- package/src/types/email-otp.ts +3 -0
- package/src/types/email.ts +26 -0
- package/src/types/handle.ts +18 -0
- package/src/types/invite-code.ts +4 -0
- package/src/types/password.ts +4 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +1 -1
- package/dist/access-token/access-token-type.d.ts +0 -6
- package/dist/access-token/access-token-type.d.ts.map +0 -1
- package/dist/access-token/access-token-type.js +0 -10
- package/dist/access-token/access-token-type.js.map +0 -1
- package/dist/account/account.d.ts +0 -2
- package/dist/account/account.d.ts.map +0 -1
- package/dist/account/account.js.map +0 -1
- package/dist/assets/assets-middleware.d.ts +0 -5
- package/dist/assets/assets-middleware.d.ts.map +0 -1
- package/dist/assets/assets-middleware.js +0 -41
- package/dist/assets/assets-middleware.js.map +0 -1
- package/dist/lib/locale.d.ts +0 -15
- package/dist/lib/locale.d.ts.map +0 -1
- package/dist/lib/locale.js +0 -17
- package/dist/lib/locale.js.map +0 -1
- package/dist/output/backend-data.d.ts +0 -4
- package/dist/output/backend-data.d.ts.map +0 -1
- package/dist/output/backend-data.js.map +0 -1
- package/dist/output/build-authorize-data.d.ts +0 -29
- package/dist/output/build-authorize-data.d.ts.map +0 -1
- package/dist/output/build-authorize-data.js +0 -21
- package/dist/output/build-authorize-data.js.map +0 -1
- package/dist/output/build-customization-data.d.ts +0 -234
- package/dist/output/build-customization-data.d.ts.map +0 -1
- package/dist/output/build-customization-data.js +0 -174
- package/dist/output/build-customization-data.js.map +0 -1
- package/dist/output/build-error-data.d.ts +0 -3
- package/dist/output/build-error-data.d.ts.map +0 -1
- package/dist/output/build-error-data.js +0 -10
- package/dist/output/build-error-data.js.map +0 -1
- package/dist/output/build-error-payload.d.ts.map +0 -1
- package/dist/output/build-error-payload.js.map +0 -1
- package/dist/output/output-manager.d.ts +0 -28
- package/dist/output/output-manager.d.ts.map +0 -1
- package/dist/output/output-manager.js +0 -134
- package/dist/output/output-manager.js.map +0 -1
- package/dist/output/send-authorize-redirect.d.ts +0 -25
- package/dist/output/send-authorize-redirect.d.ts.map +0 -1
- package/dist/output/send-authorize-redirect.js.map +0 -1
- package/dist/output/send-web-page.d.ts +0 -8
- package/dist/output/send-web-page.d.ts.map +0 -1
- package/dist/output/send-web-page.js.map +0 -1
- package/dist/token/token-claims.d.ts.map +0 -1
- package/dist/token/token-claims.js +0 -27
- package/dist/token/token-claims.js.map +0 -1
- package/src/access-token/access-token-type.ts +0 -5
- package/src/account/account.ts +0 -1
- package/src/assets/assets-middleware.ts +0 -44
- package/src/lib/locale.ts +0 -21
- package/src/output/build-authorize-data.ts +0 -53
- package/src/output/build-customization-data.ts +0 -217
- package/src/output/build-error-data.ts +0 -8
- package/src/output/output-manager.ts +0 -188
- package/src/output/send-authorize-redirect.ts +0 -137
- package/src/token/token-claims.ts +0 -30
- package/tsconfig.backend.tsbuildinfo +0 -1
- /package/{tsconfig.backend.json → tsconfig.build.json} +0 -0
package/src/lib/util/time.ts
CHANGED
@@ -15,10 +15,9 @@ export function onOvertimeDefault(options: {
|
|
15
15
|
/**
|
16
16
|
* Utility function to protect against timing attacks.
|
17
17
|
*/
|
18
|
-
export async function constantTime<R
|
19
|
-
this: T,
|
18
|
+
export async function constantTime<R>(
|
20
19
|
time: number,
|
21
|
-
fn: (
|
20
|
+
fn: () => Awaitable<R>,
|
22
21
|
onOvertime = onOvertimeDefault,
|
23
22
|
): Promise<R> {
|
24
23
|
if (!Number.isFinite(time) || time <= 0) {
|
@@ -27,7 +26,7 @@ export async function constantTime<R, T = unknown>(
|
|
27
26
|
|
28
27
|
const start = Date.now()
|
29
28
|
try {
|
30
|
-
return await fn
|
29
|
+
return await fn()
|
31
30
|
} finally {
|
32
31
|
const end = Date.now()
|
33
32
|
const elapsed = end - start
|
package/src/lib/util/type.ts
CHANGED
@@ -8,6 +8,30 @@ export type Override<T, V> = Simplify<{
|
|
8
8
|
: never
|
9
9
|
}>
|
10
10
|
export type Awaitable<T> = T | Promise<T>
|
11
|
+
export type NonNullableKeys<T, K extends keyof T> = Simplify<
|
12
|
+
OmitKey<T, K> & {
|
13
|
+
[P in K]-?: NonNullable<T[P]>
|
14
|
+
}
|
15
|
+
>
|
16
|
+
/**
|
17
|
+
* When a type has an `[x: string]: unknown` index signature, in addition to
|
18
|
+
* some known properties, using {@link Omit} will result in a type that only has
|
19
|
+
* the index signature, and no known properties.
|
20
|
+
*
|
21
|
+
* ```ts
|
22
|
+
* Omit<{ a: 3; b: 4; [x: string]: unknown }, 'a'> // { [x: string]: unknown }
|
23
|
+
* ```
|
24
|
+
*
|
25
|
+
* In order to properly omit specific known properties from a type with an index
|
26
|
+
* signature, we need to use another utility type that will behave correctly.
|
27
|
+
*
|
28
|
+
* ```ts
|
29
|
+
* OmitKey<{ a: 3; b: 4; [x: string]: unknown }, 'a'> // { b: 4; [x: string]: unknown }
|
30
|
+
* ```
|
31
|
+
*/
|
32
|
+
export type OmitKey<T, K extends keyof T> = {
|
33
|
+
[K2 in keyof T as K2 extends K ? never : K2]: T[K2]
|
34
|
+
}
|
11
35
|
|
12
36
|
/**
|
13
37
|
* Converts a tuple to the equivalent type of combining every item into a single
|
@@ -0,0 +1,14 @@
|
|
1
|
+
export function parseUi8Hex(v: string) {
|
2
|
+
return asUi8(parseInt(v, 16))
|
3
|
+
}
|
4
|
+
|
5
|
+
export function parseUi8Dec(v: string) {
|
6
|
+
return asUi8(parseInt(v, 10))
|
7
|
+
}
|
8
|
+
|
9
|
+
export function asUi8(v: number) {
|
10
|
+
if (v >= 0 && v <= 255 && Number.isInteger(v)) return v
|
11
|
+
throw new TypeError(
|
12
|
+
`Invalid value "${v}" (expected an integer between 0 and 255)`,
|
13
|
+
)
|
14
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ZodError } from 'zod'
|
2
|
+
|
3
|
+
export function extractZodErrorMessage(err: unknown): string | undefined {
|
4
|
+
if (err instanceof ZodError) {
|
5
|
+
const issue = err.issues[0]
|
6
|
+
if (issue?.path.length) {
|
7
|
+
// "part" will typically be "body" or "query"
|
8
|
+
const [part, ...path] = issue.path
|
9
|
+
return `Validation of "${path.join('.')}" ${part} parameter failed: ${issue.message}`
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
return undefined
|
14
|
+
}
|
package/src/oauth-errors.ts
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
// Root Error class
|
2
2
|
export { OAuthError } from './errors/oauth-error.js'
|
3
3
|
|
4
|
-
export
|
5
|
-
export
|
6
|
-
export
|
7
|
-
export
|
8
|
-
export
|
9
|
-
export
|
10
|
-
export
|
11
|
-
export
|
12
|
-
export
|
13
|
-
export
|
14
|
-
export
|
15
|
-
export
|
16
|
-
export
|
17
|
-
export
|
18
|
-
export
|
19
|
-
export
|
20
|
-
export
|
21
|
-
export
|
22
|
-
export
|
23
|
-
export
|
24
|
-
export
|
25
|
-
export
|
4
|
+
export * from './errors/access-denied-error.js'
|
5
|
+
export * from './errors/account-selection-required-error.js'
|
6
|
+
export * from './errors/consent-required-error.js'
|
7
|
+
export * from './errors/handle-unavailable-error.js'
|
8
|
+
export * from './errors/invalid-authorization-details-error.js'
|
9
|
+
export * from './errors/invalid-client-error.js'
|
10
|
+
export * from './errors/invalid-client-id-error.js'
|
11
|
+
export * from './errors/invalid-client-metadata-error.js'
|
12
|
+
export * from './errors/invalid-dpop-key-binding-error.js'
|
13
|
+
export * from './errors/invalid-dpop-proof-error.js'
|
14
|
+
export * from './errors/invalid-grant-error.js'
|
15
|
+
export * from './errors/invalid-invite-code-error.js'
|
16
|
+
export * from './errors/invalid-parameters-error.js'
|
17
|
+
export * from './errors/invalid-redirect-uri-error.js'
|
18
|
+
export * from './errors/invalid-request-error.js'
|
19
|
+
export * from './errors/invalid-scope-error.js'
|
20
|
+
export * from './errors/invalid-token-error.js'
|
21
|
+
export * from './errors/login-required-error.js'
|
22
|
+
export * from './errors/second-authentication-factor-required-error.js'
|
23
|
+
export * from './errors/unauthorized-client-error.js'
|
24
|
+
export * from './errors/use-dpop-nonce-error.js'
|
25
|
+
export * from './errors/www-authenticate-error.js'
|
package/src/oauth-hooks.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { Jwks } from '@atproto/jwk'
|
2
|
+
import type { Account } from '@atproto/oauth-provider-api'
|
2
3
|
import {
|
3
4
|
OAuthAuthorizationDetails,
|
4
5
|
OAuthAuthorizationRequestParameters,
|
5
6
|
OAuthClientMetadata,
|
6
7
|
OAuthTokenResponse,
|
7
8
|
} from '@atproto/oauth-types'
|
8
|
-
import { Account } from './account/account.js'
|
9
9
|
import { SignInData } from './account/sign-in-data.js'
|
10
10
|
import { SignUpInput } from './account/sign-up-input.js'
|
11
11
|
import { ClientAuth } from './client/client-auth.js'
|
@@ -21,7 +21,8 @@ import {
|
|
21
21
|
import { RequestMetadata } from './lib/http/request.js'
|
22
22
|
import { Awaitable } from './lib/util/type.js'
|
23
23
|
import { AccessDeniedError, OAuthError } from './oauth-errors.js'
|
24
|
-
import {
|
24
|
+
import { DeviceId, SignUpData } from './oauth-store.js'
|
25
|
+
import { RequestId } from './request/request-id.js'
|
25
26
|
|
26
27
|
// Make sure all types needed to implement the OAuthHooks are exported
|
27
28
|
export {
|
@@ -32,7 +33,6 @@ export {
|
|
32
33
|
type ClientAuth,
|
33
34
|
type ClientId,
|
34
35
|
type ClientInfo,
|
35
|
-
type DeviceAccountInfo,
|
36
36
|
type DeviceId,
|
37
37
|
type HcaptchaClientTokens,
|
38
38
|
type HcaptchaConfig,
|
@@ -63,25 +63,11 @@ export type OAuthHooks = {
|
|
63
63
|
data: { metadata: OAuthClientMetadata; jwks?: Jwks },
|
64
64
|
) => Awaitable<undefined | Partial<ClientInfo>>
|
65
65
|
|
66
|
-
/**
|
67
|
-
* Allows enriching the authorization details with additional information
|
68
|
-
* when the tokens are issued.
|
69
|
-
*
|
70
|
-
* @see {@link https://datatracker.ietf.org/doc/html/rfc9396 | RFC 9396}
|
71
|
-
*/
|
72
|
-
getAuthorizationDetails?: (data: {
|
73
|
-
client: Client
|
74
|
-
clientAuth: ClientAuth
|
75
|
-
clientMetadata: RequestMetadata
|
76
|
-
parameters: OAuthAuthorizationRequestParameters
|
77
|
-
account: Account
|
78
|
-
}) => Awaitable<undefined | OAuthAuthorizationDetails>
|
79
|
-
|
80
66
|
/**
|
81
67
|
* This hook is called when a user attempts to sign up, after every validation
|
82
68
|
* has passed (including hcaptcha).
|
83
69
|
*/
|
84
|
-
|
70
|
+
onSignUpAttempt?: (data: {
|
85
71
|
input: SignUpInput
|
86
72
|
deviceId: DeviceId
|
87
73
|
deviceMetadata: RequestMetadata
|
@@ -106,12 +92,17 @@ export type OAuthHooks = {
|
|
106
92
|
*/
|
107
93
|
onSignedUp?: (data: {
|
108
94
|
data: SignUpData
|
109
|
-
info: DeviceAccountInfo
|
110
95
|
account: Account
|
111
96
|
deviceId: DeviceId
|
112
97
|
deviceMetadata: RequestMetadata
|
113
98
|
}) => Awaitable<void>
|
114
99
|
|
100
|
+
onSignInAttempt?: (data: {
|
101
|
+
data: SignInData
|
102
|
+
deviceId: DeviceId
|
103
|
+
deviceMetadata: RequestMetadata
|
104
|
+
}) => Awaitable<void>
|
105
|
+
|
115
106
|
/**
|
116
107
|
* This hook is called when a user successfully signs in.
|
117
108
|
*
|
@@ -119,7 +110,6 @@ export type OAuthHooks = {
|
|
119
110
|
*/
|
120
111
|
onSignedIn?: (data: {
|
121
112
|
data: SignInData
|
122
|
-
info: DeviceAccountInfo
|
123
113
|
account: Account
|
124
114
|
deviceId: DeviceId
|
125
115
|
deviceMetadata: RequestMetadata
|
@@ -142,6 +132,7 @@ export type OAuthHooks = {
|
|
142
132
|
parameters: OAuthAuthorizationRequestParameters
|
143
133
|
deviceId: DeviceId
|
144
134
|
deviceMetadata: RequestMetadata
|
135
|
+
requestId: RequestId
|
145
136
|
}) => Awaitable<void>
|
146
137
|
|
147
138
|
/**
|
@@ -156,8 +147,6 @@ export type OAuthHooks = {
|
|
156
147
|
clientMetadata: RequestMetadata
|
157
148
|
account: Account
|
158
149
|
parameters: OAuthAuthorizationRequestParameters
|
159
|
-
/** null when "password grant" used (in which case {@link onAuthorized} won't have been called) */
|
160
|
-
deviceId: null | DeviceId
|
161
150
|
}) => Awaitable<void>
|
162
151
|
|
163
152
|
/**
|
@@ -171,7 +160,5 @@ export type OAuthHooks = {
|
|
171
160
|
clientMetadata: RequestMetadata
|
172
161
|
account: Account
|
173
162
|
parameters: OAuthAuthorizationRequestParameters
|
174
|
-
/** null when "password grant" used (in which case {@link onAuthorized} won't have been called) */
|
175
|
-
deviceId: null | DeviceId
|
176
163
|
}) => Awaitable<void>
|
177
164
|
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http'
|
2
|
+
import { asHandler, combineMiddlewares } from './lib/http/middleware.js'
|
3
|
+
import { Handler } from './lib/http/types.js'
|
4
|
+
import { OAuthProvider } from './oauth-provider.js'
|
5
|
+
import { assetsMiddleware } from './router/assets/assets.js'
|
6
|
+
import { createAccountPageMiddleware } from './router/create-account-page-middleware.js'
|
7
|
+
import { createApiMiddleware } from './router/create-api-middleware.js'
|
8
|
+
import { createAuthorizationPageMiddleware } from './router/create-authorization-page-middleware.js'
|
9
|
+
import { createOAuthMiddleware } from './router/create-oauth-middleware.js'
|
10
|
+
import { ErrorHandler } from './router/error-handler.js'
|
11
|
+
import { MiddlewareOptions } from './router/middleware-options.js'
|
12
|
+
|
13
|
+
// Export all the types exposed
|
14
|
+
export type {
|
15
|
+
ErrorHandler,
|
16
|
+
Handler,
|
17
|
+
IncomingMessage,
|
18
|
+
MiddlewareOptions,
|
19
|
+
ServerResponse,
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* @returns An http request handler that can be used with node's http server
|
24
|
+
* or as a middleware with express / connect.
|
25
|
+
*/
|
26
|
+
export function oauthMiddleware<
|
27
|
+
Req extends IncomingMessage = IncomingMessage,
|
28
|
+
Res extends ServerResponse = ServerResponse,
|
29
|
+
>(
|
30
|
+
server: OAuthProvider,
|
31
|
+
{ ...options }: MiddlewareOptions<Req, Res> = {},
|
32
|
+
): Handler<void, Req, Res> {
|
33
|
+
const { onError } = options
|
34
|
+
|
35
|
+
// options is shallow cloned so it's fine to mutate it
|
36
|
+
options.onError =
|
37
|
+
process.env['NODE_ENV'] === 'development'
|
38
|
+
? (req, res, err, msg) => {
|
39
|
+
console.error(`OAuthProvider error (${msg}):`, err)
|
40
|
+
return onError?.(req, res, err, msg)
|
41
|
+
}
|
42
|
+
: onError
|
43
|
+
|
44
|
+
return asHandler(
|
45
|
+
combineMiddlewares([
|
46
|
+
assetsMiddleware,
|
47
|
+
createOAuthMiddleware(server, options),
|
48
|
+
createApiMiddleware(server, options),
|
49
|
+
createAuthorizationPageMiddleware(server, options),
|
50
|
+
createAccountPageMiddleware(server, options),
|
51
|
+
]),
|
52
|
+
)
|
53
|
+
}
|