@positronic/cli 0.0.73 → 0.0.74
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/src/cli.js +86 -109
- package/dist/src/commands/auth.js +8 -34
- package/dist/src/commands/users.js +15 -14
- package/dist/src/components/auth-login.js +1 -1
- package/dist/src/components/project-auth-setup.js +1 -1
- package/dist/src/components/schedule-list.js +1 -1
- package/dist/src/components/store-explorer.js +2 -2
- package/dist/src/components/users-create.js +2 -4
- package/dist/src/components/users-delete.js +5 -5
- package/dist/src/components/users-keys-add.js +71 -17
- package/dist/src/components/users-keys-list.js +5 -5
- package/dist/src/components/users-keys-remove.js +5 -5
- package/dist/src/components/users-list.js +2 -11
- package/dist/src/components/whoami.js +71 -0
- package/dist/src/hooks/useApi.js +2 -2
- package/dist/src/lib/jwt-auth.js +1 -1
- package/dist/src/lib/ssh-key-utils.js +17 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/commands/auth.d.ts +5 -18
- package/dist/types/commands/auth.d.ts.map +1 -1
- package/dist/types/commands/users.d.ts +13 -12
- package/dist/types/commands/users.d.ts.map +1 -1
- package/dist/types/components/users-create.d.ts.map +1 -1
- package/dist/types/components/users-delete.d.ts +2 -2
- package/dist/types/components/users-delete.d.ts.map +1 -1
- package/dist/types/components/users-keys-add.d.ts +4 -3
- package/dist/types/components/users-keys-add.d.ts.map +1 -1
- package/dist/types/components/users-keys-list.d.ts +2 -2
- package/dist/types/components/users-keys-list.d.ts.map +1 -1
- package/dist/types/components/users-keys-remove.d.ts +2 -2
- package/dist/types/components/users-keys-remove.d.ts.map +1 -1
- package/dist/types/components/users-list.d.ts.map +1 -1
- package/dist/types/components/whoami.d.ts +8 -0
- package/dist/types/components/whoami.d.ts.map +1 -0
- package/dist/types/lib/ssh-key-utils.d.ts +5 -0
- package/dist/types/lib/ssh-key-utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/src/components/auth-format-jwk-key.js +0 -457
- package/dist/src/components/auth-list.js +0 -66
- package/dist/src/components/auth-status.js +0 -113
- package/dist/types/components/auth-format-jwk-key.d.ts +0 -6
- package/dist/types/components/auth-format-jwk-key.d.ts.map +0 -1
- package/dist/types/components/auth-list.d.ts +0 -8
- package/dist/types/components/auth-list.d.ts.map +0 -1
- package/dist/types/components/auth-status.d.ts +0 -8
- package/dist/types/components/auth-status.d.ts.map +0 -1
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
function _array_like_to_array(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _array_with_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return arr;
|
|
8
|
-
}
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
-
try {
|
|
11
|
-
var info = gen[key](arg);
|
|
12
|
-
var value = info.value;
|
|
13
|
-
} catch (error) {
|
|
14
|
-
reject(error);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (info.done) {
|
|
18
|
-
resolve(value);
|
|
19
|
-
} else {
|
|
20
|
-
Promise.resolve(value).then(_next, _throw);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function _async_to_generator(fn) {
|
|
24
|
-
return function() {
|
|
25
|
-
var self = this, args = arguments;
|
|
26
|
-
return new Promise(function(resolve, reject) {
|
|
27
|
-
var gen = fn.apply(self, args);
|
|
28
|
-
function _next(value) {
|
|
29
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
-
}
|
|
31
|
-
function _throw(err) {
|
|
32
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
-
}
|
|
34
|
-
_next(undefined);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function _iterable_to_array_limit(arr, i) {
|
|
39
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
40
|
-
if (_i == null) return;
|
|
41
|
-
var _arr = [];
|
|
42
|
-
var _n = true;
|
|
43
|
-
var _d = false;
|
|
44
|
-
var _s, _e;
|
|
45
|
-
try {
|
|
46
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
47
|
-
_arr.push(_s.value);
|
|
48
|
-
if (i && _arr.length === i) break;
|
|
49
|
-
}
|
|
50
|
-
} catch (err) {
|
|
51
|
-
_d = true;
|
|
52
|
-
_e = err;
|
|
53
|
-
} finally{
|
|
54
|
-
try {
|
|
55
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
56
|
-
} finally{
|
|
57
|
-
if (_d) throw _e;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return _arr;
|
|
61
|
-
}
|
|
62
|
-
function _non_iterable_rest() {
|
|
63
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
64
|
-
}
|
|
65
|
-
function _sliced_to_array(arr, i) {
|
|
66
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
67
|
-
}
|
|
68
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
69
|
-
if (!o) return;
|
|
70
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
71
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
72
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
73
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
74
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
75
|
-
}
|
|
76
|
-
function _ts_generator(thisArg, body) {
|
|
77
|
-
var f, y, t, _ = {
|
|
78
|
-
label: 0,
|
|
79
|
-
sent: function() {
|
|
80
|
-
if (t[0] & 1) throw t[1];
|
|
81
|
-
return t[1];
|
|
82
|
-
},
|
|
83
|
-
trys: [],
|
|
84
|
-
ops: []
|
|
85
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
86
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
87
|
-
return this;
|
|
88
|
-
}), g;
|
|
89
|
-
function verb(n) {
|
|
90
|
-
return function(v) {
|
|
91
|
-
return step([
|
|
92
|
-
n,
|
|
93
|
-
v
|
|
94
|
-
]);
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
function step(op) {
|
|
98
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
99
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
100
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
101
|
-
if (y = 0, t) op = [
|
|
102
|
-
op[0] & 2,
|
|
103
|
-
t.value
|
|
104
|
-
];
|
|
105
|
-
switch(op[0]){
|
|
106
|
-
case 0:
|
|
107
|
-
case 1:
|
|
108
|
-
t = op;
|
|
109
|
-
break;
|
|
110
|
-
case 4:
|
|
111
|
-
_.label++;
|
|
112
|
-
return {
|
|
113
|
-
value: op[1],
|
|
114
|
-
done: false
|
|
115
|
-
};
|
|
116
|
-
case 5:
|
|
117
|
-
_.label++;
|
|
118
|
-
y = op[1];
|
|
119
|
-
op = [
|
|
120
|
-
0
|
|
121
|
-
];
|
|
122
|
-
continue;
|
|
123
|
-
case 7:
|
|
124
|
-
op = _.ops.pop();
|
|
125
|
-
_.trys.pop();
|
|
126
|
-
continue;
|
|
127
|
-
default:
|
|
128
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
129
|
-
_ = 0;
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
133
|
-
_.label = op[1];
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
137
|
-
_.label = t[1];
|
|
138
|
-
t = op;
|
|
139
|
-
break;
|
|
140
|
-
}
|
|
141
|
-
if (t && _.label < t[2]) {
|
|
142
|
-
_.label = t[2];
|
|
143
|
-
_.ops.push(op);
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
if (t[2]) _.ops.pop();
|
|
147
|
-
_.trys.pop();
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
op = body.call(thisArg, _);
|
|
151
|
-
} catch (e) {
|
|
152
|
-
op = [
|
|
153
|
-
6,
|
|
154
|
-
e
|
|
155
|
-
];
|
|
156
|
-
y = 0;
|
|
157
|
-
} finally{
|
|
158
|
-
f = t = 0;
|
|
159
|
-
}
|
|
160
|
-
if (op[0] & 5) throw op[1];
|
|
161
|
-
return {
|
|
162
|
-
value: op[0] ? op[1] : void 0,
|
|
163
|
-
done: true
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
import React, { useState, useEffect } from 'react';
|
|
168
|
-
import { Box, Text, useApp } from 'ink';
|
|
169
|
-
import { existsSync, readdirSync } from 'fs';
|
|
170
|
-
import { homedir } from 'os';
|
|
171
|
-
import { join } from 'path';
|
|
172
|
-
import { convertSSHPubKeyToJWK, expandPath } from '../lib/ssh-key-utils.js';
|
|
173
|
-
import { SelectList } from './select-list.js';
|
|
174
|
-
/**
|
|
175
|
-
* Discover available SSH public keys in ~/.ssh
|
|
176
|
-
*/ function discoverSSHPubKeys() {
|
|
177
|
-
var sshDir = join(homedir(), '.ssh');
|
|
178
|
-
if (!existsSync(sshDir)) {
|
|
179
|
-
return [];
|
|
180
|
-
}
|
|
181
|
-
var pubKeys = [];
|
|
182
|
-
try {
|
|
183
|
-
var files = readdirSync(sshDir);
|
|
184
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
185
|
-
try {
|
|
186
|
-
for(var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
187
|
-
var file = _step.value;
|
|
188
|
-
if (file.endsWith('.pub')) {
|
|
189
|
-
var fullPath = join(sshDir, file);
|
|
190
|
-
pubKeys.push({
|
|
191
|
-
path: fullPath,
|
|
192
|
-
displayPath: "~/.ssh/".concat(file)
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
} catch (err) {
|
|
197
|
-
_didIteratorError = true;
|
|
198
|
-
_iteratorError = err;
|
|
199
|
-
} finally{
|
|
200
|
-
try {
|
|
201
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
202
|
-
_iterator.return();
|
|
203
|
-
}
|
|
204
|
-
} finally{
|
|
205
|
-
if (_didIteratorError) {
|
|
206
|
-
throw _iteratorError;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
} catch (e) {
|
|
211
|
-
return [];
|
|
212
|
-
}
|
|
213
|
-
return pubKeys;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Copy text to clipboard using pbcopy (macOS) or xclip (Linux)
|
|
217
|
-
*/ function copyToClipboard(text) {
|
|
218
|
-
return _async_to_generator(function() {
|
|
219
|
-
var spawn;
|
|
220
|
-
return _ts_generator(this, function(_state) {
|
|
221
|
-
switch(_state.label){
|
|
222
|
-
case 0:
|
|
223
|
-
return [
|
|
224
|
-
4,
|
|
225
|
-
import('child_process')
|
|
226
|
-
];
|
|
227
|
-
case 1:
|
|
228
|
-
spawn = _state.sent().spawn;
|
|
229
|
-
return [
|
|
230
|
-
2,
|
|
231
|
-
new Promise(function(resolve) {
|
|
232
|
-
var _proc_stdin, _proc_stdin1;
|
|
233
|
-
// Try pbcopy first (macOS)
|
|
234
|
-
var proc = spawn('pbcopy', [], {
|
|
235
|
-
stdio: [
|
|
236
|
-
'pipe',
|
|
237
|
-
'ignore',
|
|
238
|
-
'ignore'
|
|
239
|
-
]
|
|
240
|
-
});
|
|
241
|
-
proc.on('error', function() {
|
|
242
|
-
var _proc_stdin, _proc_stdin1;
|
|
243
|
-
// Try xclip (Linux)
|
|
244
|
-
proc = spawn('xclip', [
|
|
245
|
-
'-selection',
|
|
246
|
-
'clipboard'
|
|
247
|
-
], {
|
|
248
|
-
stdio: [
|
|
249
|
-
'pipe',
|
|
250
|
-
'ignore',
|
|
251
|
-
'ignore'
|
|
252
|
-
]
|
|
253
|
-
});
|
|
254
|
-
proc.on('error', function() {
|
|
255
|
-
resolve(false);
|
|
256
|
-
});
|
|
257
|
-
proc.on('close', function(code) {
|
|
258
|
-
resolve(code === 0);
|
|
259
|
-
});
|
|
260
|
-
(_proc_stdin = proc.stdin) === null || _proc_stdin === void 0 ? void 0 : _proc_stdin.write(text);
|
|
261
|
-
(_proc_stdin1 = proc.stdin) === null || _proc_stdin1 === void 0 ? void 0 : _proc_stdin1.end();
|
|
262
|
-
});
|
|
263
|
-
proc.on('close', function(code) {
|
|
264
|
-
resolve(code === 0);
|
|
265
|
-
});
|
|
266
|
-
(_proc_stdin = proc.stdin) === null || _proc_stdin === void 0 ? void 0 : _proc_stdin.write(text);
|
|
267
|
-
(_proc_stdin1 = proc.stdin) === null || _proc_stdin1 === void 0 ? void 0 : _proc_stdin1.end();
|
|
268
|
-
})
|
|
269
|
-
];
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
})();
|
|
273
|
-
}
|
|
274
|
-
export var AuthFormatJwkKey = function(param) {
|
|
275
|
-
var pubkeyPath = param.pubkeyPath;
|
|
276
|
-
var exit = useApp().exit;
|
|
277
|
-
var _useState = _sliced_to_array(useState(pubkeyPath ? 'success' : 'selecting'), 2), state = _useState[0], setState = _useState[1];
|
|
278
|
-
var _useState1 = _sliced_to_array(useState(null), 2), error = _useState1[0], setError = _useState1[1];
|
|
279
|
-
var _useState2 = _sliced_to_array(useState(null), 2), jwkOutput = _useState2[0], setJwkOutput = _useState2[1];
|
|
280
|
-
var _useState3 = _sliced_to_array(useState(null), 2), fingerprint = _useState3[0], setFingerprint = _useState3[1];
|
|
281
|
-
var _useState4 = _sliced_to_array(useState(false), 2), copiedToClipboard = _useState4[0], setCopiedToClipboard = _useState4[1];
|
|
282
|
-
var _useState5 = _sliced_to_array(useState(pubkeyPath || null), 2), selectedPath = _useState5[0], setSelectedPath = _useState5[1];
|
|
283
|
-
// Handle direct path provided via --pubkey
|
|
284
|
-
useEffect(function() {
|
|
285
|
-
if (pubkeyPath && state === 'success' && !jwkOutput) {
|
|
286
|
-
processKey(pubkeyPath);
|
|
287
|
-
}
|
|
288
|
-
}, [
|
|
289
|
-
pubkeyPath,
|
|
290
|
-
state,
|
|
291
|
-
jwkOutput
|
|
292
|
-
]);
|
|
293
|
-
var processKey = function(keyPath) {
|
|
294
|
-
return _async_to_generator(function() {
|
|
295
|
-
var expandedPath, keyInfo, jwkString, copied, err;
|
|
296
|
-
return _ts_generator(this, function(_state) {
|
|
297
|
-
switch(_state.label){
|
|
298
|
-
case 0:
|
|
299
|
-
_state.trys.push([
|
|
300
|
-
0,
|
|
301
|
-
2,
|
|
302
|
-
,
|
|
303
|
-
3
|
|
304
|
-
]);
|
|
305
|
-
expandedPath = expandPath(keyPath);
|
|
306
|
-
if (!existsSync(expandedPath)) {
|
|
307
|
-
setError("Public key file not found: ".concat(keyPath));
|
|
308
|
-
setState('error');
|
|
309
|
-
return [
|
|
310
|
-
2
|
|
311
|
-
];
|
|
312
|
-
}
|
|
313
|
-
keyInfo = convertSSHPubKeyToJWK(expandedPath);
|
|
314
|
-
jwkString = JSON.stringify(keyInfo.jwk, null, 2);
|
|
315
|
-
setJwkOutput(jwkString);
|
|
316
|
-
setFingerprint(keyInfo.fingerprint);
|
|
317
|
-
setSelectedPath(keyPath);
|
|
318
|
-
return [
|
|
319
|
-
4,
|
|
320
|
-
copyToClipboard(jwkString)
|
|
321
|
-
];
|
|
322
|
-
case 1:
|
|
323
|
-
copied = _state.sent();
|
|
324
|
-
setCopiedToClipboard(copied);
|
|
325
|
-
setState('success');
|
|
326
|
-
return [
|
|
327
|
-
3,
|
|
328
|
-
3
|
|
329
|
-
];
|
|
330
|
-
case 2:
|
|
331
|
-
err = _state.sent();
|
|
332
|
-
setError(err.message || 'Failed to convert key');
|
|
333
|
-
setState('error');
|
|
334
|
-
return [
|
|
335
|
-
3,
|
|
336
|
-
3
|
|
337
|
-
];
|
|
338
|
-
case 3:
|
|
339
|
-
return [
|
|
340
|
-
2
|
|
341
|
-
];
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
})();
|
|
345
|
-
};
|
|
346
|
-
// Check for available keys when in selecting state
|
|
347
|
-
var pubKeys = discoverSSHPubKeys();
|
|
348
|
-
if (state === 'selecting' && pubKeys.length === 0) {
|
|
349
|
-
return /*#__PURE__*/ React.createElement(Box, {
|
|
350
|
-
flexDirection: "column",
|
|
351
|
-
paddingTop: 1,
|
|
352
|
-
paddingBottom: 1
|
|
353
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
354
|
-
color: "yellow"
|
|
355
|
-
}, "No SSH public keys found in ~/.ssh/"), /*#__PURE__*/ React.createElement(Box, {
|
|
356
|
-
marginTop: 1,
|
|
357
|
-
flexDirection: "column"
|
|
358
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
359
|
-
dimColor: true
|
|
360
|
-
}, "Generate a new SSH key with:"), /*#__PURE__*/ React.createElement(Box, {
|
|
361
|
-
marginLeft: 2,
|
|
362
|
-
marginTop: 1
|
|
363
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
364
|
-
color: "cyan"
|
|
365
|
-
}, 'ssh-keygen -t ed25519 -C "your-email@example.com"'))), /*#__PURE__*/ React.createElement(Box, {
|
|
366
|
-
marginTop: 1
|
|
367
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
368
|
-
dimColor: true
|
|
369
|
-
}, "Or specify a public key path with: px auth format-jwk-key --pubkey /path/to/key.pub")));
|
|
370
|
-
}
|
|
371
|
-
if (state === 'selecting') {
|
|
372
|
-
var items = pubKeys.map(function(key) {
|
|
373
|
-
return {
|
|
374
|
-
id: key.path,
|
|
375
|
-
label: key.displayPath,
|
|
376
|
-
description: ''
|
|
377
|
-
};
|
|
378
|
-
});
|
|
379
|
-
var handleSelect = function(item) {
|
|
380
|
-
return _async_to_generator(function() {
|
|
381
|
-
return _ts_generator(this, function(_state) {
|
|
382
|
-
switch(_state.label){
|
|
383
|
-
case 0:
|
|
384
|
-
return [
|
|
385
|
-
4,
|
|
386
|
-
processKey(item.id)
|
|
387
|
-
];
|
|
388
|
-
case 1:
|
|
389
|
-
_state.sent();
|
|
390
|
-
return [
|
|
391
|
-
2
|
|
392
|
-
];
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
})();
|
|
396
|
-
};
|
|
397
|
-
var handleCancel = function() {
|
|
398
|
-
exit();
|
|
399
|
-
};
|
|
400
|
-
return /*#__PURE__*/ React.createElement(SelectList, {
|
|
401
|
-
items: items,
|
|
402
|
-
header: "Select an SSH public key to convert to JWK format",
|
|
403
|
-
onSelect: handleSelect,
|
|
404
|
-
onCancel: handleCancel,
|
|
405
|
-
footer: "Use arrow keys to navigate, Enter to select, q to cancel"
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
if (state === 'error') {
|
|
409
|
-
return /*#__PURE__*/ React.createElement(Box, {
|
|
410
|
-
flexDirection: "column",
|
|
411
|
-
paddingTop: 1,
|
|
412
|
-
paddingBottom: 1
|
|
413
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
414
|
-
color: "red"
|
|
415
|
-
}, "Error: ", error));
|
|
416
|
-
}
|
|
417
|
-
if (state === 'success' && jwkOutput) {
|
|
418
|
-
var displayPath = (selectedPath === null || selectedPath === void 0 ? void 0 : selectedPath.startsWith(homedir())) ? selectedPath.replace(homedir(), '~') : selectedPath;
|
|
419
|
-
return /*#__PURE__*/ React.createElement(Box, {
|
|
420
|
-
flexDirection: "column",
|
|
421
|
-
paddingTop: 1,
|
|
422
|
-
paddingBottom: 1
|
|
423
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
424
|
-
bold: true,
|
|
425
|
-
color: "green"
|
|
426
|
-
}, "JWK Public Key"), /*#__PURE__*/ React.createElement(Box, {
|
|
427
|
-
marginTop: 1
|
|
428
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
429
|
-
dimColor: true
|
|
430
|
-
}, "Source: ", displayPath)), fingerprint && /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, {
|
|
431
|
-
dimColor: true
|
|
432
|
-
}, "Fingerprint: ", fingerprint)), /*#__PURE__*/ React.createElement(Box, {
|
|
433
|
-
marginTop: 1,
|
|
434
|
-
flexDirection: "column"
|
|
435
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
436
|
-
color: "cyan"
|
|
437
|
-
}, jwkOutput)), /*#__PURE__*/ React.createElement(Box, {
|
|
438
|
-
marginTop: 1
|
|
439
|
-
}, copiedToClipboard ? /*#__PURE__*/ React.createElement(Text, {
|
|
440
|
-
color: "green"
|
|
441
|
-
}, "Copied to clipboard.") : /*#__PURE__*/ React.createElement(Text, {
|
|
442
|
-
color: "yellow"
|
|
443
|
-
}, "Could not copy to clipboard - copy the value above manually.")), /*#__PURE__*/ React.createElement(Box, {
|
|
444
|
-
marginTop: 1,
|
|
445
|
-
flexDirection: "column"
|
|
446
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
447
|
-
bold: true
|
|
448
|
-
}, "Next steps:"), /*#__PURE__*/ React.createElement(Box, {
|
|
449
|
-
marginLeft: 2,
|
|
450
|
-
marginTop: 1,
|
|
451
|
-
flexDirection: "column"
|
|
452
|
-
}, /*#__PURE__*/ React.createElement(Text, null, "1. Go to Cloudflare dashboard"), /*#__PURE__*/ React.createElement(Text, null, "2. Navigate to Workers & Pages ", '>', " Your project ", '>', " Settings ", '>', " Variables and Secrets"), /*#__PURE__*/ React.createElement(Text, null, "3. Add a new secret named ", /*#__PURE__*/ React.createElement(Text, {
|
|
453
|
-
color: "cyan"
|
|
454
|
-
}, "ROOT_PUBLIC_KEY")), /*#__PURE__*/ React.createElement(Text, null, "4. Paste the JWK value above"))));
|
|
455
|
-
}
|
|
456
|
-
return null;
|
|
457
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import { discoverSSHKeys, resolvePrivateKeyPath } from '../lib/ssh-key-utils.js';
|
|
4
|
-
import { readLocalAuth } from '../lib/local-auth.js';
|
|
5
|
-
export var AuthList = function(param) {
|
|
6
|
-
var configManager = param.configManager, projectRootPath = param.projectRootPath;
|
|
7
|
-
var discoveredKeys = discoverSSHKeys();
|
|
8
|
-
// Get the currently active key path for comparison, including local auth
|
|
9
|
-
var envPath = process.env.POSITRONIC_PRIVATE_KEY;
|
|
10
|
-
var configuredPath;
|
|
11
|
-
if (envPath) {
|
|
12
|
-
configuredPath = envPath;
|
|
13
|
-
} else if (projectRootPath) {
|
|
14
|
-
var localKeyPath = readLocalAuth(projectRootPath);
|
|
15
|
-
configuredPath = localKeyPath || configManager.getPrivateKeyPath();
|
|
16
|
-
} else {
|
|
17
|
-
configuredPath = configManager.getPrivateKeyPath();
|
|
18
|
-
}
|
|
19
|
-
var activeKeyPath = resolvePrivateKeyPath(configuredPath);
|
|
20
|
-
if (discoveredKeys.length === 0) {
|
|
21
|
-
return /*#__PURE__*/ React.createElement(Box, {
|
|
22
|
-
flexDirection: "column",
|
|
23
|
-
paddingTop: 1,
|
|
24
|
-
paddingBottom: 1
|
|
25
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
26
|
-
color: "yellow"
|
|
27
|
-
}, "No SSH keys found in ~/.ssh/"), /*#__PURE__*/ React.createElement(Box, {
|
|
28
|
-
marginTop: 1
|
|
29
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
30
|
-
dimColor: true
|
|
31
|
-
}, "Generate a new SSH key with: ssh-keygen -t ed25519")));
|
|
32
|
-
}
|
|
33
|
-
return /*#__PURE__*/ React.createElement(Box, {
|
|
34
|
-
flexDirection: "column",
|
|
35
|
-
paddingTop: 1,
|
|
36
|
-
paddingBottom: 1
|
|
37
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
38
|
-
bold: true
|
|
39
|
-
}, "Available SSH Keys (", discoveredKeys.length, "):"), /*#__PURE__*/ React.createElement(Box, {
|
|
40
|
-
marginTop: 1,
|
|
41
|
-
flexDirection: "column"
|
|
42
|
-
}, discoveredKeys.map(function(key, index) {
|
|
43
|
-
var displayPath = key.path.replace(process.env.HOME || '', '~');
|
|
44
|
-
var isActive = key.path === activeKeyPath;
|
|
45
|
-
return /*#__PURE__*/ React.createElement(Box, {
|
|
46
|
-
key: key.path,
|
|
47
|
-
flexDirection: "column",
|
|
48
|
-
marginBottom: 1
|
|
49
|
-
}, /*#__PURE__*/ React.createElement(Text, null, isActive ? /*#__PURE__*/ React.createElement(Text, {
|
|
50
|
-
color: "green"
|
|
51
|
-
}, "* ") : /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
|
|
52
|
-
bold: true,
|
|
53
|
-
color: isActive ? 'green' : undefined
|
|
54
|
-
}, displayPath)), /*#__PURE__*/ React.createElement(Box, {
|
|
55
|
-
paddingLeft: 4
|
|
56
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
57
|
-
dimColor: true
|
|
58
|
-
}, key.algorithm, " - ", key.fingerprint, key.comment ? " (".concat(key.comment, ")") : '')));
|
|
59
|
-
})), /*#__PURE__*/ React.createElement(Box, {
|
|
60
|
-
marginTop: 1
|
|
61
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
62
|
-
dimColor: true
|
|
63
|
-
}, "* = currently active key")), /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, {
|
|
64
|
-
dimColor: true
|
|
65
|
-
}, 'Run "px auth login" to configure which key to use.')));
|
|
66
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import { resolvePrivateKeyPath } from '../lib/ssh-key-utils.js';
|
|
4
|
-
import { readLocalAuth } from '../lib/local-auth.js';
|
|
5
|
-
import { existsSync } from 'fs';
|
|
6
|
-
export var AuthStatus = function(param) {
|
|
7
|
-
var configManager = param.configManager, projectRootPath = param.projectRootPath;
|
|
8
|
-
var envPath = process.env.POSITRONIC_PRIVATE_KEY;
|
|
9
|
-
var globalKeyPath = configManager.getDefaultPrivateKeyPath();
|
|
10
|
-
var currentProject = configManager.getCurrentProject();
|
|
11
|
-
var projectKeyPath = currentProject ? configManager.getProjectPrivateKeyPath(currentProject.name) : undefined;
|
|
12
|
-
var localKeyPath = projectRootPath ? readLocalAuth(projectRootPath) : null;
|
|
13
|
-
// Determine the active key path following the full priority chain:
|
|
14
|
-
// 1. Env var
|
|
15
|
-
// 2. Local project auth (.positronic-auth.json)
|
|
16
|
-
// 3. Per-project key from global config
|
|
17
|
-
// 4. Global default key
|
|
18
|
-
// 5. Fallback
|
|
19
|
-
var configuredPath;
|
|
20
|
-
if (envPath) {
|
|
21
|
-
configuredPath = envPath;
|
|
22
|
-
} else if (localKeyPath) {
|
|
23
|
-
configuredPath = localKeyPath;
|
|
24
|
-
} else {
|
|
25
|
-
configuredPath = configManager.getPrivateKeyPath();
|
|
26
|
-
}
|
|
27
|
-
var activeKeyPath = resolvePrivateKeyPath(configuredPath);
|
|
28
|
-
var keyExists = existsSync(activeKeyPath);
|
|
29
|
-
// Determine which source is being used
|
|
30
|
-
var activeSource;
|
|
31
|
-
if (envPath) {
|
|
32
|
-
activeSource = 'environment variable';
|
|
33
|
-
} else if (localKeyPath) {
|
|
34
|
-
activeSource = 'local project';
|
|
35
|
-
} else if (projectKeyPath && currentProject) {
|
|
36
|
-
activeSource = 'project "'.concat(currentProject.name, '"');
|
|
37
|
-
} else if (globalKeyPath) {
|
|
38
|
-
activeSource = 'global config';
|
|
39
|
-
} else {
|
|
40
|
-
activeSource = 'default fallback';
|
|
41
|
-
}
|
|
42
|
-
return /*#__PURE__*/ React.createElement(Box, {
|
|
43
|
-
flexDirection: "column",
|
|
44
|
-
paddingTop: 1,
|
|
45
|
-
paddingBottom: 1
|
|
46
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
47
|
-
bold: true
|
|
48
|
-
}, "Authentication Configuration"), /*#__PURE__*/ React.createElement(Box, {
|
|
49
|
-
marginTop: 1,
|
|
50
|
-
flexDirection: "column",
|
|
51
|
-
paddingLeft: 2
|
|
52
|
-
}, /*#__PURE__*/ React.createElement(Box, {
|
|
53
|
-
flexDirection: "column",
|
|
54
|
-
marginBottom: 1
|
|
55
|
-
}, /*#__PURE__*/ React.createElement(Text, null, /*#__PURE__*/ React.createElement(Text, {
|
|
56
|
-
bold: true
|
|
57
|
-
}, "Environment Variable:"), ' ', envPath ? /*#__PURE__*/ React.createElement(Text, {
|
|
58
|
-
color: "cyan"
|
|
59
|
-
}, envPath) : /*#__PURE__*/ React.createElement(Text, {
|
|
60
|
-
dimColor: true
|
|
61
|
-
}, "not set")), envPath && /*#__PURE__*/ React.createElement(Box, {
|
|
62
|
-
paddingLeft: 2
|
|
63
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
64
|
-
dimColor: true
|
|
65
|
-
}, "(POSITRONIC_PRIVATE_KEY - highest priority)"))), projectRootPath && /*#__PURE__*/ React.createElement(Box, {
|
|
66
|
-
flexDirection: "column",
|
|
67
|
-
marginBottom: 1
|
|
68
|
-
}, /*#__PURE__*/ React.createElement(Text, null, /*#__PURE__*/ React.createElement(Text, {
|
|
69
|
-
bold: true
|
|
70
|
-
}, "Local Project Key:"), ' ', localKeyPath ? /*#__PURE__*/ React.createElement(Text, {
|
|
71
|
-
color: "cyan"
|
|
72
|
-
}, localKeyPath) : /*#__PURE__*/ React.createElement(Text, {
|
|
73
|
-
dimColor: true
|
|
74
|
-
}, "not configured"))), /*#__PURE__*/ React.createElement(Box, {
|
|
75
|
-
flexDirection: "column",
|
|
76
|
-
marginBottom: 1
|
|
77
|
-
}, /*#__PURE__*/ React.createElement(Text, null, /*#__PURE__*/ React.createElement(Text, {
|
|
78
|
-
bold: true
|
|
79
|
-
}, "Global Default Key:"), ' ', globalKeyPath ? /*#__PURE__*/ React.createElement(Text, {
|
|
80
|
-
color: "cyan"
|
|
81
|
-
}, globalKeyPath) : /*#__PURE__*/ React.createElement(Text, {
|
|
82
|
-
dimColor: true
|
|
83
|
-
}, "not configured"))), currentProject && /*#__PURE__*/ React.createElement(Box, {
|
|
84
|
-
flexDirection: "column",
|
|
85
|
-
marginBottom: 1
|
|
86
|
-
}, /*#__PURE__*/ React.createElement(Text, null, /*#__PURE__*/ React.createElement(Text, {
|
|
87
|
-
bold: true
|
|
88
|
-
}, "Project Key (", currentProject.name, "):"), ' ', projectKeyPath ? /*#__PURE__*/ React.createElement(Text, {
|
|
89
|
-
color: "cyan"
|
|
90
|
-
}, projectKeyPath) : /*#__PURE__*/ React.createElement(Text, {
|
|
91
|
-
dimColor: true
|
|
92
|
-
}, "not configured (uses global)"))), /*#__PURE__*/ React.createElement(Box, {
|
|
93
|
-
marginTop: 1,
|
|
94
|
-
flexDirection: "column"
|
|
95
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
96
|
-
bold: true
|
|
97
|
-
}, "Active Key:"), /*#__PURE__*/ React.createElement(Box, {
|
|
98
|
-
paddingLeft: 2,
|
|
99
|
-
flexDirection: "column"
|
|
100
|
-
}, /*#__PURE__*/ React.createElement(Text, null, "Path: ", /*#__PURE__*/ React.createElement(Text, {
|
|
101
|
-
color: keyExists ? 'green' : 'red'
|
|
102
|
-
}, activeKeyPath)), /*#__PURE__*/ React.createElement(Text, null, "Source: ", /*#__PURE__*/ React.createElement(Text, {
|
|
103
|
-
dimColor: true
|
|
104
|
-
}, activeSource)), /*#__PURE__*/ React.createElement(Text, null, "Status:", ' ', keyExists ? /*#__PURE__*/ React.createElement(Text, {
|
|
105
|
-
color: "green"
|
|
106
|
-
}, "key file found") : /*#__PURE__*/ React.createElement(Text, {
|
|
107
|
-
color: "red"
|
|
108
|
-
}, "key file not found"))))), !globalKeyPath && !envPath && !projectKeyPath && !localKeyPath && /*#__PURE__*/ React.createElement(Box, {
|
|
109
|
-
marginTop: 1
|
|
110
|
-
}, /*#__PURE__*/ React.createElement(Text, {
|
|
111
|
-
dimColor: true
|
|
112
|
-
}, 'Run "px auth login" to configure your SSH key for authentication.')));
|
|
113
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-format-jwk-key.d.ts","sourceRoot":"","sources":["../../../src/components/auth-format-jwk-key.tsx"],"names":[],"mappings":"AAQA,UAAU,qBAAqB;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAoED,eAAO,MAAM,gBAAgB,GAAI,gBAAgB,qBAAqB,mDAgJrE,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ProjectConfigManager } from '../commands/project-config-manager.js';
|
|
2
|
-
interface AuthListProps {
|
|
3
|
-
configManager: ProjectConfigManager;
|
|
4
|
-
projectRootPath?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const AuthList: ({ configManager, projectRootPath }: AuthListProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=auth-list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-list.d.ts","sourceRoot":"","sources":["../../../src/components/auth-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAIlF,UAAU,aAAa;IACrB,aAAa,EAAE,oBAAoB,CAAC;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,QAAQ,GAAI,oCAAoC,aAAa,4CAyEzE,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ProjectConfigManager } from '../commands/project-config-manager.js';
|
|
2
|
-
interface AuthStatusProps {
|
|
3
|
-
configManager: ProjectConfigManager;
|
|
4
|
-
projectRootPath?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const AuthStatus: ({ configManager, projectRootPath }: AuthStatusProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=auth-status.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-status.d.ts","sourceRoot":"","sources":["../../../src/components/auth-status.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAKlF,UAAU,eAAe;IACvB,aAAa,EAAE,oBAAoB,CAAC;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,UAAU,GAAI,oCAAoC,eAAe,4CAuI7E,CAAC"}
|