connectbase-client 0.10.12 → 0.10.14

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.
Files changed (2) hide show
  1. package/dist/cli.js +29 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1147,16 +1147,16 @@ async function startTunnel(port, config, tunnelOpts) {
1147
1147
  info("Secret Key\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. \uBE0C\uB77C\uC6B0\uC800 \uB85C\uADF8\uC778\uC73C\uB85C \uBC1C\uAE09\uD569\uB2C8\uB2E4...");
1148
1148
  try {
1149
1149
  const sk = await browserAuthFlow();
1150
- const rcPath = path.join(process.cwd(), ".connectbaserc");
1150
+ const rcPath2 = path.join(process.cwd(), ".connectbaserc");
1151
1151
  let rcData = {};
1152
- if (fs.existsSync(rcPath)) {
1152
+ if (fs.existsSync(rcPath2)) {
1153
1153
  try {
1154
- rcData = JSON.parse(fs.readFileSync(rcPath, "utf-8"));
1154
+ rcData = JSON.parse(fs.readFileSync(rcPath2, "utf-8"));
1155
1155
  } catch {
1156
1156
  }
1157
1157
  }
1158
1158
  rcData.secretKey = sk;
1159
- fs.writeFileSync(rcPath, JSON.stringify(rcData, null, 2) + "\n");
1159
+ fs.writeFileSync(rcPath2, JSON.stringify(rcData, null, 2) + "\n");
1160
1160
  addToGitignore(".connectbaserc");
1161
1161
  success("Secret Key \uBC1C\uAE09 \uBC0F \uC800\uC7A5 \uC644\uB8CC");
1162
1162
  config.apiKey = sk;
@@ -1168,11 +1168,34 @@ async function startTunnel(port, config, tunnelOpts) {
1168
1168
  } else {
1169
1169
  config.apiKey = tunnelKey;
1170
1170
  }
1171
- const appId = await resolveAppForTunnel(config.apiKey, config.baseUrl, tunnelOpts?.appId);
1171
+ const rcPath = path.join(process.cwd(), ".connectbaserc");
1172
+ let savedAppId = tunnelOpts?.appId || "";
1173
+ if (!savedAppId) {
1174
+ try {
1175
+ const rc = JSON.parse(fs.readFileSync(rcPath, "utf-8"));
1176
+ if (rc.tunnelAppId) savedAppId = rc.tunnelAppId;
1177
+ } catch {
1178
+ }
1179
+ }
1180
+ const appId = await resolveAppForTunnel(config.apiKey, config.baseUrl, savedAppId);
1181
+ try {
1182
+ let rcData = {};
1183
+ if (fs.existsSync(rcPath)) {
1184
+ try {
1185
+ rcData = JSON.parse(fs.readFileSync(rcPath, "utf-8"));
1186
+ } catch {
1187
+ }
1188
+ }
1189
+ if (rcData.tunnelAppId !== appId) {
1190
+ rcData.tunnelAppId = appId;
1191
+ fs.writeFileSync(rcPath, JSON.stringify(rcData, null, 2) + "\n");
1192
+ }
1193
+ } catch {
1194
+ }
1172
1195
  const tunnelServerUrl = getTunnelServerUrl(config.baseUrl);
1173
1196
  const parsedUrl = new URL(tunnelServerUrl);
1174
1197
  const isHttps = parsedUrl.protocol === "https:";
1175
- let wsPath = `/v1/tunnel/connect?app_id=${encodeURIComponent(appId)}`;
1198
+ let wsPath = `/v1/tunnel/connect?app_id=${encodeURIComponent(appId)}&local_port=${port}`;
1176
1199
  if (tunnelOpts?.timeout) {
1177
1200
  wsPath += `&timeout=${tunnelOpts.timeout}`;
1178
1201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "connectbase-client",
3
- "version": "0.10.12",
3
+ "version": "0.10.14",
4
4
  "description": "Connect Base JavaScript/TypeScript SDK for browser and Node.js",
5
5
  "repository": {
6
6
  "type": "git",