connectbase-client 0.1.4 → 0.1.6

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/dist/index.d.ts CHANGED
@@ -1282,26 +1282,12 @@ interface EnabledProviderInfo {
1282
1282
  interface EnabledProvidersResponse {
1283
1283
  providers: EnabledProviderInfo[];
1284
1284
  }
1285
- /**
1286
- * OAuth 인증 URL 요청
1287
- */
1288
- interface GetAuthorizationURLRequest {
1289
- redirect_uri: string;
1290
- state?: string;
1291
- }
1292
1285
  /**
1293
1286
  * OAuth 인증 URL 응답
1294
1287
  */
1295
1288
  interface GetAuthorizationURLResponse {
1296
1289
  authorization_url: string;
1297
1290
  }
1298
- /**
1299
- * OAuth 콜백 요청
1300
- */
1301
- interface OAuthCallbackRequest {
1302
- code: string;
1303
- redirect_uri: string;
1304
- }
1305
1291
  /**
1306
1292
  * OAuth 콜백 응답
1307
1293
  */
@@ -1330,94 +1316,6 @@ declare class OAuthAPI {
1330
1316
  * ```
1331
1317
  */
1332
1318
  getEnabledProviders(): Promise<EnabledProvidersResponse>;
1333
- /**
1334
- * OAuth 인증 URL 조회
1335
- * 사용자를 소셜 로그인 페이지로 리다이렉트할 URL을 반환합니다.
1336
- *
1337
- * @param provider - OAuth 프로바이더 (google, naver, github, discord)
1338
- * @param options - redirect_uri와 선택적 state 파라미터
1339
- * @returns 인증 URL
1340
- *
1341
- * @example
1342
- * ```typescript
1343
- * const { authorization_url } = await cb.oauth.getAuthorizationURL('google', {
1344
- * redirect_uri: 'https://myapp.com/auth/callback'
1345
- * })
1346
- *
1347
- * // 사용자를 OAuth 페이지로 리다이렉트
1348
- * window.location.href = authorization_url
1349
- * ```
1350
- */
1351
- getAuthorizationURL(provider: OAuthProvider, options: GetAuthorizationURLRequest): Promise<GetAuthorizationURLResponse>;
1352
- /**
1353
- * OAuth 콜백 처리
1354
- * 소셜 로그인 후 콜백으로 받은 code를 사용하여 로그인을 완료합니다.
1355
- * 성공 시 자동으로 토큰이 저장됩니다.
1356
- *
1357
- * @param provider - OAuth 프로바이더
1358
- * @param data - code와 redirect_uri
1359
- * @returns 로그인 결과 (member_id, 토큰, 신규 회원 여부)
1360
- *
1361
- * @example
1362
- * ```typescript
1363
- * // 콜백 페이지에서 URL 파라미터로 code 추출
1364
- * const urlParams = new URLSearchParams(window.location.search)
1365
- * const code = urlParams.get('code')
1366
- *
1367
- * const result = await cb.oauth.handleCallback('google', {
1368
- * code: code,
1369
- * redirect_uri: 'https://myapp.com/auth/callback'
1370
- * })
1371
- *
1372
- * if (result.is_new_member) {
1373
- * console.log('신규 회원입니다!')
1374
- * }
1375
- * ```
1376
- */
1377
- handleCallback(provider: OAuthProvider, data: OAuthCallbackRequest): Promise<OAuthCallbackResponse>;
1378
- /**
1379
- * 소셜 로그인 전체 플로우 (팝업 방식)
1380
- * 새 창에서 소셜 로그인을 처리하고 결과를 Promise로 반환합니다.
1381
- *
1382
- * @param provider - OAuth 프로바이더
1383
- * @param redirectUri - 콜백 URL (이 페이지에서 postMessage로 결과 전달 필요)
1384
- * @returns 로그인 결과
1385
- *
1386
- * @example
1387
- * ```typescript
1388
- * // 로그인 버튼 클릭 시
1389
- * const result = await cb.oauth.signInWithPopup('google', 'https://myapp.com/auth/popup-callback')
1390
- * console.log('로그인 성공:', result.member_id)
1391
- * ```
1392
- *
1393
- * @example
1394
- * ```html
1395
- * <!-- popup-callback.html -->
1396
- * <script>
1397
- * const urlParams = new URLSearchParams(window.location.search)
1398
- * const code = urlParams.get('code')
1399
- * const error = urlParams.get('error')
1400
- *
1401
- * window.opener.postMessage({
1402
- * type: 'oauth-callback',
1403
- * code,
1404
- * error
1405
- * }, '*')
1406
- * window.close()
1407
- * </script>
1408
- * ```
1409
- */
1410
- signInWithPopup(provider: OAuthProvider, redirectUri: string): Promise<OAuthCallbackResponse>;
1411
- /**
1412
- * 소셜 로그인 (리다이렉트 방식) - 기존 방식
1413
- * ⚠️ 이 방식은 Google Cloud Console에 redirect_uri를 등록해야 합니다.
1414
- * 대부분의 경우 signIn() 메서드 사용을 권장합니다.
1415
- *
1416
- * @param provider - OAuth 프로바이더
1417
- * @param redirectUri - 콜백 URL
1418
- * @deprecated signIn() 메서드 사용 권장 (Google Console 등록 불필요)
1419
- */
1420
- signInWithRedirect(provider: OAuthProvider, redirectUri: string): Promise<void>;
1421
1319
  /**
1422
1320
  * 소셜 로그인 (중앙 콜백 방식) - 권장
1423
1321
  * Google Cloud Console에 별도로 redirect_uri를 등록할 필요가 없습니다.
@@ -1451,7 +1349,7 @@ declare class OAuthAPI {
1451
1349
  */
1452
1350
  signIn(provider: OAuthProvider, callbackUrl: string, state?: string): Promise<void>;
1453
1351
  /**
1454
- * 소셜 로그인 (팝업 방식, 중앙 콜백) - 권장
1352
+ * 소셜 로그인 (팝업 방식)
1455
1353
  * 팝업 창에서 소셜 로그인을 처리하고 결과를 Promise로 반환합니다.
1456
1354
  * Google Cloud Console에 별도 등록 불필요.
1457
1355
  *
@@ -1481,7 +1379,7 @@ declare class OAuthAPI {
1481
1379
  * </script>
1482
1380
  * ```
1483
1381
  */
1484
- signInWithPopupCentral(provider: OAuthProvider, callbackUrl: string): Promise<OAuthCallbackResponse>;
1382
+ signInWithPopup(provider: OAuthProvider, callbackUrl: string): Promise<OAuthCallbackResponse>;
1485
1383
  /**
1486
1384
  * 콜백 URL에서 OAuth 결과 추출
1487
1385
  * 중앙 콜백 방식에서 리다이렉트 후 URL 파라미터에서 결과를 추출합니다.
@@ -3416,4 +3314,4 @@ declare class ConnectBase {
3416
3314
  updateConfig(config: Partial<ConnectBaseConfig>): void;
3417
3315
  }
3418
3316
 
3419
- export { type AnonymousSignInRequest, type AnonymousSignInResponse, type AnonymousSignUpResponse, ApiError, type ApiKeyItem, type AppStatsResponse, AuthError, type AuthSettingsResponse, type BillingCycle, type BillingKeyResponse, type BulkCreateResponse, type BulkError, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateChannelRequest, type CreateColumnRequest, type CreateDataRequest, type CreateFolderRequest, type CreateFolderResponse, type CreatePlaylistRequest, type CreateSubscriptionRequest, type CreateTableRequest, type DataItem, type DataType, type DeleteWhereResponse, type DeviceInfo, type EnabledProviderInfo, type EnabledProvidersResponse, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type FetchApiKeysResponse, type FetchDataResponse, type FetchFilesResponse, type FileItem, GameAPI, type GameAction, type GameClientConfig, type GameConnectionState, type GameConnectionStatus, type GameDelta, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GetAuthorizationURLRequest, type GetAuthorizationURLResponse, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinRoomRequest, type JoinRoomResponse, type ListBillingKeysResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MessageHandler, type MoveFileRequest, type OAuthCallbackRequest, type OAuthCallbackResponse, type OAuthProvider, type PauseSubscriptionRequest, type PaymentDetail, type PaymentStatus, type PeerInfo, type PlayerEvent, type Playlist, type PlaylistItem, type PongMessage, type PreparePaymentRequest, type PreparePaymentResponse, type PushPlatform, type QualityProgress, type QueryOptions, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RenameFileRequest, type RenameFileResponse, type RoomInfo, type RoomStats, type RoomsResponse, type SendOptions, type ServerMessage, type Shorts, type ShortsListResponse, type SignInRequest, type SignInResponse, type SignUpRequest, type SignUpResponse, type SignalingMessage, type SignalingMessageType, type StateChange, type StateChangeHandler, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type TableSchema, type TranscodeStatus, type TransportType, type UpdateApiKeyRequest, type UpdateApiKeyResponse, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateDataRequest, type UpdateSubscriptionRequest, type UpdateVideoRequest, type UploadFileResponse, type UploadOptions, type UploadProgress, type UserInfo, type VAPIDPublicKeyResponse, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoVisibility, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };
3317
+ export { type AnonymousSignInRequest, type AnonymousSignInResponse, type AnonymousSignUpResponse, ApiError, type ApiKeyItem, type AppStatsResponse, AuthError, type AuthSettingsResponse, type BillingCycle, type BillingKeyResponse, type BulkCreateResponse, type BulkError, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateChannelRequest, type CreateColumnRequest, type CreateDataRequest, type CreateFolderRequest, type CreateFolderResponse, type CreatePlaylistRequest, type CreateSubscriptionRequest, type CreateTableRequest, type DataItem, type DataType, type DeleteWhereResponse, type DeviceInfo, type EnabledProviderInfo, type EnabledProvidersResponse, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type FetchApiKeysResponse, type FetchDataResponse, type FetchFilesResponse, type FileItem, GameAPI, type GameAction, type GameClientConfig, type GameConnectionState, type GameConnectionStatus, type GameDelta, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GetAuthorizationURLResponse, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinRoomRequest, type JoinRoomResponse, type ListBillingKeysResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MessageHandler, type MoveFileRequest, type OAuthCallbackResponse, type OAuthProvider, type PauseSubscriptionRequest, type PaymentDetail, type PaymentStatus, type PeerInfo, type PlayerEvent, type Playlist, type PlaylistItem, type PongMessage, type PreparePaymentRequest, type PreparePaymentResponse, type PushPlatform, type QualityProgress, type QueryOptions, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RenameFileRequest, type RenameFileResponse, type RoomInfo, type RoomStats, type RoomsResponse, type SendOptions, type ServerMessage, type Shorts, type ShortsListResponse, type SignInRequest, type SignInResponse, type SignUpRequest, type SignUpResponse, type SignalingMessage, type SignalingMessageType, type StateChange, type StateChangeHandler, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type TableSchema, type TranscodeStatus, type TransportType, type UpdateApiKeyRequest, type UpdateApiKeyResponse, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateDataRequest, type UpdateSubscriptionRequest, type UpdateVideoRequest, type UploadFileResponse, type UploadOptions, type UploadProgress, type UserInfo, type VAPIDPublicKeyResponse, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoVisibility, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };
package/dist/index.js CHANGED
@@ -2026,167 +2026,6 @@ var OAuthAPI = class {
2026
2026
  async getEnabledProviders() {
2027
2027
  return this.http.get("/v1/public/oauth/providers");
2028
2028
  }
2029
- /**
2030
- * OAuth 인증 URL 조회
2031
- * 사용자를 소셜 로그인 페이지로 리다이렉트할 URL을 반환합니다.
2032
- *
2033
- * @param provider - OAuth 프로바이더 (google, naver, github, discord)
2034
- * @param options - redirect_uri와 선택적 state 파라미터
2035
- * @returns 인증 URL
2036
- *
2037
- * @example
2038
- * ```typescript
2039
- * const { authorization_url } = await cb.oauth.getAuthorizationURL('google', {
2040
- * redirect_uri: 'https://myapp.com/auth/callback'
2041
- * })
2042
- *
2043
- * // 사용자를 OAuth 페이지로 리다이렉트
2044
- * window.location.href = authorization_url
2045
- * ```
2046
- */
2047
- async getAuthorizationURL(provider, options) {
2048
- const params = new URLSearchParams({
2049
- redirect_uri: options.redirect_uri
2050
- });
2051
- if (options.state) {
2052
- params.append("state", options.state);
2053
- }
2054
- return this.http.get(
2055
- `/v1/public/oauth/${provider}/authorize?${params.toString()}`
2056
- );
2057
- }
2058
- /**
2059
- * OAuth 콜백 처리
2060
- * 소셜 로그인 후 콜백으로 받은 code를 사용하여 로그인을 완료합니다.
2061
- * 성공 시 자동으로 토큰이 저장됩니다.
2062
- *
2063
- * @param provider - OAuth 프로바이더
2064
- * @param data - code와 redirect_uri
2065
- * @returns 로그인 결과 (member_id, 토큰, 신규 회원 여부)
2066
- *
2067
- * @example
2068
- * ```typescript
2069
- * // 콜백 페이지에서 URL 파라미터로 code 추출
2070
- * const urlParams = new URLSearchParams(window.location.search)
2071
- * const code = urlParams.get('code')
2072
- *
2073
- * const result = await cb.oauth.handleCallback('google', {
2074
- * code: code,
2075
- * redirect_uri: 'https://myapp.com/auth/callback'
2076
- * })
2077
- *
2078
- * if (result.is_new_member) {
2079
- * console.log('신규 회원입니다!')
2080
- * }
2081
- * ```
2082
- */
2083
- async handleCallback(provider, data) {
2084
- const response = await this.http.post(
2085
- `/v1/public/oauth/${provider}/callback`,
2086
- data
2087
- );
2088
- this.http.setTokens(response.access_token, response.refresh_token);
2089
- return response;
2090
- }
2091
- /**
2092
- * 소셜 로그인 전체 플로우 (팝업 방식)
2093
- * 새 창에서 소셜 로그인을 처리하고 결과를 Promise로 반환합니다.
2094
- *
2095
- * @param provider - OAuth 프로바이더
2096
- * @param redirectUri - 콜백 URL (이 페이지에서 postMessage로 결과 전달 필요)
2097
- * @returns 로그인 결과
2098
- *
2099
- * @example
2100
- * ```typescript
2101
- * // 로그인 버튼 클릭 시
2102
- * const result = await cb.oauth.signInWithPopup('google', 'https://myapp.com/auth/popup-callback')
2103
- * console.log('로그인 성공:', result.member_id)
2104
- * ```
2105
- *
2106
- * @example
2107
- * ```html
2108
- * <!-- popup-callback.html -->
2109
- * <script>
2110
- * const urlParams = new URLSearchParams(window.location.search)
2111
- * const code = urlParams.get('code')
2112
- * const error = urlParams.get('error')
2113
- *
2114
- * window.opener.postMessage({
2115
- * type: 'oauth-callback',
2116
- * code,
2117
- * error
2118
- * }, '*')
2119
- * window.close()
2120
- * </script>
2121
- * ```
2122
- */
2123
- async signInWithPopup(provider, redirectUri) {
2124
- const { authorization_url } = await this.getAuthorizationURL(provider, {
2125
- redirect_uri: redirectUri
2126
- });
2127
- const width = 500;
2128
- const height = 600;
2129
- const left = window.screenX + (window.outerWidth - width) / 2;
2130
- const top = window.screenY + (window.outerHeight - height) / 2;
2131
- const popup = window.open(
2132
- authorization_url,
2133
- "oauth-popup",
2134
- `width=${width},height=${height},left=${left},top=${top}`
2135
- );
2136
- if (!popup) {
2137
- throw new Error("\uD31D\uC5C5\uC774 \uCC28\uB2E8\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uD31D\uC5C5 \uCC28\uB2E8\uC744 \uD574\uC81C\uD574\uC8FC\uC138\uC694.");
2138
- }
2139
- return new Promise((resolve, reject) => {
2140
- const handleMessage = async (event) => {
2141
- if (event.data?.type !== "oauth-callback") return;
2142
- window.removeEventListener("message", handleMessage);
2143
- if (event.data.error) {
2144
- reject(new Error(event.data.error));
2145
- return;
2146
- }
2147
- if (!event.data.code) {
2148
- reject(new Error("\uC778\uC99D \uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."));
2149
- return;
2150
- }
2151
- try {
2152
- const result = await this.handleCallback(provider, {
2153
- code: event.data.code,
2154
- redirect_uri: redirectUri
2155
- });
2156
- resolve(result);
2157
- } catch (error) {
2158
- reject(error);
2159
- }
2160
- };
2161
- window.addEventListener("message", handleMessage);
2162
- const checkClosed = setInterval(() => {
2163
- if (popup.closed) {
2164
- clearInterval(checkClosed);
2165
- window.removeEventListener("message", handleMessage);
2166
- reject(new Error("\uB85C\uADF8\uC778\uC774 \uCDE8\uC18C\uB418\uC5C8\uC2B5\uB2C8\uB2E4."));
2167
- }
2168
- }, 500);
2169
- });
2170
- }
2171
- /**
2172
- * 소셜 로그인 (리다이렉트 방식) - 기존 방식
2173
- * ⚠️ 이 방식은 Google Cloud Console에 redirect_uri를 등록해야 합니다.
2174
- * 대부분의 경우 signIn() 메서드 사용을 권장합니다.
2175
- *
2176
- * @param provider - OAuth 프로바이더
2177
- * @param redirectUri - 콜백 URL
2178
- * @deprecated signIn() 메서드 사용 권장 (Google Console 등록 불필요)
2179
- */
2180
- async signInWithRedirect(provider, redirectUri) {
2181
- const { authorization_url } = await this.getAuthorizationURL(provider, {
2182
- redirect_uri: redirectUri
2183
- });
2184
- window.location.href = authorization_url;
2185
- }
2186
- // ==========================================
2187
- // 중앙 콜백 방식 (권장)
2188
- // Google Cloud Console에 별도 redirect_uri 등록 불필요
2189
- // ==========================================
2190
2029
  /**
2191
2030
  * 소셜 로그인 (중앙 콜백 방식) - 권장
2192
2031
  * Google Cloud Console에 별도로 redirect_uri를 등록할 필요가 없습니다.
@@ -2229,7 +2068,7 @@ var OAuthAPI = class {
2229
2068
  window.location.href = response.authorization_url;
2230
2069
  }
2231
2070
  /**
2232
- * 소셜 로그인 (팝업 방식, 중앙 콜백) - 권장
2071
+ * 소셜 로그인 (팝업 방식)
2233
2072
  * 팝업 창에서 소셜 로그인을 처리하고 결과를 Promise로 반환합니다.
2234
2073
  * Google Cloud Console에 별도 등록 불필요.
2235
2074
  *
@@ -2259,7 +2098,7 @@ var OAuthAPI = class {
2259
2098
  * </script>
2260
2099
  * ```
2261
2100
  */
2262
- async signInWithPopupCentral(provider, callbackUrl) {
2101
+ async signInWithPopup(provider, callbackUrl) {
2263
2102
  const params = new URLSearchParams({ app_callback: callbackUrl });
2264
2103
  const response = await this.http.get(
2265
2104
  `/v1/public/oauth/${provider}/authorize/central?${params.toString()}`
package/dist/index.mjs CHANGED
@@ -1992,167 +1992,6 @@ var OAuthAPI = class {
1992
1992
  async getEnabledProviders() {
1993
1993
  return this.http.get("/v1/public/oauth/providers");
1994
1994
  }
1995
- /**
1996
- * OAuth 인증 URL 조회
1997
- * 사용자를 소셜 로그인 페이지로 리다이렉트할 URL을 반환합니다.
1998
- *
1999
- * @param provider - OAuth 프로바이더 (google, naver, github, discord)
2000
- * @param options - redirect_uri와 선택적 state 파라미터
2001
- * @returns 인증 URL
2002
- *
2003
- * @example
2004
- * ```typescript
2005
- * const { authorization_url } = await cb.oauth.getAuthorizationURL('google', {
2006
- * redirect_uri: 'https://myapp.com/auth/callback'
2007
- * })
2008
- *
2009
- * // 사용자를 OAuth 페이지로 리다이렉트
2010
- * window.location.href = authorization_url
2011
- * ```
2012
- */
2013
- async getAuthorizationURL(provider, options) {
2014
- const params = new URLSearchParams({
2015
- redirect_uri: options.redirect_uri
2016
- });
2017
- if (options.state) {
2018
- params.append("state", options.state);
2019
- }
2020
- return this.http.get(
2021
- `/v1/public/oauth/${provider}/authorize?${params.toString()}`
2022
- );
2023
- }
2024
- /**
2025
- * OAuth 콜백 처리
2026
- * 소셜 로그인 후 콜백으로 받은 code를 사용하여 로그인을 완료합니다.
2027
- * 성공 시 자동으로 토큰이 저장됩니다.
2028
- *
2029
- * @param provider - OAuth 프로바이더
2030
- * @param data - code와 redirect_uri
2031
- * @returns 로그인 결과 (member_id, 토큰, 신규 회원 여부)
2032
- *
2033
- * @example
2034
- * ```typescript
2035
- * // 콜백 페이지에서 URL 파라미터로 code 추출
2036
- * const urlParams = new URLSearchParams(window.location.search)
2037
- * const code = urlParams.get('code')
2038
- *
2039
- * const result = await cb.oauth.handleCallback('google', {
2040
- * code: code,
2041
- * redirect_uri: 'https://myapp.com/auth/callback'
2042
- * })
2043
- *
2044
- * if (result.is_new_member) {
2045
- * console.log('신규 회원입니다!')
2046
- * }
2047
- * ```
2048
- */
2049
- async handleCallback(provider, data) {
2050
- const response = await this.http.post(
2051
- `/v1/public/oauth/${provider}/callback`,
2052
- data
2053
- );
2054
- this.http.setTokens(response.access_token, response.refresh_token);
2055
- return response;
2056
- }
2057
- /**
2058
- * 소셜 로그인 전체 플로우 (팝업 방식)
2059
- * 새 창에서 소셜 로그인을 처리하고 결과를 Promise로 반환합니다.
2060
- *
2061
- * @param provider - OAuth 프로바이더
2062
- * @param redirectUri - 콜백 URL (이 페이지에서 postMessage로 결과 전달 필요)
2063
- * @returns 로그인 결과
2064
- *
2065
- * @example
2066
- * ```typescript
2067
- * // 로그인 버튼 클릭 시
2068
- * const result = await cb.oauth.signInWithPopup('google', 'https://myapp.com/auth/popup-callback')
2069
- * console.log('로그인 성공:', result.member_id)
2070
- * ```
2071
- *
2072
- * @example
2073
- * ```html
2074
- * <!-- popup-callback.html -->
2075
- * <script>
2076
- * const urlParams = new URLSearchParams(window.location.search)
2077
- * const code = urlParams.get('code')
2078
- * const error = urlParams.get('error')
2079
- *
2080
- * window.opener.postMessage({
2081
- * type: 'oauth-callback',
2082
- * code,
2083
- * error
2084
- * }, '*')
2085
- * window.close()
2086
- * </script>
2087
- * ```
2088
- */
2089
- async signInWithPopup(provider, redirectUri) {
2090
- const { authorization_url } = await this.getAuthorizationURL(provider, {
2091
- redirect_uri: redirectUri
2092
- });
2093
- const width = 500;
2094
- const height = 600;
2095
- const left = window.screenX + (window.outerWidth - width) / 2;
2096
- const top = window.screenY + (window.outerHeight - height) / 2;
2097
- const popup = window.open(
2098
- authorization_url,
2099
- "oauth-popup",
2100
- `width=${width},height=${height},left=${left},top=${top}`
2101
- );
2102
- if (!popup) {
2103
- throw new Error("\uD31D\uC5C5\uC774 \uCC28\uB2E8\uB418\uC5C8\uC2B5\uB2C8\uB2E4. \uD31D\uC5C5 \uCC28\uB2E8\uC744 \uD574\uC81C\uD574\uC8FC\uC138\uC694.");
2104
- }
2105
- return new Promise((resolve, reject) => {
2106
- const handleMessage = async (event) => {
2107
- if (event.data?.type !== "oauth-callback") return;
2108
- window.removeEventListener("message", handleMessage);
2109
- if (event.data.error) {
2110
- reject(new Error(event.data.error));
2111
- return;
2112
- }
2113
- if (!event.data.code) {
2114
- reject(new Error("\uC778\uC99D \uCF54\uB4DC\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4."));
2115
- return;
2116
- }
2117
- try {
2118
- const result = await this.handleCallback(provider, {
2119
- code: event.data.code,
2120
- redirect_uri: redirectUri
2121
- });
2122
- resolve(result);
2123
- } catch (error) {
2124
- reject(error);
2125
- }
2126
- };
2127
- window.addEventListener("message", handleMessage);
2128
- const checkClosed = setInterval(() => {
2129
- if (popup.closed) {
2130
- clearInterval(checkClosed);
2131
- window.removeEventListener("message", handleMessage);
2132
- reject(new Error("\uB85C\uADF8\uC778\uC774 \uCDE8\uC18C\uB418\uC5C8\uC2B5\uB2C8\uB2E4."));
2133
- }
2134
- }, 500);
2135
- });
2136
- }
2137
- /**
2138
- * 소셜 로그인 (리다이렉트 방식) - 기존 방식
2139
- * ⚠️ 이 방식은 Google Cloud Console에 redirect_uri를 등록해야 합니다.
2140
- * 대부분의 경우 signIn() 메서드 사용을 권장합니다.
2141
- *
2142
- * @param provider - OAuth 프로바이더
2143
- * @param redirectUri - 콜백 URL
2144
- * @deprecated signIn() 메서드 사용 권장 (Google Console 등록 불필요)
2145
- */
2146
- async signInWithRedirect(provider, redirectUri) {
2147
- const { authorization_url } = await this.getAuthorizationURL(provider, {
2148
- redirect_uri: redirectUri
2149
- });
2150
- window.location.href = authorization_url;
2151
- }
2152
- // ==========================================
2153
- // 중앙 콜백 방식 (권장)
2154
- // Google Cloud Console에 별도 redirect_uri 등록 불필요
2155
- // ==========================================
2156
1995
  /**
2157
1996
  * 소셜 로그인 (중앙 콜백 방식) - 권장
2158
1997
  * Google Cloud Console에 별도로 redirect_uri를 등록할 필요가 없습니다.
@@ -2195,7 +2034,7 @@ var OAuthAPI = class {
2195
2034
  window.location.href = response.authorization_url;
2196
2035
  }
2197
2036
  /**
2198
- * 소셜 로그인 (팝업 방식, 중앙 콜백) - 권장
2037
+ * 소셜 로그인 (팝업 방식)
2199
2038
  * 팝업 창에서 소셜 로그인을 처리하고 결과를 Promise로 반환합니다.
2200
2039
  * Google Cloud Console에 별도 등록 불필요.
2201
2040
  *
@@ -2225,7 +2064,7 @@ var OAuthAPI = class {
2225
2064
  * </script>
2226
2065
  * ```
2227
2066
  */
2228
- async signInWithPopupCentral(provider, callbackUrl) {
2067
+ async signInWithPopup(provider, callbackUrl) {
2229
2068
  const params = new URLSearchParams({ app_callback: callbackUrl });
2230
2069
  const response = await this.http.get(
2231
2070
  `/v1/public/oauth/${provider}/authorize/central?${params.toString()}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectbase-client",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,7 +31,8 @@
31
31
  "scripts": {
32
32
  "build": "tsup",
33
33
  "dev": "tsup --watch",
34
- "typecheck": "tsc --noEmit"
34
+ "typecheck": "tsc --noEmit",
35
+ "publish": "pnpm run build && npm publish --access public"
35
36
  },
36
37
  "keywords": [
37
38
  "connect-base",