@getmateo/protocol 0.19.6 → 0.19.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.
@@ -1,4 +1,9 @@
1
1
  import { z } from "zod";
2
+ export declare const ConnectionOfferRelaySchema: z.ZodObject<{
3
+ endpoint: z.ZodString;
4
+ useTls: z.ZodOptional<z.ZodBoolean>;
5
+ }, z.core.$strip>;
6
+ export type ConnectionOfferRelay = z.infer<typeof ConnectionOfferRelaySchema>;
2
7
  /**
3
8
  * Relay-only pairing offer.
4
9
  *
@@ -13,6 +18,10 @@ export declare const ConnectionOfferV2Schema: z.ZodObject<{
13
18
  endpoint: z.ZodString;
14
19
  useTls: z.ZodOptional<z.ZodBoolean>;
15
20
  }, z.core.$strip>;
21
+ relays: z.ZodOptional<z.ZodArray<z.ZodObject<{
22
+ endpoint: z.ZodString;
23
+ useTls: z.ZodOptional<z.ZodBoolean>;
24
+ }, z.core.$strip>>>;
16
25
  }, z.core.$strip>;
17
26
  export type ConnectionOfferV2 = z.infer<typeof ConnectionOfferV2Schema>;
18
27
  export declare const ConnectionOfferSchema: z.ZodObject<{
@@ -23,8 +32,13 @@ export declare const ConnectionOfferSchema: z.ZodObject<{
23
32
  endpoint: z.ZodString;
24
33
  useTls: z.ZodOptional<z.ZodBoolean>;
25
34
  }, z.core.$strip>;
35
+ relays: z.ZodOptional<z.ZodArray<z.ZodObject<{
36
+ endpoint: z.ZodString;
37
+ useTls: z.ZodOptional<z.ZodBoolean>;
38
+ }, z.core.$strip>>>;
26
39
  }, z.core.$strip>;
27
40
  export type ConnectionOffer = ConnectionOfferV2;
41
+ export declare function getOfferRelays(offer: ConnectionOffer): ConnectionOfferRelay[];
28
42
  export declare function decodeOfferFragmentPayload(encoded: string): unknown;
29
43
  /**
30
44
  * Parse a pairing-offer URL of the form `https://app.paseo.sh/#offer=<base64url>`.
@@ -1,4 +1,9 @@
1
1
  import { z } from "zod";
2
+ import { normalizeHostPort } from "./daemon-endpoints.js";
3
+ export const ConnectionOfferRelaySchema = z.object({
4
+ endpoint: z.string().min(1),
5
+ useTls: z.boolean().optional(),
6
+ });
2
7
  /**
3
8
  * Relay-only pairing offer.
4
9
  *
@@ -9,12 +14,40 @@ export const ConnectionOfferV2Schema = z.object({
9
14
  v: z.literal(2),
10
15
  serverId: z.string().min(1),
11
16
  daemonPublicKeyB64: z.string().min(1),
12
- relay: z.object({
13
- endpoint: z.string().min(1),
14
- useTls: z.boolean().optional(),
15
- }),
17
+ relay: ConnectionOfferRelaySchema,
18
+ relays: z.array(ConnectionOfferRelaySchema).min(1).optional(),
16
19
  });
17
20
  export const ConnectionOfferSchema = ConnectionOfferV2Schema;
21
+ function relayTlsTag(useTls) {
22
+ if (useTls === true)
23
+ return "wss";
24
+ if (useTls === false)
25
+ return "ws";
26
+ return "auto";
27
+ }
28
+ export function getOfferRelays(offer) {
29
+ const result = [];
30
+ const seen = new Set();
31
+ const candidates = [offer.relay, ...(offer.relays ?? [])];
32
+ for (const entry of candidates) {
33
+ let endpoint = entry.endpoint.trim();
34
+ try {
35
+ endpoint = normalizeHostPort(endpoint);
36
+ }
37
+ catch {
38
+ // Keep raw string when normalization fails; callers validate before connecting.
39
+ }
40
+ const key = `${relayTlsTag(entry.useTls)}://${endpoint.toLowerCase()}`;
41
+ if (seen.has(key))
42
+ continue;
43
+ seen.add(key);
44
+ result.push({
45
+ endpoint,
46
+ ...(entry.useTls !== undefined ? { useTls: entry.useTls } : {}),
47
+ });
48
+ }
49
+ return result;
50
+ }
18
51
  function decodeBase64UrlToUtf8(input) {
19
52
  const base64 = input.replace(/-/g, "+").replace(/_/g, "/");
20
53
  const padded = base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), "=");
@@ -50,6 +50,7 @@ export declare const DaemonAuthSessionSchema: z.ZodObject<{
50
50
  hub: "hub";
51
51
  }>>;
52
52
  remoteAddress: z.ZodOptional<z.ZodString>;
53
+ relayEndpoint: z.ZodOptional<z.ZodString>;
53
54
  deviceCredentialId: z.ZodOptional<z.ZodString>;
54
55
  customName: z.ZodOptional<z.ZodString>;
55
56
  computerName: z.ZodOptional<z.ZodString>;
@@ -108,6 +109,7 @@ export declare const DaemonAuthStatusSchema: z.ZodObject<{
108
109
  hub: "hub";
109
110
  }>>;
110
111
  remoteAddress: z.ZodOptional<z.ZodString>;
112
+ relayEndpoint: z.ZodOptional<z.ZodString>;
111
113
  deviceCredentialId: z.ZodOptional<z.ZodString>;
112
114
  customName: z.ZodOptional<z.ZodString>;
113
115
  computerName: z.ZodOptional<z.ZodString>;
@@ -202,6 +204,7 @@ export declare const DaemonAuthStatusResponseSchema: z.ZodObject<{
202
204
  hub: "hub";
203
205
  }>>;
204
206
  remoteAddress: z.ZodOptional<z.ZodString>;
207
+ relayEndpoint: z.ZodOptional<z.ZodString>;
205
208
  deviceCredentialId: z.ZodOptional<z.ZodString>;
206
209
  customName: z.ZodOptional<z.ZodString>;
207
210
  computerName: z.ZodOptional<z.ZodString>;
@@ -267,6 +270,7 @@ export declare const DaemonAuthPasswordSetResponseSchema: z.ZodObject<{
267
270
  hub: "hub";
268
271
  }>>;
269
272
  remoteAddress: z.ZodOptional<z.ZodString>;
273
+ relayEndpoint: z.ZodOptional<z.ZodString>;
270
274
  deviceCredentialId: z.ZodOptional<z.ZodString>;
271
275
  customName: z.ZodOptional<z.ZodString>;
272
276
  computerName: z.ZodOptional<z.ZodString>;
@@ -333,6 +337,7 @@ export declare const DaemonAuthDeviceRevokeResponseSchema: z.ZodObject<{
333
337
  hub: "hub";
334
338
  }>>;
335
339
  remoteAddress: z.ZodOptional<z.ZodString>;
340
+ relayEndpoint: z.ZodOptional<z.ZodString>;
336
341
  deviceCredentialId: z.ZodOptional<z.ZodString>;
337
342
  customName: z.ZodOptional<z.ZodString>;
338
343
  computerName: z.ZodOptional<z.ZodString>;
@@ -419,6 +424,7 @@ export declare const DaemonAuthSessionDisconnectResponseSchema: z.ZodObject<{
419
424
  hub: "hub";
420
425
  }>>;
421
426
  remoteAddress: z.ZodOptional<z.ZodString>;
427
+ relayEndpoint: z.ZodOptional<z.ZodString>;
422
428
  deviceCredentialId: z.ZodOptional<z.ZodString>;
423
429
  customName: z.ZodOptional<z.ZodString>;
424
430
  computerName: z.ZodOptional<z.ZodString>;
@@ -485,6 +491,7 @@ export declare const DaemonAuthStatusSubscribeResponseSchema: z.ZodObject<{
485
491
  hub: "hub";
486
492
  }>>;
487
493
  remoteAddress: z.ZodOptional<z.ZodString>;
494
+ relayEndpoint: z.ZodOptional<z.ZodString>;
488
495
  deviceCredentialId: z.ZodOptional<z.ZodString>;
489
496
  customName: z.ZodOptional<z.ZodString>;
490
497
  computerName: z.ZodOptional<z.ZodString>;
@@ -551,6 +558,7 @@ export declare const DaemonAuthStatusChangedSchema: z.ZodObject<{
551
558
  hub: "hub";
552
559
  }>>;
553
560
  remoteAddress: z.ZodOptional<z.ZodString>;
561
+ relayEndpoint: z.ZodOptional<z.ZodString>;
554
562
  deviceCredentialId: z.ZodOptional<z.ZodString>;
555
563
  customName: z.ZodOptional<z.ZodString>;
556
564
  computerName: z.ZodOptional<z.ZodString>;
@@ -50,6 +50,8 @@ export const DaemonAuthSessionSchema = z.object({
50
50
  transport: DaemonAuthSessionTransportSchema.optional(),
51
51
  /** The peer address of a direct connection. Never set for local, relay or Hub sessions. */
