@lastshotlabs/bunshot 0.0.4 → 0.0.5
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
CHANGED
|
@@ -686,6 +686,7 @@ await createServer({
|
|
|
686
686
|
primaryField: "email", // default: "email" — use "username" or "phone" to change the login identifier
|
|
687
687
|
emailVerification: { // optional — only active when primaryField is "email"
|
|
688
688
|
required: true, // default: false (soft gate) — set true to block login until verified
|
|
689
|
+
tokenExpiry: 60 * 60, // default: 86400 (24 hours) — token TTL in seconds
|
|
689
690
|
onSend: async (email, token) => { // called after registration and resend — use any email provider
|
|
690
691
|
await resend.emails.send({ to: email, subject: "Verify your email", text: `Token: ${token}` });
|
|
691
692
|
},
|
|
@@ -14,7 +14,7 @@ export declare const memoryGetCache: (key: string) => string | null;
|
|
|
14
14
|
export declare const memorySetCache: (key: string, value: string, ttlSeconds?: number) => void;
|
|
15
15
|
export declare const memoryDelCache: (key: string) => void;
|
|
16
16
|
export declare const memoryDelCachePattern: (pattern: string) => void;
|
|
17
|
-
export declare const memoryCreateVerificationToken: (token: string, userId: string, email: string) => void;
|
|
17
|
+
export declare const memoryCreateVerificationToken: (token: string, userId: string, email: string, ttlSeconds: number) => void;
|
|
18
18
|
export declare const memoryGetVerificationToken: (token: string) => {
|
|
19
19
|
userId: string;
|
|
20
20
|
email: string;
|
|
@@ -14,7 +14,7 @@ export declare const sqliteGetCache: (key: string) => string | null;
|
|
|
14
14
|
export declare const sqliteSetCache: (key: string, value: string, ttlSeconds?: number) => void;
|
|
15
15
|
export declare const sqliteDelCache: (key: string) => void;
|
|
16
16
|
export declare const sqliteDelCachePattern: (pattern: string) => void;
|
|
17
|
-
export declare const sqliteCreateVerificationToken: (token: string, userId: string, email: string) => void;
|
|
17
|
+
export declare const sqliteCreateVerificationToken: (token: string, userId: string, email: string, ttlSeconds: number) => void;
|
|
18
18
|
export declare const sqliteGetVerificationToken: (token: string) => {
|
|
19
19
|
userId: string;
|
|
20
20
|
email: string;
|
package/dist/lib/appConfig.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export type PrimaryField = "email" | "username" | "phone";
|
|
|
2
2
|
export interface EmailVerificationConfig {
|
|
3
3
|
/** Block login until email is verified. Defaults to false (soft gate — emailVerified returned in login response). */
|
|
4
4
|
required?: boolean;
|
|
5
|
+
/** Token time-to-live in seconds. Defaults to 86 400 (24 hours). */
|
|
6
|
+
tokenExpiry?: number;
|
|
5
7
|
/** Called after registration with the identifier and verification token. Use to send the email. */
|
|
6
8
|
onSend: (email: string, token: string) => Promise<void>;
|
|
7
9
|
}
|
|
@@ -15,3 +17,4 @@ export declare const setPrimaryField: (field: PrimaryField) => void;
|
|
|
15
17
|
export declare const getPrimaryField: () => PrimaryField;
|
|
16
18
|
export declare const setEmailVerificationConfig: (config: EmailVerificationConfig | null) => void;
|
|
17
19
|
export declare const getEmailVerificationConfig: () => EmailVerificationConfig | null;
|
|
20
|
+
export declare const getTokenExpiry: () => number;
|
|
@@ -4,7 +4,7 @@ type CacheStore = "redis" | "mongo" | "sqlite" | "memory";
|
|
|
4
4
|
export declare const setCacheStore: (store: CacheStore) => void;
|
|
5
5
|
export declare const bustCache: (key: string) => Promise<void>;
|
|
6
6
|
export declare const bustCachePattern: (pattern: string) => Promise<void>;
|
|
7
|
-
type KeyFn = (c: Parameters<MiddlewareHandler<
|
|
7
|
+
type KeyFn = (c: Parameters<MiddlewareHandler<any>>[0]) => string;
|
|
8
8
|
interface CacheOptions {
|
|
9
9
|
ttl?: number;
|
|
10
10
|
key: string | KeyFn;
|
package/package.json
CHANGED