@gatwech/auth 1.0.0-beta.18 → 1.0.0-beta.20
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 +8 -14
- package/dist/{access-C6O_osEz.mjs → access-CrwEFPHE.mjs} +1 -1
- package/dist/{access-DT1f6l5k.mjs → access-bhklJd7m.mjs} +1 -1
- package/dist/{adapter-factory-BZ2Qiqpn.mjs → adapter-factory-xbLUJt85.mjs} +2 -2
- package/dist/adapters/drizzle-adapter/index.mjs +6 -5
- package/dist/adapters/index.d.mts +5 -5
- package/dist/adapters/index.mjs +6 -5
- package/dist/adapters/kysely-adapter/index.d.mts +1 -1
- package/dist/adapters/kysely-adapter/index.mjs +8 -7
- package/dist/adapters/memory-adapter/index.d.mts +1 -1
- package/dist/adapters/memory-adapter/index.mjs +6 -5
- package/dist/adapters/mongodb-adapter/index.mjs +6 -5
- package/dist/adapters/prisma-adapter/index.mjs +6 -5
- package/dist/adapters/test.mjs +4 -3
- package/dist/{admin-Bcq53Nwj.mjs → admin-BzUJL6tr.mjs} +6 -6
- package/dist/{anonymous-CRt1imBW.mjs → anonymous-BjlTk4gl.mjs} +5 -5
- package/dist/api/index.d.mts +5 -5
- package/dist/api/index.mjs +12 -11
- package/dist/{api-0pR_I-Nx.mjs → api-Dk8Yj_J5.mjs} +15 -5
- package/dist/audit-log-DKsUWR8O.mjs +772 -0
- package/dist/{auth-CBUoBX6o.mjs → auth-vfCyIIeV.mjs} +8 -8
- package/dist/{bearer-Djf_awfo.mjs → bearer-DvQLM00l.mjs} +2 -2
- package/dist/client/index.d.mts +19 -19
- package/dist/client/index.mjs +4 -4
- package/dist/client/plugins/index.d.mts +42 -34
- package/dist/client/plugins/index.mjs +16 -12
- package/dist/client/react/index.d.mts +5 -5
- package/dist/client/react/index.mjs +2 -2
- package/dist/client-4QEb0rUr.mjs +95 -0
- package/dist/client-C_qmyez2.d.mts +75 -0
- package/dist/client-DzOqXJUm.mjs +15 -0
- package/dist/client-F67q-Lbi.d.mts +14 -0
- package/dist/{client-aExCkfwm.mjs → client-xga7yFIX.mjs} +2 -2
- package/dist/cookies/index.d.mts +6 -6
- package/dist/cookies/index.mjs +2 -2
- package/dist/{cookies-cJObLwn1.mjs → cookies-BuvlgcA-.mjs} +1 -1
- package/dist/crypto/index.mjs +2 -1
- package/dist/{crypto-Bb42eMrH.mjs → crypto-CCyta8xj.mjs} +1 -6
- package/dist/{custom-session-L3t7ecsd.mjs → custom-session-DN_-pfi_.mjs} +2 -2
- package/dist/db/index.d.mts +5 -5
- package/dist/db/index.mjs +9 -8
- package/dist/{db-BrstmDhc.mjs → db-7vHnL1XA.mjs} +15 -9
- package/dist/{device-authorization-V4s3h4Mj.mjs → device-authorization-BKnNhlsz.mjs} +4 -4
- package/dist/{dialect-CeddeGHf.mjs → dialect-HsWUfpYY.mjs} +2 -2
- package/dist/{email-otp-BtDHSw14.mjs → email-otp-Dw0DypjQ.mjs} +7 -6
- package/dist/{generic-oauth-CL5X27ZI.mjs → generic-oauth-DFj27JY8.mjs} +4 -4
- package/dist/{has-permission-BpAr7uCn.mjs → has-permission-Bvg8de8g.mjs} +1 -1
- package/dist/{haveibeenpwned-cMpJvmzI.mjs → haveibeenpwned-CzNda7Tn.mjs} +28 -15
- package/dist/{index-BYMI9r_d.d.mts → index-4I1YhYhk.d.mts} +4 -4
- package/dist/{index-Cxi7TbLE.d.mts → index-BNhJglHC.d.mts} +122 -122
- package/dist/{index-DlaMq1nb.d.mts → index-BX7rl07Z.d.mts} +14 -14
- package/dist/{client-BOX93C3d.d.mts → index-Bml-PCqP.d.mts} +52 -52
- package/dist/{index-zjjNBRY2.d.mts → index-BsSKcKgO.d.mts} +6 -6
- package/dist/{index-Buhn3hkR.d.mts → index-CBiGsvDd.d.mts} +8 -8
- package/dist/{index-D_k662QG.d.mts → index-CC920PPp.d.mts} +14 -14
- package/dist/{index-B3n8e37d.d.mts → index-CNd5jqLl.d.mts} +7 -7
- package/dist/{index-BqhKCbPH.d.mts → index-CP8x1TFq.d.mts} +6 -6
- package/dist/{index-DKNNV1kb.d.mts → index-CofuaNMl.d.mts} +8 -8
- package/dist/{index-DR0xXno9.d.mts → index-CsxtcAO0.d.mts} +1 -1
- package/dist/{index-C7fQuk-V.d.mts → index-CxlWnL9c.d.mts} +1 -1
- package/dist/{index-CuFzhoS6.d.mts → index-CzpdkTdv.d.mts} +10 -10
- package/dist/index-D57DuhZR.d.mts +3769 -0
- package/dist/{index-C-u1h_WX.d.mts → index-D6ku0rUC.d.mts} +5 -5
- package/dist/{client-CNY0tn9g.d.mts → index-DFSRYWFI.d.mts} +21 -21
- package/dist/{index-BBm8nQ9Q.d.mts → index-DGeoJ4gu.d.mts} +2 -2
- package/dist/{index-G6V0Z_Mn.d.mts → index-DTkcY7xH.d.mts} +10 -10
- package/dist/{index-65G5U5DB-DSdjzreF.d.mts → index-Df0KhQRf-BEa5tdwJ.d.mts} +3 -2
- package/dist/{index-34ONrP8l.d.mts → index-Dnd8S4S4.d.mts} +11 -11
- package/dist/{index-B-XKqFvY.d.mts → index-DwPAddfE.d.mts} +11 -4
- package/dist/{index-DoXZYQpq.d.mts → index-DyXi7S2M.d.mts} +10 -10
- package/dist/{index-BHoQlf7a.d.mts → index-KhbNmMmG.d.mts} +178 -178
- package/dist/{index-z0KSvE5i.d.mts → index-QmocqGM-.d.mts} +1 -1
- package/dist/{admin-DtfO1PLg.d.mts → index-XfE0WjTN.d.mts} +36 -36
- package/dist/{index-DaBcikv9.d.mts → index-sb-UFLuo.d.mts} +2 -2
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +16 -15
- package/dist/integrations/next-js.d.mts +4 -4
- package/dist/integrations/next-js.mjs +2 -2
- package/dist/integrations/node.d.mts +5 -5
- package/dist/integrations/react-start.d.mts +4 -4
- package/dist/integrations/react-start.mjs +2 -2
- package/dist/{jwt-lHV4QHpD.mjs → jwt-DBN2mu0r.mjs} +4 -4
- package/dist/{kysely-adapter-DpzYO8Yf.mjs → kysely-adapter-Bkm1liPW.mjs} +1 -1
- package/dist/{magic-link-Bk-ueorR.mjs → magic-link-D9Em1aOR.mjs} +3 -3
- package/dist/{multi-session-DRrLKrg9.mjs → multi-session-Dno_8DxC.mjs} +5 -5
- package/dist/{oauth-proxy-D1sWh9B_.mjs → oauth-proxy-DW-zt8wv.mjs} +2 -2
- package/dist/oauth2/index.d.mts +5 -5
- package/dist/oauth2/index.mjs +12 -11
- package/dist/{one-tap-DMswkTEc.mjs → one-tap-CodeyQb8.mjs} +2 -2
- package/dist/{organization-BArHO_5v.mjs → organization-CkTKs7bx.mjs} +9 -9
- package/dist/{passkey-CcD4CnhM.mjs → passkey-JNQTz5a0.mjs} +5 -5
- package/dist/{phone-number-rHDIlh-2.mjs → phone-number-Dqz8aeyF.mjs} +4 -4
- package/dist/plugins/access/index.d.mts +2 -2
- package/dist/plugins/access/index.mjs +1 -1
- package/dist/plugins/admin/access/index.d.mts +2 -2
- package/dist/plugins/admin/access/index.mjs +2 -2
- package/dist/plugins/admin/index.d.mts +7 -8
- package/dist/plugins/admin/index.mjs +17 -16
- package/dist/plugins/anonymous/index.d.mts +6 -6
- package/dist/plugins/anonymous/index.mjs +13 -12
- package/dist/plugins/audit-log/client.d.mts +30 -0
- package/dist/plugins/audit-log/client.mjs +3 -0
- package/dist/plugins/audit-log/index.d.mts +29 -0
- package/dist/plugins/audit-log/index.mjs +20 -0
- package/dist/plugins/bearer/index.d.mts +1 -1
- package/dist/plugins/bearer/index.mjs +3 -3
- package/dist/plugins/captcha/index.d.mts +1 -1
- package/dist/plugins/captcha/index.mjs +1 -1
- package/dist/plugins/custom-session/index.d.mts +6 -6
- package/dist/plugins/custom-session/index.mjs +14 -13
- package/dist/plugins/device-authorization/index.d.mts +3 -3
- package/dist/plugins/device-authorization/index.mjs +13 -12
- package/dist/plugins/email-otp/index.d.mts +2 -2
- package/dist/plugins/email-otp/index.mjs +14 -13
- package/dist/plugins/generic-oauth/index.d.mts +6 -6
- package/dist/plugins/generic-oauth/index.mjs +13 -12
- package/dist/plugins/haveibeenpwned/index.d.mts +2 -2
- package/dist/plugins/haveibeenpwned/index.mjs +14 -13
- package/dist/plugins/index.d.mts +29 -139
- package/dist/plugins/index.mjs +47 -42
- package/dist/plugins/jwt/index.d.mts +6 -6
- package/dist/plugins/jwt/index.mjs +13 -12
- package/dist/plugins/magic-link/index.d.mts +1 -1
- package/dist/plugins/magic-link/index.mjs +13 -12
- package/dist/plugins/multi-session/index.d.mts +2 -2
- package/dist/plugins/multi-session/index.mjs +13 -12
- package/dist/plugins/oauth-proxy/index.d.mts +1 -1
- package/dist/plugins/oauth-proxy/index.mjs +13 -12
- package/dist/plugins/one-tap/index.d.mts +1 -1
- package/dist/plugins/one-tap/index.mjs +13 -12
- package/dist/plugins/one-time-token/index.d.mts +6 -6
- package/dist/plugins/one-time-token/index.mjs +46 -41
- package/dist/plugins/organization/access/index.d.mts +3 -3
- package/dist/plugins/organization/access/index.mjs +2 -2
- package/dist/plugins/organization/index.d.mts +8 -8
- package/dist/plugins/organization/index.mjs +17 -16
- package/dist/plugins/passkey/index.d.mts +6 -6
- package/dist/plugins/passkey/index.mjs +13 -12
- package/dist/plugins/phone-number/index.d.mts +6 -6
- package/dist/plugins/phone-number/index.mjs +13 -12
- package/dist/plugins/sentinel/client.d.mts +30 -0
- package/dist/plugins/sentinel/client.mjs +5 -0
- package/dist/plugins/sentinel/index.d.mts +29 -0
- package/dist/plugins/sentinel/index.mjs +22 -0
- package/dist/plugins/two-factor/index.d.mts +6 -6
- package/dist/plugins/two-factor/index.mjs +15 -14
- package/dist/plugins/username/index.d.mts +3 -3
- package/dist/plugins/username/index.mjs +13 -12
- package/dist/{plugins-hFZT3hmK.d.mts → plugins-Dy_FrD4Y.d.mts} +1 -1
- package/dist/{plugins-3jfNste3.mjs → plugins-yF8CFUDR.mjs} +11 -8
- package/dist/pow-OK01yPG3.mjs +61 -0
- package/dist/{proxy-CL9PZXJA.mjs → proxy-C_KXfOhk.mjs} +1 -1
- package/dist/random-32E3cU5o.mjs +7 -0
- package/dist/registry-CqG_3Qnx.mjs +194 -0
- package/dist/sentinel-DiPqydKG.mjs +1426 -0
- package/dist/{session-Dgp133Yt.mjs → session-BB3oqApE.mjs} +2 -2
- package/dist/src/adapters/memory-adapter/memory-adapter.d.ts +1 -1
- package/dist/src/adapters/prisma-adapter/test/auth.d.ts +1 -1
- package/dist/src/adapters/tests/auth-flow.d.ts +3 -3
- package/dist/src/adapters/tests/normal.d.ts +1 -1
- package/dist/src/adapters/tests/number-id.d.ts +3 -3
- package/dist/src/adapters/tests/performance.d.ts +3 -3
- package/dist/src/adapters/tests/transactions.d.ts +3 -3
- package/dist/src/api/index.d.ts +8 -8
- package/dist/src/client/plugins/index.d.ts +2 -0
- package/dist/src/plugins/admin/admin.d.ts +2 -2
- package/dist/src/plugins/api-key/index.d.ts +2 -2
- package/dist/src/plugins/audit-log/client.d.ts +10 -0
- package/dist/src/plugins/audit-log/events.d.ts +90 -0
- package/dist/src/plugins/audit-log/index.d.ts +614 -0
- package/dist/src/plugins/audit-log/registry.d.ts +13 -0
- package/dist/src/plugins/audit-log/remote.d.ts +34 -0
- package/dist/src/plugins/audit-log/schema.d.ts +50 -0
- package/dist/src/plugins/audit-log/types.d.ts +117 -0
- package/dist/src/plugins/email-otp/index.d.ts +1 -1
- package/dist/src/plugins/haveibeenpwned/index.d.ts +6 -0
- package/dist/src/plugins/index.d.ts +2 -0
- package/dist/src/plugins/multi-session/index.d.ts +8 -8
- package/dist/src/plugins/organization/organization.d.ts +5 -5
- package/dist/src/plugins/organization/routes/crud-access-control.d.ts +8 -8
- package/dist/src/plugins/organization/routes/crud-invites.d.ts +46 -46
- package/dist/src/plugins/organization/routes/crud-members.d.ts +40 -40
- package/dist/src/plugins/organization/routes/crud-org.d.ts +36 -36
- package/dist/src/plugins/organization/routes/crud-team.d.ts +50 -50
- package/dist/src/plugins/sentinel/actions.d.ts +64 -0
- package/dist/src/plugins/sentinel/client.d.ts +67 -0
- package/dist/src/plugins/sentinel/email.d.ts +28 -0
- package/dist/src/plugins/sentinel/geo.d.ts +22 -0
- package/dist/src/plugins/sentinel/index.d.ts +326 -0
- package/dist/src/plugins/sentinel/intel.d.ts +45 -0
- package/dist/src/plugins/sentinel/pow.d.ts +21 -0
- package/dist/src/plugins/sentinel/schema.d.ts +110 -0
- package/dist/src/plugins/sentinel/store.d.ts +37 -0
- package/dist/src/plugins/sentinel/types.d.ts +412 -0
- package/dist/src/test-utils/memory-secondary-storage.d.ts +16 -0
- package/dist/src/test-utils/password.d.ts +12 -0
- package/dist/src/test-utils/test-instance.d.ts +25 -25
- package/dist/test-utils/index.d.mts +293 -293
- package/dist/test-utils/index.mjs +53 -48
- package/dist/{two-factor-ClUXxom2.mjs → two-factor-CDVjxx4f.mjs} +6 -5
- package/dist/types/index.d.mts +5 -5
- package/dist/types/index.mjs +1 -1
- package/dist/{username-DiGklOGl.mjs → username-BHNvcvsY.mjs} +3 -3
- package/dist/{utils-SOMB4Px5.mjs → utils-B03WRaGi.mjs} +2 -1
- package/package.json +36 -3
- package/dist/index-CM-CFWwr.d.mts +0 -1919
- package/dist/index-DB7t8whN.d.mts +0 -1
- /package/dist/{access-BO2g7QVe.mjs → access-BM6jSA5j.mjs} +0 -0
- /package/dist/{bun-sqlite-dialect-CeNvMaZz.mjs → bun-sqlite-dialect-CDGusFqF.mjs} +0 -0
- /package/dist/{captcha-BqaMxlKC.mjs → captcha-DGP9lCRe.mjs} +0 -0
- /package/dist/{client-CygJhqeB.mjs → client-BuveH3MN.mjs} +0 -0
- /package/dist/{client-WiN43tAS.mjs → client-cBiytuOL.mjs} +0 -0
- /package/dist/{date-Cx2yCiC4.mjs → date-CMr04reD.mjs} +0 -0
- /package/dist/{esm-C-QicDNz.mjs → esm-BbvI87Z2.mjs} +0 -0
- /package/dist/{get-tables-BQP7YW9c.mjs → get-tables-CKvSyDST.mjs} +0 -0
- /package/dist/{helper-tmxW3BHj.d.mts → helper-BgOIGHsu.d.mts} +0 -0
- /package/dist/{misc-beA1w3XV.mjs → misc-fKH4d5XQ.mjs} +0 -0
- /package/dist/{node-sqlite-dialect-BcKxBQnm.mjs → node-sqlite-dialect-CIOjcg31.mjs} +0 -0
- /package/dist/{parser-DcrIEuXE.mjs → parser-D7EkhAjZ.mjs} +0 -0
- /package/dist/{password-sVC4nePO.mjs → password-5CdcAVaH.mjs} +0 -0
- /package/dist/{permission-DLYUF3cW.mjs → permission-CDDWgA_O.mjs} +0 -0
- /package/dist/{plugin-helper-4L-lzsjZ.mjs → plugin-helper-RJJBTOba.mjs} +0 -0
- /package/dist/{promise-8rrEHRXd.mjs → promise-D7Oo6_cY.mjs} +0 -0
- /package/dist/{types-Bjn15Uy6.mjs → types-DCPpFKUB.mjs} +0 -0
- /package/dist/{types-B1OL7hyf.d.mts → types-DNQ9XQrB.d.mts} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { t as generateId } from "./utils-
|
|
1
|
+
import { t as generateId } from "./utils-B03WRaGi.mjs";
|
|
2
2
|
import { r as getOrigin, t as getBaseURL } from "./url-VB2gAbTI.mjs";
|
|
3
|
-
import { a as getEndpoints, n as checkEndpointConflicts, s as router } from "./api-
|
|
4
|
-
import {
|
|
5
|
-
import { i as getCookies, t as createCookieGetter } from "./cookies-
|
|
6
|
-
import { a as createInternalAdapter, r as getAdapter, s as getMigrations } from "./db-
|
|
7
|
-
import { n as getKyselyDatabaseType } from "./dialect-
|
|
8
|
-
import { t as getAuthTables } from "./get-tables-
|
|
9
|
-
import { t as checkPassword } from "./password-
|
|
3
|
+
import { a as getEndpoints, n as checkEndpointConflicts, s as router } from "./api-Dk8Yj_J5.mjs";
|
|
4
|
+
import { i as verifyPassword, r as hashPassword } from "./crypto-CCyta8xj.mjs";
|
|
5
|
+
import { i as getCookies, t as createCookieGetter } from "./cookies-BuvlgcA-.mjs";
|
|
6
|
+
import { a as createInternalAdapter, r as getAdapter, s as getMigrations } from "./db-7vHnL1XA.mjs";
|
|
7
|
+
import { n as getKyselyDatabaseType } from "./dialect-HsWUfpYY.mjs";
|
|
8
|
+
import { t as getAuthTables } from "./get-tables-CKvSyDST.mjs";
|
|
9
|
+
import { t as checkPassword } from "./password-5CdcAVaH.mjs";
|
|
10
10
|
import { runWithAdapter } from "@gatwech/core/context";
|
|
11
11
|
import { createLogger, env, isProduction, isTest } from "@gatwech/core/env";
|
|
12
12
|
import { BASE_ERROR_CODES, PayvoAuthError } from "@gatwech/core/error";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as parseSetCookieHeader } from "./cookies-
|
|
1
|
+
import { l as parseSetCookieHeader } from "./cookies-BuvlgcA-.mjs";
|
|
2
2
|
import { serializeSignedCookie } from "better-call";
|
|
3
3
|
import { createAuthMiddleware } from "@gatwech/core/api";
|
|
4
4
|
import { createHMAC } from "@gatwech/utils/hmac";
|
|
@@ -26,7 +26,7 @@ const bearer = (options) => {
|
|
|
26
26
|
}
|
|
27
27
|
try {
|
|
28
28
|
const decodedToken = decodeURIComponent(signedToken);
|
|
29
|
-
if (!await createHMAC("SHA-256", "
|
|
29
|
+
if (!await createHMAC("SHA-256", "base64").verify(c.context.secret, decodedToken.split(".")[0], decodedToken.split(".")[1])) return;
|
|
30
30
|
} catch (e) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
package/dist/client/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { d as PrettifyDeep, h as UnionToIntersection } from "../helper-
|
|
2
|
-
import { B as InferPluginsFromClient, F as ClientStore, G as PayvoAuthClientPlugin, H as InferUserFromClient, I as InferActions, K as SessionQueryParams, L as InferAdditionalFromClient, M as AtomListener, N as ClientAtomListener, P as ClientOptions, R as InferClientAPI, U as IsSignal, V as InferSessionFromClient, W as PayvoAuthClientOptions, q as Store, z as InferErrorCodes } from "../index-
|
|
3
|
-
import "../types-
|
|
4
|
-
import "../index-
|
|
5
|
-
import "../plugins-
|
|
1
|
+
import { d as PrettifyDeep, h as UnionToIntersection } from "../helper-BgOIGHsu.mjs";
|
|
2
|
+
import { B as InferPluginsFromClient, F as ClientStore, G as PayvoAuthClientPlugin, H as InferUserFromClient, I as InferActions, K as SessionQueryParams, L as InferAdditionalFromClient, M as AtomListener, N as ClientAtomListener, P as ClientOptions, R as InferClientAPI, U as IsSignal, V as InferSessionFromClient, W as PayvoAuthClientOptions, q as Store, z as InferErrorCodes } from "../index-BNhJglHC.mjs";
|
|
3
|
+
import "../types-DNQ9XQrB.mjs";
|
|
4
|
+
import "../index-Df0KhQRf-BEa5tdwJ.mjs";
|
|
5
|
+
import "../plugins-Dy_FrD4Y.mjs";
|
|
6
6
|
import { PayvoAuthClientOptions as PayvoAuthClientOptions$1, PayvoAuthClientPlugin as PayvoAuthClientPlugin$1, PayvoAuthOptions, PayvoAuthPlugin } from "@gatwech/core";
|
|
7
7
|
import { BASE_ERROR_CODES } from "@gatwech/core/error";
|
|
8
|
-
import * as
|
|
8
|
+
import * as _better_fetch_fetch20 from "@better-fetch/fetch";
|
|
9
9
|
import { BetterFetch, BetterFetchError, BetterFetchOption } from "@better-fetch/fetch";
|
|
10
10
|
import * as nanostores0 from "nanostores";
|
|
11
11
|
import { Atom, PreinitializedWritableAtom, WritableAtom } from "nanostores";
|
|
@@ -79,27 +79,27 @@ declare function createAuthClient<Option extends PayvoAuthClientOptions$1>(optio
|
|
|
79
79
|
error: BetterFetchError | null;
|
|
80
80
|
isPending: boolean;
|
|
81
81
|
}>;
|
|
82
|
-
$fetch:
|
|
83
|
-
plugins: (
|
|
82
|
+
$fetch: _better_fetch_fetch20.BetterFetch<{
|
|
83
|
+
plugins: (_better_fetch_fetch20.BetterFetchPlugin | {
|
|
84
84
|
id: string;
|
|
85
85
|
name: string;
|
|
86
86
|
hooks: {
|
|
87
|
-
onSuccess(context:
|
|
87
|
+
onSuccess(context: _better_fetch_fetch20.SuccessContext<any>): void;
|
|
88
88
|
};
|
|
89
89
|
} | {
|
|
90
90
|
id: string;
|
|
91
91
|
name: string;
|
|
92
92
|
hooks: {
|
|
93
|
-
onRequest<T extends Record<string, any>>(context:
|
|
93
|
+
onRequest<T extends Record<string, any>>(context: _better_fetch_fetch20.RequestContext<T>): void;
|
|
94
94
|
};
|
|
95
95
|
} | {
|
|
96
96
|
id: string;
|
|
97
97
|
name: string;
|
|
98
98
|
hooks: {
|
|
99
|
-
onSuccess: ((context:
|
|
100
|
-
onError: ((context:
|
|
101
|
-
onRequest: (<T extends Record<string, any>>(context:
|
|
102
|
-
onResponse: ((context:
|
|
99
|
+
onSuccess: ((context: _better_fetch_fetch20.SuccessContext<any>) => Promise<void> | void) | undefined;
|
|
100
|
+
onError: ((context: _better_fetch_fetch20.ErrorContext) => Promise<void> | void) | undefined;
|
|
101
|
+
onRequest: (<T extends Record<string, any>>(context: _better_fetch_fetch20.RequestContext<T>) => Promise<_better_fetch_fetch20.RequestContext | void> | _better_fetch_fetch20.RequestContext | void) | undefined;
|
|
102
|
+
onResponse: ((context: _better_fetch_fetch20.ResponseContext) => Promise<Response | void | _better_fetch_fetch20.ResponseContext> | Response | _better_fetch_fetch20.ResponseContext | void) | undefined;
|
|
103
103
|
};
|
|
104
104
|
})[];
|
|
105
105
|
method: string;
|
|
@@ -119,12 +119,12 @@ declare function createAuthClient<Option extends PayvoAuthClientOptions$1>(optio
|
|
|
119
119
|
referrerPolicy?: ReferrerPolicy | undefined;
|
|
120
120
|
signal?: (AbortSignal | null) | undefined;
|
|
121
121
|
window?: null | undefined;
|
|
122
|
-
onRetry?: ((response:
|
|
122
|
+
onRetry?: ((response: _better_fetch_fetch20.ResponseContext) => Promise<void> | void) | undefined;
|
|
123
123
|
hookOptions?: {
|
|
124
124
|
cloneResponse?: boolean;
|
|
125
125
|
} | undefined;
|
|
126
126
|
timeout?: number | undefined;
|
|
127
|
-
customFetchImpl:
|
|
127
|
+
customFetchImpl: _better_fetch_fetch20.FetchEsque;
|
|
128
128
|
baseURL: string;
|
|
129
129
|
throw?: boolean | undefined;
|
|
130
130
|
auth?: ({
|
|
@@ -144,10 +144,10 @@ declare function createAuthClient<Option extends PayvoAuthClientOptions$1>(optio
|
|
|
144
144
|
params?: any;
|
|
145
145
|
duplex?: "full" | "half" | undefined;
|
|
146
146
|
jsonParser: (text: string) => Promise<any> | any;
|
|
147
|
-
retry?:
|
|
147
|
+
retry?: _better_fetch_fetch20.RetryOptions | undefined;
|
|
148
148
|
retryAttempt?: number | undefined;
|
|
149
|
-
output?: (
|
|
150
|
-
errorSchema?:
|
|
149
|
+
output?: (_better_fetch_fetch20.StandardSchemaV1 | typeof Blob | typeof File) | undefined;
|
|
150
|
+
errorSchema?: _better_fetch_fetch20.StandardSchemaV1 | undefined;
|
|
151
151
|
disableValidation?: boolean | undefined;
|
|
152
152
|
}, unknown, unknown, {}>;
|
|
153
153
|
$store: {
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../url-VB2gAbTI.mjs";
|
|
2
|
-
import "../misc-
|
|
3
|
-
import { a as createBroadcastChannel, i as useAuthQuery, r as createSessionRefreshManager } from "../proxy-
|
|
4
|
-
import "../parser-
|
|
5
|
-
import { n as InferPlugin, r as createAuthClient, t as InferAuth } from "../client-
|
|
2
|
+
import "../misc-fKH4d5XQ.mjs";
|
|
3
|
+
import { a as createBroadcastChannel, i as useAuthQuery, r as createSessionRefreshManager } from "../proxy-C_KXfOhk.mjs";
|
|
4
|
+
import "../parser-D7EkhAjZ.mjs";
|
|
5
|
+
import { n as InferPlugin, r as createAuthClient, t as InferAuth } from "../client-xga7yFIX.mjs";
|
|
6
6
|
|
|
7
7
|
export { InferAuth, InferPlugin, createAuthClient, createBroadcastChannel, createSessionRefreshManager, useAuthQuery };
|
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
import { a as LiteralNumber, c as OmitId, d as PrettifyDeep, f as Primitive, g as WithoutEmpty, h as UnionToIntersection, i as HasRequiredKeys, l as PreserveJSDoc, m as StripEmptyObjects, n as DeepPartial, o as LiteralString, p as RequiredKeysOf, r as Expand, s as LiteralUnion, t as Awaitable, u as Prettify } from "../../helper-
|
|
2
|
-
import { K as SessionQueryParams, Y as Auth, g as User$1, h as Session$1, i as PayvoAuthPlugin$1, mn as InferAdditionalFieldsFromPluginOptions, r as PayvoAuthOptions$1 } from "../../index-
|
|
3
|
-
import "../../types-
|
|
4
|
-
import "../../index-
|
|
5
|
-
import "../../plugins-
|
|
6
|
-
import { a as Role, i as AccessControl, o as Statements } from "../../index-
|
|
7
|
-
import { t as admin } from "../../
|
|
8
|
-
import { r as anonymous } from "../../index-
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import "../../index-
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
1
|
+
import { a as LiteralNumber, c as OmitId, d as PrettifyDeep, f as Primitive, g as WithoutEmpty, h as UnionToIntersection, i as HasRequiredKeys, l as PreserveJSDoc, m as StripEmptyObjects, n as DeepPartial, o as LiteralString, p as RequiredKeysOf, r as Expand, s as LiteralUnion, t as Awaitable, u as Prettify } from "../../helper-BgOIGHsu.mjs";
|
|
2
|
+
import { K as SessionQueryParams, Y as Auth, g as User$1, h as Session$1, i as PayvoAuthPlugin$1, mn as InferAdditionalFieldsFromPluginOptions, r as PayvoAuthOptions$1 } from "../../index-BNhJglHC.mjs";
|
|
3
|
+
import "../../types-DNQ9XQrB.mjs";
|
|
4
|
+
import "../../index-Df0KhQRf-BEa5tdwJ.mjs";
|
|
5
|
+
import "../../plugins-Dy_FrD4Y.mjs";
|
|
6
|
+
import { a as Role, i as AccessControl, o as Statements } from "../../index-CxlWnL9c.mjs";
|
|
7
|
+
import { t as admin } from "../../index-XfE0WjTN.mjs";
|
|
8
|
+
import { r as anonymous } from "../../index-CNd5jqLl.mjs";
|
|
9
|
+
import { L as apiKey } from "../../index-D57DuhZR.mjs";
|
|
10
|
+
import "../../index-CP8x1TFq.mjs";
|
|
11
|
+
import "../../index-DGeoJ4gu.mjs";
|
|
12
|
+
import "../../index-BsSKcKgO.mjs";
|
|
13
|
+
import { i as deviceAuthorizationClient } from "../../index-DFSRYWFI.mjs";
|
|
14
|
+
import { n as emailOTP } from "../../index-CC920PPp.mjs";
|
|
15
|
+
import { n as genericOAuth } from "../../index-CBiGsvDd.mjs";
|
|
16
|
+
import "../../index-DwPAddfE.mjs";
|
|
17
|
+
import { t as jwt } from "../../index-Dnd8S4S4.mjs";
|
|
18
|
+
import { t as magicLink } from "../../index-4I1YhYhk.mjs";
|
|
19
|
+
import { t as multiSession } from "../../index-DyXi7S2M.mjs";
|
|
20
|
+
import "../../index-DTkcY7xH.mjs";
|
|
21
|
+
import "../../index-sb-UFLuo.mjs";
|
|
22
|
+
import { t as oneTimeToken } from "../../index-D6ku0rUC.mjs";
|
|
23
|
+
import "../../index-QmocqGM-.mjs";
|
|
24
|
+
import { F as OrganizationOptions, S as Team, b as OrganizationRole, c as InferMember, f as InferTeam, g as Member, l as InferOrganization, p as Invitation, r as OrganizationPlugin, s as InferInvitation, v as Organization, w as TeamMember } from "../../index-KhbNmMmG.mjs";
|
|
25
|
+
import { r as phoneNumber } from "../../index-CofuaNMl.mjs";
|
|
26
|
+
import { n as twoFactorClient } from "../../index-Bml-PCqP.mjs";
|
|
27
|
+
import { n as Passkey, t as passkey } from "../../index-BX7rl07Z.mjs";
|
|
28
|
+
import { n as username } from "../../index-CzpdkTdv.mjs";
|
|
29
|
+
import { t as auditLogClient } from "../../client-F67q-Lbi.mjs";
|
|
30
|
+
import { t as sentinelClient } from "../../client-C_qmyez2.mjs";
|
|
31
|
+
import * as _gatwech_core63 from "@gatwech/core";
|
|
24
32
|
import { ClientStore, PayvoAuthOptions } from "@gatwech/core";
|
|
25
33
|
import { DBFieldAttribute } from "@gatwech/core/db";
|
|
26
|
-
import * as
|
|
34
|
+
import * as _better_fetch_fetch37 from "@better-fetch/fetch";
|
|
27
35
|
import { BetterFetch, BetterFetchOption } from "@better-fetch/fetch";
|
|
28
36
|
import * as nanostores1 from "nanostores";
|
|
29
37
|
import { atom } from "nanostores";
|
|
@@ -361,10 +369,10 @@ interface GoogleOneTapActionOptions extends Omit<GoogleOneTapOptions, "clientId"
|
|
|
361
369
|
}
|
|
362
370
|
declare const oneTapClient: (options: GoogleOneTapOptions) => {
|
|
363
371
|
id: "one-tap";
|
|
364
|
-
getActions: ($fetch:
|
|
372
|
+
getActions: ($fetch: _better_fetch_fetch37.BetterFetch, _: _gatwech_core63.ClientStore) => {
|
|
365
373
|
oneTap: (opts?: GoogleOneTapActionOptions | undefined, fetchOptions?: BetterFetchOption | undefined) => Promise<void>;
|
|
366
374
|
};
|
|
367
|
-
getAtoms($fetch:
|
|
375
|
+
getAtoms($fetch: _better_fetch_fetch37.BetterFetch): {};
|
|
368
376
|
};
|
|
369
377
|
//#endregion
|
|
370
378
|
//#region src/plugins/one-time-token/client.d.ts
|
|
@@ -463,7 +471,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
463
471
|
} ? true : false;
|
|
464
472
|
};
|
|
465
473
|
}>;
|
|
466
|
-
getActions: ($fetch:
|
|
474
|
+
getActions: ($fetch: _better_fetch_fetch37.BetterFetch, _$store: _gatwech_core63.ClientStore, co: _gatwech_core63.PayvoAuthClientOptions | undefined) => {
|
|
467
475
|
$Infer: {
|
|
468
476
|
ActiveOrganization: CO["teams"] extends {
|
|
469
477
|
enabled: true;
|
|
@@ -547,7 +555,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
547
555
|
}) => boolean;
|
|
548
556
|
};
|
|
549
557
|
};
|
|
550
|
-
getAtoms: ($fetch:
|
|
558
|
+
getAtoms: ($fetch: _better_fetch_fetch37.BetterFetch) => {
|
|
551
559
|
$listOrg: nanostores1.PreinitializedWritableAtom<boolean> & object;
|
|
552
560
|
$activeOrgSignal: nanostores1.PreinitializedWritableAtom<boolean> & object;
|
|
553
561
|
$activeMemberSignal: nanostores1.PreinitializedWritableAtom<boolean> & object;
|
|
@@ -564,7 +572,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
564
572
|
members: InferMember<CO, false>[];
|
|
565
573
|
invitations: InferInvitation<CO, false>[];
|
|
566
574
|
}> | null;
|
|
567
|
-
error: null |
|
|
575
|
+
error: null | _better_fetch_fetch37.BetterFetchError;
|
|
568
576
|
isPending: boolean;
|
|
569
577
|
isRefetching: boolean;
|
|
570
578
|
refetch: (queryParams?: {
|
|
@@ -580,7 +588,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
580
588
|
logo?: string | null | undefined;
|
|
581
589
|
metadata?: any;
|
|
582
590
|
} & InferAdditionalFieldsFromPluginOptions<"organization", CO, false> extends infer T_1 ? { [K in keyof T_1]: T_1[K] } : never)[] | null;
|
|
583
|
-
error: null |
|
|
591
|
+
error: null | _better_fetch_fetch37.BetterFetchError;
|
|
584
592
|
isPending: boolean;
|
|
585
593
|
isRefetching: boolean;
|
|
586
594
|
refetch: (queryParams?: {
|
|
@@ -595,7 +603,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
595
603
|
role: string;
|
|
596
604
|
createdAt: Date;
|
|
597
605
|
} | null;
|
|
598
|
-
error: null |
|
|
606
|
+
error: null | _better_fetch_fetch37.BetterFetchError;
|
|
599
607
|
isPending: boolean;
|
|
600
608
|
isRefetching: boolean;
|
|
601
609
|
refetch: (queryParams?: {
|
|
@@ -606,7 +614,7 @@ declare const organizationClient: <CO extends OrganizationClientOptions>(options
|
|
|
606
614
|
data: {
|
|
607
615
|
role: string;
|
|
608
616
|
} | null;
|
|
609
|
-
error: null |
|
|
617
|
+
error: null | _better_fetch_fetch37.BetterFetchError;
|
|
610
618
|
isPending: boolean;
|
|
611
619
|
isRefetching: boolean;
|
|
612
620
|
refetch: (queryParams?: {
|
|
@@ -906,7 +914,7 @@ declare const passkeyClient: () => {
|
|
|
906
914
|
getAtoms($fetch: BetterFetch): {
|
|
907
915
|
listPasskeys: nanostores1.PreinitializedWritableAtom<{
|
|
908
916
|
data: Passkey[] | null;
|
|
909
|
-
error: null |
|
|
917
|
+
error: null | _better_fetch_fetch37.BetterFetchError;
|
|
910
918
|
isPending: boolean;
|
|
911
919
|
isRefetching: boolean;
|
|
912
920
|
refetch: (queryParams?: {
|
|
@@ -946,4 +954,4 @@ declare const InferServerPlugin: <AuthOrOption extends PayvoAuthOptions | {
|
|
|
946
954
|
} ? P : never : never;
|
|
947
955
|
};
|
|
948
956
|
//#endregion
|
|
949
|
-
export { ApiKeyClientPlugin, Awaitable, DeepPartial, Expand, GoogleOneTapActionOptions, GoogleOneTapOptions, HasRequiredKeys, InferServerPlugin, LastLoginMethodClientConfig, LiteralNumber, LiteralString, LiteralUnion, OmitId, PreserveJSDoc, Prettify, PrettifyDeep, Primitive, RequiredKeysOf, StripEmptyObjects, UnionToIntersection, WithoutEmpty, adminClient, anonymousClient, apiKeyClient, clientSideHasPermission, customSessionClient, deviceAuthorizationClient, emailOTPClient, genericOAuthClient, getPasskeyActions, inferAdditionalFields, inferOrgAdditionalFields, jwtClient, lastLoginMethodClient, magicLinkClient, multiSessionClient, oneTapClient, oneTimeTokenClient, organizationClient, passkeyClient, phoneNumberClient, twoFactorClient, usernameClient };
|
|
957
|
+
export { ApiKeyClientPlugin, Awaitable, DeepPartial, Expand, GoogleOneTapActionOptions, GoogleOneTapOptions, HasRequiredKeys, InferServerPlugin, LastLoginMethodClientConfig, LiteralNumber, LiteralString, LiteralUnion, OmitId, PreserveJSDoc, Prettify, PrettifyDeep, Primitive, RequiredKeysOf, StripEmptyObjects, UnionToIntersection, WithoutEmpty, adminClient, anonymousClient, apiKeyClient, auditLogClient, clientSideHasPermission, customSessionClient, deviceAuthorizationClient, emailOTPClient, genericOAuthClient, getPasskeyActions, inferAdditionalFields, inferOrgAdditionalFields, jwtClient, lastLoginMethodClient, magicLinkClient, multiSessionClient, oneTapClient, oneTimeTokenClient, organizationClient, passkeyClient, phoneNumberClient, sentinelClient, twoFactorClient, usernameClient };
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import "../../url-VB2gAbTI.mjs";
|
|
2
|
-
import "../../
|
|
3
|
-
import
|
|
4
|
-
import "../../
|
|
5
|
-
import "../../
|
|
6
|
-
import "../../
|
|
7
|
-
import
|
|
8
|
-
import { t as
|
|
9
|
-
import { t as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
2
|
+
import "../../random-32E3cU5o.mjs";
|
|
3
|
+
import "../../misc-fKH4d5XQ.mjs";
|
|
4
|
+
import { i as useAuthQuery } from "../../proxy-C_KXfOhk.mjs";
|
|
5
|
+
import "../../parser-D7EkhAjZ.mjs";
|
|
6
|
+
import "../../client-xga7yFIX.mjs";
|
|
7
|
+
import "../../access-BM6jSA5j.mjs";
|
|
8
|
+
import { a as userAc, t as adminAc$1 } from "../../access-bhklJd7m.mjs";
|
|
9
|
+
import { t as hasPermission } from "../../has-permission-Bvg8de8g.mjs";
|
|
10
|
+
import { t as deviceAuthorizationClient } from "../../client-cBiytuOL.mjs";
|
|
11
|
+
import { a as memberAc, o as ownerAc, r as defaultRoles, t as adminAc } from "../../access-CrwEFPHE.mjs";
|
|
12
|
+
import { n as hasPermissionFn } from "../../permission-CDDWgA_O.mjs";
|
|
13
|
+
import "../../pow-OK01yPG3.mjs";
|
|
14
|
+
import { t as twoFactorClient } from "../../client-BuveH3MN.mjs";
|
|
15
|
+
import { t as auditLogClient } from "../../client-DzOqXJUm.mjs";
|
|
16
|
+
import { t as sentinelClient } from "../../client-4QEb0rUr.mjs";
|
|
13
17
|
import { atom } from "nanostores";
|
|
14
18
|
import { WebAuthnError, startAuthentication, startRegistration } from "@simplewebauthn/browser";
|
|
15
19
|
|
|
@@ -536,4 +540,4 @@ const InferServerPlugin = () => {
|
|
|
536
540
|
};
|
|
537
541
|
|
|
538
542
|
//#endregion
|
|
539
|
-
export { InferServerPlugin, adminClient, anonymousClient, apiKeyClient, clientSideHasPermission, customSessionClient, deviceAuthorizationClient, emailOTPClient, genericOAuthClient, getPasskeyActions, inferAdditionalFields, inferOrgAdditionalFields, jwtClient, lastLoginMethodClient, magicLinkClient, multiSessionClient, oneTapClient, oneTimeTokenClient, organizationClient, passkeyClient, phoneNumberClient, twoFactorClient, usernameClient };
|
|
543
|
+
export { InferServerPlugin, adminClient, anonymousClient, apiKeyClient, auditLogClient, clientSideHasPermission, customSessionClient, deviceAuthorizationClient, emailOTPClient, genericOAuthClient, getPasskeyActions, inferAdditionalFields, inferOrgAdditionalFields, jwtClient, lastLoginMethodClient, magicLinkClient, multiSessionClient, oneTapClient, oneTimeTokenClient, organizationClient, passkeyClient, phoneNumberClient, sentinelClient, twoFactorClient, usernameClient };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { d as PrettifyDeep, h as UnionToIntersection } from "../../helper-
|
|
2
|
-
import { I as InferActions, K as SessionQueryParams, R as InferClientAPI, U as IsSignal, z as InferErrorCodes } from "../../index-
|
|
3
|
-
import "../../types-
|
|
4
|
-
import "../../index-
|
|
5
|
-
import "../../plugins-
|
|
1
|
+
import { d as PrettifyDeep, h as UnionToIntersection } from "../../helper-BgOIGHsu.mjs";
|
|
2
|
+
import { I as InferActions, K as SessionQueryParams, R as InferClientAPI, U as IsSignal, z as InferErrorCodes } from "../../index-BNhJglHC.mjs";
|
|
3
|
+
import "../../types-DNQ9XQrB.mjs";
|
|
4
|
+
import "../../index-Df0KhQRf-BEa5tdwJ.mjs";
|
|
5
|
+
import "../../plugins-Dy_FrD4Y.mjs";
|
|
6
6
|
import { PayvoAuthClientOptions, PayvoAuthClientPlugin } from "@gatwech/core";
|
|
7
7
|
import { BASE_ERROR_CODES } from "@gatwech/core/error";
|
|
8
8
|
import * as _better_fetch_fetch0 from "@better-fetch/fetch";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../url-VB2gAbTI.mjs";
|
|
2
|
-
import { n as getClientConfig, t as createDynamicPathProxy } from "../../proxy-
|
|
3
|
-
import "../../parser-
|
|
2
|
+
import { n as getClientConfig, t as createDynamicPathProxy } from "../../proxy-C_KXfOhk.mjs";
|
|
3
|
+
import "../../parser-D7EkhAjZ.mjs";
|
|
4
4
|
import { listenKeys } from "nanostores";
|
|
5
5
|
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
6
6
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { t as generateRandomString } from "./random-32E3cU5o.mjs";
|
|
2
|
+
import { n as POW_REASON_HEADER, o as parsePowHeader, r as POW_SOLUTION_HEADER, s as solveChallenge, t as POW_CHALLENGE_HEADER } from "./pow-OK01yPG3.mjs";
|
|
3
|
+
import { betterFetch } from "@better-fetch/fetch";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/sentinel/client.ts
|
|
6
|
+
const VISITOR_ID_STORAGE_KEY = "payvo-auth.visitor_id";
|
|
7
|
+
/** A random id kept for the lifetime of the browser storage */
|
|
8
|
+
function storedVisitorId() {
|
|
9
|
+
try {
|
|
10
|
+
const storage = globalThis.localStorage;
|
|
11
|
+
const existing = storage?.getItem(VISITOR_ID_STORAGE_KEY);
|
|
12
|
+
if (existing) return existing;
|
|
13
|
+
const created = generateRandomString(32, "a-z", "0-9");
|
|
14
|
+
storage?.setItem(VISITOR_ID_STORAGE_KEY, created);
|
|
15
|
+
return created;
|
|
16
|
+
} catch {
|
|
17
|
+
return generateRandomString(32, "a-z", "0-9");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const sentinelClient = (options) => {
|
|
21
|
+
const autoSolveChallenge = options?.autoSolveChallenge ?? true;
|
|
22
|
+
const timeout = options?.identifyOptions?.timeout ?? 1e3;
|
|
23
|
+
const retry = {
|
|
24
|
+
attempts: options?.identifyOptions?.retry?.attempts ?? 2,
|
|
25
|
+
baseDelay: options?.identifyOptions?.retry?.baseDelay ?? 400,
|
|
26
|
+
maxDelay: options?.identifyOptions?.retry?.maxDelay ?? 600
|
|
27
|
+
};
|
|
28
|
+
let visitorId;
|
|
29
|
+
async function identify(fingerprint) {
|
|
30
|
+
const identifyUrl = options?.identifyUrl?.replace(/\/+$/, "");
|
|
31
|
+
if (!identifyUrl) return fingerprint;
|
|
32
|
+
for (let attempt = 0; attempt <= retry.attempts; attempt++) {
|
|
33
|
+
if (attempt > 0) {
|
|
34
|
+
const delay = Math.min(retry.baseDelay * 2 ** (attempt - 1), retry.maxDelay);
|
|
35
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
36
|
+
}
|
|
37
|
+
const { data } = await betterFetch(`${identifyUrl}/v1/identify`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: options?.identifyOptions?.headers,
|
|
40
|
+
body: {
|
|
41
|
+
fingerprint,
|
|
42
|
+
userAgent: globalThis.navigator?.userAgent ?? null
|
|
43
|
+
},
|
|
44
|
+
timeout
|
|
45
|
+
}).catch(() => ({ data: null }));
|
|
46
|
+
if (data?.visitorId) return data.visitorId;
|
|
47
|
+
}
|
|
48
|
+
return fingerprint;
|
|
49
|
+
}
|
|
50
|
+
function getVisitorId() {
|
|
51
|
+
visitorId ??= (async () => {
|
|
52
|
+
return identify(options?.getFingerprint ? await options.getFingerprint() : storedVisitorId());
|
|
53
|
+
})();
|
|
54
|
+
return visitorId;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
id: "sentinel",
|
|
58
|
+
$InferServerPlugin: {},
|
|
59
|
+
fetchPlugins: [{
|
|
60
|
+
id: "sentinel",
|
|
61
|
+
name: "sentinel",
|
|
62
|
+
hooks: {
|
|
63
|
+
async onRequest(context) {
|
|
64
|
+
context.headers.set("x-visitor-id", await getVisitorId());
|
|
65
|
+
return context;
|
|
66
|
+
},
|
|
67
|
+
async onResponse({ response, request }) {
|
|
68
|
+
if (response.status !== 423) return;
|
|
69
|
+
const challenge = parsePowHeader(response.headers.get(POW_CHALLENGE_HEADER));
|
|
70
|
+
if (!challenge) return;
|
|
71
|
+
options?.onChallengeReceived?.(response.headers.get(POW_REASON_HEADER) ?? "unknown");
|
|
72
|
+
if (!autoSolveChallenge) return;
|
|
73
|
+
try {
|
|
74
|
+
const startedAt = Date.now();
|
|
75
|
+
const solution = await solveChallenge(challenge.nonce, Number(challenge.value));
|
|
76
|
+
options?.onChallengeSolved?.(Date.now() - startedAt);
|
|
77
|
+
const headers = new Headers(request.headers);
|
|
78
|
+
headers.set(POW_SOLUTION_HEADER, `${challenge.nonce}:${solution}`);
|
|
79
|
+
const retried = await (request.customFetchImpl ?? fetch)(request.url, {
|
|
80
|
+
...request,
|
|
81
|
+
headers
|
|
82
|
+
});
|
|
83
|
+
if (retried.status === 423 && retried.headers.has(POW_CHALLENGE_HEADER)) options?.onChallengeFailed?.(/* @__PURE__ */ new Error("The challenge solution was rejected"));
|
|
84
|
+
return retried;
|
|
85
|
+
} catch (e) {
|
|
86
|
+
options?.onChallengeFailed?.(e instanceof Error ? e : new Error(String(e)));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}]
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
export { sentinelClient as t };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { c as sentinel } from "./index-D57DuhZR.mjs";
|
|
2
|
+
import * as _better_fetch_fetch16 from "@better-fetch/fetch";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/sentinel/client.d.ts
|
|
5
|
+
declare const sentinelClient: (options?: {
|
|
6
|
+
/**
|
|
7
|
+
* Base URL of the hosted identify service. Without it, the fingerprint is
|
|
8
|
+
* sent as the visitor id.
|
|
9
|
+
*/
|
|
10
|
+
identifyUrl?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Identify request options
|
|
13
|
+
*/
|
|
14
|
+
identifyOptions?: {
|
|
15
|
+
/**
|
|
16
|
+
* Request timeout in milliseconds
|
|
17
|
+
*
|
|
18
|
+
* @default 1000
|
|
19
|
+
*/
|
|
20
|
+
timeout?: number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Retries after a failed request, with exponential backoff
|
|
23
|
+
*
|
|
24
|
+
* @default { attempts: 2, baseDelay: 400, maxDelay: 600 }
|
|
25
|
+
*/
|
|
26
|
+
retry?: {
|
|
27
|
+
attempts?: number | undefined;
|
|
28
|
+
baseDelay?: number | undefined;
|
|
29
|
+
maxDelay?: number | undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Additional headers, e.g. the publishable key
|
|
33
|
+
*/
|
|
34
|
+
headers?: Record<string, string> | undefined;
|
|
35
|
+
} | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Return a browser fingerprint, e.g. from FingerprintJS. By default a
|
|
38
|
+
* random id is created and kept in `localStorage`.
|
|
39
|
+
*/
|
|
40
|
+
getFingerprint?: (() => string | Promise<string>) | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Solve proof-of-work challenges and retry the request once
|
|
43
|
+
*
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
autoSolveChallenge?: boolean | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Called when a proof-of-work challenge is received
|
|
49
|
+
*/
|
|
50
|
+
onChallengeReceived?: ((reason: string) => void) | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Called after a challenge is solved
|
|
53
|
+
*/
|
|
54
|
+
onChallengeSolved?: ((solveTimeMs: number) => void) | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Called when solving a challenge fails or its solution is rejected
|
|
57
|
+
*/
|
|
58
|
+
onChallengeFailed?: ((error: Error) => void) | undefined;
|
|
59
|
+
} | undefined) => {
|
|
60
|
+
id: "sentinel";
|
|
61
|
+
$InferServerPlugin: ReturnType<typeof sentinel>;
|
|
62
|
+
fetchPlugins: {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
hooks: {
|
|
66
|
+
onRequest<T extends Record<string, any>>(context: _better_fetch_fetch16.RequestContext<T>): Promise<_better_fetch_fetch16.RequestContext<T>>;
|
|
67
|
+
onResponse({
|
|
68
|
+
response,
|
|
69
|
+
request
|
|
70
|
+
}: _better_fetch_fetch16.ResponseContext): Promise<Response | undefined>;
|
|
71
|
+
};
|
|
72
|
+
}[];
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { sentinelClient as t };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/plugins/audit-log/client.ts
|
|
2
|
+
const auditLogClient = () => {
|
|
3
|
+
return {
|
|
4
|
+
id: "audit-log",
|
|
5
|
+
$InferServerPlugin: {},
|
|
6
|
+
pathMethods: {
|
|
7
|
+
"/audit-log/get-audit-logs": "GET",
|
|
8
|
+
"/audit-log/get-all-audit-logs": "GET",
|
|
9
|
+
"/audit-log/get-event-types": "GET"
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { auditLogClient as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { n as auditLog } from "./index-D57DuhZR.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/audit-log/client.d.ts
|
|
4
|
+
declare const auditLogClient: () => {
|
|
5
|
+
id: "audit-log";
|
|
6
|
+
$InferServerPlugin: ReturnType<typeof auditLog>;
|
|
7
|
+
pathMethods: {
|
|
8
|
+
"/audit-log/get-audit-logs": "GET";
|
|
9
|
+
"/audit-log/get-all-audit-logs": "GET";
|
|
10
|
+
"/audit-log/get-event-types": "GET";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { auditLogClient as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as capitalizeFirstLetter } from "./misc-
|
|
2
|
-
import { n as getClientConfig, t as createDynamicPathProxy } from "./proxy-
|
|
1
|
+
import { t as capitalizeFirstLetter } from "./misc-fKH4d5XQ.mjs";
|
|
2
|
+
import { n as getClientConfig, t as createDynamicPathProxy } from "./proxy-C_KXfOhk.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/client/vanilla.ts
|
|
5
5
|
function createAuthClient(options) {
|
package/dist/cookies/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../helper-
|
|
2
|
-
import "../index-
|
|
3
|
-
import "../types-
|
|
4
|
-
import "../index-
|
|
5
|
-
import "../plugins-
|
|
6
|
-
import { a as getCookies, c as setCookieCache, d as getChunkedCookie, f as parseSetCookieHeader, i as getCookieCache, l as setSessionCookie, n as createCookieGetter, o as getSessionCookie, p as setCookieToHeader, r as deleteSessionCookie, s as parseCookies, t as EligibleCookies, u as createSessionStore } from "../index-
|
|
1
|
+
import "../helper-BgOIGHsu.mjs";
|
|
2
|
+
import "../index-BNhJglHC.mjs";
|
|
3
|
+
import "../types-DNQ9XQrB.mjs";
|
|
4
|
+
import "../index-Df0KhQRf-BEa5tdwJ.mjs";
|
|
5
|
+
import "../plugins-Dy_FrD4Y.mjs";
|
|
6
|
+
import { a as getCookies, c as setCookieCache, d as getChunkedCookie, f as parseSetCookieHeader, i as getCookieCache, l as setSessionCookie, n as createCookieGetter, o as getSessionCookie, p as setCookieToHeader, r as deleteSessionCookie, s as parseCookies, t as EligibleCookies, u as createSessionStore } from "../index-CsxtcAO0.mjs";
|
|
7
7
|
export { EligibleCookies, createCookieGetter, createSessionStore, deleteSessionCookie, getChunkedCookie, getCookieCache, getCookies, getSessionCookie, parseCookies, parseSetCookieHeader, setCookieCache, setCookieToHeader, setSessionCookie };
|
package/dist/cookies/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../url-VB2gAbTI.mjs";
|
|
2
2
|
import "../json-D0TBLy4q.mjs";
|
|
3
3
|
import "../jwt-CmxZAGe2.mjs";
|
|
4
|
-
import { a as getSessionCookie, c as setSessionCookie, d as createSessionStore, f as getChunkedCookie, i as getCookies, l as parseSetCookieHeader, n as deleteSessionCookie, o as parseCookies, r as getCookieCache, s as setCookieCache, t as createCookieGetter, u as setCookieToHeader } from "../cookies-
|
|
5
|
-
import "../date-
|
|
4
|
+
import { a as getSessionCookie, c as setSessionCookie, d as createSessionStore, f as getChunkedCookie, i as getCookies, l as parseSetCookieHeader, n as deleteSessionCookie, o as parseCookies, r as getCookieCache, s as setCookieCache, t as createCookieGetter, u as setCookieToHeader } from "../cookies-BuvlgcA-.mjs";
|
|
5
|
+
import "../date-CMr04reD.mjs";
|
|
6
6
|
|
|
7
7
|
export { createCookieGetter, createSessionStore, deleteSessionCookie, getChunkedCookie, getCookieCache, getCookies, getSessionCookie, parseCookies, parseSetCookieHeader, setCookieCache, setCookieToHeader, setSessionCookie };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as getBaseURL } from "./url-VB2gAbTI.mjs";
|
|
2
2
|
import { t as safeJSONParse } from "./json-D0TBLy4q.mjs";
|
|
3
3
|
import { i as verifyJWT, n as symmetricDecodeJWT, r as symmetricEncodeJWT, t as signJWT } from "./jwt-CmxZAGe2.mjs";
|
|
4
|
-
import { t as getDate, u as parseUserOutput } from "./date-
|
|
4
|
+
import { t as getDate, u as parseUserOutput } from "./date-CMr04reD.mjs";
|
|
5
5
|
import { env, isProduction } from "@gatwech/core/env";
|
|
6
6
|
import { PayvoAuthError } from "@gatwech/core/error";
|
|
7
7
|
import * as z$1 from "zod";
|
package/dist/crypto/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as constantTimeEqual, i as verifyPassword, n as symmetricEncrypt, r as hashPassword, t as symmetricDecrypt } from "../crypto-CCyta8xj.mjs";
|
|
2
2
|
import { i as verifyJWT, n as symmetricDecodeJWT, r as symmetricEncodeJWT, t as signJWT } from "../jwt-CmxZAGe2.mjs";
|
|
3
|
+
import { t as generateRandomString } from "../random-32E3cU5o.mjs";
|
|
3
4
|
|
|
4
5
|
export { constantTimeEqual, generateRandomString, hashPassword, signJWT, symmetricDecodeJWT, symmetricDecrypt, symmetricEncodeJWT, symmetricEncrypt, verifyJWT, verifyPassword };
|
|
@@ -5,7 +5,6 @@ import { bytesToHex, hexToBytes, managedNonce, utf8ToBytes } from "@noble/cipher
|
|
|
5
5
|
import { hex } from "@gatwech/utils/hex";
|
|
6
6
|
import { scryptAsync } from "@noble/hashes/scrypt.js";
|
|
7
7
|
import { hexToBytes as hexToBytes$1 } from "@noble/hashes/utils.js";
|
|
8
|
-
import { createRandomStringGenerator } from "@gatwech/utils/random";
|
|
9
8
|
|
|
10
9
|
//#region src/crypto/buffer.ts
|
|
11
10
|
/**
|
|
@@ -48,10 +47,6 @@ const verifyPassword = async ({ hash, password }) => {
|
|
|
48
47
|
return constantTimeEqual(await generateKey(password, salt), hexToBytes$1(key));
|
|
49
48
|
};
|
|
50
49
|
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/crypto/random.ts
|
|
53
|
-
const generateRandomString = createRandomStringGenerator("a-z", "0-9", "A-Z", "-_");
|
|
54
|
-
|
|
55
50
|
//#endregion
|
|
56
51
|
//#region src/crypto/index.ts
|
|
57
52
|
const symmetricEncrypt = async ({ key, data }) => {
|
|
@@ -67,4 +62,4 @@ const symmetricDecrypt = async ({ key, data }) => {
|
|
|
67
62
|
};
|
|
68
63
|
|
|
69
64
|
//#endregion
|
|
70
|
-
export {
|
|
65
|
+
export { constantTimeEqual as a, verifyPassword as i, symmetricEncrypt as n, hashPassword as r, symmetricDecrypt as t };
|