tirtc-devtools-cli 0.0.11 → 0.0.12
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 +1 -1
- package/USAGE.md +79 -11
- package/dist/cli/src/guide.js +1 -1
- package/dist/cli/src/index.js +13 -13
- package/dist/cli/src/token_command.js +15 -20
- package/dist/cli/src/token_tool.d.ts +8 -17
- package/dist/cli/src/token_tool.js +24 -29
- package/package.json +1 -1
- package/vendor/app-server/bin/native/linux-x64/credential_napi.node +0 -0
- package/vendor/app-server/bin/native/macos-arm64/credential_napi.node +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/app-server/bin/runtime/linux-x64/manifest.txt +1 -1
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/audio.h +12 -316
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/av.h +11 -372
- package/vendor/app-server/bin/runtime/macos-arm64/include/tirtc/trp.h +47 -325
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_audio.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_credential.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_facade.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_http.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_foundation_logging.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_media.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_transport.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/lib/libmatrix_runtime_video.a +0 -0
- package/vendor/app-server/bin/runtime/macos-arm64/manifest.txt +12 -12
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
- **产品级 Observability**:将底层的运行时事件和状态翻译为结构化输出 (JSON) 或友好的终端日志输出;对长耗时命令补轻量进度提示。
|
|
21
21
|
- **调试期工具内聚**:承接调试期必要工具(如 token bootstrap、二维码与媒体预处理)的产品化入口,避免把调试流程散落在 runtime 或外部手工步骤中。
|
|
22
22
|
- **本地 token 工具**:提供直接签发 token、打印组合 JSON、单独 token 与本地二维码 PNG 路径的公开 CLI 能力,服务本地联调与体验验证。
|
|
23
|
-
- **本地 license 二维码工具**:提供 server 扫码用的 license JSON 二维码生成能力,支持可选 `
|
|
23
|
+
- **本地 license 二维码工具**:提供 server 扫码用的 license JSON 二维码生成能力,支持可选 `endpoint`。
|
|
24
24
|
|
|
25
25
|
## 不负责什么
|
|
26
26
|
|
package/USAGE.md
CHANGED
|
@@ -70,6 +70,7 @@ node products/cli/bin/tirtc-devtools-cli.js service --help
|
|
|
70
70
|
node products/cli/bin/tirtc-devtools-cli.js stream --help
|
|
71
71
|
node products/cli/bin/tirtc-devtools-cli.js command --help
|
|
72
72
|
node products/cli/bin/tirtc-devtools-cli.js token issue --help
|
|
73
|
+
node products/cli/bin/tirtc-devtools-cli.js license qrcode --help
|
|
73
74
|
```
|
|
74
75
|
|
|
75
76
|
当前关键子菜单快照:
|
|
@@ -96,20 +97,21 @@ Commands:
|
|
|
96
97
|
tail 持续监听命令相关事件
|
|
97
98
|
|
|
98
99
|
$ node ... token issue --help
|
|
100
|
+
Usage: tirtc-devtools-cli token issue [options] <remote_id>
|
|
101
|
+
|
|
99
102
|
Options:
|
|
100
103
|
--access-id <accessId>
|
|
101
104
|
--secret-key <secretKey>
|
|
102
|
-
--
|
|
103
|
-
--
|
|
104
|
-
--service-entry <entry>
|
|
105
|
-
--user-ttl-seconds <seconds>
|
|
106
|
-
--channel-ttl-seconds <seconds>
|
|
105
|
+
--openapi-endpoint <url>
|
|
106
|
+
--endpoint <entry>
|
|
107
107
|
--qr-error-correction-level <level>
|
|
108
108
|
--ascii-max-columns <columns>
|
|
109
109
|
|
|
110
110
|
$ node ... license qrcode --help
|
|
111
|
+
Usage: tirtc-devtools-cli license qrcode [options] <license>
|
|
112
|
+
|
|
111
113
|
Options:
|
|
112
|
-
--
|
|
114
|
+
--endpoint <entry>
|
|
113
115
|
--qr-error-correction-level <level>
|
|
114
116
|
--ascii-max-columns <columns>
|
|
115
117
|
```
|
|
@@ -143,7 +145,6 @@ license = "runtime-license"
|
|
|
143
145
|
mp4_path = "/Users/allenfeng/Development/Repositories/tirtc-nexus/tirtc-matrix/.refers/simple.mp4"
|
|
144
146
|
video_stream_id = 11
|
|
145
147
|
audio_stream_id = 10
|
|
146
|
-
|
|
147
148
|
```
|
|
148
149
|
|
|
149
150
|
说明:
|
|
@@ -250,10 +251,77 @@ CLI 仍会在本地收紧最小组合矩阵:
|
|
|
250
251
|
|
|
251
252
|
`command request` 是 canonical 主语,`command send` 只保留为兼容别名。若要发 JSON,请把 JSON 文本作为 `payload` 传入。`command pending list` 用于恢复或轮询当前积压,`command reply` 基于 `remoteRequestId` 显式回复待处理请求。
|
|
252
253
|
|
|
253
|
-
## 十、token / debug / report
|
|
254
|
+
## 十、token / license / debug / report
|
|
255
|
+
|
|
256
|
+
### token issue
|
|
257
|
+
|
|
258
|
+
命令形态:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
export TIRTC_CONN_ACCESS_ID="<ACCESS_ID>"
|
|
262
|
+
export TIRTC_CONN_SECRET_KEY="<SECRET_KEY>"
|
|
263
|
+
node products/cli/bin/tirtc-devtools-cli.js --json token issue <REMOTE_ID>
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
如果要覆盖默认 endpoint,并显式透传给底层签发路径:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
node products/cli/bin/tirtc-devtools-cli.js --json token issue <REMOTE_ID> \
|
|
270
|
+
--endpoint <ENDPOINT> \
|
|
271
|
+
--openapi-endpoint <OPENAPI_ENDPOINT>
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
当前 CLI 合同:
|
|
275
|
+
|
|
276
|
+
- 位置参数改为 `<remote_id>`。
|
|
277
|
+
- `--endpoint` 取代旧 `--service-entry`。
|
|
278
|
+
- `--openapi-endpoint` 取代旧 `--openapi-entry`。
|
|
279
|
+
- 不再接收 `local_id`。
|
|
280
|
+
- 显式传入的 `endpoint` / `openapi_endpoint` 会透传给 C 层签发路径,并同时进入二维码 payload。
|
|
281
|
+
- 若未显式传入 `endpoint` / `openapi_endpoint`,则 payload 中不再补默认字段。
|
|
282
|
+
|
|
283
|
+
`--json` 输出保持外层 envelope 不变:
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
{
|
|
287
|
+
"code": 0,
|
|
288
|
+
"message": "OK",
|
|
289
|
+
"data": {
|
|
290
|
+
"payload": {
|
|
291
|
+
"remote_id": "TESTFENGJUN4",
|
|
292
|
+
"token": "<TOKEN>",
|
|
293
|
+
"endpoint": "http://ep-test-tirtc.tange365.com",
|
|
294
|
+
"openapi_endpoint": "http://api-test-tirtc.tange365.com"
|
|
295
|
+
},
|
|
296
|
+
"payloadJson": "{\"remote_id\":\"TESTFENGJUN4\",\"token\":\"<TOKEN>\",\"endpoint\":\"http://ep-test-tirtc.tange365.com\",\"openapi_endpoint\":\"http://api-test-tirtc.tange365.com\"}",
|
|
297
|
+
"token": "<TOKEN>",
|
|
298
|
+
"qrCodePngPath": "/absolute/path/to/token-*.png"
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
说明:
|
|
304
|
+
|
|
305
|
+
- payload 只保留 `remote_id`、`token`、可选 `endpoint`、可选 `openapi_endpoint`。
|
|
306
|
+
- 已删除字段不再出现:`version`、`type`、`local_id`、`peer_id`、`openapi_entry`、`service_entry`、`user_ttl_seconds`、`channel_ttl_seconds`、`generated_at`。
|
|
307
|
+
|
|
308
|
+
### license qrcode
|
|
309
|
+
|
|
310
|
+
命令形态:
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
node products/cli/bin/tirtc-devtools-cli.js --json license qrcode <LICENSE>
|
|
314
|
+
node products/cli/bin/tirtc-devtools-cli.js --json license qrcode <LICENSE> --endpoint <ENDPOINT>
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
当前 CLI 合同:
|
|
318
|
+
|
|
319
|
+
- 只保留 `license` 和可选 `endpoint`。
|
|
320
|
+
- `--endpoint` 取代旧 `--service-entry`。
|
|
321
|
+
- 若未显式传入 `endpoint`,payload 中不再补默认字段。
|
|
322
|
+
|
|
323
|
+
### 其他命令
|
|
254
324
|
|
|
255
|
-
- `token issue <peerId>`:本地签发 token。
|
|
256
|
-
- `license qrcode <license>`:本地生成 server 扫码二维码。
|
|
257
325
|
- `debug bootstrap qrcode ...` / `debug bootstrap qrcode-from-config`:生成联调用二维码。
|
|
258
326
|
- `events tail`:实时查看事件流。
|
|
259
327
|
- `logs export <outputPath>`:导出日志。
|
|
@@ -267,7 +335,7 @@ CLI 仍会在本地收紧最小组合矩阵:
|
|
|
267
335
|
- `client.local.toml` 字段:`[client]` + `[debug.token_issue]`
|
|
268
336
|
- CLI server-only E2E 不再要求先手工 `media assets prepare` 再回填 `assetsDir`
|
|
269
337
|
|
|
270
|
-
##
|
|
338
|
+
## 十二、Android 人工闭环脚本
|
|
271
339
|
|
|
272
340
|
如果需要把 CLI 侧闭环常驻起来,再手工去操作 Android example,使用:
|
|
273
341
|
|
package/dist/cli/src/guide.js
CHANGED
|
@@ -23,7 +23,7 @@ function printQuickstartGuide() {
|
|
|
23
23
|
'步骤 3:显式签发 client token(可本地执行,也可由外部系统提供)',
|
|
24
24
|
' export TIRTC_CONN_ACCESS_ID="<ACCESS_ID>"',
|
|
25
25
|
' export TIRTC_CONN_SECRET_KEY="<SECRET_KEY>"',
|
|
26
|
-
' node products/cli/bin/tirtc-devtools-cli.js --json token issue "<
|
|
26
|
+
' node products/cli/bin/tirtc-devtools-cli.js --json token issue "<REMOTE_ID>" --endpoint "<ENDPOINT>"',
|
|
27
27
|
'',
|
|
28
28
|
'步骤 4:启动 client 本地 web preview',
|
|
29
29
|
' node products/cli/bin/tirtc-devtools-cli.js --config ./client.toml client start --token "<TOKEN>"',
|
package/dist/cli/src/index.js
CHANGED
|
@@ -11,7 +11,7 @@ const media_assets_1 = require("./media_assets");
|
|
|
11
11
|
const token_command_1 = require("./token_command");
|
|
12
12
|
const transport_1 = require("./transport");
|
|
13
13
|
const progress_1 = require("./progress");
|
|
14
|
-
const CLI_VERSION = '0.0.
|
|
14
|
+
const CLI_VERSION = '0.0.12';
|
|
15
15
|
const HOST_VERSION = '1.0.0';
|
|
16
16
|
const PROTOCOL_VERSION = '1.0.0';
|
|
17
17
|
if (process.argv.includes('--version') || process.argv.includes('-V')) {
|
|
@@ -585,15 +585,15 @@ const debugBootstrap = debug.command('bootstrap').description('连接 bootstrap
|
|
|
585
585
|
debugBootstrap.command('qrcode <access_id> <secret_key> <peer_id> [service_entry]')
|
|
586
586
|
.description('生成客户端连接 bootstrap 二维码(payload 包含 access_id/secret_key/peer_id)')
|
|
587
587
|
.action((accessId, secretKey, peerId, serviceEntry) => {
|
|
588
|
-
const
|
|
589
|
-
version: 1,
|
|
590
|
-
type: 'tirtc-connect-bootstrap',
|
|
588
|
+
const payloadObject = {
|
|
591
589
|
access_id: accessId,
|
|
592
590
|
secret_key: secretKey,
|
|
593
591
|
peer_id: peerId,
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
592
|
+
};
|
|
593
|
+
if (serviceEntry && serviceEntry.length > 0) {
|
|
594
|
+
payloadObject.service_entry = serviceEntry;
|
|
595
|
+
}
|
|
596
|
+
const payload = JSON.stringify(payloadObject);
|
|
597
597
|
runAndExit(runCommand('debug bootstrap qrcode', { payload, outputStem: 'connect-bootstrap' }, getCliOptions()));
|
|
598
598
|
});
|
|
599
599
|
debugBootstrap.command('qrcode-from-config')
|
|
@@ -607,15 +607,15 @@ debugBootstrap.command('qrcode-from-config')
|
|
|
607
607
|
if (!bootstrap.access_id || !bootstrap.secret_key || !bootstrap.peer_id) {
|
|
608
608
|
throw new Error('debug.connect_bootstrap requires access_id + secret_key + peer_id');
|
|
609
609
|
}
|
|
610
|
-
const
|
|
611
|
-
version: 1,
|
|
612
|
-
type: 'tirtc-connect-bootstrap',
|
|
610
|
+
const payloadObject = {
|
|
613
611
|
access_id: bootstrap.access_id,
|
|
614
612
|
secret_key: bootstrap.secret_key,
|
|
615
613
|
peer_id: bootstrap.peer_id,
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
614
|
+
};
|
|
615
|
+
if (bootstrap.service_entry && bootstrap.service_entry.length > 0) {
|
|
616
|
+
payloadObject.service_entry = bootstrap.service_entry;
|
|
617
|
+
}
|
|
618
|
+
const payload = JSON.stringify(payloadObject);
|
|
619
619
|
runAndExit(runCommand('debug bootstrap qrcode', { payload, outputStem: 'connect-bootstrap' }, getCliOptions()));
|
|
620
620
|
});
|
|
621
621
|
const events = program.command('events').description('事件订阅:实时观察 Host 事件');
|
|
@@ -102,7 +102,7 @@ function resolveTokenIssueCredential(explicitValue, envVarName, optionName) {
|
|
|
102
102
|
throw new Error('missing credential: set environment variable ' + envVarName +
|
|
103
103
|
' or pass ' + optionName + ' explicitly');
|
|
104
104
|
}
|
|
105
|
-
async function runTokenIssueFromCli(
|
|
105
|
+
async function runTokenIssueFromCli(remoteId, commandOptions, options) {
|
|
106
106
|
const parsePositiveInt = (name, raw) => {
|
|
107
107
|
if (raw === undefined) {
|
|
108
108
|
return undefined;
|
|
@@ -129,12 +129,9 @@ async function runTokenIssueFromCli(peerId, commandOptions, options) {
|
|
|
129
129
|
return await runTokenIssue({
|
|
130
130
|
accessId,
|
|
131
131
|
secretKey,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
serviceEntry: commandOptions.serviceEntry,
|
|
136
|
-
userTtlSeconds: parsePositiveInt('user-ttl-seconds', commandOptions.userTtlSeconds),
|
|
137
|
-
channelTtlSeconds: parsePositiveInt('channel-ttl-seconds', commandOptions.channelTtlSeconds),
|
|
132
|
+
remoteId,
|
|
133
|
+
openapiEndpoint: commandOptions.openapiEndpoint,
|
|
134
|
+
endpoint: commandOptions.endpoint,
|
|
138
135
|
qrErrorCorrectionLevel: parseQrErrorCorrectionLevel(commandOptions.qrErrorCorrectionLevel),
|
|
139
136
|
asciiMaxColumns: parsePositiveInt('ascii-max-columns', commandOptions.asciiMaxColumns),
|
|
140
137
|
}, options);
|
|
@@ -169,11 +166,12 @@ async function runLicenseQrcodeFromCli(license, commandOptions, options) {
|
|
|
169
166
|
if (normalizedLicense.length === 0) {
|
|
170
167
|
throw new Error('license must not be empty');
|
|
171
168
|
}
|
|
169
|
+
const asciiMaxColumns = commandOptions.asciiMaxColumns === undefined ? undefined : parsePositiveInt('ascii-max-columns', commandOptions.asciiMaxColumns);
|
|
172
170
|
return await runLicenseQrcode({
|
|
173
171
|
license: normalizedLicense,
|
|
174
|
-
|
|
172
|
+
endpoint: commandOptions.endpoint,
|
|
175
173
|
qrErrorCorrectionLevel: parseQrErrorCorrectionLevel(commandOptions.qrErrorCorrectionLevel),
|
|
176
|
-
asciiMaxColumns
|
|
174
|
+
asciiMaxColumns,
|
|
177
175
|
}, options);
|
|
178
176
|
}
|
|
179
177
|
catch (error) {
|
|
@@ -182,24 +180,21 @@ async function runLicenseQrcodeFromCli(license, commandOptions, options) {
|
|
|
182
180
|
}
|
|
183
181
|
function registerTokenCommands(program, getCliOptions, runAndExit) {
|
|
184
182
|
const token = program.command('token').description('Token 工具:签发 token,并输出可直接使用的 JSON 与本地二维码 PNG');
|
|
185
|
-
token.command('issue <
|
|
186
|
-
.description('默认从环境变量读取 access/secret
|
|
183
|
+
token.command('issue <remote_id>')
|
|
184
|
+
.description('默认从环境变量读取 access/secret,并基于 remote_id 签发 token')
|
|
187
185
|
.option('--access-id <accessId>', '显式 access id;不传时读取 ' + kTokenIssueAccessIdEnvVar)
|
|
188
186
|
.option('--secret-key <secretKey>', '显式 secret key;不传时读取 ' + kTokenIssueSecretKeyEnvVar)
|
|
189
|
-
.option('--
|
|
190
|
-
.option('--
|
|
191
|
-
.option('--service-entry <entry>', '可选 service entry;用于组合连接 payload 与二维码 PNG')
|
|
192
|
-
.option('--user-ttl-seconds <seconds>', '可选 user token ttl(秒)')
|
|
193
|
-
.option('--channel-ttl-seconds <seconds>', '可选 channel token ttl(秒)')
|
|
187
|
+
.option('--openapi-endpoint <url>', '可选 openapi endpoint;传了就透传到底层签发')
|
|
188
|
+
.option('--endpoint <entry>', '可选 endpoint;传了就写入 payload 与二维码')
|
|
194
189
|
.option('--qr-error-correction-level <level>', '二维码纠错级别:L/M/Q/H;默认 M')
|
|
195
190
|
.option('--ascii-max-columns <columns>', 'ASCII 二维码最大宽度;不传时优先读取当前终端宽度或 COLUMNS')
|
|
196
|
-
.action((
|
|
197
|
-
runAndExit(runTokenIssueFromCli(
|
|
191
|
+
.action((remoteId, commandOptions) => {
|
|
192
|
+
runAndExit(runTokenIssueFromCli(remoteId, commandOptions, getCliOptions()));
|
|
198
193
|
});
|
|
199
194
|
const license = program.command('license').description('License 工具:生成 server 扫码 JSON 与本地二维码 PNG');
|
|
200
195
|
license.command('qrcode <license>')
|
|
201
|
-
.description('生成包含 license 与可选
|
|
202
|
-
.option('--
|
|
196
|
+
.description('生成包含 license 与可选 endpoint 的本地二维码')
|
|
197
|
+
.option('--endpoint <entry>', '可选 endpoint;传了就写入 payload 与二维码')
|
|
203
198
|
.option('--qr-error-correction-level <level>', '二维码纠错级别:L/M/Q/H;默认 M')
|
|
204
199
|
.option('--ascii-max-columns <columns>', 'ASCII 二维码最大宽度;不传时优先读取当前终端宽度或 COLUMNS')
|
|
205
200
|
.action((licenseValue, commandOptions) => {
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
export type TokenIssueInput = {
|
|
2
2
|
accessId: string;
|
|
3
3
|
secretKey: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
serviceEntry?: string;
|
|
8
|
-
userTtlSeconds?: number;
|
|
9
|
-
channelTtlSeconds?: number;
|
|
4
|
+
remoteId: string;
|
|
5
|
+
openapiEndpoint?: string;
|
|
6
|
+
endpoint?: string;
|
|
10
7
|
qrErrorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H';
|
|
11
8
|
asciiMaxColumns?: number;
|
|
12
9
|
};
|
|
13
10
|
export type IssuedTokenPayload = {
|
|
14
|
-
|
|
15
|
-
type: 'tirtc-connect-token';
|
|
16
|
-
peer_id: string;
|
|
17
|
-
local_id: string;
|
|
18
|
-
service_entry: string;
|
|
11
|
+
remote_id: string;
|
|
19
12
|
token: string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
channel_ttl_seconds: number;
|
|
23
|
-
generated_at: string;
|
|
13
|
+
endpoint?: string;
|
|
14
|
+
openapi_endpoint?: string;
|
|
24
15
|
};
|
|
25
16
|
export type TokenIssueOutput = {
|
|
26
17
|
payload: IssuedTokenPayload;
|
|
@@ -32,13 +23,13 @@ export type TokenIssueOutput = {
|
|
|
32
23
|
};
|
|
33
24
|
export type LicenseQrcodeInput = {
|
|
34
25
|
license: string;
|
|
35
|
-
|
|
26
|
+
endpoint?: string;
|
|
36
27
|
qrErrorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H';
|
|
37
28
|
asciiMaxColumns?: number;
|
|
38
29
|
};
|
|
39
30
|
export type LicenseQrcodePayload = {
|
|
40
31
|
license: string;
|
|
41
|
-
|
|
32
|
+
endpoint?: string;
|
|
42
33
|
};
|
|
43
34
|
export type LicenseQrcodeOutput = {
|
|
44
35
|
payload: LicenseQrcodePayload;
|
|
@@ -51,9 +51,6 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
51
51
|
const path_1 = __importDefault(require("path"));
|
|
52
52
|
const qrcode_1 = __importDefault(require("qrcode"));
|
|
53
53
|
const embedded_paths_1 = require("./embedded_paths");
|
|
54
|
-
const kDefaultOpenapiEntry = 'http://api-test-tirtc.tange365.com';
|
|
55
|
-
const kDefaultUserTtlSeconds = 86400;
|
|
56
|
-
const kDefaultChannelTtlSeconds = 300;
|
|
57
54
|
const kAsciiQrQuietZoneModules = 2;
|
|
58
55
|
function pathExists(filePath) {
|
|
59
56
|
return fs_1.default.existsSync(filePath);
|
|
@@ -76,7 +73,7 @@ function buildQrCodePngPath(prefix, ...parts) {
|
|
|
76
73
|
return path_1.default.join(resolveQrCodeOutputDir(), fileName);
|
|
77
74
|
}
|
|
78
75
|
function buildTokenQrCodePngPath(payload) {
|
|
79
|
-
return buildQrCodePngPath('token', payload.
|
|
76
|
+
return buildQrCodePngPath('token', payload.remote_id);
|
|
80
77
|
}
|
|
81
78
|
function buildLicenseQrCodePngPath(payload) {
|
|
82
79
|
return buildQrCodePngPath('license', payload.license);
|
|
@@ -206,13 +203,10 @@ function buildIssueTokenHelperSource() {
|
|
|
206
203
|
'});',
|
|
207
204
|
'try {',
|
|
208
205
|
' const token = addon.issueToken({',
|
|
209
|
-
'
|
|
206
|
+
' openapiEndpoint: input.openapiEndpoint,',
|
|
210
207
|
' accessId: input.accessId,',
|
|
211
208
|
' secretKey: input.secretKey,',
|
|
212
|
-
'
|
|
213
|
-
' peerId: input.peerId,',
|
|
214
|
-
' userTtlSeconds: input.userTtlSeconds,',
|
|
215
|
-
' channelTtlSeconds: input.channelTtlSeconds,',
|
|
209
|
+
' remoteId: input.remoteId,',
|
|
216
210
|
' });',
|
|
217
211
|
' process.stdout.write(String(token).trim());',
|
|
218
212
|
'} finally {',
|
|
@@ -305,24 +299,29 @@ async function issueToken(input) {
|
|
|
305
299
|
}
|
|
306
300
|
}
|
|
307
301
|
function buildIssuedTokenPayload(input, token) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
type: 'tirtc-connect-token',
|
|
311
|
-
peer_id: input.peerId,
|
|
312
|
-
local_id: input.localId,
|
|
313
|
-
service_entry: input.serviceEntry ?? '',
|
|
302
|
+
const payload = {
|
|
303
|
+
remote_id: input.remoteId,
|
|
314
304
|
token,
|
|
315
|
-
openapi_entry: input.openapiEntry?.trim() || kDefaultOpenapiEntry,
|
|
316
|
-
user_ttl_seconds: input.userTtlSeconds ?? kDefaultUserTtlSeconds,
|
|
317
|
-
channel_ttl_seconds: input.channelTtlSeconds ?? kDefaultChannelTtlSeconds,
|
|
318
|
-
generated_at: new Date().toISOString(),
|
|
319
305
|
};
|
|
306
|
+
const normalizedEndpoint = input.endpoint?.trim();
|
|
307
|
+
if (normalizedEndpoint) {
|
|
308
|
+
payload.endpoint = normalizedEndpoint;
|
|
309
|
+
}
|
|
310
|
+
const normalizedOpenapiEndpoint = input.openapiEndpoint?.trim();
|
|
311
|
+
if (normalizedOpenapiEndpoint) {
|
|
312
|
+
payload.openapi_endpoint = normalizedOpenapiEndpoint;
|
|
313
|
+
}
|
|
314
|
+
return payload;
|
|
320
315
|
}
|
|
321
316
|
function buildLicenseQrcodePayload(input) {
|
|
322
|
-
|
|
317
|
+
const payload = {
|
|
323
318
|
license: input.license.trim(),
|
|
324
|
-
service_entry: input.serviceEntry?.trim() ?? '',
|
|
325
319
|
};
|
|
320
|
+
const normalizedEndpoint = input.endpoint?.trim();
|
|
321
|
+
if (normalizedEndpoint) {
|
|
322
|
+
payload.endpoint = normalizedEndpoint;
|
|
323
|
+
}
|
|
324
|
+
return payload;
|
|
326
325
|
}
|
|
327
326
|
async function writePngQrcode(payloadJson, outputPath, errorCorrectionLevel) {
|
|
328
327
|
const resolvedPath = path_1.default.resolve(outputPath);
|
|
@@ -382,13 +381,9 @@ async function buildLicenseQrcode(input) {
|
|
|
382
381
|
function formatTokenIssueConsoleOutput(output) {
|
|
383
382
|
const summaryLines = [
|
|
384
383
|
'Issued Token Summary:',
|
|
385
|
-
'
|
|
386
|
-
'
|
|
387
|
-
'
|
|
388
|
-
' openapi_entry: ' + output.payload.openapi_entry,
|
|
389
|
-
' user_ttl_seconds: ' + output.payload.user_ttl_seconds,
|
|
390
|
-
' channel_ttl_seconds: ' + output.payload.channel_ttl_seconds,
|
|
391
|
-
' generated_at: ' + output.payload.generated_at,
|
|
384
|
+
' remote_id: ' + output.payload.remote_id,
|
|
385
|
+
' endpoint: ' + (output.payload.endpoint ?? '(omitted)'),
|
|
386
|
+
' openapi_endpoint: ' + (output.payload.openapi_endpoint ?? '(omitted)'),
|
|
392
387
|
'',
|
|
393
388
|
'Token:',
|
|
394
389
|
output.token,
|
|
@@ -408,7 +403,7 @@ function formatLicenseQrcodeConsoleOutput(output) {
|
|
|
408
403
|
const summaryLines = [
|
|
409
404
|
'License QR Code Summary:',
|
|
410
405
|
' license: ' + output.payload.license,
|
|
411
|
-
'
|
|
406
|
+
' endpoint: ' + (output.payload.endpoint ?? '(omitted)'),
|
|
412
407
|
'',
|
|
413
408
|
'Payload JSON:',
|
|
414
409
|
JSON.stringify(output.payload, null, 2),
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|