isa-auth 0.1.0 → 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/.agents/skills/isa-auth-guide/SKILL.md +154 -0
- package/README.md +176 -120
- package/dist/index.d.mts +797 -68
- package/dist/index.d.ts +797 -68
- package/dist/index.js +2380 -293
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2379 -292
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -6
- package/skills/isa-auth-guide/SKILL.md +167 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type AuthButtonType = 'rect' | 'rounded' | 'circle' | 'link' | 'brand';
|
|
2
|
-
type ButtonProviderType = 'default' | 'google' | 'apple' | 'kakao' | 'line' | 'naver' | 'facebook' | 'twitter' | 'wechat' | 'web3';
|
|
2
|
+
type ButtonProviderType = 'default' | 'google' | 'apple' | 'kakao' | 'line' | 'naver' | 'facebook' | 'meta' | 'twitter' | 'wechat' | 'web3' | 'github' | 'discord' | 'world' | 'passkey';
|
|
3
3
|
interface LoginButtonConfig {
|
|
4
4
|
id: string;
|
|
5
5
|
style?: Partial<CSSStyleDeclaration>;
|
|
@@ -64,6 +64,78 @@ declare class GoogleAuthProvider implements AuthProvider$1 {
|
|
|
64
64
|
getUserInfo(): Promise<any>;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
declare global {
|
|
68
|
+
interface Window {
|
|
69
|
+
AppleID?: any;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
interface AppleAuthOptions {
|
|
73
|
+
clientId: string;
|
|
74
|
+
redirectURI?: string;
|
|
75
|
+
scope?: string;
|
|
76
|
+
state?: string;
|
|
77
|
+
nonce?: string;
|
|
78
|
+
usePopup?: boolean;
|
|
79
|
+
onSuccess?: (response: any) => void;
|
|
80
|
+
onFail?: (error: any) => void;
|
|
81
|
+
}
|
|
82
|
+
declare class AppleAuthProvider implements AuthProvider$1 {
|
|
83
|
+
private clientId;
|
|
84
|
+
private redirectURI;
|
|
85
|
+
private scope;
|
|
86
|
+
private state?;
|
|
87
|
+
private nonce?;
|
|
88
|
+
private usePopup;
|
|
89
|
+
private onSuccess?;
|
|
90
|
+
private onFail?;
|
|
91
|
+
private idToken;
|
|
92
|
+
private userInfo;
|
|
93
|
+
constructor(options: AppleAuthOptions);
|
|
94
|
+
loadAppleSdk(): Promise<void>;
|
|
95
|
+
init(): Promise<void>;
|
|
96
|
+
signIn(): Promise<void>;
|
|
97
|
+
signOut(): void;
|
|
98
|
+
getAccessToken(): Promise<string | null>;
|
|
99
|
+
getUserInfo(): Promise<any>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare global {
|
|
103
|
+
interface Window {
|
|
104
|
+
FB?: any;
|
|
105
|
+
fbAsyncInit?: () => void;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
interface MetaAuthOptions {
|
|
109
|
+
appId: string;
|
|
110
|
+
version?: string;
|
|
111
|
+
redirectUri?: string;
|
|
112
|
+
scope?: string;
|
|
113
|
+
isPopup?: boolean;
|
|
114
|
+
onSuccess?: (response: any) => void;
|
|
115
|
+
onFail?: (error: any) => void;
|
|
116
|
+
}
|
|
117
|
+
declare class MetaAuthProvider implements AuthProvider$1 {
|
|
118
|
+
private appId;
|
|
119
|
+
private version;
|
|
120
|
+
private redirectUri?;
|
|
121
|
+
private scope;
|
|
122
|
+
private isPopup;
|
|
123
|
+
private onSuccess?;
|
|
124
|
+
private onFail?;
|
|
125
|
+
private accessToken;
|
|
126
|
+
private userInfo;
|
|
127
|
+
constructor(options: MetaAuthOptions);
|
|
128
|
+
loadFacebookSdk(): Promise<void>;
|
|
129
|
+
init(): Promise<void>;
|
|
130
|
+
signIn(): void;
|
|
131
|
+
signOut(): void;
|
|
132
|
+
getAccessToken(): Promise<string | null>;
|
|
133
|
+
getUserInfo(): Promise<any>;
|
|
134
|
+
setToken(token: string): void;
|
|
135
|
+
setUser(user: any): void;
|
|
136
|
+
}
|
|
137
|
+
declare const FacebookAuthProvider: typeof MetaAuthProvider;
|
|
138
|
+
|
|
67
139
|
declare global {
|
|
68
140
|
interface Window {
|
|
69
141
|
Kakao?: any;
|
|
@@ -119,6 +191,123 @@ declare class NaverAuthProvider implements AuthProvider$1 {
|
|
|
119
191
|
getUserInfo(): Promise<any>;
|
|
120
192
|
}
|
|
121
193
|
|
|
194
|
+
interface LineAuthOptions {
|
|
195
|
+
clientId: string;
|
|
196
|
+
callbackUrl?: string;
|
|
197
|
+
scope?: string;
|
|
198
|
+
state?: string;
|
|
199
|
+
nonce?: string;
|
|
200
|
+
isPopup?: boolean;
|
|
201
|
+
botPrompt?: 'normal' | 'aggressive';
|
|
202
|
+
onSuccess?: (response: any) => void;
|
|
203
|
+
onFail?: (error: any) => void;
|
|
204
|
+
}
|
|
205
|
+
declare class LineAuthProvider implements AuthProvider$1 {
|
|
206
|
+
private clientId;
|
|
207
|
+
private callbackUrl;
|
|
208
|
+
private scope;
|
|
209
|
+
private state?;
|
|
210
|
+
private nonce?;
|
|
211
|
+
private isPopup;
|
|
212
|
+
private botPrompt?;
|
|
213
|
+
private onSuccess?;
|
|
214
|
+
private onFail?;
|
|
215
|
+
private accessToken;
|
|
216
|
+
private userInfo;
|
|
217
|
+
constructor(options: LineAuthOptions);
|
|
218
|
+
init(): Promise<void>;
|
|
219
|
+
buildLoginUrl(): string;
|
|
220
|
+
signIn(): Promise<void>;
|
|
221
|
+
signOut(): void;
|
|
222
|
+
getAccessToken(): Promise<string | null>;
|
|
223
|
+
getUserInfo(): Promise<any>;
|
|
224
|
+
setToken(token: string): void;
|
|
225
|
+
setUser(user: any): void;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare const socialProviders: {
|
|
229
|
+
google: typeof GoogleAuthProvider;
|
|
230
|
+
apple: typeof AppleAuthProvider;
|
|
231
|
+
meta: typeof MetaAuthProvider;
|
|
232
|
+
facebook: typeof MetaAuthProvider;
|
|
233
|
+
kakao: typeof KakaoAuthProvider;
|
|
234
|
+
naver: typeof NaverAuthProvider;
|
|
235
|
+
line: typeof LineAuthProvider;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
interface GithubAuthOptions {
|
|
239
|
+
clientId: string;
|
|
240
|
+
redirectUri?: string;
|
|
241
|
+
scope?: string;
|
|
242
|
+
isPopup?: boolean;
|
|
243
|
+
state?: string;
|
|
244
|
+
usePkce?: boolean;
|
|
245
|
+
onSuccess?: (response: any) => void;
|
|
246
|
+
onFail?: (error: any) => void;
|
|
247
|
+
}
|
|
248
|
+
declare class GithubAuthProvider implements AuthProvider$1 {
|
|
249
|
+
private clientId;
|
|
250
|
+
private redirectUri;
|
|
251
|
+
private scope;
|
|
252
|
+
private isPopup;
|
|
253
|
+
private state?;
|
|
254
|
+
private usePkce;
|
|
255
|
+
private onSuccess?;
|
|
256
|
+
private onFail?;
|
|
257
|
+
private codeVerifier?;
|
|
258
|
+
private accessToken;
|
|
259
|
+
private userInfo;
|
|
260
|
+
constructor(options: GithubAuthOptions);
|
|
261
|
+
init(): Promise<void>;
|
|
262
|
+
buildLoginUrl(): Promise<string>;
|
|
263
|
+
signIn(): Promise<void>;
|
|
264
|
+
signOut(): void;
|
|
265
|
+
getAccessToken(): Promise<string | null>;
|
|
266
|
+
getUserInfo(): Promise<any>;
|
|
267
|
+
setToken(token: string): void;
|
|
268
|
+
setUser(user: any): void;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
interface DiscordAuthOptions {
|
|
272
|
+
clientId: string;
|
|
273
|
+
redirectUri?: string;
|
|
274
|
+
scope?: string;
|
|
275
|
+
isPopup?: boolean;
|
|
276
|
+
state?: string;
|
|
277
|
+
usePkce?: boolean;
|
|
278
|
+
prompt?: 'consent' | 'none';
|
|
279
|
+
onSuccess?: (response: any) => void;
|
|
280
|
+
onFail?: (error: any) => void;
|
|
281
|
+
}
|
|
282
|
+
declare class DiscordAuthProvider implements AuthProvider$1 {
|
|
283
|
+
private clientId;
|
|
284
|
+
private redirectUri;
|
|
285
|
+
private scope;
|
|
286
|
+
private isPopup;
|
|
287
|
+
private state?;
|
|
288
|
+
private usePkce;
|
|
289
|
+
private prompt?;
|
|
290
|
+
private onSuccess?;
|
|
291
|
+
private onFail?;
|
|
292
|
+
private codeVerifier?;
|
|
293
|
+
private accessToken;
|
|
294
|
+
private userInfo;
|
|
295
|
+
constructor(options: DiscordAuthOptions);
|
|
296
|
+
init(): Promise<void>;
|
|
297
|
+
buildLoginUrl(): Promise<string>;
|
|
298
|
+
signIn(): Promise<void>;
|
|
299
|
+
signOut(): void;
|
|
300
|
+
getAccessToken(): Promise<string | null>;
|
|
301
|
+
getUserInfo(): Promise<any>;
|
|
302
|
+
setToken(token: string): void;
|
|
303
|
+
setUser(user: any): void;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
declare const developerProviders: {
|
|
307
|
+
github: typeof GithubAuthProvider;
|
|
308
|
+
discord: typeof DiscordAuthProvider;
|
|
309
|
+
};
|
|
310
|
+
|
|
122
311
|
/**
|
|
123
312
|
* Web3 Authentication Provider (SIWE - EIP-4361 Sign-In with Ethereum)
|
|
124
313
|
*/
|
|
@@ -159,6 +348,116 @@ declare class Web3AuthProvider implements AuthProvider$1 {
|
|
|
159
348
|
getUserInfo(): Promise<any>;
|
|
160
349
|
}
|
|
161
350
|
|
|
351
|
+
declare const web3Providers: {
|
|
352
|
+
web3: typeof Web3AuthProvider;
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* World ID Authentication & Verification Provider (World Network / Worldcoin Orb)
|
|
357
|
+
* Supports Proof of Personhood (PoP) with Orb and Device verification levels.
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
type WorldVerificationLevel = 'orb' | 'device';
|
|
361
|
+
interface WorldAuthOptions {
|
|
362
|
+
appId: string;
|
|
363
|
+
action: string;
|
|
364
|
+
actionDescription?: string;
|
|
365
|
+
verificationLevel?: WorldVerificationLevel;
|
|
366
|
+
signal?: string;
|
|
367
|
+
bridgeUrl?: string;
|
|
368
|
+
onSuccess?: (result: WorldIDProofResult) => void;
|
|
369
|
+
onFail?: (error: any) => void;
|
|
370
|
+
mockProof?: boolean;
|
|
371
|
+
}
|
|
372
|
+
interface WorldIDProofResult {
|
|
373
|
+
merkle_root: string;
|
|
374
|
+
nullifier_hash: string;
|
|
375
|
+
proof: string;
|
|
376
|
+
verification_level: WorldVerificationLevel;
|
|
377
|
+
credential_type?: string;
|
|
378
|
+
action: string;
|
|
379
|
+
signal?: string;
|
|
380
|
+
}
|
|
381
|
+
declare class WorldAuthProvider implements AuthProvider$1 {
|
|
382
|
+
private appId;
|
|
383
|
+
private action;
|
|
384
|
+
private actionDescription?;
|
|
385
|
+
private verificationLevel;
|
|
386
|
+
private signal?;
|
|
387
|
+
private onSuccess?;
|
|
388
|
+
private onFail?;
|
|
389
|
+
private mockProof;
|
|
390
|
+
private lastProof;
|
|
391
|
+
constructor(options: WorldAuthOptions);
|
|
392
|
+
init(): Promise<void>;
|
|
393
|
+
/**
|
|
394
|
+
* Triggers World ID verification via Orb or Device.
|
|
395
|
+
* In browser environment, launches IDKit modal or resolves with mock proof if configured.
|
|
396
|
+
*/
|
|
397
|
+
signIn(): Promise<void>;
|
|
398
|
+
private promptWorldAppModal;
|
|
399
|
+
signOut(): void;
|
|
400
|
+
getAccessToken(): Promise<string | null>;
|
|
401
|
+
getUserInfo(): Promise<any>;
|
|
402
|
+
getProof(): WorldIDProofResult | null;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Passkey / WebAuthn (FIDO2) Authentication Provider
|
|
407
|
+
* Biometric authentication via Face ID, Touch ID, Windows Hello, and Hardware Keys.
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
interface PasskeyAuthOptions {
|
|
411
|
+
rpName?: string;
|
|
412
|
+
rpId?: string;
|
|
413
|
+
challengeGenerator?: () => Promise<Uint8Array | string> | Uint8Array | string;
|
|
414
|
+
userName?: string;
|
|
415
|
+
userDisplayName?: string;
|
|
416
|
+
userId?: string;
|
|
417
|
+
onSuccess?: (assertion: PasskeyAssertionResult) => void;
|
|
418
|
+
onFail?: (error: any) => void;
|
|
419
|
+
}
|
|
420
|
+
interface PasskeyAssertionResult {
|
|
421
|
+
id: string;
|
|
422
|
+
rawId: string;
|
|
423
|
+
type: 'public-key';
|
|
424
|
+
response: {
|
|
425
|
+
clientDataJSON: string;
|
|
426
|
+
authenticatorData: string;
|
|
427
|
+
signature: string;
|
|
428
|
+
userHandle?: string;
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
declare class PasskeyAuthProvider implements AuthProvider$1 {
|
|
432
|
+
private rpName;
|
|
433
|
+
private rpId?;
|
|
434
|
+
private challengeGenerator?;
|
|
435
|
+
private userName?;
|
|
436
|
+
private userDisplayName?;
|
|
437
|
+
private userId?;
|
|
438
|
+
private onSuccess?;
|
|
439
|
+
private onFail?;
|
|
440
|
+
private lastAssertion;
|
|
441
|
+
constructor(options?: PasskeyAuthOptions);
|
|
442
|
+
init(): Promise<void>;
|
|
443
|
+
/**
|
|
444
|
+
* Helper to register a new Passkey credential
|
|
445
|
+
*/
|
|
446
|
+
registerCredential(options?: {
|
|
447
|
+
challenge?: Uint8Array;
|
|
448
|
+
userName?: string;
|
|
449
|
+
userId?: string;
|
|
450
|
+
}): Promise<any>;
|
|
451
|
+
/**
|
|
452
|
+
* Performs Passkey authentication (navigator.credentials.get)
|
|
453
|
+
*/
|
|
454
|
+
signIn(): Promise<void>;
|
|
455
|
+
signOut(): void;
|
|
456
|
+
getAccessToken(): Promise<string | null>;
|
|
457
|
+
getUserInfo(): Promise<any>;
|
|
458
|
+
getAssertion(): PasskeyAssertionResult | null;
|
|
459
|
+
}
|
|
460
|
+
|
|
162
461
|
/**
|
|
163
462
|
* OAuth 2.0 PKCE (Proof Key for Code Exchange) utilities
|
|
164
463
|
* Compatible with modern browser Web Crypto API.
|
|
@@ -197,14 +496,53 @@ declare function parseOAuthCallback(urlOrSearch?: string): {
|
|
|
197
496
|
token?: string;
|
|
198
497
|
};
|
|
199
498
|
|
|
499
|
+
declare const identityProviders: {
|
|
500
|
+
world: typeof WorldAuthProvider;
|
|
501
|
+
passkey: typeof PasskeyAuthProvider;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
type ProviderCategory = 'social' | 'developer' | 'web3' | 'identity';
|
|
505
|
+
/**
|
|
506
|
+
* Unified Flat Providers Map
|
|
507
|
+
*/
|
|
200
508
|
declare const providers: {
|
|
201
509
|
google: typeof GoogleAuthProvider;
|
|
510
|
+
apple: typeof AppleAuthProvider;
|
|
511
|
+
meta: typeof MetaAuthProvider;
|
|
512
|
+
facebook: typeof MetaAuthProvider;
|
|
202
513
|
kakao: typeof KakaoAuthProvider;
|
|
203
514
|
naver: typeof NaverAuthProvider;
|
|
515
|
+
line: typeof LineAuthProvider;
|
|
516
|
+
github: typeof GithubAuthProvider;
|
|
517
|
+
discord: typeof DiscordAuthProvider;
|
|
204
518
|
web3: typeof Web3AuthProvider;
|
|
519
|
+
world: typeof WorldAuthProvider;
|
|
520
|
+
passkey: typeof PasskeyAuthProvider;
|
|
205
521
|
none: null;
|
|
206
522
|
};
|
|
207
523
|
type ProviderType = keyof typeof providers;
|
|
524
|
+
/**
|
|
525
|
+
* Returns the category of a provider
|
|
526
|
+
*/
|
|
527
|
+
declare const getProviderCategory: (provider: ProviderType) => ProviderCategory | null;
|
|
528
|
+
/**
|
|
529
|
+
* Returns all providers belonging to a specific category
|
|
530
|
+
*/
|
|
531
|
+
declare const getProvidersByCategory: (category: ProviderCategory) => {};
|
|
532
|
+
|
|
533
|
+
declare class AuthBaseService {
|
|
534
|
+
constructor();
|
|
535
|
+
initStore(prevState?: boolean): void;
|
|
536
|
+
getAuthState(): boolean;
|
|
537
|
+
isAuthenticated(): boolean;
|
|
538
|
+
setAuthState(value: boolean): void;
|
|
539
|
+
getAuthInfo<T = any>(): T | null;
|
|
540
|
+
setAuthInfo(value: any): void;
|
|
541
|
+
updateAuthInfo<T = any>(partial: Partial<T>): T;
|
|
542
|
+
watchAuthState(callback: (auth: boolean) => void): () => void;
|
|
543
|
+
watchAuthInfo<T = any>(callback: (info: T | null) => void): () => void;
|
|
544
|
+
clearAuthState(): void;
|
|
545
|
+
}
|
|
208
546
|
|
|
209
547
|
/**
|
|
210
548
|
* Browser-friendly JWT utilities (No Node.js dependencies)
|
|
@@ -258,42 +596,256 @@ declare function getTokenPayload<T = JwtPayload>(token: string): T | null;
|
|
|
258
596
|
*/
|
|
259
597
|
declare function getTokenFromHeader(header: string): string | null;
|
|
260
598
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
599
|
+
/**
|
|
600
|
+
* Role-Based Access Control (RBAC) and Permission Guards
|
|
601
|
+
* Supports wildcards, role hierarchy, custom predicates, and lifecycle callbacks.
|
|
602
|
+
*/
|
|
603
|
+
type MatchMode = 'any' | 'all';
|
|
604
|
+
type GuardFailureReason = 'UNAUTHENTICATED' | 'INSUFFICIENT_ROLES' | 'INSUFFICIENT_PERMISSIONS' | 'CUSTOM_VALIDATION_FAILED';
|
|
605
|
+
interface GuardResult {
|
|
606
|
+
allowed: boolean;
|
|
607
|
+
reason?: GuardFailureReason;
|
|
608
|
+
message?: string;
|
|
609
|
+
missingRoles?: string[];
|
|
610
|
+
missingPermissions?: string[];
|
|
611
|
+
}
|
|
612
|
+
interface AuthContext {
|
|
613
|
+
isAuthenticated: boolean;
|
|
614
|
+
roles?: string[];
|
|
615
|
+
permissions?: string[];
|
|
616
|
+
user?: any;
|
|
617
|
+
[key: string]: any;
|
|
618
|
+
}
|
|
619
|
+
type RoleHierarchyMap = Record<string, string[]>;
|
|
620
|
+
interface AuthGuardOptions {
|
|
621
|
+
/**
|
|
622
|
+
* Whether authentication is strictly required
|
|
623
|
+
* @default true
|
|
624
|
+
*/
|
|
625
|
+
requireAuth?: boolean;
|
|
626
|
+
/**
|
|
627
|
+
* Allowed roles (e.g. ['ADMIN', 'MANAGER'])
|
|
628
|
+
*/
|
|
629
|
+
roles?: string | string[];
|
|
630
|
+
/**
|
|
631
|
+
* Role match strategy ('any' = match at least one, 'all' = match all)
|
|
632
|
+
* @default 'any'
|
|
633
|
+
*/
|
|
634
|
+
roleMatch?: MatchMode;
|
|
635
|
+
/**
|
|
636
|
+
* Optional role hierarchy mapping (e.g. { ADMIN: ['MANAGER', 'USER'] })
|
|
637
|
+
*/
|
|
638
|
+
roleHierarchy?: RoleHierarchyMap;
|
|
639
|
+
/**
|
|
640
|
+
* Required permissions (e.g. ['read:users', 'write:*'])
|
|
641
|
+
*/
|
|
642
|
+
permissions?: string | string[];
|
|
643
|
+
/**
|
|
644
|
+
* Permission match strategy ('any' = match at least one, 'all' = match all)
|
|
645
|
+
* @default 'all'
|
|
646
|
+
*/
|
|
647
|
+
permissionMatch?: MatchMode;
|
|
648
|
+
/**
|
|
649
|
+
* Custom validation predicate for attribute-based or contextual checks (ABAC)
|
|
650
|
+
*/
|
|
651
|
+
validate?: (context: AuthContext) => boolean | Promise<boolean>;
|
|
652
|
+
/**
|
|
653
|
+
* Target resource or route identifier for telemetry/logging
|
|
654
|
+
*/
|
|
655
|
+
target?: string;
|
|
656
|
+
/**
|
|
657
|
+
* Callback when authentication check fails (not logged in)
|
|
658
|
+
*/
|
|
659
|
+
onUnauthenticated?: (context: AuthContext) => void | Promise<void>;
|
|
660
|
+
/**
|
|
661
|
+
* Callback when authorization check fails (insufficient roles/permissions/validation)
|
|
662
|
+
*/
|
|
663
|
+
onUnauthorized?: (reason: string, context: AuthContext, result?: GuardResult) => void | Promise<void>;
|
|
664
|
+
/**
|
|
665
|
+
* Callback specifically when roles or permissions are missing (403 Forbidden scenario)
|
|
666
|
+
*/
|
|
667
|
+
onForbidden?: (missing: {
|
|
668
|
+
roles?: string[];
|
|
669
|
+
permissions?: string[];
|
|
670
|
+
}, context: AuthContext) => void | Promise<void>;
|
|
671
|
+
/**
|
|
672
|
+
* Callback when authorization check succeeds
|
|
673
|
+
*/
|
|
674
|
+
onSuccess?: (context: AuthContext) => void | Promise<void>;
|
|
675
|
+
/**
|
|
676
|
+
* Global evaluation callback triggered on every guard check
|
|
677
|
+
*/
|
|
678
|
+
onEvaluate?: (result: GuardResult, context: AuthContext) => void | Promise<void>;
|
|
270
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* Resolves all inherited roles given a user's direct roles and a hierarchy map.
|
|
682
|
+
*/
|
|
683
|
+
declare function resolveInheritedRoles(userRoles?: string[], hierarchy?: RoleHierarchyMap): string[];
|
|
684
|
+
/**
|
|
685
|
+
* Checks if a user permission satisfies a required permission pattern.
|
|
686
|
+
* Supports wildcards:
|
|
687
|
+
* - '*' matches everything (superuser)
|
|
688
|
+
* - 'users:*' matches 'users:read', 'users:create'
|
|
689
|
+
* - '*:read' matches 'posts:read', 'users:read'
|
|
690
|
+
*/
|
|
691
|
+
declare function matchPermissionRule(pattern: string, userPerm: string): boolean;
|
|
692
|
+
/**
|
|
693
|
+
* Checks if user has required role(s).
|
|
694
|
+
*/
|
|
695
|
+
declare function checkRole(required: string | string[], userRoles?: string[], matchAll?: boolean, hierarchy?: RoleHierarchyMap): boolean;
|
|
696
|
+
/**
|
|
697
|
+
* Checks if user has required permission(s), supporting wildcards.
|
|
698
|
+
*/
|
|
699
|
+
declare function checkPermission(required: string | string[], userPermissions?: string[], matchAll?: boolean): boolean;
|
|
700
|
+
/**
|
|
701
|
+
* Evaluates guard rules against context and returns detailed GuardResult.
|
|
702
|
+
*/
|
|
703
|
+
declare function evaluateGuard(options: AuthGuardOptions, context: AuthContext): Promise<GuardResult>;
|
|
704
|
+
/**
|
|
705
|
+
* Creates a reusable route/navigation guard with callbacks and detailed evaluation.
|
|
706
|
+
*/
|
|
707
|
+
declare function createAuthGuard(options: AuthGuardOptions): (context: AuthContext) => Promise<boolean>;
|
|
708
|
+
/**
|
|
709
|
+
* Router / Navigation Guard Helper
|
|
710
|
+
* Compatible with Vue Router, React Router loader, SvelteKit, etc.
|
|
711
|
+
*/
|
|
712
|
+
declare function createNavigationGuard(options: AuthGuardOptions & {
|
|
713
|
+
getContext: () => AuthContext | Promise<AuthContext>;
|
|
714
|
+
redirectToOnUnauthenticated?: string;
|
|
715
|
+
redirectToOnUnauthorized?: string;
|
|
716
|
+
onRedirect?: (url: string) => void;
|
|
717
|
+
}): () => Promise<{
|
|
718
|
+
allowed: boolean;
|
|
719
|
+
redirect?: string;
|
|
720
|
+
}>;
|
|
271
721
|
|
|
722
|
+
interface AutoRefreshOptions {
|
|
723
|
+
/**
|
|
724
|
+
* Seconds before actual expiration to trigger refresh
|
|
725
|
+
* @default 60
|
|
726
|
+
*/
|
|
727
|
+
leadTimeSeconds?: number;
|
|
728
|
+
/**
|
|
729
|
+
* Whether to trigger refresh immediately if token is missing or already expired
|
|
730
|
+
* @default true
|
|
731
|
+
*/
|
|
732
|
+
immediateIfExpired?: boolean;
|
|
733
|
+
/**
|
|
734
|
+
* Callback when auto refresh succeeds
|
|
735
|
+
*/
|
|
736
|
+
onSuccess?: (newToken: string) => void;
|
|
737
|
+
/**
|
|
738
|
+
* Callback when auto refresh fails
|
|
739
|
+
*/
|
|
740
|
+
onError?: (error: any) => void;
|
|
741
|
+
}
|
|
272
742
|
declare class JwtService extends AuthBaseService {
|
|
743
|
+
private inFlightRefreshPromise;
|
|
744
|
+
private autoRefreshTimer;
|
|
745
|
+
private autoRefreshFn;
|
|
746
|
+
private autoRefreshOptions;
|
|
273
747
|
constructor(secretKey?: string);
|
|
274
|
-
|
|
748
|
+
private validatePersistedSession;
|
|
275
749
|
configureJwt(secretKey: string): void;
|
|
276
|
-
getAuthState(): boolean;
|
|
277
|
-
setAuthState(value: boolean): void;
|
|
278
|
-
getAuthInfo<T = any>(): T | null;
|
|
279
|
-
setAuthInfo(value: any): void;
|
|
280
|
-
watchAuthState<T extends HTMLElement>(callback: (auth: boolean) => void): void | (() => void);
|
|
281
|
-
clearAuthState(): void;
|
|
282
750
|
getAccessToken(): string | null;
|
|
283
|
-
setAccessToken(value: string): void;
|
|
751
|
+
setAccessToken(value: string | null): void;
|
|
752
|
+
getRefreshToken(): string | null;
|
|
753
|
+
setRefreshToken(token: string | null): void;
|
|
284
754
|
isValidAccessToken(): boolean;
|
|
285
755
|
isExpiredAccessToken(): boolean;
|
|
286
756
|
getTimeRemaining(): number;
|
|
287
757
|
getAccessTokenPayload<T = JwtPayload>(): T | null;
|
|
288
758
|
setAccessTokenFromHeader(header: string): void;
|
|
289
|
-
hasRole(role: string): boolean;
|
|
290
|
-
hasPermission(permission: string): boolean;
|
|
759
|
+
hasRole(role: string | string[], matchAll?: boolean, hierarchy?: RoleHierarchyMap): boolean;
|
|
760
|
+
hasPermission(permission: string | string[], matchAll?: boolean): boolean;
|
|
761
|
+
can(permission: string | string[], matchAll?: boolean): boolean;
|
|
762
|
+
is(role: string | string[], matchAll?: boolean, hierarchy?: RoleHierarchyMap): boolean;
|
|
763
|
+
/**
|
|
764
|
+
* Refreshes access token with in-flight deduplication (Mutex)
|
|
765
|
+
*/
|
|
291
766
|
refreshToken(refreshTokenFn: () => Promise<string>): Promise<string | null>;
|
|
767
|
+
/**
|
|
768
|
+
* Starts automatic background token refresh prior to expiration
|
|
769
|
+
*/
|
|
770
|
+
startAutoRefresh(refreshFn: () => Promise<string>, options?: AutoRefreshOptions): void;
|
|
771
|
+
/**
|
|
772
|
+
* Stops automatic token refresh scheduler
|
|
773
|
+
*/
|
|
774
|
+
stopAutoRefresh(): void;
|
|
775
|
+
private scheduleNextAutoRefresh;
|
|
776
|
+
clearAuthState(): void;
|
|
292
777
|
}
|
|
293
778
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
779
|
+
/**
|
|
780
|
+
* Token Exchange Adapter
|
|
781
|
+
* Standardized interface and HTTP implementation for exchanging OAuth codes,
|
|
782
|
+
* World ID proofs, Passkey assertions, and Web3 signatures with backend APIs.
|
|
783
|
+
*/
|
|
784
|
+
interface TokenExchangeResult {
|
|
785
|
+
accessToken: string;
|
|
786
|
+
refreshToken?: string;
|
|
787
|
+
expiresIn?: number;
|
|
788
|
+
tokenType?: string;
|
|
789
|
+
user?: any;
|
|
790
|
+
raw?: any;
|
|
791
|
+
}
|
|
792
|
+
interface TokenExchangeAdapter {
|
|
793
|
+
exchangeOAuthCode(provider: string, code: string, options?: {
|
|
794
|
+
redirectUri?: string;
|
|
795
|
+
state?: string;
|
|
796
|
+
codeVerifier?: string;
|
|
797
|
+
}): Promise<TokenExchangeResult>;
|
|
798
|
+
exchangeWorldProof?(proofResult: any, options?: {
|
|
799
|
+
action?: string;
|
|
800
|
+
signal?: string;
|
|
801
|
+
}): Promise<TokenExchangeResult>;
|
|
802
|
+
exchangePasskeyAssertion?(assertion: any, options?: {
|
|
803
|
+
challenge?: string;
|
|
804
|
+
}): Promise<TokenExchangeResult>;
|
|
805
|
+
exchangeWeb3Signature?(signatureResult: {
|
|
806
|
+
address: string;
|
|
807
|
+
signature: string;
|
|
808
|
+
message: string;
|
|
809
|
+
chainId: number;
|
|
810
|
+
}): Promise<TokenExchangeResult>;
|
|
811
|
+
}
|
|
812
|
+
interface HttpTokenExchangeOptions {
|
|
813
|
+
tokenEndpoint: string;
|
|
814
|
+
headers?: Record<string, string>;
|
|
815
|
+
credentials?: RequestCredentials;
|
|
816
|
+
customBodyFormatter?: (type: string, payload: any) => any;
|
|
817
|
+
fetchFn?: typeof fetch;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Standard HTTP-based Token Exchange Adapter
|
|
821
|
+
*/
|
|
822
|
+
declare class HttpTokenExchangeAdapter implements TokenExchangeAdapter {
|
|
823
|
+
private endpoint;
|
|
824
|
+
private headers;
|
|
825
|
+
private credentials;
|
|
826
|
+
private customBodyFormatter?;
|
|
827
|
+
private fetchFn;
|
|
828
|
+
constructor(options: HttpTokenExchangeOptions);
|
|
829
|
+
private postExchange;
|
|
830
|
+
exchangeOAuthCode(provider: string, code: string, options?: {
|
|
831
|
+
redirectUri?: string;
|
|
832
|
+
state?: string;
|
|
833
|
+
codeVerifier?: string;
|
|
834
|
+
}): Promise<TokenExchangeResult>;
|
|
835
|
+
exchangeWorldProof(proofResult: any, options?: {
|
|
836
|
+
action?: string;
|
|
837
|
+
signal?: string;
|
|
838
|
+
}): Promise<TokenExchangeResult>;
|
|
839
|
+
exchangePasskeyAssertion(assertion: any, options?: {
|
|
840
|
+
challenge?: string;
|
|
841
|
+
}): Promise<TokenExchangeResult>;
|
|
842
|
+
exchangeWeb3Signature(signatureResult: {
|
|
843
|
+
address: string;
|
|
844
|
+
signature: string;
|
|
845
|
+
message: string;
|
|
846
|
+
chainId: number;
|
|
847
|
+
}): Promise<TokenExchangeResult>;
|
|
848
|
+
}
|
|
297
849
|
|
|
298
850
|
declare const AuthService: {
|
|
299
851
|
base: typeof AuthBaseService;
|
|
@@ -301,13 +853,38 @@ declare const AuthService: {
|
|
|
301
853
|
};
|
|
302
854
|
type AuthServiceType = keyof typeof AuthService;
|
|
303
855
|
|
|
856
|
+
declare function addAuthEventListener(callback: (detail: any) => void, target?: EventTarget): () => void;
|
|
857
|
+
declare function removeAuthEventListener(callback: (detail: any) => void, target?: EventTarget): void;
|
|
858
|
+
declare function dispatchAuthEvent(eventNameOrDetail: string | any, detailOrTarget?: any, optionalTarget?: EventTarget): void;
|
|
859
|
+
|
|
304
860
|
type CoreProviderType = Exclude<ProviderType | AuthServiceType, 'none'>;
|
|
305
861
|
|
|
306
862
|
/**
|
|
307
|
-
* Authentication Lifecycle Event & Hook System
|
|
863
|
+
* Authentication & Authorization Lifecycle Event & Hook System
|
|
308
864
|
*/
|
|
309
|
-
type AuthLifecycleEvent = 'signIn' | 'signOut' | 'tokenExpired' | 'tokenRefreshed' | 'error';
|
|
865
|
+
type AuthLifecycleEvent = 'signIn' | 'signOut' | 'tokenExpired' | 'tokenRefreshed' | 'error' | 'unauthorized' | 'accessDenied' | 'roleChanged' | 'permissionChanged';
|
|
310
866
|
type LifecycleListener<T = any> = (data?: T) => void | Promise<void>;
|
|
867
|
+
interface UnauthorizedEventData {
|
|
868
|
+
reason: string;
|
|
869
|
+
result?: any;
|
|
870
|
+
context?: any;
|
|
871
|
+
timestamp?: number;
|
|
872
|
+
}
|
|
873
|
+
interface AccessDeniedEventData {
|
|
874
|
+
reason: string;
|
|
875
|
+
result?: any;
|
|
876
|
+
context?: any;
|
|
877
|
+
target?: string;
|
|
878
|
+
timestamp?: number;
|
|
879
|
+
}
|
|
880
|
+
interface RoleChangedEventData {
|
|
881
|
+
roles: string[];
|
|
882
|
+
previousRoles?: string[];
|
|
883
|
+
}
|
|
884
|
+
interface PermissionChangedEventData {
|
|
885
|
+
permissions: string[];
|
|
886
|
+
previousPermissions?: string[];
|
|
887
|
+
}
|
|
311
888
|
declare class AuthLifecycleManager {
|
|
312
889
|
private listeners;
|
|
313
890
|
on(event: AuthLifecycleEvent, listener: LifecycleListener): () => void;
|
|
@@ -324,66 +901,74 @@ declare class AuthLifecycleManager {
|
|
|
324
901
|
error: any;
|
|
325
902
|
phase?: string;
|
|
326
903
|
}>): () => void;
|
|
327
|
-
emit(event: AuthLifecycleEvent, data?: any): Promise<void>;
|
|
328
|
-
clear(): void;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Role-Based Access Control (RBAC) and Permission Guards
|
|
333
|
-
*/
|
|
334
|
-
interface AuthGuardOptions {
|
|
335
|
-
/**
|
|
336
|
-
* Whether authentication is strictly required
|
|
337
|
-
* @default true
|
|
338
|
-
*/
|
|
339
|
-
requireAuth?: boolean;
|
|
340
904
|
/**
|
|
341
|
-
*
|
|
905
|
+
* Called when authentication or authorization check fails
|
|
342
906
|
*/
|
|
343
|
-
|
|
907
|
+
onUnauthorized(listener: LifecycleListener<UnauthorizedEventData>): () => void;
|
|
344
908
|
/**
|
|
345
|
-
*
|
|
909
|
+
* Called when access to a resource/route is denied by an auth guard
|
|
346
910
|
*/
|
|
347
|
-
|
|
911
|
+
onAccessDenied(listener: LifecycleListener<AccessDeniedEventData>): () => void;
|
|
348
912
|
/**
|
|
349
|
-
*
|
|
913
|
+
* Called when the active user's roles change
|
|
350
914
|
*/
|
|
351
|
-
|
|
915
|
+
onRoleChanged(listener: LifecycleListener<RoleChangedEventData>): () => void;
|
|
352
916
|
/**
|
|
353
|
-
*
|
|
917
|
+
* Called when the active user's permissions change
|
|
354
918
|
*/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
isAuthenticated: boolean;
|
|
359
|
-
roles?: string[];
|
|
360
|
-
permissions?: string[];
|
|
919
|
+
onPermissionChanged(listener: LifecycleListener<PermissionChangedEventData>): () => void;
|
|
920
|
+
emit(event: AuthLifecycleEvent, data?: any): Promise<void>;
|
|
921
|
+
clear(): void;
|
|
361
922
|
}
|
|
362
|
-
/**
|
|
363
|
-
* Creates a reusable route/navigation guard
|
|
364
|
-
*/
|
|
365
|
-
declare function createAuthGuard(options: AuthGuardOptions): (context: AuthContext) => Promise<boolean>;
|
|
366
923
|
|
|
367
924
|
/**
|
|
368
925
|
* HTTP Client utilities with automatic Authorization header injection and 401 retry
|
|
926
|
+
* Supports both Fetch API (createAuthFetch) and Axios (applyAuthInterceptor / createAuthAxios)
|
|
369
927
|
*/
|
|
370
928
|
interface AuthClientInterface {
|
|
371
929
|
getAccessToken(): string | null;
|
|
372
930
|
refreshToken?(refreshFn?: () => Promise<string>): Promise<string | null>;
|
|
373
931
|
clearAuthState?(): void;
|
|
374
932
|
}
|
|
375
|
-
interface
|
|
933
|
+
interface AuthHttpOptions {
|
|
376
934
|
authClient: AuthClientInterface;
|
|
377
935
|
refreshFn?: () => Promise<string>;
|
|
378
936
|
baseUrl?: string;
|
|
379
937
|
onUnauthorized?: () => void;
|
|
380
938
|
headerName?: string;
|
|
381
939
|
tokenPrefix?: string;
|
|
940
|
+
withCredentials?: boolean;
|
|
941
|
+
beforeRequest?: (config: any) => any | Promise<any>;
|
|
942
|
+
afterResponse?: (response: any) => any | Promise<any>;
|
|
943
|
+
}
|
|
944
|
+
interface AuthFetchOptions extends AuthHttpOptions {
|
|
945
|
+
customFetch?: typeof fetch;
|
|
382
946
|
}
|
|
383
947
|
/**
|
|
384
948
|
* Creates an authenticated fetch wrapper that injects Bearer token and automatically retries upon 401.
|
|
385
949
|
*/
|
|
386
950
|
declare function createAuthFetch(options: AuthFetchOptions): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
951
|
+
/**
|
|
952
|
+
* Applies authorization interceptor and automatic 401 token refresh retry to an Axios instance.
|
|
953
|
+
*/
|
|
954
|
+
declare function applyAuthInterceptor(axiosInstance: any, options: AuthHttpOptions): {
|
|
955
|
+
eject: () => void;
|
|
956
|
+
};
|
|
957
|
+
/**
|
|
958
|
+
* Helper to create or wrap an Axios instance with auth interceptors.
|
|
959
|
+
*/
|
|
960
|
+
declare function createAuthAxios(axiosModuleOrInstance: any, options: AuthHttpOptions): any;
|
|
961
|
+
|
|
962
|
+
type Selector<T, R> = (state: T) => R;
|
|
963
|
+
type EqualityFn<T> = (a: T, b: T) => boolean;
|
|
964
|
+
/**
|
|
965
|
+
* 상태 객체의 특정 슬라이스나 계산값만 구독하는 셀렉터 구독자
|
|
966
|
+
*/
|
|
967
|
+
declare function subscribeSelector<T = any, R = any>(id: string, selector: Selector<T, R>, listener: (slice: R, prevSlice?: R) => void, equalityFn?: EqualityFn<R>): () => void;
|
|
968
|
+
/**
|
|
969
|
+
* 여러 상태 변경을 하나의 틱으로 묶어주는 배치 함수
|
|
970
|
+
*/
|
|
971
|
+
declare function batch(fn: () => void): void;
|
|
387
972
|
|
|
388
973
|
/**
|
|
389
974
|
* Storage adapter interface and implementations for persistence
|
|
@@ -392,35 +977,113 @@ interface StorageAdapter {
|
|
|
392
977
|
getItem(key: string): string | null;
|
|
393
978
|
setItem(key: string, value: string): void;
|
|
394
979
|
removeItem(key: string): void;
|
|
980
|
+
clear?(): void;
|
|
981
|
+
keys?(): string[];
|
|
982
|
+
}
|
|
983
|
+
declare class MemoryStorageAdapter implements StorageAdapter {
|
|
984
|
+
private cache;
|
|
985
|
+
getItem(key: string): string | null;
|
|
986
|
+
setItem(key: string, value: string): void;
|
|
987
|
+
removeItem(key: string): void;
|
|
988
|
+
clear(): void;
|
|
989
|
+
keys(): string[];
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* @deprecated ⚠️ SECURITY WARNING:
|
|
993
|
+
* Storing authentication tokens in LocalStorage exposes the application to XSS (Cross-Site Scripting) token theft.
|
|
994
|
+
* DO NOT USE FOR PRODUCTION!
|
|
995
|
+
* For development/prototyping, use 'dev_insecure_localStorage'.
|
|
996
|
+
* For production, use 'memory' (with silent refresh) or 'cookie' (BFF HttpOnly mode).
|
|
997
|
+
*/
|
|
998
|
+
declare class LocalStorageAdapter implements StorageAdapter {
|
|
999
|
+
getItem(key: string): string | null;
|
|
1000
|
+
setItem(key: string, value: string): void;
|
|
1001
|
+
removeItem(key: string): void;
|
|
1002
|
+
clear(): void;
|
|
1003
|
+
keys(): string[];
|
|
1004
|
+
}
|
|
1005
|
+
declare class SessionStorageAdapter implements StorageAdapter {
|
|
1006
|
+
getItem(key: string): string | null;
|
|
1007
|
+
setItem(key: string, value: string): void;
|
|
1008
|
+
removeItem(key: string): void;
|
|
1009
|
+
clear(): void;
|
|
1010
|
+
keys(): string[];
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Cookie / Hybrid Session Storage Adapter
|
|
1014
|
+
* Designed for BFF / Server-Side HttpOnly cookie setups.
|
|
1015
|
+
* Does NOT persist raw JWT/tokens to local storage (relies on browser cookie jar and withCredentials).
|
|
1016
|
+
* Only non-sensitive session metadata (user profile, roles) may optionally be cached in memory.
|
|
1017
|
+
*/
|
|
1018
|
+
declare class CookieSessionStorageAdapter implements StorageAdapter {
|
|
1019
|
+
private memoryCache;
|
|
1020
|
+
private persistUserInfo;
|
|
1021
|
+
constructor(options?: {
|
|
1022
|
+
persistUserInfo?: boolean;
|
|
1023
|
+
});
|
|
1024
|
+
getItem(key: string): string | null;
|
|
1025
|
+
setItem(key: string, value: string): void;
|
|
1026
|
+
removeItem(key: string): void;
|
|
1027
|
+
clear(): void;
|
|
1028
|
+
keys(): string[];
|
|
395
1029
|
}
|
|
396
1030
|
|
|
397
|
-
type StorageType = '
|
|
398
|
-
|
|
1031
|
+
type StorageType = 'memory' | 'cookie' | 'hybrid' | 'sessionStorage' | 'dev_insecure_localStorage' | 'insecure_localStorage' | 'localStorage';
|
|
1032
|
+
interface StorageConfig {
|
|
1033
|
+
type?: StorageType | StorageAdapter;
|
|
1034
|
+
prefix?: string;
|
|
1035
|
+
persistUserInfo?: boolean;
|
|
1036
|
+
}
|
|
1037
|
+
declare function configureStorage(config: StorageType | StorageAdapter | StorageConfig): void;
|
|
1038
|
+
declare function getStorageAdapter(): StorageAdapter;
|
|
399
1039
|
declare function getAuthState(): boolean;
|
|
400
1040
|
declare function getAccessToken(): string | null;
|
|
1041
|
+
declare function getRefreshToken(): string | null;
|
|
1042
|
+
declare function setRefreshToken(value: string | null): void;
|
|
401
1043
|
declare function getAuthInfo<T = any>(): T | null;
|
|
1044
|
+
/**
|
|
1045
|
+
* Partially updates authInfo (shallow merge)
|
|
1046
|
+
*/
|
|
1047
|
+
declare function updateAuthInfo<T = any>(partial: Partial<T>): T & Partial<T>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Clears entire authentication session atomically
|
|
1050
|
+
*/
|
|
1051
|
+
declare function clearStoreSession(): void;
|
|
402
1052
|
|
|
403
1053
|
interface AuthCoreProps {
|
|
404
1054
|
providerType?: CoreProviderType;
|
|
405
1055
|
secret?: string;
|
|
406
1056
|
storage?: StorageType;
|
|
1057
|
+
storagePrefix?: string;
|
|
407
1058
|
}
|
|
408
1059
|
declare class AuthCore {
|
|
409
1060
|
private provider;
|
|
410
1061
|
private button;
|
|
411
1062
|
private serviceInstance;
|
|
412
1063
|
lifecycle: AuthLifecycleManager;
|
|
413
|
-
constructor({ providerType, secret, storage, }?: AuthCoreProps);
|
|
1064
|
+
constructor({ providerType, secret, storage, storagePrefix, }?: AuthCoreProps);
|
|
414
1065
|
getService(): AuthBaseService | JwtService;
|
|
415
|
-
getProvider(): typeof GoogleAuthProvider | typeof KakaoAuthProvider | typeof NaverAuthProvider | typeof Web3AuthProvider | null;
|
|
1066
|
+
getProvider(): typeof GoogleAuthProvider | typeof AppleAuthProvider | typeof MetaAuthProvider | typeof KakaoAuthProvider | typeof NaverAuthProvider | typeof LineAuthProvider | typeof GithubAuthProvider | typeof DiscordAuthProvider | typeof Web3AuthProvider | typeof WorldAuthProvider | typeof PasskeyAuthProvider | null;
|
|
416
1067
|
getButton(): LoginButton | null;
|
|
1068
|
+
getContext(): AuthContext;
|
|
1069
|
+
updateAuthInfo<T = any>(partial: Partial<T>): T;
|
|
1070
|
+
startAutoRefresh(refreshFn: () => Promise<string>, options?: AutoRefreshOptions): void;
|
|
1071
|
+
stopAutoRefresh(): void;
|
|
1072
|
+
evaluateGuard(options: AuthGuardOptions, customContext?: Partial<AuthContext>): Promise<GuardResult>;
|
|
417
1073
|
createGuard(options: AuthGuardOptions): Promise<boolean>;
|
|
1074
|
+
hasRole(role: string | string[], matchAll?: boolean): boolean;
|
|
1075
|
+
hasPermission(permission: string | string[], matchAll?: boolean): boolean;
|
|
418
1076
|
createFetch(options?: Partial<AuthFetchOptions>): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
1077
|
+
applyAxiosInterceptor(axiosInstance: any, options?: Partial<AuthHttpOptions>): {
|
|
1078
|
+
eject: () => void;
|
|
1079
|
+
};
|
|
1080
|
+
createAxios(axiosModuleOrInstance: any, options?: Partial<AuthHttpOptions>): any;
|
|
1081
|
+
createTokenExchange(tokenEndpoint: string, options?: Omit<HttpTokenExchangeOptions, 'tokenEndpoint'>): HttpTokenExchangeAdapter;
|
|
419
1082
|
getWebComponentAPI(): {
|
|
420
1083
|
addAuthEventListener: typeof addAuthEventListener;
|
|
421
1084
|
removeAuthEventListener: typeof removeAuthEventListener;
|
|
422
1085
|
dispatchAuthEvent: typeof dispatchAuthEvent;
|
|
423
|
-
watchAuthState: (
|
|
1086
|
+
watchAuthState: ((callback: (auth: boolean) => void) => () => void) | ((callback: (auth: boolean) => void) => () => void);
|
|
424
1087
|
};
|
|
425
1088
|
}
|
|
426
1089
|
|
|
@@ -1066,7 +1729,8 @@ interface IsaAuthConfig {
|
|
|
1066
1729
|
clientId?: string;
|
|
1067
1730
|
callbackUrl?: string;
|
|
1068
1731
|
scope?: string;
|
|
1069
|
-
storage?:
|
|
1732
|
+
storage?: StorageType;
|
|
1733
|
+
storagePrefix?: string;
|
|
1070
1734
|
extraOptions?: Record<string, any>;
|
|
1071
1735
|
}
|
|
1072
1736
|
/**
|
|
@@ -1076,14 +1740,31 @@ declare class IsaAuth {
|
|
|
1076
1740
|
core: AuthCore;
|
|
1077
1741
|
providerInstance: any;
|
|
1078
1742
|
authProvider: AuthProvider;
|
|
1743
|
+
providerType: CoreProviderType;
|
|
1079
1744
|
constructor(config?: IsaAuthConfig);
|
|
1080
1745
|
isAuthenticated(): boolean;
|
|
1081
1746
|
getAccessToken(): string | null;
|
|
1082
1747
|
getUserInfo(): Promise<any>;
|
|
1748
|
+
getContext(): AuthContext;
|
|
1749
|
+
/**
|
|
1750
|
+
* Returns current provider category ('social' | 'developer' | 'web3' | 'identity' | null)
|
|
1751
|
+
*/
|
|
1752
|
+
getCategory(): ProviderCategory | null;
|
|
1083
1753
|
setAccessToken(token: string): void;
|
|
1754
|
+
getRefreshToken(): string | null;
|
|
1755
|
+
setRefreshToken(token: string): void;
|
|
1756
|
+
updateAuthInfo<T = any>(partial: Partial<T>): T;
|
|
1084
1757
|
signIn(): Promise<void>;
|
|
1085
1758
|
signOut(): void;
|
|
1086
1759
|
refresh(refreshFn: () => Promise<string>): Promise<string>;
|
|
1760
|
+
/**
|
|
1761
|
+
* Starts automatic background token refresh prior to expiration
|
|
1762
|
+
*/
|
|
1763
|
+
startAutoRefresh(refreshFn: () => Promise<string>, options?: any): void;
|
|
1764
|
+
/**
|
|
1765
|
+
* Stops automatic background token refresh
|
|
1766
|
+
*/
|
|
1767
|
+
stopAutoRefresh(): void;
|
|
1087
1768
|
getButton(): {
|
|
1088
1769
|
className: string;
|
|
1089
1770
|
onClick: () => Promise<void>;
|
|
@@ -1098,12 +1779,60 @@ declare class IsaAuth {
|
|
|
1098
1779
|
renderButton(container?: HTMLElement | null): HTMLButtonElement | null;
|
|
1099
1780
|
hasRole(role: string): boolean;
|
|
1100
1781
|
hasPermission(permission: string): boolean;
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1782
|
+
/**
|
|
1783
|
+
* Check permission with wildcard matching support
|
|
1784
|
+
* E.g. isaAuth.can('users:read') or isaAuth.can(['users:read', 'users:write'])
|
|
1785
|
+
*/
|
|
1786
|
+
can(permission: string | string[], matchAll?: boolean): boolean;
|
|
1787
|
+
/**
|
|
1788
|
+
* Check role with optional matchAll option
|
|
1789
|
+
*/
|
|
1790
|
+
is(role: string | string[], matchAll?: boolean): boolean;
|
|
1791
|
+
/**
|
|
1792
|
+
* Evaluates guard and returns detailed GuardResult
|
|
1793
|
+
*/
|
|
1794
|
+
evaluateGuard(options: AuthGuardOptions, customContext?: Partial<AuthContext>): Promise<GuardResult>;
|
|
1795
|
+
/**
|
|
1796
|
+
* Instant boolean guard check (backwards compatible)
|
|
1797
|
+
*/
|
|
1798
|
+
createGuard(options: AuthGuardOptions): Promise<boolean>;
|
|
1799
|
+
/**
|
|
1800
|
+
* Creates a reusable router navigation guard
|
|
1801
|
+
*/
|
|
1802
|
+
createNavigationGuard(options: AuthGuardOptions & {
|
|
1803
|
+
redirectToOnUnauthenticated?: string;
|
|
1804
|
+
redirectToOnUnauthorized?: string;
|
|
1805
|
+
onRedirect?: (url: string) => void;
|
|
1806
|
+
}): () => Promise<{
|
|
1807
|
+
allowed: boolean;
|
|
1808
|
+
redirect?: string;
|
|
1809
|
+
}>;
|
|
1810
|
+
onSignIn(listener: LifecycleListener<{
|
|
1811
|
+
user?: any;
|
|
1812
|
+
token?: string;
|
|
1813
|
+
}>): () => void;
|
|
1814
|
+
onSignOut(listener: LifecycleListener<void>): () => void;
|
|
1815
|
+
onTokenExpired(listener: LifecycleListener<void>): () => void;
|
|
1816
|
+
onUnauthorized(listener: LifecycleListener<{
|
|
1817
|
+
reason: string;
|
|
1818
|
+
result?: GuardResult;
|
|
1819
|
+
context?: AuthContext;
|
|
1820
|
+
}>): () => void;
|
|
1821
|
+
onAccessDenied(listener: LifecycleListener<{
|
|
1822
|
+
reason: string;
|
|
1823
|
+
result?: GuardResult;
|
|
1824
|
+
context?: AuthContext;
|
|
1825
|
+
target?: string;
|
|
1826
|
+
}>): () => void;
|
|
1827
|
+
onRoleChanged(listener: Parameters<AuthLifecycleManager['onRoleChanged']>[0]): () => void;
|
|
1828
|
+
onPermissionChanged(listener: Parameters<AuthLifecycleManager['onPermissionChanged']>[0]): () => void;
|
|
1829
|
+
createFetch(options?: Partial<AuthFetchOptions>): (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
1830
|
+
applyAxiosInterceptor(axiosInstance: any, options?: Partial<AuthHttpOptions>): {
|
|
1831
|
+
eject: () => void;
|
|
1832
|
+
};
|
|
1833
|
+
createAxios(axiosModuleOrInstance: any, options?: Partial<AuthHttpOptions>): any;
|
|
1834
|
+
createTokenExchange(tokenEndpoint: string, options?: any): HttpTokenExchangeAdapter;
|
|
1106
1835
|
subscribe(callback: (isAuthenticated: boolean) => void): void | (() => void);
|
|
1107
1836
|
}
|
|
1108
1837
|
|
|
1109
|
-
export { AuthCore, AuthProvider, GoogleAuthProvider, IsaAuth, type IsaAuthConfig, KakaoAuthProvider, NaverAuthProvider, Web3AuthProvider, buildAuthorizeUrl, configureStorage, createAuthFetch, createAuthGuard, decodeToken, IsaAuth as default, generateCodeChallenge, generateCodeVerifier, getAccessToken, getAuthInfo, getAuthState, getTokenFromHeader, getTokenPayload, getTokenTimeRemaining, isExpiredToken, parseOAuthCallback, index as renderers };
|
|
1838
|
+
export { AppleAuthProvider, AuthBaseService, type AuthContext, AuthCore, type AuthFetchOptions, type AuthGuardOptions, type AuthHttpOptions, AuthProvider, type AutoRefreshOptions, CookieSessionStorageAdapter, DiscordAuthProvider, FacebookAuthProvider, GithubAuthProvider, GoogleAuthProvider, type GuardFailureReason, type GuardResult, HttpTokenExchangeAdapter, IsaAuth, type IsaAuthConfig, JwtService, KakaoAuthProvider, LineAuthProvider, LocalStorageAdapter, type MatchMode, MemoryStorageAdapter, MetaAuthProvider, NaverAuthProvider, type PasskeyAssertionResult, PasskeyAuthProvider, type ProviderCategory, type RoleHierarchyMap, SessionStorageAdapter, type StorageConfig, type StorageType, type TokenExchangeAdapter, type TokenExchangeResult, Web3AuthProvider, WorldAuthProvider, type WorldIDProofResult, type WorldVerificationLevel, applyAuthInterceptor, batch, buildAuthorizeUrl, checkPermission, checkRole, clearStoreSession, configureStorage, createAuthAxios, createAuthFetch, createAuthGuard, createNavigationGuard, decodeToken, IsaAuth as default, developerProviders, evaluateGuard, generateCodeChallenge, generateCodeVerifier, getAccessToken, getAuthInfo, getAuthState, getProviderCategory, getProvidersByCategory, getRefreshToken, getStorageAdapter, getTokenFromHeader, getTokenPayload, getTokenTimeRemaining, identityProviders, isExpiredToken, matchPermissionRule, parseOAuthCallback, index as renderers, resolveInheritedRoles, setRefreshToken, socialProviders, subscribeSelector, updateAuthInfo, web3Providers };
|