phirepass-widgets 0.0.13 → 0.0.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.
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
6
6
  const defineCustomElements = async (win, options) => {
7
7
  if (typeof window === 'undefined') return undefined;
8
8
  await appGlobals.globalScripts();
9
- return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[257,"phirepass-sftp-client"]]],["phirepass-terminal.cjs",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
9
+ return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[257,"phirepass-sftp-client"]]],["phirepass-terminal.cjs",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
10
10
  };
11
11
 
12
12
  exports.setNonce = index.setNonce;
@@ -227,6 +227,18 @@ class Channel {
227
227
  const ptr = this.__destroy_into_raw();
228
228
  wasm.__wbg_channel_free(ptr, 0);
229
229
  }
230
+ /**
231
+ * @param {string} token
232
+ * @param {string} node_id
233
+ * @param {number | null} [msg_id]
234
+ */
235
+ authenticate(token, node_id, msg_id) {
236
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_export, wasm.__wbindgen_export2);
237
+ const len0 = WASM_VECTOR_LEN;
238
+ const ptr1 = passStringToWasm0(node_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
239
+ const len1 = WASM_VECTOR_LEN;
240
+ wasm.channel_authenticate(this.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(msg_id) ? 0x100000001 : (msg_id) >>> 0);
241
+ }
230
242
  connect() {
231
243
  wasm.channel_connect(this.__wbg_ptr);
232
244
  }