52
52
  remoteAddress: z.string().optional(),
53
+ /** The relay server endpoint (`host:port`) the session arrived through when `transport === "relay"`. */
54
+ relayEndpoint: z.string().optional(),
53
55
  /** The device credential the session connected with or was issued while connected. */
54
56
  deviceCredentialId: z.string().optional(),
55
57
  });
@@ -58,6 +58,7 @@ export declare const SessionOutboundMessage0: {
58
58
  hub: "hub";
59
59
  }>>;
60
60
  remoteAddress: import("zod").ZodOptional<import("zod").ZodString>;
61
+ relayEndpoint: import("zod").ZodOptional<import("zod").ZodString>;
61
62
  deviceCredentialId: import("zod").ZodOptional<import("zod").ZodString>;
62
63
  customName: import("zod").ZodOptional<import("zod").ZodString>;
63
64
  computerName: import("zod").ZodOptional<import("zod").ZodString>;
@@ -125,6 +126,7 @@ export declare const SessionOutboundMessage1: {
125
126
  hub: "hub";
126
127
  }>>;
127
128
  remoteAddress: import("zod").ZodOptional<import("zod").ZodString>;
129
+ relayEndpoint: import("zod").ZodOptional<import("zod").ZodString>;
128
130
  deviceCredentialId: import("zod").ZodOptional<import("zod").ZodString>;
