@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,49 @@
|
|
|
1
|
+
import type { PayvoAuthClientOptions, PayvoAuthClientPlugin, PayvoAuthPlugin, ClientAtomListener, ClientStore } from "@gatwech/core";
|
|
2
|
+
import type { Auth } from "../auth";
|
|
3
|
+
import type { InferFieldsInputClient, InferFieldsOutput } from "../db";
|
|
4
|
+
import type { Session, User } from "../types";
|
|
5
|
+
import type { StripEmptyObjects, UnionToIntersection } from "../types/helper";
|
|
6
|
+
import type { InferRoutes } from "./path-to-object";
|
|
7
|
+
export type { ClientStore, ClientAtomListener, PayvoAuthClientOptions, PayvoAuthClientPlugin, };
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use type `PayvoAuthClientOptions` instead.
|
|
10
|
+
*/
|
|
11
|
+
export type Store = ClientStore;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use type `ClientAtomListener` instead.
|
|
14
|
+
*/
|
|
15
|
+
export type AtomListener = ClientAtomListener;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated use type `PayvoAuthClientPlugin` instead.
|
|
18
|
+
*/
|
|
19
|
+
export type ClientOptions = PayvoAuthClientOptions;
|
|
20
|
+
export type InferClientAPI<O extends PayvoAuthClientOptions> = InferRoutes<O["plugins"] extends Array<any> ? Auth["api"] & (O["plugins"] extends Array<infer Pl> ? UnionToIntersection<Pl extends {
|
|
21
|
+
$InferServerPlugin: infer Plug;
|
|
22
|
+
} ? Plug extends {
|
|
23
|
+
endpoints: infer Endpoints;
|
|
24
|
+
} ? Endpoints : {} : {}> : {}) : Auth["api"], O>;
|
|
25
|
+
export type InferActions<O extends PayvoAuthClientOptions> = (O["plugins"] extends Array<infer Plugin> ? UnionToIntersection<Plugin extends PayvoAuthClientPlugin ? Plugin["getActions"] extends (...args: any) => infer Actions ? Actions : {} : {}> : {}) & InferRoutes<O["$InferAuth"] extends {
|
|
26
|
+
plugins: infer Plugins;
|
|
27
|
+
} ? Plugins extends Array<infer Plugin> ? Plugin extends {
|
|
28
|
+
endpoints: infer Endpoints;
|
|
29
|
+
} ? Endpoints : {} : {} : {}, O>;
|
|
30
|
+
export type InferErrorCodes<O extends PayvoAuthClientOptions> = O["plugins"] extends Array<infer Plugin> ? UnionToIntersection<Plugin extends PayvoAuthClientPlugin ? Plugin["$InferServerPlugin"] extends PayvoAuthPlugin ? Plugin["$InferServerPlugin"]["$ERROR_CODES"] : {} : {}> : {};
|
|
31
|
+
/**
|
|
32
|
+
* signals are just used to recall a computed value.
|
|
33
|
+
* as a convention they start with "$"
|
|
34
|
+
*/
|
|
35
|
+
export type IsSignal<T> = T extends `$${infer _}` ? true : false;
|
|
36
|
+
export type InferPluginsFromClient<O extends PayvoAuthClientOptions> = O["plugins"] extends Array<PayvoAuthClientPlugin> ? Array<O["plugins"][number]["$InferServerPlugin"]> : undefined;
|
|
37
|
+
export type InferSessionFromClient<O extends PayvoAuthClientOptions> = StripEmptyObjects<Session & UnionToIntersection<InferAdditionalFromClient<O, "session", "output">>>;
|
|
38
|
+
export type InferUserFromClient<O extends PayvoAuthClientOptions> = StripEmptyObjects<User & UnionToIntersection<InferAdditionalFromClient<O, "user", "output">>>;
|
|
39
|
+
export type InferAdditionalFromClient<Options extends PayvoAuthClientOptions, Key extends string, Format extends "input" | "output" = "output"> = Options["plugins"] extends Array<infer T> ? T extends PayvoAuthClientPlugin ? T["$InferServerPlugin"] extends {
|
|
40
|
+
schema: {
|
|
41
|
+
[key in Key]: {
|
|
42
|
+
fields: infer Field;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
} ? Format extends "input" ? InferFieldsInputClient<Field> : InferFieldsOutput<Field> : {} : {} : {};
|
|
46
|
+
export type SessionQueryParams = {
|
|
47
|
+
disableCookieCache?: boolean | undefined;
|
|
48
|
+
disableRefresh?: boolean | undefined;
|
|
49
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { PayvoAuthClientOptions, PayvoAuthClientPlugin } from "@gatwech/core";
|
|
2
|
+
import type { BASE_ERROR_CODES } from "@gatwech/core/error";
|
|
3
|
+
import type { BetterFetchError } from "@better-fetch/fetch";
|
|
4
|
+
import type { Atom } from "nanostores";
|
|
5
|
+
import type { PrettifyDeep, UnionToIntersection } from "../types/helper";
|
|
6
|
+
import type { InferActions, InferClientAPI, InferErrorCodes, IsSignal } from "./types";
|
|
7
|
+
type InferResolvedHooks<O extends PayvoAuthClientOptions> = O extends {
|
|
8
|
+
plugins: Array<infer Plugin>;
|
|
9
|
+
} ? UnionToIntersection<Plugin extends PayvoAuthClientPlugin ? Plugin["getAtoms"] extends (fetch: any) => infer Atoms ? Atoms extends Record<string, any> ? {
|
|
10
|
+
[key in keyof Atoms as IsSignal<key> extends true ? never : key extends string ? `use${Capitalize<key>}` : never]: Atoms[key];
|
|
11
|
+
} : {} : {} : {}> : {};
|
|
12
|
+
export declare function createAuthClient<Option extends PayvoAuthClientOptions>(options?: Option | undefined): UnionToIntersection<InferResolvedHooks<Option>> & InferClientAPI<Option> & InferActions<Option> & {
|
|
13
|
+
useSession: Atom<{
|
|
14
|
+
data: InferClientAPI<Option> extends {
|
|
15
|
+
getSession: () => Promise<infer Res>;
|
|
16
|
+
} ? Res extends {
|
|
17
|
+
data: null;
|
|
18
|
+
error: {
|
|
19
|
+
message?: string | undefined;
|
|
20
|
+
status: number;
|
|
21
|
+
statusText: string;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
data: infer S;
|
|
25
|
+
error: null;
|
|
26
|
+
} ? S : Res extends Record<string, any> ? Res : never : never;
|
|
27
|
+
error: BetterFetchError | null;
|
|
28
|
+
isPending: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
$fetch: import("@better-fetch/fetch").BetterFetch<{
|
|
31
|
+
plugins: (import("@better-fetch/fetch").BetterFetchPlugin | {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
hooks: {
|
|
35
|
+
onSuccess(context: import("@better-fetch/fetch").SuccessContext<any>): void;
|
|
36
|
+
};
|
|
37
|
+
} | {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
hooks: {
|
|
41
|
+
onRequest<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>): void;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
hooks: {
|
|
47
|
+
onSuccess: ((context: import("@better-fetch/fetch").SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
48
|
+
onError: ((context: import("@better-fetch/fetch").ErrorContext) => Promise<void> | void) | undefined;
|
|
49
|
+
onRequest: (<T extends Record<string, any>>(context: import("@better-fetch/fetch").RequestContext<T>) => Promise<import("@better-fetch/fetch").RequestContext | void> | import("@better-fetch/fetch").RequestContext | void) | undefined;
|
|
50
|
+
onResponse: ((context: import("@better-fetch/fetch").ResponseContext) => Promise<Response | void | import("@better-fetch/fetch").ResponseContext> | Response | import("@better-fetch/fetch").ResponseContext | void) | undefined;
|
|
51
|
+
};
|
|
52
|
+
})[];
|
|
53
|
+
method: string;
|
|
54
|
+
headers?: (HeadersInit & (HeadersInit | {
|
|
55
|
+
accept: "application/json" | "text/plain" | "application/octet-stream";
|
|
56
|
+
"content-type": "application/json" | "text/plain" | "application/x-www-form-urlencoded" | "multipart/form-data" | "application/octet-stream";
|
|
57
|
+
authorization: "Bearer" | "Basic";
|
|
58
|
+
})) | undefined;
|
|
59
|
+
redirect?: RequestRedirect | undefined;
|
|
60
|
+
cache?: RequestCache | undefined;
|
|
61
|
+
credentials?: RequestCredentials;
|
|
62
|
+
integrity?: string | undefined;
|
|
63
|
+
keepalive?: boolean | undefined;
|
|
64
|
+
mode?: RequestMode | undefined;
|
|
65
|
+
priority?: RequestPriority | undefined;
|
|
66
|
+
referrer?: string | undefined;
|
|
67
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
68
|
+
signal?: (AbortSignal | null) | undefined;
|
|
69
|
+
window?: null | undefined;
|
|
70
|
+
onRetry?: ((response: import("@better-fetch/fetch").ResponseContext) => Promise<void> | void) | undefined;
|
|
71
|
+
hookOptions?: {
|
|
72
|
+
cloneResponse?: boolean;
|
|
73
|
+
} | undefined;
|
|
74
|
+
timeout?: number | undefined;
|
|
75
|
+
customFetchImpl: import("@better-fetch/fetch").FetchEsque;
|
|
76
|
+
baseURL: string;
|
|
77
|
+
throw?: boolean | undefined;
|
|
78
|
+
auth?: ({
|
|
79
|
+
type: "Bearer";
|
|
80
|
+
token: string | Promise<string | undefined> | (() => string | Promise<string | undefined> | undefined) | undefined;
|
|
81
|
+
} | {
|
|
82
|
+
type: "Basic";
|
|
83
|
+
username: string | (() => string | undefined) | undefined;
|
|
84
|
+
password: string | (() => string | undefined) | undefined;
|
|
85
|
+
} | {
|
|
86
|
+
type: "Custom";
|
|
87
|
+
prefix: string | (() => string | undefined) | undefined;
|
|
88
|
+
value: string | (() => string | undefined) | undefined;
|
|
89
|
+
}) | undefined;
|
|
90
|
+
body?: any;
|
|
91
|
+
query?: any;
|
|
92
|
+
params?: any;
|
|
93
|
+
duplex?: "full" | "half" | undefined;
|
|
94
|
+
jsonParser: (text: string) => Promise<any> | any;
|
|
95
|
+
retry?: import("@better-fetch/fetch").RetryOptions | undefined;
|
|
96
|
+
retryAttempt?: number | undefined;
|
|
97
|
+
output?: (import("@better-fetch/fetch").StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
98
|
+
errorSchema?: import("@better-fetch/fetch").StandardSchemaV1 | undefined;
|
|
99
|
+
disableValidation?: boolean | undefined;
|
|
100
|
+
}, unknown, unknown, {}>;
|
|
101
|
+
$store: {
|
|
102
|
+
notify: (signal?: (Omit<string, "$sessionSignal"> | "$sessionSignal") | undefined) => void;
|
|
103
|
+
listen: (signal: Omit<string, "$sessionSignal"> | "$sessionSignal", listener: (value: boolean, oldValue?: boolean | undefined) => void) => void;
|
|
104
|
+
atoms: Record<string, import("nanostores").WritableAtom<any>>;
|
|
105
|
+
};
|
|
106
|
+
$Infer: {
|
|
107
|
+
Session: NonNullable<InferClientAPI<Option> extends {
|
|
108
|
+
getSession: () => Promise<infer Res>;
|
|
109
|
+
} ? Res extends {
|
|
110
|
+
data: null;
|
|
111
|
+
error: {
|
|
112
|
+
message?: string | undefined;
|
|
113
|
+
status: number;
|
|
114
|
+
statusText: string;
|
|
115
|
+
};
|
|
116
|
+
} | {
|
|
117
|
+
data: infer S;
|
|
118
|
+
error: null;
|
|
119
|
+
} ? S : Res extends Record<string, any> ? Res : never : never>;
|
|
120
|
+
};
|
|
121
|
+
$ERROR_CODES: PrettifyDeep<InferErrorCodes<Option> & typeof BASE_ERROR_CODES>;
|
|
122
|
+
};
|
|
123
|
+
export type AuthClient<Option extends PayvoAuthClientOptions> = ReturnType<typeof createAuthClient<Option>>;
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface CookieAttributes {
|
|
2
|
+
value: string;
|
|
3
|
+
"max-age"?: number | undefined;
|
|
4
|
+
expires?: Date | undefined;
|
|
5
|
+
domain?: string | undefined;
|
|
6
|
+
path?: string | undefined;
|
|
7
|
+
secure?: boolean | undefined;
|
|
8
|
+
httponly?: boolean | undefined;
|
|
9
|
+
samesite?: ("strict" | "lax" | "none") | undefined;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseSetCookieHeader(setCookie: string): Map<string, CookieAttributes>;
|
|
13
|
+
export declare function setCookieToHeader(headers: Headers): (context: {
|
|
14
|
+
response: Response;
|
|
15
|
+
}) => void;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { PayvoAuthCookies, PayvoAuthOptions, GenericEndpointContext } from "@gatwech/core";
|
|
2
|
+
import type { CookieOptions } from "better-call";
|
|
3
|
+
import type { Session, User } from "../types";
|
|
4
|
+
export declare function createCookieGetter(options: PayvoAuthOptions): (cookieName: string, overrideAttributes?: Partial<CookieOptions>) => {
|
|
5
|
+
name: string;
|
|
6
|
+
attributes: CookieOptions;
|
|
7
|
+
};
|
|
8
|
+
export declare function getCookies(options: PayvoAuthOptions): {
|
|
9
|
+
sessionToken: {
|
|
10
|
+
name: string;
|
|
11
|
+
options: CookieOptions;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* This cookie is used to store the session data in the cookie
|
|
15
|
+
* This is useful for when you want to cache the session in the cookie
|
|
16
|
+
*/
|
|
17
|
+
sessionData: {
|
|
18
|
+
name: string;
|
|
19
|
+
options: CookieOptions;
|
|
20
|
+
};
|
|
21
|
+
dontRememberToken: {
|
|
22
|
+
name: string;
|
|
23
|
+
options: CookieOptions;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare function setCookieCache(ctx: GenericEndpointContext, session: {
|
|
27
|
+
session: Session & Record<string, any>;
|
|
28
|
+
user: User;
|
|
29
|
+
}, dontRememberMe: boolean): Promise<void>;
|
|
30
|
+
export declare function setSessionCookie(ctx: GenericEndpointContext, session: {
|
|
31
|
+
session: Session & Record<string, any>;
|
|
32
|
+
user: User;
|
|
33
|
+
}, dontRememberMe?: boolean | undefined, overrides?: Partial<CookieOptions> | undefined): Promise<void>;
|
|
34
|
+
export declare function deleteSessionCookie(ctx: GenericEndpointContext, skipDontRememberMe?: boolean | undefined): void;
|
|
35
|
+
export declare function parseCookies(cookieHeader: string): Map<string, string>;
|
|
36
|
+
export type EligibleCookies = (string & {}) | (keyof PayvoAuthCookies & {});
|
|
37
|
+
export declare const getSessionCookie: (request: Request | Headers, config?: {
|
|
38
|
+
cookiePrefix?: string;
|
|
39
|
+
cookieName?: string;
|
|
40
|
+
path?: string;
|
|
41
|
+
} | undefined) => string | null;
|
|
42
|
+
export declare const getCookieCache: <S extends {
|
|
43
|
+
session: Session & Record<string, any>;
|
|
44
|
+
user: User & Record<string, any>;
|
|
45
|
+
updatedAt: number;
|
|
46
|
+
version?: string;
|
|
47
|
+
}>(request: Request | Headers, config?: {
|
|
48
|
+
cookiePrefix?: string;
|
|
49
|
+
cookieName?: string;
|
|
50
|
+
isSecure?: boolean;
|
|
51
|
+
secret?: string;
|
|
52
|
+
strategy?: "compact" | "jwt" | "jwe";
|
|
53
|
+
version?: string | ((session: Session & Record<string, any>, user: User & Record<string, any>) => string) | ((session: Session & Record<string, any>, user: User & Record<string, any>) => Promise<string>);
|
|
54
|
+
} | undefined) => Promise<S | null>;
|
|
55
|
+
export * from "./cookie-utils";
|
|
56
|
+
export { createSessionStore, getChunkedCookie } from "./session-store";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { GenericEndpointContext } from "@gatwech/core";
|
|
2
|
+
import type { CookieOptions } from "better-call";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
interface Cookie {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
options: CookieOptions;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create a session store for handling cookie chunking.
|
|
11
|
+
* When session data exceeds 4KB, it automatically splits it into multiple cookies.
|
|
12
|
+
*
|
|
13
|
+
* Based on next-auth's SessionStore implementation.
|
|
14
|
+
* @see https://github.com/nextauthjs/next-auth/blob/27b2519b84b8eb9cf053775dea29d577d2aa0098/packages/next-auth/src/core/lib/cookie.ts
|
|
15
|
+
*/
|
|
16
|
+
export declare function createSessionStore(cookieName: string, cookieOptions: CookieOptions, ctx: GenericEndpointContext): {
|
|
17
|
+
/**
|
|
18
|
+
* Get the full session data by joining all chunks
|
|
19
|
+
*/
|
|
20
|
+
getValue(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Check if there are existing chunks
|
|
23
|
+
*/
|
|
24
|
+
hasChunks(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Chunk a cookie value and return all cookies to set (including cleanup cookies)
|
|
27
|
+
*/
|
|
28
|
+
chunk(value: string, options?: Partial<CookieOptions>): Cookie[];
|
|
29
|
+
/**
|
|
30
|
+
* Get cookies to clean up all chunks
|
|
31
|
+
*/
|
|
32
|
+
clean(): Cookie[];
|
|
33
|
+
/**
|
|
34
|
+
* Set all cookies in the context
|
|
35
|
+
*/
|
|
36
|
+
setCookies(cookies: Cookie[]): void;
|
|
37
|
+
};
|
|
38
|
+
export declare function getChunkedCookie(ctx: GenericEndpointContext, cookieName: string): string | null;
|
|
39
|
+
export declare const getSessionQuerySchema: z.ZodOptional<z.ZodObject<{
|
|
40
|
+
disableCookieCache: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
41
|
+
disableRefresh: z.ZodOptional<z.ZodCoercedBoolean<unknown>>;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type SymmetricEncryptOptions = {
|
|
2
|
+
key: string;
|
|
3
|
+
data: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const symmetricEncrypt: ({ key, data, }: SymmetricEncryptOptions) => Promise<string>;
|
|
6
|
+
export type SymmetricDecryptOptions = {
|
|
7
|
+
key: string;
|
|
8
|
+
data: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const symmetricDecrypt: ({ key, data, }: SymmetricDecryptOptions) => Promise<string>;
|
|
11
|
+
export * from "./buffer";
|
|
12
|
+
export * from "./jwt";
|
|
13
|
+
export * from "./password";
|
|
14
|
+
export * from "./random";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function signJWT(payload: any, secret: string, expiresIn?: number): Promise<string>;
|
|
2
|
+
export declare function verifyJWT<T = any>(token: string, secret: string): Promise<T | null>;
|
|
3
|
+
export declare function symmetricEncodeJWT<T extends Record<string, any>>(payload: T, secret: string, salt: string, expiresIn?: number): Promise<string>;
|
|
4
|
+
export declare function symmetricDecodeJWT<T = any>(token: string, secret: string, salt: string): Promise<T | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generateRandomString: <SubA extends "a-z" | "A-Z" | "0-9" | "-_">(length: number, ...alphabets: SubA[]) => string;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { PayvoAuthOptions } from "@gatwech/core";
|
|
2
|
+
import type { DBFieldAttribute, DBFieldAttributeConfig, DBFieldType } from "@gatwech/core/db";
|
|
3
|
+
export declare const createFieldAttribute: <T extends DBFieldType, C extends DBFieldAttributeConfig>(type: T, config?: C | undefined) => {
|
|
4
|
+
required?: boolean | undefined;
|
|
5
|
+
returned?: boolean | undefined;
|
|
6
|
+
input?: boolean | undefined;
|
|
7
|
+
defaultValue?: (import("@gatwech/core/db").DBPrimitive | (() => import("@gatwech/core/db").DBPrimitive)) | undefined;
|
|
8
|
+
onUpdate?: (() => import("@gatwech/core/db").DBPrimitive) | undefined;
|
|
9
|
+
transform?: {
|
|
10
|
+
input?: (value: import("@gatwech/core/db").DBPrimitive) => import("@gatwech/core/db").DBPrimitive | Promise<import("@gatwech/core/db").DBPrimitive>;
|
|
11
|
+
output?: (value: import("@gatwech/core/db").DBPrimitive) => import("@gatwech/core/db").DBPrimitive | Promise<import("@gatwech/core/db").DBPrimitive>;
|
|
12
|
+
} | undefined;
|
|
13
|
+
references?: {
|
|
14
|
+
model: string;
|
|
15
|
+
field: string;
|
|
16
|
+
onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
|
|
17
|
+
} | undefined;
|
|
18
|
+
unique?: boolean | undefined;
|
|
19
|
+
bigint?: boolean | undefined;
|
|
20
|
+
validator?: {
|
|
21
|
+
input?: import("@standard-schema/spec").StandardSchemaV1;
|
|
22
|
+
output?: import("@standard-schema/spec").StandardSchemaV1;
|
|
23
|
+
} | undefined;
|
|
24
|
+
fieldName?: string | undefined;
|
|
25
|
+
sortable?: boolean | undefined;
|
|
26
|
+
type: T;
|
|
27
|
+
};
|
|
28
|
+
export type InferValueType<T extends DBFieldType> = T extends "string" ? string : T extends "number" ? number : T extends "boolean" ? boolean : T extends "date" ? Date : T extends "json" ? Record<string, any> : T extends `${infer U}[]` ? U extends "string" ? string[] : number[] : T extends Array<any> ? T[number] : never;
|
|
29
|
+
export type InferFieldsOutput<Field> = Field extends Record<infer Key, DBFieldAttribute> ? {
|
|
30
|
+
[key in Key as Field[key]["required"] extends false ? Field[key]["defaultValue"] extends boolean | string | number | Date ? key : never : key]: InferFieldOutput<Field[key]>;
|
|
31
|
+
} & {
|
|
32
|
+
[key in Key as Field[key]["returned"] extends false ? never : key]?: InferFieldOutput<Field[key]> | null;
|
|
33
|
+
} : {};
|
|
34
|
+
export type InferFieldsInput<Field> = Field extends Record<infer Key, DBFieldAttribute> ? {
|
|
35
|
+
[key in Key as Field[key]["required"] extends false ? never : Field[key]["defaultValue"] extends string | number | boolean | Date ? never : Field[key]["input"] extends false ? never : key]: InferFieldInput<Field[key]>;
|
|
36
|
+
} & {
|
|
37
|
+
[key in Key as Field[key]["input"] extends false ? never : key]?: InferFieldInput<Field[key]> | undefined | null;
|
|
38
|
+
} : {};
|
|
39
|
+
/**
|
|
40
|
+
* For client will add "?" on optional fields
|
|
41
|
+
*/
|
|
42
|
+
export type InferFieldsInputClient<Field> = Field extends Record<infer Key, DBFieldAttribute> ? {
|
|
43
|
+
[key in Key as Field[key]["required"] extends false ? never : Field[key]["defaultValue"] extends string | number | boolean | Date ? never : Field[key]["input"] extends false ? never : key]: InferFieldInput<Field[key]>;
|
|
44
|
+
} & {
|
|
45
|
+
[key in Key as Field[key]["input"] extends false ? never : Field[key]["required"] extends false ? key : Field[key]["defaultValue"] extends string | number | boolean | Date ? key : never]?: InferFieldInput<Field[key]> | undefined | null;
|
|
46
|
+
} : {};
|
|
47
|
+
type InferFieldOutput<T extends DBFieldAttribute> = T["returned"] extends false ? never : T["required"] extends false ? InferValueType<T["type"]> | undefined | null : InferValueType<T["type"]>;
|
|
48
|
+
/**
|
|
49
|
+
* Converts a Record<string, DBFieldAttribute> to an object type
|
|
50
|
+
* with keys and value types inferred from DBFieldAttribute["type"].
|
|
51
|
+
*/
|
|
52
|
+
export type FieldAttributeToObject<Fields extends Record<string, DBFieldAttribute>> = AddOptionalFields<{
|
|
53
|
+
[K in keyof Fields]: InferValueType<Fields[K]["type"]>;
|
|
54
|
+
}, Fields>;
|
|
55
|
+
type AddOptionalFields<T extends Record<string, any>, Fields extends Record<keyof T, DBFieldAttribute>> = {
|
|
56
|
+
[K in keyof T as Fields[K] extends {
|
|
57
|
+
required: true;
|
|
58
|
+
} ? K : never]: T[K];
|
|
59
|
+
} & {
|
|
60
|
+
[K in keyof T as Fields[K] extends {
|
|
61
|
+
required: true;
|
|
62
|
+
} ? never : K]?: T[K];
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Infer the additional fields from the plugin options.
|
|
66
|
+
* For example, you can infer the additional fields of the org plugin's organization schema like this:
|
|
67
|
+
* ```ts
|
|
68
|
+
* type AdditionalFields = InferAdditionalFieldsFromPluginOptions<"organization", OrganizationOptions>
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export type InferAdditionalFieldsFromPluginOptions<SchemaName extends string, Options extends {
|
|
72
|
+
schema?: {
|
|
73
|
+
[key in SchemaName]?: {
|
|
74
|
+
additionalFields?: Record<string, DBFieldAttribute>;
|
|
75
|
+
};
|
|
76
|
+
} | undefined;
|
|
77
|
+
}, isClientSide extends boolean = true> = Options["schema"] extends {
|
|
78
|
+
[key in SchemaName]?: {
|
|
79
|
+
additionalFields: infer Field extends Record<string, DBFieldAttribute>;
|
|
80
|
+
};
|
|
81
|
+
} ? isClientSide extends true ? FieldAttributeToObject<RemoveFieldsWithInputFalse<Field>> : FieldAttributeToObject<Field> : {};
|
|
82
|
+
type RemoveFieldsWithInputFalse<T extends Record<string, DBFieldAttribute>> = {
|
|
83
|
+
[K in keyof T as T[K]["input"] extends false ? never : K]: T[K];
|
|
84
|
+
};
|
|
85
|
+
type InferFieldInput<T extends DBFieldAttribute> = InferValueType<T["type"]>;
|
|
86
|
+
export type PluginFieldAttribute = Omit<DBFieldAttribute, "transform" | "defaultValue" | "hashValue">;
|
|
87
|
+
export type InferFieldsFromPlugins<Options extends PayvoAuthOptions, Key extends string, Format extends "output" | "input" = "output"> = Options["plugins"] extends [] ? {} : Options["plugins"] extends Array<infer T> ? T extends {
|
|
88
|
+
schema: {
|
|
89
|
+
[key in Key]: {
|
|
90
|
+
fields: infer Field;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
} ? Format extends "output" ? InferFieldsOutput<Field> : InferFieldsInput<Field> : {} : {};
|
|
94
|
+
export type InferFieldsFromOptions<Options extends PayvoAuthOptions, Key extends "session" | "user", Format extends "output" | "input" = "output"> = Options[Key] extends {
|
|
95
|
+
additionalFields: infer Field;
|
|
96
|
+
} ? Format extends "output" ? InferFieldsOutput<Field> : InferFieldsInput<Field> : {};
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PayvoAuthOptions } from "@gatwech/core";
|
|
2
|
+
import type { DBFieldAttribute, DBFieldType } from "@gatwech/core/db";
|
|
3
|
+
import type { KyselyDatabaseType } from "../adapters/kysely-adapter/types";
|
|
4
|
+
export declare function matchType(columnDataType: string, fieldType: DBFieldType, dbType: KyselyDatabaseType): boolean;
|
|
5
|
+
export declare function getMigrations(config: PayvoAuthOptions): Promise<{
|
|
6
|
+
toBeCreated: {
|
|
7
|
+
table: string;
|
|
8
|
+
fields: Record<string, DBFieldAttribute>;
|
|
9
|
+
order: number;
|
|
10
|
+
}[];
|
|
11
|
+
toBeAdded: {
|
|
12
|
+
table: string;
|
|
13
|
+
fields: Record<string, DBFieldAttribute>;
|
|
14
|
+
order: number;
|
|
15
|
+
}[];
|
|
16
|
+
runMigrations: () => Promise<void>;
|
|
17
|
+
compileMigrations: () => Promise<string>;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "@gatwech/core/db";
|
|
2
|
+
export * from "./field";
|
|
3
|
+
export * from "./get-migration";
|
|
4
|
+
export * from "./get-schema";
|
|
5
|
+
export * from "./get-tables";
|
|
6
|
+
export * from "./internal-adapter";
|
|
7
|
+
export * from "./schema";
|
|
8
|
+
export * from "./to-zod";
|
|
9
|
+
export * from "./utils";
|
|
10
|
+
export * from "./with-hooks";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AuthContext, PayvoAuthOptions, InternalAdapter } from "@gatwech/core";
|
|
2
|
+
import type { DBAdapter } from "@gatwech/core/db/adapter";
|
|
3
|
+
import type { InternalLogger } from "@gatwech/core/env";
|
|
4
|
+
export declare const createInternalAdapter: (adapter: DBAdapter<PayvoAuthOptions>, ctx: {
|
|
5
|
+
options: Omit<PayvoAuthOptions, "logger">;
|
|
6
|
+
logger: InternalLogger;
|
|
7
|
+
hooks: Exclude<PayvoAuthOptions["databaseHooks"], undefined>[];
|
|
8
|
+
generateId: AuthContext["generateId"];
|
|
9
|
+
}) => InternalAdapter;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { PayvoAuthOptions } from "@gatwech/core";
|
|
2
|
+
import type { PayvoAuthPluginDBSchema, DBFieldAttribute } from "@gatwech/core/db";
|
|
3
|
+
import type { Account, Session, User } from "../types";
|
|
4
|
+
export declare function parseUserOutput(options: PayvoAuthOptions, user: User): {
|
|
5
|
+
id: string;
|
|
6
|
+
createdAt: Date;
|
|
7
|
+
updatedAt: Date;
|
|
8
|
+
email: string;
|
|
9
|
+
emailVerified: boolean;
|
|
10
|
+
name: string;
|
|
11
|
+
image?: string | null | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare function parseAccountOutput(options: PayvoAuthOptions, account: Account): {
|
|
14
|
+
id: string;
|
|
15
|
+
createdAt: Date;
|
|
16
|
+
updatedAt: Date;
|
|
17
|
+
providerId: string;
|
|
18
|
+
accountId: string;
|
|
19
|
+
userId: string;
|
|
20
|
+
accessToken?: string | null | undefined;
|
|
21
|
+
refreshToken?: string | null | undefined;
|
|
22
|
+
idToken?: string | null | undefined;
|
|
23
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
24
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
25
|
+
scope?: string | null | undefined;
|
|
26
|
+
password?: string | null | undefined;
|
|
27
|
+
};
|
|
28
|
+
export declare function parseSessionOutput(options: PayvoAuthOptions, session: Session): {
|
|
29
|
+
id: string;
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
updatedAt: Date;
|
|
32
|
+
userId: string;
|
|
33
|
+
expiresAt: Date;
|
|
34
|
+
token: string;
|
|
35
|
+
ipAddress?: string | null | undefined;
|
|
36
|
+
userAgent?: string | null | undefined;
|
|
37
|
+
};
|
|
38
|
+
export declare function parseInputData<T extends Record<string, any>>(data: T, schema: {
|
|
39
|
+
fields: Record<string, DBFieldAttribute>;
|
|
40
|
+
action?: ("create" | "update") | undefined;
|
|
41
|
+
}): Partial<T>;
|
|
42
|
+
export declare function parseUserInput(options: PayvoAuthOptions, user: Record<string, any> | undefined, action: "create" | "update"): Partial<Record<string, any>>;
|
|
43
|
+
export declare function parseAdditionalUserInput(options: PayvoAuthOptions, user?: Record<string, any> | undefined): Partial<Record<string, any>>;
|
|
44
|
+
export declare function parseAccountInput(options: PayvoAuthOptions, account: Partial<Account>): Partial<Partial<{
|
|
45
|
+
id: string;
|
|
46
|
+
createdAt: Date;
|
|
47
|
+
updatedAt: Date;
|
|
48
|
+
providerId: string;
|
|
49
|
+
accountId: string;
|
|
50
|
+
userId: string;
|
|
51
|
+
accessToken?: string | null | undefined;
|
|
52
|
+
refreshToken?: string | null | undefined;
|
|
53
|
+
idToken?: string | null | undefined;
|
|
54
|
+
accessTokenExpiresAt?: Date | null | undefined;
|
|
55
|
+
refreshTokenExpiresAt?: Date | null | undefined;
|
|
56
|
+
scope?: string | null | undefined;
|
|
57
|
+
password?: string | null | undefined;
|
|
58
|
+
}>>;
|
|
59
|
+
export declare function parseSessionInput(options: PayvoAuthOptions, session: Partial<Session>): Partial<Partial<{
|
|
60
|
+
id: string;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
updatedAt: Date;
|
|
63
|
+
userId: string;
|
|
64
|
+
expiresAt: Date;
|
|
65
|
+
token: string;
|
|
66
|
+
ipAddress?: string | null | undefined;
|
|
67
|
+
userAgent?: string | null | undefined;
|
|
68
|
+
}>>;
|
|
69
|
+
export declare function mergeSchema<S extends PayvoAuthPluginDBSchema>(schema: S, newSchema?: {
|
|
70
|
+
[K in keyof S]?: {
|
|
71
|
+
modelName?: string;
|
|
72
|
+
fields?: {
|
|
73
|
+
[P: string]: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
} | undefined): S;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DBFieldAttribute } from "@gatwech/core/db";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
export declare function toZodSchema<Fields extends Record<string, DBFieldAttribute | never>, IsClientSide extends boolean>({ fields, isClientSide, }: {
|
|
4
|
+
fields: Fields;
|
|
5
|
+
/**
|
|
6
|
+
* If true, then any fields that have `input: false` will be removed from the schema to prevent user input.
|
|
7
|
+
*/
|
|
8
|
+
isClientSide: IsClientSide;
|
|
9
|
+
}): z.ZodObject<RemoveNeverProps<{ [key in keyof Fields]: FieldAttributeToSchema<Fields[key], IsClientSide>; }>, z.core.$strip>;
|
|
10
|
+
export type FieldAttributeToSchema<Field extends DBFieldAttribute | Record<string, never>, isClientSide extends boolean = false> = Field extends {
|
|
11
|
+
type: any;
|
|
12
|
+
} ? GetInput<isClientSide, Field, GetRequired<Field, GetType<Field>>> : Record<string, never>;
|
|
13
|
+
type GetType<F extends DBFieldAttribute> = F extends {
|
|
14
|
+
type: "string";
|
|
15
|
+
} ? z.ZodString : F extends {
|
|
16
|
+
type: "number";
|
|
17
|
+
} ? z.ZodNumber : F extends {
|
|
18
|
+
type: "boolean";
|
|
19
|
+
} ? z.ZodBoolean : F extends {
|
|
20
|
+
type: "date";
|
|
21
|
+
} ? z.ZodDate : z.ZodAny;
|
|
22
|
+
type GetRequired<F extends DBFieldAttribute, Schema extends z.core.SomeType> = F extends {
|
|
23
|
+
required: true;
|
|
24
|
+
} ? Schema : z.ZodOptional<Schema>;
|
|
25
|
+
type GetInput<isClientSide extends boolean, Field extends DBFieldAttribute, Schema extends z.core.SomeType> = Field extends {
|
|
26
|
+
input: false;
|
|
27
|
+
} ? isClientSide extends true ? never : Schema : Schema;
|
|
28
|
+
type RemoveNeverProps<T> = {
|
|
29
|
+
[K in keyof T as [T[K]] extends [never] ? never : K]: T[K];
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PayvoAuthOptions } from "@gatwech/core";
|
|
2
|
+
import type { DBFieldAttribute } from "@gatwech/core/db";
|
|
3
|
+
import type { DBAdapter } from "@gatwech/core/db/adapter";
|
|
4
|
+
export declare function getAdapter(options: PayvoAuthOptions): Promise<DBAdapter<PayvoAuthOptions>>;
|
|
5
|
+
export declare function convertToDB<T extends Record<string, any>>(fields: Record<string, DBFieldAttribute>, values: T): T;
|
|
6
|
+
export declare function convertFromDB<T extends Record<string, any>>(fields: Record<string, DBFieldAttribute>, values: T | null): T | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PayvoAuthOptions } from "@gatwech/core";
|
|
2
|
+
import type { DBAdapter, Where } from "@gatwech/core/db/adapter";
|
|
3
|
+
export declare function getWithHooks(adapter: DBAdapter<PayvoAuthOptions>, ctx: {
|
|
4
|
+
options: PayvoAuthOptions;
|
|
5
|
+
hooks: Exclude<PayvoAuthOptions["databaseHooks"], undefined>[];
|
|
6
|
+
}): {
|
|
7
|
+
createWithHooks: <T extends Record<string, any>>(data: T, model: "session" | "user" | "account" | "verification", customCreateFn?: {
|
|
8
|
+
fn: (data: Record<string, any>) => void | Promise<any>;
|
|
9
|
+
executeMainFn?: boolean;
|
|
10
|
+
} | undefined) => Promise<any>;
|
|
11
|
+
updateWithHooks: <T extends Record<string, any>>(data: any, where: Where[], model: "session" | "user" | "account" | "verification", customUpdateFn?: {
|
|
12
|
+
fn: (data: Record<string, any>) => void | Promise<any>;
|
|
13
|
+
executeMainFn?: boolean;
|
|
14
|
+
} | undefined) => Promise<any>;
|
|
15
|
+
updateManyWithHooks: <T extends Record<string, any>>(data: any, where: Where[], model: "session" | "user" | "account" | "verification", customUpdateFn?: {
|
|
16
|
+
fn: (data: Record<string, any>) => void | Promise<any>;
|
|
17
|
+
executeMainFn?: boolean;
|
|
18
|
+
} | undefined) => Promise<any>;
|
|
19
|
+
deleteWithHooks: <T extends Record<string, any>>(where: Where[], model: "session" | "user" | "account" | "verification", customDeleteFn?: {
|
|
20
|
+
fn: (where: Where[]) => void | Promise<any>;
|
|
21
|
+
executeMainFn?: boolean;
|
|
22
|
+
} | undefined) => Promise<any>;
|
|
23
|
+
deleteManyWithHooks: <T extends Record<string, any>>(where: Where[], model: "session" | "user" | "account" | "verification", customDeleteFn?: {
|
|
24
|
+
fn: (where: Where[]) => void | Promise<any>;
|
|
25
|
+
executeMainFn?: boolean;
|
|
26
|
+
} | undefined) => Promise<any>;
|
|
27
|
+
};
|