limen-auth 0.0.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/LICENSE +21 -0
- package/README.md +72 -0
- package/dist/bearer-Cqmrmjjf.mjs +84 -0
- package/dist/bearer-Cqmrmjjf.mjs.map +1 -0
- package/dist/client-Er91De-z.mjs +705 -0
- package/dist/client-Er91De-z.mjs.map +1 -0
- package/dist/constants-CsR2pQ_9.mjs +15 -0
- package/dist/constants-CsR2pQ_9.mjs.map +1 -0
- package/dist/define-plugin-C7WOGU4b.mjs +24 -0
- package/dist/define-plugin-C7WOGU4b.mjs.map +1 -0
- package/dist/define-plugin-Dv0xXIaH.d.mts +450 -0
- package/dist/define-plugin-Dv0xXIaH.d.mts.map +1 -0
- package/dist/errors-4YJYt6f0.mjs +37 -0
- package/dist/errors-4YJYt6f0.mjs.map +1 -0
- package/dist/helpers-Cs3VtXdv.mjs +54 -0
- package/dist/helpers-Cs3VtXdv.mjs.map +1 -0
- package/dist/helpers-CvmKjWi2.d.mts +10 -0
- package/dist/helpers-CvmKjWi2.d.mts.map +1 -0
- package/dist/index-B8SpHkSd.d.mts +48 -0
- package/dist/index-B8SpHkSd.d.mts.map +1 -0
- package/dist/index-C6atwjEq.d.mts +65 -0
- package/dist/index-C6atwjEq.d.mts.map +1 -0
- package/dist/index-C9EuA9UZ.d.mts +32 -0
- package/dist/index-C9EuA9UZ.d.mts.map +1 -0
- package/dist/index-Cgr2wHmM.d.mts +87 -0
- package/dist/index-Cgr2wHmM.d.mts.map +1 -0
- package/dist/index-DV6YcNSu.d.mts +81 -0
- package/dist/index-DV6YcNSu.d.mts.map +1 -0
- package/dist/index-dEksIImj.d.mts +28 -0
- package/dist/index-dEksIImj.d.mts.map +1 -0
- package/dist/index.d.mts +30 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugins/bearer/index.d.mts +2 -0
- package/dist/plugins/bearer/index.mjs +2 -0
- package/dist/plugins/credential/index.d.mts +2 -0
- package/dist/plugins/credential/index.mjs +50 -0
- package/dist/plugins/credential/index.mjs.map +1 -0
- package/dist/plugins/index.d.mts +7 -0
- package/dist/plugins/index.mjs +7 -0
- package/dist/plugins/magic-link/index.d.mts +2 -0
- package/dist/plugins/magic-link/index.mjs +21 -0
- package/dist/plugins/magic-link/index.mjs.map +1 -0
- package/dist/plugins/oauth/index.d.mts +2 -0
- package/dist/plugins/oauth/index.mjs +56 -0
- package/dist/plugins/oauth/index.mjs.map +1 -0
- package/dist/plugins/session-jwt/index.d.mts +2 -0
- package/dist/plugins/session-jwt/index.mjs +2 -0
- package/dist/plugins/two-factor/index.d.mts +2 -0
- package/dist/plugins/two-factor/index.mjs +52 -0
- package/dist/plugins/two-factor/index.mjs.map +1 -0
- package/dist/react/index.d.mts +24 -0
- package/dist/react/index.d.mts.map +1 -0
- package/dist/react/index.mjs +31 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/route-DGxvFqWl.mjs +19 -0
- package/dist/route-DGxvFqWl.mjs.map +1 -0
- package/dist/session-jwt-DgLdMQxP.mjs +129 -0
- package/dist/session-jwt-DgLdMQxP.mjs.map +1 -0
- package/dist/solid/index.d.mts +25 -0
- package/dist/solid/index.d.mts.map +1 -0
- package/dist/solid/index.mjs +28 -0
- package/dist/solid/index.mjs.map +1 -0
- package/dist/svelte/index.d.mts +25 -0
- package/dist/svelte/index.d.mts.map +1 -0
- package/dist/svelte/index.mjs +18 -0
- package/dist/svelte/index.mjs.map +1 -0
- package/dist/vue/index.d.mts +36 -0
- package/dist/vue/index.d.mts.map +1 -0
- package/dist/vue/index.mjs +36 -0
- package/dist/vue/index.mjs.map +1 -0
- package/package.json +123 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/errors.ts
|
|
2
|
+
/** Map HTTP status → typed code. Anything unmapped becomes `"unknown"`. */
|
|
3
|
+
function deriveErrorCode(status) {
|
|
4
|
+
if (status === 401) return "unauthorized";
|
|
5
|
+
if (status === 403) return "forbidden";
|
|
6
|
+
if (status === 404) return "not_found";
|
|
7
|
+
if (status === 409) return "conflict";
|
|
8
|
+
if (status === 422 || status === 400) return "validation_error";
|
|
9
|
+
if (status === 429) return "rate_limited";
|
|
10
|
+
if (status >= 500 && status < 600) return "server_error";
|
|
11
|
+
return "unknown";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The single error type every SDK call throws on non-2xx. Carries the raw
|
|
15
|
+
* server message, the HTTP status, and a derived typed code. Subclass-free so
|
|
16
|
+
* `instanceof LimenError` is the only check consumers need.
|
|
17
|
+
*/
|
|
18
|
+
var LimenError = class extends Error {
|
|
19
|
+
name = "LimenError";
|
|
20
|
+
status;
|
|
21
|
+
code;
|
|
22
|
+
constructor(message, status, code) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.status = status;
|
|
25
|
+
this.code = code ?? deriveErrorCode(status);
|
|
26
|
+
}
|
|
27
|
+
get isUnauthorized() {
|
|
28
|
+
return this.code === "unauthorized";
|
|
29
|
+
}
|
|
30
|
+
get isRateLimited() {
|
|
31
|
+
return this.code === "rate_limited";
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { deriveErrorCode as n, LimenError as t };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=errors-4YJYt6f0.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-4YJYt6f0.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["export type LimenErrorCode =\n | \"unauthorized\"\n | \"forbidden\"\n | \"not_found\"\n | \"rate_limited\"\n | \"validation_error\"\n | \"conflict\"\n | \"server_error\"\n | \"unknown\";\n\n/** Map HTTP status → typed code. Anything unmapped becomes `\"unknown\"`. */\n// prettier-ignore\nexport function deriveErrorCode(status: number): LimenErrorCode {\n if (status === 401) {return \"unauthorized\";}\n if (status === 403) {return \"forbidden\";}\n if (status === 404) {return \"not_found\";}\n if (status === 409) {return \"conflict\";}\n if (status === 422 || status === 400) {return \"validation_error\";}\n if (status === 429) {return \"rate_limited\";}\n if (status >= 500 && status < 600) {return \"server_error\";}\n return \"unknown\";\n}\n\n/**\n * The single error type every SDK call throws on non-2xx. Carries the raw\n * server message, the HTTP status, and a derived typed code. Subclass-free so\n * `instanceof LimenError` is the only check consumers need.\n */\nexport class LimenError extends Error {\n override readonly name = \"LimenError\";\n readonly status: number;\n readonly code: LimenErrorCode;\n\n constructor(message: string, status: number, code?: LimenErrorCode) {\n super(message);\n this.status = status;\n this.code = code ?? deriveErrorCode(status);\n }\n\n get isUnauthorized(): boolean {\n return this.code === \"unauthorized\";\n }\n\n get isRateLimited(): boolean {\n return this.code === \"rate_limited\";\n }\n}\n"],"mappings":";;AAYA,SAAgB,gBAAgB,QAAgC;CAC9D,IAAI,WAAW,KAAM,OAAO;CAC5B,IAAI,WAAW,KAAM,OAAO;CAC5B,IAAI,WAAW,KAAM,OAAO;CAC5B,IAAI,WAAW,KAAM,OAAO;CAC5B,IAAI,WAAW,OAAO,WAAW,KAAM,OAAO;CAC9C,IAAI,WAAW,KAAM,OAAO;CAC5B,IAAI,UAAU,OAAO,SAAS,KAAM,OAAO;CAC3C,OAAO;AACT;;;;;;AAOA,IAAa,aAAb,cAAgC,MAAM;CACpC,OAAyB;CACzB;CACA;CAEA,YAAY,SAAiB,QAAgB,MAAuB;EAClE,MAAM,OAAO;EACb,KAAK,SAAS;EACd,KAAK,OAAO,QAAQ,gBAAgB,MAAM;CAC5C;CAEA,IAAI,iBAA0B;EAC5B,OAAO,KAAK,SAAS;CACvB;CAEA,IAAI,gBAAyB;EAC3B,OAAO,KAAK,SAAS;CACvB;AACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
//#region src/helpers.ts
|
|
2
|
+
function stripTrailingSlash(s) {
|
|
3
|
+
return s.endsWith("/") ? s.slice(0, -1) : s;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Ensure a leading slash while preserving `""` as "no path".
|
|
7
|
+
*/
|
|
8
|
+
function ensureLeadingSlash(s) {
|
|
9
|
+
if (s === "" || s === "/") return s;
|
|
10
|
+
return s.startsWith("/") ? s : `/${s}`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Normalize a base path to `""` or a leading-slash path without a trailing
|
|
14
|
+
* slash.
|
|
15
|
+
*/
|
|
16
|
+
function normalizeBasePath(p) {
|
|
17
|
+
if (p === "" || p === "/") return "";
|
|
18
|
+
const withLeading = p.startsWith("/") ? p : `/${p}`;
|
|
19
|
+
return withLeading.endsWith("/") ? withLeading.slice(0, -1) : withLeading;
|
|
20
|
+
}
|
|
21
|
+
function joinURL(baseURL, path) {
|
|
22
|
+
return stripTrailingSlash(baseURL) + ensureLeadingSlash(path);
|
|
23
|
+
}
|
|
24
|
+
function toCamelCaseKey(key) {
|
|
25
|
+
return key.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
26
|
+
}
|
|
27
|
+
function kebabToCamel(key) {
|
|
28
|
+
return key.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Shallow-convert an object's keys from snake_case to camelCase. Non-object
|
|
32
|
+
* inputs and arrays pass through untouched.
|
|
33
|
+
*/
|
|
34
|
+
function camelizeKeys(raw) {
|
|
35
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return raw;
|
|
36
|
+
const out = {};
|
|
37
|
+
for (const [key, value] of Object.entries(raw)) out[toCamelCaseKey(key)] = value;
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
function camelizeEach(raw) {
|
|
41
|
+
if (!Array.isArray(raw)) return [];
|
|
42
|
+
return raw.map((item) => camelizeKeys(item));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Convert camelCase to snake_case, leaving already-snake-cased keys unchanged.
|
|
46
|
+
*/
|
|
47
|
+
function camelToSnake(key) {
|
|
48
|
+
if (key.includes("_")) return key;
|
|
49
|
+
return key.replace(/[A-Z]/g, (m) => `_${m.toLowerCase()}`);
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { joinURL as a, stripTrailingSlash as c, ensureLeadingSlash as i, toCamelCaseKey as l, camelizeEach as n, kebabToCamel as o, camelizeKeys as r, normalizeBasePath as s, camelToSnake as t };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=helpers-Cs3VtXdv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-Cs3VtXdv.mjs","names":[],"sources":["../src/helpers.ts"],"sourcesContent":["export function stripTrailingSlash(s: string): string {\n return s.endsWith(\"/\") ? s.slice(0, -1) : s;\n}\n\n/**\n * Ensure a leading slash while preserving `\"\"` as \"no path\".\n */\nexport function ensureLeadingSlash(s: string): string {\n if (s === \"\" || s === \"/\") {\n return s;\n }\n return s.startsWith(\"/\") ? s : `/${s}`;\n}\n\n/**\n * Normalize a base path to `\"\"` or a leading-slash path without a trailing\n * slash.\n */\nexport function normalizeBasePath(p: string): string {\n if (p === \"\" || p === \"/\") {\n return \"\";\n }\n const withLeading = p.startsWith(\"/\") ? p : `/${p}`;\n return withLeading.endsWith(\"/\") ? withLeading.slice(0, -1) : withLeading;\n}\n\nexport function joinURL(baseURL: string, path: string): string {\n return stripTrailingSlash(baseURL) + ensureLeadingSlash(path);\n}\n\nexport function toCamelCaseKey(key: string): string {\n return key.replace(/_([a-z])/g, (_, c: string) => c.toUpperCase());\n}\n\nexport function kebabToCamel(key: string): string {\n return key.replace(/-([a-z0-9])/g, (_, c: string) => c.toUpperCase());\n}\n\n/**\n * Shallow-convert an object's keys from snake_case to camelCase. Non-object\n * inputs and arrays pass through untouched.\n */\nexport function camelizeKeys<T = Record<string, unknown>>(raw: unknown): T {\n if (raw === null || typeof raw !== \"object\" || Array.isArray(raw)) {\n return raw as T;\n }\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(raw)) {\n out[toCamelCaseKey(key)] = value;\n }\n return out as T;\n}\n\nexport function camelizeEach<T = Record<string, unknown>>(raw: unknown): T[] {\n if (!Array.isArray(raw)) {\n return [];\n }\n return raw.map((item) => camelizeKeys<T>(item));\n}\n\n/**\n * Convert camelCase to snake_case, leaving already-snake-cased keys unchanged.\n */\nexport function camelToSnake(key: string): string {\n if (key.includes(\"_\")) {\n return key;\n }\n return key.replace(/[A-Z]/g, (m) => `_${m.toLowerCase()}`);\n}\n"],"mappings":";AAAA,SAAgB,mBAAmB,GAAmB;CACpD,OAAO,EAAE,SAAS,GAAG,IAAI,EAAE,MAAM,GAAG,EAAE,IAAI;AAC5C;;;;AAKA,SAAgB,mBAAmB,GAAmB;CACpD,IAAI,MAAM,MAAM,MAAM,KACpB,OAAO;CAET,OAAO,EAAE,WAAW,GAAG,IAAI,IAAI,IAAI;AACrC;;;;;AAMA,SAAgB,kBAAkB,GAAmB;CACnD,IAAI,MAAM,MAAM,MAAM,KACpB,OAAO;CAET,MAAM,cAAc,EAAE,WAAW,GAAG,IAAI,IAAI,IAAI;CAChD,OAAO,YAAY,SAAS,GAAG,IAAI,YAAY,MAAM,GAAG,EAAE,IAAI;AAChE;AAEA,SAAgB,QAAQ,SAAiB,MAAsB;CAC7D,OAAO,mBAAmB,OAAO,IAAI,mBAAmB,IAAI;AAC9D;AAEA,SAAgB,eAAe,KAAqB;CAClD,OAAO,IAAI,QAAQ,cAAc,GAAG,MAAc,EAAE,YAAY,CAAC;AACnE;AAEA,SAAgB,aAAa,KAAqB;CAChD,OAAO,IAAI,QAAQ,iBAAiB,GAAG,MAAc,EAAE,YAAY,CAAC;AACtE;;;;;AAMA,SAAgB,aAA0C,KAAiB;CACzE,IAAI,QAAQ,QAAQ,OAAO,QAAQ,YAAY,MAAM,QAAQ,GAAG,GAC9D,OAAO;CAET,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GAAG,GAC3C,IAAI,eAAe,GAAG,KAAK;CAE7B,OAAO;AACT;AAEA,SAAgB,aAA0C,KAAmB;CAC3E,IAAI,CAAC,MAAM,QAAQ,GAAG,GACpB,OAAO,CAAC;CAEV,OAAO,IAAI,KAAK,SAAS,aAAgB,IAAI,CAAC;AAChD;;;;AAKA,SAAgB,aAAa,KAAqB;CAChD,IAAI,IAAI,SAAS,GAAG,GAClB,OAAO;CAET,OAAO,IAAI,QAAQ,WAAW,MAAM,IAAI,EAAE,YAAY,GAAG;AAC3D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/helpers.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Shallow-convert an object's keys from snake_case to camelCase. Non-object
|
|
4
|
+
* inputs and arrays pass through untouched.
|
|
5
|
+
*/
|
|
6
|
+
declare function camelizeKeys<T = Record<string, unknown>>(raw: unknown): T;
|
|
7
|
+
declare function camelizeEach<T = Record<string, unknown>>(raw: unknown): T[];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { camelizeKeys as n, camelizeEach as t };
|
|
10
|
+
//# sourceMappingURL=helpers-CvmKjWi2.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-CvmKjWi2.d.mts","names":[],"sources":["../src/helpers.ts"],"mappings":";;;;;iBA0CgB,YAAA,KAAiB,MAAA,mBAAyB,GAAA,YAAe,CAAC;AAAA,iBAW1D,YAAA,KAAiB,MAAA,mBAAyB,GAAA,YAAe,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { n as ClientPlugin } from "./define-plugin-Dv0xXIaH.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/bearer/types.d.ts
|
|
4
|
+
type BearerPlugin = {
|
|
5
|
+
bearer: {
|
|
6
|
+
/** Currently stored tokens, or `null` if signed out / never set. */getTokens: () => BearerTokens | null; /** Manually persist tokens. */
|
|
7
|
+
setTokens: (tokens: BearerTokens) => void; /** Discard stored tokens. Also runs automatically on `signOut`. */
|
|
8
|
+
clear: () => void;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type BearerTokens = {
|
|
12
|
+
accessToken: string;
|
|
13
|
+
refreshToken?: string;
|
|
14
|
+
};
|
|
15
|
+
interface BearerStorage {
|
|
16
|
+
get(): BearerTokens | null;
|
|
17
|
+
set(tokens: BearerTokens): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
20
|
+
type BearerPluginConfig = {
|
|
21
|
+
/**
|
|
22
|
+
* Where to persist tokens. Defaults to `localStorage` when available,
|
|
23
|
+
* otherwise an in-memory store (SSR / non-browser).
|
|
24
|
+
*/
|
|
25
|
+
storage?: BearerStorage;
|
|
26
|
+
/**
|
|
27
|
+
* Key used by the default `localStorage` adapter. Ignored when a custom
|
|
28
|
+
* `storage` is supplied. Defaults to `"limen.tokens"`.
|
|
29
|
+
*/
|
|
30
|
+
storageKey?: string;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/plugins/bearer/storage.d.ts
|
|
34
|
+
declare function memoryBearerStorage(): BearerStorage;
|
|
35
|
+
declare function localStorageBearerStorage(key?: string): BearerStorage;
|
|
36
|
+
declare function resolveDefaultStorage(key: string): BearerStorage;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/plugins/bearer/index.d.ts
|
|
39
|
+
declare function bearerPlugin(config?: BearerPluginConfig): ClientPlugin<"bearer", "", [], {
|
|
40
|
+
bearer: {
|
|
41
|
+
getTokens: () => BearerTokens | null;
|
|
42
|
+
setTokens: (tokens: BearerTokens) => void;
|
|
43
|
+
clear: () => void;
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { BearerPlugin as a, BearerTokens as c, resolveDefaultStorage as i, localStorageBearerStorage as n, BearerPluginConfig as o, memoryBearerStorage as r, BearerStorage as s, bearerPlugin as t };
|
|
48
|
+
//# sourceMappingURL=index-B8SpHkSd.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-B8SpHkSd.d.mts","names":[],"sources":["../src/plugins/bearer/types.ts","../src/plugins/bearer/storage.ts","../src/plugins/bearer/index.ts"],"mappings":";;;KAAY,YAAA;EACV,MAAA;wEAEE,SAAA,QAAiB,YAAA,SAHG;IAKpB,SAAA,GAAY,MAAA,EAAQ,YAAY,WAAA;IAEhC,KAAA;EAAA;AAAA;AAAA,KAIQ,YAAA;EACV,WAAA;EACA,YAAY;AAAA;AAAA,UAGG,aAAA;EACf,GAAA,IAAO,YAAA;EACP,GAAA,CAAI,MAAA,EAAQ,YAAY;EACxB,KAAA;AAAA;AAAA,KAGU,kBAAA;EATE;AAGd;;;EAWE,OAAA,GAAU,aAAa;EAVvB;;;;EAeA,UAAA;AAAA;;;iBC7Bc,mBAAA,IAAuB,aAAa;AAAA,iBAapC,yBAAA,CAA0B,GAAA,YAA0C,aAAa;AAAA,iBA0BjF,qBAAA,CAAsB,GAAA,WAAc,aAAa;;;iBCrCjD,YAAA,CAAa,MAAA,GAAQ,kBAAA,GASG,YAAA;;;wBAAZ,YAAA"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { E as Session, F as RouteDescriptor, n as ClientPlugin } from "./define-plugin-Dv0xXIaH.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/two-factor/types.d.ts
|
|
4
|
+
type TwoFactorConfig = {
|
|
5
|
+
/** Called when sign-in requires a two-factor challenge. */onTwoFactorRedirect: () => void;
|
|
6
|
+
};
|
|
7
|
+
type VerifyInput = {
|
|
8
|
+
code: string;
|
|
9
|
+
method?: TwoFactorMethod;
|
|
10
|
+
};
|
|
11
|
+
type InitiateSetupInput = {
|
|
12
|
+
password: string;
|
|
13
|
+
};
|
|
14
|
+
type FinalizeSetupInput = {
|
|
15
|
+
code: string;
|
|
16
|
+
};
|
|
17
|
+
type DisableTwoFactorInput = {
|
|
18
|
+
password: string;
|
|
19
|
+
};
|
|
20
|
+
type SendOTPInput = {
|
|
21
|
+
email: string;
|
|
22
|
+
};
|
|
23
|
+
type TwoFactorSetupURI = {
|
|
24
|
+
uri: string;
|
|
25
|
+
};
|
|
26
|
+
type TwoFactorMethod = "totp" | "otp";
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/plugins/two-factor/index.d.ts
|
|
29
|
+
declare function twoFactorPlugin<TFields = unknown>(config: TwoFactorConfig): ClientPlugin<"two-factor", "/two-factor", [RouteDescriptor<InitiateSetupInput, TwoFactorSetupURI, {
|
|
30
|
+
readonly method: "POST";
|
|
31
|
+
readonly path: "/initiate-setup";
|
|
32
|
+
}>, RouteDescriptor<FinalizeSetupInput, Session<TFields>, {
|
|
33
|
+
readonly method: "POST";
|
|
34
|
+
readonly path: "/finalize-setup";
|
|
35
|
+
readonly parseSession: true;
|
|
36
|
+
}>, RouteDescriptor<DisableTwoFactorInput, Session<TFields>, {
|
|
37
|
+
readonly method: "POST";
|
|
38
|
+
readonly path: "/disable";
|
|
39
|
+
readonly parseSession: true;
|
|
40
|
+
}>, RouteDescriptor<VerifyInput, Session<TFields>, {
|
|
41
|
+
readonly method: "POST";
|
|
42
|
+
readonly path: "/verify";
|
|
43
|
+
readonly parseSession: true;
|
|
44
|
+
}>, RouteDescriptor<void, TwoFactorSetupURI, {
|
|
45
|
+
readonly method: "GET";
|
|
46
|
+
readonly path: "/totp/uri";
|
|
47
|
+
readonly as: "twoFactor.getTotpUri";
|
|
48
|
+
}>, RouteDescriptor<void, string[], {
|
|
49
|
+
readonly method: "GET";
|
|
50
|
+
readonly path: "/backup-codes";
|
|
51
|
+
readonly as: "twoFactor.getBackupCodes";
|
|
52
|
+
}>, RouteDescriptor<void, string[], {
|
|
53
|
+
readonly method: "PUT";
|
|
54
|
+
readonly path: "/backup-codes";
|
|
55
|
+
readonly as: "twoFactor.regenerateBackupCodes";
|
|
56
|
+
}>, RouteDescriptor<SendOTPInput, {
|
|
57
|
+
message: string;
|
|
58
|
+
}, {
|
|
59
|
+
readonly method: "POST";
|
|
60
|
+
readonly path: "/otp/send";
|
|
61
|
+
readonly as: "twoFactor.sendOTP";
|
|
62
|
+
}>], Record<never, never>>;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { SendOTPInput as a, TwoFactorSetupURI as c, InitiateSetupInput as i, VerifyInput as l, DisableTwoFactorInput as n, TwoFactorConfig as o, FinalizeSetupInput as r, TwoFactorMethod as s, twoFactorPlugin as t };
|
|
65
|
+
//# sourceMappingURL=index-C6atwjEq.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C6atwjEq.d.mts","names":[],"sources":["../src/plugins/two-factor/types.ts","../src/plugins/two-factor/index.ts"],"mappings":";;;KAAY,eAAA;6DAEV,mBAAmB;AAAA;AAAA,KAGT,WAAA;EACV,IAAA;EACA,MAAA,GAAS,eAAe;AAAA;AAAA,KAGd,kBAAA;EACV,QAAQ;AAAA;AAAA,KAGE,kBAAA;EACV,IAAI;AAAA;AAAA,KAGM,qBAAA;EACV,QAAQ;AAAA;AAAA,KAGE,YAAA;EACV,KAAK;AAAA;AAAA,KAGK,iBAAA;EACV,GAAG;AAAA;AAAA,KAGO,eAAA;;;iBCjBI,eAAA,oBAAmC,MAAA,EAAQ,eAAA,8CAAe,eAAA,CAAA,kBAAA,EAAA,iBAAA;EAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { E as Session, F as RouteDescriptor, n as ClientPlugin } from "./define-plugin-Dv0xXIaH.mjs";
|
|
2
|
+
import { c as BearerTokens, o as BearerPluginConfig } from "./index-B8SpHkSd.mjs";
|
|
3
|
+
//#region src/plugins/session-jwt/types.d.ts
|
|
4
|
+
type SessionJwtTokens = BearerTokens;
|
|
5
|
+
type SessionJwtPluginConfig = BearerPluginConfig & {
|
|
6
|
+
/** Refresh once the access token is within this many seconds of expiry. Default 30. */expirySkewSeconds?: number;
|
|
7
|
+
};
|
|
8
|
+
type RefreshInput = {
|
|
9
|
+
refreshToken: string;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/plugins/session-jwt/index.d.ts
|
|
13
|
+
declare function sessionJwtPlugin<TFields = unknown>(config?: SessionJwtPluginConfig): ClientPlugin<"session-jwt", "", [RouteDescriptor<RefreshInput, Session<TFields>, {
|
|
14
|
+
readonly method: "POST";
|
|
15
|
+
readonly path: "/refresh";
|
|
16
|
+
readonly parseSession: true;
|
|
17
|
+
readonly expose: false;
|
|
18
|
+
}>], {
|
|
19
|
+
sessionJwt: {
|
|
20
|
+
/**
|
|
21
|
+
* Get the current access token. If the token is expiring, refresh it.
|
|
22
|
+
* @returns The current access token or null if no token is found.
|
|
23
|
+
*/
|
|
24
|
+
getAccessToken: () => Promise<string | null>;
|
|
25
|
+
refresh: () => Promise<SessionJwtTokens>;
|
|
26
|
+
getTokens: () => BearerTokens | null;
|
|
27
|
+
clear: () => void;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { SessionJwtPluginConfig as n, SessionJwtTokens as r, sessionJwtPlugin as t };
|
|
32
|
+
//# sourceMappingURL=index-C9EuA9UZ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C9EuA9UZ.d.mts","names":[],"sources":["../src/plugins/session-jwt/types.ts","../src/plugins/session-jwt/index.ts"],"mappings":";;;KAEY,gBAAA,GAAmB,YAAY;AAAA,KAE/B,sBAAA,GAAyB,kBAAkB;yFAErD,iBAAiB;AAAA;AAAA,KAGP,YAAA;EAAiB,YAAY;AAAA;;;iBCEzB,gBAAA,oBAAoC,MAAA,GAAQ,sBAAA,oCAA2B,eAAA,CAAA,YAAA,EAAA,OAAA,CAAA,OAAA;EAAA;;;;;;IDT3D;;;AAAe;0BCoDR,OAAA;mBATb,OAAA,CAAQ,gBAAA;qBAAD,YAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { E as Session, F as RouteDescriptor, n as ClientPlugin } from "./define-plugin-Dv0xXIaH.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/credential/types.d.ts
|
|
4
|
+
type SignInCredentialInput = {
|
|
5
|
+
/** Email or username, depending on what the server enables. */credential: string;
|
|
6
|
+
password: string; /** When true (default), issues a long-lived session. */
|
|
7
|
+
rememberMe?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type SignUpCredentialInput = {
|
|
10
|
+
email: string;
|
|
11
|
+
password: string; /** Required when username-on-signup is enabled. */
|
|
12
|
+
username?: string; /** Optional profile fields the server records on the user. */
|
|
13
|
+
firstname?: string;
|
|
14
|
+
lastname?: string; /** Extra fields recorded on the user at registration. */
|
|
15
|
+
additionalFields?: Record<string, unknown>;
|
|
16
|
+
};
|
|
17
|
+
type ChangePasswordInput = {
|
|
18
|
+
currentPassword: string;
|
|
19
|
+
newPassword: string; /** Invalidate other sessions on success. Defaults to true. */
|
|
20
|
+
revokeOtherSessions?: boolean;
|
|
21
|
+
};
|
|
22
|
+
type SetPasswordInput = {
|
|
23
|
+
newPassword: string;
|
|
24
|
+
revokeOtherSessions?: boolean;
|
|
25
|
+
};
|
|
26
|
+
type RequestPasswordResetInput = {
|
|
27
|
+
email: string;
|
|
28
|
+
};
|
|
29
|
+
type ResetPasswordInput = {
|
|
30
|
+
token: string;
|
|
31
|
+
newPassword: string;
|
|
32
|
+
};
|
|
33
|
+
type CheckUsernameInput = {
|
|
34
|
+
username: string;
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/plugins/credential/index.d.ts
|
|
38
|
+
declare function credentialPasswordPlugin<TFields = unknown>(): ClientPlugin<"credential-password", "/", [RouteDescriptor<SignInCredentialInput, Session<TFields>, {
|
|
39
|
+
readonly method: "POST";
|
|
40
|
+
readonly path: "/signin/credential";
|
|
41
|
+
readonly parseSession: true;
|
|
42
|
+
readonly as: "signIn.credential";
|
|
43
|
+
readonly defaults: {
|
|
44
|
+
readonly rememberMe: true;
|
|
45
|
+
};
|
|
46
|
+
}>, RouteDescriptor<SignUpCredentialInput, Session<TFields>, {
|
|
47
|
+
readonly method: "POST";
|
|
48
|
+
readonly path: "/signup/credential";
|
|
49
|
+
readonly parseSession: true;
|
|
50
|
+
readonly as: "signUp.credential";
|
|
51
|
+
}>, RouteDescriptor<RequestPasswordResetInput, {
|
|
52
|
+
message: string;
|
|
53
|
+
}, {
|
|
54
|
+
readonly method: "POST";
|
|
55
|
+
readonly path: "/passwords/request-reset";
|
|
56
|
+
readonly as: "password.requestReset";
|
|
57
|
+
}>, RouteDescriptor<ResetPasswordInput, {
|
|
58
|
+
message: string;
|
|
59
|
+
}, {
|
|
60
|
+
readonly method: "POST";
|
|
61
|
+
readonly path: "/passwords/reset";
|
|
62
|
+
readonly as: "password.reset";
|
|
63
|
+
}>, RouteDescriptor<ChangePasswordInput, Session<TFields>, {
|
|
64
|
+
readonly method: "POST";
|
|
65
|
+
readonly path: "/passwords/change";
|
|
66
|
+
readonly parseSession: true;
|
|
67
|
+
readonly defaults: {
|
|
68
|
+
readonly revokeOtherSessions: true;
|
|
69
|
+
};
|
|
70
|
+
readonly as: "password.change";
|
|
71
|
+
}>, RouteDescriptor<SetPasswordInput, Session<TFields>, {
|
|
72
|
+
readonly method: "PUT";
|
|
73
|
+
readonly path: "/passwords";
|
|
74
|
+
readonly as: "password.set";
|
|
75
|
+
readonly parseSession: true;
|
|
76
|
+
readonly defaults: {
|
|
77
|
+
readonly revokeOtherSessions: true;
|
|
78
|
+
};
|
|
79
|
+
}>, RouteDescriptor<CheckUsernameInput, boolean, {
|
|
80
|
+
readonly method: "POST";
|
|
81
|
+
readonly path: "/usernames/check";
|
|
82
|
+
readonly parse: (raw: unknown) => boolean;
|
|
83
|
+
readonly as: "username.checkAvailability";
|
|
84
|
+
}>], Record<never, never>>;
|
|
85
|
+
//#endregion
|
|
86
|
+
export { ResetPasswordInput as a, SignUpCredentialInput as c, RequestPasswordResetInput as i, ChangePasswordInput as n, SetPasswordInput as o, CheckUsernameInput as r, SignInCredentialInput as s, credentialPasswordPlugin as t };
|
|
87
|
+
//# sourceMappingURL=index-Cgr2wHmM.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Cgr2wHmM.d.mts","names":[],"sources":["../src/plugins/credential/types.ts","../src/plugins/credential/index.ts"],"mappings":";;;KAAY,qBAAA;iEAEV,UAAA;EACA,QAAA,UAH+B;EAK/B,UAAA;AAAA;AAAA,KAGU,qBAAA;EACV,KAAA;EACA,QAAA,UALU;EAOV,QAAA,WAJU;EAMV,SAAA;EACA,QAAA,WAEyB;EAAzB,gBAAA,GAAmB,MAAM;AAAA;AAAA,KAGf,mBAAA;EACV,eAAA;EACA,WAAA,UALA;EAOA,mBAAA;AAAA;AAAA,KAGU,gBAAA;EACV,WAAA;EACA,mBAAmB;AAAA;AAAA,KAGT,yBAAA;EACV,KAAK;AAAA;AAAA,KAGK,kBAAA;EACV,KAAA;EACA,WAAW;AAAA;AAAA,KAGD,kBAAA;EACV,QAAQ;AAAA;;;iBC7BM,wBAAA,iEAA0C,eAAA,CAAA,qBAAA,EAAA,OAAA,CAAA,OAAA;EAAA"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { F as RouteDescriptor, I as RouteHandler, n as ClientPlugin } from "./define-plugin-Dv0xXIaH.mjs";
|
|
2
|
+
import { n as camelizeKeys } from "./helpers-CvmKjWi2.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/plugins/oauth/types.d.ts
|
|
5
|
+
type OAuthAuthorizeQuery = {
|
|
6
|
+
/** Where the server redirects the browser after a successful callback. */redirectUri?: string; /** Where the server redirects on a failed callback. Falls back to `redirectUri`. */
|
|
7
|
+
errorRedirectUri?: string;
|
|
8
|
+
};
|
|
9
|
+
type SignInOAuthInput = OAuthAuthorizeQuery & {
|
|
10
|
+
/** Provider id, e.g. `"google"` or `"github"`. */provider: string;
|
|
11
|
+
/**
|
|
12
|
+
* When true, skip auto-navigation and only resolve with the authorization
|
|
13
|
+
* URL — the caller is responsible for navigating the browser.
|
|
14
|
+
*/
|
|
15
|
+
disableRedirect?: boolean;
|
|
16
|
+
};
|
|
17
|
+
type LinkOAuthInput = SignInOAuthInput;
|
|
18
|
+
type OAuthAuthorizeResult = {
|
|
19
|
+
/** Provider authorization URL. */url: string; /** Whether the SDK navigated to `url`. */
|
|
20
|
+
redirect: boolean;
|
|
21
|
+
};
|
|
22
|
+
type OAuthAccount = {
|
|
23
|
+
provider: string;
|
|
24
|
+
providerAccountId: string;
|
|
25
|
+
scopes: string[];
|
|
26
|
+
accessTokenExpiresAt?: string;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
};
|
|
30
|
+
type OAuthTokens = {
|
|
31
|
+
accessToken: string;
|
|
32
|
+
refreshToken?: string;
|
|
33
|
+
idToken?: string;
|
|
34
|
+
accessTokenExpiresAt?: string;
|
|
35
|
+
scope?: string;
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/plugins/oauth/index.d.ts
|
|
39
|
+
declare function oauthClientPlugin(): ClientPlugin<"oauth", "/oauth", [RouteDescriptor<SignInOAuthInput, OAuthAuthorizeResult, {
|
|
40
|
+
readonly method: "GET";
|
|
41
|
+
readonly path: "/:provider/authorize";
|
|
42
|
+
readonly as: "signIn.social";
|
|
43
|
+
readonly params: readonly ["provider"];
|
|
44
|
+
readonly handler: RouteHandler<SignInOAuthInput, OAuthAuthorizeResult>;
|
|
45
|
+
}>, RouteDescriptor<SignInOAuthInput, OAuthAuthorizeResult, {
|
|
46
|
+
readonly method: "GET";
|
|
47
|
+
readonly path: "/:provider/link";
|
|
48
|
+
readonly as: "social.link";
|
|
49
|
+
readonly params: readonly ["provider"];
|
|
50
|
+
readonly handler: RouteHandler<SignInOAuthInput, OAuthAuthorizeResult>;
|
|
51
|
+
}>, RouteDescriptor<{
|
|
52
|
+
provider: string;
|
|
53
|
+
}, void, {
|
|
54
|
+
readonly method: "DELETE";
|
|
55
|
+
readonly path: "/:provider/unlink";
|
|
56
|
+
readonly as: "social.unlink";
|
|
57
|
+
readonly params: readonly ["provider"];
|
|
58
|
+
}>, RouteDescriptor<void, OAuthAccount[], {
|
|
59
|
+
readonly method: "GET";
|
|
60
|
+
readonly path: "/accounts";
|
|
61
|
+
readonly as: "social.accounts";
|
|
62
|
+
}>, RouteDescriptor<{
|
|
63
|
+
provider: string;
|
|
64
|
+
}, OAuthTokens, {
|
|
65
|
+
readonly method: "GET";
|
|
66
|
+
readonly path: "/:provider/tokens";
|
|
67
|
+
readonly as: "social.tokens";
|
|
68
|
+
readonly params: readonly ["provider"];
|
|
69
|
+
readonly parse: typeof camelizeKeys;
|
|
70
|
+
}>, RouteDescriptor<{
|
|
71
|
+
provider: string;
|
|
72
|
+
}, OAuthTokens, {
|
|
73
|
+
readonly method: "POST";
|
|
74
|
+
readonly path: "/:provider/tokens/refresh";
|
|
75
|
+
readonly as: "social.refreshTokens";
|
|
76
|
+
readonly params: readonly ["provider"];
|
|
77
|
+
readonly parse: typeof camelizeKeys;
|
|
78
|
+
}>], Record<never, never>>;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { OAuthAuthorizeResult as a, OAuthAuthorizeQuery as i, LinkOAuthInput as n, OAuthTokens as o, OAuthAccount as r, SignInOAuthInput as s, oauthClientPlugin as t };
|
|
81
|
+
//# sourceMappingURL=index-DV6YcNSu.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DV6YcNSu.d.mts","names":[],"sources":["../src/plugins/oauth/types.ts","../src/plugins/oauth/index.ts"],"mappings":";;;;KAAY,mBAAA;4EAEV,WAAA;EAEA,gBAAgB;AAAA;AAAA,KAGN,gBAAA,GAAmB,mBAAmB;EALhD,kDAOA,QAAA;EAFU;;;;EAOV,eAAA;AAAA;AAAA,KAGU,cAAA,GAAiB,gBAAgB;AAAA,KAEjC,oBAAA;EALK,kCAOf,GAAA,UAJwB;EAMxB,QAAQ;AAAA;AAAA,KAGE,YAAA;EACV,QAAA;EACA,iBAAA;EACA,MAAA;EACA,oBAAA;EACA,SAAA;EACA,SAAA;AAAA;AAAA,KAGU,WAAA;EACV,WAAA;EACA,YAAA;EACA,OAAA;EACA,oBAAA;EACA,KAAA;AAAA;;;iBC7Bc,iBAAA,qDAAiB,gBAAA,EAAA,oBAAA;EAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { E as Session, F as RouteDescriptor, n as ClientPlugin } from "./define-plugin-Dv0xXIaH.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/magic-link/types.d.ts
|
|
4
|
+
type RequestMagicLinkInput = {
|
|
5
|
+
email: string;
|
|
6
|
+
redirectUri?: string;
|
|
7
|
+
newUserRedirectUri?: string;
|
|
8
|
+
errorRedirectUri?: string;
|
|
9
|
+
meta?: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
type VerifyMagicLinkInput = {
|
|
12
|
+
token: string;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/plugins/magic-link/index.d.ts
|
|
16
|
+
declare function magicLinkPlugin<TFields = unknown>(): ClientPlugin<"magic-link", "/magic-link", [RouteDescriptor<RequestMagicLinkInput, {
|
|
17
|
+
message: string;
|
|
18
|
+
}, {
|
|
19
|
+
readonly method: "POST";
|
|
20
|
+
readonly path: "/signin";
|
|
21
|
+
}>, RouteDescriptor<VerifyMagicLinkInput, Session<TFields>, {
|
|
22
|
+
readonly method: "GET";
|
|
23
|
+
readonly path: "/verify";
|
|
24
|
+
readonly parseSession: true;
|
|
25
|
+
}>], Record<never, never>>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { RequestMagicLinkInput as n, VerifyMagicLinkInput as r, magicLinkPlugin as t };
|
|
28
|
+
//# sourceMappingURL=index-dEksIImj.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-dEksIImj.d.mts","names":[],"sources":["../src/plugins/magic-link/types.ts","../src/plugins/magic-link/index.ts"],"mappings":";;;KAAY,qBAAA;EACV,KAAA;EACA,WAAA;EACA,kBAAA;EACA,gBAAA;EACA,IAAA,GAAO,MAAM;AAAA;AAAA,KAGH,oBAAA;EACV,KAAK;AAAA;;;iBCJS,eAAA,kEAAiC,eAAA,CAAA,qBAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { A as ActiveSession, B as deriveErrorCode, C as HTTPMethod, D as User, E as Session, I as RouteHandler, L as route, M as VerifyEmailInput, N as coreClientPlugin, O as SessionState, P as RouteCallOptions, R as LimenError, S as EnvelopeMode, T as RedirectFn, _ as AuthClient, a as defineRoutes, b as EnvelopeConfig, c as AfterResponseHook, d as PluginClientOverride, f as PluginIdOf, g as RouteMatcher, h as ResponseContext, i as defineClientPlugin, j as CoreContribution, k as SessionStore, l as BeforeRequestHook, m as RequestContext, o as AnyRouteContext, p as PluginOverrides, r as RunRoute, s as RouteContext, t as AnyClientPlugin, u as FetchInit, v as ClientFetchOptions, w as ParseSession, x as EnvelopeFields, y as CreateAuthClientOptions, z as LimenErrorCode } from "./define-plugin-Dv0xXIaH.mjs";
|
|
2
|
+
import { n as camelizeKeys, t as camelizeEach } from "./helpers-CvmKjWi2.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/version.d.ts
|
|
5
|
+
declare const VERSION: string;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/client.d.ts
|
|
8
|
+
declare function createAuthClient<const Plugins extends readonly AnyClientPlugin[] = readonly [], TFields = unknown>(opts: CreateAuthClientOptions<Plugins, TFields>): AuthClient<Plugins, TFields>;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/normalize.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Convert snake_case User keys from server payloads to camelCase. Unknown
|
|
13
|
+
* extension fields are converted with the same rule so consumers consistently
|
|
14
|
+
* read camelCase in SDK responses.
|
|
15
|
+
*/
|
|
16
|
+
declare function normalizeUser<F = unknown>(raw: Record<string, unknown>): User<F>;
|
|
17
|
+
declare function defaultSessionParse<F = unknown>(raw: unknown): Session<F>;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/serialize.d.ts
|
|
20
|
+
/**
|
|
21
|
+
* Default request serializer: shallow camelCase → snake_case, drops `undefined`,
|
|
22
|
+
* leaves non-objects unchanged.
|
|
23
|
+
*
|
|
24
|
+
* `additionalFields` entries are merged into the top-level body verbatim.
|
|
25
|
+
* Known route fields win on key collisions.
|
|
26
|
+
*/
|
|
27
|
+
declare function defaultSerialize(input: unknown): unknown;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { type ActiveSession, type AfterResponseHook, type AnyRouteContext, type AuthClient, type BeforeRequestHook, type ClientFetchOptions, type CoreContribution, type CreateAuthClientOptions, type EnvelopeConfig, type EnvelopeFields, type EnvelopeMode, type FetchInit, type HTTPMethod, LimenError, type LimenErrorCode, type ParseSession, type PluginClientOverride, type PluginIdOf, type PluginOverrides, type RedirectFn, type RequestContext, type ResponseContext, type RouteCallOptions, type RouteContext, type RouteHandler, type RouteMatcher, type RunRoute, type Session, type SessionState, type SessionStore, type User, VERSION, type VerifyEmailInput, camelizeEach, camelizeKeys, coreClientPlugin, createAuthClient, defaultSerialize, defaultSessionParse, defineClientPlugin, defineRoutes, deriveErrorCode, normalizeUser, route };
|
|
30
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/version.ts","../src/client.ts","../src/normalize.ts","../src/serialize.ts"],"mappings":";;;;cAEa,OAAA;;;iBCYG,gBAAA,gCAAgD,eAAA,qCAC9D,IAAA,EAAM,uBAAA,CAAwB,OAAA,EAAS,OAAA,IACtC,UAAA,CAAW,OAAA,EAAS,OAAA;;;;;;ADdvB;;iBEMgB,aAAA,cAA2B,GAAA,EAAK,MAAA,oBAA0B,IAAA,CAAK,CAAA;AAAA,iBAQ/D,mBAAA,cAAiC,GAAA,YAAe,OAAO,CAAC,CAAA;;;;;;;AFdxE;;;iBGOgB,gBAAA,CAAiB,KAAc"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { n as camelizeEach, r as camelizeKeys } from "./helpers-Cs3VtXdv.mjs";
|
|
2
|
+
import { a as defaultSerialize, i as normalizeUser, n as coreClientPlugin, r as defaultSessionParse, t as createAuthClient } from "./client-Er91De-z.mjs";
|
|
3
|
+
import { n as deriveErrorCode, t as LimenError } from "./errors-4YJYt6f0.mjs";
|
|
4
|
+
import { n as defineRoutes, t as defineClientPlugin } from "./define-plugin-C7WOGU4b.mjs";
|
|
5
|
+
import { t as route } from "./route-DGxvFqWl.mjs";
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/version.ts
|
|
8
|
+
const VERSION = "0.0.0";
|
|
9
|
+
//#endregion
|
|
10
|
+
export { LimenError, VERSION, camelizeEach, camelizeKeys, coreClientPlugin, createAuthClient, defaultSerialize, defaultSessionParse, defineClientPlugin, defineRoutes, deriveErrorCode, normalizeUser, route };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["pkg.version"],"sources":["../package.json","../src/version.ts"],"sourcesContent":["","import pkg from \"../package.json\";\n\nexport const VERSION = pkg.version;\n"],"mappings":";;;;;;;ACEA,MAAa,UAAUA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as BearerPlugin, c as BearerTokens, i as resolveDefaultStorage, n as localStorageBearerStorage, o as BearerPluginConfig, r as memoryBearerStorage, s as BearerStorage, t as bearerPlugin } from "../../index-B8SpHkSd.mjs";
|
|
2
|
+
export { type BearerPluginConfig, type BearerPlugin as BearerPublic, type BearerStorage, type BearerTokens, bearerPlugin, localStorageBearerStorage, memoryBearerStorage, resolveDefaultStorage };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as ResetPasswordInput, c as SignUpCredentialInput, i as RequestPasswordResetInput, n as ChangePasswordInput, o as SetPasswordInput, r as CheckUsernameInput, s as SignInCredentialInput, t as credentialPasswordPlugin } from "../../index-Cgr2wHmM.mjs";
|
|
2
|
+
export { type ChangePasswordInput, type CheckUsernameInput, type RequestPasswordResetInput, type ResetPasswordInput, type SetPasswordInput, type SignInCredentialInput, type SignUpCredentialInput, credentialPasswordPlugin };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { n as defineRoutes, t as defineClientPlugin } from "../../define-plugin-C7WOGU4b.mjs";
|
|
2
|
+
import { t as route } from "../../route-DGxvFqWl.mjs";
|
|
3
|
+
//#region src/plugins/credential/index.ts
|
|
4
|
+
function credentialPasswordPlugin() {
|
|
5
|
+
return defineClientPlugin({
|
|
6
|
+
id: "credential-password",
|
|
7
|
+
basePath: "/",
|
|
8
|
+
routes: defineRoutes(route()({
|
|
9
|
+
method: "POST",
|
|
10
|
+
path: "/signin/credential",
|
|
11
|
+
parseSession: true,
|
|
12
|
+
as: "signIn.credential",
|
|
13
|
+
defaults: { rememberMe: true }
|
|
14
|
+
}), route()({
|
|
15
|
+
method: "POST",
|
|
16
|
+
path: "/signup/credential",
|
|
17
|
+
parseSession: true,
|
|
18
|
+
as: "signUp.credential"
|
|
19
|
+
}), route()({
|
|
20
|
+
method: "POST",
|
|
21
|
+
path: "/passwords/request-reset",
|
|
22
|
+
as: "password.requestReset"
|
|
23
|
+
}), route()({
|
|
24
|
+
method: "POST",
|
|
25
|
+
path: "/passwords/reset",
|
|
26
|
+
as: "password.reset"
|
|
27
|
+
}), route()({
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: "/passwords/change",
|
|
30
|
+
parseSession: true,
|
|
31
|
+
defaults: { revokeOtherSessions: true },
|
|
32
|
+
as: "password.change"
|
|
33
|
+
}), route()({
|
|
34
|
+
method: "PUT",
|
|
35
|
+
path: "/passwords",
|
|
36
|
+
as: "password.set",
|
|
37
|
+
parseSession: true,
|
|
38
|
+
defaults: { revokeOtherSessions: true }
|
|
39
|
+
}), route()({
|
|
40
|
+
method: "POST",
|
|
41
|
+
path: "/usernames/check",
|
|
42
|
+
parse: (raw) => raw.available,
|
|
43
|
+
as: "username.checkAvailability"
|
|
44
|
+
}))
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { credentialPasswordPlugin };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/credential/index.ts"],"sourcesContent":["import { defineClientPlugin, defineRoutes } from \"../../define-plugin\";\nimport { route } from \"../../route\";\nimport type { Session } from \"../../types\";\nimport type {\n ChangePasswordInput,\n CheckUsernameInput,\n RequestPasswordResetInput,\n ResetPasswordInput,\n SetPasswordInput,\n SignInCredentialInput,\n SignUpCredentialInput,\n} from \"./types\";\n\nexport function credentialPasswordPlugin<TFields = unknown>() {\n const routes = defineRoutes(\n route<SignInCredentialInput, Session<TFields>>()({\n method: \"POST\",\n path: \"/signin/credential\",\n parseSession: true,\n as: \"signIn.credential\",\n defaults: { rememberMe: true },\n }),\n route<SignUpCredentialInput, Session<TFields>>()({\n method: \"POST\",\n path: \"/signup/credential\",\n parseSession: true,\n as: \"signUp.credential\",\n }),\n route<RequestPasswordResetInput, { message: string }>()({\n method: \"POST\",\n path: \"/passwords/request-reset\",\n as: \"password.requestReset\",\n }),\n route<ResetPasswordInput, { message: string }>()({\n method: \"POST\",\n path: \"/passwords/reset\",\n as: \"password.reset\",\n }),\n route<ChangePasswordInput, Session<TFields>>()({\n method: \"POST\",\n path: \"/passwords/change\",\n parseSession: true,\n defaults: { revokeOtherSessions: true },\n as: \"password.change\",\n }),\n route<SetPasswordInput, Session<TFields>>()({\n method: \"PUT\",\n path: \"/passwords\",\n as: \"password.set\",\n parseSession: true,\n defaults: { revokeOtherSessions: true },\n }),\n route<CheckUsernameInput, boolean>()({\n method: \"POST\",\n path: \"/usernames/check\",\n parse: (raw) => (raw as { available: boolean }).available,\n as: \"username.checkAvailability\",\n }),\n );\n\n return defineClientPlugin({\n id: \"credential-password\",\n basePath: \"/\",\n routes,\n });\n}\n\nexport type {\n ChangePasswordInput,\n CheckUsernameInput,\n RequestPasswordResetInput,\n ResetPasswordInput,\n SetPasswordInput,\n SignInCredentialInput,\n SignUpCredentialInput,\n} from \"./types\";\n"],"mappings":";;;AAaA,SAAgB,2BAA8C;CA+C5D,OAAO,mBAAmB;EACxB,IAAI;EACJ,UAAU;EACV,QAjDa,aACb,MAA+C,CAAC,CAAC;GAC/C,QAAQ;GACR,MAAM;GACN,cAAc;GACd,IAAI;GACJ,UAAU,EAAE,YAAY,KAAK;EAC/B,CAAC,GACD,MAA+C,CAAC,CAAC;GAC/C,QAAQ;GACR,MAAM;GACN,cAAc;GACd,IAAI;EACN,CAAC,GACD,MAAsD,CAAC,CAAC;GACtD,QAAQ;GACR,MAAM;GACN,IAAI;EACN,CAAC,GACD,MAA+C,CAAC,CAAC;GAC/C,QAAQ;GACR,MAAM;GACN,IAAI;EACN,CAAC,GACD,MAA6C,CAAC,CAAC;GAC7C,QAAQ;GACR,MAAM;GACN,cAAc;GACd,UAAU,EAAE,qBAAqB,KAAK;GACtC,IAAI;EACN,CAAC,GACD,MAA0C,CAAC,CAAC;GAC1C,QAAQ;GACR,MAAM;GACN,IAAI;GACJ,cAAc;GACd,UAAU,EAAE,qBAAqB,KAAK;EACxC,CAAC,GACD,MAAmC,CAAC,CAAC;GACnC,QAAQ;GACR,MAAM;GACN,QAAQ,QAAS,IAA+B;GAChD,IAAI;EACN,CAAC,CAMI;CACP,CAAC;AACH"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { a as BearerPlugin, c as BearerTokens, i as resolveDefaultStorage, n as localStorageBearerStorage, o as BearerPluginConfig, r as memoryBearerStorage, s as BearerStorage, t as bearerPlugin } from "../index-B8SpHkSd.mjs";
|
|
2
|
+
import { a as ResetPasswordInput, c as SignUpCredentialInput, i as RequestPasswordResetInput, n as ChangePasswordInput, o as SetPasswordInput, r as CheckUsernameInput, s as SignInCredentialInput, t as credentialPasswordPlugin } from "../index-Cgr2wHmM.mjs";
|
|
3
|
+
import { n as RequestMagicLinkInput, r as VerifyMagicLinkInput, t as magicLinkPlugin } from "../index-dEksIImj.mjs";
|
|
4
|
+
import { a as OAuthAuthorizeResult, i as OAuthAuthorizeQuery, n as LinkOAuthInput, o as OAuthTokens, r as OAuthAccount, s as SignInOAuthInput, t as oauthClientPlugin } from "../index-DV6YcNSu.mjs";
|
|
5
|
+
import { n as SessionJwtPluginConfig, r as SessionJwtTokens, t as sessionJwtPlugin } from "../index-C9EuA9UZ.mjs";
|
|
6
|
+
import { a as SendOTPInput, c as TwoFactorSetupURI, i as InitiateSetupInput, l as VerifyInput, n as DisableTwoFactorInput, o as TwoFactorConfig, r as FinalizeSetupInput, s as TwoFactorMethod, t as twoFactorPlugin } from "../index-C6atwjEq.mjs";
|
|
7
|
+
export { type BearerPluginConfig, type BearerPlugin as BearerPublic, type BearerStorage, type BearerTokens, type ChangePasswordInput, type CheckUsernameInput, type DisableTwoFactorInput, type FinalizeSetupInput, type InitiateSetupInput, type LinkOAuthInput, type OAuthAccount, type OAuthAuthorizeQuery, type OAuthAuthorizeResult, type OAuthTokens, type RequestMagicLinkInput, type RequestPasswordResetInput, type ResetPasswordInput, type SendOTPInput, type SessionJwtPluginConfig, type SessionJwtTokens, type SetPasswordInput, type SignInCredentialInput, type SignInOAuthInput, type SignUpCredentialInput, type TwoFactorConfig, type TwoFactorMethod, type TwoFactorSetupURI, type VerifyInput, type VerifyMagicLinkInput, bearerPlugin, credentialPasswordPlugin, localStorageBearerStorage, magicLinkPlugin, memoryBearerStorage, oauthClientPlugin, resolveDefaultStorage, sessionJwtPlugin, twoFactorPlugin };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { i as resolveDefaultStorage, n as localStorageBearerStorage, r as memoryBearerStorage, t as bearerPlugin } from "../bearer-Cqmrmjjf.mjs";
|
|
2
|
+
import { credentialPasswordPlugin } from "./credential/index.mjs";
|
|
3
|
+
import { magicLinkPlugin } from "./magic-link/index.mjs";
|
|
4
|
+
import { oauthClientPlugin } from "./oauth/index.mjs";
|
|
5
|
+
import { t as sessionJwtPlugin } from "../session-jwt-DgLdMQxP.mjs";
|
|
6
|
+
import { twoFactorPlugin } from "./two-factor/index.mjs";
|
|
7
|
+
export { bearerPlugin, credentialPasswordPlugin, localStorageBearerStorage, magicLinkPlugin, memoryBearerStorage, oauthClientPlugin, resolveDefaultStorage, sessionJwtPlugin, twoFactorPlugin };
|