@spfn/auth 0.2.0-beta.11 → 0.2.0-beta.13
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 +338 -8
- package/dist/{authenticate-CU6_zQaa.d.ts → authenticate-Cz2FjLdB.d.ts} +113 -1
- package/dist/config.d.ts +120 -0
- package/dist/config.js +72 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +46 -2
- 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 -2
- package/dist/nextjs/server.js.map +1 -1
- package/dist/server.d.ts +243 -3
- package/dist/server.js +594 -23
- package/dist/server.js.map +1 -1
- package/package.json +10 -3
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 './authenticate-
|
|
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-Cz2FjLdB.js';
|
|
2
|
+
export { B as ChangePasswordParams, w as CheckAccountExistsParams, C as CheckAccountExistsResult, a5 as EmailSchema, I as INVITATION_STATUSES, K as KEY_ALGORITHM, y as LoginParams, L as LoginResult, z as LogoutParams, a2 as OAuthCallbackParams, a3 as OAuthCallbackResult, a1 as OAuthStartParams, O as OAuthStartResult, a7 as PasswordSchema, a6 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, a8 as TargetTypeSchema, d as USER_STATUSES, o as UserStatus, h as VERIFICATION_PURPOSES, g as VERIFICATION_TARGET_TYPES, a9 as VerificationPurposeSchema, V as VerificationTargetType, G as VerifyCodeParams, H as VerifyCodeResult, m as authRouter, a4 as authenticate, Z as buildOAuthErrorUrl, v as changePasswordService, r as checkAccountExistsService, $ as getEnabledOAuthProviders, a0 as getGoogleAccessToken, _ 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-Cz2FjLdB.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';
|
|
@@ -4139,6 +4139,136 @@ declare class InvitationsRepository extends BaseRepository {
|
|
|
4139
4139
|
}
|
|
4140
4140
|
declare const invitationsRepository: InvitationsRepository;
|
|
4141
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
|
+
|
|
4142
4272
|
/**
|
|
4143
4273
|
* @spfn/auth - Password Helpers
|
|
4144
4274
|
*
|
|
@@ -4685,6 +4815,8 @@ declare const COOKIE_NAMES: {
|
|
|
4685
4815
|
readonly SESSION: "spfn_session";
|
|
4686
4816
|
/** Current key ID (for key rotation) */
|
|
4687
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";
|
|
4688
4820
|
};
|
|
4689
4821
|
/**
|
|
4690
4822
|
* Parse duration string to seconds
|
|
@@ -4741,6 +4873,114 @@ declare function getAuthConfig(): AuthConfig;
|
|
|
4741
4873
|
*/
|
|
4742
4874
|
declare function getSessionTtl(override?: string | number): number;
|
|
4743
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 (기본: env 또는 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
|
+
|
|
4744
4984
|
/**
|
|
4745
4985
|
* @spfn/auth - Centralized Logger
|
|
4746
4986
|
*
|
|
@@ -4836,4 +5076,4 @@ interface AuthLifecycleConfig {
|
|
|
4836
5076
|
*/
|
|
4837
5077
|
declare function createAuthLifecycle(options?: AuthInitOptions): AuthLifecycleConfig;
|
|
4838
5078
|
|
|
4839
|
-
export { type AuthConfig, AuthContext, COOKIE_NAMES, 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 Permission, type PermissionEntity, PermissionsRepository, type Role, type RoleEntity, type RoleGuardOptions, type RolePermission, RolePermissionsRepository, RolesRepository, type SessionData, type SessionPayload, 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, createRole, decodeToken, deleteInvitation, deleteRole, expireOldInvitations, generateClientToken, generateKeyPair, generateKeyPairES256, generateKeyPairRS256, generateToken, getAllRoles, getAuth, getAuthConfig, getAuthSessionService, getInvitationByToken, getInvitationWithDetails, getKeyId, getKeySize, getRoleByName, getRolePermissions, getSessionInfo, getSessionTtl, getUser, getUserByEmailService, getUserByIdService, getUserByPhoneService, getUserId, getUserPermissions, getUserProfileService, getUserRole, hasAllPermissions, hasAnyPermission, hasAnyRole, hasPermission, hasRole, hashPassword, initializeAuth, invitationsRepository, keysRepository, listInvitations, parseDuration, permissions, permissionsRepository, removePermissionFromRole, requireAnyPermission, requirePermissions, requireRole, resendInvitation, roleGuard, rolePermissions, rolePermissionsRepository, roles, rolesRepository, sealSession, setRolePermissions, shouldRefreshSession, shouldRotateKey, unsealSession, updateLastLoginService, updateRole, updateUserProfileService, updateUserService, userInvitations, userPermissions, userPermissionsRepository, userProfiles, userProfilesRepository, userPublicKeys, userSocialAccounts, users, usersRepository, validateInvitation, validatePasswordStrength, verificationCodes, verificationCodesRepository, verifyClientToken, verifyKeyFingerprint, verifyPassword, verifyToken };
|
|
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 };
|