@gatwech/auth 1.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/access-BO2g7QVe.mjs +45 -0
- package/dist/access-C6O_osEz.mjs +79 -0
- package/dist/access-DT1f6l5k.mjs +51 -0
- package/dist/adapter-factory-BZ2Qiqpn.mjs +640 -0
- package/dist/adapters/drizzle-adapter/index.d.mts +47 -0
- package/dist/adapters/drizzle-adapter/index.mjs +208 -0
- package/dist/adapters/index.d.mts +132 -0
- package/dist/adapters/index.mjs +18 -0
- package/dist/adapters/kysely-adapter/index.d.mts +47 -0
- package/dist/adapters/kysely-adapter/index.mjs +11 -0
- package/dist/adapters/memory-adapter/index.d.mts +14 -0
- package/dist/adapters/memory-adapter/index.mjs +154 -0
- package/dist/adapters/mongodb-adapter/index.d.mts +35 -0
- package/dist/adapters/mongodb-adapter/index.mjs +315 -0
- package/dist/adapters/prisma-adapter/index.d.mts +34 -0
- package/dist/adapters/prisma-adapter/index.mjs +159 -0
- package/dist/adapters/test.d.mts +81 -0
- package/dist/adapters/test.mjs +793 -0
- package/dist/admin-Bcq53Nwj.mjs +743 -0
- package/dist/admin-DtfO1PLg.d.mts +1689 -0
- package/dist/anonymous-CRt1imBW.mjs +107 -0
- package/dist/api/index.d.mts +6 -0
- package/dist/api/index.mjs +17 -0
- package/dist/api-0pR_I-Nx.mjs +3139 -0
- package/dist/auth-CBUoBX6o.mjs +233 -0
- package/dist/bearer-Djf_awfo.mjs +63 -0
- package/dist/bun-sqlite-dialect-CeNvMaZz.mjs +155 -0
- package/dist/captcha-BqaMxlKC.mjs +178 -0
- package/dist/chunk-BK_LfMhE.mjs +40 -0
- package/dist/client/index.d.mts +186 -0
- package/dist/client/index.mjs +7 -0
- package/dist/client/plugins/index.d.mts +949 -0
- package/dist/client/plugins/index.mjs +539 -0
- package/dist/client/react/index.d.mts +179 -0
- package/dist/client/react/index.mjs +69 -0
- package/dist/client-BOX93C3d.d.mts +1250 -0
- package/dist/client-CNY0tn9g.d.mts +628 -0
- package/dist/client-CygJhqeB.mjs +29 -0
- package/dist/client-WiN43tAS.mjs +17 -0
- package/dist/client-aExCkfwm.mjs +30 -0
- package/dist/cookies/index.d.mts +7 -0
- package/dist/cookies/index.mjs +7 -0
- package/dist/cookies-cJObLwn1.mjs +597 -0
- package/dist/crypto/index.d.mts +44 -0
- package/dist/crypto/index.mjs +4 -0
- package/dist/crypto-Bb42eMrH.mjs +70 -0
- package/dist/custom-session-L3t7ecsd.mjs +67 -0
- package/dist/date-Cx2yCiC4.mjs +115 -0
- package/dist/db/index.d.mts +7 -0
- package/dist/db/index.mjs +15 -0
- package/dist/db-BrstmDhc.mjs +1124 -0
- package/dist/device-authorization-V4s3h4Mj.mjs +557 -0
- package/dist/dialect-CeddeGHf.mjs +72 -0
- package/dist/email-otp-BtDHSw14.mjs +592 -0
- package/dist/esm-C-QicDNz.mjs +4090 -0
- package/dist/generic-oauth-CL5X27ZI.mjs +445 -0
- package/dist/get-request-ip-DSjrEpGo.mjs +27 -0
- package/dist/get-tables-BQP7YW9c.mjs +249 -0
- package/dist/has-permission-BpAr7uCn.mjs +14 -0
- package/dist/haveibeenpwned-cMpJvmzI.mjs +43 -0
- package/dist/helper-tmxW3BHj.d.mts +21 -0
- package/dist/index-34ONrP8l.d.mts +503 -0
- package/dist/index-65G5U5DB-DSdjzreF.d.mts +2543 -0
- package/dist/index-B-XKqFvY.d.mts +30 -0
- package/dist/index-B3n8e37d.d.mts +165 -0
- package/dist/index-BBm8nQ9Q.d.mts +42 -0
- package/dist/index-BHoQlf7a.d.mts +7699 -0
- package/dist/index-BYMI9r_d.d.mts +257 -0
- package/dist/index-BqhKCbPH.d.mts +36 -0
- package/dist/index-Buhn3hkR.d.mts +433 -0
- package/dist/index-C-u1h_WX.d.mts +174 -0
- package/dist/index-C7fQuk-V.d.mts +41 -0
- package/dist/index-CM-CFWwr.d.mts +1919 -0
- package/dist/index-CuFzhoS6.d.mts +359 -0
- package/dist/index-Cxi7TbLE.d.mts +11347 -0
- package/dist/index-DB7t8whN.d.mts +1 -0
- package/dist/index-DKNNV1kb.d.mts +626 -0
- package/dist/index-DR0xXno9.d.mts +113 -0
- package/dist/index-D_k662QG.d.mts +833 -0
- package/dist/index-DaBcikv9.d.mts +118 -0
- package/dist/index-DlaMq1nb.d.mts +955 -0
- package/dist/index-DoXZYQpq.d.mts +290 -0
- package/dist/index-G6V0Z_Mn.d.mts +125 -0
- package/dist/index-z0KSvE5i.d.mts +246 -0
- package/dist/index-zjjNBRY2.d.mts +95 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +33 -0
- package/dist/integrations/next-js.d.mts +21 -0
- package/dist/integrations/next-js.mjs +62 -0
- package/dist/integrations/node.d.mts +15 -0
- package/dist/integrations/node.mjs +15 -0
- package/dist/integrations/react-start.d.mts +15 -0
- package/dist/integrations/react-start.mjs +46 -0
- package/dist/json-D0TBLy4q.mjs +24 -0
- package/dist/jwt-CmxZAGe2.mjs +94 -0
- package/dist/jwt-lHV4QHpD.mjs +387 -0
- package/dist/kysely-adapter-DpzYO8Yf.mjs +181 -0
- package/dist/magic-link-Bk-ueorR.mjs +176 -0
- package/dist/misc-beA1w3XV.mjs +7 -0
- package/dist/multi-session-DRrLKrg9.mjs +144 -0
- package/dist/node-sqlite-dialect-BcKxBQnm.mjs +155 -0
- package/dist/oauth-proxy-D1sWh9B_.mjs +133 -0
- package/dist/oauth2/index.d.mts +60 -0
- package/dist/oauth2/index.mjs +19 -0
- package/dist/one-tap-DMswkTEc.mjs +113 -0
- package/dist/organization-BArHO_5v.mjs +3857 -0
- package/dist/parser-DcrIEuXE.mjs +73 -0
- package/dist/passkey-CcD4CnhM.mjs +558 -0
- package/dist/password-sVC4nePO.mjs +25 -0
- package/dist/permission-DLYUF3cW.mjs +15 -0
- package/dist/phone-number-rHDIlh-2.mjs +485 -0
- package/dist/plugin-helper-4L-lzsjZ.mjs +16 -0
- package/dist/plugins/access/index.d.mts +3 -0
- package/dist/plugins/access/index.mjs +3 -0
- package/dist/plugins/admin/access/index.d.mts +116 -0
- package/dist/plugins/admin/access/index.mjs +4 -0
- package/dist/plugins/admin/index.d.mts +9 -0
- package/dist/plugins/admin/index.mjs +22 -0
- package/dist/plugins/anonymous/index.d.mts +7 -0
- package/dist/plugins/anonymous/index.mjs +18 -0
- package/dist/plugins/bearer/index.d.mts +2 -0
- package/dist/plugins/bearer/index.mjs +8 -0
- package/dist/plugins/captcha/index.d.mts +2 -0
- package/dist/plugins/captcha/index.mjs +4 -0
- package/dist/plugins/custom-session/index.d.mts +7 -0
- package/dist/plugins/custom-session/index.mjs +19 -0
- package/dist/plugins/device-authorization/index.d.mts +4 -0
- package/dist/plugins/device-authorization/index.mjs +18 -0
- package/dist/plugins/email-otp/index.d.mts +3 -0
- package/dist/plugins/email-otp/index.mjs +19 -0
- package/dist/plugins/generic-oauth/index.d.mts +7 -0
- package/dist/plugins/generic-oauth/index.mjs +18 -0
- package/dist/plugins/haveibeenpwned/index.d.mts +2 -0
- package/dist/plugins/haveibeenpwned/index.mjs +18 -0
- package/dist/plugins/index.d.mts +139 -0
- package/dist/plugins/index.mjs +47 -0
- package/dist/plugins/jwt/index.d.mts +7 -0
- package/dist/plugins/jwt/index.mjs +18 -0
- package/dist/plugins/magic-link/index.d.mts +2 -0
- package/dist/plugins/magic-link/index.mjs +18 -0
- package/dist/plugins/multi-session/index.d.mts +3 -0
- package/dist/plugins/multi-session/index.mjs +18 -0
- package/dist/plugins/oauth-proxy/index.d.mts +2 -0
- package/dist/plugins/oauth-proxy/index.mjs +18 -0
- package/dist/plugins/one-tap/index.d.mts +2 -0
- package/dist/plugins/one-tap/index.mjs +18 -0
- package/dist/plugins/one-time-token/index.d.mts +7 -0
- package/dist/plugins/one-time-token/index.mjs +47 -0
- package/dist/plugins/organization/access/index.d.mts +4 -0
- package/dist/plugins/organization/access/index.mjs +4 -0
- package/dist/plugins/organization/index.d.mts +9 -0
- package/dist/plugins/organization/index.mjs +22 -0
- package/dist/plugins/passkey/index.d.mts +7 -0
- package/dist/plugins/passkey/index.mjs +18 -0
- package/dist/plugins/phone-number/index.d.mts +7 -0
- package/dist/plugins/phone-number/index.mjs +18 -0
- package/dist/plugins/two-factor/index.d.mts +7 -0
- package/dist/plugins/two-factor/index.mjs +20 -0
- package/dist/plugins/username/index.d.mts +4 -0
- package/dist/plugins/username/index.mjs +18 -0
- package/dist/plugins-3jfNste3.mjs +1544 -0
- package/dist/plugins-hFZT3hmK.d.mts +14 -0
- package/dist/promise-8rrEHRXd.mjs +23154 -0
- package/dist/proxy-CL9PZXJA.mjs +441 -0
- package/dist/session-Dgp133Yt.mjs +413 -0
- package/dist/social-providers/index.d.mts +1 -0
- package/dist/social-providers/index.mjs +3 -0
- package/dist/src/adapters/adapter-factory/index.d.ts +10 -0
- package/dist/src/adapters/adapter-factory/types.d.ts +124 -0
- package/dist/src/adapters/create-test-suite.d.ts +97 -0
- package/dist/src/adapters/drizzle-adapter/drizzle-adapter.d.ts +43 -0
- package/dist/src/adapters/drizzle-adapter/index.d.ts +1 -0
- package/dist/src/adapters/drizzle-adapter/test/generate-schema.d.ts +12 -0
- package/dist/src/adapters/index.d.ts +21 -0
- package/dist/src/adapters/kysely-adapter/bun-sqlite-dialect.d.ts +58 -0
- package/dist/src/adapters/kysely-adapter/dialect.d.ts +13 -0
- package/dist/src/adapters/kysely-adapter/index.d.ts +3 -0
- package/dist/src/adapters/kysely-adapter/kysely-adapter.d.ts +32 -0
- package/dist/src/adapters/kysely-adapter/node-sqlite-dialect.d.ts +58 -0
- package/dist/src/adapters/kysely-adapter/types.d.ts +1 -0
- package/dist/src/adapters/memory-adapter/index.d.ts +1 -0
- package/dist/src/adapters/memory-adapter/memory-adapter.d.ts +9 -0
- package/dist/src/adapters/mongodb-adapter/index.d.ts +1 -0
- package/dist/src/adapters/mongodb-adapter/mongodb-adapter.d.ts +31 -0
- package/dist/src/adapters/prisma-adapter/index.d.ts +1 -0
- package/dist/src/adapters/prisma-adapter/prisma-adapter.d.ts +32 -0
- package/dist/src/adapters/prisma-adapter/test/auth.d.ts +3 -0
- package/dist/src/adapters/prisma-adapter/test/generate-auth-config.d.ts +2 -0
- package/dist/src/adapters/prisma-adapter/test/generate-prisma-schema.d.ts +3 -0
- package/dist/src/adapters/prisma-adapter/test/get-prisma-client.d.ts +7 -0
- package/dist/src/adapters/prisma-adapter/test/push-prisma-schema.d.ts +1 -0
- package/dist/src/adapters/test-adapter.d.ts +61 -0
- package/dist/src/adapters/test.d.ts +78 -0
- package/dist/src/adapters/tests/auth-flow.d.ts +22 -0
- package/dist/src/adapters/tests/index.d.ts +5 -0
- package/dist/src/adapters/tests/normal.d.ts +87 -0
- package/dist/src/adapters/tests/number-id.d.ts +17 -0
- package/dist/src/adapters/tests/performance.d.ts +24 -0
- package/dist/src/adapters/tests/transactions.d.ts +20 -0
- package/dist/src/adapters/utils.d.ts +3 -0
- package/dist/src/api/index.d.ts +7150 -0
- package/dist/src/api/middlewares/index.d.ts +2 -0
- package/dist/src/api/middlewares/oauth.d.ts +15 -0
- package/dist/src/api/middlewares/origin-check.d.ts +8 -0
- package/dist/src/api/rate-limiter/index.d.ts +13 -0
- package/dist/src/api/routes/account.d.ts +623 -0
- package/dist/src/api/routes/callback.d.ts +68 -0
- package/dist/src/api/routes/email-verification.d.ts +266 -0
- package/dist/src/api/routes/error.d.ts +51 -0
- package/dist/src/api/routes/index.d.ts +11 -0
- package/dist/src/api/routes/ok.d.ts +61 -0
- package/dist/src/api/routes/reset-password.d.ts +203 -0
- package/dist/src/api/routes/session.d.ts +586 -0
- package/dist/src/api/routes/sign-in.d.ts +298 -0
- package/dist/src/api/routes/sign-out.d.ts +59 -0
- package/dist/src/api/routes/sign-up.d.ts +625 -0
- package/dist/src/api/routes/update-user.d.ts +862 -0
- package/dist/src/api/to-auth-endpoints.d.ts +3 -0
- package/dist/src/auth.d.ts +25 -0
- package/dist/src/client/broadcast-channel.d.ts +12 -0
- package/dist/src/client/config.d.ts +85 -0
- package/dist/src/client/fetch-plugins.d.ts +14 -0
- package/dist/src/client/index.d.ts +15 -0
- package/dist/src/client/parser.d.ts +12 -0
- package/dist/src/client/path-to-object.d.ts +63 -0
- package/dist/src/client/plugins/index.d.ts +21 -0
- package/dist/src/client/plugins/infer-plugin.d.ts +11 -0
- package/dist/src/client/proxy.d.ts +8 -0
- package/dist/src/client/query.d.ts +16 -0
- package/dist/src/client/react/index.d.ts +130 -0
- package/dist/src/client/react/react-store.d.ts +43 -0
- package/dist/src/client/session-atom.d.ts +18 -0
- package/dist/src/client/session-refresh.d.ts +17 -0
- package/dist/src/client/test-plugin.d.ts +147 -0
- package/dist/src/client/types.d.ts +49 -0
- package/dist/src/client/vanilla.d.ts +124 -0
- package/dist/src/cookies/check-cookies.d.ts +4 -0
- package/dist/src/cookies/cookie-utils.d.ts +16 -0
- package/dist/src/cookies/index.d.ts +56 -0
- package/dist/src/cookies/session-store.d.ts +43 -0
- package/dist/src/crypto/buffer.d.ts +4 -0
- package/dist/src/crypto/index.d.ts +14 -0
- package/dist/src/crypto/jwt.d.ts +4 -0
- package/dist/src/crypto/password.d.ts +5 -0
- package/dist/src/crypto/random.d.ts +1 -0
- package/dist/src/db/field.d.ts +97 -0
- package/dist/src/db/get-migration.d.ts +18 -0
- package/dist/src/db/get-schema.d.ts +6 -0
- package/dist/src/db/get-tables.d.ts +3 -0
- package/dist/src/db/index.d.ts +10 -0
- package/dist/src/db/internal-adapter.d.ts +9 -0
- package/dist/src/db/schema.d.ts +76 -0
- package/dist/src/db/to-zod.d.ts +31 -0
- package/dist/src/db/utils.d.ts +6 -0
- package/dist/src/db/with-hooks.d.ts +27 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/init.d.ts +2 -0
- package/dist/src/integrations/next-js.d.ts +15 -0
- package/dist/src/integrations/node.d.ts +6 -0
- package/dist/src/integrations/react-start.d.ts +9 -0
- package/dist/src/oauth2/index.d.ts +4 -0
- package/dist/src/oauth2/link-account.d.ts +41 -0
- package/dist/src/oauth2/state.d.ts +21 -0
- package/dist/src/oauth2/utils.d.ts +3 -0
- package/dist/src/plugins/access/access.d.ts +25 -0
- package/dist/src/plugins/access/index.d.ts +2 -0
- package/dist/src/plugins/access/types.d.ts +14 -0
- package/dist/src/plugins/additional-fields/client.d.ts +91 -0
- package/dist/src/plugins/admin/access/index.d.ts +1 -0
- package/dist/src/plugins/admin/access/statement.d.ts +110 -0
- package/dist/src/plugins/admin/admin.d.ts +1570 -0
- package/dist/src/plugins/admin/client.d.ts +62 -0
- package/dist/src/plugins/admin/error-codes.d.ts +21 -0
- package/dist/src/plugins/admin/has-permission.d.ts +21 -0
- package/dist/src/plugins/admin/index.d.ts +2 -0
- package/dist/src/plugins/admin/schema.d.ts +36 -0
- package/dist/src/plugins/admin/types.d.ts +77 -0
- package/dist/src/plugins/anonymous/client.d.ts +8 -0
- package/dist/src/plugins/anonymous/index.d.ts +159 -0
- package/dist/src/plugins/api-key/client.d.ts +11 -0
- package/dist/src/plugins/api-key/index.d.ts +1431 -0
- package/dist/src/plugins/api-key/rate-limit.d.ts +20 -0
- package/dist/src/plugins/api-key/routes/create-api-key.d.ts +244 -0
- package/dist/src/plugins/api-key/routes/delete-all-expired-api-keys.d.ts +45 -0
- package/dist/src/plugins/api-key/routes/delete-api-key.d.ts +112 -0
- package/dist/src/plugins/api-key/routes/get-api-key.d.ts +234 -0
- package/dist/src/plugins/api-key/routes/index.d.ts +1136 -0
- package/dist/src/plugins/api-key/routes/list-api-keys.d.ts +231 -0
- package/dist/src/plugins/api-key/routes/update-api-key.d.ts +235 -0
- package/dist/src/plugins/api-key/routes/verify-api-key.d.ts +80 -0
- package/dist/src/plugins/api-key/schema.d.ts +188 -0
- package/dist/src/plugins/api-key/types.d.ts +285 -0
- package/dist/src/plugins/bearer/index.d.ts +31 -0
- package/dist/src/plugins/captcha/constants.d.ts +9 -0
- package/dist/src/plugins/captcha/error-codes.d.ts +9 -0
- package/dist/src/plugins/captcha/index.d.ts +7 -0
- package/dist/src/plugins/captcha/types.d.ts +23 -0
- package/dist/src/plugins/captcha/utils.d.ts +1 -0
- package/dist/src/plugins/captcha/verify-handlers/captchafox.d.ts +11 -0
- package/dist/src/plugins/captcha/verify-handlers/cloudflare-turnstile.d.ts +10 -0
- package/dist/src/plugins/captcha/verify-handlers/google-recaptcha.d.ts +11 -0
- package/dist/src/plugins/captcha/verify-handlers/h-captcha.d.ts +11 -0
- package/dist/src/plugins/captcha/verify-handlers/index.d.ts +4 -0
- package/dist/src/plugins/custom-session/client.d.ts +12 -0
- package/dist/src/plugins/custom-session/index.d.ts +89 -0
- package/dist/src/plugins/device-authorization/client.d.ts +12 -0
- package/dist/src/plugins/device-authorization/index.d.ts +568 -0
- package/dist/src/plugins/device-authorization/schema.d.ts +56 -0
- package/dist/src/plugins/email-otp/client.d.ts +9 -0
- package/dist/src/plugins/email-otp/index.d.ts +826 -0
- package/dist/src/plugins/email-otp/utils.d.ts +2 -0
- package/dist/src/plugins/generic-oauth/client.d.ts +5 -0
- package/dist/src/plugins/generic-oauth/index.d.ts +428 -0
- package/dist/src/plugins/haveibeenpwned/index.d.ts +25 -0
- package/dist/src/plugins/index.d.ts +28 -0
- package/dist/src/plugins/jwt/adapter.d.ts +8 -0
- package/dist/src/plugins/jwt/client.d.ts +5 -0
- package/dist/src/plugins/jwt/index.d.ts +276 -0
- package/dist/src/plugins/jwt/schema.d.ts +18 -0
- package/dist/src/plugins/jwt/sign.d.ts +8 -0
- package/dist/src/plugins/jwt/types.d.ts +175 -0
- package/dist/src/plugins/jwt/utils.d.ts +46 -0
- package/dist/src/plugins/last-login-method/client.d.ts +34 -0
- package/dist/src/plugins/last-login-method/index.d.ts +103 -0
- package/dist/src/plugins/magic-link/client.d.ts +5 -0
- package/dist/src/plugins/magic-link/index.d.ts +253 -0
- package/dist/src/plugins/magic-link/utils.d.ts +1 -0
- package/dist/src/plugins/multi-session/client.d.ts +9 -0
- package/dist/src/plugins/multi-session/index.d.ts +284 -0
- package/dist/src/plugins/oauth-proxy/index.d.ts +119 -0
- package/dist/src/plugins/one-tap/client.d.ts +81 -0
- package/dist/src/plugins/one-tap/index.d.ts +114 -0
- package/dist/src/plugins/one-time-token/client.d.ts +5 -0
- package/dist/src/plugins/one-time-token/index.d.ts +170 -0
- package/dist/src/plugins/one-time-token/utils.d.ts +1 -0
- package/dist/src/plugins/organization/access/index.d.ts +1 -0
- package/dist/src/plugins/organization/access/statement.d.ts +241 -0
- package/dist/src/plugins/organization/adapter.d.ts +685 -0
- package/dist/src/plugins/organization/call.d.ts +55 -0
- package/dist/src/plugins/organization/client.d.ts +344 -0
- package/dist/src/plugins/organization/error-codes.d.ts +58 -0
- package/dist/src/plugins/organization/has-permission.d.ts +13 -0
- package/dist/src/plugins/organization/index.d.ts +4 -0
- package/dist/src/plugins/organization/organization.d.ts +412 -0
- package/dist/src/plugins/organization/permission.d.ts +27 -0
- package/dist/src/plugins/organization/routes/crud-access-control.d.ts +701 -0
- package/dist/src/plugins/organization/routes/crud-invites.d.ts +1522 -0
- package/dist/src/plugins/organization/routes/crud-members.d.ts +1220 -0
- package/dist/src/plugins/organization/routes/crud-org.d.ts +1399 -0
- package/dist/src/plugins/organization/routes/crud-team.d.ts +1323 -0
- package/dist/src/plugins/organization/schema.d.ts +366 -0
- package/dist/src/plugins/organization/types.d.ts +737 -0
- package/dist/src/plugins/passkey/client.d.ts +190 -0
- package/dist/src/plugins/passkey/error-codes.d.ts +9 -0
- package/dist/src/plugins/passkey/index.d.ts +838 -0
- package/dist/src/plugins/passkey/schema.d.ts +50 -0
- package/dist/src/plugins/passkey/types.d.ts +69 -0
- package/dist/src/plugins/passkey/utils.d.ts +2 -0
- package/dist/src/plugins/phone-number/client.d.ts +9 -0
- package/dist/src/plugins/phone-number/index.d.ts +622 -0
- package/dist/src/plugins/phone-number/phone-number-error.d.ts +10 -0
- package/dist/src/plugins/two-factor/backup-codes/index.d.ts +387 -0
- package/dist/src/plugins/two-factor/client.d.ts +28 -0
- package/dist/src/plugins/two-factor/constant.d.ts +2 -0
- package/dist/src/plugins/two-factor/error-code.d.ts +11 -0
- package/dist/src/plugins/two-factor/index.d.ts +1014 -0
- package/dist/src/plugins/two-factor/otp/index.d.ts +282 -0
- package/dist/src/plugins/two-factor/schema.d.ts +35 -0
- package/dist/src/plugins/two-factor/totp/index.d.ts +298 -0
- package/dist/src/plugins/two-factor/types.d.ts +50 -0
- package/dist/src/plugins/two-factor/utils.d.ts +1 -0
- package/dist/src/plugins/two-factor/verify-two-factor.d.ts +59 -0
- package/dist/src/plugins/username/client.d.ts +5 -0
- package/dist/src/plugins/username/error-codes.d.ts +10 -0
- package/dist/src/plugins/username/index.d.ts +313 -0
- package/dist/src/plugins/username/schema.d.ts +27 -0
- package/dist/src/social-providers/index.d.ts +1 -0
- package/dist/src/test-utils/headers.d.ts +5 -0
- package/dist/src/test-utils/index.d.ts +2 -0
- package/dist/src/test-utils/test-instance.d.ts +17849 -0
- package/dist/src/types/adapter.d.ts +21 -0
- package/dist/src/types/api.d.ts +29 -0
- package/dist/src/types/helper.d.ts +32 -0
- package/dist/src/types/index.d.ts +7 -0
- package/dist/src/types/models.d.ts +13 -0
- package/dist/src/types/plugins.d.ts +14 -0
- package/dist/src/utils/await-object.d.ts +3 -0
- package/dist/src/utils/boolean.d.ts +1 -0
- package/dist/src/utils/clone.d.ts +1 -0
- package/dist/src/utils/constants.d.ts +1 -0
- package/dist/src/utils/date.d.ts +1 -0
- package/dist/src/utils/ensure-utc.d.ts +1 -0
- package/dist/src/utils/get-request-ip.d.ts +2 -0
- package/dist/src/utils/hashing.d.ts +6 -0
- package/dist/src/utils/hide-metadata.d.ts +3 -0
- package/dist/src/utils/id.d.ts +1 -0
- package/dist/src/utils/import-util.d.ts +1 -0
- package/dist/src/utils/index.d.ts +5 -0
- package/dist/src/utils/is-atom.d.ts +2 -0
- package/dist/src/utils/is-promise.d.ts +1 -0
- package/dist/src/utils/json.d.ts +1 -0
- package/dist/src/utils/merger.d.ts +1 -0
- package/dist/src/utils/middleware-response.d.ts +8 -0
- package/dist/src/utils/misc.d.ts +1 -0
- package/dist/src/utils/password.d.ts +6 -0
- package/dist/src/utils/plugin-helper.d.ts +5 -0
- package/dist/src/utils/shim.d.ts +3 -0
- package/dist/src/utils/time.d.ts +4 -0
- package/dist/src/utils/url.d.ts +4 -0
- package/dist/src/utils/wildcard.d.ts +45 -0
- package/dist/test-utils/index.d.mts +17870 -0
- package/dist/test-utils/index.mjs +272 -0
- package/dist/two-factor-ClUXxom2.mjs +914 -0
- package/dist/types/index.d.mts +6 -0
- package/dist/types/index.mjs +3 -0
- package/dist/types-B1OL7hyf.d.mts +4 -0
- package/dist/types-Bjn15Uy6.mjs +1 -0
- package/dist/url-VB2gAbTI.mjs +59 -0
- package/dist/username-DiGklOGl.mjs +278 -0
- package/dist/utils-SOMB4Px5.mjs +132 -0
- package/package.json +447 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import type { JSONWebKeySet, JWTPayload } from "jose";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { getJwtToken } from "./sign";
|
|
4
|
+
import type { JwtOptions } from "./types";
|
|
5
|
+
export type * from "./types";
|
|
6
|
+
export { createJwk, generateExportedKeyPair } from "./utils";
|
|
7
|
+
export declare const jwt: (options?: JwtOptions | undefined) => {
|
|
8
|
+
id: "jwt";
|
|
9
|
+
options: JwtOptions | undefined;
|
|
10
|
+
endpoints: {
|
|
11
|
+
getJwks: {
|
|
12
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0?: ({
|
|
13
|
+
body?: undefined;
|
|
14
|
+
} & {
|
|
15
|
+
method?: "GET" | undefined;
|
|
16
|
+
} & {
|
|
17
|
+
query?: Record<string, any> | undefined;
|
|
18
|
+
} & {
|
|
19
|
+
params?: Record<string, any>;
|
|
20
|
+
} & {
|
|
21
|
+
request?: Request;
|
|
22
|
+
} & {
|
|
23
|
+
headers?: HeadersInit;
|
|
24
|
+
} & {
|
|
25
|
+
asResponse?: boolean;
|
|
26
|
+
returnHeaders?: boolean;
|
|
27
|
+
use?: import("better-call").Middleware[];
|
|
28
|
+
path?: string;
|
|
29
|
+
} & {
|
|
30
|
+
asResponse?: AsResponse | undefined;
|
|
31
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
32
|
+
}) | undefined): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
|
|
33
|
+
headers: Headers;
|
|
34
|
+
response: JSONWebKeySet;
|
|
35
|
+
} : JSONWebKeySet>;
|
|
36
|
+
options: {
|
|
37
|
+
method: "GET";
|
|
38
|
+
metadata: {
|
|
39
|
+
openapi: {
|
|
40
|
+
description: string;
|
|
41
|
+
responses: {
|
|
42
|
+
"200": {
|
|
43
|
+
description: string;
|
|
44
|
+
content: {
|
|
45
|
+
"application/json": {
|
|
46
|
+
schema: {
|
|
47
|
+
type: "object";
|
|
48
|
+
properties: {
|
|
49
|
+
keys: {
|
|
50
|
+
type: string;
|
|
51
|
+
description: string;
|
|
52
|
+
items: {
|
|
53
|
+
type: string;
|
|
54
|
+
properties: {
|
|
55
|
+
kid: {
|
|
56
|
+
type: string;
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
kty: {
|
|
60
|
+
type: string;
|
|
61
|
+
description: string;
|
|
62
|
+
};
|
|
63
|
+
alg: {
|
|
64
|
+
type: string;
|
|
65
|
+
description: string;
|
|
66
|
+
};
|
|
67
|
+
use: {
|
|
68
|
+
type: string;
|
|
69
|
+
description: string;
|
|
70
|
+
enum: string[];
|
|
71
|
+
nullable: boolean;
|
|
72
|
+
};
|
|
73
|
+
n: {
|
|
74
|
+
type: string;
|
|
75
|
+
description: string;
|
|
76
|
+
nullable: boolean;
|
|
77
|
+
};
|
|
78
|
+
e: {
|
|
79
|
+
type: string;
|
|
80
|
+
description: string;
|
|
81
|
+
nullable: boolean;
|
|
82
|
+
};
|
|
83
|
+
crv: {
|
|
84
|
+
type: string;
|
|
85
|
+
description: string;
|
|
86
|
+
nullable: boolean;
|
|
87
|
+
};
|
|
88
|
+
x: {
|
|
89
|
+
type: string;
|
|
90
|
+
description: string;
|
|
91
|
+
nullable: boolean;
|
|
92
|
+
};
|
|
93
|
+
y: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
nullable: boolean;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
required: string[];
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
required: string[];
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
} & {
|
|
112
|
+
use: any[];
|
|
113
|
+
};
|
|
114
|
+
path: "/jwks";
|
|
115
|
+
};
|
|
116
|
+
getToken: {
|
|
117
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
|
|
118
|
+
body?: undefined;
|
|
119
|
+
} & {
|
|
120
|
+
method?: "GET" | undefined;
|
|
121
|
+
} & {
|
|
122
|
+
query?: Record<string, any> | undefined;
|
|
123
|
+
} & {
|
|
124
|
+
params?: Record<string, any>;
|
|
125
|
+
} & {
|
|
126
|
+
request?: Request;
|
|
127
|
+
} & {
|
|
128
|
+
headers: HeadersInit;
|
|
129
|
+
} & {
|
|
130
|
+
asResponse?: boolean;
|
|
131
|
+
returnHeaders?: boolean;
|
|
132
|
+
use?: import("better-call").Middleware[];
|
|
133
|
+
path?: string;
|
|
134
|
+
} & {
|
|
135
|
+
asResponse?: AsResponse | undefined;
|
|
136
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
137
|
+
}): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
|
|
138
|
+
headers: Headers;
|
|
139
|
+
response: {
|
|
140
|
+
token: string;
|
|
141
|
+
};
|
|
142
|
+
} : {
|
|
143
|
+
token: string;
|
|
144
|
+
}>;
|
|
145
|
+
options: {
|
|
146
|
+
method: "GET";
|
|
147
|
+
requireHeaders: true;
|
|
148
|
+
use: ((inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
149
|
+
session: {
|
|
150
|
+
session: Record<string, any> & {
|
|
151
|
+
id: string;
|
|
152
|
+
createdAt: Date;
|
|
153
|
+
updatedAt: Date;
|
|
154
|
+
userId: string;
|
|
155
|
+
expiresAt: Date;
|
|
156
|
+
token: string;
|
|
157
|
+
ipAddress?: string | null | undefined;
|
|
158
|
+
userAgent?: string | null | undefined;
|
|
159
|
+
};
|
|
160
|
+
user: Record<string, any> & {
|
|
161
|
+
id: string;
|
|
162
|
+
createdAt: Date;
|
|
163
|
+
updatedAt: Date;
|
|
164
|
+
email: string;
|
|
165
|
+
emailVerified: boolean;
|
|
166
|
+
name: string;
|
|
167
|
+
image?: string | null | undefined;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
}>)[];
|
|
171
|
+
metadata: {
|
|
172
|
+
openapi: {
|
|
173
|
+
description: string;
|
|
174
|
+
responses: {
|
|
175
|
+
200: {
|
|
176
|
+
description: string;
|
|
177
|
+
content: {
|
|
178
|
+
"application/json": {
|
|
179
|
+
schema: {
|
|
180
|
+
type: "object";
|
|
181
|
+
properties: {
|
|
182
|
+
token: {
|
|
183
|
+
type: string;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
} & {
|
|
194
|
+
use: any[];
|
|
195
|
+
};
|
|
196
|
+
path: "/token";
|
|
197
|
+
};
|
|
198
|
+
signJWT: {
|
|
199
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(inputCtx_0: {
|
|
200
|
+
body: {
|
|
201
|
+
payload: JWTPayload;
|
|
202
|
+
overrideOptions?: JwtOptions | undefined;
|
|
203
|
+
};
|
|
204
|
+
} & {
|
|
205
|
+
method?: "POST" | undefined;
|
|
206
|
+
} & {
|
|
207
|
+
query?: Record<string, any> | undefined;
|
|
208
|
+
} & {
|
|
209
|
+
params?: Record<string, any>;
|
|
210
|
+
} & {
|
|
211
|
+
request?: Request;
|
|
212
|
+
} & {
|
|
213
|
+
headers?: HeadersInit;
|
|
214
|
+
} & {
|
|
215
|
+
asResponse?: boolean;
|
|
216
|
+
returnHeaders?: boolean;
|
|
217
|
+
use?: import("better-call").Middleware[];
|
|
218
|
+
path?: string;
|
|
219
|
+
} & {
|
|
220
|
+
asResponse?: AsResponse | undefined;
|
|
221
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
222
|
+
}): Promise<[AsResponse] extends [true] ? Response : [ReturnHeaders] extends [true] ? {
|
|
223
|
+
headers: Headers;
|
|
224
|
+
response: {
|
|
225
|
+
token: string;
|
|
226
|
+
};
|
|
227
|
+
} : {
|
|
228
|
+
token: string;
|
|
229
|
+
}>;
|
|
230
|
+
options: {
|
|
231
|
+
method: "POST";
|
|
232
|
+
metadata: {
|
|
233
|
+
SERVER_ONLY: true;
|
|
234
|
+
$Infer: {
|
|
235
|
+
body: {
|
|
236
|
+
payload: JWTPayload;
|
|
237
|
+
overrideOptions?: JwtOptions | undefined;
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
body: z.ZodObject<{
|
|
242
|
+
payload: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
243
|
+
overrideOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
244
|
+
}, z.core.$strip>;
|
|
245
|
+
} & {
|
|
246
|
+
use: any[];
|
|
247
|
+
};
|
|
248
|
+
path: "/sign-jwt";
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
hooks: {
|
|
252
|
+
after: {
|
|
253
|
+
matcher(context: import("@gatwech/core").HookEndpointContext): boolean;
|
|
254
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
255
|
+
}[];
|
|
256
|
+
};
|
|
257
|
+
schema: {
|
|
258
|
+
jwks: {
|
|
259
|
+
fields: {
|
|
260
|
+
publicKey: {
|
|
261
|
+
type: "string";
|
|
262
|
+
required: true;
|
|
263
|
+
};
|
|
264
|
+
privateKey: {
|
|
265
|
+
type: "string";
|
|
266
|
+
required: true;
|
|
267
|
+
};
|
|
268
|
+
createdAt: {
|
|
269
|
+
type: "date";
|
|
270
|
+
required: true;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
export { getJwtToken };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GenericEndpointContext } from "@gatwech/core";
|
|
2
|
+
import { type JWTPayload } from "jose";
|
|
3
|
+
import type { JwtOptions } from "./types";
|
|
4
|
+
export declare function signJWT(ctx: GenericEndpointContext, config: {
|
|
5
|
+
options?: JwtOptions | undefined;
|
|
6
|
+
payload: JWTPayload;
|
|
7
|
+
}): Promise<string>;
|
|
8
|
+
export declare function getJwtToken(ctx: GenericEndpointContext, options?: JwtOptions | undefined): Promise<string>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type { JWTPayload } from "jose";
|
|
2
|
+
import type { GenericEndpointContext } from "../..";
|
|
3
|
+
import type { InferOptionSchema, Session, User } from "../../types";
|
|
4
|
+
import type { Awaitable } from "../../types/helper";
|
|
5
|
+
import type { schema } from "./schema";
|
|
6
|
+
export interface JwtOptions {
|
|
7
|
+
jwks?: {
|
|
8
|
+
/**
|
|
9
|
+
* Disables the /jwks endpoint and uses this endpoint in discovery.
|
|
10
|
+
*
|
|
11
|
+
* Useful if jwks are not managed at /jwks or
|
|
12
|
+
* if your jwks are signed with a certificate and placed on your CDN.
|
|
13
|
+
*/
|
|
14
|
+
remoteUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Key pair configuration
|
|
17
|
+
* @description A subset of the options available for the generateKeyPair function
|
|
18
|
+
*
|
|
19
|
+
* @see https://github.com/panva/jose/blob/main/src/runtime/node/generate.ts
|
|
20
|
+
*
|
|
21
|
+
* @default { alg: 'EdDSA', crv: 'Ed25519' }
|
|
22
|
+
*/
|
|
23
|
+
keyPairConfig?: JWKOptions;
|
|
24
|
+
/**
|
|
25
|
+
* Disable private key encryption
|
|
26
|
+
* @description Disable the encryption of the private key in the database
|
|
27
|
+
*
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
disablePrivateKeyEncryption?: boolean;
|
|
31
|
+
} | undefined;
|
|
32
|
+
jwt?: {
|
|
33
|
+
/**
|
|
34
|
+
* The issuer of the JWT
|
|
35
|
+
*/
|
|
36
|
+
issuer?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The audience of the JWT
|
|
39
|
+
*/
|
|
40
|
+
audience?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Set the "exp" (Expiration Time) Claim.
|
|
43
|
+
*
|
|
44
|
+
* - If a `number` is passed as an argument it is used as the claim directly.
|
|
45
|
+
* - If a `Date` instance is passed as an argument it is converted to unix timestamp and used as the
|
|
46
|
+
* claim.
|
|
47
|
+
* - If a `string` is passed as an argument it is resolved to a time span, and then added to the
|
|
48
|
+
* current unix timestamp and used as the claim.
|
|
49
|
+
*
|
|
50
|
+
* Format used for time span should be a number followed by a unit, such as "5 minutes" or "1
|
|
51
|
+
* day".
|
|
52
|
+
*
|
|
53
|
+
* Valid units are: "sec", "secs", "second", "seconds", "s", "minute", "minutes", "min", "mins",
|
|
54
|
+
* "m", "hour", "hours", "hr", "hrs", "h", "day", "days", "d", "week", "weeks", "w", "year",
|
|
55
|
+
* "years", "yr", "yrs", and "y". It is not possible to specify months. 365.25 days is used as an
|
|
56
|
+
* alias for a year.
|
|
57
|
+
*
|
|
58
|
+
* If the string is suffixed with "ago", or prefixed with a "-", the resulting time span gets
|
|
59
|
+
* subtracted from the current unix timestamp. A "from now" suffix can also be used for
|
|
60
|
+
* readability when adding to the current unix timestamp.
|
|
61
|
+
*
|
|
62
|
+
* @default 15m
|
|
63
|
+
*/
|
|
64
|
+
expirationTime?: number | string | Date;
|
|
65
|
+
/**
|
|
66
|
+
* A function that is called to define the payload of the JWT
|
|
67
|
+
*/
|
|
68
|
+
definePayload?: (session: {
|
|
69
|
+
user: User & Record<string, any>;
|
|
70
|
+
session: Session & Record<string, any>;
|
|
71
|
+
}) => Promise<Record<string, any>> | Record<string, any>;
|
|
72
|
+
/**
|
|
73
|
+
* A function that is called to get the subject of the JWT
|
|
74
|
+
*
|
|
75
|
+
* @default session.user.id
|
|
76
|
+
*/
|
|
77
|
+
getSubject?: (session: {
|
|
78
|
+
user: User & Record<string, any>;
|
|
79
|
+
session: Session & Record<string, any>;
|
|
80
|
+
}) => Promise<string> | string;
|
|
81
|
+
/**
|
|
82
|
+
* A custom function to remote sign the jwt payload.
|
|
83
|
+
*
|
|
84
|
+
* All headers, such as `alg` and `kid`,
|
|
85
|
+
* MUST be defined within this function.
|
|
86
|
+
* You can safely define the header `typ: 'JWT'`.
|
|
87
|
+
*
|
|
88
|
+
* @requires jwks.remoteUrl
|
|
89
|
+
* @invalidates other jwt.* options
|
|
90
|
+
*/
|
|
91
|
+
sign?: (payload: JWTPayload) => Awaitable<string>;
|
|
92
|
+
} | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Disables setting JWTs through middleware.
|
|
95
|
+
*
|
|
96
|
+
* Recommended to set `true` when using an oAuth provider plugin
|
|
97
|
+
* like OIDC or MCP where session payloads should not be signed.
|
|
98
|
+
*
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
disableSettingJwtHeader?: boolean | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Custom schema for the admin plugin
|
|
104
|
+
*/
|
|
105
|
+
schema?: InferOptionSchema<typeof schema> | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Custom adapter for the jwt plugin
|
|
108
|
+
*
|
|
109
|
+
* This will override the default adapter
|
|
110
|
+
*
|
|
111
|
+
* @default adapter from the database
|
|
112
|
+
*/
|
|
113
|
+
adapter?: {
|
|
114
|
+
/**
|
|
115
|
+
* A custom function to get the JWKS from the database or
|
|
116
|
+
* other source
|
|
117
|
+
*
|
|
118
|
+
* This will override the default getJwks from the database
|
|
119
|
+
*
|
|
120
|
+
* @param ctx - The context of the request
|
|
121
|
+
* @returns The JWKS
|
|
122
|
+
*/
|
|
123
|
+
getJwks?: (ctx: GenericEndpointContext) => Promise<Jwk[] | null | undefined>;
|
|
124
|
+
/**
|
|
125
|
+
* A custom function to get the latest key from the database or
|
|
126
|
+
* other source
|
|
127
|
+
*
|
|
128
|
+
* This will override the default getLatestKey from the database
|
|
129
|
+
*
|
|
130
|
+
* @param ctx - The context of the request
|
|
131
|
+
* @returns The latest key
|
|
132
|
+
*/
|
|
133
|
+
getLatestKey?: (ctx: GenericEndpointContext) => Promise<Jwk | null | undefined>;
|
|
134
|
+
/**
|
|
135
|
+
* A custom function to create a new key in the database or
|
|
136
|
+
* other source
|
|
137
|
+
*
|
|
138
|
+
* This will override the default createJwk from the database
|
|
139
|
+
*
|
|
140
|
+
* @param data - The key to create
|
|
141
|
+
* @returns The created key
|
|
142
|
+
*/
|
|
143
|
+
createJwk?: (data: Omit<Jwk, "id">, ctx: GenericEndpointContext) => Promise<Jwk>;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Asymmetric (JWS) Supported.
|
|
148
|
+
*
|
|
149
|
+
* @see https://github.com/panva/jose/issues/210
|
|
150
|
+
*/
|
|
151
|
+
export type JWKOptions = {
|
|
152
|
+
alg: "EdDSA";
|
|
153
|
+
crv?: "Ed25519" | undefined;
|
|
154
|
+
} | {
|
|
155
|
+
alg: "ES256";
|
|
156
|
+
crv?: never | undefined;
|
|
157
|
+
} | {
|
|
158
|
+
alg: "ES512";
|
|
159
|
+
crv?: never | undefined;
|
|
160
|
+
} | {
|
|
161
|
+
alg: "PS256";
|
|
162
|
+
modulusLength?: number | undefined;
|
|
163
|
+
} | {
|
|
164
|
+
alg: "RS256";
|
|
165
|
+
modulusLength?: number | undefined;
|
|
166
|
+
};
|
|
167
|
+
export type JWSAlgorithms = JWKOptions["alg"];
|
|
168
|
+
export interface Jwk {
|
|
169
|
+
id: string;
|
|
170
|
+
publicKey: string;
|
|
171
|
+
privateKey: string;
|
|
172
|
+
createdAt: Date;
|
|
173
|
+
alg?: JWSAlgorithms | undefined;
|
|
174
|
+
crv?: ("Ed25519" | "P-256" | "P-521") | undefined;
|
|
175
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GenericEndpointContext } from "@gatwech/core";
|
|
2
|
+
import type { Jwk, JwtOptions } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Converts an expirationTime to ISO seconds expiration time (the format of JWT exp)
|
|
5
|
+
*
|
|
6
|
+
* See https://github.com/panva/jose/blob/main/src/lib/jwt_claims_set.ts#L245
|
|
7
|
+
*
|
|
8
|
+
* @param expirationTime - see options.jwt.expirationTime
|
|
9
|
+
* @param iat - the iat time to consolidate on
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare function toExpJWT(expirationTime: number | Date | string, iat: number): number;
|
|
13
|
+
export declare function encryptPrivateKey(privateKey: string, secretKey: string): Promise<{
|
|
14
|
+
encryptedPrivateKey: string;
|
|
15
|
+
iv: string;
|
|
16
|
+
authTag: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function decryptPrivateKey(encryptedPrivate: {
|
|
19
|
+
encryptedPrivateKey: string;
|
|
20
|
+
iv: string;
|
|
21
|
+
authTag: string;
|
|
22
|
+
}, secretKey: string): Promise<string>;
|
|
23
|
+
export declare function generateExportedKeyPair(options?: JwtOptions | undefined): Promise<{
|
|
24
|
+
publicWebKey: import("jose").JWK;
|
|
25
|
+
privateWebKey: import("jose").JWK;
|
|
26
|
+
alg: "EdDSA" | "ES256" | "ES512" | "PS256" | "RS256";
|
|
27
|
+
cfg: {
|
|
28
|
+
crv?: "Ed25519" | undefined;
|
|
29
|
+
} | {
|
|
30
|
+
crv?: never | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
crv?: never | undefined;
|
|
33
|
+
} | {
|
|
34
|
+
modulusLength?: number | undefined;
|
|
35
|
+
} | {
|
|
36
|
+
modulusLength?: number | undefined;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a Jwk on the database
|
|
41
|
+
*
|
|
42
|
+
* @param ctx
|
|
43
|
+
* @param options
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
export declare function createJwk(ctx: GenericEndpointContext, options?: JwtOptions | undefined): Promise<Jwk>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for the client-side last login method plugin
|
|
3
|
+
*/
|
|
4
|
+
export interface LastLoginMethodClientConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Name of the cookie to read the last login method from
|
|
7
|
+
* @default "payvo-auth.last_used_login_method"
|
|
8
|
+
*/
|
|
9
|
+
cookieName?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Client-side plugin to retrieve the last used login method
|
|
13
|
+
*/
|
|
14
|
+
export declare const lastLoginMethodClient: (config?: LastLoginMethodClientConfig) => {
|
|
15
|
+
id: "last-login-method-client";
|
|
16
|
+
getActions(): {
|
|
17
|
+
/**
|
|
18
|
+
* Get the last used login method from cookies
|
|
19
|
+
* @returns The last used login method or null if not found
|
|
20
|
+
*/
|
|
21
|
+
getLastUsedLoginMethod: () => string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Clear the last used login method cookie
|
|
24
|
+
* This sets the cookie with an expiration date in the past
|
|
25
|
+
*/
|
|
26
|
+
clearLastUsedLoginMethod: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a specific login method was the last used
|
|
29
|
+
* @param method The method to check
|
|
30
|
+
* @returns True if the method was the last used, false otherwise
|
|
31
|
+
*/
|
|
32
|
+
isLastUsedLoginMethod: (method: string) => boolean;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { GenericEndpointContext } from "@gatwech/core";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for tracking different authentication methods
|
|
4
|
+
*/
|
|
5
|
+
export interface LastLoginMethodOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Name of the cookie to store the last login method
|
|
8
|
+
* @default "payvo-auth.last_used_login_method"
|
|
9
|
+
*/
|
|
10
|
+
cookieName?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Cookie expiration time in seconds
|
|
13
|
+
* @default 2592000 (30 days)
|
|
14
|
+
*/
|
|
15
|
+
maxAge?: number | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Custom method to resolve the last login method
|
|
18
|
+
* @param ctx - The context from the hook
|
|
19
|
+
* @returns The last login method
|
|
20
|
+
*/
|
|
21
|
+
customResolveMethod?: ((ctx: GenericEndpointContext) => string | null) | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Store the last login method in the database. This will create a new field in the user table.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
storeInDatabase?: boolean | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Custom schema for the plugin
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
schema?: {
|
|
32
|
+
user?: {
|
|
33
|
+
lastLoginMethod?: string;
|
|
34
|
+
};
|
|
35
|
+
} | undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Plugin to track the last used login method
|
|
39
|
+
*/
|
|
40
|
+
export declare const lastLoginMethod: <O extends LastLoginMethodOptions>(userConfig?: O | undefined) => {
|
|
41
|
+
id: "last-login-method";
|
|
42
|
+
init(ctx: import("@gatwech/core").AuthContext<import("@gatwech/core").PayvoAuthOptions>): {
|
|
43
|
+
options: {
|
|
44
|
+
databaseHooks: {
|
|
45
|
+
user: {
|
|
46
|
+
create: {
|
|
47
|
+
before(user: {
|
|
48
|
+
id: string;
|
|
49
|
+
createdAt: Date;
|
|
50
|
+
updatedAt: Date;
|
|
51
|
+
email: string;
|
|
52
|
+
emailVerified: boolean;
|
|
53
|
+
name: string;
|
|
54
|
+
image?: string | null | undefined;
|
|
55
|
+
} & Record<string, unknown>, context: GenericEndpointContext<import("@gatwech/core").PayvoAuthOptions> | undefined): Promise<{
|
|
56
|
+
data: {
|
|
57
|
+
lastLoginMethod: any;
|
|
58
|
+
id: string;
|
|
59
|
+
createdAt: Date;
|
|
60
|
+
updatedAt: Date;
|
|
61
|
+
email: string;
|
|
62
|
+
emailVerified: boolean;
|
|
63
|
+
name: string;
|
|
64
|
+
image?: string | null | undefined;
|
|
65
|
+
};
|
|
66
|
+
} | undefined>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
session: {
|
|
70
|
+
create: {
|
|
71
|
+
after(session: {
|
|
72
|
+
id: string;
|
|
73
|
+
createdAt: Date;
|
|
74
|
+
updatedAt: Date;
|
|
75
|
+
userId: string;
|
|
76
|
+
expiresAt: Date;
|
|
77
|
+
token: string;
|
|
78
|
+
ipAddress?: string | null | undefined;
|
|
79
|
+
userAgent?: string | null | undefined;
|
|
80
|
+
} & Record<string, unknown>, context: GenericEndpointContext<import("@gatwech/core").PayvoAuthOptions> | undefined): Promise<void>;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
hooks: {
|
|
87
|
+
after: {
|
|
88
|
+
matcher(): true;
|
|
89
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
90
|
+
}[];
|
|
91
|
+
};
|
|
92
|
+
schema: O["storeInDatabase"] extends true ? {
|
|
93
|
+
user: {
|
|
94
|
+
fields: {
|
|
95
|
+
lastLoginMethod: {
|
|
96
|
+
type: "string";
|
|
97
|
+
required: false;
|
|
98
|
+
input: false;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
} : undefined;
|
|
103
|
+
};
|