connectbase-client 0.10.14 → 0.12.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/README.md +14 -14
- package/dist/cli.js +46 -38
- package/dist/connect-base.umd.js +3 -3
- package/dist/index.d.mts +106 -61
- package/dist/index.d.ts +106 -61
- package/dist/index.js +93 -58
- package/dist/index.mjs +93 -58
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var HttpClient = class {
|
|
|
55
55
|
constructor(config) {
|
|
56
56
|
this.isRefreshing = false;
|
|
57
57
|
this.refreshPromise = null;
|
|
58
|
-
this.config = config;
|
|
58
|
+
this.config = { ...config };
|
|
59
59
|
}
|
|
60
60
|
updateConfig(config) {
|
|
61
61
|
this.config = { ...this.config, ...config };
|
|
@@ -69,16 +69,34 @@ var HttpClient = class {
|
|
|
69
69
|
this.config.refreshToken = void 0;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Public Key 가 설정되어 있는지 확인
|
|
73
|
+
*/
|
|
74
|
+
hasPublicKey() {
|
|
75
|
+
return !!this.config.publicKey;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Public Key 반환
|
|
73
79
|
*/
|
|
74
|
-
|
|
75
|
-
return
|
|
80
|
+
getPublicKey() {
|
|
81
|
+
return this.config.publicKey;
|
|
76
82
|
}
|
|
77
83
|
/**
|
|
78
|
-
*
|
|
84
|
+
* Secret Key 가 설정되어 있는지 확인
|
|
79
85
|
*/
|
|
80
|
-
|
|
81
|
-
return this.config.
|
|
86
|
+
hasSecretKey() {
|
|
87
|
+
return !!this.config.secretKey;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Secret Key 반환
|
|
91
|
+
*/
|
|
92
|
+
getSecretKey() {
|
|
93
|
+
return this.config.secretKey;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 현재 설정된 자격증명 (publicKey 또는 secretKey) 반환
|
|
97
|
+
*/
|
|
98
|
+
getCredential() {
|
|
99
|
+
return this.config.publicKey ?? this.config.secretKey;
|
|
82
100
|
}
|
|
83
101
|
/**
|
|
84
102
|
* Access Token 반환
|
|
@@ -149,8 +167,9 @@ var HttpClient = class {
|
|
|
149
167
|
async prepareHeaders(config) {
|
|
150
168
|
const headers = new Headers();
|
|
151
169
|
headers.set("Content-Type", "application/json");
|
|
152
|
-
|
|
153
|
-
|
|
170
|
+
const credential = this.getCredential();
|
|
171
|
+
if (credential) {
|
|
172
|
+
headers.set("X-Public-Key", credential);
|
|
154
173
|
}
|
|
155
174
|
if (!config?.skipAuth && this.config.accessToken) {
|
|
156
175
|
let token = this.config.accessToken;
|
|
@@ -489,11 +508,11 @@ var AuthAPI = class {
|
|
|
489
508
|
if (this.cachedGuestMemberTokenKey) {
|
|
490
509
|
return this.cachedGuestMemberTokenKey;
|
|
491
510
|
}
|
|
492
|
-
const
|
|
493
|
-
if (!
|
|
511
|
+
const credential = this.http.getCredential();
|
|
512
|
+
if (!credential) {
|
|
494
513
|
this.cachedGuestMemberTokenKey = `${GUEST_MEMBER_TOKEN_KEY_PREFIX}default`;
|
|
495
514
|
} else {
|
|
496
|
-
const keyHash = simpleHash(
|
|
515
|
+
const keyHash = simpleHash(credential);
|
|
497
516
|
this.cachedGuestMemberTokenKey = `${GUEST_MEMBER_TOKEN_KEY_PREFIX}${keyHash}`;
|
|
498
517
|
}
|
|
499
518
|
return this.cachedGuestMemberTokenKey;
|
|
@@ -534,7 +553,7 @@ var DatabaseAPI = class {
|
|
|
534
553
|
* API Key 인증 시 /v1/public 접두사 반환
|
|
535
554
|
*/
|
|
536
555
|
getPublicPrefix() {
|
|
537
|
-
return this.http.
|
|
556
|
+
return this.http.hasPublicKey() ? "/v1/public" : "/v1";
|
|
538
557
|
}
|
|
539
558
|
// ============ Table Methods ============
|
|
540
559
|
/**
|
|
@@ -1531,7 +1550,7 @@ var StorageAPI = class {
|
|
|
1531
1550
|
* API Key 인증 시 /v1/public 접두사 반환
|
|
1532
1551
|
*/
|
|
1533
1552
|
getPublicPrefix() {
|
|
1534
|
-
return this.http.
|
|
1553
|
+
return this.http.hasPublicKey() ? "/v1/public" : "/v1";
|
|
1535
1554
|
}
|
|
1536
1555
|
/**
|
|
1537
1556
|
* 파일 목록 조회
|
|
@@ -1854,46 +1873,46 @@ var StorageAPI = class {
|
|
|
1854
1873
|
}
|
|
1855
1874
|
};
|
|
1856
1875
|
|
|
1857
|
-
// src/api/
|
|
1858
|
-
var
|
|
1876
|
+
// src/api/public-key.ts
|
|
1877
|
+
var PublicKeyAPI = class {
|
|
1859
1878
|
constructor(http) {
|
|
1860
1879
|
this.http = http;
|
|
1861
1880
|
}
|
|
1862
1881
|
/**
|
|
1863
|
-
* 앱의
|
|
1882
|
+
* 앱의 Public Key 목록을 조회합니다
|
|
1864
1883
|
* @param appId 앱 ID
|
|
1865
1884
|
*/
|
|
1866
|
-
async
|
|
1867
|
-
return this.http.get(`/v1/apps/${appId}/
|
|
1885
|
+
async getPublicKeys(appId) {
|
|
1886
|
+
return this.http.get(`/v1/apps/${appId}/public-keys`);
|
|
1868
1887
|
}
|
|
1869
1888
|
/**
|
|
1870
|
-
* 새
|
|
1889
|
+
* 새 Public Key 를 생성합니다
|
|
1871
1890
|
*
|
|
1872
1891
|
* **중요**: 반환되는 `key` 값은 이 응답에서만 볼 수 있습니다.
|
|
1873
1892
|
* 안전한 곳에 저장하세요.
|
|
1874
1893
|
*
|
|
1875
1894
|
* @param appId 앱 ID
|
|
1876
|
-
* @param data 생성할
|
|
1895
|
+
* @param data 생성할 Public Key 정보
|
|
1877
1896
|
*/
|
|
1878
|
-
async
|
|
1879
|
-
return this.http.post(`/v1/apps/${appId}/
|
|
1897
|
+
async createPublicKey(appId, data) {
|
|
1898
|
+
return this.http.post(`/v1/apps/${appId}/public-keys`, data);
|
|
1880
1899
|
}
|
|
1881
1900
|
/**
|
|
1882
|
-
*
|
|
1901
|
+
* Public Key 를 수정합니다 (이름 변경, 활성화/비활성화)
|
|
1883
1902
|
* @param appId 앱 ID
|
|
1884
|
-
* @param keyId
|
|
1903
|
+
* @param keyId Public Key ID
|
|
1885
1904
|
* @param data 수정할 정보
|
|
1886
1905
|
*/
|
|
1887
|
-
async
|
|
1888
|
-
return this.http.patch(`/v1/apps/${appId}/
|
|
1906
|
+
async updatePublicKey(appId, keyId, data) {
|
|
1907
|
+
return this.http.patch(`/v1/apps/${appId}/public-keys/${keyId}`, data);
|
|
1889
1908
|
}
|
|
1890
1909
|
/**
|
|
1891
|
-
*
|
|
1910
|
+
* Public Key 를 삭제합니다
|
|
1892
1911
|
* @param appId 앱 ID
|
|
1893
|
-
* @param keyId
|
|
1912
|
+
* @param keyId Public Key ID
|
|
1894
1913
|
*/
|
|
1895
|
-
async
|
|
1896
|
-
await this.http.delete(`/v1/apps/${appId}/
|
|
1914
|
+
async deletePublicKey(appId, keyId) {
|
|
1915
|
+
await this.http.delete(`/v1/apps/${appId}/public-keys/${keyId}`);
|
|
1897
1916
|
}
|
|
1898
1917
|
};
|
|
1899
1918
|
|
|
@@ -1906,7 +1925,7 @@ var FunctionsAPI = class {
|
|
|
1906
1925
|
* API Key 인증 시 /v1/public 접두사 반환
|
|
1907
1926
|
*/
|
|
1908
1927
|
getPublicPrefix() {
|
|
1909
|
-
return this.http.
|
|
1928
|
+
return this.http.hasPublicKey() ? "/v1/public" : "/v1";
|
|
1910
1929
|
}
|
|
1911
1930
|
/**
|
|
1912
1931
|
* 서버리스 함수 실행
|
|
@@ -2636,14 +2655,14 @@ var RealtimeAPI = class {
|
|
|
2636
2655
|
url = `${wsUrl}/v1/realtime/auth?access_token=${encodeURIComponent(this.options.accessToken)}&client_id=${this.clientId}`;
|
|
2637
2656
|
this.log("Using accessToken authentication");
|
|
2638
2657
|
} else {
|
|
2639
|
-
const
|
|
2640
|
-
if (!
|
|
2658
|
+
const publicKey = this.http.getPublicKey();
|
|
2659
|
+
if (!publicKey) {
|
|
2641
2660
|
const error = new Error("API Key or accessToken is required for realtime connection");
|
|
2642
2661
|
this.log("Connection failed: no API Key or accessToken");
|
|
2643
2662
|
reject(error);
|
|
2644
2663
|
return;
|
|
2645
2664
|
}
|
|
2646
|
-
url = `${wsUrl}/v1/realtime/auth?
|
|
2665
|
+
url = `${wsUrl}/v1/realtime/auth?public_key=${encodeURIComponent(publicKey)}&client_id=${this.clientId}`;
|
|
2647
2666
|
this.log("Using API Key authentication");
|
|
2648
2667
|
}
|
|
2649
2668
|
if (this.userId) {
|
|
@@ -3157,13 +3176,13 @@ var WebRTCAPI = class {
|
|
|
3157
3176
|
}
|
|
3158
3177
|
buildWebSocketUrl() {
|
|
3159
3178
|
let wsBase = this.webrtcUrl.replace("https://", "wss://").replace("http://", "ws://");
|
|
3160
|
-
const
|
|
3179
|
+
const publicKey = this.http.getPublicKey();
|
|
3161
3180
|
const accessToken = this.http.getAccessToken();
|
|
3162
3181
|
let authParam = "";
|
|
3163
3182
|
if (accessToken) {
|
|
3164
3183
|
authParam = `access_token=${encodeURIComponent(accessToken)}`;
|
|
3165
|
-
} else if (
|
|
3166
|
-
authParam = `api_key=${encodeURIComponent(
|
|
3184
|
+
} else if (publicKey) {
|
|
3185
|
+
authParam = `api_key=${encodeURIComponent(publicKey)}`;
|
|
3167
3186
|
}
|
|
3168
3187
|
if (!this.appId) {
|
|
3169
3188
|
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.");
|
|
@@ -3996,7 +4015,7 @@ var PaymentAPI = class {
|
|
|
3996
4015
|
* API Key 인증 시 /v1/public 접두사 반환
|
|
3997
4016
|
*/
|
|
3998
4017
|
getPublicPrefix() {
|
|
3999
|
-
return this.http.
|
|
4018
|
+
return this.http.hasPublicKey() ? "/v1/public" : "/v1";
|
|
4000
4019
|
}
|
|
4001
4020
|
/**
|
|
4002
4021
|
* 결제 준비
|
|
@@ -4122,7 +4141,7 @@ var SubscriptionAPI = class {
|
|
|
4122
4141
|
* API Key 인증 시 /v1/public 접두사 반환
|
|
4123
4142
|
*/
|
|
4124
4143
|
getPublicPrefix() {
|
|
4125
|
-
return this.http.
|
|
4144
|
+
return this.http.hasPublicKey() ? "/v1/public" : "/v1";
|
|
4126
4145
|
}
|
|
4127
4146
|
// =====================
|
|
4128
4147
|
// Billing Key APIs
|
|
@@ -4429,7 +4448,7 @@ var PushAPI = class {
|
|
|
4429
4448
|
* API Key 인증 시 /v1/public 접두사 반환
|
|
4430
4449
|
*/
|
|
4431
4450
|
getPublicPrefix() {
|
|
4432
|
-
return this.http.
|
|
4451
|
+
return this.http.hasPublicKey() ? "/v1/public" : "/v1";
|
|
4433
4452
|
}
|
|
4434
4453
|
// ============ Device Registration ============
|
|
4435
4454
|
/**
|
|
@@ -4811,13 +4830,13 @@ var VideoAPI = class {
|
|
|
4811
4830
|
return "https://video.connectbase.world";
|
|
4812
4831
|
}
|
|
4813
4832
|
getPublicPrefix() {
|
|
4814
|
-
return this.http.
|
|
4833
|
+
return this.http.hasPublicKey() ? "/v1/public" : "/v1";
|
|
4815
4834
|
}
|
|
4816
4835
|
async videoFetch(method, path, body) {
|
|
4817
4836
|
const headers = {};
|
|
4818
|
-
const
|
|
4819
|
-
if (
|
|
4820
|
-
headers["X-
|
|
4837
|
+
const publicKey = this.http.getPublicKey();
|
|
4838
|
+
if (publicKey) {
|
|
4839
|
+
headers["X-Public-Key"] = publicKey;
|
|
4821
4840
|
}
|
|
4822
4841
|
const accessToken = this.http.getAccessToken();
|
|
4823
4842
|
if (accessToken) {
|
|
@@ -5588,8 +5607,8 @@ var GameRoom = class {
|
|
|
5588
5607
|
if (roomId) {
|
|
5589
5608
|
params.set("room_id", roomId);
|
|
5590
5609
|
}
|
|
5591
|
-
if (this.config.
|
|
5592
|
-
params.set("
|
|
5610
|
+
if (this.config.publicKey) {
|
|
5611
|
+
params.set("public_key", this.config.publicKey);
|
|
5593
5612
|
}
|
|
5594
5613
|
if (this.config.accessToken) {
|
|
5595
5614
|
params.set("token", this.config.accessToken);
|
|
@@ -5810,7 +5829,7 @@ var GameAPI = class {
|
|
|
5810
5829
|
...config,
|
|
5811
5830
|
gameServerUrl: this.gameServerUrl.replace(/^http/, "ws"),
|
|
5812
5831
|
appId: this.appId,
|
|
5813
|
-
|
|
5832
|
+
publicKey: this.http.getPublicKey(),
|
|
5814
5833
|
accessToken: this.http.getAccessToken()
|
|
5815
5834
|
});
|
|
5816
5835
|
}
|
|
@@ -6455,9 +6474,9 @@ var GameAPI = class {
|
|
|
6455
6474
|
}
|
|
6456
6475
|
getHeaders() {
|
|
6457
6476
|
const headers = {};
|
|
6458
|
-
const
|
|
6459
|
-
if (
|
|
6460
|
-
headers["X-
|
|
6477
|
+
const publicKey = this.http.getPublicKey();
|
|
6478
|
+
if (publicKey) {
|
|
6479
|
+
headers["X-Public-Key"] = publicKey;
|
|
6461
6480
|
}
|
|
6462
6481
|
const accessToken = this.http.getAccessToken();
|
|
6463
6482
|
if (accessToken) {
|
|
@@ -6476,7 +6495,7 @@ var AdsAPI = class {
|
|
|
6476
6495
|
* API Key 인증 시 /v1/public 접두사 반환
|
|
6477
6496
|
*/
|
|
6478
6497
|
getPublicPrefix() {
|
|
6479
|
-
return this.http.
|
|
6498
|
+
return this.http.hasPublicKey() ? "/v1/public" : "/v1";
|
|
6480
6499
|
}
|
|
6481
6500
|
/**
|
|
6482
6501
|
* AdSense 연결 상태 확인
|
|
@@ -7214,6 +7233,21 @@ var AIAPI = class {
|
|
|
7214
7233
|
callbacks.onSources?.(event.sources);
|
|
7215
7234
|
continue;
|
|
7216
7235
|
}
|
|
7236
|
+
if (event.type === "tool_start" || event.type === "tool_end") {
|
|
7237
|
+
callbacks.onToolEvent?.({
|
|
7238
|
+
type: event.type,
|
|
7239
|
+
name: event.name,
|
|
7240
|
+
toolCallId: event.toolCallId,
|
|
7241
|
+
arguments: event.arguments,
|
|
7242
|
+
result: event.result,
|
|
7243
|
+
success: event.success,
|
|
7244
|
+
durationMs: event.durationMs
|
|
7245
|
+
});
|
|
7246
|
+
continue;
|
|
7247
|
+
}
|
|
7248
|
+
if (event.type === "heartbeat" || event.type === "searching") {
|
|
7249
|
+
continue;
|
|
7250
|
+
}
|
|
7217
7251
|
if (event.content) callbacks.onToken?.(event.content);
|
|
7218
7252
|
if (event.done) {
|
|
7219
7253
|
callbacks.onDone?.();
|
|
@@ -7312,8 +7346,8 @@ var WebTransportTransport = class {
|
|
|
7312
7346
|
const httpsUrl = baseUrl.replace(/^ws/, "http").replace(/^http:/, "https:");
|
|
7313
7347
|
const params = new URLSearchParams();
|
|
7314
7348
|
params.set("client_id", this.config.clientId);
|
|
7315
|
-
if (this.config.
|
|
7316
|
-
params.set("
|
|
7349
|
+
if (this.config.publicKey) {
|
|
7350
|
+
params.set("public_key", this.config.publicKey);
|
|
7317
7351
|
}
|
|
7318
7352
|
if (this.config.accessToken) {
|
|
7319
7353
|
params.set("token", this.config.accessToken);
|
|
@@ -7437,8 +7471,8 @@ var WebSocketTransport = class {
|
|
|
7437
7471
|
const wsUrl = baseUrl.replace(/^http/, "ws");
|
|
7438
7472
|
const params = new URLSearchParams();
|
|
7439
7473
|
params.set("client_id", this.config.clientId);
|
|
7440
|
-
if (this.config.
|
|
7441
|
-
params.set("
|
|
7474
|
+
if (this.config.publicKey) {
|
|
7475
|
+
params.set("public_key", this.config.publicKey);
|
|
7442
7476
|
}
|
|
7443
7477
|
if (this.config.accessToken) {
|
|
7444
7478
|
params.set("token", this.config.accessToken);
|
|
@@ -7933,7 +7967,8 @@ var ConnectBase = class {
|
|
|
7933
7967
|
constructor(config = {}) {
|
|
7934
7968
|
const httpConfig = {
|
|
7935
7969
|
baseUrl: config.baseUrl || DEFAULT_BASE_URL,
|
|
7936
|
-
|
|
7970
|
+
publicKey: config.publicKey,
|
|
7971
|
+
secretKey: config.secretKey,
|
|
7937
7972
|
onTokenRefresh: config.onTokenRefresh,
|
|
7938
7973
|
onAuthError: config.onAuthError,
|
|
7939
7974
|
onTokenExpired: config.onTokenExpired
|
|
@@ -7942,7 +7977,7 @@ var ConnectBase = class {
|
|
|
7942
7977
|
this.auth = new AuthAPI(this.http);
|
|
7943
7978
|
this.database = new DatabaseAPI(this.http);
|
|
7944
7979
|
this.storage = new StorageAPI(this.http);
|
|
7945
|
-
this.
|
|
7980
|
+
this.publicKey = new PublicKeyAPI(this.http);
|
|
7946
7981
|
this.functions = new FunctionsAPI(this.http);
|
|
7947
7982
|
this.realtime = new RealtimeAPI(this.http, config.socketUrl || DEFAULT_SOCKET_URL);
|
|
7948
7983
|
this.webrtc = new WebRTCAPI(this.http, config.webrtcUrl || DEFAULT_WEBRTC_URL, config.appId);
|