@aiam/ciba 0.9.6 → 0.9.7
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/ciba.mjs +0 -30
- package/package.json +1 -1
- package/token.mjs +1 -13
package/ciba.mjs
CHANGED
|
@@ -689,35 +689,6 @@ const refreshCmd = defineCommand({
|
|
|
689
689
|
},
|
|
690
690
|
});
|
|
691
691
|
|
|
692
|
-
const inspectCmd = defineCommand({
|
|
693
|
-
meta: { description: 'Open live device doc inspector in browser' },
|
|
694
|
-
args: {
|
|
695
|
-
url: { ...serverArg },
|
|
696
|
-
},
|
|
697
|
-
async run({ args }) {
|
|
698
|
-
const serverUrl = args.url || process.env.CIBA_URL || loadConfig().url || DEFAULT_SERVER_URL;
|
|
699
|
-
const keys = loadOrGenerateEcdhKeys();
|
|
700
|
-
const { jwt: deviceJwt } = signDeviceJwt(keys.privateKey, keys.publicKey);
|
|
701
|
-
|
|
702
|
-
// POST /inspect with device JWT to get a one-time inspect code.
|
|
703
|
-
const res = await fetch(`${serverUrl}/inspect`, {
|
|
704
|
-
method: 'POST',
|
|
705
|
-
headers: { Authorization: `Bearer ${deviceJwt}` },
|
|
706
|
-
});
|
|
707
|
-
if (!res.ok) {
|
|
708
|
-
const err = await res.json().catch(() => ({}));
|
|
709
|
-
process.stderr.write(`Error: ${err.error || res.status}\n`);
|
|
710
|
-
process.exit(1);
|
|
711
|
-
}
|
|
712
|
-
const { code, url } = await res.json();
|
|
713
|
-
process.stderr.write(`→ inspect code: ${code}\n`);
|
|
714
|
-
process.stderr.write(`→ opening: ${url}\n`);
|
|
715
|
-
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start ""' : 'xdg-open';
|
|
716
|
-
exec(`${cmd} "${url}"`);
|
|
717
|
-
process.exit(0);
|
|
718
|
-
},
|
|
719
|
-
});
|
|
720
|
-
|
|
721
692
|
const logoutCmd = defineCommand({
|
|
722
693
|
meta: { description: 'Clear device keys, session and config (next login generates a new device identity)' },
|
|
723
694
|
args: {},
|
|
@@ -793,7 +764,6 @@ const main = defineCommand({
|
|
|
793
764
|
login: loginCmd,
|
|
794
765
|
token: tokenCmd,
|
|
795
766
|
refresh: refreshCmd,
|
|
796
|
-
inspect: inspectCmd,
|
|
797
767
|
stop: stopCmd,
|
|
798
768
|
status: statusCmd,
|
|
799
769
|
logout: logoutCmd,
|
package/package.json
CHANGED
package/token.mjs
CHANGED
|
@@ -130,17 +130,7 @@ function tryGet(resourcesMap, deviceDoc, res) {
|
|
|
130
130
|
|
|
131
131
|
// ─── Output ───────────────────────────────────────────────────────────────────
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
// Before doc is synced, fall back to stderr.
|
|
135
|
-
let _logMap = null;
|
|
136
|
-
let _logIdx = 0;
|
|
137
|
-
function log(msg) {
|
|
138
|
-
if (_logMap) {
|
|
139
|
-
_logMap.set(`${Date.now()}-${_logIdx++}`, { ts: new Date().toISOString(), msg });
|
|
140
|
-
} else {
|
|
141
|
-
process.stderr.write(msg + '\n');
|
|
142
|
-
}
|
|
143
|
-
}
|
|
133
|
+
function log(msg) { process.stderr.write(msg + '\n'); }
|
|
144
134
|
|
|
145
135
|
function output(token) {
|
|
146
136
|
if (jsonOut) {
|
|
@@ -180,8 +170,6 @@ await new Promise((resolve, reject) => {
|
|
|
180
170
|
provider.on('authenticationFailed', ({ reason }) => { clearTimeout(t); reject(new Error(reason)); });
|
|
181
171
|
});
|
|
182
172
|
|
|
183
|
-
// Switch logging to Yjs after sync — ciba inspect can now see entries.
|
|
184
|
-
_logMap = deviceDoc.getMap('log');
|
|
185
173
|
log('→ synced');
|
|
186
174
|
|
|
187
175
|
// Write public key
|