@positronic/cli 0.0.57 → 0.0.59
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 +9 -0
- package/dist/src/commands/auth.js +13 -0
- package/dist/src/commands/helpers.js +60 -27
- package/dist/src/components/auth-format-jwk-key.js +457 -0
- package/dist/src/components/auth-login.js +3 -3
- package/dist/src/components/auth-logout.js +3 -3
- package/dist/src/hooks/useApi.js +183 -49
- package/dist/src/lib/jwt-auth.js +364 -0
- package/dist/src/lib/ssh-key-utils.js +0 -9
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/commands/auth.d.ts +8 -0
- package/dist/types/commands/auth.d.ts.map +1 -1
- package/dist/types/commands/helpers.d.ts +4 -0
- package/dist/types/commands/helpers.d.ts.map +1 -1
- package/dist/types/components/auth-format-jwk-key.d.ts +6 -0
- package/dist/types/components/auth-format-jwk-key.d.ts.map +1 -0
- package/dist/types/hooks/useApi.d.ts.map +1 -1
- package/dist/types/lib/jwt-auth.d.ts +51 -0
- package/dist/types/lib/jwt-auth.d.ts.map +1 -0
- package/dist/types/lib/ssh-key-utils.d.ts +0 -4
- package/dist/types/lib/ssh-key-utils.d.ts.map +1 -1
- package/package.json +5 -4
- package/dist/src/lib/request-signer.js +0 -208
- package/dist/types/lib/request-signer.d.ts +0 -51
- package/dist/types/lib/request-signer.d.ts.map +0 -1
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _class_call_check(instance, Constructor) {
|
|
31
|
+
if (!(instance instanceof Constructor)) {
|
|
32
|
+
throw new TypeError("Cannot call a class as a function");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function _defineProperties(target, props) {
|
|
36
|
+
for(var i = 0; i < props.length; i++){
|
|
37
|
+
var descriptor = props[i];
|
|
38
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
39
|
+
descriptor.configurable = true;
|
|
40
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
41
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
45
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
46
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
47
|
+
return Constructor;
|
|
48
|
+
}
|
|
49
|
+
function _define_property(obj, key, value) {
|
|
50
|
+
if (key in obj) {
|
|
51
|
+
Object.defineProperty(obj, key, {
|
|
52
|
+
value: value,
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
obj[key] = value;
|
|
59
|
+
}
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
function _instanceof(left, right) {
|
|
63
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
64
|
+
return !!right[Symbol.hasInstance](left);
|
|
65
|
+
} else {
|
|
66
|
+
return left instanceof right;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function _ts_generator(thisArg, body) {
|
|
70
|
+
var f, y, t, _ = {
|
|
71
|
+
label: 0,
|
|
72
|
+
sent: function() {
|
|
73
|
+
if (t[0] & 1) throw t[1];
|
|
74
|
+
return t[1];
|
|
75
|
+
},
|
|
76
|
+
trys: [],
|
|
77
|
+
ops: []
|
|
78
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
79
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
80
|
+
return this;
|
|
81
|
+
}), g;
|
|
82
|
+
function verb(n) {
|
|
83
|
+
return function(v) {
|
|
84
|
+
return step([
|
|
85
|
+
n,
|
|
86
|
+
v
|
|
87
|
+
]);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function step(op) {
|
|
91
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
92
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
93
|
+
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;
|
|
94
|
+
if (y = 0, t) op = [
|
|
95
|
+
op[0] & 2,
|
|
96
|
+
t.value
|
|
97
|
+
];
|
|
98
|
+
switch(op[0]){
|
|
99
|
+
case 0:
|
|
100
|
+
case 1:
|
|
101
|
+
t = op;
|
|
102
|
+
break;
|
|
103
|
+
case 4:
|
|
104
|
+
_.label++;
|
|
105
|
+
return {
|
|
106
|
+
value: op[1],
|
|
107
|
+
done: false
|
|
108
|
+
};
|
|
109
|
+
case 5:
|
|
110
|
+
_.label++;
|
|
111
|
+
y = op[1];
|
|
112
|
+
op = [
|
|
113
|
+
0
|
|
114
|
+
];
|
|
115
|
+
continue;
|
|
116
|
+
case 7:
|
|
117
|
+
op = _.ops.pop();
|
|
118
|
+
_.trys.pop();
|
|
119
|
+
continue;
|
|
120
|
+
default:
|
|
121
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
122
|
+
_ = 0;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
126
|
+
_.label = op[1];
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
130
|
+
_.label = t[1];
|
|
131
|
+
t = op;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
if (t && _.label < t[2]) {
|
|
135
|
+
_.label = t[2];
|
|
136
|
+
_.ops.push(op);
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
if (t[2]) _.ops.pop();
|
|
140
|
+
_.trys.pop();
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
op = body.call(thisArg, _);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
op = [
|
|
146
|
+
6,
|
|
147
|
+
e
|
|
148
|
+
];
|
|
149
|
+
y = 0;
|
|
150
|
+
} finally{
|
|
151
|
+
f = t = 0;
|
|
152
|
+
}
|
|
153
|
+
if (op[0] & 5) throw op[1];
|
|
154
|
+
return {
|
|
155
|
+
value: op[0] ? op[1] : void 0,
|
|
156
|
+
done: true
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
import { SignJWT, importPKCS8 } from 'jose';
|
|
161
|
+
import { existsSync } from 'fs';
|
|
162
|
+
import { loadPrivateKey, getPrivateKeyFingerprint, resolvePrivateKeyPath } from './ssh-key-utils.js';
|
|
163
|
+
import { ProjectConfigManager } from '../commands/project-config-manager.js';
|
|
164
|
+
/**
|
|
165
|
+
* JWT Auth Provider for authenticating API requests
|
|
166
|
+
* Uses SSH private keys to sign short-lived JWTs
|
|
167
|
+
*/ export var JwtAuthProvider = /*#__PURE__*/ function() {
|
|
168
|
+
"use strict";
|
|
169
|
+
function JwtAuthProvider() {
|
|
170
|
+
_class_call_check(this, JwtAuthProvider);
|
|
171
|
+
_define_property(this, "privateKey", null);
|
|
172
|
+
_define_property(this, "fingerprint", null);
|
|
173
|
+
_define_property(this, "initialized", false);
|
|
174
|
+
_define_property(this, "initError", null);
|
|
175
|
+
this.initialize();
|
|
176
|
+
}
|
|
177
|
+
_create_class(JwtAuthProvider, [
|
|
178
|
+
{
|
|
179
|
+
key: "initialize",
|
|
180
|
+
value: function initialize() {
|
|
181
|
+
try {
|
|
182
|
+
// Get configured path from project config manager
|
|
183
|
+
var configManager = new ProjectConfigManager();
|
|
184
|
+
var configuredPath = configManager.getPrivateKeyPath();
|
|
185
|
+
var keyPath = resolvePrivateKeyPath(configuredPath);
|
|
186
|
+
if (!existsSync(keyPath)) {
|
|
187
|
+
this.initError = new Error("Private key not found at ".concat(keyPath, ". Run 'px auth login' to configure your SSH key, or set POSITRONIC_PRIVATE_KEY environment variable."));
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.privateKey = loadPrivateKey(keyPath);
|
|
191
|
+
this.fingerprint = getPrivateKeyFingerprint(this.privateKey);
|
|
192
|
+
this.initialized = true;
|
|
193
|
+
} catch (error) {
|
|
194
|
+
this.initError = _instanceof(error, Error) ? error : new Error('Failed to initialize JWT auth provider');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
/**
|
|
200
|
+
* Check if the provider is ready to create JWTs
|
|
201
|
+
*/ key: "isReady",
|
|
202
|
+
value: function isReady() {
|
|
203
|
+
return this.initialized && this.privateKey !== null;
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
/**
|
|
208
|
+
* Get the error that occurred during initialization, if any
|
|
209
|
+
*/ key: "getError",
|
|
210
|
+
value: function getError() {
|
|
211
|
+
return this.initError;
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
/**
|
|
216
|
+
* Get the fingerprint of the loaded private key
|
|
217
|
+
*/ key: "getFingerprint",
|
|
218
|
+
value: function getFingerprint() {
|
|
219
|
+
return this.fingerprint;
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
key: "getAlgorithm",
|
|
224
|
+
value: /**
|
|
225
|
+
* Map SSH key type to JWT algorithm
|
|
226
|
+
*/ function getAlgorithm() {
|
|
227
|
+
if (!this.privateKey) {
|
|
228
|
+
throw new Error('Private key not loaded');
|
|
229
|
+
}
|
|
230
|
+
var keyType = this.privateKey.type;
|
|
231
|
+
if (keyType === 'rsa') {
|
|
232
|
+
return 'RS256';
|
|
233
|
+
} else if (keyType === 'ecdsa') {
|
|
234
|
+
// ECDSA curve determines algorithm
|
|
235
|
+
var curve = this.privateKey.curve;
|
|
236
|
+
if (curve === 'nistp256') {
|
|
237
|
+
return 'ES256';
|
|
238
|
+
} else if (curve === 'nistp384') {
|
|
239
|
+
return 'ES384';
|
|
240
|
+
} else if (curve === 'nistp521') {
|
|
241
|
+
return 'ES512';
|
|
242
|
+
}
|
|
243
|
+
// Default to ES256 for unknown curves
|
|
244
|
+
return 'ES256';
|
|
245
|
+
} else if (keyType === 'ed25519') {
|
|
246
|
+
return 'EdDSA';
|
|
247
|
+
}
|
|
248
|
+
throw new Error("Unsupported key type: ".concat(keyType));
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
key: "createToken",
|
|
253
|
+
value: /**
|
|
254
|
+
* Create a short-lived JWT for authentication
|
|
255
|
+
*/ function createToken() {
|
|
256
|
+
return _async_to_generator(function() {
|
|
257
|
+
var algorithm, pkcs8Pem, joseKey, jwt;
|
|
258
|
+
return _ts_generator(this, function(_state) {
|
|
259
|
+
switch(_state.label){
|
|
260
|
+
case 0:
|
|
261
|
+
if (!this.privateKey || !this.fingerprint) {
|
|
262
|
+
throw new Error('JWT auth provider not initialized');
|
|
263
|
+
}
|
|
264
|
+
algorithm = this.getAlgorithm();
|
|
265
|
+
// Convert SSH private key to PKCS8 PEM format
|
|
266
|
+
pkcs8Pem = this.privateKey.toString('pkcs8');
|
|
267
|
+
return [
|
|
268
|
+
4,
|
|
269
|
+
importPKCS8(pkcs8Pem, algorithm)
|
|
270
|
+
];
|
|
271
|
+
case 1:
|
|
272
|
+
joseKey = _state.sent();
|
|
273
|
+
return [
|
|
274
|
+
4,
|
|
275
|
+
new SignJWT({}).setProtectedHeader({
|
|
276
|
+
alg: algorithm
|
|
277
|
+
}).setSubject(this.fingerprint).setIssuedAt().setExpirationTime('30s').sign(joseKey)
|
|
278
|
+
];
|
|
279
|
+
case 2:
|
|
280
|
+
jwt = _state.sent();
|
|
281
|
+
return [
|
|
282
|
+
2,
|
|
283
|
+
jwt
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}).call(this);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
]);
|
|
291
|
+
return JwtAuthProvider;
|
|
292
|
+
}();
|
|
293
|
+
// Singleton instance
|
|
294
|
+
var providerInstance = null;
|
|
295
|
+
/**
|
|
296
|
+
* Get the singleton JWT auth provider instance
|
|
297
|
+
*/ export function getJwtAuthProvider() {
|
|
298
|
+
if (!providerInstance) {
|
|
299
|
+
providerInstance = new JwtAuthProvider();
|
|
300
|
+
}
|
|
301
|
+
return providerInstance;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Reset the JWT auth provider singleton
|
|
305
|
+
* Call this after auth config changes to force reinitialization with new key
|
|
306
|
+
*/ export function resetJwtAuthProvider() {
|
|
307
|
+
providerInstance = null;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Check if JWT auth is available
|
|
311
|
+
*/ export function isAuthAvailable() {
|
|
312
|
+
return getJwtAuthProvider().isReady();
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Get the Authorization header if auth is available
|
|
316
|
+
* Returns { Authorization: 'Bearer <token>' } or empty object
|
|
317
|
+
*/ export function getAuthHeader() {
|
|
318
|
+
return _async_to_generator(function() {
|
|
319
|
+
var provider, token, error;
|
|
320
|
+
return _ts_generator(this, function(_state) {
|
|
321
|
+
switch(_state.label){
|
|
322
|
+
case 0:
|
|
323
|
+
provider = getJwtAuthProvider();
|
|
324
|
+
if (!provider.isReady()) {
|
|
325
|
+
return [
|
|
326
|
+
2,
|
|
327
|
+
{}
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
_state.label = 1;
|
|
331
|
+
case 1:
|
|
332
|
+
_state.trys.push([
|
|
333
|
+
1,
|
|
334
|
+
3,
|
|
335
|
+
,
|
|
336
|
+
4
|
|
337
|
+
]);
|
|
338
|
+
return [
|
|
339
|
+
4,
|
|
340
|
+
provider.createToken()
|
|
341
|
+
];
|
|
342
|
+
case 2:
|
|
343
|
+
token = _state.sent();
|
|
344
|
+
return [
|
|
345
|
+
2,
|
|
346
|
+
{
|
|
347
|
+
Authorization: "Bearer ".concat(token)
|
|
348
|
+
}
|
|
349
|
+
];
|
|
350
|
+
case 3:
|
|
351
|
+
error = _state.sent();
|
|
352
|
+
console.error('Warning: Failed to create auth token:', error);
|
|
353
|
+
return [
|
|
354
|
+
2,
|
|
355
|
+
{}
|
|
356
|
+
];
|
|
357
|
+
case 4:
|
|
358
|
+
return [
|
|
359
|
+
2
|
|
360
|
+
];
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
})();
|
|
364
|
+
}
|
|
@@ -171,15 +171,6 @@ import { createPublicKey } from 'crypto';
|
|
|
171
171
|
var publicKey = privateKey.toPublic();
|
|
172
172
|
return publicKey.fingerprint('sha256').toString();
|
|
173
173
|
}
|
|
174
|
-
/**
|
|
175
|
-
* Sign data with an SSH private key
|
|
176
|
-
*/ export function signWithPrivateKey(privateKey, data) {
|
|
177
|
-
var dataBuffer = typeof data === 'string' ? Buffer.from(data) : data;
|
|
178
|
-
var signer = privateKey.createSign('sha256');
|
|
179
|
-
signer.update(dataBuffer);
|
|
180
|
-
var signature = signer.sign();
|
|
181
|
-
return signature.toBuffer('raw');
|
|
182
|
-
}
|
|
183
174
|
/**
|
|
184
175
|
* Resolve the private key path from environment, config, or default
|
|
185
176
|
* @param configuredPath - Optional configured path from ProjectConfigManager
|
package/dist/types/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAK5D,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,KAAK,GAAG,CAAC;CAC9C;AAoBD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAK5D,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,KAAK,GAAG,CAAC;CAC9C;AAoBD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,UAAU,4BAu5C3C"}
|
|
@@ -8,6 +8,9 @@ interface LoginArgs {
|
|
|
8
8
|
interface LogoutArgs {
|
|
9
9
|
project?: boolean;
|
|
10
10
|
}
|
|
11
|
+
interface FormatJwkKeyArgs {
|
|
12
|
+
pubkey?: string;
|
|
13
|
+
}
|
|
11
14
|
export declare class AuthCommand {
|
|
12
15
|
private configManager;
|
|
13
16
|
constructor(configManager?: ProjectConfigManager);
|
|
@@ -31,6 +34,11 @@ export declare class AuthCommand {
|
|
|
31
34
|
* List available SSH keys.
|
|
32
35
|
*/
|
|
33
36
|
list(): React.ReactElement;
|
|
37
|
+
/**
|
|
38
|
+
* Handles the 'px auth format-jwk-key' command.
|
|
39
|
+
* Convert an SSH public key to JWK format for ROOT_PUBLIC_KEY configuration.
|
|
40
|
+
*/
|
|
41
|
+
formatJwkKey({ pubkey }: ArgumentsCamelCase<FormatJwkKeyArgs>): React.ReactElement;
|
|
34
42
|
}
|
|
35
43
|
export {};
|
|
36
44
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,UAAU,SAAS;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,UAAU;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,gBAAgB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,aAAa,CAAuB;gBAEhC,aAAa,CAAC,EAAE,oBAAoB;IAIhD;;;OAGG;IACH,MAAM,IAAI,KAAK,CAAC,YAAY;IAM5B;;;OAGG;IACH,KAAK,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,kBAAkB,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC,YAAY;IAQ3E;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,kBAAkB,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC,YAAY;IAOvE;;;OAGG;IACH,IAAI,IAAI,KAAK,CAAC,YAAY;IAM1B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,YAAY;CAKnF"}
|
|
@@ -24,6 +24,10 @@ export declare function isApiLocalDevMode(): boolean;
|
|
|
24
24
|
export declare function getApiBaseUrl(): string;
|
|
25
25
|
export declare const apiClient: {
|
|
26
26
|
fetch: (apiPath: string, options?: RequestInit) => Promise<Response>;
|
|
27
|
+
/**
|
|
28
|
+
* Fetch without authentication - used for unauthenticated endpoints like /auth/setup
|
|
29
|
+
*/
|
|
30
|
+
fetchUnauthenticated: (apiPath: string, options?: RequestInit) => Promise<Response>;
|
|
27
31
|
};
|
|
28
32
|
export declare function generateProject(projectName: string, projectDir: string): Promise<void>;
|
|
29
33
|
export declare function scanLocalResources(resourcesDir: string): ResourceEntry[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/commands/helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAUtD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CAC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,EAC7B,UAAU,CAAC,EAAE,gBAAgB,EAC7B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CA2If"}
|
|
@@ -0,0 +1 @@
|
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useApi.d.ts","sourceRoot":"","sources":["../../../src/hooks/useApi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useApi.d.ts","sourceRoot":"","sources":["../../../src/hooks/useApi.ts"],"names":[],"mappings":"AA2EA,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;;;;eAIjD,MAAM;iBACJ,MAAM;kBACL,MAAM;;EAgDnB;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,GAAG;;;;eAIzD,MAAM;iBACJ,MAAM;kBACL,MAAM;;qBAIF,GAAG,YAAY,GAAG;EA0DnC;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM;;;eAGtC,MAAM;iBACJ,MAAM;kBACL,MAAM;;wBAIC,MAAM,YAAY,GAAG;EAsDzC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JWT Auth Provider for authenticating API requests
|
|
3
|
+
* Uses SSH private keys to sign short-lived JWTs
|
|
4
|
+
*/
|
|
5
|
+
export declare class JwtAuthProvider {
|
|
6
|
+
private privateKey;
|
|
7
|
+
private fingerprint;
|
|
8
|
+
private initialized;
|
|
9
|
+
private initError;
|
|
10
|
+
constructor();
|
|
11
|
+
private initialize;
|
|
12
|
+
/**
|
|
13
|
+
* Check if the provider is ready to create JWTs
|
|
14
|
+
*/
|
|
15
|
+
isReady(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Get the error that occurred during initialization, if any
|
|
18
|
+
*/
|
|
19
|
+
getError(): Error | null;
|
|
20
|
+
/**
|
|
21
|
+
* Get the fingerprint of the loaded private key
|
|
22
|
+
*/
|
|
23
|
+
getFingerprint(): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Map SSH key type to JWT algorithm
|
|
26
|
+
*/
|
|
27
|
+
private getAlgorithm;
|
|
28
|
+
/**
|
|
29
|
+
* Create a short-lived JWT for authentication
|
|
30
|
+
*/
|
|
31
|
+
createToken(): Promise<string>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the singleton JWT auth provider instance
|
|
35
|
+
*/
|
|
36
|
+
export declare function getJwtAuthProvider(): JwtAuthProvider;
|
|
37
|
+
/**
|
|
38
|
+
* Reset the JWT auth provider singleton
|
|
39
|
+
* Call this after auth config changes to force reinitialization with new key
|
|
40
|
+
*/
|
|
41
|
+
export declare function resetJwtAuthProvider(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Check if JWT auth is available
|
|
44
|
+
*/
|
|
45
|
+
export declare function isAuthAvailable(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get the Authorization header if auth is available
|
|
48
|
+
* Returns { Authorization: 'Bearer <token>' } or empty object
|
|
49
|
+
*/
|
|
50
|
+
export declare function getAuthHeader(): Promise<Record<string, string>>;
|
|
51
|
+
//# sourceMappingURL=jwt-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-auth.d.ts","sourceRoot":"","sources":["../../../src/lib/jwt-auth.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAsB;;IAMvC,OAAO,CAAC,UAAU;IA0BlB;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,QAAQ,IAAI,KAAK,GAAG,IAAI;IAIxB;;OAEG;IACH,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACH,OAAO,CAAC,YAAY;IA4BpB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;CAuBrC;AAKD;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAKpD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAarE"}
|
|
@@ -29,10 +29,6 @@ export declare function loadPrivateKey(pathOrEnv?: string): sshpk.PrivateKey;
|
|
|
29
29
|
* Get the fingerprint of a private key (from its public component)
|
|
30
30
|
*/
|
|
31
31
|
export declare function getPrivateKeyFingerprint(privateKey: sshpk.PrivateKey): string;
|
|
32
|
-
/**
|
|
33
|
-
* Sign data with an SSH private key
|
|
34
|
-
*/
|
|
35
|
-
export declare function signWithPrivateKey(privateKey: sshpk.PrivateKey, data: Buffer | string): Buffer;
|
|
36
32
|
/**
|
|
37
33
|
* Resolve the private key path from environment, config, or default
|
|
38
34
|
* @param configuredPath - Optional configured path from ProjectConfigManager
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-key-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/ssh-key-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAmB,UAAU,EAAE,MAAM,QAAQ,CAAC;AAErD,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,UAAU,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C,UAAU,CAyBnE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,GAAG,MAAM,CAG7E;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAoB5E;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAKlD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@positronic/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"clean": "rm -rf tsconfig.tsbuildinfo dist node_modules"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@positronic/core": "^0.0.
|
|
27
|
-
"@positronic/spec": "^0.0.
|
|
28
|
-
"@positronic/template-new-project": "^0.0.
|
|
26
|
+
"@positronic/core": "^0.0.59",
|
|
27
|
+
"@positronic/spec": "^0.0.59",
|
|
28
|
+
"@positronic/template-new-project": "^0.0.59",
|
|
29
29
|
"caz": "^2.0.0",
|
|
30
30
|
"chokidar": "^3.6.0",
|
|
31
31
|
"dotenv": "^16.4.7",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"ink": "^5.2.1",
|
|
34
34
|
"ink-text-input": "^6.0.0",
|
|
35
35
|
"istextorbinary": "^9.5.0",
|
|
36
|
+
"jose": "^5.2.0",
|
|
36
37
|
"node-fetch": "^3.3.2",
|
|
37
38
|
"react": "^18.3.1",
|
|
38
39
|
"react-robot": "^1.2.1",
|