129
131
  customName: import("zod").ZodOptional<import("zod").ZodString>;
130
132
  computerName: import("zod").ZodOptional<import("zod").ZodString>;
@@ -193,6 +195,7 @@ export declare const SessionOutboundMessage2: {
193
195
  hub: "hub";
194
196
  }>>;
195
197
  remoteAddress: import("zod").ZodOptional<import("zod").ZodString>;
198
+ relayEndpoint: import("zod").ZodOptional<import("zod").ZodString>;
196
199
  deviceCredentialId: import("zod").ZodOptional<import("zod").ZodString>;
197
200
  customName: import("zod").ZodOptional<import("zod").ZodString>;
198
201
  computerName: import("zod").ZodOptional<import("zod").ZodString>;
@@ -279,6 +282,7 @@ export declare const SessionOutboundMessage5: {
279
282
  hub: "hub";
280
283
  }>>;
281
284
  remoteAddress: import("zod").ZodOptional<import("zod").ZodString>;
285
+ relayEndpoint: import("zod").ZodOptional<import("zod").ZodString>;
282
286
  deviceCredentialId: import("zod").ZodOptional<import("zod").ZodString>;
283
287
  customName: import("zod").ZodOptional<import("zod").ZodString>;
284
288
  computerName: import("zod").ZodOptional<import("zod").ZodString>;
