connectbase-client 3.2.0 → 3.3.0
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 +64 -4
- package/README.md +29 -11
- package/dist/connect-base.umd.js +3 -3
- package/dist/index.d.mts +97 -10
- package/dist/index.d.ts +97 -10
- package/dist/index.js +81 -9
- package/dist/index.mjs +80 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,63 @@
|
|
|
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.3.0] - 2026-04-30
|
|
7
|
+
|
|
8
|
+
### Added — `cb.game.config` (게임 기능 opt-in 토글)
|
|
9
|
+
|
|
10
|
+
게임 서버 v3.1 의 7개 기능 (matchqueue / leaderboard / entity / scripts / voice / replay /
|
|
11
|
+
spectator) 이 모두 앱 단위 명시적 opt-in 정책으로 전환됨에 따라, 콘솔 / 외부 도구가
|
|
12
|
+
토글 상태를 조회/변경할 수 있는 SDK 헬퍼 신규 추가.
|
|
13
|
+
|
|
14
|
+
- **`cb.game.config.get(appId?)`** — 현재 7개 토글 상태 + `legacy_defaults` 플래그.
|
|
15
|
+
row 가 없는 기존 앱은 모든 기능 ON 상태로 응답 (서비스 단절 방지). `legacy_defaults=true`
|
|
16
|
+
를 받으면 backfill 권장.
|
|
17
|
+
- **`cb.game.config.set(appId, patch)`** / **`cb.game.config.set(patch)`** — partial
|
|
18
|
+
update. 보낸 필드만 갱신, 나머지는 보존. PATCH 직후 game-server 캐시는 NATS
|
|
19
|
+
publish 로 즉시 무효화 (또는 30s TTL).
|
|
20
|
+
- **`cb.game.config.enable(appId, feature)`** / **`disable(appId, feature)`** —
|
|
21
|
+
단일 토글 편의 wrapper.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
const cfg = await cb.game.config.get(appId)
|
|
25
|
+
if (!cfg.matchqueue_enabled) {
|
|
26
|
+
await cb.game.config.set(appId, { matchqueue_enabled: true, leaderboard_enabled: true })
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
신규 앱은 모든 기능 OFF 가 기본값. 사용 안 하는 앱은 noisy-neighbor / 의도치 않은
|
|
31
|
+
quota 소비에서 격리됨.
|
|
32
|
+
|
|
33
|
+
자세한 정책: [docs/game-server/OPT_IN.md](https://github.com/connectbase-world/connectbase/blob/release/docs/game-server/OPT_IN.md)
|
|
34
|
+
|
|
35
|
+
### Behavior — 비활성 기능 호출 시 응답 변화
|
|
36
|
+
|
|
37
|
+
본 버전부터, 비활성 feature 의 HTTP 호출은 **HTTP 403 + `{error: "feature_disabled", feature, hint}`**
|
|
38
|
+
를 반환. 기존 SDK 호출 코드는 catch 에서 status 403 + error 코드를 분기해 사용자에게
|
|
39
|
+
"콘솔에서 켜주세요" 메시지를 표시하는 게 권장됩니다.
|
|
40
|
+
|
|
41
|
+
## [3.2.1] - 2026-04-29
|
|
42
|
+
|
|
43
|
+
### Fixed — Docs
|
|
44
|
+
|
|
45
|
+
`cb.endpoint.url(label, path)` 의 README/JSDoc 예제와 CHANGELOG `[3.2.0]` 설명을
|
|
46
|
+
ConnectBase 프록시 인증 모델에 맞춰 정정. 코드 동작 변화 없음 (JSDoc / README /
|
|
47
|
+
CHANGELOG 만 수정).
|
|
48
|
+
|
|
49
|
+
- 3.2.0 의 `<img src={cb.endpoint.url(...)}>` / `new WebSocket(cb.endpoint.url(...))`
|
|
50
|
+
예제는 실제로는 401 — `/v1/proxy/:label/*` 가 `X-Public-Key` 헤더를 강제하고
|
|
51
|
+
쿼리 파라미터 폴백이 없어, 커스텀 헤더를 못 보내는 브라우저 네이티브 API
|
|
52
|
+
(`<img>`, native `WebSocket`, `<script src>`, `EventSource`) 는 인증 자체가
|
|
53
|
+
불가능. 잘못된 시연 코드를 제거.
|
|
54
|
+
- 정정된 사용 사례:
|
|
55
|
+
- **이미지 렌더링**: `cb.endpoint.call(...)` 로 받아
|
|
56
|
+
`URL.createObjectURL(await res.blob())` 패턴 사용. 영구 URL 이 필요하면
|
|
57
|
+
`cb.storage.uploadByPath` 로 업로드.
|
|
58
|
+
- **URL 전달**: Service Worker / 백엔드 워커 / 커스텀 fetch wrapper 처럼 호출자가
|
|
59
|
+
`X-Public-Key` 헤더를 직접 부착할 수 있는 환경.
|
|
60
|
+
- **로깅·디버깅**: 라벨 → 최종 URL 매핑 확인.
|
|
61
|
+
- `EndpointAPI` 클래스 / `cb.endpoint.{call,url,pollUntil}` 동작은 3.2.0 과 동일.
|
|
62
|
+
|
|
6
63
|
## [3.2.0] - 2026-04-29
|
|
7
64
|
|
|
8
65
|
### Added — Endpoint API 헬퍼 (`pollUntil` / `url`)
|
|
@@ -16,10 +73,13 @@ ComfyUI × 웹스토리지 같은 e2e 통합 패턴 (작업 제출 → 폴링
|
|
|
16
73
|
"작업 제출 → 폴링" 패턴 전용. `predicate` 가 값을 반환할 때까지 반복 호출,
|
|
17
74
|
HTTP 5xx/네트워크 오류는 재시도, 4xx 는 즉시 reject, `AbortSignal`/`timeoutMs`
|
|
18
75
|
지원. `parse: "json" | "text" | "none"` 으로 본문 파싱 방식 선택.
|
|
19
|
-
- **`cb.endpoint.url(label, path)`** — 라벨 + path 의 최종 호출 URL
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
76
|
+
- **`cb.endpoint.url(label, path)`** — 라벨 + path 의 최종 호출 URL
|
|
77
|
+
(`${baseUrl}/v1/proxy/${label}${path}`) 만 조립해서 반환. URL 을 Service
|
|
78
|
+
Worker / 백엔드 워커로 넘기거나 로깅·디버깅 용도. ⚠️ `<img src>` / 네이티브
|
|
79
|
+
`WebSocket` / `<script src>` / `EventSource` 처럼 커스텀 헤더를 못 보내는
|
|
80
|
+
브라우저 API 에 직접 넘기면 401 — ConnectBase 프록시는 항상 `X-Public-Key`
|
|
81
|
+
헤더를 요구하고 쿼리 파라미터 폴백이 없음. 그 경우엔 `call()` 로 받아
|
|
82
|
+
`URL.createObjectURL(await res.blob())` 패턴 사용.
|
|
23
83
|
- 신규 export: `PollUntilOptions` 타입.
|
|
24
84
|
|
|
25
85
|
### 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
|