connectbase-client 0.11.0 → 0.12.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/dist/index.mjs CHANGED
@@ -18,25 +18,7 @@ var HttpClient = class {
18
18
  constructor(config) {
19
19
  this.isRefreshing = false;
20
20
  this.refreshPromise = null;
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
- };
21
+ this.config = { ...config };
40
22
  }
41
23
  updateConfig(config) {
42
24
  this.config = { ...this.config, ...config };
@@ -79,18 +61,6 @@ var HttpClient = class {
79
61
  getCredential() {
80
62
  return this.config.publicKey ?? this.config.secretKey;
81
63
  }
82
- /**
83
- * @deprecated `hasPublicKey()` / `hasSecretKey()` 를 사용하세요.
84
- */
85
- hasApiKey() {
86
- return !!this.getCredential();
87
- }
88
- /**
89
- * @deprecated `getPublicKey()` / `getSecretKey()` / `getCredential()` 을 사용하세요.
90
- */
91
- getApiKey() {
92
- return this.getCredential();
93
- }
94
64
  /**
95
65
  * Access Token 반환
96
66
  */
@@ -163,7 +133,6 @@ var HttpClient = class {
163
133
  const credential = this.getCredential();
164
134
  if (credential) {
165
135
  headers.set("X-Public-Key", credential);
166
- headers.set("X-API-Key", credential);
167
136
  }
168
137
  if (!config?.skipAuth && this.config.accessToken) {
169
138
  let token = this.config.accessToken;
@@ -547,7 +516,7 @@ var DatabaseAPI = class {
547
516
  * API Key 인증 시 /v1/public 접두사 반환
548
517
  */
549
518
  getPublicPrefix() {
550
- return this.http.hasApiKey() ? "/v1/public" : "/v1";
519
+ return this.http.hasPublicKey() ? "/v1/public" : "/v1";
551
520
  }
552
521
  // ============ Table Methods ============
553
522
  /**
@@ -1544,7 +1513,7 @@ var StorageAPI = class {
1544
1513
  * API Key 인증 시 /v1/public 접두사 반환
1545
1514
  */
1546
1515
  getPublicPrefix() {
1547
- return this.http.hasApiKey() ? "/v1/public" : "/v1";
1516
+ return this.http.hasPublicKey() ? "/v1/public" : "/v1";
1548
1517
  }
1549
1518
  /**
1550
1519
  * 파일 목록 조회
@@ -1908,23 +1877,6 @@ var PublicKeyAPI = class {
1908
1877
  async deletePublicKey(appId, keyId) {
1909
1878
  await this.http.delete(`/v1/apps/${appId}/public-keys/${keyId}`);
1910
1879
  }
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` 를 사용하세요. */
1925
- async deleteApiKey(appId, keyId) {
1926
- return this.deletePublicKey(appId, keyId);
1927
- }
1928
1880
  };
1929
1881
 
1930
1882
  // src/api/functions.ts
@@ -1936,7 +1888,7 @@ var FunctionsAPI = class {
1936
1888
  * API Key 인증 시 /v1/public 접두사 반환
1937
1889
  */
1938
1890
  getPublicPrefix() {
1939
- return this.http.hasApiKey() ? "/v1/public" : "/v1";
1891
+ return this.http.hasPublicKey() ? "/v1/public" : "/v1";
1940
1892
  }
1941
1893
  /**
1942
1894
  * 서버리스 함수 실행
@@ -2666,14 +2618,14 @@ var RealtimeAPI = class {
2666
2618
  url = `${wsUrl}/v1/realtime/auth?access_token=${encodeURIComponent(this.options.accessToken)}&client_id=${this.clientId}`;
2667
2619
  this.log("Using accessToken authentication");
2668
2620
  } else {
2669
- const apiKey = this.http.getApiKey();
2670
- if (!apiKey) {
2621
+ const publicKey = this.http.getPublicKey();
2622
+ if (!publicKey) {
2671
2623
  const error = new Error("API Key or accessToken is required for realtime connection");
2672
2624
  this.log("Connection failed: no API Key or accessToken");
2673
2625
  reject(error);
2674
2626
  return;
2675
2627
  }
2676
- url = `${wsUrl}/v1/realtime/auth?api_key=${encodeURIComponent(apiKey)}&client_id=${this.clientId}`;
2628
+ url = `${wsUrl}/v1/realtime/auth?public_key=${encodeURIComponent(publicKey)}&client_id=${this.clientId}`;
2677
2629
  this.log("Using API Key authentication");
2678
2630
  }
2679
2631
  if (this.userId) {
@@ -3187,13 +3139,13 @@ var WebRTCAPI = class {
3187
3139
  }
3188
3140
  buildWebSocketUrl() {
3189
3141
  let wsBase = this.webrtcUrl.replace("https://", "wss://").replace("http://", "ws://");
3190
- const apiKey = this.http.getApiKey();
3142
+ const publicKey = this.http.getPublicKey();
3191
3143
  const accessToken = this.http.getAccessToken();
3192
3144
  let authParam = "";
3193
3145
  if (accessToken) {
3194
3146
  authParam = `access_token=${encodeURIComponent(accessToken)}`;
3195
- } else if (apiKey) {
3196
- authParam = `api_key=${encodeURIComponent(apiKey)}`;
3147
+ } else if (publicKey) {
3148
+ authParam = `public_key=${encodeURIComponent(publicKey)}`;
3197
3149
  }
3198
3150
  if (!this.appId) {
3199
3151
  throw new Error("WebRTC \uC5F0\uACB0\uC5D0\uB294 appId\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. ConnectBase \uCD08\uAE30\uD654 \uC2DC appId\uB97C \uC124\uC815\uD558\uC138\uC694.");
@@ -4026,7 +3978,7 @@ var PaymentAPI = class {
4026
3978
  * API Key 인증 시 /v1/public 접두사 반환
4027
3979
  */
4028
3980
  getPublicPrefix() {
4029
- return this.http.hasApiKey() ? "/v1/public" : "/v1";
3981
+ return this.http.hasPublicKey() ? "/v1/public" : "/v1";
4030
3982
  }
4031
3983
  /**
4032
3984
  * 결제 준비
@@ -4152,7 +4104,7 @@ var SubscriptionAPI = class {
4152
4104
  * API Key 인증 시 /v1/public 접두사 반환
4153
4105
  */
4154
4106
  getPublicPrefix() {
4155
- return this.http.hasApiKey() ? "/v1/public" : "/v1";
4107
+ return this.http.hasPublicKey() ? "/v1/public" : "/v1";
4156
4108
  }
4157
4109
  // =====================
4158
4110
  // Billing Key APIs
@@ -4459,7 +4411,7 @@ var PushAPI = class {
4459
4411
  * API Key 인증 시 /v1/public 접두사 반환
4460
4412
  */
4461
4413
  getPublicPrefix() {
4462
- return this.http.hasApiKey() ? "/v1/public" : "/v1";
4414
+ return this.http.hasPublicKey() ? "/v1/public" : "/v1";
4463
4415
  }
4464
4416
  // ============ Device Registration ============
4465
4417
  /**
@@ -4841,13 +4793,13 @@ var VideoAPI = class {
4841
4793
  return "https://video.connectbase.world";
4842
4794
  }
4843
4795
  getPublicPrefix() {
4844
- return this.http.hasApiKey() ? "/v1/public" : "/v1";
4796
+ return this.http.hasPublicKey() ? "/v1/public" : "/v1";
4845
4797
  }
4846
4798
  async videoFetch(method, path, body) {
4847
4799
  const headers = {};
4848
- const apiKey = this.http.getApiKey();
4849
- if (apiKey) {
4850
- headers["X-API-Key"] = apiKey;
4800
+ const publicKey = this.http.getPublicKey();
4801
+ if (publicKey) {
4802
+ headers["X-Public-Key"] = publicKey;
4851
4803
  }
4852
4804
  const accessToken = this.http.getAccessToken();
4853
4805
  if (accessToken) {
@@ -5618,8 +5570,8 @@ var GameRoom = class {
5618
5570
  if (roomId) {
5619
5571
  params.set("room_id", roomId);
5620
5572
  }
5621
- if (this.config.apiKey) {
5622
- params.set("api_key", this.config.apiKey);
5573
+ if (this.config.publicKey) {
5574
+ params.set("public_key", this.config.publicKey);
5623
5575
  }
5624
5576
  if (this.config.accessToken) {
5625
5577
  params.set("token", this.config.accessToken);
@@ -5840,7 +5792,7 @@ var GameAPI = class {
5840
5792
  ...config,
5841
5793
  gameServerUrl: this.gameServerUrl.replace(/^http/, "ws"),
5842
5794
  appId: this.appId,
5843
- apiKey: this.http.getApiKey(),
5795
+ publicKey: this.http.getPublicKey(),
5844
5796
  accessToken: this.http.getAccessToken()
5845
5797
  });
5846
5798
  }
@@ -6485,9 +6437,9 @@ var GameAPI = class {
6485
6437
  }
6486
6438
  getHeaders() {
6487
6439
  const headers = {};
6488
- const apiKey = this.http.getApiKey();
6489
- if (apiKey) {
6490
- headers["X-API-Key"] = apiKey;
6440
+ const publicKey = this.http.getPublicKey();
6441
+ if (publicKey) {
6442
+ headers["X-Public-Key"] = publicKey;
6491
6443
  }
6492
6444
  const accessToken = this.http.getAccessToken();
6493
6445
  if (accessToken) {
@@ -6506,7 +6458,7 @@ var AdsAPI = class {
6506
6458
  * API Key 인증 시 /v1/public 접두사 반환
6507
6459
  */
6508
6460
  getPublicPrefix() {
6509
- return this.http.hasApiKey() ? "/v1/public" : "/v1";
6461
+ return this.http.hasPublicKey() ? "/v1/public" : "/v1";
6510
6462
  }
6511
6463
  /**
6512
6464
  * AdSense 연결 상태 확인
@@ -7357,8 +7309,8 @@ var WebTransportTransport = class {
7357
7309
  const httpsUrl = baseUrl.replace(/^ws/, "http").replace(/^http:/, "https:");
7358
7310
  const params = new URLSearchParams();
7359
7311
  params.set("client_id", this.config.clientId);
7360
- if (this.config.apiKey) {
7361
- params.set("api_key", this.config.apiKey);
7312
+ if (this.config.publicKey) {
7313
+ params.set("public_key", this.config.publicKey);
7362
7314
  }
7363
7315
  if (this.config.accessToken) {
7364
7316
  params.set("token", this.config.accessToken);
@@ -7482,8 +7434,8 @@ var WebSocketTransport = class {
7482
7434
  const wsUrl = baseUrl.replace(/^http/, "ws");
7483
7435
  const params = new URLSearchParams();
7484
7436
  params.set("client_id", this.config.clientId);
7485
- if (this.config.apiKey) {
7486
- params.set("api_key", this.config.apiKey);
7437
+ if (this.config.publicKey) {
7438
+ params.set("public_key", this.config.publicKey);
7487
7439
  }
7488
7440
  if (this.config.accessToken) {
7489
7441
  params.set("token", this.config.accessToken);
@@ -7980,7 +7932,6 @@ var ConnectBase = class {
7980
7932
  baseUrl: config.baseUrl || DEFAULT_BASE_URL,
7981
7933
  publicKey: config.publicKey,
7982
7934
  secretKey: config.secretKey,
7983
- apiKey: config.apiKey,
7984
7935
  onTokenRefresh: config.onTokenRefresh,
7985
7936
  onAuthError: config.onAuthError,
7986
7937
  onTokenExpired: config.onTokenExpired
@@ -7990,7 +7941,6 @@ var ConnectBase = class {
7990
7941
  this.database = new DatabaseAPI(this.http);
7991
7942
  this.storage = new StorageAPI(this.http);
7992
7943
  this.publicKey = new PublicKeyAPI(this.http);
7993
- this.apiKey = this.publicKey;
7994
7944
  this.functions = new FunctionsAPI(this.http);
7995
7945
  this.realtime = new RealtimeAPI(this.http, config.socketUrl || DEFAULT_SOCKET_URL);
7996
7946
  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.11.0",
3
+ "version": "0.12.1",
4
4
  "description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
5
5
  "repository": {
6
6
  "type": "git",