@@ -582,7 +594,7 @@ function __wbg_get_imports() {
582
594
  __wbg_set_onopen_34e3e24cf9337ddd: function(arg0, arg1) {
583
595
  getObject(arg0).onopen = getObject(arg1);
584
596
  },
585
- __wbg_warn_5bd788cc2f780742: function(arg0, arg1) {
597
+ __wbg_warn_3ba994e68c965ce3: function(arg0, arg1) {
586
598
  console.warn(getStringFromWasm0(arg0, arg1));
587
599
  },
588
600
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
@@ -1051,11 +1063,12 @@ const PhirepassTerminal = class {
1051
1063
  allowInsecure = false;
1052
1064
  heartbeatInterval = 30_000;
1053
1065
  nodeId;
1066
+ token;
1054
1067
  onNodeIdChange(newValue, _oldValue) {
1055
1068
  // Handle the change in node_id here
1056
1069
  // console.log(`node_id changed from ${oldValue} to ${newValue}`);
1057
1070
  // Always clear local session state and reset terminal view
1058
- this.resetSessionState();
1071
+ this.reset_session_state();
1059
1072
  this.terminal.reset();
1060
1073
  // Close existing comms if connected
1061
1074
  if (this.channel && this.channel.is_connected()) {
@@ -1135,8 +1148,7 @@ const PhirepassTerminal = class {
1135
1148
  this.channel = new Channel(`${this.createWebSocketEndpoint()}/api/web/ws`, this.nodeId);
1136
1149
  }
1137
1150
  this.channel.on_connection_open(() => {
1138
- this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
1139
- this.channel.open_ssh_tunnel(this.nodeId);
1151
+ this.channel.authenticate(this.token, this.nodeId);
1140
1152
  });
1141
1153
  this.channel.on_connection_close(() => {
1142
1154
  this.terminal.reset();
@@ -1153,6 +1165,9 @@ const PhirepassTerminal = class {
1153
1165
  case "Error":
1154
1166
  this.handle_error(web);
1155
1167
  break;
1168
+ case "AuthSuccess":
1169
+ this.handleAuthSuccess(web);
1170
+ break;
1156
1171
  case "TunnelOpened":
1157
1172
  this.session_id = web.sid;
1158
1173
  this.terminal.reset();
@@ -1219,27 +1234,30 @@ const PhirepassTerminal = class {
1219
1234
  this.channel.stop_heartbeat();
1220
1235
  this.channel.disconnect();
1221
1236
  }
1222
- cancelCredentialEntry() {
1237
+ cancel_credential_entry() {
1223
1238
  this.inputMode = InputMode.Default;
1224
- this.usernameBuffer = "";
1225
- this.passwordBuffer = "";
1239
+ this.clear_creds_buffer();
1226
1240
  this.terminal.writeln("Authentication cancelled.");
1227
1241
  this.terminal.reset();
1228
1242
  }
1229
- resetSessionState() {
1230
- this.session_id = undefined;
1231
- this.inputMode = InputMode.Default;
1243
+ clear_creds_buffer() {
1232
1244
  this.usernameBuffer = "";
1233
1245
  this.passwordBuffer = "";
1234
1246
  }
1247
+ reset_session_state() {
1248
+ this.session_id = undefined;
1249
+ this.inputMode = InputMode.Default;
1250
+ this.clear_creds_buffer();
1251
+ }
1252
+ handleAuthSuccess(_auth_) {
1253
+ this.clear_creds_buffer();
1254
+ this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
1255
+ this.channel.open_ssh_tunnel(this.nodeId);
1256
+ }
1235
1257
  handleTunnelClosed() {
1236
- // Clear session state
1237
1258
  this.session_id = undefined;
1238
1259
  this.inputMode = InputMode.Default;
1239
- // Clear credential buffers for security
1240
- this.usernameBuffer = "";
1241
- this.passwordBuffer = "";
1242
- // Reset terminal display
1260
+ this.clear_creds_buffer();
1243
1261
  this.terminal.reset();
1244
1262
  this.terminal.writeln("Connection closed.");
1245
1263
  }
@@ -1287,7 +1305,7 @@ const PhirepassTerminal = class {
1287
1305
  }
1288
1306
  if (data === "\u0003") {
1289
1307
  this.terminal.write("^C\r\n");
1290
- this.cancelCredentialEntry();
1308
+ this.cancel_credential_entry();
1291
1309
  return;
1292
1310
  }
1293
1311
  if (data === "\u007f") {
@@ -1324,7 +1342,7 @@ const PhirepassTerminal = class {
1324
1342
  }
1325
1343
  if (data === "\u0003") {
1326
1344
  this.terminal.write("^C\r\n");
1327
- this.cancelCredentialEntry();
1345
+ this.cancel_credential_entry();
1328
1346
  return;
1329
1347
  }
1330
1348
  if (data === "\u007f") {
@@ -1359,7 +1377,7 @@ const PhirepassTerminal = class {
1359
1377
  this.usernameBuffer = "";
1360
1378
  }
1361
1379
  render() {
1362
- return (index.h(index.Host, { key: '885e11a9806ba614dda57e491f9d67fddd9aca9e' }, index.h("div", { key: 'ea169bd62479b9f831989f244f640777d48d65c4', id: "ccc" })));
1380
+ return (index.h(index.Host, { key: '0b5fe3ada16e417d82d44cfa9fb900972ed7d49a' }, index.h("div", { key: '8b2a23b7954b1f36636f52a747f82a46a118943e', id: "ccc" })));
1363
1381
  }
1364
1382
  static get watchers() { return {
1365
1383
  "nodeId": [{
@@ -19,7 +19,7 @@ var patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(async (options) => {
21
21
  await appGlobals.globalScripts();
22
- return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[257,"phirepass-sftp-client"]]],["phirepass-terminal.cjs",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
22
+ return index.bootstrapLazy([["phirepass-sftp-client.cjs",[[257,"phirepass-sftp-client"]]],["phirepass-terminal.cjs",[[513,"phirepass-terminal",{"terminalOptions":[16],"serverHost":[1,"server-host"],"serverPort":[2,"server-port"],"allowInsecure":[4,"allow-insecure"],"heartbeatInterval":[2,"heartbeat-interval"],"nodeId":[1,"node-id"],"token":[1],"serverId":[1,"server-id"]},null,{"nodeId":[{"onNodeIdChange":0}],"serverId":[{"onServerIdChange":0}]}]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -88,11 +88,12 @@ export class PhirepassTerminal {
88
88
  allowInsecure = false;
89
89
  heartbeatInterval = 30_000;
90
90
  nodeId;
91
+ token;
91
92
  onNodeIdChange(newValue, _oldValue) {
92
93
  // Handle the change in node_id here
93
94
  // console.log(`node_id changed from ${oldValue} to ${newValue}`);
94
95
  // Always clear local session state and reset terminal view
95
- this.resetSessionState();
96
+ this.reset_session_state();
96
97
  this.terminal.reset();
97
98
  // Close existing comms if connected
98
99
  if (this.channel && this.channel.is_connected()) {
@@ -172,8 +173,7 @@ export class PhirepassTerminal {
172
173
  this.channel = new PhirepassChannel(`${this.createWebSocketEndpoint()}/api/web/ws`, this.nodeId);
173
174
  }
174
175
  this.channel.on_connection_open(() => {
175
- this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
176
- this.channel.open_ssh_tunnel(this.nodeId);
176
+ this.channel.authenticate(this.token, this.nodeId);
177
177
  });
178
178
  this.channel.on_connection_close(() => {
179
179
  this.terminal.reset();
@@ -190,6 +190,9 @@ export class PhirepassTerminal {
190
190
  case "Error":
191
191
  this.handle_error(web);
192
192
  break;
193
+ case "AuthSuccess":
194
+ this.handleAuthSuccess(web);
195
+ break;
193
196
  case "TunnelOpened":
194
197
  this.session_id = web.sid;
195
198
  this.terminal.reset();
@@ -256,27 +259,30 @@ export class PhirepassTerminal {
256
259
  this.channel.stop_heartbeat();
257
260
  this.channel.disconnect();
258
261
  }
259
- cancelCredentialEntry() {
262
+ cancel_credential_entry() {
260
263
  this.inputMode = InputMode.Default;
261
- this.usernameBuffer = "";
262
- this.passwordBuffer = "";
264
+ this.clear_creds_buffer();
263
265
  this.terminal.writeln("Authentication cancelled.");
264
266
  this.terminal.reset();
265
267
  }
266
- resetSessionState() {
267
- this.session_id = undefined;
268
- this.inputMode = InputMode.Default;
268
+ clear_creds_buffer() {
269
269
  this.usernameBuffer = "";
270
270
  this.passwordBuffer = "";
271
271
  }
272
+ reset_session_state() {
273
+ this.session_id = undefined;
274
+ this.inputMode = InputMode.Default;
275
+ this.clear_creds_buffer();
276
+ }
277
+ handleAuthSuccess(_auth_) {
278
+ this.clear_creds_buffer();
279
+ this.channel.start_heartbeat(this.heartbeatInterval <= 15_000 ? 30_000 : this.heartbeatInterval);
280
+ this.channel.open_ssh_tunnel(this.nodeId);
281
+ }
272
282
  handleTunnelClosed() {
273
- // Clear session state
274
283
  this.session_id = undefined;
275
284
  this.inputMode = InputMode.Default;
276
- // Clear credential buffers for security
277
- this.usernameBuffer = "";
278
- this.passwordBuffer = "";
279
- // Reset terminal display
285
+ this.clear_creds_buffer();
280
286
  this.terminal.reset();
281
287
  this.terminal.writeln("Connection closed.");
282
288
  }
@@ -324,7 +330,7 @@ export class PhirepassTerminal {
324
330
  }
325
331
  if (data === "\u0003") {
326
332
  this.terminal.write("^C\r\n");
327
- this.cancelCredentialEntry();
333
+ this.cancel_credential_entry();
328
334
  return;
329
335
  }
330
336
  if (data === "\u007f") {
@@ -361,7 +367,7 @@ export class PhirepassTerminal {
361
367
  }
362
368
  if (data === "\u0003") {
363
369
  this.terminal.write("^C\r\n");
364
- this.cancelCredentialEntry();
370
+ this.cancel_credential_entry();
365
371
  return;
366
372
  }
367
373
  if (data === "\u007f") {
@@ -396,7 +402,7 @@ export class PhirepassTerminal {
396
402
  this.usernameBuffer = "";
397
403
  }
398
404
  render() {
399
- return (h(Host, { key: '885e11a9806ba614dda57e491f9d67fddd9aca9e' }, h("div", { key: 'ea169bd62479b9f831989f244f640777d48d65c4', id: "ccc" })));
405
+ return (h(Host, { key: '0b5fe3ada16e417d82d44cfa9fb900972ed7d49a' }, h("div", { key: '8b2a23b7954b1f36636f52a747f82a46a118943e', id: "ccc" })));
400
406
  }
401
407
  static get is() { return "phirepass-terminal"; }
402
408
  static get encapsulation() { return "shadow"; }
@@ -519,7 +525,7 @@ export class PhirepassTerminal {
519
525
  "references": {}
520
526
  },
521
527
  "required": false,
522
- "optional": true,
528
+ "optional": false,
523
529
  "docs": {
524
530
  "tags": [],
525
531
  "text": ""
@@ -529,6 +535,25 @@ export class PhirepassTerminal {
529
535
  "reflect": false,
530
536
  "attribute": "node-id"
531
537
  },
538
+ "token": {
539
+ "type": "string",
540
+ "mutable": false,
541
+ "complexType": {
542
+ "original": "string",
543
+ "resolved": "string",
544
+ "references": {}
545
+ },
546
+ "required": false,
547
+ "optional": false,
548
+ "docs": {
549
+ "tags": [],
550
+ "text": ""
551
+ },
552
+ "getter": false,
553
+ "setter": false,
554
+ "reflect": false,
555
+ "attribute": "token"
556
+ },
532
557
  "serverId": {
533
558
  "type": "string",
534
559
  "mutable": false,