@spfn/auth 0.2.0-beta.9 → 0.2.0-beta.90
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 +1 -1
- package/README.md +984 -1743
- package/dist/authenticate-CnccboAg.d.ts +1383 -0
- package/dist/client-proof.d.ts +677 -0
- package/dist/client-proof.js +1814 -0
- package/dist/client-proof.js.map +1 -0
- package/dist/config.d.ts +487 -39
- package/dist/config.js +243 -29
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +208 -3
- package/dist/errors.js +140 -1
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +391 -109
- package/dist/index.js +186 -7
- package/dist/index.js.map +1 -1
- package/dist/nextjs/api.js +591 -61
- package/dist/nextjs/api.js.map +1 -1
- package/dist/nextjs/client.d.ts +28 -0
- package/dist/nextjs/client.js +80 -0
- package/dist/nextjs/client.js.map +1 -0
- package/dist/nextjs/server.d.ts +92 -3
- package/dist/nextjs/server.js +288 -24
- package/dist/nextjs/server.js.map +1 -1
- package/dist/server.d.ts +2495 -1089
- package/dist/server.js +6212 -1499
- package/dist/server.js.map +1 -1
- package/dist/session-CFK4BT25.d.ts +53 -0
- package/dist/types-CD95yudz.d.ts +98 -0
- package/migrations/20251125021229_premium_famine/snapshot.json +2641 -0
- package/migrations/20260225130050_smooth_the_fury/migration.sql +3 -0
- package/migrations/20260225130050_smooth_the_fury/snapshot.json +2686 -0
- package/migrations/20260308141417_deep_iceman/migration.sql +11 -0
- package/migrations/20260308141417_deep_iceman/snapshot.json +2686 -0
- package/migrations/20260308151309_perfect_deathbird/migration.sql +3 -0
- package/migrations/20260308151309_perfect_deathbird/snapshot.json +2731 -0
- package/migrations/20260308201135_concerned_rawhide_kid/migration.sql +5 -0
- package/migrations/20260308201135_concerned_rawhide_kid/snapshot.json +2786 -0
- package/migrations/20260629103209_lethal_lifeguard/migration.sql +32 -0
- package/migrations/20260629103209_lethal_lifeguard/snapshot.json +2786 -0
- package/migrations/20260709073531_easy_hardball/migration.sql +24 -0
- package/migrations/20260709073531_easy_hardball/snapshot.json +3119 -0
- package/migrations/20260714081434_glossy_major_mapleleaf/migration.sql +1 -0
- package/migrations/20260714081434_glossy_major_mapleleaf/snapshot.json +3112 -0
- package/migrations/20260804105939_amazing_bushwacker/migration.sql +3 -0
- package/migrations/20260804105939_amazing_bushwacker/snapshot.json +3112 -0
- package/migrations/20260804110033_fat_piledriver/migration.sql +2 -0
- package/migrations/20260804110033_fat_piledriver/snapshot.json +3138 -0
- package/package.json +60 -46
- package/dist/dto-CRlgoCP5.d.ts +0 -645
- package/migrations/meta/0000_snapshot.json +0 -1632
- package/migrations/meta/_journal.json +0 -13
- /package/migrations/{0000_premium_famine.sql → 20251125021229_premium_famine/migration.sql} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { K as KeyAlgorithmType } from './types-CD95yudz.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @spfn/auth - Client Session Management
|
|
5
|
+
*
|
|
6
|
+
* Uses Jose JWE (JSON Web Encryption) to securely store session data in cookies
|
|
7
|
+
* More efficient than Iron Session with better Edge Runtime support
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface SessionData {
|
|
11
|
+
userId: string;
|
|
12
|
+
privateKey: string;
|
|
13
|
+
keyId: string;
|
|
14
|
+
algorithm: KeyAlgorithmType;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Seal session data into encrypted JWT (JWE)
|
|
18
|
+
*
|
|
19
|
+
* @param data - Session data to encrypt
|
|
20
|
+
* @param ttl - Time to live in seconds (default: 7 days)
|
|
21
|
+
* @returns Encrypted JWT string
|
|
22
|
+
*/
|
|
23
|
+
declare function sealSession(data: SessionData, ttl?: number): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* Unseal encrypted JWT (JWE) to session data
|
|
26
|
+
*
|
|
27
|
+
* @param jwt - Encrypted JWT string
|
|
28
|
+
* @returns Session data
|
|
29
|
+
* @throws Error if session is invalid or expired
|
|
30
|
+
*/
|
|
31
|
+
declare function unsealSession(jwt: string): Promise<SessionData>;
|
|
32
|
+
/**
|
|
33
|
+
* Get session metadata without decrypting
|
|
34
|
+
*
|
|
35
|
+
* @param jwt - Encrypted JWT string
|
|
36
|
+
* @returns Session metadata or null if invalid
|
|
37
|
+
*/
|
|
38
|
+
declare function getSessionInfo(jwt: string): Promise<{
|
|
39
|
+
issuedAt: Date;
|
|
40
|
+
expiresAt: Date;
|
|
41
|
+
issuer: string;
|
|
42
|
+
audience: string;
|
|
43
|
+
} | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Check if session is about to expire (within threshold)
|
|
46
|
+
*
|
|
47
|
+
* @param jwt - Encrypted JWT string
|
|
48
|
+
* @param thresholdHours - Hours before expiry to trigger refresh (default: 24)
|
|
49
|
+
* @returns True if session should be refreshed
|
|
50
|
+
*/
|
|
51
|
+
declare function shouldRefreshSession(jwt: string, thresholdHours?: number): Promise<boolean>;
|
|
52
|
+
|
|
53
|
+
export { type SessionData as S, shouldRefreshSession as a, getSessionInfo as g, sealSession as s, unsealSession as u };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @spfn/auth - Shared Types
|
|
3
|
+
*
|
|
4
|
+
* Common types and constants used across the auth package
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Supported JWT signature algorithms
|
|
8
|
+
*
|
|
9
|
+
* - ES256: ECDSA with P-256 and SHA-256 (recommended, smaller keys)
|
|
10
|
+
* - RS256: RSA with SHA-256 (fallback, larger keys)
|
|
11
|
+
*/
|
|
12
|
+
declare const KEY_ALGORITHM: readonly ["ES256", "RS256"];
|
|
13
|
+
/**
|
|
14
|
+
* Key algorithm type derived from the const array
|
|
15
|
+
*/
|
|
16
|
+
type KeyAlgorithmType = typeof KEY_ALGORITHM[number];
|
|
17
|
+
/**
|
|
18
|
+
* Where a registered key lives, as the client declares it.
|
|
19
|
+
*
|
|
20
|
+
* Only for telling one entry apart from another in the key list — nothing is
|
|
21
|
+
* authorized or refused by it, so a client that lies gains nothing. Stored via
|
|
22
|
+
* `enumText`, so adding a value here needs no migration.
|
|
23
|
+
*/
|
|
24
|
+
declare const KEY_PLATFORM: readonly ["ios", "android", "web", "desktop"];
|
|
25
|
+
/**
|
|
26
|
+
* Key platform type derived from the const array
|
|
27
|
+
*/
|
|
28
|
+
type KeyPlatformType = typeof KEY_PLATFORM[number];
|
|
29
|
+
/** Longest device label accepted at registration, and what the list returns. */
|
|
30
|
+
declare const KEY_DEVICE_NAME_MAX_LENGTH = 64;
|
|
31
|
+
/**
|
|
32
|
+
* Invitation status enum values
|
|
33
|
+
* Single source of truth for all invitation statuses
|
|
34
|
+
*/
|
|
35
|
+
declare const INVITATION_STATUSES: readonly ["pending", "accepted", "expired", "cancelled"];
|
|
36
|
+
/**
|
|
37
|
+
* Invitation status type derived from the const array
|
|
38
|
+
*/
|
|
39
|
+
type InvitationStatus = typeof INVITATION_STATUSES[number];
|
|
40
|
+
/**
|
|
41
|
+
* User status enum values
|
|
42
|
+
* Single source of truth for all user statuses
|
|
43
|
+
*
|
|
44
|
+
* - active: Normal operation (default)
|
|
45
|
+
* - inactive: Deactivated (user request, dormant)
|
|
46
|
+
* - suspended: Locked (security incident, ToS violation)
|
|
47
|
+
* - pending_deletion: Deletion requested, within the grace period (recoverable)
|
|
48
|
+
* - deleted: Grace period elapsed and the account was purged (anonymize mode only —
|
|
49
|
+
* hard-delete removes the row instead, so this status never appears for it)
|
|
50
|
+
*/
|
|
51
|
+
declare const USER_STATUSES: readonly ["active", "inactive", "suspended", "pending_deletion", "deleted"];
|
|
52
|
+
/**
|
|
53
|
+
* User status type derived from the const array
|
|
54
|
+
*/
|
|
55
|
+
type UserStatus = typeof USER_STATUSES[number];
|
|
56
|
+
/**
|
|
57
|
+
* Social provider enum values
|
|
58
|
+
* Single source of truth for supported OAuth providers
|
|
59
|
+
*/
|
|
60
|
+
declare const SOCIAL_PROVIDERS: readonly ["google", "apple", "github", "kakao", "naver", "superself"];
|
|
61
|
+
/**
|
|
62
|
+
* Social provider type derived from the const array
|
|
63
|
+
*/
|
|
64
|
+
type SocialProvider = typeof SOCIAL_PROVIDERS[number];
|
|
65
|
+
/**
|
|
66
|
+
* Account deletion request status enum values
|
|
67
|
+
* Single source of truth for `account_deletion_requests.status`
|
|
68
|
+
*
|
|
69
|
+
* - pending: Awaiting the grace period (or immediate purge)
|
|
70
|
+
* - cancelled: User (or admin) recovered the account before purge
|
|
71
|
+
* - completed: The purge ran (row is kept as an audit record, never deleted)
|
|
72
|
+
*/
|
|
73
|
+
declare const ACCOUNT_DELETION_REQUEST_STATUSES: readonly ["pending", "cancelled", "completed"];
|
|
74
|
+
/**
|
|
75
|
+
* Account deletion request status type derived from the const array
|
|
76
|
+
*/
|
|
77
|
+
type AccountDeletionRequestStatus = typeof ACCOUNT_DELETION_REQUEST_STATUSES[number];
|
|
78
|
+
/**
|
|
79
|
+
* Who initiated an account deletion request
|
|
80
|
+
*/
|
|
81
|
+
declare const ACCOUNT_DELETION_REQUESTED_BY: readonly ["self", "admin"];
|
|
82
|
+
/**
|
|
83
|
+
* Account deletion requester type derived from the const array
|
|
84
|
+
*/
|
|
85
|
+
type AccountDeletionRequestedBy = typeof ACCOUNT_DELETION_REQUESTED_BY[number];
|
|
86
|
+
/**
|
|
87
|
+
* Purge strategy enum values
|
|
88
|
+
*
|
|
89
|
+
* - anonymize: Scrub PII, keep the row (status becomes 'deleted') — default
|
|
90
|
+
* - hard-delete: Physically remove the `users` row (cascades to child rows)
|
|
91
|
+
*/
|
|
92
|
+
declare const PURGE_STRATEGIES: readonly ["anonymize", "hard-delete"];
|
|
93
|
+
/**
|
|
94
|
+
* Purge strategy type derived from the const array
|
|
95
|
+
*/
|
|
96
|
+
type PurgeStrategy = typeof PURGE_STRATEGIES[number];
|
|
97
|
+
|
|
98
|
+
export { ACCOUNT_DELETION_REQUEST_STATUSES as A, INVITATION_STATUSES as I, type KeyAlgorithmType as K, PURGE_STRATEGIES as P, SOCIAL_PROVIDERS as S, USER_STATUSES as U, KEY_ALGORITHM as a, ACCOUNT_DELETION_REQUESTED_BY as b, KEY_PLATFORM as c, type KeyPlatformType as d, KEY_DEVICE_NAME_MAX_LENGTH as e, type InvitationStatus as f, type UserStatus as g, type SocialProvider as h, type AccountDeletionRequestStatus as i, type AccountDeletionRequestedBy as j, type PurgeStrategy as k };
|