@stacksjs/auth 0.75.519 → 0.75.522

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.
@@ -4,7 +4,17 @@ import type { AuthCredentials, AuthToken, NewAccessToken, PersonalAccessToken, T
4
4
  import type { ImpersonationGrant } from './impersonation';
5
5
  declare type UserModel = NonNullable<Awaited<ReturnType<typeof User.find>>>;
6
6
  export declare class Auth {
7
+ private static getBearerToken;
8
+ private static parseToken;
9
+ private static getClientSecret;
10
+ private static encryptTokenId;
11
+ private static decryptTokenId;
12
+ private static getPersonalAccessClient;
13
+ private static verifiedClient;
14
+ private static getTokenFromId;
15
+ private static tokenFromRow;
7
16
  static attempt(credentials: AuthCredentials): Promise<boolean>;
17
+ private static verifyCredentials;
8
18
  static validate(credentials: AuthCredentials): Promise<boolean>;
9
19
  static withVerifiedCredentials<T>(credentials: AuthCredentials, issue: (user: UserModel) => Promise<T>): Promise<T | null>;
10
20
  static login(credentials: AuthCredentials, options?: TokenCreateOptions): Promise<
@@ -25,6 +35,7 @@ export declare class Auth {
25
35
  static requestToken(credentials: AuthCredentials, clientId: number, clientSecret: string): Promise<{ token: AuthToken } | null>;
26
36
  static validateToken(token: string): Promise<boolean>;
27
37
  static getUserFromToken(token: string): Promise<UserModel | undefined>;
38
+ private static resolveUserFromToken;
28
39
  static startImpersonation(subjectId: number, reason: string): Promise<ImpersonationGrant>;
29
40
  static endImpersonation(credential: string): Promise<void>;
30
41
  static currentAccessToken(): Promise<PersonalAccessToken | undefined>;
@@ -47,3 +58,4 @@ export declare class Auth {
47
58
  static viaRemember(): boolean;
48
59
  static clearState(): void;
49
60
  }
61
+ export {};
@@ -75,3 +75,4 @@ declare type UserModel = OrmUserModel;
75
75
  * Type for a user with authorization methods
76
76
  */
77
77
  export type AuthorizableUser<T extends UserModel> = T & AuthorizableMethods;
78
+ export {};
@@ -20,3 +20,4 @@ export declare interface ResolvedBrowserSessionPolicy {
20
20
  }
21
21
  declare type BrowserSessionPolicyConfig = Pick<Partial<AuthOptions>, 'tokenExpiry' | 'browserSession'>;
22
22
  declare type HeaderRequest = { headers?: { get: (name: string) => string | null } }
23
+ export {};
@@ -5,3 +5,4 @@ export declare function findAuthUserRowByEmail(value: string): Promise<Record<st
5
5
  /** Resolve an email without making existing mixed-case accounts unloginable. */
6
6
  export declare function findAuthUserByEmail(value: string): Promise<UserModel | undefined>;
7
7
  declare type UserModel = NonNullable<Awaited<ReturnType<typeof User.find>>>;
8
+ export {};
@@ -1,4 +1,3 @@
1
- declare function credentialHash(value: string): string;
2
1
  /**
3
2
  * Lifecycle for separately revocable support-view credentials. This service
4
3
  * never issues a subject's ordinary login token and never returns the actor's
@@ -94,3 +94,4 @@ declare type OAuthSqlHelpers = ReturnType<typeof sqlHelpers>;
94
94
  export declare class OAuthClientRegistrationError extends Error {
95
95
  constructor(message: string);
96
96
  }
97
+ export {};
@@ -85,3 +85,4 @@ export declare class OAuthAuthorizationConsentRequestError extends Error {
85
85
  declare class NoReusableOAuthConsentError extends Error {
86
86
 
87
87
  }
88
+ export {};
@@ -15,3 +15,4 @@ export type OAuthDelegatedAccessResult = { ok: true, token: AccessToken }
15
15
  | { ok: false, reason: 'invalid_token' }
16
16
  | { ok: false, reason: 'insufficient_scope', requiredScopes: string[] }
17
17
  declare type OAuthDelegatedAccessFailure = Exclude<OAuthDelegatedAccessResult, { ok: true }>;
18
+ export {};
@@ -1,7 +1,7 @@
1
1
  /** RFC 9728 metadata for the exact protected audience, never the inbound Host. */
2
2
  export declare function oauthProtectedResourceMetadata(options: OAuthProtectedResourceOptions): {
3
- resource: OAuthProtectedResourceOptions.resource;
4
- authorization_servers: (OAuthProtectedResourceOptions.authorizationServers)[number][];
3
+ resource: (OAuthProtectedResourceOptions)["resource"];
4
+ authorization_servers: ((OAuthProtectedResourceOptions)["authorizationServers"])[number][];
5
5
  bearer_methods_supported: string[]
6
6
  };
7
7
  export declare function oauthProtectedResourceMetadataPath(resource: string): string;
@@ -1,5 +1,4 @@
1
1
  import type { OAuthProviderConsentWorkspace, OAuthProviderConsentWorkspaceContext, OAuthProviderConsentWorkspaceResolver, OAuthProviderConfig, OAuthProviderResourceConfig, OAuthProviderScopeConfig, OAuthProviderSubjectEligibility } from '@stacksjs/types';
2
- declare function endpoint(issuer: URL, configured: string | undefined, fallback: string): string;
3
2
  /** Resolve and validate application-owned workspace authority for consent. */
4
3
  export declare function resolveOAuthConsentWorkspace(provider: ResolvedOAuthProviderConfig, context: OAuthProviderConsentWorkspaceContext): Promise<OAuthProviderConsentWorkspace | null>;
5
4
  /**
@@ -78,3 +78,4 @@ export type OAuthClientCredentialsExchangeResult = AuthorizationCodeResult<Deleg
78
78
  declare class InactiveOAuthClientError extends Error {
79
79
 
80
80
  }
81
+ export {};
@@ -35,3 +35,4 @@ export declare interface PageGateOptions {
35
35
  declare type StxPageMiddleware = ((request: Request, context: StxPageContext) => Promise<Response | null>) & {
36
36
  priority: number
37
37
  }
38
+ export {};
@@ -32,6 +32,10 @@ export declare interface RedisRateLimiterStoreOptions {
32
32
  }
33
33
  /** Process-local store — the default. */
34
34
  declare class MemoryStore implements RateLimiterStore {
35
+ private store;
36
+ private lastEviction;
37
+ private nextEvictionSize;
38
+ private evict;
35
39
  get(key: string): RateLimitEntry | undefined;
36
40
  set(key: string, entry: RateLimitEntry, ttlMs: number): void;
37
41
  delete(key: string): void;
@@ -39,7 +43,11 @@ declare class MemoryStore implements RateLimiterStore {
39
43
  }
40
44
  /** Redis-backed store whose Lua update is atomic across workers. */
41
45
  export declare class RedisRateLimiterStore implements RateLimiterStore {
46
+ private clientPromise;
47
+ private options;
42
48
  constructor(options?: RedisRateLimiterStoreOptions);
49
+ private client;
50
+ private key;
43
51
  get(key: string): Promise<RateLimitEntry | undefined>;
44
52
  set(key: string, entry: RateLimitEntry, ttlMs: number): Promise<void>;
45
53
  delete(key: string): Promise<void>;
@@ -52,7 +60,11 @@ export declare class RedisRateLimiterStore implements RateLimiterStore {
52
60
  * failing every sign-in. Warns once per outage.
53
61
  */
54
62
  export declare class FallbackRateLimiterStore implements RateLimiterStore {
63
+ private warned;
64
+ private shared;
65
+ private local;
55
66
  constructor(shared: RateLimiterStore, local?: MemoryStore);
67
+ private attempt;
56
68
  get(key: string): Promise<RateLimitEntry | undefined>;
57
69
  delete(key: string): Promise<void>;
58
70
  recordFailedAttempt(key: string, now: number, ttlMs: number): Promise<void>;
@@ -68,3 +80,4 @@ export declare class RateLimiter {
68
80
  static resetAttempts(email: string): Promise<void>;
69
81
  static validateAttempt(email: string): Promise<void>;
70
82
  }
83
+ export {};
package/dist/rbac.d.ts CHANGED
@@ -276,6 +276,8 @@ export declare class RbacEntityNotFoundError extends Error {
276
276
  * `@stacksjs/router/stacks-router.ts`.
277
277
  */
278
278
  declare class BoundedMap<K, V> {
279
+ private map;
280
+ private max;
279
281
  constructor(max: number);
280
282
  get(key: K): V | undefined;
281
283
  has(key: K): boolean;
@@ -78,3 +78,4 @@ export declare const SessionAuth: {
78
78
  refresh: typeof sessionRefresh
79
79
  };
80
80
  declare type UserModel = NonNullable<Awaited<ReturnType<typeof User.find>>>;
81
+ export {};
package/dist/socials.d.ts CHANGED
@@ -90,3 +90,4 @@ export declare class SocialSignInRefusedError extends Error {
90
90
  readonly reason: SocialRefusalReason;
91
91
  constructor(reason: SocialRefusalReason, message: string);
92
92
  }
93
+ export {};
package/dist/tokens.d.ts CHANGED
@@ -390,3 +390,4 @@ declare interface AccessTokenRow {
390
390
  access_token_id: number | null
391
391
  provider: string | null
392
392
  }
393
+ export {};
package/dist/user.d.ts CHANGED
@@ -27,3 +27,4 @@ export declare function refresh(): Promise<void>;
27
27
  declare type UserModel = OrmUserModel;
28
28
  declare type UserJsonResponse = OrmUserModel;
29
29
  export type AuthUser = UserJsonResponse;
30
+ export {};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/auth",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.519",
5
+ "version": "0.75.522",
6
6
  "description": "A more simplistic way to authenticate.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -59,19 +59,19 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@stacksjs/bun-router": "^0.1.24",
62
- "@stacksjs/cache": "0.75.519",
63
- "@stacksjs/config": "0.75.519",
64
- "@stacksjs/database": "0.75.519",
65
- "@stacksjs/email": "0.75.519",
66
- "@stacksjs/env": "0.75.519",
67
- "@stacksjs/error-handling": "0.75.519",
68
- "@stacksjs/logging": "0.75.519",
69
- "@stacksjs/orm": "0.75.519",
70
- "@stacksjs/path": "0.75.519",
71
- "@stacksjs/router": "0.75.519",
72
- "@stacksjs/security": "0.75.519",
73
- "@stacksjs/socials": "0.75.519",
74
- "@stacksjs/storage": "0.75.519",
62
+ "@stacksjs/cache": "0.75.522",
63
+ "@stacksjs/config": "0.75.522",
64
+ "@stacksjs/database": "0.75.522",
65
+ "@stacksjs/email": "0.75.522",
66
+ "@stacksjs/env": "0.75.522",
67
+ "@stacksjs/error-handling": "0.75.522",
68
+ "@stacksjs/logging": "0.75.522",
69
+ "@stacksjs/orm": "0.75.522",
70
+ "@stacksjs/path": "0.75.522",
71
+ "@stacksjs/router": "0.75.522",
72
+ "@stacksjs/security": "0.75.522",
73
+ "@stacksjs/socials": "0.75.522",
74
+ "@stacksjs/storage": "0.75.522",
75
75
  "@stacksjs/ts-auth": "^0.4.7",
76
76
  "ts-qr-codes": "^0.1.8"
77
77
  },