connectbase-client 3.2.0 → 3.2.1
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/CHANGELOG.md +29 -4
- package/README.md +29 -11
- package/dist/index.d.mts +21 -9
- package/dist/index.d.ts +21 -9
- package/dist/index.js +21 -9
- package/dist/index.mjs +21 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
본 SDK 의 모든 주요 변경사항을 [Keep a Changelog](https://keepachangelog.com/ko/1.1.0/) 형식으로 기록합니다.
|
|
4
4
|
버전은 [Semantic Versioning](https://semver.org/lang/ko/) 을 따릅니다.
|
|
5
5
|
|
|
6
|
+
## [3.2.1] - 2026-04-29
|
|
7
|
+
|
|
8
|
+
### Fixed — Docs
|
|
9
|
+
|
|
10
|
+
`cb.endpoint.url(label, path)` 의 README/JSDoc 예제와 CHANGELOG `[3.2.0]` 설명을
|
|
11
|
+
ConnectBase 프록시 인증 모델에 맞춰 정정. 코드 동작 변화 없음 (JSDoc / README /
|
|
12
|
+
CHANGELOG 만 수정).
|
|
13
|
+
|
|
14
|
+
- 3.2.0 의 `<img src={cb.endpoint.url(...)}>` / `new WebSocket(cb.endpoint.url(...))`
|
|
15
|
+
예제는 실제로는 401 — `/v1/proxy/:label/*` 가 `X-Public-Key` 헤더를 강제하고
|
|
16
|
+
쿼리 파라미터 폴백이 없어, 커스텀 헤더를 못 보내는 브라우저 네이티브 API
|
|
17
|
+
(`<img>`, native `WebSocket`, `<script src>`, `EventSource`) 는 인증 자체가
|
|
18
|
+
불가능. 잘못된 시연 코드를 제거.
|
|
19
|
+
- 정정된 사용 사례:
|
|
20
|
+
- **이미지 렌더링**: `cb.endpoint.call(...)` 로 받아
|
|
21
|
+
`URL.createObjectURL(await res.blob())` 패턴 사용. 영구 URL 이 필요하면
|
|
22
|
+
`cb.storage.uploadByPath` 로 업로드.
|
|
23
|
+
- **URL 전달**: Service Worker / 백엔드 워커 / 커스텀 fetch wrapper 처럼 호출자가
|
|
24
|
+
`X-Public-Key` 헤더를 직접 부착할 수 있는 환경.
|
|
25
|
+
- **로깅·디버깅**: 라벨 → 최종 URL 매핑 확인.
|
|
26
|
+
- `EndpointAPI` 클래스 / `cb.endpoint.{call,url,pollUntil}` 동작은 3.2.0 과 동일.
|
|
27
|
+
|
|
6
28
|
## [3.2.0] - 2026-04-29
|
|
7
29
|
|
|
8
30
|
### Added — Endpoint API 헬퍼 (`pollUntil` / `url`)
|
|
@@ -16,10 +38,13 @@ ComfyUI × 웹스토리지 같은 e2e 통합 패턴 (작업 제출 → 폴링
|
|
|
16
38
|
"작업 제출 → 폴링" 패턴 전용. `predicate` 가 값을 반환할 때까지 반복 호출,
|
|
17
39
|
HTTP 5xx/네트워크 오류는 재시도, 4xx 는 즉시 reject, `AbortSignal`/`timeoutMs`
|
|
18
40
|
지원. `parse: "json" | "text" | "none"` 으로 본문 파싱 방식 선택.
|
|
19
|
-
- **`cb.endpoint.url(label, path)`** — 라벨 + path 의 최종 호출 URL
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
41
|
+
- **`cb.endpoint.url(label, path)`** — 라벨 + path 의 최종 호출 URL
|
|
42
|
+
(`${baseUrl}/v1/proxy/${label}${path}`) 만 조립해서 반환. URL 을 Service
|
|
43
|
+
Worker / 백엔드 워커로 넘기거나 로깅·디버깅 용도. ⚠️ `<img src>` / 네이티브
|
|
44
|
+
`WebSocket` / `<script src>` / `EventSource` 처럼 커스텀 헤더를 못 보내는
|
|
45
|
+
브라우저 API 에 직접 넘기면 401 — ConnectBase 프록시는 항상 `X-Public-Key`
|
|
46
|
+
헤더를 요구하고 쿼리 파라미터 폴백이 없음. 그 경우엔 `call()` 로 받아
|
|
47
|
+
`URL.createObjectURL(await res.blob())` 패턴 사용.
|
|
23
48
|
- 신규 export: `PollUntilOptions` 타입.
|
|
24
49
|
|
|
25
50
|
### Docs
|
package/README.md
CHANGED
|
@@ -929,23 +929,41 @@ const filename = await cb.endpoint.pollUntil<string>(
|
|
|
929
929
|
|
|
930
930
|
#### `cb.endpoint.url(label, path): string`
|
|
931
931
|
|
|
932
|
-
Returns the assembled call URL (`${baseUrl}/v1/proxy/${label}${path}`) for
|
|
933
|
-
|
|
934
|
-
`
|
|
932
|
+
Returns the assembled call URL (`${baseUrl}/v1/proxy/${label}${path}`) for
|
|
933
|
+
URL-passing scenarios where you control the request and can attach the
|
|
934
|
+
`X-Public-Key` header yourself.
|
|
935
935
|
|
|
936
|
-
⚠️
|
|
937
|
-
|
|
938
|
-
|
|
936
|
+
⚠️ **Browser-native APIs that cannot set custom headers will fail with `401`.**
|
|
937
|
+
ConnectBase's proxy requires `X-Public-Key` on every call (header-only — no
|
|
938
|
+
`?api_key=` fallback), so `<img src>`, `new Image()`, native `WebSocket`,
|
|
939
|
+
`<script src>`, EventSource, etc. **cannot authenticate** through this URL.
|
|
940
|
+
Use `cb.endpoint.call()` instead for those cases:
|
|
939
941
|
|
|
940
942
|
```typescript
|
|
941
|
-
// Render
|
|
942
|
-
|
|
943
|
-
|
|
943
|
+
// ✅ Render an image: download via call(), then convert to a blob URL
|
|
944
|
+
const res = await cb.endpoint.call('comfyui-main', {
|
|
945
|
+
path: `/view?filename=${encodeURIComponent(name)}`,
|
|
946
|
+
})
|
|
947
|
+
img.src = URL.createObjectURL(await res.blob())
|
|
948
|
+
// ...later: URL.revokeObjectURL(img.src)
|
|
944
949
|
```
|
|
945
950
|
|
|
951
|
+
For permanent images (works across CDN, survives tunnel restarts), upload the
|
|
952
|
+
blob to `cb.storage` and use `saved.url` — see
|
|
953
|
+
[`examples/ai-image-generator/`](https://github.com/connectbase-world/connectbase/tree/release/examples/ai-image-generator).
|
|
954
|
+
|
|
955
|
+
When `cb.endpoint.url()` IS the right tool:
|
|
956
|
+
|
|
957
|
+
- Logging / debugging the resolved tunnel URL
|
|
958
|
+
- Passing the URL to a backend service or worker that will make the call with proper headers
|
|
959
|
+
- Building a `RequestInfo` for a custom `fetch()` wrapper (you control headers)
|
|
960
|
+
|
|
946
961
|
```typescript
|
|
947
|
-
|
|
948
|
-
|
|
962
|
+
console.log(cb.endpoint.url('comfyui-main', '/prompt'))
|
|
963
|
+
// → https://api.connectbase.world/v1/proxy/comfyui-main/prompt
|
|
964
|
+
|
|
965
|
+
// Hand the URL to a Service Worker that injects X-Public-Key
|
|
966
|
+
sw.postMessage({ url: cb.endpoint.url('comfyui-main', '/prompt'), key: PK })
|
|
949
967
|
```
|
|
950
968
|
|
|
951
969
|
### Push Notifications
|
package/dist/index.d.mts
CHANGED
|
@@ -6772,18 +6772,30 @@ declare class EndpointAPI {
|
|
|
6772
6772
|
*/
|
|
6773
6773
|
call(label: string, init: EndpointCallInit): Promise<Response>;
|
|
6774
6774
|
/**
|
|
6775
|
-
* 라벨 + path 의 최종 호출 URL
|
|
6776
|
-
*
|
|
6775
|
+
* 라벨 + path 의 최종 호출 URL `${baseUrl}/v1/proxy/${label}${path}` 을 조립해서
|
|
6776
|
+
* 반환. URL 을 다른 시스템 (Service Worker, 백엔드 워커, 로깅) 에 넘기거나
|
|
6777
|
+
* 디버깅 용도일 때 사용.
|
|
6777
6778
|
*
|
|
6778
|
-
*
|
|
6779
|
-
*
|
|
6780
|
-
*
|
|
6779
|
+
* ⚠️ **`<img src>` / 네이티브 `WebSocket` / `<script src>` / `EventSource` 처럼
|
|
6780
|
+
* 커스텀 헤더를 못 보내는 브라우저 API 에 직접 넘기면 401 입니다.** ConnectBase
|
|
6781
|
+
* 프록시는 모든 요청에 `X-Public-Key` 헤더를 요구하고, 쿼리 파라미터 폴백은
|
|
6782
|
+
* 제공하지 않습니다. 그런 경우엔 `call()` 로 받아서 Blob URL 로 변환하세요.
|
|
6781
6783
|
*
|
|
6782
|
-
* @example
|
|
6784
|
+
* @example URL 을 워커로 넘겨 호출 (✅)
|
|
6785
|
+
* ```typescript
|
|
6786
|
+
* sw.postMessage({
|
|
6787
|
+
* url: cb.endpoint.url("comfyui-main", "/prompt"),
|
|
6788
|
+
* key: publicKey, // 워커가 X-Public-Key 헤더로 부착
|
|
6789
|
+
* })
|
|
6790
|
+
* ```
|
|
6791
|
+
*
|
|
6792
|
+
* @example 이미지 렌더링은 call() + Blob URL 패턴으로 (✅)
|
|
6783
6793
|
* ```typescript
|
|
6784
|
-
*
|
|
6785
|
-
*
|
|
6786
|
-
*
|
|
6794
|
+
* const res = await cb.endpoint.call("comfyui-main", {
|
|
6795
|
+
* path: `/view?filename=${encodeURIComponent(name)}`,
|
|
6796
|
+
* })
|
|
6797
|
+
* img.src = URL.createObjectURL(await res.blob())
|
|
6798
|
+
* // 나중에 URL.revokeObjectURL(img.src)
|
|
6787
6799
|
* ```
|
|
6788
6800
|
*/
|
|
6789
6801
|
url(label: string, path: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -6772,18 +6772,30 @@ declare class EndpointAPI {
|
|
|
6772
6772
|
*/
|
|
6773
6773
|
call(label: string, init: EndpointCallInit): Promise<Response>;
|
|
6774
6774
|
/**
|
|
6775
|
-
* 라벨 + path 의 최종 호출 URL
|
|
6776
|
-
*
|
|
6775
|
+
* 라벨 + path 의 최종 호출 URL `${baseUrl}/v1/proxy/${label}${path}` 을 조립해서
|
|
6776
|
+
* 반환. URL 을 다른 시스템 (Service Worker, 백엔드 워커, 로깅) 에 넘기거나
|
|
6777
|
+
* 디버깅 용도일 때 사용.
|
|
6777
6778
|
*
|
|
6778
|
-
*
|
|
6779
|
-
*
|
|
6780
|
-
*
|
|
6779
|
+
* ⚠️ **`<img src>` / 네이티브 `WebSocket` / `<script src>` / `EventSource` 처럼
|
|
6780
|
+
* 커스텀 헤더를 못 보내는 브라우저 API 에 직접 넘기면 401 입니다.** ConnectBase
|
|
6781
|
+
* 프록시는 모든 요청에 `X-Public-Key` 헤더를 요구하고, 쿼리 파라미터 폴백은
|
|
6782
|
+
* 제공하지 않습니다. 그런 경우엔 `call()` 로 받아서 Blob URL 로 변환하세요.
|
|
6781
6783
|
*
|
|
6782
|
-
* @example
|
|
6784
|
+
* @example URL 을 워커로 넘겨 호출 (✅)
|
|
6785
|
+
* ```typescript
|
|
6786
|
+
* sw.postMessage({
|
|
6787
|
+
* url: cb.endpoint.url("comfyui-main", "/prompt"),
|
|
6788
|
+
* key: publicKey, // 워커가 X-Public-Key 헤더로 부착
|
|
6789
|
+
* })
|
|
6790
|
+
* ```
|
|
6791
|
+
*
|
|
6792
|
+
* @example 이미지 렌더링은 call() + Blob URL 패턴으로 (✅)
|
|
6783
6793
|
* ```typescript
|
|
6784
|
-
*
|
|
6785
|
-
*
|
|
6786
|
-
*
|
|
6794
|
+
* const res = await cb.endpoint.call("comfyui-main", {
|
|
6795
|
+
* path: `/view?filename=${encodeURIComponent(name)}`,
|
|
6796
|
+
* })
|
|
6797
|
+
* img.src = URL.createObjectURL(await res.blob())
|
|
6798
|
+
* // 나중에 URL.revokeObjectURL(img.src)
|
|
6787
6799
|
* ```
|
|
6788
6800
|
*/
|
|
6789
6801
|
url(label: string, path: string): string;
|
package/dist/index.js
CHANGED
|
@@ -7718,18 +7718,30 @@ var EndpointAPI = class {
|
|
|
7718
7718
|
});
|
|
7719
7719
|
}
|
|
7720
7720
|
/**
|
|
7721
|
-
* 라벨 + path 의 최종 호출 URL
|
|
7722
|
-
*
|
|
7721
|
+
* 라벨 + path 의 최종 호출 URL `${baseUrl}/v1/proxy/${label}${path}` 을 조립해서
|
|
7722
|
+
* 반환. URL 을 다른 시스템 (Service Worker, 백엔드 워커, 로깅) 에 넘기거나
|
|
7723
|
+
* 디버깅 용도일 때 사용.
|
|
7723
7724
|
*
|
|
7724
|
-
*
|
|
7725
|
-
*
|
|
7726
|
-
*
|
|
7725
|
+
* ⚠️ **`<img src>` / 네이티브 `WebSocket` / `<script src>` / `EventSource` 처럼
|
|
7726
|
+
* 커스텀 헤더를 못 보내는 브라우저 API 에 직접 넘기면 401 입니다.** ConnectBase
|
|
7727
|
+
* 프록시는 모든 요청에 `X-Public-Key` 헤더를 요구하고, 쿼리 파라미터 폴백은
|
|
7728
|
+
* 제공하지 않습니다. 그런 경우엔 `call()` 로 받아서 Blob URL 로 변환하세요.
|
|
7727
7729
|
*
|
|
7728
|
-
* @example
|
|
7730
|
+
* @example URL 을 워커로 넘겨 호출 (✅)
|
|
7731
|
+
* ```typescript
|
|
7732
|
+
* sw.postMessage({
|
|
7733
|
+
* url: cb.endpoint.url("comfyui-main", "/prompt"),
|
|
7734
|
+
* key: publicKey, // 워커가 X-Public-Key 헤더로 부착
|
|
7735
|
+
* })
|
|
7736
|
+
* ```
|
|
7737
|
+
*
|
|
7738
|
+
* @example 이미지 렌더링은 call() + Blob URL 패턴으로 (✅)
|
|
7729
7739
|
* ```typescript
|
|
7730
|
-
*
|
|
7731
|
-
*
|
|
7732
|
-
*
|
|
7740
|
+
* const res = await cb.endpoint.call("comfyui-main", {
|
|
7741
|
+
* path: `/view?filename=${encodeURIComponent(name)}`,
|
|
7742
|
+
* })
|
|
7743
|
+
* img.src = URL.createObjectURL(await res.blob())
|
|
7744
|
+
* // 나중에 URL.revokeObjectURL(img.src)
|
|
7733
7745
|
* ```
|
|
7734
7746
|
*/
|
|
7735
7747
|
url(label, path) {
|
package/dist/index.mjs
CHANGED
|
@@ -7679,18 +7679,30 @@ var EndpointAPI = class {
|
|
|
7679
7679
|
});
|
|
7680
7680
|
}
|
|
7681
7681
|
/**
|
|
7682
|
-
* 라벨 + path 의 최종 호출 URL
|
|
7683
|
-
*
|
|
7682
|
+
* 라벨 + path 의 최종 호출 URL `${baseUrl}/v1/proxy/${label}${path}` 을 조립해서
|
|
7683
|
+
* 반환. URL 을 다른 시스템 (Service Worker, 백엔드 워커, 로깅) 에 넘기거나
|
|
7684
|
+
* 디버깅 용도일 때 사용.
|
|
7684
7685
|
*
|
|
7685
|
-
*
|
|
7686
|
-
*
|
|
7687
|
-
*
|
|
7686
|
+
* ⚠️ **`<img src>` / 네이티브 `WebSocket` / `<script src>` / `EventSource` 처럼
|
|
7687
|
+
* 커스텀 헤더를 못 보내는 브라우저 API 에 직접 넘기면 401 입니다.** ConnectBase
|
|
7688
|
+
* 프록시는 모든 요청에 `X-Public-Key` 헤더를 요구하고, 쿼리 파라미터 폴백은
|
|
7689
|
+
* 제공하지 않습니다. 그런 경우엔 `call()` 로 받아서 Blob URL 로 변환하세요.
|
|
7688
7690
|
*
|
|
7689
|
-
* @example
|
|
7691
|
+
* @example URL 을 워커로 넘겨 호출 (✅)
|
|
7692
|
+
* ```typescript
|
|
7693
|
+
* sw.postMessage({
|
|
7694
|
+
* url: cb.endpoint.url("comfyui-main", "/prompt"),
|
|
7695
|
+
* key: publicKey, // 워커가 X-Public-Key 헤더로 부착
|
|
7696
|
+
* })
|
|
7697
|
+
* ```
|
|
7698
|
+
*
|
|
7699
|
+
* @example 이미지 렌더링은 call() + Blob URL 패턴으로 (✅)
|
|
7690
7700
|
* ```typescript
|
|
7691
|
-
*
|
|
7692
|
-
*
|
|
7693
|
-
*
|
|
7701
|
+
* const res = await cb.endpoint.call("comfyui-main", {
|
|
7702
|
+
* path: `/view?filename=${encodeURIComponent(name)}`,
|
|
7703
|
+
* })
|
|
7704
|
+
* img.src = URL.createObjectURL(await res.blob())
|
|
7705
|
+
* // 나중에 URL.revokeObjectURL(img.src)
|
|
7694
7706
|
* ```
|
|
7695
7707
|
*/
|
|
7696
7708
|
url(label, path) {
|