@finueva/auth 0.4.0 → 0.6.0
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 +6 -0
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/device.d.ts +1 -1
- package/dist/device.js +47 -46
- package/dist/index.d.ts +2 -2
- package/dist/index.js +237 -126
- package/dist/server.d.ts +1 -1
- package/dist/server.js +2 -1
- package/dist/{types-zEqO1_r2.d.ts → types-HSdjQWMZ.d.ts} +6 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -23,6 +23,10 @@ const stop = auth.onAuthStateChange((state) => {
|
|
|
23
23
|
|
|
24
24
|
const session = await auth.getSession();
|
|
25
25
|
await auth.signIn({ email, password });
|
|
26
|
+
await auth.sendVerificationEmail({
|
|
27
|
+
email,
|
|
28
|
+
callbackURL: `${window.location.origin}/account/email-verified`,
|
|
29
|
+
});
|
|
26
30
|
const organizations = await auth.listOrganizations();
|
|
27
31
|
const acceptance = await auth.acceptInvitation({ invitationId });
|
|
28
32
|
const credential = await auth.getDriveCredential({
|
|
@@ -37,6 +41,8 @@ stop();
|
|
|
37
41
|
|
|
38
42
|
The Auth session uses the Auth-owned HTTP-only cookie. `getSession()` and `onSessionChange()` report Better Auth authority results only. `onAuthStateChange()` separately emits `loading`, non-authoritative `cached`, authoritative `authenticated`/`unauthenticated`, or non-authoritative `unavailable`; it verifies every cache hint immediately.
|
|
39
43
|
|
|
44
|
+
`sendVerificationEmail({ email, callbackURL? })` sends one non-retried request. An explicit callback must be an exact absolute URL on `appOrigin`; it is never persisted by the SDK. Without one, the email lands on Auth's value-free verification result page after Better Auth completes verification.
|
|
45
|
+
|
|
40
46
|
DOM browsers use local storage by default. Set `persistence` to `"session"`, `"memory"`, or a structural driver with `getItem`, `setItem`, and `removeItem`; Workers and Node default to memory. The one 16 KiB versioned snapshot contains only a normalized session and its Auth authority identity. It expires with the session and never contains cookies, passwords, Drive credentials, tokens, headers, workspace selection, Better Auth payloads, or errors. Persistence failure cannot change an Auth request result.
|
|
41
47
|
|
|
42
48
|
A workspace is either `{ type: "personal" }` or `{ type: "organization", organizationId }`; organization IDs must match `[A-Za-z0-9_-]{1,128}`. Workspace selections are strict and reject additional properties locally with `invalid_workspace_selection` before making a request.
|
package/THIRD_PARTY_NOTICES.md
CHANGED
package/dist/device.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as AuthSession } from "./types-
|
|
1
|
+
import { o as AuthSession } from "./types-HSdjQWMZ.js";
|
|
2
2
|
//#region src/device.d.ts
|
|
3
3
|
type DeviceAuthorizationErrorCode = "device_access_denied" | "device_authorization_cancelled" | "device_code_expired" | "invalid_device_authorization" | "identity_authority_unavailable";
|
|
4
4
|
declare class DeviceAuthorizationError extends Error {
|
package/dist/device.js
CHANGED
|
@@ -1,45 +1,3 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
|
|
2
|
-
const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
|
|
3
|
-
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
4
|
-
const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
5
|
-
function jsonParseTransform(key, value) {
|
|
6
|
-
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
7
|
-
warnKeyDropped(key);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
return value;
|
|
11
|
-
}
|
|
12
|
-
function warnKeyDropped(key) {
|
|
13
|
-
console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
|
|
14
|
-
}
|
|
15
|
-
function destr(value, options = {}) {
|
|
16
|
-
if (typeof value !== "string") return value;
|
|
17
|
-
if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
|
|
18
|
-
const _value = value.trim();
|
|
19
|
-
if (_value.length <= 9) switch (_value.toLowerCase()) {
|
|
20
|
-
case "true": return true;
|
|
21
|
-
case "false": return false;
|
|
22
|
-
case "undefined": return;
|
|
23
|
-
case "null": return null;
|
|
24
|
-
case "nan": return NaN;
|
|
25
|
-
case "infinity": return Number.POSITIVE_INFINITY;
|
|
26
|
-
case "-infinity": return Number.NEGATIVE_INFINITY;
|
|
27
|
-
}
|
|
28
|
-
if (!JsonSigRx.test(value)) {
|
|
29
|
-
if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
|
|
34
|
-
if (options.strict) throw new Error("[destr] Possible prototype pollution");
|
|
35
|
-
return JSON.parse(value, jsonParseTransform);
|
|
36
|
-
}
|
|
37
|
-
return JSON.parse(value);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (options.strict) throw error;
|
|
40
|
-
return value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
1
|
String.fromCharCode;
|
|
44
2
|
const HASH_RE = /#/g;
|
|
45
3
|
const AMPERSAND_RE = /&/g;
|
|
@@ -215,6 +173,49 @@ function stringifyParsedURL(parsed) {
|
|
|
215
173
|
return (parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "") + auth + host + pathname + search + hash;
|
|
216
174
|
}
|
|
217
175
|
//#endregion
|
|
176
|
+
//#region ../../node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs
|
|
177
|
+
const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
|
|
178
|
+
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
179
|
+
const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;
|
|
180
|
+
function jsonParseTransform(key, value) {
|
|
181
|
+
if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
|
|
182
|
+
warnKeyDropped(key);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
return value;
|
|
186
|
+
}
|
|
187
|
+
function warnKeyDropped(key) {
|
|
188
|
+
console.warn(`[destr] Dropping "${key}" key to prevent prototype pollution.`);
|
|
189
|
+
}
|
|
190
|
+
function destr(value, options = {}) {
|
|
191
|
+
if (typeof value !== "string") return value;
|
|
192
|
+
if (value[0] === "\"" && value[value.length - 1] === "\"" && value.indexOf("\\") === -1) return value.slice(1, -1);
|
|
193
|
+
const _value = value.trim();
|
|
194
|
+
if (_value.length <= 9) switch (_value.toLowerCase()) {
|
|
195
|
+
case "true": return true;
|
|
196
|
+
case "false": return false;
|
|
197
|
+
case "undefined": return;
|
|
198
|
+
case "null": return null;
|
|
199
|
+
case "nan": return NaN;
|
|
200
|
+
case "infinity": return Number.POSITIVE_INFINITY;
|
|
201
|
+
case "-infinity": return Number.NEGATIVE_INFINITY;
|
|
202
|
+
}
|
|
203
|
+
if (!JsonSigRx.test(value)) {
|
|
204
|
+
if (options.strict) throw new SyntaxError("[destr] Invalid JSON");
|
|
205
|
+
return value;
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {
|
|
209
|
+
if (options.strict) throw new Error("[destr] Possible prototype pollution");
|
|
210
|
+
return JSON.parse(value, jsonParseTransform);
|
|
211
|
+
}
|
|
212
|
+
return JSON.parse(value);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (options.strict) throw error;
|
|
215
|
+
return value;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
218
219
|
//#region ../../node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs
|
|
219
220
|
var FetchError = class extends Error {
|
|
220
221
|
constructor(message, opts) {
|
|
@@ -705,7 +706,7 @@ function createDeviceAuth(options) {
|
|
|
705
706
|
async function requestAuthorization(requestOptions = {}) {
|
|
706
707
|
if (requestOptions.signal?.aborted) throw cancelled();
|
|
707
708
|
try {
|
|
708
|
-
return normalizeAuthorization((await requestJsonResponse(
|
|
709
|
+
return normalizeAuthorization((await requestJsonResponse(joinURL(authOrigin, "api/v1/auth/device/code"), {
|
|
709
710
|
fetch: requestFetch,
|
|
710
711
|
timeoutMs,
|
|
711
712
|
method: "POST",
|
|
@@ -734,7 +735,7 @@ function createDeviceAuth(options) {
|
|
|
734
735
|
if (requestBudget <= 0) throw expired();
|
|
735
736
|
let response;
|
|
736
737
|
try {
|
|
737
|
-
response = await requestJsonResponse(
|
|
738
|
+
response = await requestJsonResponse(joinURL(authOrigin, "api/v1/auth/device/token"), {
|
|
738
739
|
fetch: requestFetch,
|
|
739
740
|
timeoutMs: Math.min(timeoutMs, requestBudget),
|
|
740
741
|
method: "POST",
|
|
@@ -782,7 +783,7 @@ function createDeviceAuth(options) {
|
|
|
782
783
|
const current = await getToken();
|
|
783
784
|
if (!current) return null;
|
|
784
785
|
try {
|
|
785
|
-
return await requestJsonResponse(
|
|
786
|
+
return await requestJsonResponse(joinURL(authOrigin, "api/v1/auth", path), {
|
|
786
787
|
fetch: requestFetch,
|
|
787
788
|
timeoutMs,
|
|
788
789
|
method: body ? "POST" : "GET",
|
|
@@ -797,7 +798,7 @@ function createDeviceAuth(options) {
|
|
|
797
798
|
const current = await getToken();
|
|
798
799
|
if (!current) return;
|
|
799
800
|
try {
|
|
800
|
-
await requestJsonResponse(
|
|
801
|
+
await requestJsonResponse(joinURL(authOrigin, "api/v1/auth", path), {
|
|
801
802
|
fetch: requestFetch,
|
|
802
803
|
timeoutMs,
|
|
803
804
|
method: "POST",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as AuthPersistenceDriver, c as AuthUser, d as FinuevaAuthClient, f as InvitationAcceptance, g as
|
|
1
|
+
import { _ as WorkspaceSelection, a as AuthPersistenceDriver, c as AuthUser, d as FinuevaAuthClient, f as InvitationAcceptance, g as SignInInput, h as SendVerificationEmailInput, i as AuthPersistence, l as DriveCredential, m as PersonalWorkspaceSelection, n as AuthClientOptions, o as AuthSession, p as OrganizationWorkspaceSelection, r as AuthOrganization, s as AuthState, t as AcceptInvitationInput, u as DriveCredentialInput } from "./types-HSdjQWMZ.js";
|
|
2
2
|
import { n as AuthErrorCode, r as AuthErrorStatus, t as AuthError } from "./errors-Crd93Rah.js";
|
|
3
3
|
//#region src/client.d.ts
|
|
4
4
|
declare function createAuthClient(options: AuthClientOptions): FinuevaAuthClient;
|
|
5
5
|
//#endregion
|
|
6
|
-
export { type AcceptInvitationInput, type AuthClientOptions, AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthOrganization, type AuthPersistence, type AuthPersistenceDriver, type AuthSession, type AuthState, type AuthUser, type DriveCredential, type DriveCredentialInput, type FinuevaAuthClient, type InvitationAcceptance, type OrganizationWorkspaceSelection, type PersonalWorkspaceSelection, type SignInInput, type WorkspaceSelection, createAuthClient };
|
|
6
|
+
export { type AcceptInvitationInput, type AuthClientOptions, AuthError, type AuthErrorCode, type AuthErrorStatus, type AuthOrganization, type AuthPersistence, type AuthPersistenceDriver, type AuthSession, type AuthState, type AuthUser, type DriveCredential, type DriveCredentialInput, type FinuevaAuthClient, type InvitationAcceptance, type OrganizationWorkspaceSelection, type PersonalWorkspaceSelection, type SendVerificationEmailInput, type SignInInput, type WorkspaceSelection, createAuthClient };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp$1 = Object.defineProperty;
|
|
3
|
+
var __esmMin = (fn, res, err) => () => {
|
|
4
|
+
if (err) throw err[0];
|
|
5
|
+
try {
|
|
6
|
+
return fn && (res = fn(fn = 0)), res;
|
|
7
|
+
} catch (e) {
|
|
8
|
+
throw err = [e], e;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var __exportAll = (all, no_symbols) => {
|
|
12
|
+
let target = {};
|
|
13
|
+
for (var name in all) __defProp$1(target, name, {
|
|
14
|
+
get: all[name],
|
|
15
|
+
enumerable: true
|
|
16
|
+
});
|
|
17
|
+
if (!no_symbols) __defProp$1(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
2
22
|
const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
|
|
3
23
|
const now$1 = () => Math.floor(Date.now() / 1e3);
|
|
4
24
|
var WindowBroadcastChannel = class {
|
|
@@ -205,7 +225,7 @@ let onMount = ($store, initialize) => {
|
|
|
205
225
|
});
|
|
206
226
|
};
|
|
207
227
|
//#endregion
|
|
208
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
228
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/equality.mjs
|
|
209
229
|
function isPlainObject$1(value) {
|
|
210
230
|
if (typeof value !== "object" || value === null) return false;
|
|
211
231
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -233,7 +253,7 @@ function withEquality(store, isEqual) {
|
|
|
233
253
|
});
|
|
234
254
|
}
|
|
235
255
|
//#endregion
|
|
236
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
256
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/focus-manager.mjs
|
|
237
257
|
const kFocusManager = Symbol.for("better-auth:focus-manager");
|
|
238
258
|
var WindowFocusManager = class {
|
|
239
259
|
listeners = new Set();
|
|
@@ -262,7 +282,7 @@ function getGlobalFocusManager() {
|
|
|
262
282
|
return globalThis[kFocusManager];
|
|
263
283
|
}
|
|
264
284
|
//#endregion
|
|
265
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
285
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/online-manager.mjs
|
|
266
286
|
const kOnlineManager = Symbol.for("better-auth:online-manager");
|
|
267
287
|
var WindowOnlineManager = class {
|
|
268
288
|
listeners = new Set();
|
|
@@ -294,7 +314,7 @@ function getGlobalOnlineManager() {
|
|
|
294
314
|
return globalThis[kOnlineManager];
|
|
295
315
|
}
|
|
296
316
|
//#endregion
|
|
297
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
317
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/parser.mjs
|
|
298
318
|
const PROTO_POLLUTION_PATTERNS = {
|
|
299
319
|
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
300
320
|
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
@@ -363,7 +383,7 @@ function parseJSON(value, options = { strict: true }) {
|
|
|
363
383
|
return betterJSONParse(value, options);
|
|
364
384
|
}
|
|
365
385
|
//#endregion
|
|
366
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
386
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/session-refresh.mjs
|
|
367
387
|
const now = () => Math.floor(Date.now() / 1e3);
|
|
368
388
|
const FOCUS_REFETCH_RATE_LIMIT_SECONDS = 5;
|
|
369
389
|
function createSessionRefreshManager(opts) {
|
|
@@ -660,7 +680,7 @@ var BetterAuthError = class extends Error {
|
|
|
660
680
|
}
|
|
661
681
|
};
|
|
662
682
|
//#endregion
|
|
663
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
683
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/utils/url.mjs
|
|
664
684
|
const SLASH_CHAR_CODE = "/".charCodeAt(0);
|
|
665
685
|
function trimTrailingSlashes(value) {
|
|
666
686
|
let end = value.length;
|
|
@@ -754,7 +774,7 @@ function isSafeUrlScheme(value) {
|
|
|
754
774
|
return !DANGEROUS_URL_SCHEMES.includes(parsed.protocol);
|
|
755
775
|
}
|
|
756
776
|
//#endregion
|
|
757
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
777
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
758
778
|
const redirectPlugin = {
|
|
759
779
|
id: "redirect",
|
|
760
780
|
name: "Redirect",
|
|
@@ -769,7 +789,7 @@ const redirectPlugin = {
|
|
|
769
789
|
} }
|
|
770
790
|
};
|
|
771
791
|
//#endregion
|
|
772
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
792
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/session-atom.mjs
|
|
773
793
|
const isServer = () => typeof window === "undefined";
|
|
774
794
|
function normalizeSessionResponse(res) {
|
|
775
795
|
if (typeof res === "object" && res !== null && "data" in res && "error" in res) return res;
|
|
@@ -1417,7 +1437,7 @@ var betterFetch = async (url, options) => {
|
|
|
1417
1437
|
};
|
|
1418
1438
|
};
|
|
1419
1439
|
//#endregion
|
|
1420
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
1440
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/config.mjs
|
|
1421
1441
|
const resolvePublicAuthUrl = (basePath) => {
|
|
1422
1442
|
if (typeof process === "undefined") return void 0;
|
|
1423
1443
|
const path = basePath ?? "/api/auth";
|
|
@@ -1515,7 +1535,7 @@ const getClientConfig = (options, loadEnv) => {
|
|
|
1515
1535
|
};
|
|
1516
1536
|
};
|
|
1517
1537
|
//#endregion
|
|
1518
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
1538
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/utils/is-atom.mjs
|
|
1519
1539
|
function isAtom(value) {
|
|
1520
1540
|
return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
|
|
1521
1541
|
}
|
|
@@ -1533,7 +1553,7 @@ function toKebabCase(input) {
|
|
|
1533
1553
|
return splitWords(input).map((word) => word.toLowerCase()).join("-");
|
|
1534
1554
|
}
|
|
1535
1555
|
//#endregion
|
|
1536
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
1556
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/proxy.mjs
|
|
1537
1557
|
function getMethod(path, knownPathMethods, args) {
|
|
1538
1558
|
const method = knownPathMethods[path];
|
|
1539
1559
|
const { fetchOptions, query: _query, ...body } = args || {};
|
|
@@ -1602,7 +1622,7 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
|
|
|
1602
1622
|
return createProxy();
|
|
1603
1623
|
}
|
|
1604
1624
|
//#endregion
|
|
1605
|
-
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@
|
|
1625
|
+
//#region ../../node_modules/.pnpm/better-auth@1.6.22_drizzle-kit@0.31.10_drizzle-orm@0.45.2_@libsql+client@0.17.4_kysely@_fc032d4b6d0d0a5be5267474da10b212/node_modules/better-auth/dist/client/vanilla.mjs
|
|
1606
1626
|
function createAuthClient$1(options) {
|
|
1607
1627
|
const { pluginPathMethods, pluginsActions, pluginsAtoms, $fetch, atomListeners, $store } = getClientConfig(options);
|
|
1608
1628
|
const resolvedHooks = {};
|
|
@@ -1615,7 +1635,7 @@ function createAuthClient$1(options) {
|
|
|
1615
1635
|
}, $fetch, pluginPathMethods, pluginsAtoms, atomListeners);
|
|
1616
1636
|
}
|
|
1617
1637
|
//#endregion
|
|
1618
|
-
//#region ../../node_modules/.pnpm/@chiballc+utils@2.
|
|
1638
|
+
//#region ../../node_modules/.pnpm/@chiballc+utils@2.5.0_@hono+zod-openapi@1.5.1_hono@4.13.0_zod@4.4.3__hono@4.13.0_magic-_deb761a9672ce7cf69932b564bd2142d/node_modules/@chiballc/utils/dist/index.mjs
|
|
1619
1639
|
function isPromise(arg) {
|
|
1620
1640
|
return arg && typeof arg.then === "function";
|
|
1621
1641
|
}
|
|
@@ -2149,6 +2169,7 @@ function createFetch(globalOptions = {}) {
|
|
|
2149
2169
|
}
|
|
2150
2170
|
//#endregion
|
|
2151
2171
|
//#region src/shared.ts
|
|
2172
|
+
const DRIVE_CREDENTIAL_LIFETIME_SECONDS = 840;
|
|
2152
2173
|
const id = /^[A-Za-z0-9_-]{1,128}$/;
|
|
2153
2174
|
const email = /^[^\s@]+@[^\s@]+$/;
|
|
2154
2175
|
function normalizeOrigin(value, name) {
|
|
@@ -2187,7 +2208,7 @@ function normalizeSession(value) {
|
|
|
2187
2208
|
};
|
|
2188
2209
|
}
|
|
2189
2210
|
function normalizeDriveCredential(value, now) {
|
|
2190
|
-
if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !==
|
|
2211
|
+
if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !== DRIVE_CREDENTIAL_LIFETIME_SECONDS || typeof value.token !== "string" || value.token.length === 0 || value.token.length + 7 > 16 * 1024) throw authorityUnavailable();
|
|
2191
2212
|
return {
|
|
2192
2213
|
tokenType: "Bearer",
|
|
2193
2214
|
token: value.token,
|
|
@@ -2211,6 +2232,27 @@ function normalizeInvitationInput(value) {
|
|
|
2211
2232
|
if (!isObject(value) || Object.keys(value).length !== 1 || !isId(value.invitationId)) throw new AuthError("invalid_invitation", 422);
|
|
2212
2233
|
return { invitationId: value.invitationId };
|
|
2213
2234
|
}
|
|
2235
|
+
function normalizeVerificationEmailInput(value, appOrigin) {
|
|
2236
|
+
if (!isObject(value)) throw new TypeError("verification email input is invalid");
|
|
2237
|
+
const keys = Object.keys(value);
|
|
2238
|
+
if (keys.length !== 1 && keys.length !== 2 || !keys.includes("email") || keys.length === 2 && !keys.includes("callbackURL") || typeof value.email !== "string" || value.email.length > 320 || !email.test(value.email)) throw new TypeError("verification email input is invalid");
|
|
2239
|
+
if (value.callbackURL === void 0) return { email: value.email };
|
|
2240
|
+
if (typeof value.callbackURL !== "string" || value.callbackURL.length > 2048 || /[^\x20-\x7e]/.test(value.callbackURL)) throw new TypeError("callbackURL must belong to appOrigin");
|
|
2241
|
+
let callback;
|
|
2242
|
+
try {
|
|
2243
|
+
callback = new URL(value.callbackURL);
|
|
2244
|
+
} catch {
|
|
2245
|
+
throw new TypeError("callbackURL must belong to appOrigin");
|
|
2246
|
+
}
|
|
2247
|
+
if (callback.origin !== appOrigin || callback.username || callback.password || callback.toString() !== value.callbackURL) throw new TypeError("callbackURL must belong to appOrigin");
|
|
2248
|
+
return {
|
|
2249
|
+
email: value.email,
|
|
2250
|
+
callbackURL: value.callbackURL
|
|
2251
|
+
};
|
|
2252
|
+
}
|
|
2253
|
+
function normalizeVerificationEmailResponse(value) {
|
|
2254
|
+
if (!isObject(value) || value.status !== true) throw authorityUnavailable();
|
|
2255
|
+
}
|
|
2214
2256
|
function normalizeInvitationAcceptance(value, invitationId) {
|
|
2215
2257
|
if (!isObject(value) || !isObject(value.invitation) || !isObject(value.member) || value.invitation.id !== invitationId || value.invitation.status !== "accepted" || !isId(value.invitation.organizationId) || value.member.organizationId !== value.invitation.organizationId) throw authorityUnavailable();
|
|
2216
2258
|
return { organizationId: value.invitation.organizationId };
|
|
@@ -2780,120 +2822,148 @@ function createRequiredError(driver, name) {
|
|
|
2780
2822
|
if (Array.isArray(name)) return createError(driver, `Missing some of the required options ${name.map((n) => "`" + n + "`").join(", ")}`);
|
|
2781
2823
|
return createError(driver, `Missing required option \`${name}\`.`);
|
|
2782
2824
|
}
|
|
2783
|
-
|
|
2784
|
-
//#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/drivers/localstorage.mjs
|
|
2785
|
-
const DRIVER_NAME$2 = "localstorage";
|
|
2786
|
-
var localstorage_default = defineDriver((opts = {}) => {
|
|
2787
|
-
const storage = opts.storage || opts.localStorage || opts.sessionStorage || (opts.window || globalThis.window)?.[opts.windowKey || "localStorage"];
|
|
2788
|
-
if (!storage) throw createRequiredError(DRIVER_NAME$2, "localStorage");
|
|
2789
|
-
const base = opts.base ? normalizeKey(opts.base) : "";
|
|
2790
|
-
const r = (key) => (base ? `${base}:` : "") + key;
|
|
2791
|
-
let _storageListener;
|
|
2792
|
-
const _unwatch = () => {
|
|
2793
|
-
if (_storageListener) opts.window?.removeEventListener("storage", _storageListener);
|
|
2794
|
-
_storageListener = void 0;
|
|
2795
|
-
};
|
|
2796
|
-
return {
|
|
2797
|
-
name: DRIVER_NAME$2,
|
|
2798
|
-
options: opts,
|
|
2799
|
-
getInstance: () => storage,
|
|
2800
|
-
hasItem(key) {
|
|
2801
|
-
return Object.prototype.hasOwnProperty.call(storage, r(key));
|
|
2802
|
-
},
|
|
2803
|
-
getItem(key) {
|
|
2804
|
-
return storage.getItem(r(key));
|
|
2805
|
-
},
|
|
2806
|
-
setItem(key, value) {
|
|
2807
|
-
return storage.setItem(r(key), value);
|
|
2808
|
-
},
|
|
2809
|
-
removeItem(key) {
|
|
2810
|
-
return storage.removeItem(r(key));
|
|
2811
|
-
},
|
|
2812
|
-
getKeys() {
|
|
2813
|
-
const allKeys = Object.keys(storage);
|
|
2814
|
-
return base ? allKeys.filter((key) => key.startsWith(`${base}:`)).map((key) => key.slice(base.length + 1)) : allKeys;
|
|
2815
|
-
},
|
|
2816
|
-
clear(prefix) {
|
|
2817
|
-
const _base = [base, prefix].filter(Boolean).join(":");
|
|
2818
|
-
if (_base) {
|
|
2819
|
-
for (const key of Object.keys(storage)) if (key.startsWith(`${_base}:`)) storage?.removeItem(key);
|
|
2820
|
-
} else storage.clear();
|
|
2821
|
-
},
|
|
2822
|
-
dispose() {
|
|
2823
|
-
if (opts.window && _storageListener) opts.window.removeEventListener("storage", _storageListener);
|
|
2824
|
-
},
|
|
2825
|
-
watch(callback) {
|
|
2826
|
-
if (!opts.window) return _unwatch;
|
|
2827
|
-
_storageListener = (ev) => {
|
|
2828
|
-
if (ev.key) callback(ev.newValue ? "update" : "remove", ev.key);
|
|
2829
|
-
};
|
|
2830
|
-
opts.window.addEventListener("storage", _storageListener);
|
|
2831
|
-
return _unwatch;
|
|
2832
|
-
}
|
|
2833
|
-
};
|
|
2834
|
-
});
|
|
2825
|
+
var init_utils = __esmMin((() => {}));
|
|
2835
2826
|
//#endregion
|
|
2836
2827
|
//#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/drivers/memory.mjs
|
|
2837
|
-
|
|
2838
|
-
var memory_default
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2828
|
+
var memory_exports = __exportAll({ default: () => memory_default });
|
|
2829
|
+
var DRIVER_NAME$2, memory_default;
|
|
2830
|
+
var init_memory = __esmMin((() => {
|
|
2831
|
+
init_utils();
|
|
2832
|
+
DRIVER_NAME$2 = "memory";
|
|
2833
|
+
memory_default = defineDriver(() => {
|
|
2834
|
+
const data = new Map();
|
|
2835
|
+
return {
|
|
2836
|
+
name: DRIVER_NAME$2,
|
|
2837
|
+
getInstance: () => data,
|
|
2838
|
+
hasItem(key) {
|
|
2839
|
+
return data.has(key);
|
|
2840
|
+
},
|
|
2841
|
+
getItem(key) {
|
|
2842
|
+
return data.get(key) ?? null;
|
|
2843
|
+
},
|
|
2844
|
+
getItemRaw(key) {
|
|
2845
|
+
return data.get(key) ?? null;
|
|
2846
|
+
},
|
|
2847
|
+
setItem(key, value) {
|
|
2848
|
+
data.set(key, value);
|
|
2849
|
+
},
|
|
2850
|
+
setItemRaw(key, value) {
|
|
2851
|
+
data.set(key, value);
|
|
2852
|
+
},
|
|
2853
|
+
removeItem(key) {
|
|
2854
|
+
data.delete(key);
|
|
2855
|
+
},
|
|
2856
|
+
getKeys() {
|
|
2857
|
+
return [...data.keys()];
|
|
2858
|
+
},
|
|
2859
|
+
clear() {
|
|
2860
|
+
data.clear();
|
|
2861
|
+
},
|
|
2862
|
+
dispose() {
|
|
2863
|
+
data.clear();
|
|
2864
|
+
}
|
|
2865
|
+
};
|
|
2866
|
+
});
|
|
2867
|
+
}));
|
|
2868
|
+
//#endregion
|
|
2869
|
+
//#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/drivers/localstorage.mjs
|
|
2870
|
+
var localstorage_exports = __exportAll({ default: () => localstorage_default });
|
|
2871
|
+
var DRIVER_NAME$1, localstorage_default;
|
|
2872
|
+
var init_localstorage = __esmMin((() => {
|
|
2873
|
+
init_utils();
|
|
2874
|
+
DRIVER_NAME$1 = "localstorage";
|
|
2875
|
+
localstorage_default = defineDriver((opts = {}) => {
|
|
2876
|
+
const storage = opts.storage || opts.localStorage || opts.sessionStorage || (opts.window || globalThis.window)?.[opts.windowKey || "localStorage"];
|
|
2877
|
+
if (!storage) throw createRequiredError(DRIVER_NAME$1, "localStorage");
|
|
2878
|
+
const base = opts.base ? normalizeKey(opts.base) : "";
|
|
2879
|
+
const r = (key) => (base ? `${base}:` : "") + key;
|
|
2880
|
+
let _storageListener;
|
|
2881
|
+
const _unwatch = () => {
|
|
2882
|
+
if (_storageListener) opts.window?.removeEventListener("storage", _storageListener);
|
|
2883
|
+
_storageListener = void 0;
|
|
2884
|
+
};
|
|
2885
|
+
return {
|
|
2886
|
+
name: DRIVER_NAME$1,
|
|
2887
|
+
options: opts,
|
|
2888
|
+
getInstance: () => storage,
|
|
2889
|
+
hasItem(key) {
|
|
2890
|
+
return Object.prototype.hasOwnProperty.call(storage, r(key));
|
|
2891
|
+
},
|
|
2892
|
+
getItem(key) {
|
|
2893
|
+
return storage.getItem(r(key));
|
|
2894
|
+
},
|
|
2895
|
+
setItem(key, value) {
|
|
2896
|
+
return storage.setItem(r(key), value);
|
|
2897
|
+
},
|
|
2898
|
+
removeItem(key) {
|
|
2899
|
+
return storage.removeItem(r(key));
|
|
2900
|
+
},
|
|
2901
|
+
getKeys() {
|
|
2902
|
+
const allKeys = Object.keys(storage);
|
|
2903
|
+
return base ? allKeys.filter((key) => key.startsWith(`${base}:`)).map((key) => key.slice(base.length + 1)) : allKeys;
|
|
2904
|
+
},
|
|
2905
|
+
clear(prefix) {
|
|
2906
|
+
const _base = [base, prefix].filter(Boolean).join(":");
|
|
2907
|
+
if (_base) {
|
|
2908
|
+
for (const key of Object.keys(storage)) if (key.startsWith(`${_base}:`)) storage?.removeItem(key);
|
|
2909
|
+
} else storage.clear();
|
|
2910
|
+
},
|
|
2911
|
+
dispose() {
|
|
2912
|
+
if (opts.window && _storageListener) opts.window.removeEventListener("storage", _storageListener);
|
|
2913
|
+
},
|
|
2914
|
+
watch(callback) {
|
|
2915
|
+
if (!opts.window) return _unwatch;
|
|
2916
|
+
_storageListener = (ev) => {
|
|
2917
|
+
if (ev.key) callback(ev.newValue ? "update" : "remove", ev.key);
|
|
2918
|
+
};
|
|
2919
|
+
opts.window.addEventListener("storage", _storageListener);
|
|
2920
|
+
return _unwatch;
|
|
2921
|
+
}
|
|
2922
|
+
};
|
|
2923
|
+
});
|
|
2924
|
+
}));
|
|
2872
2925
|
//#endregion
|
|
2873
2926
|
//#region ../../node_modules/.pnpm/unstorage@1.17.5/node_modules/unstorage/drivers/session-storage.mjs
|
|
2874
|
-
|
|
2875
|
-
var session_storage_default
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2927
|
+
var session_storage_exports = __exportAll({ default: () => session_storage_default });
|
|
2928
|
+
var DRIVER_NAME, session_storage_default;
|
|
2929
|
+
var init_session_storage = __esmMin((() => {
|
|
2930
|
+
init_utils();
|
|
2931
|
+
init_localstorage();
|
|
2932
|
+
DRIVER_NAME = "session-storage";
|
|
2933
|
+
session_storage_default = defineDriver((opts = {}) => {
|
|
2934
|
+
return {
|
|
2935
|
+
...localstorage_default({
|
|
2936
|
+
windowKey: "sessionStorage",
|
|
2937
|
+
...opts
|
|
2938
|
+
}),
|
|
2939
|
+
name: DRIVER_NAME
|
|
2940
|
+
};
|
|
2941
|
+
});
|
|
2942
|
+
}));
|
|
2884
2943
|
//#endregion
|
|
2885
2944
|
//#region src/persistence.ts
|
|
2886
2945
|
const KEY = "finueva-auth:session:v1";
|
|
2887
2946
|
const MAX_SNAPSHOT_BYTES = 16 * 1024;
|
|
2888
2947
|
const MAX_FUTURE_SKEW_MS = 300 * 1e3;
|
|
2889
2948
|
function createSessionPersistence(persistence, authOrigin, now, timeoutMs) {
|
|
2890
|
-
|
|
2949
|
+
validatePersistence(persistence);
|
|
2950
|
+
const storageCache = {};
|
|
2951
|
+
const storage = async (persistence) => {
|
|
2952
|
+
if (typeof persistence === "string") {
|
|
2953
|
+
if (storageCache[persistence]) return storageCache[persistence];
|
|
2954
|
+
const storage = createStorage({ driver: guardRawValues(await selectDriver(persistence)) });
|
|
2955
|
+
storageCache[persistence] = storage;
|
|
2956
|
+
return storage;
|
|
2957
|
+
}
|
|
2958
|
+
if (typeof persistence === "object" && persistence !== null) return createStorage({ driver: guardRawValues(adaptDriver(persistence)) });
|
|
2959
|
+
return createStorage({ driver: guardRawValues(await selectDriver(persistence)) });
|
|
2960
|
+
};
|
|
2891
2961
|
let enabled = true;
|
|
2892
2962
|
let generation = 0;
|
|
2893
2963
|
let queue = Promise.resolve();
|
|
2894
2964
|
const operationTimeoutMs = Math.min(timeoutMs, 1e3);
|
|
2895
|
-
function cleanup() {
|
|
2896
|
-
|
|
2965
|
+
async function cleanup() {
|
|
2966
|
+
await (await storage(persistence)).removeItem(KEY);
|
|
2897
2967
|
}
|
|
2898
2968
|
async function finishesWithin(work) {
|
|
2899
2969
|
let timeout;
|
|
@@ -2926,12 +2996,13 @@ function createSessionPersistence(persistence, authOrigin, now, timeoutMs) {
|
|
|
2926
2996
|
return {
|
|
2927
2997
|
hydrate(accept) {
|
|
2928
2998
|
schedule(async (isCurrent) => {
|
|
2929
|
-
const
|
|
2999
|
+
const _storage = await storage(persistence);
|
|
3000
|
+
const value = await _storage.getItem(KEY);
|
|
2930
3001
|
if (!isCurrent()) return;
|
|
2931
3002
|
if (value === null) return;
|
|
2932
3003
|
const session = readSnapshot(value, authOrigin, now());
|
|
2933
3004
|
if (!session) {
|
|
2934
|
-
await
|
|
3005
|
+
await _storage.removeItem(KEY);
|
|
2935
3006
|
return;
|
|
2936
3007
|
}
|
|
2937
3008
|
if (isCurrent()) accept(session);
|
|
@@ -2952,8 +3023,9 @@ function createSessionPersistence(persistence, authOrigin, now, timeoutMs) {
|
|
|
2952
3023
|
};
|
|
2953
3024
|
schedule(async () => {
|
|
2954
3025
|
const cachedAt = now();
|
|
3026
|
+
const _storage = await storage(persistence);
|
|
2955
3027
|
if (expiresAt <= cachedAt) {
|
|
2956
|
-
await
|
|
3028
|
+
await _storage.removeItem(KEY);
|
|
2957
3029
|
return;
|
|
2958
3030
|
}
|
|
2959
3031
|
const snapshot = {
|
|
@@ -2963,28 +3035,57 @@ function createSessionPersistence(persistence, authOrigin, now, timeoutMs) {
|
|
|
2963
3035
|
session: normalizedSession
|
|
2964
3036
|
};
|
|
2965
3037
|
if (byteLength(JSON.stringify(snapshot)) > MAX_SNAPSHOT_BYTES) {
|
|
2966
|
-
await
|
|
3038
|
+
await _storage.removeItem(KEY);
|
|
2967
3039
|
return;
|
|
2968
3040
|
}
|
|
2969
|
-
await
|
|
2970
|
-
if (expiresAt <= now()) await
|
|
3041
|
+
await _storage.setItem(KEY, snapshot);
|
|
3042
|
+
if (expiresAt <= now()) await _storage.removeItem(KEY);
|
|
2971
3043
|
});
|
|
2972
3044
|
},
|
|
2973
3045
|
remove() {
|
|
2974
|
-
schedule(() =>
|
|
3046
|
+
schedule(async () => {
|
|
3047
|
+
(await storage(persistence)).removeItem(KEY);
|
|
3048
|
+
});
|
|
2975
3049
|
}
|
|
2976
3050
|
};
|
|
2977
3051
|
}
|
|
2978
|
-
function
|
|
3052
|
+
function validatePersistence(persistence) {
|
|
3053
|
+
if (persistence === void 0) return;
|
|
3054
|
+
if (persistence === "local" || persistence === "session" || persistence === "memory") return;
|
|
3055
|
+
if (typeof persistence === "object" && persistence !== null) {
|
|
3056
|
+
adaptDriver(persistence);
|
|
3057
|
+
return;
|
|
3058
|
+
}
|
|
3059
|
+
throw new TypeError("persistence must be local, session, memory, or a driver");
|
|
3060
|
+
}
|
|
3061
|
+
async function selectDriver(persistence) {
|
|
2979
3062
|
if (typeof persistence === "object" && persistence !== null) return adaptDriver(persistence);
|
|
2980
|
-
if (persistence === "memory")
|
|
3063
|
+
if (persistence === "memory") {
|
|
3064
|
+
const { default: memoryDriver } = await Promise.resolve().then(() => (init_memory(), memory_exports));
|
|
3065
|
+
return memoryDriver();
|
|
3066
|
+
}
|
|
2981
3067
|
if (persistence === "local" || persistence === "session") {
|
|
2982
3068
|
const storage = browserStorage(persistence);
|
|
2983
|
-
|
|
3069
|
+
if (persistence === "local") {
|
|
3070
|
+
const { default: localStorageDriver } = await Promise.resolve().then(() => (init_localstorage(), localstorage_exports));
|
|
3071
|
+
if (storage) return localStorageDriver({ storage });
|
|
3072
|
+
const { default: memoryDriver } = await Promise.resolve().then(() => (init_memory(), memory_exports));
|
|
3073
|
+
return memoryDriver();
|
|
3074
|
+
} else {
|
|
3075
|
+
const { default: sessionStorageDriver } = await Promise.resolve().then(() => (init_session_storage(), session_storage_exports));
|
|
3076
|
+
if (storage) return sessionStorageDriver({ storage });
|
|
3077
|
+
const { default: memoryDriver } = await Promise.resolve().then(() => (init_memory(), memory_exports));
|
|
3078
|
+
return memoryDriver();
|
|
3079
|
+
}
|
|
2984
3080
|
}
|
|
2985
3081
|
if (persistence !== void 0) throw new TypeError("persistence must be local, session, memory, or a driver");
|
|
2986
3082
|
const storage = browserStorage("local");
|
|
2987
|
-
|
|
3083
|
+
if (storage) {
|
|
3084
|
+
const { default: localStorageDriver } = await Promise.resolve().then(() => (init_localstorage(), localstorage_exports));
|
|
3085
|
+
return localStorageDriver({ storage });
|
|
3086
|
+
}
|
|
3087
|
+
const { default: memoryDriver } = await Promise.resolve().then(() => (init_memory(), memory_exports));
|
|
3088
|
+
return memoryDriver();
|
|
2988
3089
|
}
|
|
2989
3090
|
function browserStorage(mode) {
|
|
2990
3091
|
try {
|
|
@@ -3324,6 +3425,16 @@ function createAuthClient(options) {
|
|
|
3324
3425
|
if (activeSignInGeneration === generation) activeSignInGeneration = void 0;
|
|
3325
3426
|
}
|
|
3326
3427
|
},
|
|
3428
|
+
async sendVerificationEmail(input) {
|
|
3429
|
+
const body = normalizeVerificationEmailInput(input, appOrigin);
|
|
3430
|
+
normalizeVerificationEmailResponse(await requestJson(joinURL(authOrigin, "api/v1/auth/send-verification-email"), {
|
|
3431
|
+
fetch: fetchImpl,
|
|
3432
|
+
timeoutMs,
|
|
3433
|
+
method: "POST",
|
|
3434
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
3435
|
+
body
|
|
3436
|
+
}));
|
|
3437
|
+
},
|
|
3327
3438
|
signOut,
|
|
3328
3439
|
getDriveCredential(input) {
|
|
3329
3440
|
let workspace;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as WorkspaceSelection, c as AuthUser, f as InvitationAcceptance, l as DriveCredential, m as PersonalWorkspaceSelection, o as AuthSession, p as OrganizationWorkspaceSelection, r as AuthOrganization, t as AcceptInvitationInput, u as DriveCredentialInput } from "./types-HSdjQWMZ.js";
|
|
2
2
|
import { n as AuthErrorCode, r as AuthErrorStatus, t as AuthError } from "./errors-Crd93Rah.js";
|
|
3
3
|
//#region src/server.d.ts
|
|
4
4
|
interface ServerAuthOptions {
|
package/dist/server.js
CHANGED
|
@@ -466,6 +466,7 @@ var AuthError = class extends Error {
|
|
|
466
466
|
};
|
|
467
467
|
//#endregion
|
|
468
468
|
//#region src/shared.ts
|
|
469
|
+
const DRIVE_CREDENTIAL_LIFETIME_SECONDS = 840;
|
|
469
470
|
const id = /^[A-Za-z0-9_-]{1,128}$/;
|
|
470
471
|
const email = /^[^\s@]+@[^\s@]+$/;
|
|
471
472
|
function normalizeOrigin(value, name) {
|
|
@@ -504,7 +505,7 @@ function normalizeSession(value) {
|
|
|
504
505
|
};
|
|
505
506
|
}
|
|
506
507
|
function normalizeDriveCredential(value, now) {
|
|
507
|
-
if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !==
|
|
508
|
+
if (!isObject(value) || value.tokenType !== "Bearer" || value.expiresIn !== DRIVE_CREDENTIAL_LIFETIME_SECONDS || typeof value.token !== "string" || value.token.length === 0 || value.token.length + 7 > 16 * 1024) throw authorityUnavailable();
|
|
508
509
|
return {
|
|
509
510
|
tokenType: "Bearer",
|
|
510
511
|
token: value.token,
|
|
@@ -64,6 +64,10 @@ interface SignInInput {
|
|
|
64
64
|
email: string;
|
|
65
65
|
password: string;
|
|
66
66
|
}
|
|
67
|
+
interface SendVerificationEmailInput {
|
|
68
|
+
email: string;
|
|
69
|
+
callbackURL?: string;
|
|
70
|
+
}
|
|
67
71
|
interface DriveCredentialInput {
|
|
68
72
|
workspace: WorkspaceSelection;
|
|
69
73
|
forceRefresh?: boolean;
|
|
@@ -80,6 +84,7 @@ interface FinuevaAuthClient {
|
|
|
80
84
|
acceptInvitation(input: AcceptInvitationInput): Promise<InvitationAcceptance>;
|
|
81
85
|
getSession(): Promise<AuthSession | null>;
|
|
82
86
|
listOrganizations(): Promise<AuthOrganization[]>;
|
|
87
|
+
sendVerificationEmail(input: SendVerificationEmailInput): Promise<void>;
|
|
83
88
|
signIn(input: SignInInput): Promise<AuthSession>;
|
|
84
89
|
signOut(): Promise<void>;
|
|
85
90
|
getDriveCredential(input: DriveCredentialInput): Promise<DriveCredential>;
|
|
@@ -87,4 +92,4 @@ interface FinuevaAuthClient {
|
|
|
87
92
|
onSessionChange(listener: (session: AuthSession | null) => void): () => void;
|
|
88
93
|
}
|
|
89
94
|
//#endregion
|
|
90
|
-
export { AuthPersistenceDriver as a, AuthUser as c, FinuevaAuthClient as d, InvitationAcceptance as f,
|
|
95
|
+
export { WorkspaceSelection as _, AuthPersistenceDriver as a, AuthUser as c, FinuevaAuthClient as d, InvitationAcceptance as f, SignInInput as g, SendVerificationEmailInput as h, AuthPersistence as i, DriveCredential as l, PersonalWorkspaceSelection as m, AuthClientOptions as n, AuthSession as o, OrganizationWorkspaceSelection as p, AuthOrganization as r, AuthState as s, AcceptInvitationInput as t, DriveCredentialInput as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finueva/auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Public browser and server SDK for Finueva Auth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "rolldown -c",
|
|
42
42
|
"coverage": "vitest run --coverage",
|
|
43
|
-
"lint": "
|
|
43
|
+
"lint": "oxlint . --deny-warnings",
|
|
44
44
|
"test": "pnpm test:unit && pnpm build && pnpm test:package",
|
|
45
45
|
"test:composition": "node scripts/test-composition.mjs",
|
|
46
46
|
"test:package": "node scripts/test-package.mjs",
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
"typecheck": "tsc --noEmit"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@chiballc/utils": "2.
|
|
51
|
+
"@chiballc/utils": "2.5.0",
|
|
52
52
|
"@types/node": "24.13.3",
|
|
53
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
53
54
|
"@vitest/coverage-v8": "4.1.10",
|
|
54
55
|
"better-auth": "1.6.22",
|
|
55
56
|
"miniflare": "4.20260722.0",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"playwright": "1.62.0",
|
|
58
59
|
"rolldown": "1.2.0",
|
|
59
60
|
"rolldown-plugin-dts": "0.27.14",
|
|
60
|
-
"typescript": "
|
|
61
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
61
62
|
"ufo": "1.6.4",
|
|
62
63
|
"unstorage": "1.17.5",
|
|
63
64
|
"vitest": "4.1.10"
|