@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,441 @@
|
|
|
1
|
+
import { t as getBaseURL } from "./url-VB2gAbTI.mjs";
|
|
2
|
+
import { t as parseJSON } from "./parser-DcrIEuXE.mjs";
|
|
3
|
+
import { BetterFetchError, createFetch } from "@better-fetch/fetch";
|
|
4
|
+
import { atom, onMount } from "nanostores";
|
|
5
|
+
|
|
6
|
+
//#region src/client/broadcast-channel.ts
|
|
7
|
+
const now$1 = () => Math.floor(Date.now() / 1e3);
|
|
8
|
+
function createBroadcastChannel(name = "payvo-auth.message") {
|
|
9
|
+
return {
|
|
10
|
+
receive(onReceive) {
|
|
11
|
+
const handler = (event) => {
|
|
12
|
+
if (event.key !== name) return;
|
|
13
|
+
const message = JSON.parse(event.newValue ?? "{}");
|
|
14
|
+
if (message?.event !== "session" || !message?.data) return;
|
|
15
|
+
onReceive(message);
|
|
16
|
+
};
|
|
17
|
+
window.addEventListener("storage", handler);
|
|
18
|
+
return () => window.removeEventListener("storage", handler);
|
|
19
|
+
},
|
|
20
|
+
post(message) {
|
|
21
|
+
if (typeof window === "undefined") return;
|
|
22
|
+
try {
|
|
23
|
+
localStorage.setItem(name, JSON.stringify({
|
|
24
|
+
...message,
|
|
25
|
+
timestamp: now$1()
|
|
26
|
+
}));
|
|
27
|
+
} catch {}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/client/query.ts
|
|
34
|
+
const isServer = typeof window === "undefined";
|
|
35
|
+
const useAuthQuery = (initializedAtom, path, $fetch, options) => {
|
|
36
|
+
const value = atom({
|
|
37
|
+
data: null,
|
|
38
|
+
error: null,
|
|
39
|
+
isPending: true,
|
|
40
|
+
isRefetching: false,
|
|
41
|
+
refetch: (queryParams) => {
|
|
42
|
+
return fn(queryParams);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const fn = (queryParams) => {
|
|
46
|
+
const opts = typeof options === "function" ? options({
|
|
47
|
+
data: value.get().data,
|
|
48
|
+
error: value.get().error,
|
|
49
|
+
isPending: value.get().isPending
|
|
50
|
+
}) : options;
|
|
51
|
+
$fetch(path, {
|
|
52
|
+
...opts,
|
|
53
|
+
query: {
|
|
54
|
+
...opts?.query,
|
|
55
|
+
...queryParams?.query
|
|
56
|
+
},
|
|
57
|
+
async onSuccess(context) {
|
|
58
|
+
value.set({
|
|
59
|
+
data: context.data,
|
|
60
|
+
error: null,
|
|
61
|
+
isPending: false,
|
|
62
|
+
isRefetching: false,
|
|
63
|
+
refetch: value.value.refetch
|
|
64
|
+
});
|
|
65
|
+
await opts?.onSuccess?.(context);
|
|
66
|
+
},
|
|
67
|
+
async onError(context) {
|
|
68
|
+
const { request } = context;
|
|
69
|
+
const retryAttempts = typeof request.retry === "number" ? request.retry : request.retry?.attempts;
|
|
70
|
+
const retryAttempt = request.retryAttempt || 0;
|
|
71
|
+
if (retryAttempts && retryAttempt < retryAttempts) return;
|
|
72
|
+
value.set({
|
|
73
|
+
error: context.error,
|
|
74
|
+
data: null,
|
|
75
|
+
isPending: false,
|
|
76
|
+
isRefetching: false,
|
|
77
|
+
refetch: value.value.refetch
|
|
78
|
+
});
|
|
79
|
+
await opts?.onError?.(context);
|
|
80
|
+
},
|
|
81
|
+
async onRequest(context) {
|
|
82
|
+
const currentValue = value.get();
|
|
83
|
+
value.set({
|
|
84
|
+
isPending: currentValue.data === null,
|
|
85
|
+
data: currentValue.data,
|
|
86
|
+
error: null,
|
|
87
|
+
isRefetching: true,
|
|
88
|
+
refetch: value.value.refetch
|
|
89
|
+
});
|
|
90
|
+
await opts?.onRequest?.(context);
|
|
91
|
+
}
|
|
92
|
+
}).catch((error) => {
|
|
93
|
+
value.set({
|
|
94
|
+
error,
|
|
95
|
+
data: null,
|
|
96
|
+
isPending: false,
|
|
97
|
+
isRefetching: false,
|
|
98
|
+
refetch: value.value.refetch
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
initializedAtom = Array.isArray(initializedAtom) ? initializedAtom : [initializedAtom];
|
|
103
|
+
let isMounted = false;
|
|
104
|
+
for (const initAtom of initializedAtom) initAtom.subscribe(() => {
|
|
105
|
+
if (isServer) return;
|
|
106
|
+
if (isMounted) fn();
|
|
107
|
+
else onMount(value, () => {
|
|
108
|
+
const timeoutId = setTimeout(() => {
|
|
109
|
+
if (!isMounted) {
|
|
110
|
+
fn();
|
|
111
|
+
isMounted = true;
|
|
112
|
+
}
|
|
113
|
+
}, 0);
|
|
114
|
+
return () => {
|
|
115
|
+
value.off();
|
|
116
|
+
initAtom.off();
|
|
117
|
+
clearTimeout(timeoutId);
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
return value;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/client/session-refresh.ts
|
|
126
|
+
const now = () => Math.floor(Date.now() / 1e3);
|
|
127
|
+
function createSessionRefreshManager(opts) {
|
|
128
|
+
const { sessionAtom, sessionSignal, options = {} } = opts;
|
|
129
|
+
const { refetchInterval = 0, refetchOnWindowFocus = true, refetchWhenOffline = false } = options?.sessionOptions || {};
|
|
130
|
+
const state = {
|
|
131
|
+
lastSync: 0,
|
|
132
|
+
cachedSession: void 0
|
|
133
|
+
};
|
|
134
|
+
let isOnline = typeof navigator !== "undefined" ? navigator.onLine : true;
|
|
135
|
+
const broadcast = createBroadcastChannel();
|
|
136
|
+
const shouldRefetch = () => {
|
|
137
|
+
if (typeof window === "undefined") return false;
|
|
138
|
+
return refetchWhenOffline || isOnline;
|
|
139
|
+
};
|
|
140
|
+
const triggerRefetch = (event) => {
|
|
141
|
+
if (!shouldRefetch()) return;
|
|
142
|
+
if (event?.event === "storage") {
|
|
143
|
+
state.lastSync = now();
|
|
144
|
+
sessionSignal.set(!sessionSignal.get());
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const currentSession = sessionAtom.get();
|
|
148
|
+
if (currentSession?.data === null || currentSession?.data === void 0 || event?.event === "poll" || event?.event === "visibilitychange") {
|
|
149
|
+
state.lastSync = now();
|
|
150
|
+
sessionSignal.set(!sessionSignal.get());
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const broadcastSessionUpdate = (trigger) => {
|
|
154
|
+
broadcast.post({
|
|
155
|
+
event: "session",
|
|
156
|
+
data: { trigger },
|
|
157
|
+
clientId: Math.random().toString(36).substring(7)
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
const setupPolling = () => {
|
|
161
|
+
if (refetchInterval && refetchInterval > 0) state.pollInterval = setInterval(() => {
|
|
162
|
+
if (sessionAtom.get()?.data) triggerRefetch({ event: "poll" });
|
|
163
|
+
}, refetchInterval * 1e3);
|
|
164
|
+
};
|
|
165
|
+
const setupBroadcast = () => {
|
|
166
|
+
state.unsubscribeBroadcast = broadcast.receive(() => {
|
|
167
|
+
triggerRefetch({ event: "storage" });
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
const setupVisibilityChange = () => {
|
|
171
|
+
if (!refetchOnWindowFocus) return;
|
|
172
|
+
if (typeof document === "undefined") return;
|
|
173
|
+
const visibilityHandler = () => {
|
|
174
|
+
if (document.visibilityState === "visible") triggerRefetch({ event: "visibilitychange" });
|
|
175
|
+
};
|
|
176
|
+
document.addEventListener("visibilitychange", visibilityHandler, false);
|
|
177
|
+
state.unsubscribeVisibility = () => {
|
|
178
|
+
document.removeEventListener("visibilitychange", visibilityHandler, false);
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
const setupOnlineDetection = () => {
|
|
182
|
+
if (typeof window === "undefined") return;
|
|
183
|
+
const setOnline = () => {
|
|
184
|
+
isOnline = true;
|
|
185
|
+
triggerRefetch({ event: "visibilitychange" });
|
|
186
|
+
};
|
|
187
|
+
const setOffline = () => {
|
|
188
|
+
isOnline = false;
|
|
189
|
+
};
|
|
190
|
+
window.addEventListener("online", setOnline);
|
|
191
|
+
window.addEventListener("offline", setOffline);
|
|
192
|
+
state.unsubscribeOnline = () => window.removeEventListener("online", setOnline);
|
|
193
|
+
state.unsubscribeOffline = () => window.removeEventListener("offline", setOffline);
|
|
194
|
+
};
|
|
195
|
+
const init = () => {
|
|
196
|
+
if (typeof window === "undefined") return;
|
|
197
|
+
setupPolling();
|
|
198
|
+
setupBroadcast();
|
|
199
|
+
setupVisibilityChange();
|
|
200
|
+
setupOnlineDetection();
|
|
201
|
+
};
|
|
202
|
+
const cleanup = () => {
|
|
203
|
+
if (state.pollInterval) {
|
|
204
|
+
clearInterval(state.pollInterval);
|
|
205
|
+
state.pollInterval = void 0;
|
|
206
|
+
}
|
|
207
|
+
if (state.unsubscribeBroadcast) {
|
|
208
|
+
state.unsubscribeBroadcast();
|
|
209
|
+
state.unsubscribeBroadcast = void 0;
|
|
210
|
+
}
|
|
211
|
+
if (state.unsubscribeVisibility) {
|
|
212
|
+
state.unsubscribeVisibility();
|
|
213
|
+
state.unsubscribeVisibility = void 0;
|
|
214
|
+
}
|
|
215
|
+
if (state.unsubscribeOnline) {
|
|
216
|
+
state.unsubscribeOnline();
|
|
217
|
+
state.unsubscribeOnline = void 0;
|
|
218
|
+
}
|
|
219
|
+
if (state.unsubscribeOffline) {
|
|
220
|
+
state.unsubscribeOffline();
|
|
221
|
+
state.unsubscribeOffline = void 0;
|
|
222
|
+
}
|
|
223
|
+
state.lastSync = 0;
|
|
224
|
+
state.cachedSession = void 0;
|
|
225
|
+
};
|
|
226
|
+
return {
|
|
227
|
+
init,
|
|
228
|
+
cleanup,
|
|
229
|
+
triggerRefetch,
|
|
230
|
+
broadcastSessionUpdate
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/client/fetch-plugins.ts
|
|
236
|
+
const redirectPlugin = {
|
|
237
|
+
id: "redirect",
|
|
238
|
+
name: "Redirect",
|
|
239
|
+
hooks: { onSuccess(context) {
|
|
240
|
+
if (context.data?.url && context.data?.redirect) {
|
|
241
|
+
if (typeof window !== "undefined" && window.location) {
|
|
242
|
+
if (window.location) try {
|
|
243
|
+
window.location.href = context.data.url;
|
|
244
|
+
} catch {}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
} }
|
|
248
|
+
};
|
|
249
|
+
const userAgentPlugin = {
|
|
250
|
+
id: "user-agent",
|
|
251
|
+
name: "UserAgent",
|
|
252
|
+
hooks: { onRequest(context) {
|
|
253
|
+
context.headers.append("user-agent", "payvo-auth");
|
|
254
|
+
} }
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/client/session-atom.ts
|
|
259
|
+
function getSessionAtom($fetch, options) {
|
|
260
|
+
const $signal = atom(false);
|
|
261
|
+
const session = useAuthQuery($signal, "/get-session", $fetch, { method: "GET" });
|
|
262
|
+
if (typeof window !== "undefined") onMount(session, () => {
|
|
263
|
+
const refreshManager = createSessionRefreshManager({
|
|
264
|
+
sessionAtom: session,
|
|
265
|
+
sessionSignal: $signal,
|
|
266
|
+
$fetch,
|
|
267
|
+
options
|
|
268
|
+
});
|
|
269
|
+
refreshManager.init();
|
|
270
|
+
return () => {
|
|
271
|
+
refreshManager.cleanup();
|
|
272
|
+
};
|
|
273
|
+
});
|
|
274
|
+
return {
|
|
275
|
+
session,
|
|
276
|
+
$sessionSignal: $signal
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/client/config.ts
|
|
282
|
+
const getClientConfig = (options, loadEnv) => {
|
|
283
|
+
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
284
|
+
const baseURL = getBaseURL(options?.baseURL, options?.basePath, void 0, loadEnv) ?? "/api/auth";
|
|
285
|
+
const pluginsFetchPlugins = options?.plugins?.flatMap((plugin) => plugin.fetchPlugins).filter((pl) => pl !== void 0) || [];
|
|
286
|
+
const lifeCyclePlugin = {
|
|
287
|
+
id: "lifecycle-hooks",
|
|
288
|
+
name: "lifecycle-hooks",
|
|
289
|
+
hooks: {
|
|
290
|
+
onSuccess: options?.fetchOptions?.onSuccess,
|
|
291
|
+
onError: options?.fetchOptions?.onError,
|
|
292
|
+
onRequest: options?.fetchOptions?.onRequest,
|
|
293
|
+
onResponse: options?.fetchOptions?.onResponse
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
const { onSuccess, onError, onRequest, onResponse,...restOfFetchOptions } = options?.fetchOptions || {};
|
|
297
|
+
const $fetch = createFetch({
|
|
298
|
+
baseURL,
|
|
299
|
+
...isCredentialsSupported ? { credentials: "include" } : {},
|
|
300
|
+
method: "GET",
|
|
301
|
+
jsonParser(text) {
|
|
302
|
+
if (!text) return null;
|
|
303
|
+
return parseJSON(text, { strict: false });
|
|
304
|
+
},
|
|
305
|
+
customFetchImpl: fetch,
|
|
306
|
+
...restOfFetchOptions,
|
|
307
|
+
plugins: [
|
|
308
|
+
lifeCyclePlugin,
|
|
309
|
+
userAgentPlugin,
|
|
310
|
+
...restOfFetchOptions.plugins || [],
|
|
311
|
+
...options?.disableDefaultFetchPlugins ? [] : [redirectPlugin],
|
|
312
|
+
...pluginsFetchPlugins
|
|
313
|
+
]
|
|
314
|
+
});
|
|
315
|
+
const { $sessionSignal, session } = getSessionAtom($fetch, options);
|
|
316
|
+
const plugins = options?.plugins || [];
|
|
317
|
+
let pluginsActions = {};
|
|
318
|
+
let pluginsAtoms = {
|
|
319
|
+
$sessionSignal,
|
|
320
|
+
session
|
|
321
|
+
};
|
|
322
|
+
let pluginPathMethods = {
|
|
323
|
+
"/sign-out": "POST",
|
|
324
|
+
"/revoke-sessions": "POST",
|
|
325
|
+
"/revoke-other-sessions": "POST",
|
|
326
|
+
"/delete-user": "POST"
|
|
327
|
+
};
|
|
328
|
+
const atomListeners = [{
|
|
329
|
+
signal: "$sessionSignal",
|
|
330
|
+
matcher(path) {
|
|
331
|
+
return path === "/sign-out" || path === "/update-user" || path.startsWith("/sign-in") || path.startsWith("/sign-up") || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session";
|
|
332
|
+
}
|
|
333
|
+
}];
|
|
334
|
+
for (const plugin of plugins) {
|
|
335
|
+
if (plugin.getAtoms) Object.assign(pluginsAtoms, plugin.getAtoms?.($fetch));
|
|
336
|
+
if (plugin.pathMethods) Object.assign(pluginPathMethods, plugin.pathMethods);
|
|
337
|
+
if (plugin.atomListeners) atomListeners.push(...plugin.atomListeners);
|
|
338
|
+
}
|
|
339
|
+
const $store = {
|
|
340
|
+
notify: (signal) => {
|
|
341
|
+
pluginsAtoms[signal].set(!pluginsAtoms[signal].get());
|
|
342
|
+
},
|
|
343
|
+
listen: (signal, listener) => {
|
|
344
|
+
pluginsAtoms[signal].subscribe(listener);
|
|
345
|
+
},
|
|
346
|
+
atoms: pluginsAtoms
|
|
347
|
+
};
|
|
348
|
+
for (const plugin of plugins) if (plugin.getActions) Object.assign(pluginsActions, plugin.getActions?.($fetch, $store, options));
|
|
349
|
+
return {
|
|
350
|
+
get baseURL() {
|
|
351
|
+
return baseURL;
|
|
352
|
+
},
|
|
353
|
+
pluginsActions,
|
|
354
|
+
pluginsAtoms,
|
|
355
|
+
pluginPathMethods,
|
|
356
|
+
atomListeners,
|
|
357
|
+
$fetch,
|
|
358
|
+
$store
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/utils/is-atom.ts
|
|
364
|
+
function isAtom(value) {
|
|
365
|
+
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region src/client/proxy.ts
|
|
370
|
+
function getMethod(path, knownPathMethods, args) {
|
|
371
|
+
const method = knownPathMethods[path];
|
|
372
|
+
const { fetchOptions, query,...body } = args || {};
|
|
373
|
+
if (method) return method;
|
|
374
|
+
if (fetchOptions?.method) return fetchOptions.method;
|
|
375
|
+
if (body && Object.keys(body).length > 0) return "POST";
|
|
376
|
+
return "GET";
|
|
377
|
+
}
|
|
378
|
+
function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomListeners) {
|
|
379
|
+
function createProxy(path = []) {
|
|
380
|
+
return new Proxy(function() {}, {
|
|
381
|
+
get(_, prop) {
|
|
382
|
+
if (typeof prop !== "string") return;
|
|
383
|
+
if (prop === "then" || prop === "catch" || prop === "finally") return;
|
|
384
|
+
const fullPath = [...path, prop];
|
|
385
|
+
let current = routes;
|
|
386
|
+
for (const segment of fullPath) if (current && typeof current === "object" && segment in current) current = current[segment];
|
|
387
|
+
else {
|
|
388
|
+
current = void 0;
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
if (typeof current === "function") return current;
|
|
392
|
+
if (isAtom(current)) return current;
|
|
393
|
+
return createProxy(fullPath);
|
|
394
|
+
},
|
|
395
|
+
apply: async (_, __, args) => {
|
|
396
|
+
const routePath = "/" + path.map((segment) => segment.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)).join("/");
|
|
397
|
+
const arg = args[0] || {};
|
|
398
|
+
const fetchOptions = args[1] || {};
|
|
399
|
+
const { query, fetchOptions: argFetchOptions,...body } = arg;
|
|
400
|
+
const options = {
|
|
401
|
+
...fetchOptions,
|
|
402
|
+
...argFetchOptions
|
|
403
|
+
};
|
|
404
|
+
const method = getMethod(routePath, knownPathMethods, arg);
|
|
405
|
+
return await client(routePath, {
|
|
406
|
+
...options,
|
|
407
|
+
body: method === "GET" ? void 0 : {
|
|
408
|
+
...body,
|
|
409
|
+
...options?.body || {}
|
|
410
|
+
},
|
|
411
|
+
query: query || options?.query,
|
|
412
|
+
method,
|
|
413
|
+
async onSuccess(context) {
|
|
414
|
+
await options?.onSuccess?.(context);
|
|
415
|
+
if (!atomListeners) return;
|
|
416
|
+
/**
|
|
417
|
+
* We trigger listeners
|
|
418
|
+
*/
|
|
419
|
+
const matches = atomListeners.filter((s) => s.matcher(routePath));
|
|
420
|
+
if (!matches.length) return;
|
|
421
|
+
for (const match of matches) {
|
|
422
|
+
const signal = atoms[match.signal];
|
|
423
|
+
if (!signal) return;
|
|
424
|
+
/**
|
|
425
|
+
* To avoid race conditions we set the signal in a setTimeout
|
|
426
|
+
*/
|
|
427
|
+
const val = signal.get();
|
|
428
|
+
setTimeout(() => {
|
|
429
|
+
signal.set(!val);
|
|
430
|
+
}, 10);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
return createProxy();
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
//#endregion
|
|
441
|
+
export { createBroadcastChannel as a, useAuthQuery as i, getClientConfig as n, createSessionRefreshManager as r, createDynamicPathProxy as t };
|