@@ -347,6 +351,7 @@ export declare const SessionOutboundMessage6: {
347
351
  hub: "hub";
348
352
  }>>;
349
353
  remoteAddress: import("zod").ZodOptional<import("zod").ZodString>;
354
+ relayEndpoint: import("zod").ZodOptional<import("zod").ZodString>;
350
355
  deviceCredentialId: import("zod").ZodOptional<import("zod").ZodString>;
351
356
  customName: import("zod").ZodOptional<import("zod").ZodString>;
352
357
  computerName: import("zod").ZodOptional<import("zod").ZodString>;
@@ -414,6 +419,7 @@ export declare const SessionOutboundMessage7: {
414
419
  hub: "hub";
415
420
  }>>;
416
421
  remoteAddress: import("zod").ZodOptional<import("zod").ZodString>;
422
+ relayEndpoint: import("zod").ZodOptional<import("zod").ZodString>;
417
423
  deviceCredentialId: import("zod").ZodOptional<import("zod").ZodString>;
418
424
  customName: import("zod").ZodOptional<import("zod").ZodString>;
419
425
  computerName: import("zod").ZodOptional<import("zod").ZodString>;
@@ -9562,6 +9568,12 @@ export declare const SessionOutboundMessage126: {
9562
9568
  publicEndpoint: import("zod").ZodString;
9563
9569
  useTls: import("zod").ZodBoolean;
9564
9570
  publicUseTls: import("zod").ZodBoolean;
9571
+ servers: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
9572
+ endpoint: import("zod").ZodString;
9573
+ useTls: import("zod").ZodBoolean;
9574
+ publicEndpoint: import("zod").ZodOptional<import("zod").ZodString>;
9575
+ publicUseTls: import("zod").ZodOptional<import("zod").ZodBoolean>;
9576
+ }, import("zod/v4/core").$strip>>>;
9565
9577
  }, import("zod/v4/core").$strip>>>;
9566
9578
  providers: import("zod").ZodArray<import("zod").ZodObject<{
9567
9579
  provider: import("zod").ZodString;
@@ -9747,6 +9759,12 @@ export declare const SessionOutboundMessage134: {
9747
9759
  config: import("zod").ZodObject<{
9748
9760
  relay: import("zod").ZodOptional<import("zod").ZodObject<{
9749
9761
  enabled: import("zod").ZodBoolean;
9762
+ servers: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
9763
+ endpoint: import("zod").ZodString;
9764
+ useTls: import("zod").ZodBoolean;
9765
+ publicEndpoint: import("zod").ZodOptional<import("zod").ZodString>;
9766
+ publicUseTls: import("zod").ZodOptional<import("zod").ZodBoolean>;
9767
+ }, import("zod/v4/core").$strip>>>;
9750
9768
  }, import("zod/v4/core").$loose>>;
9751
9769
  mcp: import("zod").ZodObject<{
9752
9770
  enabled: import("zod").ZodOptional<import("zod").ZodBoolean>;
@@ -9840,6 +9858,12 @@ export declare const SessionOutboundMessage135: {
9840
9858
  config: import("zod").ZodObject<{
9841
9859
  relay: import("zod").ZodOptional<import("zod").ZodObject<{
9842
9860
  enabled: import("zod").ZodBoolean;
9861
+ servers: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
9862
+ endpoint: import("zod").ZodString;
9863
+ useTls: import("zod").ZodBoolean;
9864
+ publicEndpoint: import("zod").ZodOptional<import("zod").ZodString>;
9865
+ publicUseTls: import("zod").ZodOptional<import("zod").ZodBoolean>;
9866
+ }, import("zod/v4/core").$strip>>>;
9843
9867
  }, import("zod/v4/core").$loose>>;
9844
9868
  mcp: import("zod").ZodObject<{
9845
9869
  enabled: import("zod").ZodOptional<import("zod").ZodBoolean>;