@paigy/mcp 0.40.8 → 0.40.10

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.
@@ -1,16 +1,10 @@
1
1
  import {
2
- deleteKeyFile,
3
- fetchCredential,
4
- finalizeE2ee,
5
2
  isNetworkError,
6
- pairStep,
7
- readKeyFile,
3
+ pollToken,
8
4
  requestCode,
9
- saveKeyFile,
10
5
  saveToken,
11
- sleep,
12
- startE2ee
13
- } from "./chunk-BT5S7VT2.js";
6
+ sleep
7
+ } from "./chunk-HCCUK3ZL.js";
14
8
 
15
9
  // src/identity.ts
16
10
  var CLIENT_LABELS = {
@@ -34,12 +28,14 @@ function suggestedAgentName(clientName) {
34
28
 
35
29
  // src/pairing.ts
36
30
  async function resolvePairing(deviceCode, capMs, pollMs = 2e3) {
37
- let kf = readKeyFile();
38
31
  const start = Date.now();
39
32
  while (Date.now() - start < capMs) {
40
- let step;
41
33
  try {
42
- step = await pairStep(deviceCode, kf);
34
+ const token = await pollToken(deviceCode);
35
+ if (token) {
36
+ saveToken(token);
37
+ return { kind: "paired", token };
38
+ }
43
39
  } catch (e) {
44
40
  if (isNetworkError(e)) {
45
41
  await sleep(pollMs);
@@ -47,34 +43,6 @@ async function resolvePairing(deviceCode, capMs, pollMs = 2e3) {
47
43
  }
48
44
  return { kind: "error", message: e.message };
49
45
  }
50
- if (step.kind === "e2ee_aborted") {
51
- deleteKeyFile();
52
- kf = null;
53
- await sleep(pollMs);
54
- continue;
55
- }
56
- if (step.kind === "awaiting_confirm") {
57
- return { kind: "awaiting_confirm", sas: step.sas };
58
- }
59
- if (step.kind === "paired") {
60
- saveToken(step.token);
61
- if (!step.sas || !kf) {
62
- deleteKeyFile();
63
- return { kind: "paired", token: step.token };
64
- }
65
- const finalDeadline = Math.min(Date.now() + 1e4, start + capMs);
66
- let e2ee = false;
67
- while (Date.now() < finalDeadline) {
68
- const cred = kf.userCode ? await fetchCredential(kf.userCode) : null;
69
- if (cred && step.uikPub) {
70
- e2ee = finalizeE2ee(kf, cred, step.uikPub);
71
- break;
72
- }
73
- await sleep(pollMs);
74
- }
75
- if (!e2ee) deleteKeyFile();
76
- return { kind: "paired", token: step.token, sas: step.sas, e2ee };
77
- }
78
46
  await sleep(pollMs);
79
47
  }
80
48
  return { kind: "pending" };
@@ -83,15 +51,13 @@ var bg = null;
83
51
  var started = null;
84
52
  async function startPairing(agent) {
85
53
  if (started) return started;
86
- const { keyFile, offer } = startE2ee();
87
- const code = await requestCode(agent, offer);
54
+ const code = await requestCode(agent);
88
55
  started = {
89
56
  verificationUri: code.verification_uri_complete,
90
57
  userCode: code.user_code,
91
58
  deviceCode: code.device_code,
92
59
  expiresIn: code.expires_in
93
60
  };
94
- saveKeyFile({ ...keyFile, userCode: code.user_code });
95
61
  startBackgroundPair(code.device_code, code.expires_in * 1e3);
96
62
  return started;
97
63
  }