create-croissant 0.1.8 → 0.1.9
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/package.json +1 -1
- package/template/apps/web/package.json +2 -0
- package/template/apps/web/src/components/login-form.tsx +95 -48
- package/template/apps/web/src/components/signup-form.tsx +149 -79
- package/template/apps/web/src/routes/__root.tsx +17 -12
- package/template/apps/web/src/routes/client-orpc-auth.tsx +8 -20
- package/template/apps/web/src/routes/client-orpc.tsx +203 -108
- package/template/apps/web/src/routes/ssr-orpc.tsx +169 -96
- package/template/package.json +3 -1
- package/template/apps/web/node_modules/@better-auth/core/LICENSE.md +0 -20
- package/template/apps/web/node_modules/@better-auth/core/README.md +0 -17
- package/template/apps/web/node_modules/@better-auth/core/dist/api/index.d.mts +0 -278
- package/template/apps/web/node_modules/@better-auth/core/dist/api/index.mjs +0 -56
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/index.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/index.mjs +0 -20
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/pure.index.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/async_hooks/pure.index.mjs +0 -33
- package/template/apps/web/node_modules/@better-auth/core/dist/context/endpoint-context.d.mts +0 -18
- package/template/apps/web/node_modules/@better-auth/core/dist/context/endpoint-context.mjs +0 -29
- package/template/apps/web/node_modules/@better-auth/core/dist/context/global.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/context/global.mjs +0 -36
- package/template/apps/web/node_modules/@better-auth/core/dist/context/index.d.mts +0 -5
- package/template/apps/web/node_modules/@better-auth/core/dist/context/index.mjs +0 -5
- package/template/apps/web/node_modules/@better-auth/core/dist/context/request-state.d.mts +0 -27
- package/template/apps/web/node_modules/@better-auth/core/dist/context/request-state.mjs +0 -47
- package/template/apps/web/node_modules/@better-auth/core/dist/context/transaction.d.mts +0 -24
- package/template/apps/web/node_modules/@better-auth/core/dist/context/transaction.mjs +0 -93
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/factory.d.mts +0 -17
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/factory.mjs +0 -754
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-field-name.d.mts +0 -18
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-field-name.mjs +0 -36
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-model-name.d.mts +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-default-model-name.mjs +0 -30
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-attributes.d.mts +0 -26
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-attributes.mjs +0 -37
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-name.d.mts +0 -18
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-field-name.mjs +0 -31
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-id-field.d.mts +0 -36
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-id-field.mjs +0 -64
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-model-name.d.mts +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/get-model-name.mjs +0 -21
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/index.d.mts +0 -525
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/index.mjs +0 -24
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/types.d.mts +0 -105
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/utils.d.mts +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/db/adapter/utils.mjs +0 -37
- package/template/apps/web/node_modules/@better-auth/core/dist/db/get-tables.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/db/get-tables.mjs +0 -265
- package/template/apps/web/node_modules/@better-auth/core/dist/db/index.d.mts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/db/index.mjs +0 -8
- package/template/apps/web/node_modules/@better-auth/core/dist/db/plugin.d.mts +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/account.d.mts +0 -28
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/account.mjs +0 -17
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/rate-limit.d.mts +0 -18
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/rate-limit.mjs +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/session.d.mts +0 -23
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/session.mjs +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/shared.d.mts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/shared.mjs +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/user.d.mts +0 -22
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/user.mjs +0 -11
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/verification.d.mts +0 -21
- package/template/apps/web/node_modules/@better-auth/core/dist/db/schema/verification.mjs +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/db/type.d.mts +0 -167
- package/template/apps/web/node_modules/@better-auth/core/dist/env/color-depth.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/env/color-depth.mjs +0 -86
- package/template/apps/web/node_modules/@better-auth/core/dist/env/env-impl.d.mts +0 -32
- package/template/apps/web/node_modules/@better-auth/core/dist/env/env-impl.mjs +0 -81
- package/template/apps/web/node_modules/@better-auth/core/dist/env/index.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/env/index.mjs +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/env/logger.d.mts +0 -48
- package/template/apps/web/node_modules/@better-auth/core/dist/env/logger.mjs +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/error/codes.d.mts +0 -68
- package/template/apps/web/node_modules/@better-auth/core/dist/error/codes.mjs +0 -54
- package/template/apps/web/node_modules/@better-auth/core/dist/error/index.d.mts +0 -19
- package/template/apps/web/node_modules/@better-auth/core/dist/error/index.mjs +0 -27
- package/template/apps/web/node_modules/@better-auth/core/dist/index.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/index.mjs +0 -1
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/api.mjs +0 -12
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/attributes.d.mts +0 -11
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/attributes.mjs +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/index.d.mts +0 -3
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/index.mjs +0 -3
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/noop.mjs +0 -42
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/pure.index.d.mts +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/pure.index.mjs +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/tracer.d.mts +0 -13
- package/template/apps/web/node_modules/@better-auth/core/dist/instrumentation/tracer.mjs +0 -53
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/client-credentials-token.d.mts +0 -56
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/client-credentials-token.mjs +0 -64
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/create-authorization-url.d.mts +0 -44
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/create-authorization-url.mjs +0 -41
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/index.d.mts +0 -8
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/index.mjs +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/oauth-provider.d.mts +0 -192
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/refresh-access-token.d.mts +0 -54
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/refresh-access-token.mjs +0 -73
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/utils.d.mts +0 -16
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/utils.mjs +0 -37
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/validate-authorization-code.d.mts +0 -85
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/validate-authorization-code.mjs +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/verify.d.mts +0 -42
- package/template/apps/web/node_modules/@better-auth/core/dist/oauth2/verify.mjs +0 -92
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/apple.d.mts +0 -126
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/apple.mjs +0 -107
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/atlassian.d.mts +0 -70
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/atlassian.mjs +0 -80
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/cognito.d.mts +0 -85
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/cognito.mjs +0 -162
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/discord.d.mts +0 -124
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/discord.mjs +0 -62
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/dropbox.d.mts +0 -69
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/dropbox.mjs +0 -72
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/facebook.d.mts +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/facebook.mjs +0 -124
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/figma.d.mts +0 -61
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/figma.mjs +0 -83
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/github.d.mts +0 -102
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/github.mjs +0 -92
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/gitlab.d.mts +0 -123
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/gitlab.mjs +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/google.d.mts +0 -97
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/google.mjs +0 -109
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/huggingface.d.mts +0 -83
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/huggingface.mjs +0 -73
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/index.d.mts +0 -1834
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/index.mjs +0 -78
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kakao.d.mts +0 -161
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kakao.mjs +0 -70
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kick.d.mts +0 -73
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/kick.mjs +0 -68
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/line.d.mts +0 -105
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/line.mjs +0 -110
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linear.d.mts +0 -68
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linear.mjs +0 -85
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linkedin.d.mts +0 -67
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/linkedin.mjs +0 -73
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/microsoft-entra-id.d.mts +0 -174
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/microsoft-entra-id.mjs +0 -140
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/naver.d.mts +0 -92
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/naver.mjs +0 -65
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/notion.d.mts +0 -64
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/notion.mjs +0 -72
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paybin.d.mts +0 -71
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paybin.mjs +0 -81
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paypal.d.mts +0 -129
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/paypal.mjs +0 -140
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/polar.d.mts +0 -74
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/polar.mjs +0 -71
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/railway.d.mts +0 -65
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/railway.mjs +0 -74
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/reddit.d.mts +0 -62
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/reddit.mjs +0 -80
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/roblox.d.mts +0 -70
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/roblox.mjs +0 -57
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/salesforce.d.mts +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/salesforce.mjs +0 -87
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/slack.d.mts +0 -83
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/slack.mjs +0 -66
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/spotify.d.mts +0 -63
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/spotify.mjs +0 -69
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/tiktok.d.mts +0 -168
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/tiktok.mjs +0 -60
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitch.d.mts +0 -79
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitch.mjs +0 -75
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitter.d.mts +0 -126
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/twitter.mjs +0 -85
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vercel.d.mts +0 -62
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vercel.mjs +0 -58
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vk.d.mts +0 -70
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/vk.mjs +0 -81
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/wechat.d.mts +0 -113
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/wechat.mjs +0 -81
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/zoom.d.mts +0 -163
- package/template/apps/web/node_modules/@better-auth/core/dist/social-providers/zoom.mjs +0 -69
- package/template/apps/web/node_modules/@better-auth/core/dist/types/context.d.mts +0 -277
- package/template/apps/web/node_modules/@better-auth/core/dist/types/cookie.d.mts +0 -15
- package/template/apps/web/node_modules/@better-auth/core/dist/types/helper.d.mts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/types/index.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/types/init-options.d.mts +0 -1358
- package/template/apps/web/node_modules/@better-auth/core/dist/types/plugin-client.d.mts +0 -113
- package/template/apps/web/node_modules/@better-auth/core/dist/types/plugin.d.mts +0 -124
- package/template/apps/web/node_modules/@better-auth/core/dist/types/secret.d.mts +0 -11
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/async.d.mts +0 -22
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/async.mjs +0 -32
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/db.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/db.mjs +0 -15
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/deprecate.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/deprecate.mjs +0 -16
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/error-codes.d.mts +0 -13
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/error-codes.mjs +0 -10
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/fetch-metadata.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/fetch-metadata.mjs +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/host.d.mts +0 -147
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/host.mjs +0 -291
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/id.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/id.mjs +0 -7
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/ip.d.mts +0 -54
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/ip.mjs +0 -116
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/is-api-error.d.mts +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/is-api-error.mjs +0 -8
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/json.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/json.mjs +0 -41
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/string.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/string.mjs +0 -6
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/url.d.mts +0 -20
- package/template/apps/web/node_modules/@better-auth/core/dist/utils/url.mjs +0 -31
- package/template/apps/web/node_modules/@better-auth/core/package.json +0 -193
- package/template/apps/web/node_modules/@better-auth/core/src/api/index.ts +0 -140
- package/template/apps/web/node_modules/@better-auth/core/src/async_hooks/index.ts +0 -40
- package/template/apps/web/node_modules/@better-auth/core/src/async_hooks/pure.index.ts +0 -46
- package/template/apps/web/node_modules/@better-auth/core/src/context/endpoint-context.ts +0 -50
- package/template/apps/web/node_modules/@better-auth/core/src/context/global.ts +0 -57
- package/template/apps/web/node_modules/@better-auth/core/src/context/index.ts +0 -23
- package/template/apps/web/node_modules/@better-auth/core/src/context/request-state.ts +0 -91
- package/template/apps/web/node_modules/@better-auth/core/src/context/transaction.ts +0 -136
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/factory.ts +0 -1440
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-default-field-name.ts +0 -59
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-default-model-name.ts +0 -51
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-field-attributes.ts +0 -62
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-field-name.ts +0 -43
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-id-field.ts +0 -150
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/get-model-name.ts +0 -36
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/index.ts +0 -567
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/types.ts +0 -132
- package/template/apps/web/node_modules/@better-auth/core/src/db/adapter/utils.ts +0 -61
- package/template/apps/web/node_modules/@better-auth/core/src/db/get-tables.ts +0 -296
- package/template/apps/web/node_modules/@better-auth/core/src/db/index.ts +0 -43
- package/template/apps/web/node_modules/@better-auth/core/src/db/plugin.ts +0 -11
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/account.ts +0 -47
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/rate-limit.ts +0 -36
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/session.ts +0 -29
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/shared.ts +0 -7
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/user.ts +0 -28
- package/template/apps/web/node_modules/@better-auth/core/src/db/schema/verification.ts +0 -28
- package/template/apps/web/node_modules/@better-auth/core/src/db/type.ts +0 -333
- package/template/apps/web/node_modules/@better-auth/core/src/env/color-depth.ts +0 -172
- package/template/apps/web/node_modules/@better-auth/core/src/env/env-impl.ts +0 -124
- package/template/apps/web/node_modules/@better-auth/core/src/env/index.ts +0 -23
- package/template/apps/web/node_modules/@better-auth/core/src/env/logger.ts +0 -145
- package/template/apps/web/node_modules/@better-auth/core/src/error/codes.ts +0 -71
- package/template/apps/web/node_modules/@better-auth/core/src/error/index.ts +0 -35
- package/template/apps/web/node_modules/@better-auth/core/src/index.ts +0 -1
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/api.ts +0 -17
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/attributes.ts +0 -22
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/index.ts +0 -2
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/noop.ts +0 -74
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/pure.index.ts +0 -31
- package/template/apps/web/node_modules/@better-auth/core/src/instrumentation/tracer.ts +0 -95
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/client-credentials-token.ts +0 -126
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/create-authorization-url.ts +0 -89
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/index.ts +0 -33
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/oauth-provider.ts +0 -222
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/refresh-access-token.ts +0 -157
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/utils.ts +0 -51
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/validate-authorization-code.ts +0 -180
- package/template/apps/web/node_modules/@better-auth/core/src/oauth2/verify.ts +0 -221
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/apple.ts +0 -231
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/atlassian.ts +0 -133
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/cognito.ts +0 -281
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/discord.ts +0 -170
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/dropbox.ts +0 -112
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/facebook.ts +0 -215
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/figma.ts +0 -118
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/github.ts +0 -184
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/gitlab.ts +0 -155
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/google.ts +0 -204
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/huggingface.ts +0 -119
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/index.ts +0 -132
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/kakao.ts +0 -179
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/kick.ts +0 -109
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/line.ts +0 -169
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/linear.ts +0 -121
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/linkedin.ts +0 -110
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/microsoft-entra-id.ts +0 -352
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/naver.ts +0 -113
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/notion.ts +0 -108
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/paybin.ts +0 -118
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/paypal.ts +0 -263
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/polar.ts +0 -111
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/railway.ts +0 -100
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/reddit.ts +0 -122
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/roblox.ts +0 -112
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/salesforce.ts +0 -159
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/slack.ts +0 -112
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/spotify.ts +0 -94
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/tiktok.ts +0 -211
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/twitch.ts +0 -112
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/twitter.ts +0 -199
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/vercel.ts +0 -87
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/vk.ts +0 -125
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/wechat.ts +0 -213
- package/template/apps/web/node_modules/@better-auth/core/src/social-providers/zoom.ts +0 -230
- package/template/apps/web/node_modules/@better-auth/core/src/types/context.ts +0 -415
- package/template/apps/web/node_modules/@better-auth/core/src/types/cookie.ts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/src/types/helper.ts +0 -27
- package/template/apps/web/node_modules/@better-auth/core/src/types/index.ts +0 -40
- package/template/apps/web/node_modules/@better-auth/core/src/types/init-options.ts +0 -1610
- package/template/apps/web/node_modules/@better-auth/core/src/types/plugin-client.ts +0 -129
- package/template/apps/web/node_modules/@better-auth/core/src/types/plugin.ts +0 -163
- package/template/apps/web/node_modules/@better-auth/core/src/types/secret.ts +0 -8
- package/template/apps/web/node_modules/@better-auth/core/src/utils/async.ts +0 -53
- package/template/apps/web/node_modules/@better-auth/core/src/utils/db.ts +0 -20
- package/template/apps/web/node_modules/@better-auth/core/src/utils/deprecate.ts +0 -21
- package/template/apps/web/node_modules/@better-auth/core/src/utils/error-codes.ts +0 -68
- package/template/apps/web/node_modules/@better-auth/core/src/utils/fetch-metadata.ts +0 -3
- package/template/apps/web/node_modules/@better-auth/core/src/utils/host.ts +0 -401
- package/template/apps/web/node_modules/@better-auth/core/src/utils/id.ts +0 -5
- package/template/apps/web/node_modules/@better-auth/core/src/utils/ip.ts +0 -211
- package/template/apps/web/node_modules/@better-auth/core/src/utils/is-api-error.ts +0 -10
- package/template/apps/web/node_modules/@better-auth/core/src/utils/json.ts +0 -56
- package/template/apps/web/node_modules/@better-auth/core/src/utils/string.ts +0 -3
- package/template/apps/web/node_modules/@better-auth/core/src/utils/url.ts +0 -43
- package/template/apps/web/node_modules/@better-auth/utils/README.md +0 -384
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.cjs +0 -104
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.d.cts +0 -44
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.d.mts +0 -44
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.d.ts +0 -44
- package/template/apps/web/node_modules/@better-auth/utils/dist/base32.mjs +0 -101
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.cjs +0 -80
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.d.cts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.d.mts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.d.ts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/base64.mjs +0 -77
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.cjs +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.d.cts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.d.mts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.d.ts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/binary.mjs +0 -14
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.cjs +0 -90
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.d.cts +0 -19
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.d.mts +0 -19
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.d.ts +0 -19
- package/template/apps/web/node_modules/@better-auth/utils/dist/ecdsa.mjs +0 -88
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.cjs +0 -31
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.d.cts +0 -7
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.d.mts +0 -7
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.d.ts +0 -7
- package/template/apps/web/node_modules/@better-auth/utils/dist/hash.mjs +0 -29
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.cjs +0 -40
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.d.cts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.d.mts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.d.ts +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/hex.mjs +0 -38
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.cjs +0 -58
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.d.cts +0 -9
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.d.mts +0 -9
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.d.ts +0 -9
- package/template/apps/web/node_modules/@better-auth/utils/dist/hmac.mjs +0 -56
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.cjs +0 -10
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.d.cts +0 -3
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.d.mts +0 -3
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.d.ts +0 -3
- package/template/apps/web/node_modules/@better-auth/utils/dist/index.mjs +0 -8
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.cjs +0 -90
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.d.cts +0 -13
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.d.mts +0 -13
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.d.ts +0 -13
- package/template/apps/web/node_modules/@better-auth/utils/dist/otp.mjs +0 -88
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.cjs +0 -36
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.d.cts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.d.ts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.mjs +0 -33
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.cjs +0 -47
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.d.cts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.d.ts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/password.node.mjs +0 -44
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.cjs +0 -55
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.d.cts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.d.mts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.d.ts +0 -4
- package/template/apps/web/node_modules/@better-auth/utils/dist/random.mjs +0 -53
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.cjs +0 -76
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.d.cts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.d.mts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.d.ts +0 -16
- package/template/apps/web/node_modules/@better-auth/utils/dist/rsa.mjs +0 -74
- package/template/apps/web/node_modules/@better-auth/utils/dist/shared/utils.ecd028f7.d.cts +0 -22
- package/template/apps/web/node_modules/@better-auth/utils/dist/shared/utils.ecd028f7.d.mts +0 -22
- package/template/apps/web/node_modules/@better-auth/utils/dist/shared/utils.ecd028f7.d.ts +0 -22
- package/template/apps/web/node_modules/@better-auth/utils/package.json +0 -95
- package/template/apps/web/node_modules/better-call/LICENSE +0 -21
- package/template/apps/web/node_modules/better-call/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.cjs +0 -181
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.d.cts +0 -16
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.d.mts +0 -16
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.mjs +0 -178
- package/template/apps/web/node_modules/better-call/dist/adapters/node/request.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/client.cjs +0 -23
- package/template/apps/web/node_modules/better-call/dist/client.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/client.d.cts +0 -53
- package/template/apps/web/node_modules/better-call/dist/client.d.mts +0 -53
- package/template/apps/web/node_modules/better-call/dist/client.mjs +0 -14
- package/template/apps/web/node_modules/better-call/dist/client.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/context.cjs +0 -103
- package/template/apps/web/node_modules/better-call/dist/context.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/context.d.cts +0 -341
- package/template/apps/web/node_modules/better-call/dist/context.d.mts +0 -341
- package/template/apps/web/node_modules/better-call/dist/context.mjs +0 -103
- package/template/apps/web/node_modules/better-call/dist/context.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/cookies.cjs +0 -87
- package/template/apps/web/node_modules/better-call/dist/cookies.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/cookies.d.cts +0 -103
- package/template/apps/web/node_modules/better-call/dist/cookies.d.mts +0 -103
- package/template/apps/web/node_modules/better-call/dist/cookies.mjs +0 -84
- package/template/apps/web/node_modules/better-call/dist/cookies.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/crypto.cjs +0 -39
- package/template/apps/web/node_modules/better-call/dist/crypto.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/crypto.mjs +0 -36
- package/template/apps/web/node_modules/better-call/dist/crypto.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/endpoint.cjs +0 -70
- package/template/apps/web/node_modules/better-call/dist/endpoint.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/endpoint.d.cts +0 -475
- package/template/apps/web/node_modules/better-call/dist/endpoint.d.mts +0 -475
- package/template/apps/web/node_modules/better-call/dist/endpoint.mjs +0 -70
- package/template/apps/web/node_modules/better-call/dist/endpoint.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/error.cjs +0 -141
- package/template/apps/web/node_modules/better-call/dist/error.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/error.d.cts +0 -103
- package/template/apps/web/node_modules/better-call/dist/error.d.mts +0 -103
- package/template/apps/web/node_modules/better-call/dist/error.mjs +0 -133
- package/template/apps/web/node_modules/better-call/dist/error.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/helper.d.cts +0 -12
- package/template/apps/web/node_modules/better-call/dist/helper.d.mts +0 -12
- package/template/apps/web/node_modules/better-call/dist/index.cjs +0 -28
- package/template/apps/web/node_modules/better-call/dist/index.d.cts +0 -11
- package/template/apps/web/node_modules/better-call/dist/index.d.mts +0 -11
- package/template/apps/web/node_modules/better-call/dist/index.mjs +0 -10
- package/template/apps/web/node_modules/better-call/dist/middleware.cjs +0 -52
- package/template/apps/web/node_modules/better-call/dist/middleware.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/middleware.d.cts +0 -123
- package/template/apps/web/node_modules/better-call/dist/middleware.d.mts +0 -123
- package/template/apps/web/node_modules/better-call/dist/middleware.mjs +0 -52
- package/template/apps/web/node_modules/better-call/dist/middleware.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/node.cjs +0 -18
- package/template/apps/web/node_modules/better-call/dist/node.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/node.d.cts +0 -9
- package/template/apps/web/node_modules/better-call/dist/node.d.mts +0 -9
- package/template/apps/web/node_modules/better-call/dist/node.mjs +0 -15
- package/template/apps/web/node_modules/better-call/dist/node.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/openapi.cjs +0 -191
- package/template/apps/web/node_modules/better-call/dist/openapi.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/openapi.d.cts +0 -113
- package/template/apps/web/node_modules/better-call/dist/openapi.d.mts +0 -113
- package/template/apps/web/node_modules/better-call/dist/openapi.mjs +0 -189
- package/template/apps/web/node_modules/better-call/dist/openapi.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/router.cjs +0 -118
- package/template/apps/web/node_modules/better-call/dist/router.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/router.d.cts +0 -103
- package/template/apps/web/node_modules/better-call/dist/router.d.mts +0 -103
- package/template/apps/web/node_modules/better-call/dist/router.mjs +0 -117
- package/template/apps/web/node_modules/better-call/dist/router.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/standard-schema.d.cts +0 -59
- package/template/apps/web/node_modules/better-call/dist/standard-schema.d.mts +0 -59
- package/template/apps/web/node_modules/better-call/dist/to-response.cjs +0 -153
- package/template/apps/web/node_modules/better-call/dist/to-response.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/to-response.d.cts +0 -12
- package/template/apps/web/node_modules/better-call/dist/to-response.d.mts +0 -12
- package/template/apps/web/node_modules/better-call/dist/to-response.mjs +0 -153
- package/template/apps/web/node_modules/better-call/dist/to-response.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/utils.cjs +0 -86
- package/template/apps/web/node_modules/better-call/dist/utils.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/utils.mjs +0 -82
- package/template/apps/web/node_modules/better-call/dist/utils.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/validator.cjs +0 -58
- package/template/apps/web/node_modules/better-call/dist/validator.cjs.map +0 -1
- package/template/apps/web/node_modules/better-call/dist/validator.mjs +0 -57
- package/template/apps/web/node_modules/better-call/dist/validator.mjs.map +0 -1
- package/template/apps/web/node_modules/better-call/package.json +0 -96
- package/template/apps/web/node_modules/set-cookie-parser/LICENSE +0 -21
- package/template/apps/web/node_modules/set-cookie-parser/README.md +0 -169
- package/template/apps/web/node_modules/set-cookie-parser/dist/.eslintrc.cjs +0 -16
- package/template/apps/web/node_modules/set-cookie-parser/dist/set-cookie.cjs +0 -260
- package/template/apps/web/node_modules/set-cookie-parser/lib/set-cookie.d.ts +0 -119
- package/template/apps/web/node_modules/set-cookie-parser/lib/set-cookie.js +0 -265
- package/template/apps/web/node_modules/set-cookie-parser/package.json +0 -61
package/template/apps/web/node_modules/@better-auth/core/src/oauth2/validate-authorization-code.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { base64 } from "@better-auth/utils/base64";
|
|
2
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
3
|
-
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
4
|
-
import type { AwaitableFunction } from "../types";
|
|
5
|
-
import type { ProviderOptions } from "./index";
|
|
6
|
-
import { getOAuth2Tokens } from "./index";
|
|
7
|
-
|
|
8
|
-
export async function authorizationCodeRequest({
|
|
9
|
-
code,
|
|
10
|
-
codeVerifier,
|
|
11
|
-
redirectURI,
|
|
12
|
-
options,
|
|
13
|
-
authentication,
|
|
14
|
-
deviceId,
|
|
15
|
-
headers,
|
|
16
|
-
additionalParams = {},
|
|
17
|
-
resource,
|
|
18
|
-
}: {
|
|
19
|
-
code: string;
|
|
20
|
-
redirectURI: string;
|
|
21
|
-
options: AwaitableFunction<Partial<ProviderOptions>>;
|
|
22
|
-
codeVerifier?: string | undefined;
|
|
23
|
-
deviceId?: string | undefined;
|
|
24
|
-
authentication?: ("basic" | "post") | undefined;
|
|
25
|
-
headers?: Record<string, string> | undefined;
|
|
26
|
-
additionalParams?: Record<string, string> | undefined;
|
|
27
|
-
resource?: (string | string[]) | undefined;
|
|
28
|
-
}) {
|
|
29
|
-
options = typeof options === "function" ? await options() : options;
|
|
30
|
-
return createAuthorizationCodeRequest({
|
|
31
|
-
code,
|
|
32
|
-
codeVerifier,
|
|
33
|
-
redirectURI,
|
|
34
|
-
options,
|
|
35
|
-
authentication,
|
|
36
|
-
deviceId,
|
|
37
|
-
headers,
|
|
38
|
-
additionalParams,
|
|
39
|
-
resource,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated use async'd authorizationCodeRequest instead
|
|
45
|
-
*/
|
|
46
|
-
export function createAuthorizationCodeRequest({
|
|
47
|
-
code,
|
|
48
|
-
codeVerifier,
|
|
49
|
-
redirectURI,
|
|
50
|
-
options,
|
|
51
|
-
authentication,
|
|
52
|
-
deviceId,
|
|
53
|
-
headers,
|
|
54
|
-
additionalParams = {},
|
|
55
|
-
resource,
|
|
56
|
-
}: {
|
|
57
|
-
code: string;
|
|
58
|
-
redirectURI: string;
|
|
59
|
-
options: Partial<ProviderOptions>;
|
|
60
|
-
codeVerifier?: string | undefined;
|
|
61
|
-
deviceId?: string | undefined;
|
|
62
|
-
authentication?: ("basic" | "post") | undefined;
|
|
63
|
-
headers?: Record<string, string> | undefined;
|
|
64
|
-
additionalParams?: Record<string, string> | undefined;
|
|
65
|
-
resource?: (string | string[]) | undefined;
|
|
66
|
-
}) {
|
|
67
|
-
const body = new URLSearchParams();
|
|
68
|
-
const requestHeaders: Record<string, any> = {
|
|
69
|
-
"content-type": "application/x-www-form-urlencoded",
|
|
70
|
-
accept: "application/json",
|
|
71
|
-
...headers,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
body.set("grant_type", "authorization_code");
|
|
75
|
-
body.set("code", code);
|
|
76
|
-
codeVerifier && body.set("code_verifier", codeVerifier);
|
|
77
|
-
options.clientKey && body.set("client_key", options.clientKey);
|
|
78
|
-
deviceId && body.set("device_id", deviceId);
|
|
79
|
-
body.set("redirect_uri", options.redirectURI || redirectURI);
|
|
80
|
-
if (resource) {
|
|
81
|
-
if (typeof resource === "string") {
|
|
82
|
-
body.append("resource", resource);
|
|
83
|
-
} else {
|
|
84
|
-
for (const _resource of resource) {
|
|
85
|
-
body.append("resource", _resource);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// Use standard Base64 encoding for HTTP Basic Auth (OAuth2 spec, RFC 7617)
|
|
90
|
-
// Fixes compatibility with providers like Notion, Twitter, etc.
|
|
91
|
-
if (authentication === "basic") {
|
|
92
|
-
const primaryClientId = Array.isArray(options.clientId)
|
|
93
|
-
? options.clientId[0]
|
|
94
|
-
: options.clientId;
|
|
95
|
-
const encodedCredentials = base64.encode(
|
|
96
|
-
`${primaryClientId}:${options.clientSecret ?? ""}`,
|
|
97
|
-
);
|
|
98
|
-
requestHeaders["authorization"] = `Basic ${encodedCredentials}`;
|
|
99
|
-
} else {
|
|
100
|
-
const primaryClientId = Array.isArray(options.clientId)
|
|
101
|
-
? options.clientId[0]
|
|
102
|
-
: options.clientId;
|
|
103
|
-
body.set("client_id", primaryClientId);
|
|
104
|
-
if (options.clientSecret) {
|
|
105
|
-
body.set("client_secret", options.clientSecret);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
for (const [key, value] of Object.entries(additionalParams)) {
|
|
110
|
-
if (!body.has(key)) body.append(key, value);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return {
|
|
114
|
-
body,
|
|
115
|
-
headers: requestHeaders,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export async function validateAuthorizationCode({
|
|
120
|
-
code,
|
|
121
|
-
codeVerifier,
|
|
122
|
-
redirectURI,
|
|
123
|
-
options,
|
|
124
|
-
tokenEndpoint,
|
|
125
|
-
authentication,
|
|
126
|
-
deviceId,
|
|
127
|
-
headers,
|
|
128
|
-
additionalParams = {},
|
|
129
|
-
resource,
|
|
130
|
-
}: {
|
|
131
|
-
code: string;
|
|
132
|
-
redirectURI: string;
|
|
133
|
-
options: AwaitableFunction<Partial<ProviderOptions>>;
|
|
134
|
-
codeVerifier?: string | undefined;
|
|
135
|
-
deviceId?: string | undefined;
|
|
136
|
-
tokenEndpoint: string;
|
|
137
|
-
authentication?: ("basic" | "post") | undefined;
|
|
138
|
-
headers?: Record<string, string> | undefined;
|
|
139
|
-
additionalParams?: Record<string, string> | undefined;
|
|
140
|
-
resource?: (string | string[]) | undefined;
|
|
141
|
-
}) {
|
|
142
|
-
const { body, headers: requestHeaders } = await authorizationCodeRequest({
|
|
143
|
-
code,
|
|
144
|
-
codeVerifier,
|
|
145
|
-
redirectURI,
|
|
146
|
-
options,
|
|
147
|
-
authentication,
|
|
148
|
-
deviceId,
|
|
149
|
-
headers,
|
|
150
|
-
additionalParams,
|
|
151
|
-
resource,
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const { data, error } = await betterFetch<object>(tokenEndpoint, {
|
|
155
|
-
method: "POST",
|
|
156
|
-
body: body,
|
|
157
|
-
headers: requestHeaders,
|
|
158
|
-
});
|
|
159
|
-
if (error) {
|
|
160
|
-
throw error;
|
|
161
|
-
}
|
|
162
|
-
const tokens = getOAuth2Tokens(data);
|
|
163
|
-
return tokens;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
export async function validateToken(
|
|
167
|
-
token: string,
|
|
168
|
-
jwksEndpoint: string,
|
|
169
|
-
options?: {
|
|
170
|
-
audience?: string | string[];
|
|
171
|
-
issuer?: string | string[];
|
|
172
|
-
},
|
|
173
|
-
) {
|
|
174
|
-
const jwks = createRemoteJWKSet(new URL(jwksEndpoint));
|
|
175
|
-
const verified = await jwtVerify(token, jwks, {
|
|
176
|
-
audience: options?.audience,
|
|
177
|
-
issuer: options?.issuer,
|
|
178
|
-
});
|
|
179
|
-
return verified;
|
|
180
|
-
}
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
import { APIError } from "better-call";
|
|
3
|
-
import type {
|
|
4
|
-
JSONWebKeySet,
|
|
5
|
-
JWTPayload,
|
|
6
|
-
JWTVerifyOptions,
|
|
7
|
-
ProtectedHeaderParameters,
|
|
8
|
-
} from "jose";
|
|
9
|
-
import {
|
|
10
|
-
createLocalJWKSet,
|
|
11
|
-
decodeProtectedHeader,
|
|
12
|
-
jwtVerify,
|
|
13
|
-
UnsecuredJWT,
|
|
14
|
-
} from "jose";
|
|
15
|
-
import { logger } from "../env";
|
|
16
|
-
|
|
17
|
-
/** Last fetched jwks used locally in getJwks @internal */
|
|
18
|
-
let jwks: JSONWebKeySet | undefined;
|
|
19
|
-
|
|
20
|
-
export interface VerifyAccessTokenRemote {
|
|
21
|
-
/** Full url of the introspect endpoint. Should end with `/oauth2/introspect` */
|
|
22
|
-
introspectUrl: string;
|
|
23
|
-
/** Client Secret */
|
|
24
|
-
clientId: string;
|
|
25
|
-
/** Client Secret */
|
|
26
|
-
clientSecret: string;
|
|
27
|
-
/**
|
|
28
|
-
* Forces remote verification of a token.
|
|
29
|
-
* This ensures attached session (if applicable)
|
|
30
|
-
* is also still active.
|
|
31
|
-
*/
|
|
32
|
-
force?: boolean;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Performs local verification of an access token for your APIs.
|
|
37
|
-
*
|
|
38
|
-
* Can also be configured for remote verification.
|
|
39
|
-
*/
|
|
40
|
-
export async function verifyJwsAccessToken(
|
|
41
|
-
token: string,
|
|
42
|
-
opts: {
|
|
43
|
-
/** Jwks url or promise of a Jwks */
|
|
44
|
-
jwksFetch: string | (() => Promise<JSONWebKeySet | undefined>);
|
|
45
|
-
/** Verify options */
|
|
46
|
-
verifyOptions: JWTVerifyOptions &
|
|
47
|
-
Required<Pick<JWTVerifyOptions, "audience" | "issuer">>;
|
|
48
|
-
},
|
|
49
|
-
) {
|
|
50
|
-
try {
|
|
51
|
-
const jwks = await getJwks(token, opts);
|
|
52
|
-
const jwt = await jwtVerify<JWTPayload>(
|
|
53
|
-
token,
|
|
54
|
-
createLocalJWKSet(jwks),
|
|
55
|
-
opts.verifyOptions,
|
|
56
|
-
);
|
|
57
|
-
// Return the JWT payload in introspection format
|
|
58
|
-
// https://datatracker.ietf.org/doc/html/rfc7662#section-2.2
|
|
59
|
-
if (jwt.payload.azp) {
|
|
60
|
-
jwt.payload.client_id = jwt.payload.azp;
|
|
61
|
-
}
|
|
62
|
-
return jwt.payload;
|
|
63
|
-
} catch (error) {
|
|
64
|
-
if (error instanceof Error) throw error;
|
|
65
|
-
throw new Error(error as unknown as string);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export async function getJwks(
|
|
70
|
-
token: string,
|
|
71
|
-
opts: {
|
|
72
|
-
/** Jwks url or promise of a Jwks */
|
|
73
|
-
jwksFetch: string | (() => Promise<JSONWebKeySet | undefined>);
|
|
74
|
-
},
|
|
75
|
-
) {
|
|
76
|
-
// Attempt to decode the token and find a matching kid in jwks
|
|
77
|
-
let jwtHeaders: ProtectedHeaderParameters | undefined;
|
|
78
|
-
try {
|
|
79
|
-
jwtHeaders = decodeProtectedHeader(token);
|
|
80
|
-
} catch (error) {
|
|
81
|
-
if (error instanceof Error) throw error;
|
|
82
|
-
throw new Error(error as unknown as string);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!jwtHeaders.kid) throw new Error("Missing jwt kid");
|
|
86
|
-
|
|
87
|
-
// Fetch jwks if not set or has a different kid than the one stored
|
|
88
|
-
if (!jwks || !jwks.keys.find((jwk) => jwk.kid === jwtHeaders.kid)) {
|
|
89
|
-
jwks =
|
|
90
|
-
typeof opts.jwksFetch === "string"
|
|
91
|
-
? await betterFetch<JSONWebKeySet>(opts.jwksFetch, {
|
|
92
|
-
headers: {
|
|
93
|
-
Accept: "application/json",
|
|
94
|
-
},
|
|
95
|
-
}).then(async (res) => {
|
|
96
|
-
if (res.error)
|
|
97
|
-
throw new Error(
|
|
98
|
-
`Jwks failed: ${res.error.message ?? res.error.statusText}`,
|
|
99
|
-
);
|
|
100
|
-
return res.data;
|
|
101
|
-
})
|
|
102
|
-
: await opts.jwksFetch();
|
|
103
|
-
if (!jwks) throw new Error("No jwks found");
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return jwks;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Performs local verification of an access token for your API.
|
|
111
|
-
*
|
|
112
|
-
* Can also be configured for remote verification.
|
|
113
|
-
*/
|
|
114
|
-
export async function verifyAccessToken(
|
|
115
|
-
token: string,
|
|
116
|
-
opts: {
|
|
117
|
-
/** Verify options */
|
|
118
|
-
verifyOptions: JWTVerifyOptions &
|
|
119
|
-
Required<Pick<JWTVerifyOptions, "audience" | "issuer">>;
|
|
120
|
-
/** Scopes to additionally verify. Token must include all but not exact. */
|
|
121
|
-
scopes?: string[];
|
|
122
|
-
/** Required to verify access token locally */
|
|
123
|
-
jwksUrl?: string;
|
|
124
|
-
/** If provided, can verify a token remotely */
|
|
125
|
-
remoteVerify?: VerifyAccessTokenRemote;
|
|
126
|
-
},
|
|
127
|
-
) {
|
|
128
|
-
let payload: JWTPayload | undefined;
|
|
129
|
-
// Locally verify
|
|
130
|
-
if (opts.jwksUrl && !opts?.remoteVerify?.force) {
|
|
131
|
-
try {
|
|
132
|
-
payload = await verifyJwsAccessToken(token, {
|
|
133
|
-
jwksFetch: opts.jwksUrl,
|
|
134
|
-
verifyOptions: opts.verifyOptions,
|
|
135
|
-
});
|
|
136
|
-
} catch (error) {
|
|
137
|
-
if (error instanceof Error) {
|
|
138
|
-
if (error.name === "TypeError" || error.name === "JWSInvalid") {
|
|
139
|
-
// likely an opaque token (continue)
|
|
140
|
-
} else if (error.name === "JWTExpired") {
|
|
141
|
-
throw new APIError("UNAUTHORIZED", {
|
|
142
|
-
message: "token expired",
|
|
143
|
-
});
|
|
144
|
-
} else if (error.name === "JWTInvalid") {
|
|
145
|
-
throw new APIError("UNAUTHORIZED", {
|
|
146
|
-
message: "token invalid",
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
throw error;
|
|
150
|
-
}
|
|
151
|
-
} else {
|
|
152
|
-
throw new Error(error as unknown as string);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Remote verify
|
|
158
|
-
if (opts?.remoteVerify) {
|
|
159
|
-
const { data: introspect, error: introspectError } = await betterFetch<
|
|
160
|
-
JWTPayload & {
|
|
161
|
-
active: boolean;
|
|
162
|
-
}
|
|
163
|
-
>(opts.remoteVerify.introspectUrl, {
|
|
164
|
-
method: "POST",
|
|
165
|
-
headers: {
|
|
166
|
-
Accept: "application/json",
|
|
167
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
168
|
-
},
|
|
169
|
-
body: new URLSearchParams({
|
|
170
|
-
client_id: opts.remoteVerify.clientId,
|
|
171
|
-
client_secret: opts.remoteVerify.clientSecret,
|
|
172
|
-
token,
|
|
173
|
-
token_type_hint: "access_token",
|
|
174
|
-
}).toString(),
|
|
175
|
-
});
|
|
176
|
-
if (introspectError)
|
|
177
|
-
logger.error(
|
|
178
|
-
`Introspection failed: ${introspectError.message ?? introspectError.statusText}`,
|
|
179
|
-
);
|
|
180
|
-
if (!introspect)
|
|
181
|
-
throw new APIError("INTERNAL_SERVER_ERROR", {
|
|
182
|
-
message: "introspection failed",
|
|
183
|
-
});
|
|
184
|
-
if (!introspect.active)
|
|
185
|
-
throw new APIError("UNAUTHORIZED", {
|
|
186
|
-
message: "token inactive",
|
|
187
|
-
});
|
|
188
|
-
// Verifies payload using verify options (token valid through introspect)
|
|
189
|
-
try {
|
|
190
|
-
const unsecuredJwt = new UnsecuredJWT(introspect).encode();
|
|
191
|
-
const { audience: _audience, ...verifyOptions } = opts.verifyOptions;
|
|
192
|
-
const verify = introspect.aud
|
|
193
|
-
? UnsecuredJWT.decode(unsecuredJwt, opts.verifyOptions)
|
|
194
|
-
: UnsecuredJWT.decode(unsecuredJwt, verifyOptions);
|
|
195
|
-
payload = verify.payload;
|
|
196
|
-
} catch (error) {
|
|
197
|
-
throw new Error(error as unknown as string);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (!payload)
|
|
202
|
-
throw new APIError("UNAUTHORIZED", {
|
|
203
|
-
message: `no token payload`,
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
// Check scopes if provided
|
|
207
|
-
if (opts.scopes) {
|
|
208
|
-
const validScopes = new Set(
|
|
209
|
-
(payload.scope as string | undefined)?.split(" "),
|
|
210
|
-
);
|
|
211
|
-
for (const sc of opts.scopes) {
|
|
212
|
-
if (!validScopes.has(sc)) {
|
|
213
|
-
throw new APIError("FORBIDDEN", {
|
|
214
|
-
message: `invalid scope ${sc}`,
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return payload;
|
|
221
|
-
}
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { betterFetch } from "@better-fetch/fetch";
|
|
2
|
-
|
|
3
|
-
import { decodeJwt, decodeProtectedHeader, importJWK, jwtVerify } from "jose";
|
|
4
|
-
import { logger } from "../env";
|
|
5
|
-
import { APIError, BetterAuthError } from "../error";
|
|
6
|
-
import type { OAuthProvider, ProviderOptions } from "../oauth2";
|
|
7
|
-
import {
|
|
8
|
-
createAuthorizationURL,
|
|
9
|
-
getPrimaryClientId,
|
|
10
|
-
refreshAccessToken,
|
|
11
|
-
validateAuthorizationCode,
|
|
12
|
-
} from "../oauth2";
|
|
13
|
-
export interface AppleProfile {
|
|
14
|
-
/**
|
|
15
|
-
* The subject registered claim identifies the principal that’s the subject
|
|
16
|
-
* of the identity token. Because this token is for your app, the value is
|
|
17
|
-
* the unique identifier for the user.
|
|
18
|
-
*/
|
|
19
|
-
sub: string;
|
|
20
|
-
/**
|
|
21
|
-
* A String value representing the user's email address.
|
|
22
|
-
* The email address is either the user's real email address or the proxy
|
|
23
|
-
* address, depending on their status private email relay service.
|
|
24
|
-
*/
|
|
25
|
-
email: string;
|
|
26
|
-
/**
|
|
27
|
-
* A string or Boolean value that indicates whether the service verifies
|
|
28
|
-
* the email. The value can either be a string ("true" or "false") or a
|
|
29
|
-
* Boolean (true or false). The system may not verify email addresses for
|
|
30
|
-
* Sign in with Apple at Work & School users, and this claim is "false" or
|
|
31
|
-
* false for those users.
|
|
32
|
-
*/
|
|
33
|
-
email_verified: true | "true";
|
|
34
|
-
/**
|
|
35
|
-
* A string or Boolean value that indicates whether the email that the user
|
|
36
|
-
* shares is the proxy address. The value can either be a string ("true" or
|
|
37
|
-
* "false") or a Boolean (true or false).
|
|
38
|
-
*/
|
|
39
|
-
is_private_email: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* An Integer value that indicates whether the user appears to be a real
|
|
42
|
-
* person. Use the value of this claim to mitigate fraud. The possible
|
|
43
|
-
* values are: 0 (or Unsupported), 1 (or Unknown), 2 (or LikelyReal). For
|
|
44
|
-
* more information, see ASUserDetectionStatus. This claim is present only
|
|
45
|
-
* in iOS 14 and later, macOS 11 and later, watchOS 7 and later, tvOS 14
|
|
46
|
-
* and later. The claim isn’t present or supported for web-based apps.
|
|
47
|
-
*/
|
|
48
|
-
real_user_status: number;
|
|
49
|
-
/**
|
|
50
|
-
* The user’s full name in the format provided during the authorization
|
|
51
|
-
* process.
|
|
52
|
-
*/
|
|
53
|
-
name: string;
|
|
54
|
-
/**
|
|
55
|
-
* The URL to the user's profile picture.
|
|
56
|
-
*/
|
|
57
|
-
picture: string;
|
|
58
|
-
user?: AppleNonConformUser | undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* This is the shape of the `user` query parameter that Apple sends the first
|
|
63
|
-
* time the user consents to the app.
|
|
64
|
-
* @see https://developer.apple.com/documentation/signinwithapplerestapi/request-an-authorization-to-the-sign-in-with-apple-server./
|
|
65
|
-
*/
|
|
66
|
-
export interface AppleNonConformUser {
|
|
67
|
-
name: {
|
|
68
|
-
firstName: string;
|
|
69
|
-
lastName: string;
|
|
70
|
-
};
|
|
71
|
-
email: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface AppleOptions extends ProviderOptions<AppleProfile> {
|
|
75
|
-
clientId: string | string[];
|
|
76
|
-
appBundleIdentifier?: string | undefined;
|
|
77
|
-
audience?: (string | string[]) | undefined;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export const apple = (options: AppleOptions) => {
|
|
81
|
-
const tokenEndpoint = "https://appleid.apple.com/auth/token";
|
|
82
|
-
return {
|
|
83
|
-
id: "apple",
|
|
84
|
-
name: "Apple",
|
|
85
|
-
async createAuthorizationURL({ state, scopes, redirectURI }) {
|
|
86
|
-
if (!getPrimaryClientId(options.clientId) || !options.clientSecret) {
|
|
87
|
-
logger.error(
|
|
88
|
-
"Client ID and client secret are required for Apple. Make sure to provide them in the options.",
|
|
89
|
-
);
|
|
90
|
-
throw new BetterAuthError("CLIENT_ID_AND_SECRET_REQUIRED");
|
|
91
|
-
}
|
|
92
|
-
const _scope = options.disableDefaultScope ? [] : ["email", "name"];
|
|
93
|
-
if (options.scope) _scope.push(...options.scope);
|
|
94
|
-
if (scopes) _scope.push(...scopes);
|
|
95
|
-
const url = await createAuthorizationURL({
|
|
96
|
-
id: "apple",
|
|
97
|
-
options,
|
|
98
|
-
authorizationEndpoint: "https://appleid.apple.com/auth/authorize",
|
|
99
|
-
scopes: _scope,
|
|
100
|
-
state,
|
|
101
|
-
redirectURI,
|
|
102
|
-
responseMode: "form_post",
|
|
103
|
-
responseType: "code id_token",
|
|
104
|
-
});
|
|
105
|
-
return url;
|
|
106
|
-
},
|
|
107
|
-
validateAuthorizationCode: async ({ code, codeVerifier, redirectURI }) => {
|
|
108
|
-
return validateAuthorizationCode({
|
|
109
|
-
code,
|
|
110
|
-
codeVerifier,
|
|
111
|
-
redirectURI,
|
|
112
|
-
options,
|
|
113
|
-
tokenEndpoint,
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
async verifyIdToken(token, nonce) {
|
|
117
|
-
if (options.disableIdTokenSignIn) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
if (options.verifyIdToken) {
|
|
121
|
-
return options.verifyIdToken(token, nonce);
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
const decodedHeader = decodeProtectedHeader(token);
|
|
125
|
-
const { kid, alg: jwtAlg } = decodedHeader;
|
|
126
|
-
if (!kid || !jwtAlg) return false;
|
|
127
|
-
const publicKey = await getApplePublicKey(kid);
|
|
128
|
-
const { payload: jwtClaims } = await jwtVerify(token, publicKey, {
|
|
129
|
-
algorithms: [jwtAlg],
|
|
130
|
-
issuer: "https://appleid.apple.com",
|
|
131
|
-
audience:
|
|
132
|
-
options.audience && options.audience.length
|
|
133
|
-
? options.audience
|
|
134
|
-
: options.appBundleIdentifier
|
|
135
|
-
? options.appBundleIdentifier
|
|
136
|
-
: options.clientId,
|
|
137
|
-
maxTokenAge: "1h",
|
|
138
|
-
});
|
|
139
|
-
["email_verified", "is_private_email"].forEach((field) => {
|
|
140
|
-
if (jwtClaims[field] !== undefined) {
|
|
141
|
-
jwtClaims[field] = Boolean(jwtClaims[field]);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
if (nonce && jwtClaims.nonce !== nonce) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
return !!jwtClaims;
|
|
148
|
-
} catch {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
refreshAccessToken: options.refreshAccessToken
|
|
153
|
-
? options.refreshAccessToken
|
|
154
|
-
: async (refreshToken) => {
|
|
155
|
-
return refreshAccessToken({
|
|
156
|
-
refreshToken,
|
|
157
|
-
options,
|
|
158
|
-
tokenEndpoint,
|
|
159
|
-
});
|
|
160
|
-
},
|
|
161
|
-
async getUserInfo(token) {
|
|
162
|
-
if (options.getUserInfo) {
|
|
163
|
-
return options.getUserInfo(token);
|
|
164
|
-
}
|
|
165
|
-
if (!token.idToken) {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
const profile = decodeJwt<AppleProfile>(token.idToken);
|
|
169
|
-
if (!profile) {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// TODO: "" masking will be removed when the name field is made optional
|
|
174
|
-
let name: string;
|
|
175
|
-
if (token.user?.name) {
|
|
176
|
-
const firstName = token.user.name.firstName || "";
|
|
177
|
-
const lastName = token.user.name.lastName || "";
|
|
178
|
-
const fullName = `${firstName} ${lastName}`.trim();
|
|
179
|
-
name = fullName;
|
|
180
|
-
} else {
|
|
181
|
-
name = profile.name || "";
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const emailVerified =
|
|
185
|
-
typeof profile.email_verified === "boolean"
|
|
186
|
-
? profile.email_verified
|
|
187
|
-
: profile.email_verified === "true";
|
|
188
|
-
const enrichedProfile = {
|
|
189
|
-
...profile,
|
|
190
|
-
name,
|
|
191
|
-
};
|
|
192
|
-
const userMap = await options.mapProfileToUser?.(enrichedProfile);
|
|
193
|
-
return {
|
|
194
|
-
user: {
|
|
195
|
-
id: profile.sub,
|
|
196
|
-
name: enrichedProfile.name,
|
|
197
|
-
emailVerified: emailVerified,
|
|
198
|
-
email: profile.email,
|
|
199
|
-
...userMap,
|
|
200
|
-
},
|
|
201
|
-
data: enrichedProfile,
|
|
202
|
-
};
|
|
203
|
-
},
|
|
204
|
-
options,
|
|
205
|
-
} satisfies OAuthProvider<AppleProfile>;
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export const getApplePublicKey = async (kid: string) => {
|
|
209
|
-
const APPLE_BASE_URL = "https://appleid.apple.com";
|
|
210
|
-
const JWKS_APPLE_URI = "/auth/keys";
|
|
211
|
-
const { data } = await betterFetch<{
|
|
212
|
-
keys: Array<{
|
|
213
|
-
kid: string;
|
|
214
|
-
alg: string;
|
|
215
|
-
kty: string;
|
|
216
|
-
use: string;
|
|
217
|
-
n: string;
|
|
218
|
-
e: string;
|
|
219
|
-
}>;
|
|
220
|
-
}>(`${APPLE_BASE_URL}${JWKS_APPLE_URI}`);
|
|
221
|
-
if (!data?.keys) {
|
|
222
|
-
throw new APIError("BAD_REQUEST", {
|
|
223
|
-
message: "Keys not found",
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
const jwk = data.keys.find((key) => key.kid === kid);
|
|
227
|
-
if (!jwk) {
|
|
228
|
-
throw new Error(`JWK with kid ${kid} not found`);
|
|
229
|
-
}
|
|
230
|
-
return await importJWK(jwk, jwk.alg);
|
|
231
|
-
};
|