@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,188 @@
|
|
|
1
|
+
export declare const apiKeySchema: ({ timeWindow, rateLimitMax, }: {
|
|
2
|
+
timeWindow: number;
|
|
3
|
+
rateLimitMax: number;
|
|
4
|
+
}) => {
|
|
5
|
+
apikey: {
|
|
6
|
+
fields: {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the key.
|
|
9
|
+
*/
|
|
10
|
+
name: {
|
|
11
|
+
type: "string";
|
|
12
|
+
required: false;
|
|
13
|
+
input: false;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Shows the first few characters of the API key
|
|
17
|
+
* This allows you to show those few characters in the UI to make it easier for users to identify the API key.
|
|
18
|
+
*/
|
|
19
|
+
start: {
|
|
20
|
+
type: "string";
|
|
21
|
+
required: false;
|
|
22
|
+
input: false;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The prefix of the key.
|
|
26
|
+
*/
|
|
27
|
+
prefix: {
|
|
28
|
+
type: "string";
|
|
29
|
+
required: false;
|
|
30
|
+
input: false;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The hashed key value.
|
|
34
|
+
*/
|
|
35
|
+
key: {
|
|
36
|
+
type: "string";
|
|
37
|
+
required: true;
|
|
38
|
+
input: false;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The user id of the user who created the key.
|
|
42
|
+
*/
|
|
43
|
+
userId: {
|
|
44
|
+
type: "string";
|
|
45
|
+
references: {
|
|
46
|
+
model: string;
|
|
47
|
+
field: string;
|
|
48
|
+
onDelete: "cascade";
|
|
49
|
+
};
|
|
50
|
+
required: true;
|
|
51
|
+
input: false;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The interval to refill the key in milliseconds.
|
|
55
|
+
*/
|
|
56
|
+
refillInterval: {
|
|
57
|
+
type: "number";
|
|
58
|
+
required: false;
|
|
59
|
+
input: false;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* The amount to refill the remaining count of the key.
|
|
63
|
+
*/
|
|
64
|
+
refillAmount: {
|
|
65
|
+
type: "number";
|
|
66
|
+
required: false;
|
|
67
|
+
input: false;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The date and time when the key was last refilled.
|
|
71
|
+
*/
|
|
72
|
+
lastRefillAt: {
|
|
73
|
+
type: "date";
|
|
74
|
+
required: false;
|
|
75
|
+
input: false;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Whether the key is enabled.
|
|
79
|
+
*/
|
|
80
|
+
enabled: {
|
|
81
|
+
type: "boolean";
|
|
82
|
+
required: false;
|
|
83
|
+
input: false;
|
|
84
|
+
defaultValue: true;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Whether the key has rate limiting enabled.
|
|
88
|
+
*/
|
|
89
|
+
rateLimitEnabled: {
|
|
90
|
+
type: "boolean";
|
|
91
|
+
required: false;
|
|
92
|
+
input: false;
|
|
93
|
+
defaultValue: true;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The time window in milliseconds for the rate limit.
|
|
97
|
+
*/
|
|
98
|
+
rateLimitTimeWindow: {
|
|
99
|
+
type: "number";
|
|
100
|
+
required: false;
|
|
101
|
+
input: false;
|
|
102
|
+
defaultValue: number;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* The maximum number of requests allowed within the `rateLimitTimeWindow`.
|
|
106
|
+
*/
|
|
107
|
+
rateLimitMax: {
|
|
108
|
+
type: "number";
|
|
109
|
+
required: false;
|
|
110
|
+
input: false;
|
|
111
|
+
defaultValue: number;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* The number of requests made within the rate limit time window
|
|
115
|
+
*/
|
|
116
|
+
requestCount: {
|
|
117
|
+
type: "number";
|
|
118
|
+
required: false;
|
|
119
|
+
input: false;
|
|
120
|
+
defaultValue: number;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* The remaining number of requests before the key is revoked.
|
|
124
|
+
*
|
|
125
|
+
* If this is null, then the key is not revoked.
|
|
126
|
+
*
|
|
127
|
+
* If `refillInterval` & `refillAmount` are provided, than this will refill accordingly.
|
|
128
|
+
*/
|
|
129
|
+
remaining: {
|
|
130
|
+
type: "number";
|
|
131
|
+
required: false;
|
|
132
|
+
input: false;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* The date and time of the last request made to the key.
|
|
136
|
+
*/
|
|
137
|
+
lastRequest: {
|
|
138
|
+
type: "date";
|
|
139
|
+
required: false;
|
|
140
|
+
input: false;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* The date and time when the key will expire.
|
|
144
|
+
*/
|
|
145
|
+
expiresAt: {
|
|
146
|
+
type: "date";
|
|
147
|
+
required: false;
|
|
148
|
+
input: false;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* The date and time when the key was created.
|
|
152
|
+
*/
|
|
153
|
+
createdAt: {
|
|
154
|
+
type: "date";
|
|
155
|
+
required: true;
|
|
156
|
+
input: false;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* The date and time when the key was last updated.
|
|
160
|
+
*/
|
|
161
|
+
updatedAt: {
|
|
162
|
+
type: "date";
|
|
163
|
+
required: true;
|
|
164
|
+
input: false;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* The permissions of the key.
|
|
168
|
+
*/
|
|
169
|
+
permissions: {
|
|
170
|
+
type: "string";
|
|
171
|
+
required: false;
|
|
172
|
+
input: false;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Any additional metadata you want to store with the key.
|
|
176
|
+
*/
|
|
177
|
+
metadata: {
|
|
178
|
+
type: "string";
|
|
179
|
+
required: false;
|
|
180
|
+
input: true;
|
|
181
|
+
transform: {
|
|
182
|
+
input(value: import("@gatwech/core/db").DBPrimitive): string;
|
|
183
|
+
output(value: import("@gatwech/core/db").DBPrimitive): any;
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
};
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import type { GenericEndpointContext, HookEndpointContext } from "@gatwech/core";
|
|
2
|
+
import type { InferOptionSchema } from "../../types";
|
|
3
|
+
import type { Statements } from "../access";
|
|
4
|
+
import type { apiKeySchema } from "./schema";
|
|
5
|
+
export interface ApiKeyOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The header name to check for API key
|
|
8
|
+
* @default "x-api-key"
|
|
9
|
+
*/
|
|
10
|
+
apiKeyHeaders?: (string | string[]) | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Disable hashing of the API key.
|
|
13
|
+
*
|
|
14
|
+
* ⚠️ Security Warning: It's strongly recommended to not disable hashing.
|
|
15
|
+
* Storing API keys in plaintext makes them vulnerable to database breaches, potentially exposing all your users' API keys.
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
disableKeyHashing?: boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The function to get the API key from the context
|
|
22
|
+
*/
|
|
23
|
+
customAPIKeyGetter?: ((ctx: HookEndpointContext) => string | null) | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* A custom function to validate the API key
|
|
26
|
+
*/
|
|
27
|
+
customAPIKeyValidator?: ((options: {
|
|
28
|
+
ctx: GenericEndpointContext;
|
|
29
|
+
key: string;
|
|
30
|
+
}) => boolean | Promise<boolean>) | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* custom key generation function
|
|
33
|
+
*/
|
|
34
|
+
customKeyGenerator?: (options: {
|
|
35
|
+
/**
|
|
36
|
+
* The length of the API key to generate
|
|
37
|
+
*/
|
|
38
|
+
length: number;
|
|
39
|
+
/**
|
|
40
|
+
* The prefix of the API key to generate
|
|
41
|
+
*/
|
|
42
|
+
prefix: string | undefined;
|
|
43
|
+
}) => string | Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* The configuration for storing the starting characters of the API key in the database.
|
|
46
|
+
*
|
|
47
|
+
* Useful if you want to display the starting characters of an API key in the UI.
|
|
48
|
+
*/
|
|
49
|
+
startingCharactersConfig?: {
|
|
50
|
+
/**
|
|
51
|
+
* Whether to store the starting characters in the database. If false, we will set `start` to `null`.
|
|
52
|
+
*
|
|
53
|
+
* @default true
|
|
54
|
+
*/
|
|
55
|
+
shouldStore?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The length of the starting characters to store in the database.
|
|
58
|
+
*
|
|
59
|
+
* This includes the prefix length.
|
|
60
|
+
*
|
|
61
|
+
* @default 6
|
|
62
|
+
*/
|
|
63
|
+
charactersLength?: number;
|
|
64
|
+
} | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* The length of the API key. Longer is better. Default is 64. (Doesn't include the prefix length)
|
|
67
|
+
* @default 64
|
|
68
|
+
*/
|
|
69
|
+
defaultKeyLength?: number | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The prefix of the API key.
|
|
72
|
+
*
|
|
73
|
+
* Note: We recommend you append an underscore to the prefix to make the prefix more identifiable. (eg `hello_`)
|
|
74
|
+
*/
|
|
75
|
+
defaultPrefix?: string | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The maximum length of the prefix.
|
|
78
|
+
*
|
|
79
|
+
* @default 32
|
|
80
|
+
*/
|
|
81
|
+
maximumPrefixLength?: number | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Whether to require a name for the API key.
|
|
84
|
+
*
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
requireName?: boolean | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* The minimum length of the prefix.
|
|
90
|
+
*
|
|
91
|
+
* @default 1
|
|
92
|
+
*/
|
|
93
|
+
minimumPrefixLength?: number | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* The maximum length of the name.
|
|
96
|
+
*
|
|
97
|
+
* @default 32
|
|
98
|
+
*/
|
|
99
|
+
maximumNameLength?: number | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* The minimum length of the name.
|
|
102
|
+
*
|
|
103
|
+
* @default 1
|
|
104
|
+
*/
|
|
105
|
+
minimumNameLength?: number | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Whether to enable metadata for an API key.
|
|
108
|
+
*
|
|
109
|
+
* @default false
|
|
110
|
+
*/
|
|
111
|
+
enableMetadata?: boolean | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Customize the key expiration.
|
|
114
|
+
*/
|
|
115
|
+
keyExpiration?: {
|
|
116
|
+
/**
|
|
117
|
+
* The default expires time in milliseconds.
|
|
118
|
+
*
|
|
119
|
+
* If `null`, then there will be no expiration time.
|
|
120
|
+
*
|
|
121
|
+
* @default null
|
|
122
|
+
*/
|
|
123
|
+
defaultExpiresIn?: number | null;
|
|
124
|
+
/**
|
|
125
|
+
* Whether to disable the expires time passed from the client.
|
|
126
|
+
*
|
|
127
|
+
* If `true`, the expires time will be based on the default values.
|
|
128
|
+
*
|
|
129
|
+
* @default false
|
|
130
|
+
*/
|
|
131
|
+
disableCustomExpiresTime?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The minimum expiresIn value allowed to be set from the client. in days.
|
|
134
|
+
*
|
|
135
|
+
* @default 1
|
|
136
|
+
*/
|
|
137
|
+
minExpiresIn?: number;
|
|
138
|
+
/**
|
|
139
|
+
* The maximum expiresIn value allowed to be set from the client. in days.
|
|
140
|
+
*
|
|
141
|
+
* @default 365
|
|
142
|
+
*/
|
|
143
|
+
maxExpiresIn?: number;
|
|
144
|
+
} | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Default rate limiting options.
|
|
147
|
+
*/
|
|
148
|
+
rateLimit?: {
|
|
149
|
+
/**
|
|
150
|
+
* Whether to enable rate limiting.
|
|
151
|
+
*
|
|
152
|
+
* @default true
|
|
153
|
+
*/
|
|
154
|
+
enabled?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* The duration in milliseconds where each request is counted.
|
|
157
|
+
*
|
|
158
|
+
* Once the `maxRequests` is reached, the request will be rejected until the `timeWindow` has passed, at which point the `timeWindow` will be reset.
|
|
159
|
+
*
|
|
160
|
+
* @default 1000 * 60 * 60 * 24 // 1 day
|
|
161
|
+
*/
|
|
162
|
+
timeWindow?: number;
|
|
163
|
+
/**
|
|
164
|
+
* Maximum amount of requests allowed within a window
|
|
165
|
+
*
|
|
166
|
+
* Once the `maxRequests` is reached, the request will be rejected until the `timeWindow` has passed, at which point the `timeWindow` will be reset.
|
|
167
|
+
*
|
|
168
|
+
* @default 10 // 10 requests per day
|
|
169
|
+
*/
|
|
170
|
+
maxRequests?: number;
|
|
171
|
+
} | undefined;
|
|
172
|
+
/**
|
|
173
|
+
* custom schema for the API key plugin
|
|
174
|
+
*/
|
|
175
|
+
schema?: InferOptionSchema<ReturnType<typeof apiKeySchema>> | undefined;
|
|
176
|
+
/**
|
|
177
|
+
* An API Key can represent a valid session, so we automatically mock a session for the user if we find a valid API key in the request headers.
|
|
178
|
+
*
|
|
179
|
+
* ⚠︎ This is not recommended for production use, as it can lead to security issues.
|
|
180
|
+
* @default false
|
|
181
|
+
*/
|
|
182
|
+
enableSessionForAPIKeys?: boolean | undefined;
|
|
183
|
+
/**
|
|
184
|
+
* Permissions for the API key.
|
|
185
|
+
*/
|
|
186
|
+
permissions?: {
|
|
187
|
+
/**
|
|
188
|
+
* The default permissions for the API key.
|
|
189
|
+
*/
|
|
190
|
+
defaultPermissions?: Statements | ((userId: string, ctx: GenericEndpointContext) => Statements | Promise<Statements>);
|
|
191
|
+
} | undefined;
|
|
192
|
+
}
|
|
193
|
+
export type ApiKey = {
|
|
194
|
+
/**
|
|
195
|
+
* ID
|
|
196
|
+
*/
|
|
197
|
+
id: string;
|
|
198
|
+
/**
|
|
199
|
+
* The name of the key
|
|
200
|
+
*/
|
|
201
|
+
name: string | null;
|
|
202
|
+
/**
|
|
203
|
+
* Shows the first few characters of the API key, including the prefix.
|
|
204
|
+
* This allows you to show those few characters in the UI to make it easier for users to identify the API key.
|
|
205
|
+
*/
|
|
206
|
+
start: string | null;
|
|
207
|
+
/**
|
|
208
|
+
* The API Key prefix. Stored as plain text.
|
|
209
|
+
*/
|
|
210
|
+
prefix: string | null;
|
|
211
|
+
/**
|
|
212
|
+
* The hashed API key value
|
|
213
|
+
*/
|
|
214
|
+
key: string;
|
|
215
|
+
/**
|
|
216
|
+
* The owner of the user id
|
|
217
|
+
*/
|
|
218
|
+
userId: string;
|
|
219
|
+
/**
|
|
220
|
+
* The interval in milliseconds between refills of the `remaining` count
|
|
221
|
+
*
|
|
222
|
+
* @example 3600000 // refill every hour (3600000ms = 1h)
|
|
223
|
+
*/
|
|
224
|
+
refillInterval: number | null;
|
|
225
|
+
/**
|
|
226
|
+
* The amount to refill
|
|
227
|
+
*/
|
|
228
|
+
refillAmount: number | null;
|
|
229
|
+
/**
|
|
230
|
+
* The last refill date
|
|
231
|
+
*/
|
|
232
|
+
lastRefillAt: Date | null;
|
|
233
|
+
/**
|
|
234
|
+
* Sets if key is enabled or disabled
|
|
235
|
+
*
|
|
236
|
+
* @default true
|
|
237
|
+
*/
|
|
238
|
+
enabled: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Whether the key has rate limiting enabled.
|
|
241
|
+
*/
|
|
242
|
+
rateLimitEnabled: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* The duration in milliseconds
|
|
245
|
+
*/
|
|
246
|
+
rateLimitTimeWindow: number | null;
|
|
247
|
+
/**
|
|
248
|
+
* Maximum amount of requests allowed within a window
|
|
249
|
+
*/
|
|
250
|
+
rateLimitMax: number | null;
|
|
251
|
+
/**
|
|
252
|
+
* The number of requests made within the rate limit time window
|
|
253
|
+
*/
|
|
254
|
+
requestCount: number;
|
|
255
|
+
/**
|
|
256
|
+
* Remaining requests (every time API key is used this should updated and should be updated on refill as well)
|
|
257
|
+
*/
|
|
258
|
+
remaining: number | null;
|
|
259
|
+
/**
|
|
260
|
+
* When last request occurred
|
|
261
|
+
*/
|
|
262
|
+
lastRequest: Date | null;
|
|
263
|
+
/**
|
|
264
|
+
* Expiry date of a key
|
|
265
|
+
*/
|
|
266
|
+
expiresAt: Date | null;
|
|
267
|
+
/**
|
|
268
|
+
* created at
|
|
269
|
+
*/
|
|
270
|
+
createdAt: Date;
|
|
271
|
+
/**
|
|
272
|
+
* updated at
|
|
273
|
+
*/
|
|
274
|
+
updatedAt: Date;
|
|
275
|
+
/**
|
|
276
|
+
* Extra metadata about the apiKey
|
|
277
|
+
*/
|
|
278
|
+
metadata: Record<string, any> | null;
|
|
279
|
+
/**
|
|
280
|
+
* Permissions for the API key
|
|
281
|
+
*/
|
|
282
|
+
permissions?: ({
|
|
283
|
+
[key: string]: string[];
|
|
284
|
+
} | null) | undefined;
|
|
285
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
interface BearerOptions {
|
|
2
|
+
/**
|
|
3
|
+
* If true, only signed tokens
|
|
4
|
+
* will be converted to session
|
|
5
|
+
* cookies
|
|
6
|
+
*
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
requireSignature?: boolean | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Converts bearer token to session cookie
|
|
13
|
+
*/
|
|
14
|
+
export declare const bearer: (options?: BearerOptions | undefined) => {
|
|
15
|
+
id: "bearer";
|
|
16
|
+
hooks: {
|
|
17
|
+
before: {
|
|
18
|
+
matcher(context: import("@gatwech/core").HookEndpointContext): boolean;
|
|
19
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
20
|
+
context: {
|
|
21
|
+
headers: Headers;
|
|
22
|
+
};
|
|
23
|
+
} | undefined>;
|
|
24
|
+
}[];
|
|
25
|
+
after: {
|
|
26
|
+
matcher(context: import("@gatwech/core").HookEndpointContext): true;
|
|
27
|
+
handler: (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<void>;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Provider } from "./types";
|
|
2
|
+
export declare const defaultEndpoints: string[];
|
|
3
|
+
export declare const Providers: {
|
|
4
|
+
readonly CLOUDFLARE_TURNSTILE: "cloudflare-turnstile";
|
|
5
|
+
readonly GOOGLE_RECAPTCHA: "google-recaptcha";
|
|
6
|
+
readonly HCAPTCHA: "hcaptcha";
|
|
7
|
+
readonly CAPTCHAFOX: "captchafox";
|
|
8
|
+
};
|
|
9
|
+
export declare const siteVerifyMap: Record<Provider, string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const EXTERNAL_ERROR_CODES: {
|
|
2
|
+
readonly VERIFICATION_FAILED: "Captcha verification failed";
|
|
3
|
+
readonly MISSING_RESPONSE: "Missing CAPTCHA response";
|
|
4
|
+
readonly UNKNOWN_ERROR: "Something went wrong";
|
|
5
|
+
};
|
|
6
|
+
export declare const INTERNAL_ERROR_CODES: {
|
|
7
|
+
readonly MISSING_SECRET_KEY: "Missing secret key";
|
|
8
|
+
readonly SERVICE_UNAVAILABLE: "CAPTCHA service unavailable";
|
|
9
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CaptchaOptions } from "./types";
|
|
2
|
+
export declare const captcha: (options: CaptchaOptions) => {
|
|
3
|
+
id: "captcha";
|
|
4
|
+
onRequest: (request: Request, ctx: import("@gatwech/core").AuthContext<import("@gatwech/core").PayvoAuthOptions>) => Promise<{
|
|
5
|
+
response: Response;
|
|
6
|
+
} | undefined>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Providers } from "./constants";
|
|
2
|
+
export type Provider = (typeof Providers)[keyof typeof Providers];
|
|
3
|
+
export interface BaseCaptchaOptions {
|
|
4
|
+
secretKey: string;
|
|
5
|
+
endpoints?: string[] | undefined;
|
|
6
|
+
siteVerifyURLOverride?: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface GoogleRecaptchaOptions extends BaseCaptchaOptions {
|
|
9
|
+
provider: typeof Providers.GOOGLE_RECAPTCHA;
|
|
10
|
+
minScore?: number | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface CloudflareTurnstileOptions extends BaseCaptchaOptions {
|
|
13
|
+
provider: typeof Providers.CLOUDFLARE_TURNSTILE;
|
|
14
|
+
}
|
|
15
|
+
export interface HCaptchaOptions extends BaseCaptchaOptions {
|
|
16
|
+
provider: typeof Providers.HCAPTCHA;
|
|
17
|
+
siteKey?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface CaptchaFoxOptions extends BaseCaptchaOptions {
|
|
20
|
+
provider: typeof Providers.CAPTCHAFOX;
|
|
21
|
+
siteKey?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export type CaptchaOptions = GoogleRecaptchaOptions | CloudflareTurnstileOptions | HCaptchaOptions | CaptchaFoxOptions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const encodeToURLParams: (obj: Record<string, any>) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Params = {
|
|
2
|
+
siteVerifyURL: string;
|
|
3
|
+
secretKey: string;
|
|
4
|
+
captchaResponse: string;
|
|
5
|
+
siteKey?: string | undefined;
|
|
6
|
+
remoteIP?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const captchaFox: ({ siteVerifyURL, captchaResponse, secretKey, siteKey, remoteIP, }: Params) => Promise<{
|
|
9
|
+
response: Response;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Params = {
|
|
2
|
+
siteVerifyURL: string;
|
|
3
|
+
secretKey: string;
|
|
4
|
+
captchaResponse: string;
|
|
5
|
+
remoteIP?: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const cloudflareTurnstile: ({ siteVerifyURL, captchaResponse, secretKey, remoteIP, }: Params) => Promise<{
|
|
8
|
+
response: Response;
|
|
9
|
+
} | undefined>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Params = {
|
|
2
|
+
siteVerifyURL: string;
|
|
3
|
+
secretKey: string;
|
|
4
|
+
captchaResponse: string;
|
|
5
|
+
minScore?: number | undefined;
|
|
6
|
+
remoteIP?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const googleRecaptcha: ({ siteVerifyURL, captchaResponse, secretKey, minScore, remoteIP, }: Params) => Promise<{
|
|
9
|
+
response: Response;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Params = {
|
|
2
|
+
siteVerifyURL: string;
|
|
3
|
+
secretKey: string;
|
|
4
|
+
captchaResponse: string;
|
|
5
|
+
siteKey?: string | undefined;
|
|
6
|
+
remoteIP?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const hCaptcha: ({ siteVerifyURL, captchaResponse, secretKey, siteKey, remoteIP, }: Params) => Promise<{
|
|
9
|
+
response: Response;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Auth } from "../../auth";
|
|
2
|
+
import type { PayvoAuthOptions } from "../../types";
|
|
3
|
+
export declare const customSessionClient: <A extends Auth | {
|
|
4
|
+
options: PayvoAuthOptions;
|
|
5
|
+
}>() => {
|
|
6
|
+
id: "infer-server-plugin";
|
|
7
|
+
$InferServerPlugin: (A extends {
|
|
8
|
+
options: infer O;
|
|
9
|
+
} ? O : A)["plugins"] extends (infer P)[] ? P extends {
|
|
10
|
+
id: "custom-session";
|
|
11
|
+
} ? P : never : never;
|
|
12
|
+
};
|