@spfn/auth 0.2.0-beta.86 → 0.2.0-beta.88
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 +347 -27
- package/dist/{authenticate-DTA7W4v2.d.ts → authenticate-ZssfqJ7d.d.ts} +201 -5
- package/dist/client-proof.d.ts +185 -46
- package/dist/client-proof.js +253 -34
- package/dist/client-proof.js.map +1 -1
- package/dist/config.d.ts +36 -0
- package/dist/config.js +18 -0
- package/dist/config.js.map +1 -1
- package/dist/errors.d.ts +93 -2
- package/dist/errors.js +57 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +33 -3
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -1
- package/dist/nextjs/server.d.ts +2 -2
- package/dist/server.d.ts +148 -12
- package/dist/server.js +1410 -192
- package/dist/server.js.map +1 -1
- package/dist/{session-CGxgH3C9.d.ts → session-CFK4BT25.d.ts} +1 -1
- package/dist/{types-1BMx0OX1.d.ts → types-CD95yudz.d.ts} +15 -1
- package/migrations/20251125021229_premium_famine/snapshot.json +2641 -0
- package/migrations/20260225130050_smooth_the_fury/snapshot.json +2686 -0
- package/migrations/20260308141417_deep_iceman/snapshot.json +2686 -0
- package/migrations/20260308151309_perfect_deathbird/snapshot.json +2731 -0
- package/migrations/20260308201135_concerned_rawhide_kid/snapshot.json +2786 -0
- package/migrations/20260629103209_lethal_lifeguard/snapshot.json +2786 -0
- package/migrations/20260709073531_easy_hardball/snapshot.json +3119 -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 +6 -9
- package/migrations/meta/0000_snapshot.json +0 -1632
- package/migrations/meta/0001_snapshot.json +0 -1660
- package/migrations/meta/0002_snapshot.json +0 -1660
- package/migrations/meta/0003_snapshot.json +0 -1689
- package/migrations/meta/0004_snapshot.json +0 -1721
- package/migrations/meta/0005_snapshot.json +0 -1721
- package/migrations/meta/0006_snapshot.json +0 -1921
- package/migrations/meta/0007_snapshot.json +0 -1916
- package/migrations/meta/_journal.json +0 -62
- /package/migrations/{0000_premium_famine.sql → 20251125021229_premium_famine/migration.sql} +0 -0
- /package/migrations/{0001_smooth_the_fury.sql → 20260225130050_smooth_the_fury/migration.sql} +0 -0
- /package/migrations/{0002_deep_iceman.sql → 20260308141417_deep_iceman/migration.sql} +0 -0
- /package/migrations/{0003_perfect_deathbird.sql → 20260308151309_perfect_deathbird/migration.sql} +0 -0
- /package/migrations/{0004_concerned_rawhide_kid.sql → 20260308201135_concerned_rawhide_kid/migration.sql} +0 -0
- /package/migrations/{0005_lethal_lifeguard.sql → 20260629103209_lethal_lifeguard/migration.sql} +0 -0
- /package/migrations/{0006_easy_hardball.sql → 20260709073531_easy_hardball/migration.sql} +0 -0
- /package/migrations/{0007_glossy_major_mapleleaf.sql → 20260714081434_glossy_major_mapleleaf/migration.sql} +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as _spfn_core_route from '@spfn/core/route';
|
|
2
|
-
import { K as KeyAlgorithmType,
|
|
2
|
+
import { K as KeyAlgorithmType, d as KeyPlatformType, h as SocialProvider } from './types-CD95yudz.js';
|
|
3
3
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
4
4
|
import { Static } from '@sinclair/typebox';
|
|
5
|
+
import { Context } from 'hono';
|
|
5
6
|
import { User } from '@spfn/auth/server';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -100,6 +101,8 @@ interface RegisterParams {
|
|
|
100
101
|
keyId: string;
|
|
101
102
|
fingerprint: string;
|
|
102
103
|
algorithm?: KeyAlgorithmType;
|
|
104
|
+
deviceName?: string;
|
|
105
|
+
platform?: KeyPlatformType;
|
|
103
106
|
metadata?: Record<string, unknown>;
|
|
104
107
|
}
|
|
105
108
|
interface RegisterResult {
|
|
@@ -117,6 +120,8 @@ interface LoginParams {
|
|
|
117
120
|
fingerprint: string;
|
|
118
121
|
oldKeyId?: string;
|
|
119
122
|
algorithm?: KeyAlgorithmType;
|
|
123
|
+
deviceName?: string;
|
|
124
|
+
platform?: KeyPlatformType;
|
|
120
125
|
}
|
|
121
126
|
interface LoginResult {
|
|
122
127
|
userId: string;
|
|
@@ -154,6 +159,16 @@ declare function changePasswordService(params: ChangePasswordParams): Promise<vo
|
|
|
154
159
|
|
|
155
160
|
declare const EmailSchema: _sinclair_typebox.TString;
|
|
156
161
|
declare const PhoneSchema: _sinclair_typebox.TString;
|
|
162
|
+
/**
|
|
163
|
+
* Optional device labels a client may send when registering a key.
|
|
164
|
+
*
|
|
165
|
+
* Display only: the key list uses them to tell one device from another, and
|
|
166
|
+
* nothing is authorized or refused by either value, so a client that lies about
|
|
167
|
+
* them gains nothing. Both are omitted by every key registered before they
|
|
168
|
+
* existed, hence optional rather than defaulted.
|
|
169
|
+
*/
|
|
170
|
+
declare const DeviceNameSchema: _sinclair_typebox.TString;
|
|
171
|
+
declare const PlatformSchema: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ios" | "android" | "web" | "desktop">[]>;
|
|
157
172
|
declare const PasswordSchema: _sinclair_typebox.TString;
|
|
158
173
|
declare const TargetTypeSchema: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"email">, _sinclair_typebox.TLiteral<"phone">]>;
|
|
159
174
|
type VerificationTargetType = Static<typeof TargetTypeSchema>;
|
|
@@ -211,6 +226,9 @@ interface RegisterPublicKeyParams {
|
|
|
211
226
|
publicKey: string;
|
|
212
227
|
fingerprint: string;
|
|
213
228
|
algorithm?: KeyAlgorithmType;
|
|
229
|
+
/** Device label for the key list. Display only — nothing is authorized by it. */
|
|
230
|
+
deviceName?: string;
|
|
231
|
+
platform?: KeyPlatformType;
|
|
214
232
|
}
|
|
215
233
|
interface RotateKeyParams {
|
|
216
234
|
userId: number;
|
|
@@ -219,6 +237,9 @@ interface RotateKeyParams {
|
|
|
219
237
|
newPublicKey: string;
|
|
220
238
|
fingerprint: string;
|
|
221
239
|
algorithm?: KeyAlgorithmType;
|
|
240
|
+
/** Omitted: the replaced key's label carries over, so rotation keeps its name. */
|
|
241
|
+
deviceName?: string;
|
|
242
|
+
platform?: KeyPlatformType;
|
|
222
243
|
}
|
|
223
244
|
interface RotateKeyResult {
|
|
224
245
|
success: boolean;
|
|
@@ -229,8 +250,53 @@ interface RevokeKeyParams {
|
|
|
229
250
|
keyId: string;
|
|
230
251
|
reason: string;
|
|
231
252
|
}
|
|
253
|
+
interface RevokeAllKeysParams {
|
|
254
|
+
userId: number;
|
|
255
|
+
/** The key the request itself is signed with — spared unless includeCurrent. */
|
|
256
|
+
currentKeyId: string;
|
|
257
|
+
/** true signs the caller out too. Default false: "my other devices". */
|
|
258
|
+
includeCurrent?: boolean;
|
|
259
|
+
reason: string;
|
|
260
|
+
}
|
|
261
|
+
interface RevokeAllKeysResult {
|
|
262
|
+
revokedCount: number;
|
|
263
|
+
currentKeyRevoked: boolean;
|
|
264
|
+
}
|
|
265
|
+
/** One registered device as the account surface shows it. */
|
|
266
|
+
interface KeySummary {
|
|
267
|
+
keyId: string;
|
|
268
|
+
deviceName?: string;
|
|
269
|
+
platform?: string;
|
|
270
|
+
algorithm: KeyAlgorithmType;
|
|
271
|
+
/** First bytes of the fingerprint — enough to tell two entries apart. */
|
|
272
|
+
fingerprintPrefix: string;
|
|
273
|
+
createdAt: string;
|
|
274
|
+
lastUsedAt?: string;
|
|
275
|
+
expiresAt?: string;
|
|
276
|
+
/** The TTL has run out. The key still reads as active; authenticate refuses it. */
|
|
277
|
+
isExpired: boolean;
|
|
278
|
+
/** False once revoked. Only ever false when the caller asked for revoked keys. */
|
|
279
|
+
isActive: boolean;
|
|
280
|
+
/** When it was revoked, for the "what did I cut off, and when" reading. */
|
|
281
|
+
revokedAt?: string;
|
|
282
|
+
}
|
|
283
|
+
interface ListKeysParams {
|
|
284
|
+
userId: number;
|
|
285
|
+
/** Also return keys already revoked. Default false: only what can still sign. */
|
|
286
|
+
includeRevoked?: boolean;
|
|
287
|
+
}
|
|
288
|
+
/** How much of the fingerprint the list returns. */
|
|
289
|
+
declare const KEY_FINGERPRINT_PREFIX_LENGTH = 8;
|
|
232
290
|
/**
|
|
233
291
|
* Register a new public key for a user
|
|
292
|
+
*
|
|
293
|
+
* `keyId` is UNIQUE across all users, so the lookup must ignore `isActive` —
|
|
294
|
+
* filtering on it misses a revoked row and the insert then fails on the unique
|
|
295
|
+
* index, rolling the whole login transaction back into a 500. Reuse is refused
|
|
296
|
+
* with a domain error instead, telling the client to generate a fresh keyId.
|
|
297
|
+
*
|
|
298
|
+
* @throws KeyIdAlreadyRegisteredError keyId가 이미 쓰인 값일 때 (자기 폐기 키 재사용 · 남의 키)
|
|
299
|
+
* @throws InvalidKeyFingerprintError fingerprint가 publicKey와 맞지 않을 때
|
|
234
300
|
*/
|
|
235
301
|
declare function registerPublicKeyService(params: RegisterPublicKeyParams): Promise<void>;
|
|
236
302
|
/**
|
|
@@ -238,9 +304,36 @@ declare function registerPublicKeyService(params: RegisterPublicKeyParams): Prom
|
|
|
238
304
|
*/
|
|
239
305
|
declare function rotateKeyService(params: RotateKeyParams): Promise<RotateKeyResult>;
|
|
240
306
|
/**
|
|
241
|
-
* Revoke a user's public key
|
|
307
|
+
* Revoke a user's public key.
|
|
308
|
+
*
|
|
309
|
+
* Returns false when the key does not belong to this user, so a caller acting
|
|
310
|
+
* on a key id from outside (the device list) can answer "not found" instead of
|
|
311
|
+
* reporting a revocation that never happened. The repository already scopes the
|
|
312
|
+
* update by userId, so someone else's key is never touched either way.
|
|
242
313
|
*/
|
|
243
|
-
declare function revokeKeyService(params: RevokeKeyParams): Promise<
|
|
314
|
+
declare function revokeKeyService(params: RevokeKeyParams): Promise<boolean>;
|
|
315
|
+
/**
|
|
316
|
+
* List the caller's active keys — one entry per device that can sign for them.
|
|
317
|
+
*
|
|
318
|
+
* `isExpired` is computed rather than stored: an expired key keeps `isActive`
|
|
319
|
+
* true (nothing flips it), and `authenticate` refuses it at request time. A list
|
|
320
|
+
* that showed it as simply "active" would be telling the user something the
|
|
321
|
+
* server does not act on.
|
|
322
|
+
*
|
|
323
|
+
* The fingerprint is truncated. Its full value is what a native sign-in must
|
|
324
|
+
* send as its nonce (issue #63), and an account page has no use for it beyond
|
|
325
|
+
* telling two entries apart.
|
|
326
|
+
*/
|
|
327
|
+
declare function listKeysService(params: ListKeysParams): Promise<KeySummary[]>;
|
|
328
|
+
/**
|
|
329
|
+
* Revoke every active key the user has, optionally sparing the current one.
|
|
330
|
+
*
|
|
331
|
+
* The caller's own key is spared by default, so "sign out my other devices"
|
|
332
|
+
* does not also end the session making the request. Passing
|
|
333
|
+
* `includeCurrent: true` is the full sign-out, which until now was reachable
|
|
334
|
+
* only as a side effect of changing a password.
|
|
335
|
+
*/
|
|
336
|
+
declare function revokeAllKeysService(params: RevokeAllKeysParams): Promise<RevokeAllKeysResult>;
|
|
244
337
|
|
|
245
338
|
/**
|
|
246
339
|
* @spfn/auth - RBAC Type Definitions
|
|
@@ -391,6 +484,16 @@ interface OAuthTokens {
|
|
|
391
484
|
interface NativeVerifyOptions {
|
|
392
485
|
/** 클라이언트가 생성한 raw nonce. provider별 규약(raw 또는 SHA-256 해시)으로 대조된다. */
|
|
393
486
|
nonce: string;
|
|
487
|
+
/**
|
|
488
|
+
* 같은 로그인에서 SDK가 함께 받은 provider access token (선택).
|
|
489
|
+
*
|
|
490
|
+
* id_token만으로는 알 수 없는 claim을 provider API로 보강하려는 provider가 쓴다
|
|
491
|
+
* (카카오: id_token에 email_verified가 없어 /v2/user/me의 이메일 유효·인증 플래그를 본다).
|
|
492
|
+
*
|
|
493
|
+
* ⚠️ 클라이언트가 보낸 검증되지 않은 값이다. 다른 사용자의 토큰일 수 있으므로,
|
|
494
|
+
* 이 값으로 조회한 신원은 반드시 id_token의 sub와 대조한 뒤에만 신뢰해야 한다.
|
|
495
|
+
*/
|
|
496
|
+
accessToken?: string;
|
|
394
497
|
}
|
|
395
498
|
interface OAuthCodeExchangeOptions {
|
|
396
499
|
/** Provider가 callback에 돌려준 원본 state. 일부 provider는 token 교환에도 요구한다. */
|
|
@@ -620,6 +723,16 @@ interface OAuthNativeParams {
|
|
|
620
723
|
keyId: string;
|
|
621
724
|
fingerprint: string;
|
|
622
725
|
algorithm: KeyAlgorithmType;
|
|
726
|
+
/** 키 목록에 보일 기기 라벨 (선택). 표시용이라 권한 판정에 쓰이지 않는다. */
|
|
727
|
+
deviceName?: string;
|
|
728
|
+
platform?: KeyPlatformType;
|
|
729
|
+
/**
|
|
730
|
+
* SDK가 id_token과 함께 받은 provider access token (선택).
|
|
731
|
+
*
|
|
732
|
+
* provider가 id_token만으로 확인할 수 없는 claim을 보강할 때만 쓴다. 없으면 provider는
|
|
733
|
+
* id_token이 담은 정보만으로 신원을 정규화한다.
|
|
734
|
+
*/
|
|
735
|
+
accessToken?: string;
|
|
623
736
|
/** Apple은 첫 로그인에만 이름을 별도로 주므로 클라이언트가 전달할 수 있다. */
|
|
624
737
|
profile?: {
|
|
625
738
|
name?: string;
|
|
@@ -634,7 +747,7 @@ interface OAuthNativeResult {
|
|
|
634
747
|
/**
|
|
635
748
|
* native id_token 로그인 처리
|
|
636
749
|
*
|
|
637
|
-
* @throws
|
|
750
|
+
* @throws NativeSignInUnsupportedError provider가 native sign-in을 지원하지 않을 때
|
|
638
751
|
* @throws InvalidSocialTokenError id_token 검증 실패 시
|
|
639
752
|
*/
|
|
640
753
|
declare function oauthNativeService(params: OAuthNativeParams): Promise<OAuthNativeResult>;
|
|
@@ -689,6 +802,8 @@ declare const mainAuthRouter: _spfn_core_route.Router<{
|
|
|
689
802
|
keyId: _sinclair_typebox.TString;
|
|
690
803
|
fingerprint: _sinclair_typebox.TString;
|
|
691
804
|
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
805
|
+
deviceName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
806
|
+
platform: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ios" | "android" | "web" | "desktop">[]>>;
|
|
692
807
|
}>;
|
|
693
808
|
}, RegisterResult>;
|
|
694
809
|
login: _spfn_core_route.RouteDef<{
|
|
@@ -704,6 +819,8 @@ declare const mainAuthRouter: _spfn_core_route.Router<{
|
|
|
704
819
|
fingerprint: _sinclair_typebox.TString;
|
|
705
820
|
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
706
821
|
oldKeyId: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
822
|
+
deviceName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
823
|
+
platform: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ios" | "android" | "web" | "desktop">[]>>;
|
|
707
824
|
}>;
|
|
708
825
|
}, LoginResult>;
|
|
709
826
|
logout: _spfn_core_route.RouteDef<{}, {}, void>;
|
|
@@ -713,8 +830,30 @@ declare const mainAuthRouter: _spfn_core_route.Router<{
|
|
|
713
830
|
keyId: _sinclair_typebox.TString;
|
|
714
831
|
fingerprint: _sinclair_typebox.TString;
|
|
715
832
|
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
833
|
+
deviceName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
834
|
+
platform: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ios" | "android" | "web" | "desktop">[]>>;
|
|
716
835
|
}>;
|
|
717
836
|
}, RotateKeyResult>;
|
|
837
|
+
listKeys: _spfn_core_route.RouteDef<{
|
|
838
|
+
body: _sinclair_typebox.TObject<{
|
|
839
|
+
includeRevoked: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
840
|
+
}>;
|
|
841
|
+
}, {}, {
|
|
842
|
+
keys: KeySummary[];
|
|
843
|
+
}>;
|
|
844
|
+
revokeKey: _spfn_core_route.RouteDef<{
|
|
845
|
+
body: _sinclair_typebox.TObject<{
|
|
846
|
+
keyId: _sinclair_typebox.TString;
|
|
847
|
+
}>;
|
|
848
|
+
}, {}, {
|
|
849
|
+
keyId: string;
|
|
850
|
+
selfRevoked: boolean;
|
|
851
|
+
}>;
|
|
852
|
+
revokeAllKeys: _spfn_core_route.RouteDef<{
|
|
853
|
+
body: _sinclair_typebox.TObject<{
|
|
854
|
+
includeCurrent: _sinclair_typebox.TOptional<_sinclair_typebox.TBoolean>;
|
|
855
|
+
}>;
|
|
856
|
+
}, {}, RevokeAllKeysResult>;
|
|
718
857
|
changePassword: _spfn_core_route.RouteDef<{
|
|
719
858
|
body: _sinclair_typebox.TObject<{
|
|
720
859
|
currentPassword: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
@@ -846,10 +985,13 @@ declare const mainAuthRouter: _spfn_core_route.Router<{
|
|
|
846
985
|
body: _sinclair_typebox.TObject<{
|
|
847
986
|
idToken: _sinclair_typebox.TString;
|
|
848
987
|
nonce: _sinclair_typebox.TString;
|
|
988
|
+
accessToken: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
849
989
|
publicKey: _sinclair_typebox.TString;
|
|
850
990
|
keyId: _sinclair_typebox.TString;
|
|
851
991
|
fingerprint: _sinclair_typebox.TString;
|
|
852
992
|
algorithm: _sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ES256" | "RS256">[]>;
|
|
993
|
+
deviceName: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
994
|
+
platform: _sinclair_typebox.TOptional<_sinclair_typebox.TUnion<_sinclair_typebox.TLiteral<"ios" | "android" | "web" | "desktop">[]>>;
|
|
853
995
|
profile: _sinclair_typebox.TOptional<_sinclair_typebox.TObject<{
|
|
854
996
|
name: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
855
997
|
}>>;
|
|
@@ -1104,13 +1246,67 @@ declare const mainAuthRouter: _spfn_core_route.Router<{
|
|
|
1104
1246
|
}>;
|
|
1105
1247
|
}>;
|
|
1106
1248
|
|
|
1249
|
+
/**
|
|
1250
|
+
* The auth-profile registry the authenticate middleware dispatches on.
|
|
1251
|
+
*
|
|
1252
|
+
* A request that names `x-spfn-auth-profile` is answered by the verifier
|
|
1253
|
+
* registered for that profile — an O(1) map lookup, never a per-profile if
|
|
1254
|
+
* chain in the middleware body. A request that names no profile falls through
|
|
1255
|
+
* to the existing Bearer path untouched.
|
|
1256
|
+
*
|
|
1257
|
+
* Every verifier converges on the same `AuthContext` the Bearer path sets, so
|
|
1258
|
+
* downstream permission/tenant code consumes one principal shape and never
|
|
1259
|
+
* branches on how it was authenticated.
|
|
1260
|
+
*
|
|
1261
|
+
* The clientProofV1 verifier reuses the phase-1 admission pieces (header
|
|
1262
|
+
* shape, canonical body, proof-input assembly, ECDSA verification) with two
|
|
1263
|
+
* production substitutions: the key directory is `user_public_keys` via
|
|
1264
|
+
* `keysRepository`, and the replay ledger is the pluggable store from
|
|
1265
|
+
* `client-proof/replay-store` (memory default, Redis opt-in). The admission
|
|
1266
|
+
* order is the contract's — revocation → session → expiry → replay → proof —
|
|
1267
|
+
* and the non-disclosure rule holds: an unregistered keyId shares
|
|
1268
|
+
* PROOF_INVALID with a failed signature, while a revoked or expired key
|
|
1269
|
+
* answers SESSION_REVOKED before the proof is ever examined.
|
|
1270
|
+
*
|
|
1271
|
+
* @module server/middleware/auth-profiles
|
|
1272
|
+
*/
|
|
1273
|
+
|
|
1274
|
+
/** What a verified request leaves in the context — one shape for every scheme. */
|
|
1107
1275
|
interface AuthContext {
|
|
1108
1276
|
user: User;
|
|
1109
1277
|
userId: string;
|
|
1110
1278
|
keyId: string;
|
|
1111
1279
|
role: string | null;
|
|
1112
1280
|
locale: string;
|
|
1281
|
+
/** How the principal was authenticated. Informational — downstream code never branches on it. */
|
|
1282
|
+
scheme: 'bearer' | 'clientProofV1' | 'oneTimeToken';
|
|
1283
|
+
}
|
|
1284
|
+
/** A profile's verifier: admits the request and returns the principal, or throws. */
|
|
1285
|
+
interface AuthProfileVerifier {
|
|
1286
|
+
verify(c: Context): Promise<AuthContext>;
|
|
1113
1287
|
}
|
|
1288
|
+
/**
|
|
1289
|
+
* Routes a request to its profile verifier.
|
|
1290
|
+
*
|
|
1291
|
+
* - no profile header → null: the caller continues on the Bearer path;
|
|
1292
|
+
* - profile header + Authorization header → rejected (mixing prohibited);
|
|
1293
|
+
* - unknown profile value → rejected (unknownProfilePolicy: reject).
|
|
1294
|
+
*
|
|
1295
|
+
* Shared by authenticate and optionalAuth so "presented but invalid" refuses
|
|
1296
|
+
* identically on both — only the "presented nothing" outcome differs.
|
|
1297
|
+
*/
|
|
1298
|
+
declare function selectAuthProfile(c: Context): AuthProfileVerifier | null;
|
|
1299
|
+
/**
|
|
1300
|
+
* Loads the user for an authenticated key and applies the account-status
|
|
1301
|
+
* rules. One implementation for every scheme: the Bearer path and the profile
|
|
1302
|
+
* verifiers call this, so a status added here gates both identically.
|
|
1303
|
+
*/
|
|
1304
|
+
declare function resolveAuthenticatedUser(userId: number): Promise<{
|
|
1305
|
+
user: User;
|
|
1306
|
+
role: string | null;
|
|
1307
|
+
locale: string;
|
|
1308
|
+
}>;
|
|
1309
|
+
|
|
1114
1310
|
declare module 'hono' {
|
|
1115
1311
|
interface ContextVariableMap {
|
|
1116
1312
|
auth: AuthContext;
|
|
@@ -1176,4 +1372,4 @@ declare const authenticate: _spfn_core_route.NamedMiddleware<"auth">;
|
|
|
1176
1372
|
*/
|
|
1177
1373
|
declare const optionalAuth: _spfn_core_route.NamedMiddleware<"optionalAuth">;
|
|
1178
1374
|
|
|
1179
|
-
export {
|
|
1375
|
+
export { requireEnabledProvider as $, type AuthSession as A, registerPublicKeyService as B, type ChangePasswordParams as C, rotateKeyService as D, revokeKeyService as E, listKeysService as F, revokeAllKeysService as G, KEY_FINGERPRINT_PREFIX_LENGTH as H, type IssueOneTimeTokenResult as I, type RegisterPublicKeyParams as J, type KeySummary as K, type LoginResult as L, type RotateKeyParams as M, type RevokeKeyParams as N, type OAuthStartResult as O, type PermissionConfig as P, type RevokeAllKeysParams as Q, type RoleConfig as R, type SendVerificationCodeResult as S, issueOneTimeTokenService as T, type UserProfile as U, type VerificationTargetType as V, verifyOneTimeTokenService as W, oauthStartService as X, oauthCallbackService as Y, buildOAuthErrorUrl as Z, isOAuthProviderEnabled as _, type RegisterResult as a, getEnabledOAuthProviders as a0, getGoogleAccessToken as a1, oauthUnlinkNotifyService as a2, type OAuthStartParams as a3, type OAuthCallbackParams as a4, type OAuthCallbackResult as a5, type UnlinkNotifyResult as a6, oauthNativeService as a7, type OAuthNativeParams as a8, selectAuthProfile as a9, resolveAuthenticatedUser as aa, type AuthProfileVerifier as ab, authenticate as ac, optionalAuth as ad, EmailSchema as ae, PhoneSchema as af, DeviceNameSchema as ag, PlatformSchema as ah, PasswordSchema as ai, TargetTypeSchema as aj, VerificationPurposeSchema as ak, type NormalizedIdentity as al, type OAuthTokens as am, type NativeVerifyOptions as an, type OAuthCodeExchangeOptions as ao, type UnlinkNotifyRequest as ap, type UnlinkNotification as aq, UnlinkNotifyRejection as ar, registerOAuthProvider as as, getOAuthProvider as at, getRegisteredProviders as au, type RotateKeyResult as b, type RevokeAllKeysResult as c, type OAuthNativeResult as d, type ProfileInfo as e, type VerificationPurpose as f, VERIFICATION_TARGET_TYPES as g, VERIFICATION_PURPOSES as h, PERMISSION_CATEGORIES as i, type PermissionCategory as j, type AuthInitOptions as k, type OAuthProvider as l, mainAuthRouter as m, type AuthContext as n, loginService as o, logoutService as p, changePasswordService as q, registerService as r, type RegisterParams as s, type LoginParams as t, type LogoutParams as u, sendVerificationCodeService as v, verifyCodeService as w, type SendVerificationCodeParams as x, type VerifyCodeParams as y, type VerifyCodeResult as z };
|