connectbase-client 0.1.12 → 0.1.14
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 +2 -2
- package/dist/cli.js +14 -6
- package/dist/index.d.mts +5 -16
- package/dist/index.d.ts +5 -16
- package/dist/index.js +5 -16
- package/dist/index.mjs +5 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -352,8 +352,8 @@ const session = await cb.auth.signIn({
|
|
|
352
352
|
// OAuth login (리다이렉트 방식)
|
|
353
353
|
await cb.oauth.signIn('google', 'https://myapp.com/oauth/callback')
|
|
354
354
|
|
|
355
|
-
// OAuth login (팝업 방식)
|
|
356
|
-
const result = await cb.oauth.signInWithPopup('google', 'https://myapp.com/oauth/
|
|
355
|
+
// OAuth login (팝업 방식 - 동일한 콜백 URL 사용 가능)
|
|
356
|
+
const result = await cb.oauth.signInWithPopup('google', 'https://myapp.com/oauth/callback')
|
|
357
357
|
|
|
358
358
|
// Get current user
|
|
359
359
|
const user = await cb.auth.getCurrentUser()
|
package/dist/cli.js
CHANGED
|
@@ -165,19 +165,23 @@ function collectFiles(dir, baseDir = dir) {
|
|
|
165
165
|
}
|
|
166
166
|
return files;
|
|
167
167
|
}
|
|
168
|
-
function makeRequest(url, method, headers, body) {
|
|
168
|
+
async function makeRequest(url, method, headers, body) {
|
|
169
169
|
return new Promise((resolve2, reject) => {
|
|
170
170
|
const parsedUrl = new URL(url);
|
|
171
171
|
const isHttps = parsedUrl.protocol === "https:";
|
|
172
172
|
const lib = isHttps ? https : http;
|
|
173
|
+
const bodyBuffer = body ? Buffer.from(body, "utf-8") : null;
|
|
173
174
|
const options = {
|
|
174
175
|
hostname: parsedUrl.hostname,
|
|
175
176
|
port: parsedUrl.port || (isHttps ? 443 : 80),
|
|
176
177
|
path: parsedUrl.pathname + parsedUrl.search,
|
|
177
178
|
method,
|
|
179
|
+
family: 4,
|
|
180
|
+
autoSelectFamily: false,
|
|
178
181
|
headers: {
|
|
179
182
|
...headers,
|
|
180
|
-
"Content-Type": "application/json"
|
|
183
|
+
"Content-Type": "application/json",
|
|
184
|
+
...bodyBuffer ? { "Content-Length": bodyBuffer.length } : {}
|
|
181
185
|
}
|
|
182
186
|
};
|
|
183
187
|
const req = lib.request(options, (res) => {
|
|
@@ -194,9 +198,12 @@ function makeRequest(url, method, headers, body) {
|
|
|
194
198
|
}
|
|
195
199
|
});
|
|
196
200
|
});
|
|
201
|
+
req.setTimeout(6e4, () => {
|
|
202
|
+
req.destroy(new Error("\uC694\uCCAD \uC2DC\uAC04 \uCD08\uACFC (60\uCD08)"));
|
|
203
|
+
});
|
|
197
204
|
req.on("error", reject);
|
|
198
|
-
if (
|
|
199
|
-
req.write(
|
|
205
|
+
if (bodyBuffer) {
|
|
206
|
+
req.write(bodyBuffer);
|
|
200
207
|
}
|
|
201
208
|
req.end();
|
|
202
209
|
});
|
|
@@ -223,7 +230,7 @@ async function deploy(directory, config) {
|
|
|
223
230
|
process.exit(1);
|
|
224
231
|
}
|
|
225
232
|
log(`${colors.dim}${files.length}\uAC1C \uD30C\uC77C \uBC1C\uACAC${colors.reset}`);
|
|
226
|
-
const url = `${config.baseUrl}/v1/storages/webs/${config.storageId}/deploy`;
|
|
233
|
+
const url = `${config.baseUrl}/v1/public/storages/webs/${config.storageId}/deploy`;
|
|
227
234
|
info("\uBC30\uD3EC \uC911...");
|
|
228
235
|
try {
|
|
229
236
|
const response = await makeRequest(
|
|
@@ -250,7 +257,8 @@ ${colors.cyan}URL: ${data.url}${colors.reset}
|
|
|
250
257
|
}
|
|
251
258
|
} else {
|
|
252
259
|
const data = response.data;
|
|
253
|
-
|
|
260
|
+
const errorMsg = typeof data === "object" && data !== null ? data.message || data.error || JSON.stringify(data) : typeof data === "string" ? data : `HTTP ${response.status}`;
|
|
261
|
+
error(`\uBC30\uD3EC \uC2E4\uD328: ${errorMsg}`);
|
|
254
262
|
process.exit(1);
|
|
255
263
|
}
|
|
256
264
|
} catch (err) {
|
package/dist/index.d.mts
CHANGED
|
@@ -1359,25 +1359,14 @@ declare class OAuthAPI {
|
|
|
1359
1359
|
*
|
|
1360
1360
|
* @example
|
|
1361
1361
|
* ```typescript
|
|
1362
|
-
*
|
|
1362
|
+
* // 리다이렉트 방식과 동일한 콜백 URL 사용 가능
|
|
1363
|
+
* const result = await cb.oauth.signInWithPopup('google', 'https://myapp.com/oauth/callback')
|
|
1363
1364
|
* console.log('로그인 성공:', result.member_id)
|
|
1364
1365
|
* ```
|
|
1365
1366
|
*
|
|
1366
|
-
*
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1369
|
-
* <script src="https://unpkg.com/connectbase-client"></script>
|
|
1370
|
-
* <script>
|
|
1371
|
-
* const cb = new ConnectBase({ apiKey: 'YOUR_API_KEY' })
|
|
1372
|
-
* const result = cb.oauth.getCallbackResult()
|
|
1373
|
-
*
|
|
1374
|
-
* window.opener.postMessage({
|
|
1375
|
-
* type: 'oauth-callback',
|
|
1376
|
-
* ...result
|
|
1377
|
-
* }, '*')
|
|
1378
|
-
* window.close()
|
|
1379
|
-
* </script>
|
|
1380
|
-
* ```
|
|
1367
|
+
* 콜백 페이지에서 `getCallbackResult()`를 호출하면 팝업 여부를 자동 감지합니다:
|
|
1368
|
+
* - 팝업: 부모 창에 결과 전달 후 자동 닫힘
|
|
1369
|
+
* - 리다이렉트: 토큰 저장 후 결과 반환
|
|
1381
1370
|
*/
|
|
1382
1371
|
signInWithPopup(provider: OAuthProvider, callbackUrl: string): Promise<OAuthCallbackResponse>;
|
|
1383
1372
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1359,25 +1359,14 @@ declare class OAuthAPI {
|
|
|
1359
1359
|
*
|
|
1360
1360
|
* @example
|
|
1361
1361
|
* ```typescript
|
|
1362
|
-
*
|
|
1362
|
+
* // 리다이렉트 방식과 동일한 콜백 URL 사용 가능
|
|
1363
|
+
* const result = await cb.oauth.signInWithPopup('google', 'https://myapp.com/oauth/callback')
|
|
1363
1364
|
* console.log('로그인 성공:', result.member_id)
|
|
1364
1365
|
* ```
|
|
1365
1366
|
*
|
|
1366
|
-
*
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1369
|
-
* <script src="https://unpkg.com/connectbase-client"></script>
|
|
1370
|
-
* <script>
|
|
1371
|
-
* const cb = new ConnectBase({ apiKey: 'YOUR_API_KEY' })
|
|
1372
|
-
* const result = cb.oauth.getCallbackResult()
|
|
1373
|
-
*
|
|
1374
|
-
* window.opener.postMessage({
|
|
1375
|
-
* type: 'oauth-callback',
|
|
1376
|
-
* ...result
|
|
1377
|
-
* }, '*')
|
|
1378
|
-
* window.close()
|
|
1379
|
-
* </script>
|
|
1380
|
-
* ```
|
|
1367
|
+
* 콜백 페이지에서 `getCallbackResult()`를 호출하면 팝업 여부를 자동 감지합니다:
|
|
1368
|
+
* - 팝업: 부모 창에 결과 전달 후 자동 닫힘
|
|
1369
|
+
* - 리다이렉트: 토큰 저장 후 결과 반환
|
|
1381
1370
|
*/
|
|
1382
1371
|
signInWithPopup(provider: OAuthProvider, callbackUrl: string): Promise<OAuthCallbackResponse>;
|
|
1383
1372
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2078,25 +2078,14 @@ var OAuthAPI = class {
|
|
|
2078
2078
|
*
|
|
2079
2079
|
* @example
|
|
2080
2080
|
* ```typescript
|
|
2081
|
-
*
|
|
2081
|
+
* // 리다이렉트 방식과 동일한 콜백 URL 사용 가능
|
|
2082
|
+
* const result = await cb.oauth.signInWithPopup('google', 'https://myapp.com/oauth/callback')
|
|
2082
2083
|
* console.log('로그인 성공:', result.member_id)
|
|
2083
2084
|
* ```
|
|
2084
2085
|
*
|
|
2085
|
-
*
|
|
2086
|
-
*
|
|
2087
|
-
*
|
|
2088
|
-
* <script src="https://unpkg.com/connectbase-client"></script>
|
|
2089
|
-
* <script>
|
|
2090
|
-
* const cb = new ConnectBase({ apiKey: 'YOUR_API_KEY' })
|
|
2091
|
-
* const result = cb.oauth.getCallbackResult()
|
|
2092
|
-
*
|
|
2093
|
-
* window.opener.postMessage({
|
|
2094
|
-
* type: 'oauth-callback',
|
|
2095
|
-
* ...result
|
|
2096
|
-
* }, '*')
|
|
2097
|
-
* window.close()
|
|
2098
|
-
* </script>
|
|
2099
|
-
* ```
|
|
2086
|
+
* 콜백 페이지에서 `getCallbackResult()`를 호출하면 팝업 여부를 자동 감지합니다:
|
|
2087
|
+
* - 팝업: 부모 창에 결과 전달 후 자동 닫힘
|
|
2088
|
+
* - 리다이렉트: 토큰 저장 후 결과 반환
|
|
2100
2089
|
*/
|
|
2101
2090
|
async signInWithPopup(provider, callbackUrl) {
|
|
2102
2091
|
const params = new URLSearchParams({ app_callback: callbackUrl });
|
package/dist/index.mjs
CHANGED
|
@@ -2044,25 +2044,14 @@ var OAuthAPI = class {
|
|
|
2044
2044
|
*
|
|
2045
2045
|
* @example
|
|
2046
2046
|
* ```typescript
|
|
2047
|
-
*
|
|
2047
|
+
* // 리다이렉트 방식과 동일한 콜백 URL 사용 가능
|
|
2048
|
+
* const result = await cb.oauth.signInWithPopup('google', 'https://myapp.com/oauth/callback')
|
|
2048
2049
|
* console.log('로그인 성공:', result.member_id)
|
|
2049
2050
|
* ```
|
|
2050
2051
|
*
|
|
2051
|
-
*
|
|
2052
|
-
*
|
|
2053
|
-
*
|
|
2054
|
-
* <script src="https://unpkg.com/connectbase-client"></script>
|
|
2055
|
-
* <script>
|
|
2056
|
-
* const cb = new ConnectBase({ apiKey: 'YOUR_API_KEY' })
|
|
2057
|
-
* const result = cb.oauth.getCallbackResult()
|
|
2058
|
-
*
|
|
2059
|
-
* window.opener.postMessage({
|
|
2060
|
-
* type: 'oauth-callback',
|
|
2061
|
-
* ...result
|
|
2062
|
-
* }, '*')
|
|
2063
|
-
* window.close()
|
|
2064
|
-
* </script>
|
|
2065
|
-
* ```
|
|
2052
|
+
* 콜백 페이지에서 `getCallbackResult()`를 호출하면 팝업 여부를 자동 감지합니다:
|
|
2053
|
+
* - 팝업: 부모 창에 결과 전달 후 자동 닫힘
|
|
2054
|
+
* - 리다이렉트: 토큰 저장 후 결과 반환
|
|
2066
2055
|
*/
|
|
2067
2056
|
async signInWithPopup(provider, callbackUrl) {
|
|
2068
2057
|
const params = new URLSearchParams({ app_callback: callbackUrl });
|