@aooth/auth 0.1.85 → 0.2.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/dist/atscript-db.cjs +80 -4
- package/dist/atscript-db.d.cts +51 -10
- package/dist/atscript-db.d.mts +51 -10
- package/dist/atscript-db.mjs +79 -5
- package/dist/{auth-credential-CLAQgjCS.d.mts → auth-credential-BsH0E8hG.d.mts} +73 -9
- package/dist/{auth-credential-GRAK230V.d.cts → auth-credential-D1V5-2uy.d.cts} +73 -9
- package/dist/authz.d.cts +2 -2
- package/dist/authz.d.mts +2 -2
- package/dist/client.cjs +25 -12
- package/dist/client.d.cts +59 -13
- package/dist/client.d.mts +59 -13
- package/dist/client.mjs +25 -12
- package/dist/{clock-CyjqzLxc.d.cts → clock-CzAaCoZ5.d.cts} +7 -0
- package/dist/{clock-CyjqzLxc.d.mts → clock-CzAaCoZ5.d.mts} +7 -0
- package/dist/{dynamic-client-store-BF4nXMK2.d.mts → dynamic-client-store-CUGQiS08.d.mts} +2 -2
- package/dist/{dynamic-client-store-HLfcl2FJ.d.cts → dynamic-client-store-D0RDGSSJ.d.cts} +2 -2
- package/dist/index.cjs +276 -113
- package/dist/index.d.cts +26 -4
- package/dist/index.d.mts +26 -4
- package/dist/index.mjs +253 -91
- package/dist/{payload-HPgyPiek.cjs → payload-C1cQW7p_.cjs} +27 -0
- package/dist/{payload-DP5zRiXT.mjs → payload-DDlf38B-.mjs} +22 -1
- package/dist/redis.cjs +11 -1
- package/dist/redis.d.cts +5 -2
- package/dist/redis.d.mts +5 -2
- package/dist/redis.mjs +11 -1
- package/dist/store-BaFYDHxn.d.cts +69 -0
- package/dist/store-h-bLOAaS.d.mts +69 -0
- package/package.json +2 -2
- package/dist/store-CVD1nd2j.d.mts +0 -41
- package/dist/store-ClQnA8yh.d.cts +0 -41
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as AuthContext, d as RefreshConfig, f as RefreshResult, i as DenylistStore, l as EnrichedSession, m as SessionInfo, n as defaultClock, o as CredentialMetadata, p as SessionEnricher, r as CredentialStore, s as CredentialState, t as Clock, u as IssueResult } from "./clock-
|
|
2
|
-
import { i as RefreshCallOptions, n as AuthCredentialOptions, r as IssueOptions, t as AuthCredential } from "./auth-credential-
|
|
3
|
-
import { n as RateLimitStoreMemory, t as RateLimitStore } from "./store-
|
|
1
|
+
import { a as AuthContext, d as RefreshConfig, f as RefreshResult, i as DenylistStore, l as EnrichedSession, m as SessionInfo, n as defaultClock, o as CredentialMetadata, p as SessionEnricher, r as CredentialStore, s as CredentialState, t as Clock, u as IssueResult } from "./clock-CzAaCoZ5.cjs";
|
|
2
|
+
import { i as RefreshCallOptions, n as AuthCredentialOptions, r as IssueOptions, t as AuthCredential } from "./auth-credential-D1V5-2uy.cjs";
|
|
3
|
+
import { n as RateLimitStoreMemory, t as RateLimitStore } from "./store-BaFYDHxn.cjs";
|
|
4
4
|
import { CryptoKey } from "jose";
|
|
5
5
|
//#region src/errors.d.ts
|
|
6
6
|
type AuthErrorType = "INVALID_TOKEN" | "TOKEN_EXPIRED" | "TOKEN_REVOKED" | "REFRESH_REUSE_DETECTED" | "STATELESS_OPERATION_UNSUPPORTED" | "MAX_CONCURRENT_REACHED" | "INVALID_CONFIG";
|
|
@@ -28,6 +28,7 @@ declare class CredentialStoreMemory<TPayload extends object = object> implements
|
|
|
28
28
|
clock?: Clock;
|
|
29
29
|
});
|
|
30
30
|
persist(state: CredentialState & TPayload, ttl?: number): Promise<string>;
|
|
31
|
+
persistAs(id: string, state: CredentialState & TPayload, ttl?: number): Promise<void>;
|
|
31
32
|
retrieve(token: string): Promise<(CredentialState & TPayload) | null>;
|
|
32
33
|
consume(token: string): Promise<(CredentialState & TPayload) | null>;
|
|
33
34
|
update(token: string, state: CredentialState & TPayload): Promise<string>;
|
|
@@ -303,6 +304,17 @@ interface RateLimitDecision {
|
|
|
303
304
|
* key and one atomic store increment decides. All rules are hit on every
|
|
304
305
|
* check (rejected requests count too — they cannot extend a fixed window).
|
|
305
306
|
*/
|
|
307
|
+
/**
|
|
308
|
+
* The item that governs a combined decision: among the rejected ones (when
|
|
309
|
+
* any), the one whose window frees capacity LAST — the request only becomes
|
|
310
|
+
* allowed once every one passes, so a shorter hint would invite
|
|
311
|
+
* guaranteed-rejected retries; otherwise the one with the least remaining
|
|
312
|
+
* budget. Used across the rules of one check and across stacked policies.
|
|
313
|
+
*/
|
|
314
|
+
declare function pickGoverning<T extends {
|
|
315
|
+
resetAt: number;
|
|
316
|
+
remaining: number;
|
|
317
|
+
}>(items: readonly T[], rejected: (item: T) => boolean): T;
|
|
306
318
|
declare class RateLimiter {
|
|
307
319
|
private readonly store;
|
|
308
320
|
private readonly clock;
|
|
@@ -321,6 +333,16 @@ declare class RateLimiter {
|
|
|
321
333
|
check(scope: string, subject: string, rules: RateLimitRuleInput[], opts?: {
|
|
322
334
|
defaultMessage?: string;
|
|
323
335
|
}): Promise<RateLimitDecision>;
|
|
336
|
+
/**
|
|
337
|
+
* Read the budget `check()` would see — without spending it. `remaining`
|
|
338
|
+
* is what is left in each window; `allowed` says whether a `check()` made
|
|
339
|
+
* now would pass. Use it for a "N left today" status line. Requires a store
|
|
340
|
+
* with `get()` (both bundled stores have it).
|
|
341
|
+
*/
|
|
342
|
+
peek(scope: string, subject: string, rules: RateLimitRuleInput[], opts?: {
|
|
343
|
+
defaultMessage?: string;
|
|
344
|
+
}): Promise<RateLimitDecision>;
|
|
345
|
+
private evaluate;
|
|
324
346
|
}
|
|
325
347
|
//#endregion
|
|
326
348
|
//#region src/email.d.ts
|
|
@@ -430,4 +452,4 @@ declare function generateMagicLinkToken(): string;
|
|
|
430
452
|
*/
|
|
431
453
|
declare function generateOpaqueToken(): string;
|
|
432
454
|
//#endregion
|
|
433
|
-
export { type AuthContext, AuthCredential, type AuthCredentialOptions, type AuthEmailEvent, type AuthEmailKind, AuthError, type AuthErrorType, type AuthSmsEvent, type AuthSmsKind, type BuildMagicLinkUrl, type Clock, type CredentialMetadata, type CredentialState, type CredentialStore, CredentialStoreEncapsulated, type CredentialStoreEncapsulatedOptions, CredentialStoreJwt, type CredentialStoreJwtOptions, CredentialStoreMemory, DEFAULT_RATE_LIMIT_MESSAGE, type DenylistStore, DenylistStoreMemory, type EmailSender, type EnrichedSession, type IssueOptions, type IssueResult, type JwtAlgorithm, type RateLimitDecision, type RateLimitRule, type RateLimitRuleInput, type RateLimitStore, RateLimitStoreMemory, RateLimiter, type RateLimiterOptions, type RefreshCallOptions, type RefreshConfig, type RefreshResult, type SessionEnricher, type SessionInfo, type SmsSender, defaultClock, formatDurationMs, generateMagicLinkToken, generateOpaqueToken, parseDurationMs, parseRateLimitRule, renderRateLimitMessage };
|
|
455
|
+
export { type AuthContext, AuthCredential, type AuthCredentialOptions, type AuthEmailEvent, type AuthEmailKind, AuthError, type AuthErrorType, type AuthSmsEvent, type AuthSmsKind, type BuildMagicLinkUrl, type Clock, type CredentialMetadata, type CredentialState, type CredentialStore, CredentialStoreEncapsulated, type CredentialStoreEncapsulatedOptions, CredentialStoreJwt, type CredentialStoreJwtOptions, CredentialStoreMemory, DEFAULT_RATE_LIMIT_MESSAGE, type DenylistStore, DenylistStoreMemory, type EmailSender, type EnrichedSession, type IssueOptions, type IssueResult, type JwtAlgorithm, type RateLimitDecision, type RateLimitRule, type RateLimitRuleInput, type RateLimitStore, RateLimitStoreMemory, RateLimiter, type RateLimiterOptions, type RefreshCallOptions, type RefreshConfig, type RefreshResult, type SessionEnricher, type SessionInfo, type SmsSender, defaultClock, formatDurationMs, generateMagicLinkToken, generateOpaqueToken, parseDurationMs, parseRateLimitRule, pickGoverning, renderRateLimitMessage };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as AuthContext, d as RefreshConfig, f as RefreshResult, i as DenylistStore, l as EnrichedSession, m as SessionInfo, n as defaultClock, o as CredentialMetadata, p as SessionEnricher, r as CredentialStore, s as CredentialState, t as Clock, u as IssueResult } from "./clock-
|
|
2
|
-
import { i as RefreshCallOptions, n as AuthCredentialOptions, r as IssueOptions, t as AuthCredential } from "./auth-credential-
|
|
3
|
-
import { n as RateLimitStoreMemory, t as RateLimitStore } from "./store-
|
|
1
|
+
import { a as AuthContext, d as RefreshConfig, f as RefreshResult, i as DenylistStore, l as EnrichedSession, m as SessionInfo, n as defaultClock, o as CredentialMetadata, p as SessionEnricher, r as CredentialStore, s as CredentialState, t as Clock, u as IssueResult } from "./clock-CzAaCoZ5.mjs";
|
|
2
|
+
import { i as RefreshCallOptions, n as AuthCredentialOptions, r as IssueOptions, t as AuthCredential } from "./auth-credential-BsH0E8hG.mjs";
|
|
3
|
+
import { n as RateLimitStoreMemory, t as RateLimitStore } from "./store-h-bLOAaS.mjs";
|
|
4
4
|
import { CryptoKey } from "jose";
|
|
5
5
|
//#region src/errors.d.ts
|
|
6
6
|
type AuthErrorType = "INVALID_TOKEN" | "TOKEN_EXPIRED" | "TOKEN_REVOKED" | "REFRESH_REUSE_DETECTED" | "STATELESS_OPERATION_UNSUPPORTED" | "MAX_CONCURRENT_REACHED" | "INVALID_CONFIG";
|
|
@@ -28,6 +28,7 @@ declare class CredentialStoreMemory<TPayload extends object = object> implements
|
|
|
28
28
|
clock?: Clock;
|
|
29
29
|
});
|
|
30
30
|
persist(state: CredentialState & TPayload, ttl?: number): Promise<string>;
|
|
31
|
+
persistAs(id: string, state: CredentialState & TPayload, ttl?: number): Promise<void>;
|
|
31
32
|
retrieve(token: string): Promise<(CredentialState & TPayload) | null>;
|
|
32
33
|
consume(token: string): Promise<(CredentialState & TPayload) | null>;
|
|
33
34
|
update(token: string, state: CredentialState & TPayload): Promise<string>;
|
|
@@ -303,6 +304,17 @@ interface RateLimitDecision {
|
|
|
303
304
|
* key and one atomic store increment decides. All rules are hit on every
|
|
304
305
|
* check (rejected requests count too — they cannot extend a fixed window).
|
|
305
306
|
*/
|
|
307
|
+
/**
|
|
308
|
+
* The item that governs a combined decision: among the rejected ones (when
|
|
309
|
+
* any), the one whose window frees capacity LAST — the request only becomes
|
|
310
|
+
* allowed once every one passes, so a shorter hint would invite
|
|
311
|
+
* guaranteed-rejected retries; otherwise the one with the least remaining
|
|
312
|
+
* budget. Used across the rules of one check and across stacked policies.
|
|
313
|
+
*/
|
|
314
|
+
declare function pickGoverning<T extends {
|
|
315
|
+
resetAt: number;
|
|
316
|
+
remaining: number;
|
|
317
|
+
}>(items: readonly T[], rejected: (item: T) => boolean): T;
|
|
306
318
|
declare class RateLimiter {
|
|
307
319
|
private readonly store;
|
|
308
320
|
private readonly clock;
|
|
@@ -321,6 +333,16 @@ declare class RateLimiter {
|
|
|
321
333
|
check(scope: string, subject: string, rules: RateLimitRuleInput[], opts?: {
|
|
322
334
|
defaultMessage?: string;
|
|
323
335
|
}): Promise<RateLimitDecision>;
|
|
336
|
+
/**
|
|
337
|
+
* Read the budget `check()` would see — without spending it. `remaining`
|
|
338
|
+
* is what is left in each window; `allowed` says whether a `check()` made
|
|
339
|
+
* now would pass. Use it for a "N left today" status line. Requires a store
|
|
340
|
+
* with `get()` (both bundled stores have it).
|
|
341
|
+
*/
|
|
342
|
+
peek(scope: string, subject: string, rules: RateLimitRuleInput[], opts?: {
|
|
343
|
+
defaultMessage?: string;
|
|
344
|
+
}): Promise<RateLimitDecision>;
|
|
345
|
+
private evaluate;
|
|
324
346
|
}
|
|
325
347
|
//#endregion
|
|
326
348
|
//#region src/email.d.ts
|
|
@@ -430,4 +452,4 @@ declare function generateMagicLinkToken(): string;
|
|
|
430
452
|
*/
|
|
431
453
|
declare function generateOpaqueToken(): string;
|
|
432
454
|
//#endregion
|
|
433
|
-
export { type AuthContext, AuthCredential, type AuthCredentialOptions, type AuthEmailEvent, type AuthEmailKind, AuthError, type AuthErrorType, type AuthSmsEvent, type AuthSmsKind, type BuildMagicLinkUrl, type Clock, type CredentialMetadata, type CredentialState, type CredentialStore, CredentialStoreEncapsulated, type CredentialStoreEncapsulatedOptions, CredentialStoreJwt, type CredentialStoreJwtOptions, CredentialStoreMemory, DEFAULT_RATE_LIMIT_MESSAGE, type DenylistStore, DenylistStoreMemory, type EmailSender, type EnrichedSession, type IssueOptions, type IssueResult, type JwtAlgorithm, type RateLimitDecision, type RateLimitRule, type RateLimitRuleInput, type RateLimitStore, RateLimitStoreMemory, RateLimiter, type RateLimiterOptions, type RefreshCallOptions, type RefreshConfig, type RefreshResult, type SessionEnricher, type SessionInfo, type SmsSender, defaultClock, formatDurationMs, generateMagicLinkToken, generateOpaqueToken, parseDurationMs, parseRateLimitRule, renderRateLimitMessage };
|
|
455
|
+
export { type AuthContext, AuthCredential, type AuthCredentialOptions, type AuthEmailEvent, type AuthEmailKind, AuthError, type AuthErrorType, type AuthSmsEvent, type AuthSmsKind, type BuildMagicLinkUrl, type Clock, type CredentialMetadata, type CredentialState, type CredentialStore, CredentialStoreEncapsulated, type CredentialStoreEncapsulatedOptions, CredentialStoreJwt, type CredentialStoreJwtOptions, CredentialStoreMemory, DEFAULT_RATE_LIMIT_MESSAGE, type DenylistStore, DenylistStoreMemory, type EmailSender, type EnrichedSession, type IssueOptions, type IssueResult, type JwtAlgorithm, type RateLimitDecision, type RateLimitRule, type RateLimitRuleInput, type RateLimitStore, RateLimitStoreMemory, RateLimiter, type RateLimiterOptions, type RefreshCallOptions, type RefreshConfig, type RefreshResult, type SessionEnricher, type SessionInfo, type SmsSender, defaultClock, formatDurationMs, generateMagicLinkToken, generateOpaqueToken, parseDurationMs, parseRateLimitRule, pickGoverning, renderRateLimitMessage };
|