connectbase-client 0.10.14 → 0.11.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/dist/index.mjs CHANGED
@@ -18,7 +18,25 @@ var HttpClient = class {
18
18
  constructor(config) {
19
19
  this.isRefreshing = false;
20
20
  this.refreshPromise = null;
21
- this.config = config;
21
+ let publicKey = config.publicKey;
22
+ let secretKey = config.secretKey;
23
+ if (config.apiKey && !publicKey && !secretKey) {
24
+ if (config.apiKey.startsWith("cb_sk_")) {
25
+ secretKey = config.apiKey;
26
+ } else {
27
+ publicKey = config.apiKey;
28
+ }
29
+ if (typeof console !== "undefined") {
30
+ console.warn(
31
+ "[connectbase-client] `apiKey` \uC635\uC158\uC740 deprecated \uC785\uB2C8\uB2E4. `publicKey` (cb_pk_) \uB610\uB294 `secretKey` (cb_sk_) \uB97C \uC0AC\uC6A9\uD558\uC138\uC694."
32
+ );
33
+ }
34
+ }
35
+ this.config = {
36
+ ...config,
37
+ publicKey,
38
+ secretKey
39
+ };
22
40
  }
23
41
  updateConfig(config) {
24
42
  this.config = { ...this.config, ...config };
@@ -32,16 +50,46 @@ var HttpClient = class {
32
50
  this.config.refreshToken = void 0;
33
51
  }
34
52
  /**
35
- * API Key가 설정되어 있는지 확인
53
+ * Public Key 가 설정되어 있는지 확인
54
+ */
55
+ hasPublicKey() {
56
+ return !!this.config.publicKey;
57
+ }
58
+ /**
59
+ * Public Key 반환
60
+ */
61
+ getPublicKey() {
62
+ return this.config.publicKey;
63
+ }
64
+ /**
65
+ * Secret Key 가 설정되어 있는지 확인
66
+ */
67
+ hasSecretKey() {
68
+ return !!this.config.secretKey;
69
+ }
70
+ /**
71
+ * Secret Key 반환
72
+ */
73
+ getSecretKey() {
74
+ return this.config.secretKey;
75
+ }
76
+ /**
77
+ * 현재 설정된 자격증명 (publicKey 또는 secretKey) 반환
78
+ */
79
+ getCredential() {
80
+ return this.config.publicKey ?? this.config.secretKey;
81
+ }
82
+ /**
83
+ * @deprecated `hasPublicKey()` / `hasSecretKey()` 를 사용하세요.
36
84
  */
37
85
  hasApiKey() {
38
- return !!this.config.apiKey;
86
+ return !!this.getCredential();
39
87
  }
40
88
  /**
41
- * API Key 반환
89
+ * @deprecated `getPublicKey()` / `getSecretKey()` / `getCredential()` 을 사용하세요.
42
90
  */
43
91
  getApiKey() {
44
- return this.config.apiKey;
92
+ return this.getCredential();
45
93
  }
46
94
  /**
47
95
  * Access Token 반환
@@ -112,8 +160,10 @@ var HttpClient = class {
112
160
  async prepareHeaders(config) {
113
161
  const headers = new Headers();
114
162
  headers.set("Content-Type", "application/json");
115
- if (this.config.apiKey) {
116
- headers.set("X-API-Key", this.config.apiKey);
163
+ const credential = this.getCredential();
164
+ if (credential) {
165
+ headers.set("X-Public-Key", credential);
166
+ headers.set("X-API-Key", credential);
117
167
  }
118
168
  if (!config?.skipAuth && this.config.accessToken) {
119
169
  let token = this.config.accessToken;
@@ -452,11 +502,11 @@ var AuthAPI = class {
452
502
  if (this.cachedGuestMemberTokenKey) {
453
503
  return this.cachedGuestMemberTokenKey;
454
504
  }
455
- const apiKey = this.http.getApiKey();
456
- if (!apiKey) {
505
+ const credential = this.http.getCredential();
506
+ if (!credential) {
457
507
  this.cachedGuestMemberTokenKey = `${GUEST_MEMBER_TOKEN_KEY_PREFIX}default`;
458
508
  } else {
459
- const keyHash = simpleHash(apiKey);
509
+ const keyHash = simpleHash(credential);
460
510
  this.cachedGuestMemberTokenKey = `${GUEST_MEMBER_TOKEN_KEY_PREFIX}${keyHash}`;
461
511
  }
462
512
  return this.cachedGuestMemberTokenKey;
@@ -1817,46 +1867,63 @@ var StorageAPI = class {
1817
1867
  }
1818
1868
  };
1819
1869
 
1820
- // src/api/api-key.ts
1821
- var ApiKeyAPI = class {
1870
+ // src/api/public-key.ts
1871
+ var PublicKeyAPI = class {
1822
1872
  constructor(http) {
1823
1873
  this.http = http;
1824
1874
  }
1825
1875
  /**
1826
- * 앱의 API Key 목록을 조회합니다
1876
+ * 앱의 Public Key 목록을 조회합니다
1827
1877
  * @param appId 앱 ID
1828
1878
  */
1829
- async getApiKeys(appId) {
1830
- return this.http.get(`/v1/apps/${appId}/api-keys`);
1879
+ async getPublicKeys(appId) {
1880
+ return this.http.get(`/v1/apps/${appId}/public-keys`);
1831
1881
  }
1832
1882
  /**
1833
- * 새 API Key를 생성합니다
1883
+ * 새 Public Key 를 생성합니다
1834
1884
  *
1835
1885
  * **중요**: 반환되는 `key` 값은 이 응답에서만 볼 수 있습니다.
1836
1886
  * 안전한 곳에 저장하세요.
1837
1887
  *
1838
1888
  * @param appId 앱 ID
1839
- * @param data 생성할 API Key 정보
1889
+ * @param data 생성할 Public Key 정보
1840
1890
  */
1841
- async createApiKey(appId, data) {
1842
- return this.http.post(`/v1/apps/${appId}/api-keys`, data);
1891
+ async createPublicKey(appId, data) {
1892
+ return this.http.post(`/v1/apps/${appId}/public-keys`, data);
1843
1893
  }
1844
1894
  /**
1845
- * API Key를 수정합니다 (이름 변경, 활성화/비활성화)
1895
+ * Public Key 를 수정합니다 (이름 변경, 활성화/비활성화)
1846
1896
  * @param appId 앱 ID
1847
- * @param keyId API Key ID
1897
+ * @param keyId Public Key ID
1848
1898
  * @param data 수정할 정보
1849
1899
  */
1850
- async updateApiKey(appId, keyId, data) {
1851
- return this.http.patch(`/v1/apps/${appId}/api-keys/${keyId}`, data);
1900
+ async updatePublicKey(appId, keyId, data) {
1901
+ return this.http.patch(`/v1/apps/${appId}/public-keys/${keyId}`, data);
1852
1902
  }
1853
1903
  /**
1854
- * API Key를 삭제합니다
1904
+ * Public Key 를 삭제합니다
1855
1905
  * @param appId 앱 ID
1856
- * @param keyId API Key ID
1906
+ * @param keyId Public Key ID
1857
1907
  */
1908
+ async deletePublicKey(appId, keyId) {
1909
+ await this.http.delete(`/v1/apps/${appId}/public-keys/${keyId}`);
1910
+ }
1911
+ // ── Deprecated method aliases (하위 호환) ──────────────────────────
1912
+ /** @deprecated `getPublicKeys` 를 사용하세요. */
1913
+ async getApiKeys(appId) {
1914
+ return this.getPublicKeys(appId);
1915
+ }
1916
+ /** @deprecated `createPublicKey` 를 사용하세요. */
1917
+ async createApiKey(appId, data) {
1918
+ return this.createPublicKey(appId, data);
1919
+ }
1920
+ /** @deprecated `updatePublicKey` 를 사용하세요. */
1921
+ async updateApiKey(appId, keyId, data) {
1922
+ return this.updatePublicKey(appId, keyId, data);
1923
+ }
1924
+ /** @deprecated `deletePublicKey` 를 사용하세요. */
1858
1925
  async deleteApiKey(appId, keyId) {
1859
- await this.http.delete(`/v1/apps/${appId}/api-keys/${keyId}`);
1926
+ return this.deletePublicKey(appId, keyId);
1860
1927
  }
1861
1928
  };
1862
1929
 
@@ -7177,6 +7244,21 @@ var AIAPI = class {
7177
7244
  callbacks.onSources?.(event.sources);
7178
7245
  continue;
7179
7246
  }
7247
+ if (event.type === "tool_start" || event.type === "tool_end") {
7248
+ callbacks.onToolEvent?.({
7249
+ type: event.type,
7250
+ name: event.name,
7251
+ toolCallId: event.toolCallId,
7252
+ arguments: event.arguments,
7253
+ result: event.result,
7254
+ success: event.success,
7255
+ durationMs: event.durationMs
7256
+ });
7257
+ continue;
7258
+ }
7259
+ if (event.type === "heartbeat" || event.type === "searching") {
7260
+ continue;
7261
+ }
7180
7262
  if (event.content) callbacks.onToken?.(event.content);
7181
7263
  if (event.done) {
7182
7264
  callbacks.onDone?.();
@@ -7896,6 +7978,8 @@ var ConnectBase = class {
7896
7978
  constructor(config = {}) {
7897
7979
  const httpConfig = {
7898
7980
  baseUrl: config.baseUrl || DEFAULT_BASE_URL,
7981
+ publicKey: config.publicKey,
7982
+ secretKey: config.secretKey,
7899
7983
  apiKey: config.apiKey,
7900
7984
  onTokenRefresh: config.onTokenRefresh,
7901
7985
  onAuthError: config.onAuthError,
@@ -7905,7 +7989,8 @@ var ConnectBase = class {
7905
7989
  this.auth = new AuthAPI(this.http);
7906
7990
  this.database = new DatabaseAPI(this.http);
7907
7991
  this.storage = new StorageAPI(this.http);
7908
- this.apiKey = new ApiKeyAPI(this.http);
7992
+ this.publicKey = new PublicKeyAPI(this.http);
7993
+ this.apiKey = this.publicKey;
7909
7994
  this.functions = new FunctionsAPI(this.http);
7910
7995
  this.realtime = new RealtimeAPI(this.http, config.socketUrl || DEFAULT_SOCKET_URL);
7911
7996
  this.webrtc = new WebRTCAPI(this.http, config.webrtcUrl || DEFAULT_WEBRTC_URL, config.appId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectbase-client",
3
- "version": "0.10.14",
3
+ "version": "0.11.0",
4
4
  "description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
5
5
  "repository": {
6
6
  "type": "git",