@spfn/auth 0.3.0-beta.1 → 0.3.0-beta.2
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 +74 -3
- package/dist/{authenticate-DlTGaBT8.d.ts → authenticate-55LeXHqZ.d.ts} +44 -0
- package/dist/crypto.d.ts +61 -0
- package/dist/crypto.js +108 -0
- package/dist/crypto.js.map +1 -0
- package/dist/index.d.ts +46 -2
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +254 -65
- package/dist/server.js +341 -101
- package/dist/server.js.map +1 -1
- package/migrations/20260807145911_mixed_invisible_woman/migration.sql +11 -0
- package/migrations/20260807145911_mixed_invisible_woman/snapshot.json +3334 -0
- package/package.json +6 -1
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AuthInitOptions, l as OAuthProvider, j as VerificationPurpose, h as PermissionCategory, n as AuthContext } from './authenticate-
|
|
2
|
-
export { o as AuthProfileOutcome, p as AuthProfileVerifier, C as ChangePasswordParams, D as DeviceNameSchema, E as EmailSchema, I as IssueOneTimeTokenResult, q as KEY_FINGERPRINT_PREFIX_LENGTH, K as KeySummary, r as LoginParams, L as LoginResult, s as LogoutParams, N as NativeVerifyOptions, t as NormalizedIdentity, u as OAuthCallbackParams, v as OAuthCallbackResult, w as OAuthCodeExchangeOptions, x as OAuthNativeParams, d as OAuthNativeResult, y as OAuthStartParams, O as OAuthStartResult, z as OAuthTokens, B as PasswordSchema, F as PhoneSchema, G as PlatformSchema, H as RegisterParams, J as RegisterPublicKeyParams, a as RegisterResult, M as RevokeAllKeysParams, c as RevokeAllKeysResult, Q as RevokeKeyParams, T as RotateKeyParams, b as RotateKeyResult, W as SendVerificationCodeParams, S as SendVerificationCodeResult, X as TargetTypeSchema, Y as UnlinkNotification, Z as UnlinkNotifyRejection, _ as UnlinkNotifyRequest, $ as UnlinkNotifyResult, V as VERIFICATION_PURPOSES, i as VERIFICATION_TARGET_TYPES, a0 as VerificationPurposeSchema, k as VerificationTargetType, a1 as VerifyCodeParams, a2 as VerifyCodeResult, m as authRouter, a3 as authenticate, a4 as buildOAuthErrorUrl, a5 as changePasswordService, a6 as getEnabledOAuthProviders, a7 as getGoogleAccessToken, a8 as getOAuthProvider, a9 as getRegisteredProviders, aa as isOAuthProviderEnabled, ab as issueOneTimeTokenService, ac as listKeysService, ad as loginService, ae as logoutService, af as oauthCallbackService, ag as oauthNativeService, ah as oauthStartService, ai as oauthUnlinkNotifyService, aj as optionalAuth, ak as registerOAuthProvider, al as registerPublicKeyService, am as registerService, an as requireEnabledProvider, ao as resolveAuthenticatedUser, ap as revokeAllKeysService, aq as revokeKeyService, ar as rotateKeyService, as as runAuthProfile, at as selectAuthProfile, au as sendVerificationCodeService, av as verifyCodeService, aw as verifyOneTimeTokenService } from './authenticate-
|
|
1
|
+
import { A as AuthInitOptions, l as OAuthProvider, j as VerificationPurpose, h as PermissionCategory, n as AuthContext } from './authenticate-55LeXHqZ.js';
|
|
2
|
+
export { o as AuthProfileOutcome, p as AuthProfileVerifier, C as ChangePasswordParams, D as DeviceNameSchema, E as EmailSchema, I as IssueOneTimeTokenResult, q as KEY_FINGERPRINT_PREFIX_LENGTH, K as KeySummary, r as LoginParams, L as LoginResult, s as LogoutParams, N as NativeVerifyOptions, t as NormalizedIdentity, u as OAuthCallbackParams, v as OAuthCallbackResult, w as OAuthCodeExchangeOptions, x as OAuthNativeParams, d as OAuthNativeResult, y as OAuthStartParams, O as OAuthStartResult, z as OAuthTokens, B as PasswordSchema, F as PhoneSchema, G as PlatformSchema, H as RegisterParams, J as RegisterPublicKeyParams, a as RegisterResult, M as RevokeAllKeysParams, c as RevokeAllKeysResult, Q as RevokeKeyParams, T as RotateKeyParams, b as RotateKeyResult, W as SendVerificationCodeParams, S as SendVerificationCodeResult, X as TargetTypeSchema, Y as UnlinkNotification, Z as UnlinkNotifyRejection, _ as UnlinkNotifyRequest, $ as UnlinkNotifyResult, V as VERIFICATION_PURPOSES, i as VERIFICATION_TARGET_TYPES, a0 as VerificationPurposeSchema, k as VerificationTargetType, a1 as VerifyCodeParams, a2 as VerifyCodeResult, m as authRouter, a3 as authenticate, a4 as buildOAuthErrorUrl, a5 as changePasswordService, a6 as getEnabledOAuthProviders, a7 as getGoogleAccessToken, a8 as getOAuthProvider, a9 as getRegisteredProviders, aa as isOAuthProviderEnabled, ab as issueOneTimeTokenService, ac as listKeysService, ad as loginService, ae as logoutService, af as oauthCallbackService, ag as oauthNativeService, ah as oauthStartService, ai as oauthUnlinkNotifyService, aj as optionalAuth, ak as registerOAuthProvider, al as registerPublicKeyService, am as registerService, an as requireEnabledProvider, ao as resolveAuthenticatedUser, ap as revokeAllKeysService, aq as revokeKeyService, ar as rotateKeyService, as as runAuthProfile, at as selectAuthProfile, au as sendVerificationCodeService, av as verifyCodeService, aw as verifyOneTimeTokenService } from './authenticate-55LeXHqZ.js';
|
|
3
3
|
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
4
4
|
import { K as KeyAlgorithmType, d as InvitationStatus, j as SocialProvider, c as AccountDeletionRequestedBy, i as PurgeStrategy } from './types-DYyhze28.js';
|
|
5
5
|
export { A as ACCOUNT_DELETION_REQUESTED_BY, a as ACCOUNT_DELETION_REQUEST_STATUSES, b as AccountDeletionRequestStatus, I as INVITATION_STATUSES, e as KEY_ALGORITHM, f as KEY_DEVICE_NAME_MAX_LENGTH, g as KEY_PLATFORM, h as KeyPlatformType, P as PURGE_STRATEGIES, S as SOCIAL_PROVIDERS, U as USER_STATUSES, k as UserStatus } from './types-DYyhze28.js';
|
|
@@ -8,7 +8,7 @@ import { BaseRepository } from '@spfn/core/db';
|
|
|
8
8
|
import { c as ClientIdentity } from './wire-version-CtzMKvBB.js';
|
|
9
9
|
import { Context } from 'hono';
|
|
10
10
|
import * as _spfn_core_route from '@spfn/core/route';
|
|
11
|
-
|
|
11
|
+
export { KeyPair, generateClientToken, generateKeyPair, generateKeyPairES256, generateKeyPairRS256, getKeySize, shouldRotateKey } from './crypto.js';
|
|
12
12
|
export { S as SessionData, g as getSessionInfo, s as sealSession, a as shouldRefreshSession, u as unsealSession } from './session-DTHahDQ9.js';
|
|
13
13
|
import { JWTPayload } from 'jose';
|
|
14
14
|
import { SSETokenManager, SSETokenStore } from '@spfn/core/event/sse';
|
|
@@ -17,6 +17,7 @@ import * as _spfn_core_job from '@spfn/core/job';
|
|
|
17
17
|
import * as _spfn_core_event from '@spfn/core/event';
|
|
18
18
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
19
19
|
import '@spfn/auth/server';
|
|
20
|
+
import 'jsonwebtoken';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* @spfn/auth - Users Entity
|
|
@@ -1935,6 +1936,202 @@ interface SweepDuePurgesResult {
|
|
|
1935
1936
|
*/
|
|
1936
1937
|
declare function sweepDuePurges(now?: Date): Promise<SweepDuePurgesResult>;
|
|
1937
1938
|
|
|
1939
|
+
/**
|
|
1940
|
+
* @spfn/auth - Ops Tokens Entity
|
|
1941
|
+
*
|
|
1942
|
+
* Machine tokens for the CLI-first ops surface (`@spfn/core/ops`). A token is
|
|
1943
|
+
* an operator credential, not a user session: it carries a label and a scope
|
|
1944
|
+
* list, and the row stores only the SHA-256 hash of the secret — the secret
|
|
1945
|
+
* itself is shown once at issuance and never persisted.
|
|
1946
|
+
*
|
|
1947
|
+
* Issuance is an operator act performed where database access already exists
|
|
1948
|
+
* (`spfn ops token issue`); there is no HTTP surface for creating tokens, so
|
|
1949
|
+
* a deployed app exposes verification only.
|
|
1950
|
+
*/
|
|
1951
|
+
declare const opsTokens: drizzle_orm_pg_core.PgTableWithColumns<{
|
|
1952
|
+
name: "ops_tokens";
|
|
1953
|
+
schema: string;
|
|
1954
|
+
columns: {
|
|
1955
|
+
createdAt: drizzle_orm_pg_core.PgBuildColumn<"ops_tokens", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>, {
|
|
1956
|
+
name: string;
|
|
1957
|
+
tableName: "ops_tokens";
|
|
1958
|
+
dataType: "object date";
|
|
1959
|
+
data: Date;
|
|
1960
|
+
driverParam: string;
|
|
1961
|
+
notNull: true;
|
|
1962
|
+
hasDefault: true;
|
|
1963
|
+
isPrimaryKey: false;
|
|
1964
|
+
isAutoincrement: false;
|
|
1965
|
+
hasRuntimeDefault: false;
|
|
1966
|
+
enumValues: undefined;
|
|
1967
|
+
identity: undefined;
|
|
1968
|
+
generated: undefined;
|
|
1969
|
+
}>;
|
|
1970
|
+
updatedAt: drizzle_orm_pg_core.PgBuildColumn<"ops_tokens", drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetHasDefault<drizzle_orm_pg_core.PgTimestampBuilder>>>, {
|
|
1971
|
+
name: string;
|
|
1972
|
+
tableName: "ops_tokens";
|
|
1973
|
+
dataType: "object date";
|
|
1974
|
+
data: Date;
|
|
1975
|
+
driverParam: string;
|
|
1976
|
+
notNull: true;
|
|
1977
|
+
hasDefault: true;
|
|
1978
|
+
isPrimaryKey: false;
|
|
1979
|
+
isAutoincrement: false;
|
|
1980
|
+
hasRuntimeDefault: false;
|
|
1981
|
+
enumValues: undefined;
|
|
1982
|
+
identity: undefined;
|
|
1983
|
+
generated: undefined;
|
|
1984
|
+
}>;
|
|
1985
|
+
id: drizzle_orm_pg_core.PgBuildColumn<"ops_tokens", drizzle_orm_pg_core.SetIsPrimaryKey<drizzle_orm_pg_core.PgBigSerial53Builder>, {
|
|
1986
|
+
name: string;
|
|
1987
|
+
tableName: "ops_tokens";
|
|
1988
|
+
dataType: "number int53";
|
|
1989
|
+
data: number;
|
|
1990
|
+
driverParam: number;
|
|
1991
|
+
notNull: true;
|
|
1992
|
+
hasDefault: true;
|
|
1993
|
+
isPrimaryKey: false;
|
|
1994
|
+
isAutoincrement: false;
|
|
1995
|
+
hasRuntimeDefault: false;
|
|
1996
|
+
enumValues: undefined;
|
|
1997
|
+
identity: undefined;
|
|
1998
|
+
generated: undefined;
|
|
1999
|
+
}>;
|
|
2000
|
+
name: drizzle_orm_pg_core.PgBuildColumn<"ops_tokens", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgTextBuilder<[string, ...string[]]>>, {
|
|
2001
|
+
name: string;
|
|
2002
|
+
tableName: "ops_tokens";
|
|
2003
|
+
dataType: "string";
|
|
2004
|
+
data: string;
|
|
2005
|
+
driverParam: string;
|
|
2006
|
+
notNull: true;
|
|
2007
|
+
hasDefault: false;
|
|
2008
|
+
isPrimaryKey: false;
|
|
2009
|
+
isAutoincrement: false;
|
|
2010
|
+
hasRuntimeDefault: false;
|
|
2011
|
+
enumValues: undefined;
|
|
2012
|
+
identity: undefined;
|
|
2013
|
+
generated: undefined;
|
|
2014
|
+
}>;
|
|
2015
|
+
tokenHash: drizzle_orm_pg_core.PgBuildColumn<"ops_tokens", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.PgTextBuilder<[string, ...string[]]>>, {
|
|
2016
|
+
name: string;
|
|
2017
|
+
tableName: "ops_tokens";
|
|
2018
|
+
dataType: "string";
|
|
2019
|
+
data: string;
|
|
2020
|
+
driverParam: string;
|
|
2021
|
+
notNull: true;
|
|
2022
|
+
hasDefault: false;
|
|
2023
|
+
isPrimaryKey: false;
|
|
2024
|
+
isAutoincrement: false;
|
|
2025
|
+
hasRuntimeDefault: false;
|
|
2026
|
+
enumValues: undefined;
|
|
2027
|
+
identity: undefined;
|
|
2028
|
+
generated: undefined;
|
|
2029
|
+
}>;
|
|
2030
|
+
scopes: drizzle_orm_pg_core.PgBuildColumn<"ops_tokens", drizzle_orm_pg_core.SetNotNull<drizzle_orm_pg_core.SetDimensions<drizzle_orm_pg_core.PgTextBuilder<[string, ...string[]]>, 1>>, {
|
|
2031
|
+
name: string;
|
|
2032
|
+
tableName: "ops_tokens";
|
|
2033
|
+
dataType: "string";
|
|
2034
|
+
data: string[];
|
|
2035
|
+
driverParam: string | string[];
|
|
2036
|
+
notNull: true;
|
|
2037
|
+
hasDefault: false;
|
|
2038
|
+
isPrimaryKey: false;
|
|
2039
|
+
isAutoincrement: false;
|
|
2040
|
+
hasRuntimeDefault: false;
|
|
2041
|
+
enumValues: undefined;
|
|
2042
|
+
identity: undefined;
|
|
2043
|
+
generated: undefined;
|
|
2044
|
+
}>;
|
|
2045
|
+
expiresAt: drizzle_orm_pg_core.PgBuildColumn<"ops_tokens", drizzle_orm_pg_core.PgTimestampBuilder, {
|
|
2046
|
+
name: string;
|
|
2047
|
+
tableName: "ops_tokens";
|
|
2048
|
+
dataType: "object date";
|
|
2049
|
+
data: Date;
|
|
2050
|
+
driverParam: string;
|
|
2051
|
+
notNull: false;
|
|
2052
|
+
hasDefault: false;
|
|
2053
|
+
isPrimaryKey: false;
|
|
2054
|
+
isAutoincrement: false;
|
|
2055
|
+
hasRuntimeDefault: false;
|
|
2056
|
+
enumValues: undefined;
|
|
2057
|
+
identity: undefined;
|
|
2058
|
+
generated: undefined;
|
|
2059
|
+
}>;
|
|
2060
|
+
revokedAt: drizzle_orm_pg_core.PgBuildColumn<"ops_tokens", drizzle_orm_pg_core.PgTimestampBuilder, {
|
|
2061
|
+
name: string;
|
|
2062
|
+
tableName: "ops_tokens";
|
|
2063
|
+
dataType: "object date";
|
|
2064
|
+
data: Date;
|
|
2065
|
+
driverParam: string;
|
|
2066
|
+
notNull: false;
|
|
2067
|
+
hasDefault: false;
|
|
2068
|
+
isPrimaryKey: false;
|
|
2069
|
+
isAutoincrement: false;
|
|
2070
|
+
hasRuntimeDefault: false;
|
|
2071
|
+
enumValues: undefined;
|
|
2072
|
+
identity: undefined;
|
|
2073
|
+
generated: undefined;
|
|
2074
|
+
}>;
|
|
2075
|
+
lastUsedAt: drizzle_orm_pg_core.PgBuildColumn<"ops_tokens", drizzle_orm_pg_core.PgTimestampBuilder, {
|
|
2076
|
+
name: string;
|
|
2077
|
+
tableName: "ops_tokens";
|
|
2078
|
+
dataType: "object date";
|
|
2079
|
+
data: Date;
|
|
2080
|
+
driverParam: string;
|
|
2081
|
+
notNull: false;
|
|
2082
|
+
hasDefault: false;
|
|
2083
|
+
isPrimaryKey: false;
|
|
2084
|
+
isAutoincrement: false;
|
|
2085
|
+
hasRuntimeDefault: false;
|
|
2086
|
+
enumValues: undefined;
|
|
2087
|
+
identity: undefined;
|
|
2088
|
+
generated: undefined;
|
|
2089
|
+
}>;
|
|
2090
|
+
};
|
|
2091
|
+
dialect: "pg";
|
|
2092
|
+
}>;
|
|
2093
|
+
type OpsToken = typeof opsTokens.$inferSelect;
|
|
2094
|
+
type NewOpsToken = typeof opsTokens.$inferInsert;
|
|
2095
|
+
|
|
2096
|
+
/**
|
|
2097
|
+
* Ops Token Service
|
|
2098
|
+
*
|
|
2099
|
+
* Issuance and verification for the CLI-first ops surface. The secret is
|
|
2100
|
+
* `spfn_ops_<64 hex>`; only its SHA-256 hash is stored, so issuance is the
|
|
2101
|
+
* one moment the secret exists in the clear.
|
|
2102
|
+
*
|
|
2103
|
+
* Verification answers with the same null for an unknown, revoked, or
|
|
2104
|
+
* expired token — the refusal reveals nothing about whether a presented
|
|
2105
|
+
* secret ever existed (the non-disclosure rule the client-proof surface
|
|
2106
|
+
* keeps).
|
|
2107
|
+
*/
|
|
2108
|
+
|
|
2109
|
+
/** What a verified token authorizes — the principal ops middleware exposes. */
|
|
2110
|
+
interface VerifiedOpsToken {
|
|
2111
|
+
tokenId: number;
|
|
2112
|
+
name: string;
|
|
2113
|
+
scopes: string[];
|
|
2114
|
+
}
|
|
2115
|
+
interface IssuedOpsToken {
|
|
2116
|
+
/** The secret, shown exactly once. Never stored, never logged. */
|
|
2117
|
+
token: string;
|
|
2118
|
+
record: OpsToken;
|
|
2119
|
+
}
|
|
2120
|
+
/**
|
|
2121
|
+
* Issue a new ops token.
|
|
2122
|
+
*
|
|
2123
|
+
* @param name - Operator-facing label
|
|
2124
|
+
* @param scopes - Permission strings the token grants ('*' grants all)
|
|
2125
|
+
* @param expiresAt - null for a non-expiring token
|
|
2126
|
+
*/
|
|
2127
|
+
declare function issueOpsTokenService(name: string, scopes: string[], expiresAt: Date | null): Promise<IssuedOpsToken>;
|
|
2128
|
+
/**
|
|
2129
|
+
* Verify a presented token. Null for unknown, revoked, and expired alike.
|
|
2130
|
+
*/
|
|
2131
|
+
declare function verifyOpsTokenService(token: string): Promise<VerifiedOpsToken | null>;
|
|
2132
|
+
declare function revokeOpsTokenService(id: number): Promise<OpsToken | null>;
|
|
2133
|
+
declare function listOpsTokensService(): Promise<OpsToken[]>;
|
|
2134
|
+
|
|
1938
2135
|
/**
|
|
1939
2136
|
* @spfn/auth - Database Schema Definition
|
|
1940
2137
|
*
|
|
@@ -3871,12 +4068,12 @@ declare class KeysRepository extends BaseRepository {
|
|
|
3871
4068
|
isActive: boolean;
|
|
3872
4069
|
createdAt: Date;
|
|
3873
4070
|
expiresAt: Date | null;
|
|
4071
|
+
revokedAt: Date | null;
|
|
4072
|
+
lastUsedAt: Date | null;
|
|
3874
4073
|
clientKind: "ios" | "android" | "web" | null;
|
|
3875
4074
|
clientVersion: string | null;
|
|
3876
4075
|
clientContractVersion: string | null;
|
|
3877
4076
|
clientSeenAt: Date | null;
|
|
3878
|
-
lastUsedAt: Date | null;
|
|
3879
|
-
revokedAt: Date | null;
|
|
3880
4077
|
revokedReason: string | null;
|
|
3881
4078
|
}>;
|
|
3882
4079
|
/**
|
|
@@ -3973,12 +4170,12 @@ declare class KeysRepository extends BaseRepository {
|
|
|
3973
4170
|
isActive: boolean;
|
|
3974
4171
|
createdAt: Date;
|
|
3975
4172
|
expiresAt: Date | null;
|
|
4173
|
+
revokedAt: Date | null;
|
|
4174
|
+
lastUsedAt: Date | null;
|
|
3976
4175
|
clientKind: "ios" | "android" | "web" | null;
|
|
3977
4176
|
clientVersion: string | null;
|
|
3978
4177
|
clientContractVersion: string | null;
|
|
3979
4178
|
clientSeenAt: Date | null;
|
|
3980
|
-
lastUsedAt: Date | null;
|
|
3981
|
-
revokedAt: Date | null;
|
|
3982
4179
|
revokedReason: string | null;
|
|
3983
4180
|
}>;
|
|
3984
4181
|
/**
|
|
@@ -5440,6 +5637,37 @@ declare class AccountDeletionRequestsRepository extends BaseRepository {
|
|
|
5440
5637
|
}
|
|
5441
5638
|
declare const accountDeletionRequestsRepository: AccountDeletionRequestsRepository;
|
|
5442
5639
|
|
|
5640
|
+
/**
|
|
5641
|
+
* Ops Tokens Repository
|
|
5642
|
+
*
|
|
5643
|
+
* Data access for the ops-token credential store. Extends BaseRepository for
|
|
5644
|
+
* transaction context and read/write splitting like every other auth
|
|
5645
|
+
* repository.
|
|
5646
|
+
*/
|
|
5647
|
+
|
|
5648
|
+
declare class OpsTokensRepository extends BaseRepository {
|
|
5649
|
+
/**
|
|
5650
|
+
* Lookup by the secret's hash — the verification path.
|
|
5651
|
+
*
|
|
5652
|
+
* Reads the primary, not the replica, unlike every other SELECT here.
|
|
5653
|
+
* Revocation writes to the primary, so a replica read would keep
|
|
5654
|
+
* authenticating a revoked token for the length of the replication lag —
|
|
5655
|
+
* and revocation is documented as taking effect immediately.
|
|
5656
|
+
*/
|
|
5657
|
+
findByTokenHash(tokenHash: string): Promise<OpsToken | null>;
|
|
5658
|
+
create(data: NewOpsToken): Promise<OpsToken>;
|
|
5659
|
+
list(): Promise<OpsToken[]>;
|
|
5660
|
+
/**
|
|
5661
|
+
* Revoke an active token. Returns null when the id does not exist or the
|
|
5662
|
+
* token is already revoked — the first revocation's timestamp is never
|
|
5663
|
+
* overwritten.
|
|
5664
|
+
*/
|
|
5665
|
+
revokeById(id: number): Promise<OpsToken | null>;
|
|
5666
|
+
/** Fire-and-forget from the verification path. */
|
|
5667
|
+
updateLastUsedById(id: number): Promise<void>;
|
|
5668
|
+
}
|
|
5669
|
+
declare const opsTokensRepository: OpsTokensRepository;
|
|
5670
|
+
|
|
5443
5671
|
/**
|
|
5444
5672
|
* @spfn/auth - Password Helpers
|
|
5445
5673
|
*
|
|
@@ -5815,6 +6043,24 @@ declare const roleGuard: _spfn_core_route.NamedMiddlewareFactory<"roleGuard", [o
|
|
|
5815
6043
|
*/
|
|
5816
6044
|
declare const oneTimeTokenAuth: _spfn_core_route.NamedMiddleware<"oneTimeTokenAuth">;
|
|
5817
6045
|
|
|
6046
|
+
/** Read the verified ops token a handler runs under. */
|
|
6047
|
+
declare function getOpsToken(c: Context): VerifiedOpsToken | null;
|
|
6048
|
+
declare const opsTokenAuth: _spfn_core_route.NamedMiddleware<"opsTokenAuth">;
|
|
6049
|
+
/**
|
|
6050
|
+
* Require the verified ops token to carry every named scope.
|
|
6051
|
+
*
|
|
6052
|
+
* Must run after `opsTokenAuth` — on a `createOpsRouter` surface it always
|
|
6053
|
+
* does, because the factory injects the auth middleware first.
|
|
6054
|
+
*
|
|
6055
|
+
* @example
|
|
6056
|
+
* ```ts
|
|
6057
|
+
* export const listSignups = route.get('/_ops/signups')
|
|
6058
|
+
* .use([requireOpsScope('waitlist:read')])
|
|
6059
|
+
* .handler(async () => { ... });
|
|
6060
|
+
* ```
|
|
6061
|
+
*/
|
|
6062
|
+
declare const requireOpsScope: _spfn_core_route.NamedMiddlewareFactory<"opsScope", string[]>;
|
|
6063
|
+
|
|
5818
6064
|
/**
|
|
5819
6065
|
* Auth Context Helpers
|
|
5820
6066
|
*
|
|
@@ -5959,63 +6205,6 @@ declare function getKeyId(c: Context | {
|
|
|
5959
6205
|
raw: Context;
|
|
5960
6206
|
}): string;
|
|
5961
6207
|
|
|
5962
|
-
/**
|
|
5963
|
-
* @spfn/auth - Client Crypto Helpers
|
|
5964
|
-
*
|
|
5965
|
-
* ES256 (ECDSA P-256) key generation and JWT signing for Next.js
|
|
5966
|
-
* Keys are stored in DER format (Base64 encoded) for efficiency
|
|
5967
|
-
*
|
|
5968
|
-
* Key Sizes:
|
|
5969
|
-
* - ES256 (ECDSA P-256): ~91 bytes (Base64: ~120 chars)
|
|
5970
|
-
* - RS256 (RSA 2048): ~294 bytes (Base64: ~392 chars)
|
|
5971
|
-
*/
|
|
5972
|
-
|
|
5973
|
-
type Unit = 'Years' | 'Year' | 'Yrs' | 'Yr' | 'Y' | 'Weeks' | 'Week' | 'W' | 'Days' | 'Day' | 'D' | 'Hours' | 'Hour' | 'Hrs' | 'Hr' | 'H' | 'Minutes' | 'Minute' | 'Mins' | 'Min' | 'M' | 'Seconds' | 'Second' | 'Secs' | 'Sec' | 's' | 'Milliseconds' | 'Millisecond' | 'Msecs' | 'Msec' | 'Ms';
|
|
5974
|
-
type UnitAnyCase = Unit | Uppercase<Unit> | Lowercase<Unit>;
|
|
5975
|
-
type StringValue = `${number}` | `${number}${UnitAnyCase}` | `${number} ${UnitAnyCase}`;
|
|
5976
|
-
interface KeyPair {
|
|
5977
|
-
privateKey: string;
|
|
5978
|
-
publicKey: string;
|
|
5979
|
-
keyId: string;
|
|
5980
|
-
fingerprint: string;
|
|
5981
|
-
algorithm: KeyAlgorithmType;
|
|
5982
|
-
}
|
|
5983
|
-
/**
|
|
5984
|
-
* Generate ECDSA P-256 key pair (ES256)
|
|
5985
|
-
* Recommended for optimal size and performance
|
|
5986
|
-
*/
|
|
5987
|
-
declare function generateKeyPairES256(): KeyPair;
|
|
5988
|
-
/**
|
|
5989
|
-
* Generate RSA 2048 key pair (RS256)
|
|
5990
|
-
* Fallback option, larger size but wider compatibility
|
|
5991
|
-
*/
|
|
5992
|
-
declare function generateKeyPairRS256(): KeyPair;
|
|
5993
|
-
/**
|
|
5994
|
-
* Generate key pair (defaults to ES256)
|
|
5995
|
-
*/
|
|
5996
|
-
declare function generateKeyPair(algorithm?: KeyAlgorithmType): KeyPair;
|
|
5997
|
-
/**
|
|
5998
|
-
* Generate JWT signed with client private key (DER format)
|
|
5999
|
-
*/
|
|
6000
|
-
declare function generateClientToken(payload: Record<string, any>, privateKeyB64: string, algorithm: Algorithm, options?: {
|
|
6001
|
-
expiresIn?: StringValue | number;
|
|
6002
|
-
issuer?: string;
|
|
6003
|
-
}): string;
|
|
6004
|
-
/**
|
|
6005
|
-
* Get key size information
|
|
6006
|
-
*/
|
|
6007
|
-
declare function getKeySize(publicKeyB64: string): {
|
|
6008
|
-
bytes: number;
|
|
6009
|
-
base64Length: number;
|
|
6010
|
-
};
|
|
6011
|
-
/**
|
|
6012
|
-
* Check if key should be rotated based on creation date
|
|
6013
|
-
*/
|
|
6014
|
-
declare function shouldRotateKey(createdAt: Date, rotationDays?: number): {
|
|
6015
|
-
shouldRotate: boolean;
|
|
6016
|
-
daysRemaining: number;
|
|
6017
|
-
};
|
|
6018
|
-
|
|
6019
6208
|
/**
|
|
6020
6209
|
* @spfn/auth - Global Configuration
|
|
6021
6210
|
*
|
|
@@ -6725,4 +6914,4 @@ type AuthDeletionCancelledPayload = typeof authDeletionCancelledEvent._payload;
|
|
|
6725
6914
|
type AuthDeletionCompletedPayload = typeof authDeletionCompletedEvent._payload;
|
|
6726
6915
|
type OAuthUnlinkedPayload = typeof oauthUnlinkedEvent._payload;
|
|
6727
6916
|
|
|
6728
|
-
export { type AccountDeletionPurgeUser, type AccountDeletionRequest, AccountDeletionRequestedBy, AccountDeletionRequestsRepository, type AuthConfig, AuthContext, type AuthDeletionCancelledPayload, type AuthDeletionCompletedPayload, type AuthDeletionConfig, type AuthDeletionRequestedPayload, type AuthLifecycleConfig, type AuthLifecycleOptions, type AuthLoginPayload, type AuthMetadataEntity, AuthMetadataRepository, AuthProviderSchema, type AuthRegisterPayload, type BeforeRegisterContext, COOKIE_NAMES, type CancelAccountDeletionParams, type CancelAccountDeletionResult, type CreateOAuthStateParams, DEFAULT_DELETION_ALLOW_SELF_IMMEDIATE, DEFAULT_DELETION_GRACE_PERIOD_DAYS, DEFAULT_DELETION_PURGE_CRON, DEFAULT_DELETION_PURGE_STRATEGY, DEFAULT_DELETION_SEND_NOTIFICATIONS, type DecryptedOAuthToken, EnvironmentKeyringTokenCipher, type GoogleTokenResponse, type GoogleUserInfo, type Invitation, type InvitationAcceptedPayload, type InvitationCreatedPayload, InvitationStatus, InvitationsRepository,
|
|
6917
|
+
export { type AccountDeletionPurgeUser, type AccountDeletionRequest, AccountDeletionRequestedBy, AccountDeletionRequestsRepository, type AuthConfig, AuthContext, type AuthDeletionCancelledPayload, type AuthDeletionCompletedPayload, type AuthDeletionConfig, type AuthDeletionRequestedPayload, type AuthLifecycleConfig, type AuthLifecycleOptions, type AuthLoginPayload, type AuthMetadataEntity, AuthMetadataRepository, AuthProviderSchema, type AuthRegisterPayload, type BeforeRegisterContext, COOKIE_NAMES, type CancelAccountDeletionParams, type CancelAccountDeletionResult, type CreateOAuthStateParams, DEFAULT_DELETION_ALLOW_SELF_IMMEDIATE, DEFAULT_DELETION_GRACE_PERIOD_DAYS, DEFAULT_DELETION_PURGE_CRON, DEFAULT_DELETION_PURGE_STRATEGY, DEFAULT_DELETION_SEND_NOTIFICATIONS, type DecryptedOAuthToken, EnvironmentKeyringTokenCipher, type GoogleTokenResponse, type GoogleUserInfo, type Invitation, type InvitationAcceptedPayload, type InvitationCreatedPayload, InvitationStatus, InvitationsRepository, type IssuedOpsToken, KeyAlgorithmType, KeysRepository, type NewAccountDeletionRequest, type NewAuthMetadataEntity, type NewInvitation, type NewOpsToken, type NewPermission, type NewPermissionEntity, type NewRole, type NewRoleEntity, type NewRolePermission, type NewUser, type NewUserPermission, type NewUserProfile, type NewUserPublicKey, type NewUserSocialAccount, type NewVerificationCode, OAuthProvider, type OAuthState, type OAuthTokenCipher, type OAuthTokenContext, type OAuthTokenType, type OAuthUnlinkedPayload, type OpsToken, OpsTokensRepository, type PendingDeletionInfo, type Permission, type PermissionEntity, PermissionsRepository, PurgeStrategy, type PurgeUserResult, type RegisterChannel, type RequestAccountDeletionParams, type RequestAccountDeletionResult, type Role, type RoleEntity, type RoleGuardOptions, type RolePermission, RolePermissionsRepository, RolesRepository, type SessionPayload, SocialAccountsRepository, SocialProvider, type SweepDuePurgesResult, type TokenPayload, type UpdateProfileParams, type User, type UserPermission, UserPermissionsRepository, type UserProfile, UserProfilesRepository, type UserPublicKey, type UserSocialAccount, UsersRepository, type VerificationCode, VerificationCodesRepository, VerificationPurpose, type VerifiedOpsToken, type VerifyIdTokenParams, acceptInvitation, accountDeletionRequests, accountDeletionRequestsRepository, addPermissionToRole, appleProvider, assertCanAssignRole, authDeletionCancelledEvent, authDeletionCompletedEvent, authDeletionRequestedEvent, authJobRouter, authLogger, authLoginEvent, authMetadata, authMetadataRepository, authRegisterEvent, authSchema, cancelAccountDeletionService, cancelInvitation, checkUsernameAvailableService, configureAuth, configureDeletion, configureOAuthTokenCipher, createAuthDeletionJobRouter, createAuthDeletionPurgeJob, createAuthLifecycle, createInvitation, createOAuthState, createRole, decodeToken, decryptToken, deleteInvitation, deleteRole, encryptToken, exchangeCodeForTokens, expireOldInvitations, generateOAuthNonce, generateToken, getAllRoles, getAuth, getAuthConfig, getAuthSessionService, getDeletionConfig, getDummyPasswordHash, getGoogleAuthUrl, getGoogleOAuthConfig, getGoogleUserInfo, getInvitationByToken, getInvitationWithDetails, getKeyId, getLocale, getOneTimeTokenManager, getOpsToken, getOptionalAuth, getPendingDeletionInfo, getRole, getRoleByName, getRolePermissions, getSessionTtl, getUser, getUserByEmailService, getUserByIdService, getUserByPhoneService, getUserId, getUserPermissions, getUserProfileService, getUserRole, githubProvider, googleProvider, hasAllPermissions, hasAnyPermission, hasAnyRole, hasPermission, hasRole, hashPassword, initOneTimeTokenManager, initializeAuth, invitationAcceptedEvent, invitationCreatedEvent, invitationsRepository, isEncrypted, isGoogleOAuthEnabled, issueOpsTokenService, kakaoProvider, keysRepository, listInvitations, listOpsTokensService, matchOAuthCsrfCookies, naverProvider, oauthUnlinkedEvent, oneTimeTokenAuth, opsTokenAuth, opsTokens, opsTokensRepository, parseDuration, permissions, permissionsRepository, purgeUserService, refreshAccessToken, removePermissionFromRole, requestAccountDeletionService, requireAnyPermission, requireOpsScope, requirePermissions, requireRole, resendInvitation, revokeOpsTokenService, roleGuard, rolePermissions, rolePermissionsRepository, roles, rolesRepository, runBeforeRegister, setRolePermissions, socialAccountsRepository, sweepDuePurges, updateLastLoginService, updateLocaleService, updateRole, updateUserProfileService, updateUserService, updateUsernameService, userInvitations, userPermissions, userPermissionsRepository, userProfiles, userProfilesRepository, userPublicKeys, userSocialAccounts, users, usersRepository, validateInvitation, validatePasswordStrength, verificationCodes, verificationCodesRepository, verifyClientToken, verifyIdToken, verifyKeyFingerprint, verifyOAuthState, verifyOpsTokenService, verifyPassword, verifyToken };
|