@atproto/oauth-provider 0.19.9 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/account/account-manager.d.ts +11 -11
- package/dist/account/account-manager.d.ts.map +1 -1
- package/dist/account/account-manager.js.map +1 -1
- package/dist/account/account-store.d.ts +5 -10
- package/dist/account/account-store.d.ts.map +1 -1
- package/dist/account/account-store.js +0 -5
- package/dist/account/account-store.js.map +1 -1
- package/dist/client/client-auth.d.ts +1 -1
- package/dist/client/client-auth.d.ts.map +1 -1
- package/dist/client/client-auth.js.map +1 -1
- package/dist/client/client-data.d.ts +2 -2
- package/dist/client/client-data.d.ts.map +1 -1
- package/dist/client/client-data.js.map +1 -1
- package/dist/client/client-id.d.ts +1 -1
- package/dist/client/client-id.d.ts.map +1 -1
- package/dist/client/client-id.js.map +1 -1
- package/dist/client/client-manager.d.ts +8 -8
- package/dist/client/client-manager.d.ts.map +1 -1
- package/dist/client/client-manager.js +1 -1
- package/dist/client/client-manager.js.map +1 -1
- package/dist/client/client-store.d.ts +4 -6
- package/dist/client/client-store.d.ts.map +1 -1
- package/dist/client/client-store.js +0 -3
- package/dist/client/client-store.js.map +1 -1
- package/dist/client/client-utils.d.ts +1 -1
- package/dist/client/client-utils.d.ts.map +1 -1
- package/dist/client/client-utils.js.map +1 -1
- package/dist/client/client.d.ts +6 -6
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +1 -1
- package/dist/client/client.js.map +1 -1
- package/dist/customization/branding.d.ts +1 -1
- package/dist/customization/branding.d.ts.map +1 -1
- package/dist/customization/branding.js.map +1 -1
- package/dist/customization/build-customization-css.d.ts +1 -1
- package/dist/customization/build-customization-css.d.ts.map +1 -1
- package/dist/customization/build-customization-css.js.map +1 -1
- package/dist/customization/customization.d.ts +1 -1
- package/dist/customization/customization.d.ts.map +1 -1
- package/dist/customization/customization.js.map +1 -1
- package/dist/device/device-data.d.ts +2 -0
- package/dist/device/device-data.d.ts.map +1 -1
- package/dist/device/device-data.js.map +1 -1
- package/dist/device/device-id.js +1 -1
- package/dist/device/device-id.js.map +1 -1
- package/dist/device/device-manager.d.ts +3 -3
- package/dist/device/device-manager.d.ts.map +1 -1
- package/dist/device/device-manager.js +1 -1
- package/dist/device/device-manager.js.map +1 -1
- package/dist/device/device-store.d.ts +5 -7
- package/dist/device/device-store.d.ts.map +1 -1
- package/dist/device/device-store.js +0 -4
- package/dist/device/device-store.js.map +1 -1
- package/dist/device/session-id.d.ts.map +1 -1
- package/dist/device/session-id.js +1 -1
- package/dist/device/session-id.js.map +1 -1
- package/dist/dpop/dpop-manager.d.ts +2 -2
- package/dist/dpop/dpop-manager.d.ts.map +1 -1
- package/dist/dpop/dpop-manager.js +1 -1
- package/dist/dpop/dpop-manager.js.map +1 -1
- package/dist/dpop/dpop-nonce.js +1 -1
- package/dist/dpop/dpop-nonce.js.map +1 -1
- package/dist/errors/access-denied-error.d.ts +1 -1
- package/dist/errors/access-denied-error.d.ts.map +1 -1
- package/dist/errors/access-denied-error.js.map +1 -1
- package/dist/errors/account-selection-required-error.d.ts +1 -1
- package/dist/errors/account-selection-required-error.d.ts.map +1 -1
- package/dist/errors/account-selection-required-error.js.map +1 -1
- package/dist/errors/authorization-error.d.ts +2 -2
- package/dist/errors/authorization-error.d.ts.map +1 -1
- package/dist/errors/authorization-error.js.map +1 -1
- package/dist/errors/consent-required-error.d.ts +1 -1
- package/dist/errors/consent-required-error.d.ts.map +1 -1
- package/dist/errors/consent-required-error.js.map +1 -1
- package/dist/errors/handle-unavailable-error.d.ts +1 -1
- package/dist/errors/handle-unavailable-error.d.ts.map +1 -1
- package/dist/errors/handle-unavailable-error.js.map +1 -1
- package/dist/errors/invalid-authorization-details-error.d.ts +1 -1
- package/dist/errors/invalid-authorization-details-error.d.ts.map +1 -1
- package/dist/errors/invalid-authorization-details-error.js.map +1 -1
- package/dist/errors/invalid-client-metadata-error.js +1 -1
- package/dist/errors/invalid-client-metadata-error.js.map +1 -1
- package/dist/errors/invalid-credentials-error.d.ts +1 -1
- package/dist/errors/invalid-credentials-error.d.ts.map +1 -1
- package/dist/errors/invalid-credentials-error.js.map +1 -1
- package/dist/errors/invalid-scope-error.d.ts +1 -1
- package/dist/errors/invalid-scope-error.d.ts.map +1 -1
- package/dist/errors/invalid-scope-error.js.map +1 -1
- package/dist/errors/login-required-error.d.ts +1 -1
- package/dist/errors/login-required-error.d.ts.map +1 -1
- package/dist/errors/login-required-error.js.map +1 -1
- package/dist/lexicon/lexicon-data.d.ts +1 -1
- package/dist/lexicon/lexicon-data.d.ts.map +1 -1
- package/dist/lexicon/lexicon-data.js.map +1 -1
- package/dist/lexicon/lexicon-getter.d.ts +3 -3
- package/dist/lexicon/lexicon-getter.d.ts.map +1 -1
- package/dist/lexicon/lexicon-getter.js +1 -1
- package/dist/lexicon/lexicon-getter.js.map +1 -1
- package/dist/lexicon/lexicon-manager.d.ts +4 -4
- package/dist/lexicon/lexicon-manager.d.ts.map +1 -1
- package/dist/lexicon/lexicon-manager.js.map +1 -1
- package/dist/lexicon/lexicon-store.d.ts +4 -3
- package/dist/lexicon/lexicon-store.d.ts.map +1 -1
- package/dist/lexicon/lexicon-store.js.map +1 -1
- package/dist/lib/csp/index.d.ts +1 -1
- package/dist/lib/csp/index.d.ts.map +1 -1
- package/dist/lib/csp/index.js.map +1 -1
- package/dist/lib/hcaptcha.d.ts +1 -1
- package/dist/lib/hcaptcha.d.ts.map +1 -1
- package/dist/lib/hcaptcha.js +1 -1
- package/dist/lib/hcaptcha.js.map +1 -1
- package/dist/lib/html/build-document.d.ts +1 -1
- package/dist/lib/html/build-document.d.ts.map +1 -1
- package/dist/lib/html/build-document.js.map +1 -1
- package/dist/lib/html/escapers.d.ts +1 -1
- package/dist/lib/html/escapers.d.ts.map +1 -1
- package/dist/lib/html/escapers.js.map +1 -1
- 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 -0
- 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.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.map +1 -1
- package/dist/lib/http/request.d.ts +2 -2
- package/dist/lib/http/request.d.ts.map +1 -1
- package/dist/lib/http/request.js.map +1 -1
- package/dist/lib/http/response.d.ts +1 -1
- package/dist/lib/http/response.d.ts.map +1 -1
- package/dist/lib/http/response.js.map +1 -1
- package/dist/lib/http/route.d.ts +4 -4
- package/dist/lib/http/route.d.ts.map +1 -1
- package/dist/lib/http/route.js.map +1 -1
- package/dist/lib/http/router.d.ts +5 -5
- package/dist/lib/http/router.d.ts.map +1 -1
- package/dist/lib/http/router.js.map +1 -1
- package/dist/lib/http/stream.d.ts +2 -2
- package/dist/lib/http/stream.d.ts.map +1 -1
- package/dist/lib/http/stream.js.map +1 -1
- 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.map +1 -1
- package/dist/lib/util/zod-error.d.ts +1 -1
- package/dist/lib/util/zod-error.d.ts.map +1 -1
- package/dist/lib/util/zod-error.js.map +1 -1
- package/dist/lib/write-form-redirect.d.ts +1 -1
- package/dist/lib/write-form-redirect.d.ts.map +1 -1
- package/dist/lib/write-form-redirect.js.map +1 -1
- package/dist/lib/write-html.d.ts +3 -3
- package/dist/lib/write-html.d.ts.map +1 -1
- package/dist/lib/write-html.js.map +1 -1
- package/dist/metadata/build-metadata.d.ts +2 -2
- package/dist/metadata/build-metadata.d.ts.map +1 -1
- package/dist/metadata/build-metadata.js.map +1 -1
- package/dist/{constants.d.ts → oauth-constants.d.ts} +1 -1
- package/dist/oauth-constants.d.ts.map +1 -0
- package/dist/{constants.js → oauth-constants.js} +1 -1
- package/dist/oauth-constants.js.map +1 -0
- package/dist/oauth-errors.d.ts +2 -3
- package/dist/oauth-errors.d.ts.map +1 -1
- package/dist/oauth-errors.js +4 -4
- package/dist/oauth-errors.js.map +1 -1
- package/dist/oauth-hooks.d.ts +20 -24
- package/dist/oauth-hooks.d.ts.map +1 -1
- package/dist/oauth-hooks.js +1 -8
- package/dist/oauth-hooks.js.map +1 -1
- package/dist/oauth-middleware.d.ts +4 -4
- package/dist/oauth-middleware.d.ts.map +1 -1
- package/dist/oauth-middleware.js.map +1 -1
- package/dist/oauth-provider.d.ts +46 -37
- package/dist/oauth-provider.d.ts.map +1 -1
- package/dist/oauth-provider.js +17 -8
- package/dist/oauth-provider.js.map +1 -1
- package/dist/oauth-store.d.ts +0 -4
- package/dist/oauth-store.d.ts.map +1 -1
- package/dist/oauth-store.js +0 -4
- package/dist/oauth-store.js.map +1 -1
- package/dist/oauth-utils.d.ts +14 -0
- package/dist/oauth-utils.d.ts.map +1 -0
- package/dist/oauth-utils.js +5 -0
- package/dist/oauth-utils.js.map +1 -0
- package/dist/oauth-verifier.d.ts +6 -6
- package/dist/oauth-verifier.d.ts.map +1 -1
- package/dist/oauth-verifier.js.map +1 -1
- package/dist/replay/replay-manager.d.ts +2 -2
- package/dist/replay/replay-manager.d.ts.map +1 -1
- package/dist/replay/replay-manager.js +1 -1
- package/dist/replay/replay-manager.js.map +1 -1
- package/dist/replay/replay-store-redis.d.ts +1 -1
- package/dist/replay/replay-store-redis.d.ts.map +1 -1
- package/dist/replay/replay-store-redis.js.map +1 -1
- package/dist/replay/replay-store.d.ts +1 -1
- package/dist/replay/replay-store.d.ts.map +1 -1
- package/dist/replay/replay-store.js.map +1 -1
- package/dist/request/code.js +1 -1
- package/dist/request/code.js.map +1 -1
- package/dist/request/request-data.d.ts +7 -7
- package/dist/request/request-data.d.ts.map +1 -1
- package/dist/request/request-data.js.map +1 -1
- package/dist/request/request-id.d.ts.map +1 -1
- package/dist/request/request-id.js +1 -1
- package/dist/request/request-id.js.map +1 -1
- package/dist/request/request-manager.d.ts +13 -13
- package/dist/request/request-manager.d.ts.map +1 -1
- package/dist/request/request-manager.js +1 -1
- package/dist/request/request-manager.js.map +1 -1
- package/dist/request/request-store.d.ts +6 -8
- package/dist/request/request-store.d.ts.map +1 -1
- package/dist/request/request-store.js +0 -4
- package/dist/request/request-store.js.map +1 -1
- package/dist/request/request-uri.d.ts +1 -1
- package/dist/request/request-uri.d.ts.map +1 -1
- package/dist/request/request-uri.js.map +1 -1
- package/dist/result/authorization-redirect-parameters.d.ts +2 -2
- package/dist/result/authorization-redirect-parameters.d.ts.map +1 -1
- package/dist/result/authorization-redirect-parameters.js.map +1 -1
- package/dist/result/authorization-result-redirect.d.ts +2 -2
- package/dist/result/authorization-result-redirect.d.ts.map +1 -1
- package/dist/result/authorization-result-redirect.js.map +1 -1
- package/dist/router/assets/assets-manifest.d.ts +2 -2
- package/dist/router/assets/assets-manifest.d.ts.map +1 -1
- package/dist/router/assets/assets-manifest.js.map +1 -1
- package/dist/router/assets/assets.d.ts +4 -4
- package/dist/router/assets/assets.d.ts.map +1 -1
- package/dist/router/assets/assets.js.map +1 -1
- package/dist/router/assets/csrf.js.map +1 -1
- package/dist/router/assets/send-account-page.d.ts +2 -2
- package/dist/router/assets/send-account-page.d.ts.map +1 -1
- package/dist/router/assets/send-account-page.js.map +1 -1
- package/dist/router/assets/send-authorization-page.d.ts +3 -3
- package/dist/router/assets/send-authorization-page.d.ts.map +1 -1
- package/dist/router/assets/send-authorization-page.js.map +1 -1
- package/dist/router/assets/send-cookie-error-page.d.ts +2 -2
- package/dist/router/assets/send-cookie-error-page.d.ts.map +1 -1
- package/dist/router/assets/send-cookie-error-page.js.map +1 -1
- package/dist/router/assets/send-error-page.d.ts +2 -2
- package/dist/router/assets/send-error-page.d.ts.map +1 -1
- package/dist/router/assets/send-error-page.js.map +1 -1
- package/dist/router/assets/send-redirect.d.ts +4 -4
- package/dist/router/assets/send-redirect.d.ts.map +1 -1
- package/dist/router/assets/send-redirect.js.map +1 -1
- package/dist/router/create-account-page-middleware.d.ts +1 -1
- package/dist/router/create-account-page-middleware.d.ts.map +1 -1
- package/dist/router/create-account-page-middleware.js.map +1 -1
- package/dist/router/create-api-middleware.d.ts +2 -2
- package/dist/router/create-api-middleware.d.ts.map +1 -1
- package/dist/router/create-api-middleware.js +1 -1
- package/dist/router/create-api-middleware.js.map +1 -1
- package/dist/router/create-authorization-page-middleware.d.ts +1 -1
- package/dist/router/create-authorization-page-middleware.d.ts.map +1 -1
- package/dist/router/create-authorization-page-middleware.js.map +1 -1
- package/dist/router/create-oauth-middleware.d.ts +1 -1
- package/dist/router/create-oauth-middleware.d.ts.map +1 -1
- package/dist/router/create-oauth-middleware.js +1 -1
- package/dist/router/create-oauth-middleware.js.map +1 -1
- package/dist/signer/api-token-payload.d.ts +1 -1
- package/dist/signer/api-token-payload.d.ts.map +1 -1
- package/dist/signer/api-token-payload.js +1 -1
- package/dist/signer/api-token-payload.js.map +1 -1
- package/dist/signer/signer.d.ts +4 -4
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/signer/signer.js +2 -2
- package/dist/signer/signer.js.map +1 -1
- package/dist/token/refresh-token.js +1 -1
- package/dist/token/refresh-token.js.map +1 -1
- package/dist/token/token-claims.d.ts +4 -4
- package/dist/token/token-claims.d.ts.map +1 -1
- package/dist/token/token-claims.js.map +1 -1
- package/dist/token/token-data.d.ts +7 -7
- package/dist/token/token-data.d.ts.map +1 -1
- package/dist/token/token-data.js.map +1 -1
- package/dist/token/token-id.js +1 -1
- package/dist/token/token-id.js.map +1 -1
- package/dist/token/token-manager.d.ts +14 -14
- package/dist/token/token-manager.d.ts.map +1 -1
- package/dist/token/token-manager.js +1 -1
- package/dist/token/token-manager.js.map +1 -1
- package/dist/token/token-store.d.ts +7 -9
- package/dist/token/token-store.d.ts.map +1 -1
- package/dist/token/token-store.js +0 -4
- package/dist/token/token-store.js.map +1 -1
- package/dist/types/handle.js.map +1 -1
- package/dist/types/rgb-color.d.ts +1 -1
- package/dist/types/rgb-color.d.ts.map +1 -1
- package/dist/types/rgb-color.js.map +1 -1
- package/package.json +47 -20
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/errors/invalid-invite-code-error.d.ts +0 -5
- package/dist/errors/invalid-invite-code-error.d.ts.map +0 -1
- package/dist/errors/invalid-invite-code-error.js +0 -7
- package/dist/errors/invalid-invite-code-error.js.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -16
- package/dist/index.js.map +0 -1
- package/dist/oauth-client.d.ts +0 -4
- package/dist/oauth-client.d.ts.map +0 -1
- package/dist/oauth-client.js +0 -3
- package/dist/oauth-client.js.map +0 -1
- package/dist/oauth-dpop.d.ts +0 -3
- package/dist/oauth-dpop.d.ts.map +0 -1
- package/dist/oauth-dpop.js +0 -3
- package/dist/oauth-dpop.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-authorization-page-middleware.js","sourceRoot":"","sources":["../../src/router/create-authorization-page-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,oCAAoC,GACrC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAEL,MAAM,EAEN,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AAEjE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAC9E,OAAO,EAAE,0BAA0B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,GAAG,EACH;4BACE,MAAM,EAAE,MAAM,CAAC,MAAM;4BACrB,UAAU,EAAE,GAAG,CAAC,UAAU;4BAC1B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;yBACvB,EACD,eAAe,CAChB,CAAA;oBACH,CAAC;yBAAM,CAAC;wBACN,OAAO,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;oBACrC,CAAC;gBACH,CAAC;qBAAM,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;oBAC1B,GAAG,CAAC,GAAG,EAAE,CAAA;gBACX,CAAC;YACH,CAAC;QACH,CAAC,CAAA;IACH,CAAC;AACH,CAAC;AAED,SAAS,mCAAmC,CAC1C,GAAQ;IAER,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAClD,MAAM,MAAM,GAAG,oCAAoC,CAAC,SAAS,CAAC,KAAK,EAAE;QACnE,IAAI,EAAE,CAAC,OAAO,CAAC;KAChB,CAAC,CAAA;IAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,4BAA4B,CAAA;QAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAA;QACxB,MAAM,IAAI,mBAAmB,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAA;IAC/D,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAA;AACpB,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport {\n OAuthAuthorizationRequestQuery,\n oauthAuthorizationRequestQuerySchema,\n} from '@atproto/oauth-types'\nimport { AuthorizationError } from '../errors/authorization-error.js'\nimport { InvalidRequestError } from '../errors/invalid-request-error.js'\nimport {\n Middleware,\n Router,\n RouterCtx,\n getCookie,\n setCookie,\n validateFetchDest,\n validateFetchMode,\n validateFetchSite,\n validateOrigin,\n validateReferrer,\n} from '../lib/http/index.js'\nimport { SecurityHeadersOptions } from '../lib/http/security-headers.js'\nimport { formatError } from '../lib/util/error.js'\nimport type { Awaitable } from '../lib/util/type.js'\nimport { writeFormRedirect } from '../lib/write-form-redirect.js'\nimport type { OAuthProvider } from '../oauth-provider.js'\nimport { parseRequestUri, requestUriSchema } from '../request/request-uri.js'\nimport { sendAuthorizePageFactory } from './assets/send-authorization-page.js'\nimport { sendCookieErrorPageFactory } from './assets/send-cookie-error-page.js'\nimport { sendErrorPageFactory } from './assets/send-error-page.js'\nimport {\n sendAuthorizationResultRedirect,\n sendRedirect,\n} from './assets/send-redirect.js'\nimport { parseRedirectUrl } from './create-api-middleware.js'\nimport type { MiddlewareOptions } from './middleware-options.js'\n\nexport function createAuthorizationPageMiddleware<\n Ctx extends object | void = void,\n Req extends IncomingMessage = IncomingMessage,\n Res extends ServerResponse = ServerResponse,\n>(\n server: OAuthProvider,\n { onError }: MiddlewareOptions<Req, Res>,\n): Middleware<Ctx, Req, Res> {\n const issuerUrl = new URL(server.issuer)\n const issuerOrigin = issuerUrl.origin\n\n const securityOptions: SecurityHeadersOptions = {\n hsts: issuerUrl.protocol === 'http:' ? false : undefined,\n }\n\n const sendAuthorizePage = sendAuthorizePageFactory(\n server.customization,\n securityOptions,\n )\n const sendErrorPage = sendErrorPageFactory(\n server.customization,\n securityOptions,\n )\n const sendCookieErrorPage = sendCookieErrorPageFactory(\n server.customization,\n securityOptions,\n )\n\n const router = new Router<Ctx, Req, Res>(issuerUrl)\n\n router.get(\n '/oauth/authorize',\n withErrorHandler(async function (req, res) {\n res.setHeader('Cache-Control', 'no-store')\n res.setHeader('Pragma', 'no-cache')\n\n // \"same-origin\" is required to support the redirect test logic below (as\n // well as refreshing the authorization page).\n // \"same-site\" supports hosting PDS and app on the same site but different\n // origins (different subdomains).\n validateFetchSite(req, ['same-origin', 'same-site', 'cross-site', 'none'])\n validateFetchMode(req, ['navigate'])\n validateFetchDest(req, ['document'])\n validateOrigin(req, issuerOrigin)\n\n // Do not perform any of the following logic if the request is invalid\n const query = parseOAuthAuthorizationRequestQuery(this.url)\n\n // @NOTE For some reason, even when loaded through a\n // ASWebAuthenticationSession, iOS will sometimes fail to properly save\n // cookies set during the rendering of the page. When this happens, the\n // authorization page logic, which relies on cookies to maintain the session,\n // will fail. To work around this, we perform an initial redirect to ourselves\n // using a form GET submit, in an attempt to verify if the browser saves\n // cookies on redirect or not. If it does, we proceed as normal. If it\n // doesn't, we redirect the user back to the client with an error message.\n if (\n // Only for iOS users\n req.headers['user-agent']?.includes('iPhone OS') &&\n // Disabled if the user already passed the test, which means their browser preserves cookies on redirect\n !(getCookie(req, 'cookie-test') === 'succeeded') &&\n // Disabled if the user already has a session\n !(await server.deviceManager.hasSession(req))\n ) {\n // @TODO Another possible solution would be to avoid relying on cookies if we\n // detect that they are not being preserved. This would mean that preserving\n // sessions (SSO) would not be possible for browsers that don't preserve\n // cookies on redirect, but at least the authorization request could still be\n // completed. This was not implemented yet due to the extra complexity\n // involved in supporting this.\n\n // 1) When the user first comes here, we will test if their browser\n // preserves cookies by redirecting back to ourselves\n if (!this.url.searchParams.has('redirect-test')) {\n // 2) Set a testing cookie\n setCookie(res, 'cookie-test', 'testing', {\n sameSite: 'lax',\n httpOnly: true,\n })\n\n // 3) And send an auto-submit form redirecting back to ourselves\n return writeFormRedirect(\n res,\n 'get',\n this.url.href,\n // 4) We add an extra query parameter to trigger the test logic after\n // the redirect occurred.\n [...this.url.searchParams, ['redirect-test', '1']],\n securityOptions,\n )\n } else {\n // 5) We just got redirected back to ourselves. Verify that the\n // browser preserved cookies during the redirect\n if (getCookie(req, 'cookie-test')) {\n // 6) Success! The browser preserved cookies. Proceed with the\n // normal authorization flow.\n\n // 7) Set a long lasting cookie to skip the test next time\n setCookie(res, 'cookie-test', 'succeeded', {\n sameSite: 'lax',\n maxAge: 31 * 24 * 60 * 60,\n httpOnly: true,\n })\n } else {\n // The browser did NOT preserve cookies. We have to abort the\n // authorization request.\n\n if (this.url.searchParams.get('redirect-test') === '1') {\n // 8) Show an error page to the user explaining the situation\n\n // Give the browser another chance to save cookies after the use\n // pressed \"Continue\"\n setCookie(res, 'cookie-test', 'testing', {\n sameSite: 'lax',\n httpOnly: true,\n })\n\n // Make sure next time we reach the other branch and redirect back\n // to the client\n const continueUrl = new URL(this.url.href)\n continueUrl.searchParams.set('redirect-test', '2')\n return sendCookieErrorPage(req, res, { continueUrl })\n } else {\n // 9) Once the use acknowledges the error, redirect them back to\n // the client with an error message.\n\n // Allow the client to understand what happened (the `error`\n // response parameter value is constrained by the OAuth2 spec)\n const message = 'ERR_COOKIES_UNSUPPORTED'\n\n // @NOTE AuthorizationError thrown here will be caught by the\n // error handler middleware defined below, and cause a redirect\n // back to the client with the error parameters.\n if ('request_uri' in query) {\n // Load and delete the authorization request\n const requestUri = parseRequestUri(query.request_uri, {\n path: ['query', 'request_uri'],\n })\n const data = await server.requestManager.get(\n requestUri,\n undefined,\n query.client_id,\n )\n await server.requestManager.delete(requestUri)\n throw new AuthorizationError(data.parameters, message)\n } else if ('request' in query) {\n const client = await server.clientManager.getClient(\n query.client_id,\n )\n const parameters = await server.decodeJAR(client, query)\n throw new AuthorizationError(parameters, message)\n } else {\n throw new AuthorizationError(query, message)\n }\n }\n }\n }\n }\n\n // Normal authorization flow\n const device = await server.deviceManager.load(req, res)\n\n const result = await server.authorize(query, device)\n\n if ('redirect' in result) {\n return sendAuthorizationResultRedirect(res, result, securityOptions)\n } else {\n return sendAuthorizePage(req, res, result)\n }\n }),\n )\n\n // This is a private endpoint that will be called by the user after the\n // authorization request was either approved or denied. The logic performed\n // here **could** be performed directly in the frontend. We decided to\n // implement it here to avoid duplicating the logic.\n router.get(\n '/oauth/authorize/redirect',\n withErrorHandler(async function (req, res) {\n // Ensure we come from the authorization page\n validateFetchSite(req, ['same-origin'])\n validateFetchMode(req, ['navigate'])\n validateFetchDest(req, ['document'])\n validateOrigin(req, issuerOrigin)\n\n const referrer = validateReferrer(req, {\n origin: issuerOrigin,\n pathname: '/oauth/authorize',\n })\n\n // Ensure we are coming from the authorization page\n requestUriSchema.parse(referrer.searchParams.get('request_uri'))\n\n return sendRedirect(res, parseRedirectUrl(this.url), securityOptions)\n }),\n )\n\n return router.buildMiddleware()\n\n function withErrorHandler<T extends RouterCtx>(\n handler: (this: T, req: Req, res: Res) => Awaitable<void>,\n ): Middleware<T, Req, Res> {\n return async function (req, res) {\n try {\n await handler.call(this, req, res)\n } catch (err) {\n onError?.(req, res, err, `Authorization Request Error`)\n\n if (!res.headersSent) {\n if (err instanceof AuthorizationError) {\n return sendAuthorizationResultRedirect(\n res,\n {\n issuer: server.issuer,\n parameters: err.parameters,\n redirect: err.toJSON(),\n },\n securityOptions,\n )\n } else {\n return sendErrorPage(req, res, err)\n }\n } else if (!res.destroyed) {\n res.end()\n }\n }\n }\n }\n}\n\nfunction parseOAuthAuthorizationRequestQuery(\n url: URL,\n): OAuthAuthorizationRequestQuery {\n const query = Object.fromEntries(url.searchParams)\n const result = oauthAuthorizationRequestQuerySchema.safeParse(query, {\n path: ['query'],\n })\n\n if (!result.success) {\n const message = 'Invalid request parameters'\n const err = result.error\n throw new InvalidRequestError(formatError(err, message), err)\n }\n\n return result.data\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create-authorization-page-middleware.js","sourceRoot":"","sources":["../../src/router/create-authorization-page-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,oCAAoC,GACrC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAEL,MAAM,EAEN,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,GACjB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,EAAE,iBAAiB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,EAAE,GAAG,EAAE,GAAG,EAAE,6BAA6B,CAAC,CAAA;gBAEvD,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;oBACrB,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;wBACtC,OAAO,+BAA+B,CACpC,GAAG,EACH;4BACE,MAAM,EAAE,MAAM,CAAC,MAAM;4BACrB,UAAU,EAAE,GAAG,CAAC,UAAU;4BAC1B,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;yBACvB,EACD,eAAe,CAChB,CAAA;oBACH,CAAC;yBAAM,CAAC;wBACN,OAAO,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;oBACrC,CAAC;gBACH,CAAC;qBAAM,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;oBAC1B,GAAG,CAAC,GAAG,EAAE,CAAA;gBACX,CAAC;YACH,CAAC;QACH,CAAC,CAAA;IACH,CAAC;AACH,CAAC;AAED,SAAS,mCAAmC,CAC1C,GAAQ;IAER,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAClD,MAAM,MAAM,GAAG,oCAAoC,CAAC,SAAS,CAAC,KAAK,EAAE;QACnE,IAAI,EAAE,CAAC,OAAO,CAAC;KAChB,CAAC,CAAA;IAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,4BAA4B,CAAA;QAC5C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAA;QACxB,MAAM,IAAI,mBAAmB,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAA;IAC/D,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAA;AACpB,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport {\n type OAuthAuthorizationRequestQuery,\n oauthAuthorizationRequestQuerySchema,\n} from '@atproto/oauth-types'\nimport { AuthorizationError } from '../errors/authorization-error.js'\nimport { InvalidRequestError } from '../errors/invalid-request-error.js'\nimport {\n type Middleware,\n Router,\n type RouterCtx,\n getCookie,\n setCookie,\n validateFetchDest,\n validateFetchMode,\n validateFetchSite,\n validateOrigin,\n validateReferrer,\n} from '../lib/http/index.js'\nimport type { SecurityHeadersOptions } from '../lib/http/security-headers.js'\nimport { formatError } from '../lib/util/error.js'\nimport type { Awaitable } from '../lib/util/type.js'\nimport { writeFormRedirect } from '../lib/write-form-redirect.js'\nimport type { OAuthProvider } from '../oauth-provider.js'\nimport { parseRequestUri, requestUriSchema } from '../request/request-uri.js'\nimport { sendAuthorizePageFactory } from './assets/send-authorization-page.js'\nimport { sendCookieErrorPageFactory } from './assets/send-cookie-error-page.js'\nimport { sendErrorPageFactory } from './assets/send-error-page.js'\nimport {\n sendAuthorizationResultRedirect,\n sendRedirect,\n} from './assets/send-redirect.js'\nimport { parseRedirectUrl } from './create-api-middleware.js'\nimport type { MiddlewareOptions } from './middleware-options.js'\n\nexport function createAuthorizationPageMiddleware<\n Ctx extends object | void = void,\n Req extends IncomingMessage = IncomingMessage,\n Res extends ServerResponse = ServerResponse,\n>(\n server: OAuthProvider,\n { onError }: MiddlewareOptions<Req, Res>,\n): Middleware<Ctx, Req, Res> {\n const issuerUrl = new URL(server.issuer)\n const issuerOrigin = issuerUrl.origin\n\n const securityOptions: SecurityHeadersOptions = {\n hsts: issuerUrl.protocol === 'http:' ? false : undefined,\n }\n\n const sendAuthorizePage = sendAuthorizePageFactory(\n server.customization,\n securityOptions,\n )\n const sendErrorPage = sendErrorPageFactory(\n server.customization,\n securityOptions,\n )\n const sendCookieErrorPage = sendCookieErrorPageFactory(\n server.customization,\n securityOptions,\n )\n\n const router = new Router<Ctx, Req, Res>(issuerUrl)\n\n router.get(\n '/oauth/authorize',\n withErrorHandler(async function (req, res) {\n res.setHeader('Cache-Control', 'no-store')\n res.setHeader('Pragma', 'no-cache')\n\n // \"same-origin\" is required to support the redirect test logic below (as\n // well as refreshing the authorization page).\n // \"same-site\" supports hosting PDS and app on the same site but different\n // origins (different subdomains).\n validateFetchSite(req, ['same-origin', 'same-site', 'cross-site', 'none'])\n validateFetchMode(req, ['navigate'])\n validateFetchDest(req, ['document'])\n validateOrigin(req, issuerOrigin)\n\n // Do not perform any of the following logic if the request is invalid\n const query = parseOAuthAuthorizationRequestQuery(this.url)\n\n // @NOTE For some reason, even when loaded through a\n // ASWebAuthenticationSession, iOS will sometimes fail to properly save\n // cookies set during the rendering of the page. When this happens, the\n // authorization page logic, which relies on cookies to maintain the session,\n // will fail. To work around this, we perform an initial redirect to ourselves\n // using a form GET submit, in an attempt to verify if the browser saves\n // cookies on redirect or not. If it does, we proceed as normal. If it\n // doesn't, we redirect the user back to the client with an error message.\n if (\n // Only for iOS users\n req.headers['user-agent']?.includes('iPhone OS') &&\n // Disabled if the user already passed the test, which means their browser preserves cookies on redirect\n !(getCookie(req, 'cookie-test') === 'succeeded') &&\n // Disabled if the user already has a session\n !(await server.deviceManager.hasSession(req))\n ) {\n // @TODO Another possible solution would be to avoid relying on cookies if we\n // detect that they are not being preserved. This would mean that preserving\n // sessions (SSO) would not be possible for browsers that don't preserve\n // cookies on redirect, but at least the authorization request could still be\n // completed. This was not implemented yet due to the extra complexity\n // involved in supporting this.\n\n // 1) When the user first comes here, we will test if their browser\n // preserves cookies by redirecting back to ourselves\n if (!this.url.searchParams.has('redirect-test')) {\n // 2) Set a testing cookie\n setCookie(res, 'cookie-test', 'testing', {\n sameSite: 'lax',\n httpOnly: true,\n })\n\n // 3) And send an auto-submit form redirecting back to ourselves\n return writeFormRedirect(\n res,\n 'get',\n this.url.href,\n // 4) We add an extra query parameter to trigger the test logic after\n // the redirect occurred.\n [...this.url.searchParams, ['redirect-test', '1']],\n securityOptions,\n )\n } else {\n // 5) We just got redirected back to ourselves. Verify that the\n // browser preserved cookies during the redirect\n if (getCookie(req, 'cookie-test')) {\n // 6) Success! The browser preserved cookies. Proceed with the\n // normal authorization flow.\n\n // 7) Set a long lasting cookie to skip the test next time\n setCookie(res, 'cookie-test', 'succeeded', {\n sameSite: 'lax',\n maxAge: 31 * 24 * 60 * 60,\n httpOnly: true,\n })\n } else {\n // The browser did NOT preserve cookies. We have to abort the\n // authorization request.\n\n if (this.url.searchParams.get('redirect-test') === '1') {\n // 8) Show an error page to the user explaining the situation\n\n // Give the browser another chance to save cookies after the use\n // pressed \"Continue\"\n setCookie(res, 'cookie-test', 'testing', {\n sameSite: 'lax',\n httpOnly: true,\n })\n\n // Make sure next time we reach the other branch and redirect back\n // to the client\n const continueUrl = new URL(this.url.href)\n continueUrl.searchParams.set('redirect-test', '2')\n return sendCookieErrorPage(req, res, { continueUrl })\n } else {\n // 9) Once the use acknowledges the error, redirect them back to\n // the client with an error message.\n\n // Allow the client to understand what happened (the `error`\n // response parameter value is constrained by the OAuth2 spec)\n const message = 'ERR_COOKIES_UNSUPPORTED'\n\n // @NOTE AuthorizationError thrown here will be caught by the\n // error handler middleware defined below, and cause a redirect\n // back to the client with the error parameters.\n if ('request_uri' in query) {\n // Load and delete the authorization request\n const requestUri = parseRequestUri(query.request_uri, {\n path: ['query', 'request_uri'],\n })\n const data = await server.requestManager.get(\n requestUri,\n undefined,\n query.client_id,\n )\n await server.requestManager.delete(requestUri)\n throw new AuthorizationError(data.parameters, message)\n } else if ('request' in query) {\n const client = await server.clientManager.getClient(\n query.client_id,\n )\n const parameters = await server.decodeJAR(client, query)\n throw new AuthorizationError(parameters, message)\n } else {\n throw new AuthorizationError(query, message)\n }\n }\n }\n }\n }\n\n // Normal authorization flow\n const device = await server.deviceManager.load(req, res)\n\n const result = await server.authorize(query, device)\n\n if ('redirect' in result) {\n return sendAuthorizationResultRedirect(res, result, securityOptions)\n } else {\n return sendAuthorizePage(req, res, result)\n }\n }),\n )\n\n // This is a private endpoint that will be called by the user after the\n // authorization request was either approved or denied. The logic performed\n // here **could** be performed directly in the frontend. We decided to\n // implement it here to avoid duplicating the logic.\n router.get(\n '/oauth/authorize/redirect',\n withErrorHandler(async function (req, res) {\n // Ensure we come from the authorization page\n validateFetchSite(req, ['same-origin'])\n validateFetchMode(req, ['navigate'])\n validateFetchDest(req, ['document'])\n validateOrigin(req, issuerOrigin)\n\n const referrer = validateReferrer(req, {\n origin: issuerOrigin,\n pathname: '/oauth/authorize',\n })\n\n // Ensure we are coming from the authorization page\n requestUriSchema.parse(referrer.searchParams.get('request_uri'))\n\n return sendRedirect(res, parseRedirectUrl(this.url), securityOptions)\n }),\n )\n\n return router.buildMiddleware()\n\n function withErrorHandler<T extends RouterCtx>(\n handler: (this: T, req: Req, res: Res) => Awaitable<void>,\n ): Middleware<T, Req, Res> {\n return async function (req, res) {\n try {\n await handler.call(this, req, res)\n } catch (err) {\n onError?.(req, res, err, `Authorization Request Error`)\n\n if (!res.headersSent) {\n if (err instanceof AuthorizationError) {\n return sendAuthorizationResultRedirect(\n res,\n {\n issuer: server.issuer,\n parameters: err.parameters,\n redirect: err.toJSON(),\n },\n securityOptions,\n )\n } else {\n return sendErrorPage(req, res, err)\n }\n } else if (!res.destroyed) {\n res.end()\n }\n }\n }\n }\n}\n\nfunction parseOAuthAuthorizationRequestQuery(\n url: URL,\n): OAuthAuthorizationRequestQuery {\n const query = Object.fromEntries(url.searchParams)\n const result = oauthAuthorizationRequestQuerySchema.safeParse(query, {\n path: ['query'],\n })\n\n if (!result.success) {\n const message = 'Invalid request parameters'\n const err = result.error\n throw new InvalidRequestError(formatError(err, message), err)\n }\n\n return result.data\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import { Middleware } from '../lib/http/index.js';
|
|
2
|
+
import { type Middleware } from '../lib/http/index.js';
|
|
3
3
|
import type { OAuthProvider } from '../oauth-provider.js';
|
|
4
4
|
import type { MiddlewareOptions } from './middleware-options.js';
|
|
5
5
|
export declare function createOAuthMiddleware<Ctx extends object | void = void, Req extends IncomingMessage = IncomingMessage, Res extends ServerResponse = ServerResponse>(server: OAuthProvider, { onError }: MiddlewareOptions<Req, Res>): Middleware<Ctx, Req, Res>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-oauth-middleware.d.ts","sourceRoot":"","sources":["../../src/router/create-oauth-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"create-oauth-middleware.d.ts","sourceRoot":"","sources":["../../src/router/create-oauth-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAahE,OAAO,EACL,KAAK,UAAU,EAOhB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAqChE,wBAAgB,qBAAqB,CACnC,GAAG,SAAS,MAAM,GAAG,IAAI,GAAG,IAAI,EAChC,GAAG,SAAS,eAAe,GAAG,eAAe,EAC7C,GAAG,SAAS,cAAc,GAAG,cAAc,EAE3C,MAAM,EAAE,aAAa,EACrB,EAAE,OAAO,EAAE,EAAE,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,GACvC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAgL3B"}
|
|
@@ -3,10 +3,10 @@ import { buildErrorPayload, buildErrorStatus } from '../errors/error-parser.js';
|
|
|
3
3
|
import { InvalidClientError } from '../errors/invalid-client-error.js';
|
|
4
4
|
import { InvalidGrantError } from '../errors/invalid-grant-error.js';
|
|
5
5
|
import { InvalidRequestError } from '../errors/invalid-request-error.js';
|
|
6
|
+
import { OAuthError } from '../errors/oauth-error.js';
|
|
6
7
|
import { WWWAuthenticateError } from '../errors/www-authenticate-error.js';
|
|
7
8
|
import { Router, cacheControlMiddleware, combineMiddlewares, jsonHandler, parseHttpRequest, staticJsonMiddleware, } from '../lib/http/index.js';
|
|
8
9
|
import { formatError } from '../lib/util/error.js';
|
|
9
|
-
import { OAuthError } from '../oauth-errors.js';
|
|
10
10
|
// CORS preflight
|
|
11
11
|
const corsHeaders = function (req, res, next) {
|
|
12
12
|
res.setHeader('Access-Control-Max-Age', '86400'); // 1 day
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-oauth-middleware.js","sourceRoot":"","sources":["../../src/router/create-oauth-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kCAAkC,EAClC,4BAA4B,EAC5B,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAEL,MAAM,EACN,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAI/C,iBAAiB;AACjB,MAAM,WAAW,GAAe,UAAU,GAAG,EAAE,GAAG,EAAE,IAAI;IACtD,GAAG,CAAC,SAAS,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAA,CAAC,QAAQ;IAEzD,wFAAwF;IACxF,EAAE;IACF,mEAAmE;IACnE,+DAA+D;IAC/D,4DAA4D;IAC5D,kEAAkE;IAClE,WAAW;IACX,EAAE;IACF,4DAA4D;IAC5D,GAA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C,CAAA;AAC7D,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAY,EAAE,MAAc;IACvD,MAAM,IAAI,mBAAmB,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAA;AAC9D,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport {\n oauthAuthorizationRequestParSchema,\n oauthClientCredentialsSchema,\n oauthTokenIdentificationSchema,\n oauthTokenRequestSchema,\n} from '@atproto/oauth-types'\nimport { buildErrorPayload, buildErrorStatus } from '../errors/error-parser.js'\nimport { InvalidClientError } from '../errors/invalid-client-error.js'\nimport { InvalidGrantError } from '../errors/invalid-grant-error.js'\nimport { InvalidRequestError } from '../errors/invalid-request-error.js'\nimport { WWWAuthenticateError } from '../errors/www-authenticate-error.js'\nimport {\n Middleware,\n Router,\n cacheControlMiddleware,\n combineMiddlewares,\n jsonHandler,\n parseHttpRequest,\n staticJsonMiddleware,\n} from '../lib/http/index.js'\nimport { formatError } from '../lib/util/error.js'\nimport { OAuthError } from '../oauth-errors.js'\nimport type { OAuthProvider } from '../oauth-provider.js'\nimport type { MiddlewareOptions } from './middleware-options.js'\n\n// CORS preflight\nconst corsHeaders: Middleware = function (req, res, next) {\n res.setHeader('Access-Control-Max-Age', '86400') // 1 day\n\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin\n //\n // > For requests without credentials, the literal value \"*\" can be\n // > specified as a wildcard; the value tells browsers to allow\n // > requesting code from any origin to access the resource.\n // > Attempting to use the wildcard with credentials results in an\n // > error.\n //\n // A \"*\" is safer to use than reflecting the request origin.\n res.setHeader('Access-Control-Allow-Origin', '*')\n\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods\n // > The value \"*\" only counts as a special wildcard value for\n // > requests without credentials (requests without HTTP cookies or\n // > HTTP authentication information). In requests with credentials,\n // > it is treated as the literal method name \"*\" without special\n // > semantics.\n res.setHeader('Access-Control-Allow-Methods', '*')\n\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type,DPoP')\n\n next()\n}\n\nconst corsPreflight: Middleware = combineMiddlewares([\n corsHeaders,\n (req, res) => {\n res.writeHead(200).end()\n },\n])\n\nexport function createOAuthMiddleware<\n Ctx extends object | void = void,\n Req extends IncomingMessage = IncomingMessage,\n Res extends ServerResponse = ServerResponse,\n>(\n server: OAuthProvider,\n { onError }: MiddlewareOptions<Req, Res>,\n): Middleware<Ctx, Req, Res> {\n const router = new Router<Ctx, Req, Res>(new URL(server.issuer))\n\n //- Public OAuth endpoints\n\n router.options('/.well-known/oauth-authorization-server', corsPreflight)\n router.get(\n '/.well-known/oauth-authorization-server',\n corsHeaders,\n cacheControlMiddleware(300),\n staticJsonMiddleware(server.metadata),\n )\n\n router.options('/oauth/jwks', corsPreflight)\n router.get(\n '/oauth/jwks',\n corsHeaders,\n cacheControlMiddleware(300),\n staticJsonMiddleware(server.jwks),\n )\n\n router.options('/oauth/par', corsPreflight)\n router.post(\n '/oauth/par',\n corsHeaders,\n oauthHandler(async function (req) {\n const payload = await parseHttpRequest(req, ['json', 'urlencoded'])\n\n // https://datatracker.ietf.org/doc/html/rfc9126#name-error-response\n // https://datatracker.ietf.org/doc/html/rfc6749#autoid-56\n\n const credentials = await oauthClientCredentialsSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidClient(err, 'Client credentials missing'))\n\n const authorizationRequest = await oauthAuthorizationRequestParSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) =>\n throwInvalidRequest(err, 'Invalid authorization request'),\n )\n\n const dpopProof = await server.checkDpopProof(\n req.method!,\n this.url,\n req.headers,\n )\n\n return server.pushedAuthorizationRequest(\n credentials,\n authorizationRequest,\n dpopProof,\n )\n }, 201),\n )\n // https://datatracker.ietf.org/doc/html/rfc9126#section-2.3\n // > If the request did not use the POST method, the authorization server\n // > responds with an HTTP 405 (Method Not Allowed) status code.\n router.all('/oauth/par', (req, res) => {\n res.writeHead(405).end()\n })\n\n router.options('/oauth/token', corsPreflight)\n router.post(\n '/oauth/token',\n corsHeaders,\n oauthHandler(async function (req) {\n const payload = await parseHttpRequest(req, ['json', 'urlencoded'])\n\n const clientMetadata = await server.deviceManager.getRequestMetadata(req)\n\n const clientCredentials = await oauthClientCredentialsSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidGrant(err, 'Client credentials missing'))\n\n const tokenRequest = await oauthTokenRequestSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidGrant(err, 'Invalid request payload'))\n\n const dpopProof = await server.checkDpopProof(\n req.method!,\n this.url,\n req.headers,\n )\n\n return server.token(\n clientCredentials,\n clientMetadata,\n tokenRequest,\n dpopProof,\n )\n }),\n )\n\n router.options('/oauth/revoke', corsPreflight)\n router.post(\n '/oauth/revoke',\n corsHeaders,\n oauthHandler(async function (req, res) {\n const payload = await parseHttpRequest(req, ['json', 'urlencoded'])\n\n const credentials = await oauthClientCredentialsSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidRequest(err, 'Client credentials missing'))\n\n const tokenIdentification = await oauthTokenIdentificationSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidRequest(err, 'Invalid request payload'))\n\n const dpopProof = await server.checkDpopProof(\n req.method!,\n this.url,\n req.headers,\n )\n\n try {\n await server.revoke(credentials, tokenIdentification, dpopProof)\n } catch (err) {\n // > Note: invalid tokens do not cause an error response since the\n // > client cannot handle such an error in a reasonable way. Moreover,\n // > the purpose of the revocation request, invalidating the particular\n // > token, is already achieved.\n //\n // https://datatracker.ietf.org/doc/html/rfc7009#section-2.2\n\n onError?.(req, res, err, 'Failed to revoke token')\n }\n\n return {}\n }),\n )\n\n return router.buildMiddleware()\n\n function oauthHandler<T>(\n buildOAuthResponse: (this: T, req: Req, res: Res) => unknown,\n status?: number,\n ): Middleware<T, Req, Res> {\n return jsonHandler<T, Req, Res>(async function (req, res) {\n try {\n // https://www.rfc-editor.org/rfc/rfc6749.html#section-5.1\n res.setHeader('Cache-Control', 'no-store')\n res.setHeader('Pragma', 'no-cache')\n\n // https://datatracker.ietf.org/doc/html/rfc9449#section-8.2\n const dpopNonce = server.nextDpopNonce()\n if (dpopNonce) {\n const name = 'DPoP-Nonce'\n res.setHeader(name, dpopNonce)\n res.appendHeader('Access-Control-Expose-Headers', name)\n }\n\n const json = await buildOAuthResponse.call(this, req, res)\n return { json, status }\n } catch (err) {\n onError?.(\n req,\n res,\n err,\n err instanceof OAuthError\n ? `OAuth \"${err.error}\" error`\n : 'Unexpected error',\n )\n\n if (!res.headersSent && err instanceof WWWAuthenticateError) {\n const name = 'WWW-Authenticate'\n res.setHeader(name, err.wwwAuthenticateHeader)\n res.appendHeader('Access-Control-Expose-Headers', name)\n }\n\n const status = buildErrorStatus(err)\n const json = buildErrorPayload(err)\n\n return { json, status }\n }\n })\n }\n}\n\nfunction throwInvalidGrant(err: unknown, prefix: string): never {\n throw new InvalidGrantError(formatError(err, prefix), err)\n}\n\nfunction throwInvalidClient(err: unknown, prefix: string): never {\n throw new InvalidClientError(formatError(err, prefix), err)\n}\n\nfunction throwInvalidRequest(err: unknown, prefix: string): never {\n throw new InvalidRequestError(formatError(err, prefix), err)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create-oauth-middleware.js","sourceRoot":"","sources":["../../src/router/create-oauth-middleware.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kCAAkC,EAClC,4BAA4B,EAC5B,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,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AAI,CAAC,CAAA;gBACzD,CAAC;gBAED,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;gBACpC,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAA;gBAEnC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;YACzB,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAY,EAAE,MAAc;IACrD,MAAM,IAAI,iBAAiB,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAA;AAC5D,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAY,EAAE,MAAc;IACtD,MAAM,IAAI,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAA;AAC7D,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAY,EAAE,MAAc;IACvD,MAAM,IAAI,mBAAmB,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAA;AAC9D,CAAC","sourcesContent":["import type { IncomingMessage, ServerResponse } from 'node:http'\nimport {\n oauthAuthorizationRequestParSchema,\n oauthClientCredentialsSchema,\n oauthTokenIdentificationSchema,\n oauthTokenRequestSchema,\n} from '@atproto/oauth-types'\nimport { buildErrorPayload, buildErrorStatus } from '../errors/error-parser.js'\nimport { InvalidClientError } from '../errors/invalid-client-error.js'\nimport { InvalidGrantError } from '../errors/invalid-grant-error.js'\nimport { InvalidRequestError } from '../errors/invalid-request-error.js'\nimport { OAuthError } from '../errors/oauth-error.js'\nimport { WWWAuthenticateError } from '../errors/www-authenticate-error.js'\nimport {\n type Middleware,\n Router,\n cacheControlMiddleware,\n combineMiddlewares,\n jsonHandler,\n parseHttpRequest,\n staticJsonMiddleware,\n} from '../lib/http/index.js'\nimport { formatError } from '../lib/util/error.js'\nimport type { OAuthProvider } from '../oauth-provider.js'\nimport type { MiddlewareOptions } from './middleware-options.js'\n\n// CORS preflight\nconst corsHeaders: Middleware = function (req, res, next) {\n res.setHeader('Access-Control-Max-Age', '86400') // 1 day\n\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin\n //\n // > For requests without credentials, the literal value \"*\" can be\n // > specified as a wildcard; the value tells browsers to allow\n // > requesting code from any origin to access the resource.\n // > Attempting to use the wildcard with credentials results in an\n // > error.\n //\n // A \"*\" is safer to use than reflecting the request origin.\n res.setHeader('Access-Control-Allow-Origin', '*')\n\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods\n // > The value \"*\" only counts as a special wildcard value for\n // > requests without credentials (requests without HTTP cookies or\n // > HTTP authentication information). In requests with credentials,\n // > it is treated as the literal method name \"*\" without special\n // > semantics.\n res.setHeader('Access-Control-Allow-Methods', '*')\n\n res.setHeader('Access-Control-Allow-Headers', 'Content-Type,DPoP')\n\n next()\n}\n\nconst corsPreflight: Middleware = combineMiddlewares([\n corsHeaders,\n (req, res) => {\n res.writeHead(200).end()\n },\n])\n\nexport function createOAuthMiddleware<\n Ctx extends object | void = void,\n Req extends IncomingMessage = IncomingMessage,\n Res extends ServerResponse = ServerResponse,\n>(\n server: OAuthProvider,\n { onError }: MiddlewareOptions<Req, Res>,\n): Middleware<Ctx, Req, Res> {\n const router = new Router<Ctx, Req, Res>(new URL(server.issuer))\n\n //- Public OAuth endpoints\n\n router.options('/.well-known/oauth-authorization-server', corsPreflight)\n router.get(\n '/.well-known/oauth-authorization-server',\n corsHeaders,\n cacheControlMiddleware(300),\n staticJsonMiddleware(server.metadata),\n )\n\n router.options('/oauth/jwks', corsPreflight)\n router.get(\n '/oauth/jwks',\n corsHeaders,\n cacheControlMiddleware(300),\n staticJsonMiddleware(server.jwks),\n )\n\n router.options('/oauth/par', corsPreflight)\n router.post(\n '/oauth/par',\n corsHeaders,\n oauthHandler(async function (req) {\n const payload = await parseHttpRequest(req, ['json', 'urlencoded'])\n\n // https://datatracker.ietf.org/doc/html/rfc9126#name-error-response\n // https://datatracker.ietf.org/doc/html/rfc6749#autoid-56\n\n const credentials = await oauthClientCredentialsSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidClient(err, 'Client credentials missing'))\n\n const authorizationRequest = await oauthAuthorizationRequestParSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) =>\n throwInvalidRequest(err, 'Invalid authorization request'),\n )\n\n const dpopProof = await server.checkDpopProof(\n req.method!,\n this.url,\n req.headers,\n )\n\n return server.pushedAuthorizationRequest(\n credentials,\n authorizationRequest,\n dpopProof,\n )\n }, 201),\n )\n // https://datatracker.ietf.org/doc/html/rfc9126#section-2.3\n // > If the request did not use the POST method, the authorization server\n // > responds with an HTTP 405 (Method Not Allowed) status code.\n router.all('/oauth/par', (req, res) => {\n res.writeHead(405).end()\n })\n\n router.options('/oauth/token', corsPreflight)\n router.post(\n '/oauth/token',\n corsHeaders,\n oauthHandler(async function (req) {\n const payload = await parseHttpRequest(req, ['json', 'urlencoded'])\n\n const clientMetadata = await server.deviceManager.getRequestMetadata(req)\n\n const clientCredentials = await oauthClientCredentialsSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidGrant(err, 'Client credentials missing'))\n\n const tokenRequest = await oauthTokenRequestSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidGrant(err, 'Invalid request payload'))\n\n const dpopProof = await server.checkDpopProof(\n req.method!,\n this.url,\n req.headers,\n )\n\n return server.token(\n clientCredentials,\n clientMetadata,\n tokenRequest,\n dpopProof,\n )\n }),\n )\n\n router.options('/oauth/revoke', corsPreflight)\n router.post(\n '/oauth/revoke',\n corsHeaders,\n oauthHandler(async function (req, res) {\n const payload = await parseHttpRequest(req, ['json', 'urlencoded'])\n\n const credentials = await oauthClientCredentialsSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidRequest(err, 'Client credentials missing'))\n\n const tokenIdentification = await oauthTokenIdentificationSchema\n .parseAsync(payload, { path: ['body'] })\n .catch((err) => throwInvalidRequest(err, 'Invalid request payload'))\n\n const dpopProof = await server.checkDpopProof(\n req.method!,\n this.url,\n req.headers,\n )\n\n try {\n await server.revoke(credentials, tokenIdentification, dpopProof)\n } catch (err) {\n // > Note: invalid tokens do not cause an error response since the\n // > client cannot handle such an error in a reasonable way. Moreover,\n // > the purpose of the revocation request, invalidating the particular\n // > token, is already achieved.\n //\n // https://datatracker.ietf.org/doc/html/rfc7009#section-2.2\n\n onError?.(req, res, err, 'Failed to revoke token')\n }\n\n return {}\n }),\n )\n\n return router.buildMiddleware()\n\n function oauthHandler<T>(\n buildOAuthResponse: (this: T, req: Req, res: Res) => unknown,\n status?: number,\n ): Middleware<T, Req, Res> {\n return jsonHandler<T, Req, Res>(async function (req, res) {\n try {\n // https://www.rfc-editor.org/rfc/rfc6749.html#section-5.1\n res.setHeader('Cache-Control', 'no-store')\n res.setHeader('Pragma', 'no-cache')\n\n // https://datatracker.ietf.org/doc/html/rfc9449#section-8.2\n const dpopNonce = server.nextDpopNonce()\n if (dpopNonce) {\n const name = 'DPoP-Nonce'\n res.setHeader(name, dpopNonce)\n res.appendHeader('Access-Control-Expose-Headers', name)\n }\n\n const json = await buildOAuthResponse.call(this, req, res)\n return { json, status }\n } catch (err) {\n onError?.(\n req,\n res,\n err,\n err instanceof OAuthError\n ? `OAuth \"${err.error}\" error`\n : 'Unexpected error',\n )\n\n if (!res.headersSent && err instanceof WWWAuthenticateError) {\n const name = 'WWW-Authenticate'\n res.setHeader(name, err.wwwAuthenticateHeader)\n res.appendHeader('Access-Control-Expose-Headers', name)\n }\n\n const status = buildErrorStatus(err)\n const json = buildErrorPayload(err)\n\n return { json, status }\n }\n })\n }\n}\n\nfunction throwInvalidGrant(err: unknown, prefix: string): never {\n throw new InvalidGrantError(formatError(err, prefix), err)\n}\n\nfunction throwInvalidClient(err: unknown, prefix: string): never {\n throw new InvalidClientError(formatError(err, prefix), err)\n}\n\nfunction throwInvalidRequest(err: unknown, prefix: string): never {\n throw new InvalidRequestError(formatError(err, prefix), err)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-token-payload.d.ts","sourceRoot":"","sources":["../../src/signer/api-token-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"api-token-payload.d.ts","sourceRoot":"","sources":["../../src/signer/api-token-payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAM5B,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCASlB,CAAA;AAEhB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { didSchema } from '@atproto/did';
|
|
2
2
|
import { jwtPayloadSchema } from '@atproto/jwk';
|
|
3
|
-
import { deviceIdSchema } from '../
|
|
3
|
+
import { deviceIdSchema } from '../device/device-id.js';
|
|
4
4
|
import { requestUriSchema } from '../request/request-uri.js';
|
|
5
5
|
export const apiTokenPayloadSchema = jwtPayloadSchema
|
|
6
6
|
.extend({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-token-payload.js","sourceRoot":"","sources":["../../src/signer/api-token-payload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"api-token-payload.js","sourceRoot":"","sources":["../../src/signer/api-token-payload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAE5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB;KAClD,MAAM,CAAC;IACN,GAAG,EAAE,SAAS;IAEd,QAAQ,EAAE,cAAc;IACxB,2EAA2E;IAC3E,0CAA0C;IAC1C,UAAU,EAAE,gBAAgB,CAAC,QAAQ,EAAE;CACxC,CAAC;KACD,WAAW,EAAE,CAAA","sourcesContent":["import type { z } from 'zod'\nimport { didSchema } from '@atproto/did'\nimport { jwtPayloadSchema } from '@atproto/jwk'\nimport { deviceIdSchema } from '../device/device-id.js'\nimport { requestUriSchema } from '../request/request-uri.js'\n\nexport const apiTokenPayloadSchema = jwtPayloadSchema\n .extend({\n sub: didSchema,\n\n deviceId: deviceIdSchema,\n // If the token is bound to a particular authorization request, it can only\n // be used in the context of that request.\n requestUri: requestUriSchema.optional(),\n })\n .passthrough()\n\nexport type ApiTokenPayload = z.infer<typeof apiTokenPayloadSchema>\n"]}
|
package/dist/signer/signer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { JwtHeader, JwtPayload, JwtPayloadGetter, JwtSignHeader, Key, Keyset, SignedJwt, VerifyOptions, VerifyResult } from '@atproto/jwk';
|
|
2
|
-
import { OmitKey, RequiredKey } from '../lib/util/type.js';
|
|
3
|
-
import { AccessTokenPayload } from './access-token-payload.js';
|
|
4
|
-
import { ApiTokenPayload } from './api-token-payload.js';
|
|
1
|
+
import { type JwtHeader, type JwtPayload, type JwtPayloadGetter, type JwtSignHeader, type Key, Keyset, type SignedJwt, type VerifyOptions, type VerifyResult } from '@atproto/jwk';
|
|
2
|
+
import type { OmitKey, RequiredKey } from '../lib/util/type.js';
|
|
3
|
+
import { type AccessTokenPayload } from './access-token-payload.js';
|
|
4
|
+
import { type ApiTokenPayload } from './api-token-payload.js';
|
|
5
5
|
export type SignPayload = JwtPayload & {
|
|
6
6
|
iss?: never;
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/signer/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/signer/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,GAAG,EACR,MAAM,EACN,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,KAAK,eAAe,EAErB,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAA;CAAE,CAAA;AAEtD,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,CAAA;AAEzE,qBAAa,MAAM;aAEC,MAAM,EAAE,MAAM;aACd,MAAM,EAAE,MAAM;IAFhC,YACkB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EAC5B;IAEE,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,KAAK,EACnC,KAAK,EAAE,SAAS,EAChB,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,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|
3
2
|
import { dateToEpoch } from '../lib/util/date.js';
|
|
3
|
+
import { EPHEMERAL_SESSION_MAX_AGE } from '../oauth-constants.js';
|
|
4
4
|
import { accessTokenPayloadSchema, } from './access-token-payload.js';
|
|
5
|
-
import { apiTokenPayloadSchema } from './api-token-payload.js';
|
|
5
|
+
import { apiTokenPayloadSchema, } from './api-token-payload.js';
|
|
6
6
|
export { Keyset };
|
|
7
7
|
export class Signer {
|
|
8
8
|
constructor(issuer, keyset) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/signer/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,MAAM,GAIP,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/signer/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,MAAM,GAIP,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAEL,wBAAwB,GACzB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAEL,qBAAqB,GACtB,MAAM,wBAAwB,CAAA;AAI/B,OAAO,EAAE,MAAM,EAAE,CAAA;AAGjB,MAAM,OAAO,MAAM;IACjB,YACkB,MAAc,EACd,MAAc;sBADd,MAAM;sBACN,MAAM;IACrB,CAAC;IAEJ,KAAK,CAAC,MAAM,CACV,KAAgB,EAChB,OAA0C;QAE1C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAI,KAAK,EAAE;YACrC,GAAG,OAAO;YACV,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;SACtB,CAAC,CAAA;IACJ,CAAC;IAEM,KAAK,CAAC,IAAI,CACf,UAAyB,EACzB,OAAoD;QAEpD,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,U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AAE,sBAAsB,IAAI,CAAC,MAAM,EAAE;YAC7C,GAAG,EAAE,QAAQ;SACd,CAAC,CAAA;QACF,OAAO;YACL,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAGlD;SACF,CAAA;IACH,CAAC;CACF","sourcesContent":["import {\n type JwtHeader,\n type JwtPayload,\n type JwtPayloadGetter,\n type JwtSignHeader,\n type Key,\n Keyset,\n type SignedJwt,\n type VerifyOptions,\n type VerifyResult,\n} from '@atproto/jwk'\nimport { dateToEpoch } from '../lib/util/date.js'\nimport type { OmitKey, RequiredKey } from '../lib/util/type.js'\nimport { EPHEMERAL_SESSION_MAX_AGE } from '../oauth-constants.js'\nimport {\n type AccessTokenPayload,\n accessTokenPayloadSchema,\n} from './access-token-payload.js'\nimport {\n type ApiTokenPayload,\n apiTokenPayloadSchema,\n} from './api-token-payload.js'\n\nexport type SignPayload = JwtPayload & { iss?: never }\n\nexport { Keyset }\nexport type { JwtPayloadGetter, JwtSignHeader, SignedJwt, VerifyOptions }\n\nexport class Signer {\n constructor(\n public readonly issuer: string,\n public readonly keyset: Keyset,\n ) {}\n\n async verify<C extends string = never>(\n token: SignedJwt,\n options?: Omit<VerifyOptions<C>, 'issuer'>,\n ): Promise<VerifyResult<C> & { key: Key }> {\n return this.keyset.verifyJwt<C>(token, {\n ...options,\n issuer: [this.issuer],\n })\n }\n\n public async sign(\n signHeader: JwtSignHeader,\n payload: SignPayload | JwtPayloadGetter<SignPayload>,\n ): Promise<SignedJwt> {\n return this.keyset.createJwt(signHeader, async (protectedHeader, key) => ({\n ...(typeof payload === 'function'\n ? await payload(protectedHeader, key)\n : payload),\n iss: this.issuer,\n }))\n }\n\n async createAccessToken(\n payload: OmitKey<AccessTokenPayload, 'iss'>,\n ): Promise<SignedJwt> {\n return this.sign(\n {\n // https://datatracker.ietf.org/doc/html/rfc9068#section-2.1\n alg: undefined,\n typ: 'at+jwt',\n },\n payload,\n )\n }\n\n async verifyAccessToken<C extends string = never>(\n token: SignedJwt,\n options?: Omit<VerifyOptions<C>, 'issuer' | 'typ'>,\n ): Promise<{\n protectedHeader: JwtHeader\n payload: RequiredKey<AccessTokenPayload, C>\n }> {\n const result = await this.verify<C>(token, { ...options, typ: 'at+jwt' })\n return {\n protectedHeader: result.protectedHeader,\n payload: accessTokenPayloadSchema.parse(result.payload) as RequiredKey<\n AccessTokenPayload,\n C\n >,\n }\n }\n\n async createEphemeralToken(\n payload: OmitKey<ApiTokenPayload, 'iss' | 'aud' | 'iat'>,\n ): Promise<SignedJwt> {\n return this.sign(\n {\n alg: undefined,\n typ: 'at+jwt',\n },\n {\n ...payload,\n aud: `oauth-provider-api@${this.issuer}`,\n iat: dateToEpoch(),\n },\n )\n }\n\n async verifyEphemeralToken<C extends string = never>(\n token: SignedJwt,\n options?: Omit<VerifyOptions<C>, 'issuer' | 'audience' | 'typ'>,\n ): Promise<{\n protectedHeader: JwtHeader\n payload: RequiredKey<ApiTokenPayload, C>\n }> {\n const result = await this.verify<C>(token, {\n ...options,\n maxTokenAge: options?.maxTokenAge ?? EPHEMERAL_SESSION_MAX_AGE / 1e3,\n audience: `oauth-provider-api@${this.issuer}`,\n typ: 'at+jwt',\n })\n return {\n protectedHeader: result.protectedHeader,\n payload: apiTokenPayloadSchema.parse(result.payload) as RequiredKey<\n ApiTokenPayload,\n C\n >,\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { REFRESH_TOKEN_BYTES_LENGTH, REFRESH_TOKEN_PREFIX, } from '../constants.js';
|
|
3
2
|
import { randomHexId } from '../lib/util/crypto.js';
|
|
3
|
+
import { REFRESH_TOKEN_BYTES_LENGTH, REFRESH_TOKEN_PREFIX, } from '../oauth-constants.js';
|
|
4
4
|
export const REFRESH_TOKEN_LENGTH = REFRESH_TOKEN_PREFIX.length + REFRESH_TOKEN_BYTES_LENGTH * 2; // hex encoding
|
|
5
5
|
export const refreshTokenSchema = z
|
|
6
6
|
.string()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh-token.js","sourceRoot":"","sources":["../../src/token/refresh-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,
|
|
1
|
+
{"version":3,"file":"refresh-token.js","sourceRoot":"","sources":["../../src/token/refresh-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,uBAAuB,CAAA;AAE9B,MAAM,CAAC,MAAM,oBAAoB,GAC/B,oBAAoB,CAAC,MAAM,GAAG,0BAA0B,GAAG,CAAC,CAAA,CAAC,eAAe;AAE9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,EAAE;KACR,MAAM,CAAC,oBAAoB,CAAC;KAC5B,MAAM,CACL,CAAC,CAAC,EAAkD,EAAE,CACpD,CAAC,CAAC,UAAU,CAAC,oBAAoB,CAAC,EACpC;IACE,OAAO,EAAE,8BAA8B;CACxC,CACF,CAAA;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAa,EAAwB,EAAE,CACpE,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAA;AAG5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,IAA2B,EAAE;IACpE,OAAO,GAAG,oBAAoB,GAAG,MAAM,WAAW,CAChD,0BAA0B,CAC3B,EAAE,CAAA;AACL,CAAC,CAAA","sourcesContent":["import { z } from 'zod'\nimport { randomHexId } from '../lib/util/crypto.js'\nimport {\n REFRESH_TOKEN_BYTES_LENGTH,\n REFRESH_TOKEN_PREFIX,\n} from '../oauth-constants.js'\n\nexport const REFRESH_TOKEN_LENGTH =\n REFRESH_TOKEN_PREFIX.length + REFRESH_TOKEN_BYTES_LENGTH * 2 // hex encoding\n\nexport const refreshTokenSchema = z\n .string()\n .length(REFRESH_TOKEN_LENGTH)\n .refine(\n (v): v is `${typeof REFRESH_TOKEN_PREFIX}${string}` =>\n v.startsWith(REFRESH_TOKEN_PREFIX),\n {\n message: `Invalid refresh token format`,\n },\n )\n\nexport const isRefreshToken = (data: unknown): data is RefreshToken =>\n refreshTokenSchema.safeParse(data).success\n\nexport type RefreshToken = z.infer<typeof refreshTokenSchema>\nexport const generateRefreshToken = async (): Promise<RefreshToken> => {\n return `${REFRESH_TOKEN_PREFIX}${await randomHexId(\n REFRESH_TOKEN_BYTES_LENGTH,\n )}`\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Did } from '@atproto/did';
|
|
2
|
-
import { OAuthScope } from '@atproto/oauth-types';
|
|
3
|
-
import { ClientId } from '../client/client-id.js';
|
|
4
|
-
import { TokenId } from './token-id.js';
|
|
1
|
+
import type { Did } from '@atproto/did';
|
|
2
|
+
import type { OAuthScope } from '@atproto/oauth-types';
|
|
3
|
+
import type { ClientId } from '../client/client-id.js';
|
|
4
|
+
import type { TokenId } from './token-id.js';
|
|
5
5
|
/**
|
|
6
6
|
* The access token claims that will be set by the {@link TokenManager} and that
|
|
7
7
|
* will be passed to the "onCreateToken" hook.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-claims.d.ts","sourceRoot":"","sources":["../../src/token/token-claims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"token-claims.d.ts","sourceRoot":"","sources":["../../src/token/token-claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,OAAO,CAAA;IACZ,GAAG,EAAE,GAAG,CAAA;IACR,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;IACnC,GAAG,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;IACrB,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,SAAS,EAAE,QAAQ,CAAA;CACpB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-claims.js","sourceRoot":"","sources":["../../src/token/token-claims.ts"],"names":[],"mappings":"","sourcesContent":["import { Did } from '@atproto/did'\nimport { OAuthScope } from '@atproto/oauth-types'\nimport { ClientId } from '../client/client-id.js'\nimport { TokenId } from './token-id.js'\n\n/**\n * The access token claims that will be set by the {@link TokenManager} and that\n * will be passed to the \"onCreateToken\" hook.\n *\n * @note \"iss\" is missing here because it cannot be altered and will always be\n * set to the Authorization Server's identifier.\n */\nexport type TokenClaims = {\n jti: TokenId\n sub: Did\n iat: number\n exp: number\n aud: string | [string, ...string[]]\n cnf?: { jkt: string }\n scope?: OAuthScope\n client_id: ClientId\n}\n"]}
|
|
1
|
+
{"version":3,"file":"token-claims.js","sourceRoot":"","sources":["../../src/token/token-claims.ts"],"names":[],"mappings":"","sourcesContent":["import type { Did } from '@atproto/did'\nimport type { OAuthScope } from '@atproto/oauth-types'\nimport type { ClientId } from '../client/client-id.js'\nimport type { TokenId } from './token-id.js'\n\n/**\n * The access token claims that will be set by the {@link TokenManager} and that\n * will be passed to the \"onCreateToken\" hook.\n *\n * @note \"iss\" is missing here because it cannot be altered and will always be\n * set to the Authorization Server's identifier.\n */\nexport type TokenClaims = {\n jti: TokenId\n sub: Did\n iat: number\n exp: number\n aud: string | [string, ...string[]]\n cnf?: { jkt: string }\n scope?: OAuthScope\n client_id: ClientId\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Did } from '@atproto/did';
|
|
2
|
-
import { OAuthAuthorizationDetails, OAuthAuthorizationRequestParameters } from '@atproto/oauth-types';
|
|
3
|
-
import { ClientAuth, ClientAuthLegacy } from '../client/client-auth.js';
|
|
4
|
-
import { ClientId } from '../client/client-id.js';
|
|
5
|
-
import { DeviceId } from '../device/device-id.js';
|
|
6
|
-
import { Code } from '../request/code.js';
|
|
7
|
-
export type { ClientAuth, ClientId, Code, DeviceId, Did, OAuthAuthorizationDetails, OAuthAuthorizationRequestParameters, };
|
|
1
|
+
import type { Did } from '@atproto/did';
|
|
2
|
+
import type { OAuthAuthorizationDetails, OAuthAuthorizationRequestParameters } from '@atproto/oauth-types';
|
|
3
|
+
import type { ClientAuth, ClientAuthLegacy } from '../client/client-auth.js';
|
|
4
|
+
import type { ClientId } from '../client/client-id.js';
|
|
5
|
+
import type { DeviceId } from '../device/device-id.js';
|
|
6
|
+
import type { Code } from '../request/code.js';
|
|
7
|
+
export type { ClientAuth, ClientAuthLegacy, ClientId, Code, DeviceId, Did, OAuthAuthorizationDetails, OAuthAuthorizationRequestParameters, };
|
|
8
8
|
export type TokenData = {
|
|
9
9
|
createdAt: Date;
|
|
10
10
|
updatedAt: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-data.d.ts","sourceRoot":"","sources":["../../src/token/token-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"token-data.d.ts","sourceRoot":"","sources":["../../src/token/token-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,EACV,yBAAyB,EACzB,mCAAmC,EACpC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAE9C,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,GAAG,EACH,yBAAyB,EACzB,mCAAmC,GACpC,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,IAAI,CAAA;IACf,SAAS,EAAE,IAAI,CAAA;IACf,SAAS,EAAE,IAAI,CAAA;IACf,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,EAAE,UAAU,GAAG,gBAAgB,CAAA;IACzC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAA;IACzB,GAAG,EAAE,GAAG,CAAA;IACR,UAAU,EAAE,mCAAmC,CAAA;IAC/C,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;IAEjB;;;;;OAKG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-data.js","sourceRoot":"","sources":["../../src/token/token-data.ts"],"names":[],"mappings":"","sourcesContent":["import { Did } from '@atproto/did'\nimport {\n OAuthAuthorizationDetails,\n OAuthAuthorizationRequestParameters,\n} from '@atproto/oauth-types'\nimport { ClientAuth, ClientAuthLegacy } from '../client/client-auth.js'\nimport { ClientId } from '../client/client-id.js'\nimport { DeviceId } from '../device/device-id.js'\nimport { Code } from '../request/code.js'\n\nexport type {\n ClientAuth,\n ClientId,\n Code,\n DeviceId,\n Did,\n OAuthAuthorizationDetails,\n OAuthAuthorizationRequestParameters,\n}\n\nexport type TokenData = {\n createdAt: Date\n updatedAt: Date\n expiresAt: Date\n clientId: ClientId\n clientAuth: ClientAuth | ClientAuthLegacy\n deviceId: DeviceId | null\n did: Did\n parameters: OAuthAuthorizationRequestParameters\n details?: null // Legacy field, not used\n code: Code | null\n\n /**\n * This will contain the parameter scope, translated into permissions\n *\n * @note null because this didn't use to exist. New tokens should always\n * include a scope.\n */\n scope: string | null\n}\n"]}
|
|
1
|
+
{"version":3,"file":"token-data.js","sourceRoot":"","sources":["../../src/token/token-data.ts"],"names":[],"mappings":"","sourcesContent":["import type { Did } from '@atproto/did'\nimport type {\n OAuthAuthorizationDetails,\n OAuthAuthorizationRequestParameters,\n} from '@atproto/oauth-types'\nimport type { ClientAuth, ClientAuthLegacy } from '../client/client-auth.js'\nimport type { ClientId } from '../client/client-id.js'\nimport type { DeviceId } from '../device/device-id.js'\nimport type { Code } from '../request/code.js'\n\nexport type {\n ClientAuth,\n ClientAuthLegacy,\n ClientId,\n Code,\n DeviceId,\n Did,\n OAuthAuthorizationDetails,\n OAuthAuthorizationRequestParameters,\n}\n\nexport type TokenData = {\n createdAt: Date\n updatedAt: Date\n expiresAt: Date\n clientId: ClientId\n clientAuth: ClientAuth | ClientAuthLegacy\n deviceId: DeviceId | null\n did: Did\n parameters: OAuthAuthorizationRequestParameters\n details?: null // Legacy field, not used\n code: Code | null\n\n /**\n * This will contain the parameter scope, translated into permissions\n *\n * @note null because this didn't use to exist. New tokens should always\n * include a scope.\n */\n scope: string | null\n}\n"]}
|
package/dist/token/token-id.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { TOKEN_ID_BYTES_LENGTH, TOKEN_ID_PREFIX } from '../constants.js';
|
|
3
2
|
import { randomHexId } from '../lib/util/crypto.js';
|
|
3
|
+
import { TOKEN_ID_BYTES_LENGTH, TOKEN_ID_PREFIX } from '../oauth-constants.js';
|
|
4
4
|
export const TOKEN_ID_LENGTH = TOKEN_ID_PREFIX.length + TOKEN_ID_BYTES_LENGTH * 2; // hex encoding
|
|
5
5
|
export const tokenIdSchema = z
|
|
6
6
|
.string()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-id.js","sourceRoot":"","sources":["../../src/token/token-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"token-id.js","sourceRoot":"","sources":["../../src/token/token-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE9E,MAAM,CAAC,MAAM,eAAe,GAC1B,eAAe,CAAC,MAAM,GAAG,qBAAqB,GAAG,CAAC,CAAA,CAAC,eAAe;AAEpE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC;KAC3B,MAAM,EAAE;KACR,MAAM,CAAC,eAAe,CAAC;KACvB,MAAM,CACL,CAAC,CAAC,EAA6C,EAAE,CAC/C,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,EAC/B;IACE,OAAO,EAAE,yBAAyB;CACnC,CACF,CAAA;AAGH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,IAAsB,EAAE;IAC1D,OAAO,GAAG,eAAe,GAAG,MAAM,WAAW,CAAC,qBAAqB,CAAC,EAAE,CAAA;AACxE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAAa,EAAmB,EAAE,CAC1D,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAA","sourcesContent":["import { z } from 'zod'\nimport { randomHexId } from '../lib/util/crypto.js'\nimport { TOKEN_ID_BYTES_LENGTH, TOKEN_ID_PREFIX } from '../oauth-constants.js'\n\nexport const TOKEN_ID_LENGTH =\n TOKEN_ID_PREFIX.length + TOKEN_ID_BYTES_LENGTH * 2 // hex encoding\n\nexport const tokenIdSchema = z\n .string()\n .length(TOKEN_ID_LENGTH)\n .refine(\n (v): v is `${typeof TOKEN_ID_PREFIX}${string}` =>\n v.startsWith(TOKEN_ID_PREFIX),\n {\n message: `Invalid token ID format`,\n },\n )\n\nexport type TokenId = z.infer<typeof tokenIdSchema>\nexport const generateTokenId = async (): Promise<TokenId> => {\n return `${TOKEN_ID_PREFIX}${await randomHexId(TOKEN_ID_BYTES_LENGTH)}`\n}\n\nexport const isTokenId = (data: unknown): data is TokenId =>\n tokenIdSchema.safeParse(data).success\n"]}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { Did } from '@atproto/did';
|
|
2
|
-
import { SignedJwt } from '@atproto/jwk';
|
|
2
|
+
import { type SignedJwt } from '@atproto/jwk';
|
|
3
3
|
import type { Account } from '@atproto/oauth-provider-api';
|
|
4
|
-
import { OAuthAccessToken, OAuthAuthorizationRequestParameters, OAuthScope, OAuthTokenResponse, OAuthTokenType } from '@atproto/oauth-types';
|
|
4
|
+
import type { OAuthAccessToken, OAuthAuthorizationRequestParameters, OAuthScope, OAuthTokenResponse, OAuthTokenType } from '@atproto/oauth-types';
|
|
5
5
|
import { AccessTokenMode } from '../access-token/access-token-mode.js';
|
|
6
|
-
import { ClientAuth } from '../client/client-auth.js';
|
|
7
|
-
import { Client } from '../client/client.js';
|
|
8
|
-
import { DeviceId } from '../device/device-id.js';
|
|
9
|
-
import { LexiconManager } from '../lexicon/lexicon-manager.js';
|
|
10
|
-
import { RequestMetadata } from '../lib/http/request.js';
|
|
11
|
-
import { OAuthHooks } from '../oauth-hooks.js';
|
|
12
|
-
import { Code } from '../request/code.js';
|
|
13
|
-
import { AccessTokenPayload } from '../signer/access-token-payload.js';
|
|
6
|
+
import type { ClientAuth } from '../client/client-auth.js';
|
|
7
|
+
import type { Client } from '../client/client.js';
|
|
8
|
+
import type { DeviceId } from '../device/device-id.js';
|
|
9
|
+
import type { LexiconManager } from '../lexicon/lexicon-manager.js';
|
|
10
|
+
import type { RequestMetadata } from '../lib/http/request.js';
|
|
11
|
+
import type { OAuthHooks } from '../oauth-hooks.js';
|
|
12
|
+
import { type Code } from '../request/code.js';
|
|
13
|
+
import type { AccessTokenPayload } from '../signer/access-token-payload.js';
|
|
14
14
|
import { Signer } from '../signer/signer.js';
|
|
15
|
-
import { RefreshToken } from './refresh-token.js';
|
|
16
|
-
import { TokenClaims } from './token-claims.js';
|
|
17
|
-
import { TokenId } from './token-id.js';
|
|
18
|
-
import { TokenInfo, TokenStore } from './token-store.js';
|
|
15
|
+
import { type RefreshToken } from './refresh-token.js';
|
|
16
|
+
import type { TokenClaims } from './token-claims.js';
|
|
17
|
+
import { type TokenId } from './token-id.js';
|
|
18
|
+
import type { TokenInfo, TokenStore } from './token-store.js';
|
|
19
19
|
export { AccessTokenMode, Signer };
|
|
20
20
|
export type { OAuthHooks, TokenStore };
|
|
21
21
|
export declare class TokenManager {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-manager.d.ts","sourceRoot":"","sources":["../../src/token/token-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,SAAS,EAAe,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"token-manager.d.ts","sourceRoot":"","sources":["../../src/token/token-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,cAAc,CAAA;AAE1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,KAAK,EACV,gBAAgB,EAChB,mCAAmC,EACnC,UAAU,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,sBAA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,CAY/D;IAEY,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAiB1E;IAED,UAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAE3B;IAEY,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAyBxE;IAEY,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAE7D;IAEY,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAExD;IAEK,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC,CAE9D;IAED;;;;OAIG;IACG,eAAe,CACnB,SAAS,EAAE,cAAc,EACzB,YAAY,EAAE,kBAAkB,GAC/B,OAAO,CAAC,WAAW,CAAC,CAmCtB;IAEK,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAKtD;CACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isSignedJwt } from '@atproto/jwk';
|
|
2
2
|
import { LexResolverError } from '@atproto/lex-resolver';
|
|
3
3
|
import { AccessTokenMode } from '../access-token/access-token-mode.js';
|
|
4
|
-
import { TOKEN_MAX_AGE } from '../constants.js';
|
|
5
4
|
import { InvalidGrantError } from '../errors/invalid-grant-error.js';
|
|
6
5
|
import { InvalidRequestError } from '../errors/invalid-request-error.js';
|
|
7
6
|
import { InvalidTokenError } from '../errors/invalid-token-error.js';
|
|
8
7
|
import { dateToEpoch, dateToRelativeSeconds } from '../lib/util/date.js';
|
|
8
|
+
import { TOKEN_MAX_AGE } from '../oauth-constants.js';
|
|
9
9
|
import { isCode } from '../request/code.js';
|
|
10
10
|
import { Signer } from '../signer/signer.js';
|
|
11
11
|
import { generateRefreshToken, isRefreshToken, } from './refresh-token.js';
|