@spfn/auth 0.2.0-beta.10 → 0.2.0-beta.12
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 +459 -172
- package/dist/{dto-CRlgoCP5.d.ts → authenticate-xfEpwIjH.d.ts} +284 -182
- package/dist/config.d.ts +104 -0
- package/dist/config.js +61 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +187 -130
- package/dist/index.js +24 -1
- package/dist/index.js.map +1 -1
- package/dist/nextjs/api.js +186 -0
- package/dist/nextjs/api.js.map +1 -1
- package/dist/nextjs/client.js +80 -0
- package/dist/nextjs/client.js.map +1 -0
- package/dist/nextjs/server.d.ts +68 -2
- package/dist/nextjs/server.js +125 -3
- package/dist/nextjs/server.js.map +1 -1
- package/dist/server.d.ts +243 -366
- package/dist/server.js +596 -476
- package/dist/server.js.map +1 -1
- package/package.json +11 -11
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as AuthInitOptions, l as KeyAlgorithmType, n as InvitationStatus, f as VerificationPurpose, j as PermissionCategory, q as AuthContext } from './
|
|
2
|
-
export { B as ChangePasswordParams, w as CheckAccountExistsParams, C as CheckAccountExistsResult,
|
|
1
|
+
import { k as AuthInitOptions, l as KeyAlgorithmType, n as InvitationStatus, f as VerificationPurpose, j as PermissionCategory, p as SocialProvider, q as AuthContext } from './authenticate-xfEpwIjH.js';
|
|
2
|
+
export { B as ChangePasswordParams, w as CheckAccountExistsParams, C as CheckAccountExistsResult, a4 as EmailSchema, I as INVITATION_STATUSES, K as KEY_ALGORITHM, y as LoginParams, L as LoginResult, z as LogoutParams, a1 as OAuthCallbackParams, a2 as OAuthCallbackResult, a0 as OAuthStartParams, O as OAuthStartResult, a6 as PasswordSchema, a5 as PhoneSchema, x as RegisterParams, Q as RegisterPublicKeyParams, a as RegisterResult, W as RevokeKeyParams, T as RotateKeyParams, b as RotateKeyResult, e as SOCIAL_PROVIDERS, F as SendVerificationCodeParams, S as SendVerificationCodeResult, a7 as TargetTypeSchema, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, a8 as VerificationPurposeSchema, V as VerificationTargetType, G as VerifyCodeParams, H as VerifyCodeResult, m as authRouter, a3 as authenticate, Z as buildOAuthErrorUrl, v as changePasswordService, r as checkAccountExistsService, $ as getEnabledOAuthProviders, _ as isOAuthProviderEnabled, t as loginService, u as logoutService, Y as oauthCallbackService, X as oauthStartService, J as registerPublicKeyService, s as registerService, N as revokeKeyService, M as rotateKeyService, D as sendVerificationCodeService, E as verifyCodeService } from './authenticate-xfEpwIjH.js';
|
|
3
3
|
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
|
|
4
4
|
import { UserProfile as UserProfile$1, ProfileInfo } from '@spfn/auth';
|
|
5
5
|
import { BaseRepository } from '@spfn/core/db';
|
|
@@ -1326,369 +1326,6 @@ declare function getUserProfileService(userId: string | number | bigint): Promis
|
|
|
1326
1326
|
*/
|
|
1327
1327
|
declare function updateUserProfileService(userId: string | number | bigint, params: UpdateProfileParams): Promise<ProfileInfo>;
|
|
1328
1328
|
|
|
1329
|
-
/**
|
|
1330
|
-
* @spfn/auth - Email Template Types
|
|
1331
|
-
*
|
|
1332
|
-
* Type definitions for customizable email templates
|
|
1333
|
-
*/
|
|
1334
|
-
/**
|
|
1335
|
-
* Common template result
|
|
1336
|
-
*/
|
|
1337
|
-
interface EmailTemplateResult {
|
|
1338
|
-
subject: string;
|
|
1339
|
-
text: string;
|
|
1340
|
-
html: string;
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* Verification code template parameters
|
|
1344
|
-
*/
|
|
1345
|
-
interface VerificationCodeParams {
|
|
1346
|
-
code: string;
|
|
1347
|
-
purpose: 'registration' | 'login' | 'password_reset' | string;
|
|
1348
|
-
expiresInMinutes?: number;
|
|
1349
|
-
appName?: string;
|
|
1350
|
-
}
|
|
1351
|
-
/**
|
|
1352
|
-
* Email template provider interface
|
|
1353
|
-
*
|
|
1354
|
-
* Implement this interface to create custom email templates
|
|
1355
|
-
*
|
|
1356
|
-
* @example
|
|
1357
|
-
* ```typescript
|
|
1358
|
-
* import { registerEmailTemplates } from '@spfn/auth/server';
|
|
1359
|
-
*
|
|
1360
|
-
* registerEmailTemplates({
|
|
1361
|
-
* verificationCode: (params) => ({
|
|
1362
|
-
* subject: 'Your Code',
|
|
1363
|
-
* text: `Code: ${params.code}`,
|
|
1364
|
-
* html: `<h1>Code: ${params.code}</h1>`,
|
|
1365
|
-
* }),
|
|
1366
|
-
* });
|
|
1367
|
-
* ```
|
|
1368
|
-
*/
|
|
1369
|
-
interface EmailTemplateProvider {
|
|
1370
|
-
/**
|
|
1371
|
-
* Verification code email template
|
|
1372
|
-
*/
|
|
1373
|
-
verificationCode?(params: VerificationCodeParams): EmailTemplateResult;
|
|
1374
|
-
/**
|
|
1375
|
-
* Welcome email template (after registration)
|
|
1376
|
-
*/
|
|
1377
|
-
welcome?(params: {
|
|
1378
|
-
email: string;
|
|
1379
|
-
appName?: string;
|
|
1380
|
-
}): EmailTemplateResult;
|
|
1381
|
-
/**
|
|
1382
|
-
* Password reset email template
|
|
1383
|
-
*/
|
|
1384
|
-
passwordReset?(params: {
|
|
1385
|
-
resetLink: string;
|
|
1386
|
-
expiresInMinutes?: number;
|
|
1387
|
-
appName?: string;
|
|
1388
|
-
}): EmailTemplateResult;
|
|
1389
|
-
/**
|
|
1390
|
-
* Invitation email template
|
|
1391
|
-
*/
|
|
1392
|
-
invitation?(params: {
|
|
1393
|
-
inviteLink: string;
|
|
1394
|
-
inviterName?: string;
|
|
1395
|
-
roleName?: string;
|
|
1396
|
-
appName?: string;
|
|
1397
|
-
}): EmailTemplateResult;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
/**
|
|
1401
|
-
* @spfn/auth - Email Template Registry
|
|
1402
|
-
*
|
|
1403
|
-
* Manages custom email template registration and fallback to defaults
|
|
1404
|
-
*/
|
|
1405
|
-
|
|
1406
|
-
/**
|
|
1407
|
-
* Register custom email templates
|
|
1408
|
-
*
|
|
1409
|
-
* Templates not provided will fall back to defaults
|
|
1410
|
-
*
|
|
1411
|
-
* @param templates - Custom template implementations
|
|
1412
|
-
*
|
|
1413
|
-
* @example
|
|
1414
|
-
* ```typescript
|
|
1415
|
-
* import { registerEmailTemplates } from '@spfn/auth/server';
|
|
1416
|
-
*
|
|
1417
|
-
* // Override verification code template with custom design
|
|
1418
|
-
* registerEmailTemplates({
|
|
1419
|
-
* verificationCode: ({ code, purpose, expiresInMinutes }) => ({
|
|
1420
|
-
* subject: `[MyApp] Your verification code`,
|
|
1421
|
-
* text: `Your code is: ${code}`,
|
|
1422
|
-
* html: `
|
|
1423
|
-
* <div style="font-family: Arial;">
|
|
1424
|
-
* <h1>Welcome to MyApp!</h1>
|
|
1425
|
-
* <p>Your code: <strong>${code}</strong></p>
|
|
1426
|
-
* </div>
|
|
1427
|
-
* `,
|
|
1428
|
-
* }),
|
|
1429
|
-
* });
|
|
1430
|
-
* ```
|
|
1431
|
-
*/
|
|
1432
|
-
declare function registerEmailTemplates(templates: Partial<EmailTemplateProvider>): void;
|
|
1433
|
-
/**
|
|
1434
|
-
* Get verification code template
|
|
1435
|
-
*
|
|
1436
|
-
* Uses custom template if registered, otherwise falls back to default
|
|
1437
|
-
*/
|
|
1438
|
-
declare function getVerificationCodeTemplate(params: VerificationCodeParams): EmailTemplateResult;
|
|
1439
|
-
/**
|
|
1440
|
-
* Get welcome template
|
|
1441
|
-
*/
|
|
1442
|
-
declare function getWelcomeTemplate(params: {
|
|
1443
|
-
email: string;
|
|
1444
|
-
appName?: string;
|
|
1445
|
-
}): EmailTemplateResult;
|
|
1446
|
-
/**
|
|
1447
|
-
* Get password reset template
|
|
1448
|
-
*/
|
|
1449
|
-
declare function getPasswordResetTemplate(params: {
|
|
1450
|
-
resetLink: string;
|
|
1451
|
-
expiresInMinutes?: number;
|
|
1452
|
-
appName?: string;
|
|
1453
|
-
}): EmailTemplateResult;
|
|
1454
|
-
/**
|
|
1455
|
-
* Get invitation template
|
|
1456
|
-
*/
|
|
1457
|
-
declare function getInvitationTemplate(params: {
|
|
1458
|
-
inviteLink: string;
|
|
1459
|
-
inviterName?: string;
|
|
1460
|
-
roleName?: string;
|
|
1461
|
-
appName?: string;
|
|
1462
|
-
}): EmailTemplateResult;
|
|
1463
|
-
|
|
1464
|
-
/**
|
|
1465
|
-
* @spfn/auth - Email Service Types
|
|
1466
|
-
*
|
|
1467
|
-
* Type definitions for email sending service
|
|
1468
|
-
*/
|
|
1469
|
-
/**
|
|
1470
|
-
* Parameters for sending email
|
|
1471
|
-
*/
|
|
1472
|
-
interface SendEmailParams {
|
|
1473
|
-
/**
|
|
1474
|
-
* Recipient email address
|
|
1475
|
-
*/
|
|
1476
|
-
to: string;
|
|
1477
|
-
/**
|
|
1478
|
-
* Email subject
|
|
1479
|
-
*/
|
|
1480
|
-
subject: string;
|
|
1481
|
-
/**
|
|
1482
|
-
* Plain text content
|
|
1483
|
-
*/
|
|
1484
|
-
text?: string;
|
|
1485
|
-
/**
|
|
1486
|
-
* HTML content
|
|
1487
|
-
*/
|
|
1488
|
-
html?: string;
|
|
1489
|
-
/**
|
|
1490
|
-
* Purpose of the email (for logging)
|
|
1491
|
-
*/
|
|
1492
|
-
purpose?: string;
|
|
1493
|
-
}
|
|
1494
|
-
/**
|
|
1495
|
-
* Result of sending email
|
|
1496
|
-
*/
|
|
1497
|
-
interface SendEmailResult {
|
|
1498
|
-
/**
|
|
1499
|
-
* Whether email was sent successfully
|
|
1500
|
-
*/
|
|
1501
|
-
success: boolean;
|
|
1502
|
-
/**
|
|
1503
|
-
* Message ID from email provider (if successful)
|
|
1504
|
-
*/
|
|
1505
|
-
messageId?: string;
|
|
1506
|
-
/**
|
|
1507
|
-
* Error message (if failed)
|
|
1508
|
-
*/
|
|
1509
|
-
error?: string;
|
|
1510
|
-
}
|
|
1511
|
-
/**
|
|
1512
|
-
* Email Provider Interface
|
|
1513
|
-
*
|
|
1514
|
-
* Implement this interface to create custom email providers
|
|
1515
|
-
*
|
|
1516
|
-
* @example
|
|
1517
|
-
* ```typescript
|
|
1518
|
-
* import { EmailProvider, registerEmailProvider } from '@spfn/auth/server/services/email';
|
|
1519
|
-
*
|
|
1520
|
-
* const sendgridProvider: EmailProvider = {
|
|
1521
|
-
* name: 'sendgrid',
|
|
1522
|
-
* sendEmail: async (params) => {
|
|
1523
|
-
* // Your SendGrid implementation
|
|
1524
|
-
* return { success: true, messageId: '...' };
|
|
1525
|
-
* }
|
|
1526
|
-
* };
|
|
1527
|
-
*
|
|
1528
|
-
* registerEmailProvider(sendgridProvider);
|
|
1529
|
-
* ```
|
|
1530
|
-
*/
|
|
1531
|
-
interface EmailProvider {
|
|
1532
|
-
/**
|
|
1533
|
-
* Provider name (e.g., 'aws-ses', 'sendgrid', 'custom')
|
|
1534
|
-
*/
|
|
1535
|
-
name: string;
|
|
1536
|
-
/**
|
|
1537
|
-
* Send email via this provider
|
|
1538
|
-
*
|
|
1539
|
-
* @param params - Email parameters
|
|
1540
|
-
* @returns Send result
|
|
1541
|
-
*/
|
|
1542
|
-
sendEmail(params: SendEmailParams): Promise<SendEmailResult>;
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
/**
|
|
1546
|
-
* @spfn/auth - Email Provider Management
|
|
1547
|
-
*
|
|
1548
|
-
* Manages email provider registration and fallback behavior
|
|
1549
|
-
*/
|
|
1550
|
-
|
|
1551
|
-
/**
|
|
1552
|
-
* Register a custom email provider
|
|
1553
|
-
*
|
|
1554
|
-
* @param provider - Custom email provider implementation
|
|
1555
|
-
*
|
|
1556
|
-
* @example
|
|
1557
|
-
* ```typescript
|
|
1558
|
-
* import { registerEmailProvider } from '@spfn/auth/server/services/email';
|
|
1559
|
-
*
|
|
1560
|
-
* const sendgridProvider = {
|
|
1561
|
-
* name: 'sendgrid',
|
|
1562
|
-
* sendEmail: async (params) => {
|
|
1563
|
-
* // SendGrid implementation
|
|
1564
|
-
* return { success: true, messageId: '...' };
|
|
1565
|
-
* }
|
|
1566
|
-
* };
|
|
1567
|
-
*
|
|
1568
|
-
* registerEmailProvider(sendgridProvider);
|
|
1569
|
-
* ```
|
|
1570
|
-
*/
|
|
1571
|
-
declare function registerEmailProvider(provider: EmailProvider): void;
|
|
1572
|
-
/**
|
|
1573
|
-
* Send email using the registered provider
|
|
1574
|
-
*
|
|
1575
|
-
* Falls back to development mode (console only) if no provider is registered
|
|
1576
|
-
*
|
|
1577
|
-
* @param params - Email parameters
|
|
1578
|
-
* @returns Send result
|
|
1579
|
-
*/
|
|
1580
|
-
declare function sendEmail(params: SendEmailParams): Promise<SendEmailResult>;
|
|
1581
|
-
|
|
1582
|
-
/**
|
|
1583
|
-
* @spfn/auth - SMS Service Types
|
|
1584
|
-
*
|
|
1585
|
-
* Type definitions for SMS sending service
|
|
1586
|
-
*/
|
|
1587
|
-
/**
|
|
1588
|
-
* Parameters for sending SMS
|
|
1589
|
-
*/
|
|
1590
|
-
interface SendSMSParams {
|
|
1591
|
-
/**
|
|
1592
|
-
* Phone number in E.164 format (e.g., +821012345678)
|
|
1593
|
-
*/
|
|
1594
|
-
phone: string;
|
|
1595
|
-
/**
|
|
1596
|
-
* SMS message content
|
|
1597
|
-
*/
|
|
1598
|
-
message: string;
|
|
1599
|
-
/**
|
|
1600
|
-
* Purpose of the SMS (for logging)
|
|
1601
|
-
*/
|
|
1602
|
-
purpose?: string;
|
|
1603
|
-
}
|
|
1604
|
-
/**
|
|
1605
|
-
* Result of sending SMS
|
|
1606
|
-
*/
|
|
1607
|
-
interface SendSMSResult {
|
|
1608
|
-
/**
|
|
1609
|
-
* Whether SMS was sent successfully
|
|
1610
|
-
*/
|
|
1611
|
-
success: boolean;
|
|
1612
|
-
/**
|
|
1613
|
-
* Message ID from SMS provider (if successful)
|
|
1614
|
-
*/
|
|
1615
|
-
messageId?: string;
|
|
1616
|
-
/**
|
|
1617
|
-
* Error message (if failed)
|
|
1618
|
-
*/
|
|
1619
|
-
error?: string;
|
|
1620
|
-
}
|
|
1621
|
-
/**
|
|
1622
|
-
* SMS Provider Interface
|
|
1623
|
-
*
|
|
1624
|
-
* Implement this interface to create custom SMS providers
|
|
1625
|
-
*
|
|
1626
|
-
* @example
|
|
1627
|
-
* ```typescript
|
|
1628
|
-
* import { SMSProvider, registerSMSProvider } from '@spfn/auth/server/services/sms';
|
|
1629
|
-
*
|
|
1630
|
-
* const twilioProvider: SMSProvider = {
|
|
1631
|
-
* name: 'twilio',
|
|
1632
|
-
* sendSMS: async (params) => {
|
|
1633
|
-
* // Your Twilio implementation
|
|
1634
|
-
* return { success: true, messageId: '...' };
|
|
1635
|
-
* }
|
|
1636
|
-
* };
|
|
1637
|
-
*
|
|
1638
|
-
* registerSMSProvider(twilioProvider);
|
|
1639
|
-
* ```
|
|
1640
|
-
*/
|
|
1641
|
-
interface SMSProvider {
|
|
1642
|
-
/**
|
|
1643
|
-
* Provider name (e.g., 'aws-sns', 'twilio', 'custom')
|
|
1644
|
-
*/
|
|
1645
|
-
name: string;
|
|
1646
|
-
/**
|
|
1647
|
-
* Send SMS via this provider
|
|
1648
|
-
*
|
|
1649
|
-
* @param params - SMS parameters
|
|
1650
|
-
* @returns Send result
|
|
1651
|
-
*/
|
|
1652
|
-
sendSMS(params: SendSMSParams): Promise<SendSMSResult>;
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
/**
|
|
1656
|
-
* @spfn/auth - SMS Provider Management
|
|
1657
|
-
*
|
|
1658
|
-
* Manages SMS provider registration and fallback behavior
|
|
1659
|
-
*/
|
|
1660
|
-
|
|
1661
|
-
/**
|
|
1662
|
-
* Register a custom SMS provider
|
|
1663
|
-
*
|
|
1664
|
-
* @param provider - Custom SMS provider implementation
|
|
1665
|
-
*
|
|
1666
|
-
* @example
|
|
1667
|
-
* ```typescript
|
|
1668
|
-
* import { registerSMSProvider } from '@spfn/auth/server/services/sms';
|
|
1669
|
-
*
|
|
1670
|
-
* const twilioProvider = {
|
|
1671
|
-
* name: 'twilio',
|
|
1672
|
-
* sendSMS: async (params) => {
|
|
1673
|
-
* // Twilio implementation
|
|
1674
|
-
* return { success: true, messageId: '...' };
|
|
1675
|
-
* }
|
|
1676
|
-
* };
|
|
1677
|
-
*
|
|
1678
|
-
* registerSMSProvider(twilioProvider);
|
|
1679
|
-
* ```
|
|
1680
|
-
*/
|
|
1681
|
-
declare function registerSMSProvider(provider: SMSProvider): void;
|
|
1682
|
-
/**
|
|
1683
|
-
* Send SMS using the registered provider
|
|
1684
|
-
*
|
|
1685
|
-
* Falls back to development mode (console only) if no provider is registered
|
|
1686
|
-
*
|
|
1687
|
-
* @param params - SMS parameters
|
|
1688
|
-
* @returns Send result
|
|
1689
|
-
*/
|
|
1690
|
-
declare function sendSMS(params: SendSMSParams): Promise<SendSMSResult>;
|
|
1691
|
-
|
|
1692
1329
|
/**
|
|
1693
1330
|
* @spfn/auth - Database Schema Definition
|
|
1694
1331
|
*
|
|
@@ -4502,6 +4139,136 @@ declare class InvitationsRepository extends BaseRepository {
|
|
|
4502
4139
|
}
|
|
4503
4140
|
declare const invitationsRepository: InvitationsRepository;
|
|
4504
4141
|
|
|
4142
|
+
/**
|
|
4143
|
+
* Social Accounts Repository
|
|
4144
|
+
*
|
|
4145
|
+
* OAuth 소셜 계정 데이터 관리를 위한 Repository
|
|
4146
|
+
* BaseRepository를 상속받아 자동 트랜잭션 컨텍스트 지원 및 Read/Write 분리
|
|
4147
|
+
*/
|
|
4148
|
+
|
|
4149
|
+
/**
|
|
4150
|
+
* Social Accounts Repository 클래스
|
|
4151
|
+
*/
|
|
4152
|
+
declare class SocialAccountsRepository extends BaseRepository {
|
|
4153
|
+
/**
|
|
4154
|
+
* provider와 providerUserId로 소셜 계정 조회
|
|
4155
|
+
* Read replica 사용
|
|
4156
|
+
*/
|
|
4157
|
+
findByProviderAndProviderId(provider: SocialProvider, providerUserId: string): Promise<{
|
|
4158
|
+
createdAt: Date;
|
|
4159
|
+
updatedAt: Date;
|
|
4160
|
+
id: number;
|
|
4161
|
+
userId: number;
|
|
4162
|
+
provider: "google" | "github" | "kakao" | "naver";
|
|
4163
|
+
providerUserId: string;
|
|
4164
|
+
providerEmail: string | null;
|
|
4165
|
+
accessToken: string | null;
|
|
4166
|
+
refreshToken: string | null;
|
|
4167
|
+
tokenExpiresAt: Date | null;
|
|
4168
|
+
}>;
|
|
4169
|
+
/**
|
|
4170
|
+
* userId로 모든 소셜 계정 조회
|
|
4171
|
+
* Read replica 사용
|
|
4172
|
+
*/
|
|
4173
|
+
findByUserId(userId: number): Promise<{
|
|
4174
|
+
createdAt: Date;
|
|
4175
|
+
updatedAt: Date;
|
|
4176
|
+
id: number;
|
|
4177
|
+
userId: number;
|
|
4178
|
+
provider: "google" | "github" | "kakao" | "naver";
|
|
4179
|
+
providerUserId: string;
|
|
4180
|
+
providerEmail: string | null;
|
|
4181
|
+
accessToken: string | null;
|
|
4182
|
+
refreshToken: string | null;
|
|
4183
|
+
tokenExpiresAt: Date | null;
|
|
4184
|
+
}[]>;
|
|
4185
|
+
/**
|
|
4186
|
+
* userId와 provider로 소셜 계정 조회
|
|
4187
|
+
* Read replica 사용
|
|
4188
|
+
*/
|
|
4189
|
+
findByUserIdAndProvider(userId: number, provider: SocialProvider): Promise<{
|
|
4190
|
+
createdAt: Date;
|
|
4191
|
+
updatedAt: Date;
|
|
4192
|
+
id: number;
|
|
4193
|
+
userId: number;
|
|
4194
|
+
provider: "google" | "github" | "kakao" | "naver";
|
|
4195
|
+
providerUserId: string;
|
|
4196
|
+
providerEmail: string | null;
|
|
4197
|
+
accessToken: string | null;
|
|
4198
|
+
refreshToken: string | null;
|
|
4199
|
+
tokenExpiresAt: Date | null;
|
|
4200
|
+
}>;
|
|
4201
|
+
/**
|
|
4202
|
+
* 소셜 계정 생성
|
|
4203
|
+
* Write primary 사용
|
|
4204
|
+
*/
|
|
4205
|
+
create(data: NewUserSocialAccount): Promise<{
|
|
4206
|
+
userId: number;
|
|
4207
|
+
id: number;
|
|
4208
|
+
createdAt: Date;
|
|
4209
|
+
updatedAt: Date;
|
|
4210
|
+
provider: "google" | "github" | "kakao" | "naver";
|
|
4211
|
+
providerUserId: string;
|
|
4212
|
+
providerEmail: string | null;
|
|
4213
|
+
accessToken: string | null;
|
|
4214
|
+
refreshToken: string | null;
|
|
4215
|
+
tokenExpiresAt: Date | null;
|
|
4216
|
+
}>;
|
|
4217
|
+
/**
|
|
4218
|
+
* 토큰 정보 업데이트
|
|
4219
|
+
* Write primary 사용
|
|
4220
|
+
*/
|
|
4221
|
+
updateTokens(id: number, data: {
|
|
4222
|
+
accessToken?: string | null;
|
|
4223
|
+
refreshToken?: string | null;
|
|
4224
|
+
tokenExpiresAt?: Date | null;
|
|
4225
|
+
}): Promise<{
|
|
4226
|
+
createdAt: Date;
|
|
4227
|
+
updatedAt: Date;
|
|
4228
|
+
id: number;
|
|
4229
|
+
userId: number;
|
|
4230
|
+
provider: "google" | "github" | "kakao" | "naver";
|
|
4231
|
+
providerUserId: string;
|
|
4232
|
+
providerEmail: string | null;
|
|
4233
|
+
accessToken: string | null;
|
|
4234
|
+
refreshToken: string | null;
|
|
4235
|
+
tokenExpiresAt: Date | null;
|
|
4236
|
+
}>;
|
|
4237
|
+
/**
|
|
4238
|
+
* 소셜 계정 삭제
|
|
4239
|
+
* Write primary 사용
|
|
4240
|
+
*/
|
|
4241
|
+
deleteById(id: number): Promise<{
|
|
4242
|
+
userId: number;
|
|
4243
|
+
id: number;
|
|
4244
|
+
createdAt: Date;
|
|
4245
|
+
updatedAt: Date;
|
|
4246
|
+
provider: "google" | "github" | "kakao" | "naver";
|
|
4247
|
+
providerUserId: string;
|
|
4248
|
+
providerEmail: string | null;
|
|
4249
|
+
accessToken: string | null;
|
|
4250
|
+
refreshToken: string | null;
|
|
4251
|
+
tokenExpiresAt: Date | null;
|
|
4252
|
+
}>;
|
|
4253
|
+
/**
|
|
4254
|
+
* userId와 provider로 소셜 계정 삭제
|
|
4255
|
+
* Write primary 사용
|
|
4256
|
+
*/
|
|
4257
|
+
deleteByUserIdAndProvider(userId: number, provider: SocialProvider): Promise<{
|
|
4258
|
+
userId: number;
|
|
4259
|
+
id: number;
|
|
4260
|
+
createdAt: Date;
|
|
4261
|
+
updatedAt: Date;
|
|
4262
|
+
provider: "google" | "github" | "kakao" | "naver";
|
|
4263
|
+
providerUserId: string;
|
|
4264
|
+
providerEmail: string | null;
|
|
4265
|
+
accessToken: string | null;
|
|
4266
|
+
refreshToken: string | null;
|
|
4267
|
+
tokenExpiresAt: Date | null;
|
|
4268
|
+
}>;
|
|
4269
|
+
}
|
|
4270
|
+
declare const socialAccountsRepository: SocialAccountsRepository;
|
|
4271
|
+
|
|
4505
4272
|
/**
|
|
4506
4273
|
* @spfn/auth - Password Helpers
|
|
4507
4274
|
*
|
|
@@ -5048,6 +4815,8 @@ declare const COOKIE_NAMES: {
|
|
|
5048
4815
|
readonly SESSION: "spfn_session";
|
|
5049
4816
|
/** Current key ID (for key rotation) */
|
|
5050
4817
|
readonly SESSION_KEY_ID: "spfn_session_key_id";
|
|
4818
|
+
/** Pending OAuth session (privateKey, keyId, algorithm) - temporary during OAuth flow */
|
|
4819
|
+
readonly OAUTH_PENDING: "spfn_oauth_pending";
|
|
5051
4820
|
};
|
|
5052
4821
|
/**
|
|
5053
4822
|
* Parse duration string to seconds
|
|
@@ -5104,6 +4873,114 @@ declare function getAuthConfig(): AuthConfig;
|
|
|
5104
4873
|
*/
|
|
5105
4874
|
declare function getSessionTtl(override?: string | number): number;
|
|
5106
4875
|
|
|
4876
|
+
/**
|
|
4877
|
+
* Google OAuth 2.0 Client
|
|
4878
|
+
*
|
|
4879
|
+
* Authorization Code Flow 구현
|
|
4880
|
+
* - getGoogleAuthUrl: Google 로그인 URL 생성
|
|
4881
|
+
* - exchangeCodeForTokens: Code를 Token으로 교환
|
|
4882
|
+
* - getGoogleUserInfo: 사용자 정보 조회
|
|
4883
|
+
*/
|
|
4884
|
+
interface GoogleTokenResponse {
|
|
4885
|
+
access_token: string;
|
|
4886
|
+
expires_in: number;
|
|
4887
|
+
refresh_token?: string;
|
|
4888
|
+
scope: string;
|
|
4889
|
+
token_type: string;
|
|
4890
|
+
id_token?: string;
|
|
4891
|
+
}
|
|
4892
|
+
interface GoogleUserInfo {
|
|
4893
|
+
id: string;
|
|
4894
|
+
email: string;
|
|
4895
|
+
verified_email: boolean;
|
|
4896
|
+
name?: string;
|
|
4897
|
+
given_name?: string;
|
|
4898
|
+
family_name?: string;
|
|
4899
|
+
picture?: string;
|
|
4900
|
+
locale?: string;
|
|
4901
|
+
}
|
|
4902
|
+
/**
|
|
4903
|
+
* Google OAuth가 활성화되어 있는지 확인
|
|
4904
|
+
*/
|
|
4905
|
+
declare function isGoogleOAuthEnabled(): boolean;
|
|
4906
|
+
/**
|
|
4907
|
+
* Google OAuth 설정 가져오기
|
|
4908
|
+
*/
|
|
4909
|
+
declare function getGoogleOAuthConfig(): {
|
|
4910
|
+
clientId: string;
|
|
4911
|
+
clientSecret: string;
|
|
4912
|
+
redirectUri: string;
|
|
4913
|
+
};
|
|
4914
|
+
/**
|
|
4915
|
+
* Google 로그인 URL 생성
|
|
4916
|
+
*
|
|
4917
|
+
* @param state - CSRF 방지용 state 파라미터 (암호화된 returnUrl + nonce 포함)
|
|
4918
|
+
* @param scopes - 요청할 OAuth scopes (기본: email, profile)
|
|
4919
|
+
*/
|
|
4920
|
+
declare function getGoogleAuthUrl(state: string, scopes?: string[]): string;
|
|
4921
|
+
/**
|
|
4922
|
+
* Authorization Code를 Token으로 교환
|
|
4923
|
+
*
|
|
4924
|
+
* @param code - Google에서 받은 authorization code
|
|
4925
|
+
*/
|
|
4926
|
+
declare function exchangeCodeForTokens(code: string): Promise<GoogleTokenResponse>;
|
|
4927
|
+
/**
|
|
4928
|
+
* Access Token으로 Google 사용자 정보 조회
|
|
4929
|
+
*
|
|
4930
|
+
* @param accessToken - Google access token
|
|
4931
|
+
*/
|
|
4932
|
+
declare function getGoogleUserInfo(accessToken: string): Promise<GoogleUserInfo>;
|
|
4933
|
+
/**
|
|
4934
|
+
* Refresh Token으로 새 Access Token 획득
|
|
4935
|
+
*
|
|
4936
|
+
* @param refreshToken - Google refresh token
|
|
4937
|
+
*/
|
|
4938
|
+
declare function refreshAccessToken(refreshToken: string): Promise<GoogleTokenResponse>;
|
|
4939
|
+
|
|
4940
|
+
/**
|
|
4941
|
+
* OAuth State Management
|
|
4942
|
+
*
|
|
4943
|
+
* CSRF 방지를 위한 state 파라미터 암호화/복호화
|
|
4944
|
+
* - returnUrl: OAuth 성공 후 리다이렉트할 URL
|
|
4945
|
+
* - nonce: CSRF 방지용 일회용 토큰
|
|
4946
|
+
* - provider: OAuth provider (google, github 등)
|
|
4947
|
+
* - publicKey, keyId, fingerprint, algorithm: 클라이언트 키 정보
|
|
4948
|
+
* - expiresAt: state 만료 시간
|
|
4949
|
+
*/
|
|
4950
|
+
|
|
4951
|
+
interface OAuthState {
|
|
4952
|
+
returnUrl: string;
|
|
4953
|
+
nonce: string;
|
|
4954
|
+
provider: string;
|
|
4955
|
+
publicKey: string;
|
|
4956
|
+
keyId: string;
|
|
4957
|
+
fingerprint: string;
|
|
4958
|
+
algorithm: KeyAlgorithmType;
|
|
4959
|
+
}
|
|
4960
|
+
interface CreateOAuthStateParams {
|
|
4961
|
+
provider: string;
|
|
4962
|
+
returnUrl: string;
|
|
4963
|
+
publicKey: string;
|
|
4964
|
+
keyId: string;
|
|
4965
|
+
fingerprint: string;
|
|
4966
|
+
algorithm: KeyAlgorithmType;
|
|
4967
|
+
}
|
|
4968
|
+
/**
|
|
4969
|
+
* OAuth state 생성 및 암호화
|
|
4970
|
+
*
|
|
4971
|
+
* @param params - state 생성에 필요한 파라미터
|
|
4972
|
+
* @returns 암호화된 state 문자열
|
|
4973
|
+
*/
|
|
4974
|
+
declare function createOAuthState(params: CreateOAuthStateParams): Promise<string>;
|
|
4975
|
+
/**
|
|
4976
|
+
* OAuth state 복호화 및 검증
|
|
4977
|
+
*
|
|
4978
|
+
* @param encryptedState - 암호화된 state 문자열
|
|
4979
|
+
* @returns 복호화된 state 객체
|
|
4980
|
+
* @throws Error if state is invalid or expired (JWE exp claim으로 자동 검증)
|
|
4981
|
+
*/
|
|
4982
|
+
declare function verifyOAuthState(encryptedState: string): Promise<OAuthState>;
|
|
4983
|
+
|
|
5107
4984
|
/**
|
|
5108
4985
|
* @spfn/auth - Centralized Logger
|
|
5109
4986
|
*
|
|
@@ -5199,4 +5076,4 @@ interface AuthLifecycleConfig {
|
|
|
5199
5076
|
*/
|
|
5200
5077
|
declare function createAuthLifecycle(options?: AuthInitOptions): AuthLifecycleConfig;
|
|
5201
5078
|
|
|
5202
|
-
export { type AuthConfig, AuthContext, COOKIE_NAMES, type
|
|
5079
|
+
export { type AuthConfig, AuthContext, COOKIE_NAMES, type CreateOAuthStateParams, type GoogleTokenResponse, type GoogleUserInfo, type Invitation, InvitationStatus, InvitationsRepository, KeyAlgorithmType, type KeyPair, KeysRepository, type NewInvitation, type NewPermission, type NewPermissionEntity, type NewRole, type NewRoleEntity, type NewRolePermission, type NewUser, type NewUserPermission, type NewUserProfile, type NewUserPublicKey, type NewUserSocialAccount, type NewVerificationCode, type OAuthState, type Permission, type PermissionEntity, PermissionsRepository, type Role, type RoleEntity, type RoleGuardOptions, type RolePermission, RolePermissionsRepository, RolesRepository, type SessionData, type SessionPayload, SocialAccountsRepository, SocialProvider, type TokenPayload, type UpdateProfileParams, type User, type UserPermission, UserPermissionsRepository, type UserProfile, UserProfilesRepository, type UserPublicKey, type UserSocialAccount, UsersRepository, type VerificationCode, VerificationCodesRepository, VerificationPurpose, acceptInvitation, addPermissionToRole, authLogger, authSchema, cancelInvitation, configureAuth, createAuthLifecycle, createInvitation, createOAuthState, createRole, decodeToken, deleteInvitation, deleteRole, exchangeCodeForTokens, expireOldInvitations, generateClientToken, generateKeyPair, generateKeyPairES256, generateKeyPairRS256, generateToken, getAllRoles, getAuth, getAuthConfig, getAuthSessionService, getGoogleAuthUrl, getGoogleOAuthConfig, getGoogleUserInfo, getInvitationByToken, getInvitationWithDetails, getKeyId, getKeySize, getRoleByName, getRolePermissions, getSessionInfo, getSessionTtl, getUser, getUserByEmailService, getUserByIdService, getUserByPhoneService, getUserId, getUserPermissions, getUserProfileService, getUserRole, hasAllPermissions, hasAnyPermission, hasAnyRole, hasPermission, hasRole, hashPassword, initializeAuth, invitationsRepository, isGoogleOAuthEnabled, keysRepository, listInvitations, parseDuration, permissions, permissionsRepository, refreshAccessToken, removePermissionFromRole, requireAnyPermission, requirePermissions, requireRole, resendInvitation, roleGuard, rolePermissions, rolePermissionsRepository, roles, rolesRepository, sealSession, setRolePermissions, shouldRefreshSession, shouldRotateKey, socialAccountsRepository, unsealSession, updateLastLoginService, updateRole, updateUserProfileService, updateUserService, userInvitations, userPermissions, userPermissionsRepository, userProfiles, userProfilesRepository, userPublicKeys, userSocialAccounts, users, usersRepository, validateInvitation, validatePasswordStrength, verificationCodes, verificationCodesRepository, verifyClientToken, verifyKeyFingerprint, verifyOAuthState, verifyPassword, verifyToken };
|