@peers-app/peers-sdk 0.23.14 → 0.25.0

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.
Files changed (96) hide show
  1. package/dist/context/user-context.d.ts +8 -0
  2. package/dist/context/user-context.js +9 -1
  3. package/dist/contracts/index.d.ts +1 -0
  4. package/dist/contracts/index.js +4 -1
  5. package/dist/contracts/system/index.d.ts +2 -0
  6. package/dist/contracts/system/index.js +5 -1
  7. package/dist/contracts/system/invites-contract.d.ts +121 -0
  8. package/dist/contracts/system/invites-contract.js +150 -0
  9. package/dist/data/create-group.d.ts +24 -0
  10. package/dist/data/create-group.js +61 -0
  11. package/dist/data/group-secret.d.ts +10 -0
  12. package/dist/data/group-secret.js +26 -0
  13. package/dist/data/group-share.d.ts +0 -20
  14. package/dist/data/group-share.js +0 -35
  15. package/dist/data/index.d.ts +2 -0
  16. package/dist/data/index.js +2 -0
  17. package/dist/data/invites.d.ts +350 -0
  18. package/dist/data/invites.js +99 -0
  19. package/dist/data/orm/data-query.d.ts +1 -0
  20. package/dist/data/orm/sql.data-source.d.ts +3 -2
  21. package/dist/data/orm/sql.data-source.js +5 -3
  22. package/dist/data/orm/subscribable.data-source.d.ts +3 -2
  23. package/dist/data/orm/subscribable.data-source.js +7 -11
  24. package/dist/data/users.d.ts +11 -0
  25. package/dist/data/users.js +17 -0
  26. package/dist/device/device-election.d.ts +23 -3
  27. package/dist/device/device-election.js +15 -0
  28. package/dist/device/device-election.test.js +73 -0
  29. package/dist/device-pairing/constants.d.ts +27 -9
  30. package/dist/device-pairing/constants.js +28 -10
  31. package/dist/device-pairing/cpace.d.ts +46 -0
  32. package/dist/device-pairing/cpace.js +173 -0
  33. package/dist/device-pairing/cpace.test.js +116 -0
  34. package/dist/device-pairing/crypto.d.ts +40 -15
  35. package/dist/device-pairing/crypto.js +74 -33
  36. package/dist/device-pairing/device-pairing.test.js +156 -119
  37. package/dist/device-pairing/index.d.ts +3 -1
  38. package/dist/device-pairing/index.js +3 -1
  39. package/dist/device-pairing/pairing-code.d.ts +27 -0
  40. package/dist/device-pairing/pairing-code.js +84 -0
  41. package/dist/device-pairing/pgp-word-list.d.ts +14 -0
  42. package/dist/device-pairing/pgp-word-list.js +531 -0
  43. package/dist/device-pairing/signaling.d.ts +17 -6
  44. package/dist/device-pairing/signaling.js +31 -8
  45. package/dist/device-pairing/transcript.d.ts +3 -3
  46. package/dist/device-pairing/transcript.js +6 -13
  47. package/dist/device-pairing/types.d.ts +870 -224
  48. package/dist/device-pairing/types.js +186 -108
  49. package/dist/index.d.ts +1 -2
  50. package/dist/index.js +1 -2
  51. package/dist/invites/data-box-schema.d.ts +15 -0
  52. package/dist/invites/data-box-schema.js +15 -0
  53. package/dist/invites/group-approval.d.ts +43 -0
  54. package/dist/invites/group-approval.js +155 -0
  55. package/dist/invites/group-approval.test.js +221 -0
  56. package/dist/invites/index.d.ts +5 -0
  57. package/dist/{group-invite → invites}/index.js +5 -3
  58. package/dist/invites/invite-epoch.d.ts +18 -0
  59. package/dist/invites/invite-epoch.js +35 -0
  60. package/dist/invites/invite-messages.d.ts +1354 -0
  61. package/dist/invites/invite-messages.js +145 -0
  62. package/dist/invites/invite-token.d.ts +334 -0
  63. package/dist/invites/invite-token.js +178 -0
  64. package/dist/invites/invite-token.test.d.ts +1 -0
  65. package/dist/invites/invite-token.test.js +123 -0
  66. package/dist/keys.d.ts +17 -1
  67. package/dist/keys.js +58 -5
  68. package/dist/keys.test.js +113 -0
  69. package/dist/rpc-types.d.ts +5 -4
  70. package/dist/rpc-types.js +2 -1
  71. package/dist/serial-json.d.ts +4 -1
  72. package/dist/serial-json.js +4 -1
  73. package/dist/system-ids.d.ts +22 -0
  74. package/dist/system-ids.js +23 -1
  75. package/package.json +1 -1
  76. package/dist/device-pairing/invitation.d.ts +0 -13
  77. package/dist/device-pairing/invitation.js +0 -85
  78. package/dist/group-invite/group-invite.d.ts +0 -53
  79. package/dist/group-invite/group-invite.js +0 -231
  80. package/dist/group-invite/group-invite.pvars.d.ts +0 -94
  81. package/dist/group-invite/group-invite.pvars.js +0 -139
  82. package/dist/group-invite/group-invite.types.d.ts +0 -124
  83. package/dist/group-invite/group-invite.types.js +0 -8
  84. package/dist/group-invite/index.d.ts +0 -3
  85. package/dist/user-connect/connection-code.d.ts +0 -67
  86. package/dist/user-connect/connection-code.js +0 -176
  87. package/dist/user-connect/connection-code.test.js +0 -213
  88. package/dist/user-connect/index.d.ts +0 -3
  89. package/dist/user-connect/index.js +0 -19
  90. package/dist/user-connect/user-connect.pvars.d.ts +0 -20
  91. package/dist/user-connect/user-connect.pvars.js +0 -63
  92. package/dist/user-connect/user-connect.pvars.test.js +0 -46
  93. package/dist/user-connect/user-connect.types.d.ts +0 -94
  94. package/dist/user-connect/user-connect.types.js +0 -68
  95. /package/dist/{user-connect/connection-code.test.d.ts → device-pairing/cpace.test.d.ts} +0 -0
  96. /package/dist/{user-connect/user-connect.pvars.test.d.ts → invites/group-approval.test.d.ts} +0 -0
@@ -0,0 +1,531 @@
1
+ "use strict";
2
+ /**
3
+ * The PGP word list: 256 two-syllable "even" words and 256 three-syllable "odd" words.
4
+ *
5
+ * Word `n` in each list encodes the byte value `n`. Pairing codes alternate lists by
6
+ * position (even, odd, even) so a word typed in the wrong slot is detected before the
7
+ * PAKE runs. The list was designed for reading aloud: words are phonetically distinct
8
+ * and stress-pattern distinct across the two lists.
9
+ *
10
+ * Source: https://en.wikipedia.org/wiki/PGP_word_list (lowercased).
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.PGP_ODD_WORDS = exports.PGP_EVEN_WORDS = void 0;
14
+ /** Two-syllable words used for byte positions 0 and 2 of a pairing code. */
15
+ exports.PGP_EVEN_WORDS = Object.freeze([
16
+ "aardvark",
17
+ "absurd",
18
+ "accrue",
19
+ "acme",
20
+ "adrift",
21
+ "adult",
22
+ "afflict",
23
+ "ahead",
24
+ "aimless",
25
+ "algol",
26
+ "allow",
27
+ "alone",
28
+ "ammo",
29
+ "ancient",
30
+ "apple",
31
+ "artist",
32
+ "assume",
33
+ "athens",
34
+ "atlas",
35
+ "aztec",
36
+ "baboon",
37
+ "backfield",
38
+ "backward",
39
+ "banjo",
40
+ "beaming",
41
+ "bedlamp",
42
+ "beehive",
43
+ "beeswax",
44
+ "befriend",
45
+ "belfast",
46
+ "berserk",
47
+ "billiard",
48
+ "bison",
49
+ "blackjack",
50
+ "blockade",
51
+ "blowtorch",
52
+ "bluebird",
53
+ "bombast",
54
+ "bookshelf",
55
+ "brackish",
56
+ "breadline",
57
+ "breakup",
58
+ "brickyard",
59
+ "briefcase",
60
+ "burbank",
61
+ "button",
62
+ "buzzard",
63
+ "cement",
64
+ "chairlift",
65
+ "chatter",
66
+ "checkup",
67
+ "chisel",
68
+ "choking",
69
+ "chopper",
70
+ "christmas",
71
+ "clamshell",
72
+ "classic",
73
+ "classroom",
74
+ "cleanup",
75
+ "clockwork",
76
+ "cobra",
77
+ "commence",
78
+ "concert",
79
+ "cowbell",
80
+ "crackdown",
81
+ "cranky",
82
+ "crowfoot",
83
+ "crucial",
84
+ "crumpled",
85
+ "crusade",
86
+ "cubic",
87
+ "dashboard",
88
+ "deadbolt",
89
+ "deckhand",
90
+ "dogsled",
91
+ "dragnet",
92
+ "drainage",
93
+ "dreadful",
94
+ "drifter",
95
+ "dropper",
96
+ "drumbeat",
97
+ "drunken",
98
+ "dupont",
99
+ "dwelling",
100
+ "eating",
101
+ "edict",
102
+ "egghead",
103
+ "eightball",
104
+ "endorse",
105
+ "endow",
106
+ "enlist",
107
+ "erase",
108
+ "escape",
109
+ "exceed",
110
+ "eyeglass",
111
+ "eyetooth",
112
+ "facial",
113
+ "fallout",
114
+ "flagpole",
115
+ "flatfoot",
116
+ "flytrap",
117
+ "fracture",
118
+ "framework",
119
+ "freedom",
120
+ "frighten",
121
+ "gazelle",
122
+ "geiger",
123
+ "glitter",
124
+ "glucose",
125
+ "goggles",
126
+ "goldfish",
127
+ "gremlin",
128
+ "guidance",
129
+ "hamlet",
130
+ "highchair",
131
+ "hockey",
132
+ "indoors",
133
+ "indulge",
134
+ "inverse",
135
+ "involve",
136
+ "island",
137
+ "jawbone",
138
+ "keyboard",
139
+ "kickoff",
140
+ "kiwi",
141
+ "klaxon",
142
+ "locale",
143
+ "lockup",
144
+ "merit",
145
+ "minnow",
146
+ "miser",
147
+ "mohawk",
148
+ "mural",
149
+ "music",
150
+ "necklace",
151
+ "neptune",
152
+ "newborn",
153
+ "nightbird",
154
+ "oakland",
155
+ "obtuse",
156
+ "offload",
157
+ "optic",
158
+ "orca",
159
+ "payday",
160
+ "peachy",
161
+ "pheasant",
162
+ "physique",
163
+ "playhouse",
164
+ "pluto",
165
+ "preclude",
166
+ "prefer",
167
+ "preshrunk",
168
+ "printer",
169
+ "prowler",
170
+ "pupil",
171
+ "puppy",
172
+ "python",
173
+ "quadrant",
174
+ "quiver",
175
+ "quota",
176
+ "ragtime",
177
+ "ratchet",
178
+ "rebirth",
179
+ "reform",
180
+ "regain",
181
+ "reindeer",
182
+ "rematch",
183
+ "repay",
184
+ "retouch",
185
+ "revenge",
186
+ "reward",
187
+ "rhythm",
188
+ "ribcage",
189
+ "ringbolt",
190
+ "robust",
191
+ "rocker",
192
+ "ruffled",
193
+ "sailboat",
194
+ "sawdust",
195
+ "scallion",
196
+ "scenic",
197
+ "scorecard",
198
+ "scotland",
199
+ "seabird",
200
+ "select",
201
+ "sentence",
202
+ "shadow",
203
+ "shamrock",
204
+ "showgirl",
205
+ "skullcap",
206
+ "skydive",
207
+ "slingshot",
208
+ "slowdown",
209
+ "snapline",
210
+ "snapshot",
211
+ "snowcap",
212
+ "snowslide",
213
+ "solo",
214
+ "southward",
215
+ "soybean",
216
+ "spaniel",
217
+ "spearhead",
218
+ "spellbind",
219
+ "spheroid",
220
+ "spigot",
221
+ "spindle",
222
+ "spyglass",
223
+ "stagehand",
224
+ "stagnate",
225
+ "stairway",
226
+ "standard",
227
+ "stapler",
228
+ "steamship",
229
+ "sterling",
230
+ "stockman",
231
+ "stopwatch",
232
+ "stormy",
233
+ "sugar",
234
+ "surmount",
235
+ "suspense",
236
+ "sweatband",
237
+ "swelter",
238
+ "tactics",
239
+ "talon",
240
+ "tapeworm",
241
+ "tempest",
242
+ "tiger",
243
+ "tissue",
244
+ "tonic",
245
+ "topmost",
246
+ "tracker",
247
+ "transit",
248
+ "trauma",
249
+ "treadmill",
250
+ "trojan",
251
+ "trouble",
252
+ "tumor",
253
+ "tunnel",
254
+ "tycoon",
255
+ "uncut",
256
+ "unearth",
257
+ "unwind",
258
+ "uproot",
259
+ "upset",
260
+ "upshot",
261
+ "vapor",
262
+ "village",
263
+ "virus",
264
+ "vulcan",
265
+ "waffle",
266
+ "wallet",
267
+ "watchword",
268
+ "wayside",
269
+ "willow",
270
+ "woodlark",
271
+ "zulu",
272
+ ]);
273
+ /** Three-syllable words used for byte position 1 of a pairing code. */
274
+ exports.PGP_ODD_WORDS = Object.freeze([
275
+ "adroitness",
276
+ "adviser",
277
+ "aftermath",
278
+ "aggregate",
279
+ "alkali",
280
+ "almighty",
281
+ "amulet",
282
+ "amusement",
283
+ "antenna",
284
+ "applicant",
285
+ "apollo",
286
+ "armistice",
287
+ "article",
288
+ "asteroid",
289
+ "atlantic",
290
+ "atmosphere",
291
+ "autopsy",
292
+ "babylon",
293
+ "backwater",
294
+ "barbecue",
295
+ "belowground",
296
+ "bifocals",
297
+ "bodyguard",
298
+ "bookseller",
299
+ "borderline",
300
+ "bottomless",
301
+ "bradbury",
302
+ "bravado",
303
+ "brazilian",
304
+ "breakaway",
305
+ "burlington",
306
+ "businessman",
307
+ "butterfat",
308
+ "camelot",
309
+ "candidate",
310
+ "cannonball",
311
+ "capricorn",
312
+ "caravan",
313
+ "caretaker",
314
+ "celebrate",
315
+ "cellulose",
316
+ "certify",
317
+ "chambermaid",
318
+ "cherokee",
319
+ "chicago",
320
+ "clergyman",
321
+ "coherence",
322
+ "combustion",
323
+ "commando",
324
+ "company",
325
+ "component",
326
+ "concurrent",
327
+ "confidence",
328
+ "conformist",
329
+ "congregate",
330
+ "consensus",
331
+ "consulting",
332
+ "corporate",
333
+ "corrosion",
334
+ "councilman",
335
+ "crossover",
336
+ "crucifix",
337
+ "cumbersome",
338
+ "customer",
339
+ "dakota",
340
+ "decadence",
341
+ "december",
342
+ "decimal",
343
+ "designing",
344
+ "detector",
345
+ "detergent",
346
+ "determine",
347
+ "dictator",
348
+ "dinosaur",
349
+ "direction",
350
+ "disable",
351
+ "disbelief",
352
+ "disruptive",
353
+ "distortion",
354
+ "document",
355
+ "embezzle",
356
+ "enchanting",
357
+ "enrollment",
358
+ "enterprise",
359
+ "equation",
360
+ "equipment",
361
+ "escapade",
362
+ "eskimo",
363
+ "everyday",
364
+ "examine",
365
+ "existence",
366
+ "exodus",
367
+ "fascinate",
368
+ "filament",
369
+ "finicky",
370
+ "forever",
371
+ "fortitude",
372
+ "frequency",
373
+ "gadgetry",
374
+ "galveston",
375
+ "getaway",
376
+ "glossary",
377
+ "gossamer",
378
+ "graduate",
379
+ "gravity",
380
+ "guitarist",
381
+ "hamburger",
382
+ "hamilton",
383
+ "handiwork",
384
+ "hazardous",
385
+ "headwaters",
386
+ "hemisphere",
387
+ "hesitate",
388
+ "hideaway",
389
+ "holiness",
390
+ "hurricane",
391
+ "hydraulic",
392
+ "impartial",
393
+ "impetus",
394
+ "inception",
395
+ "indigo",
396
+ "inertia",
397
+ "infancy",
398
+ "inferno",
399
+ "informant",
400
+ "insincere",
401
+ "insurgent",
402
+ "integrate",
403
+ "intention",
404
+ "inventive",
405
+ "istanbul",
406
+ "jamaica",
407
+ "jupiter",
408
+ "leprosy",
409
+ "letterhead",
410
+ "liberty",
411
+ "maritime",
412
+ "matchmaker",
413
+ "maverick",
414
+ "medusa",
415
+ "megaton",
416
+ "microscope",
417
+ "microwave",
418
+ "midsummer",
419
+ "millionaire",
420
+ "miracle",
421
+ "misnomer",
422
+ "molasses",
423
+ "molecule",
424
+ "montana",
425
+ "monument",
426
+ "mosquito",
427
+ "narrative",
428
+ "nebula",
429
+ "newsletter",
430
+ "norwegian",
431
+ "october",
432
+ "ohio",
433
+ "onlooker",
434
+ "opulent",
435
+ "orlando",
436
+ "outfielder",
437
+ "pacific",
438
+ "pandemic",
439
+ "pandora",
440
+ "paperweight",
441
+ "paragon",
442
+ "paragraph",
443
+ "paramount",
444
+ "passenger",
445
+ "pedigree",
446
+ "pegasus",
447
+ "penetrate",
448
+ "perceptive",
449
+ "performance",
450
+ "pharmacy",
451
+ "phonetic",
452
+ "photograph",
453
+ "pioneer",
454
+ "pocketful",
455
+ "politeness",
456
+ "positive",
457
+ "potato",
458
+ "processor",
459
+ "provincial",
460
+ "proximate",
461
+ "puberty",
462
+ "publisher",
463
+ "pyramid",
464
+ "quantity",
465
+ "racketeer",
466
+ "rebellion",
467
+ "recipe",
468
+ "recover",
469
+ "repellent",
470
+ "replica",
471
+ "reproduce",
472
+ "resistor",
473
+ "responsive",
474
+ "retraction",
475
+ "retrieval",
476
+ "retrospect",
477
+ "revenue",
478
+ "revival",
479
+ "revolver",
480
+ "sandalwood",
481
+ "sardonic",
482
+ "saturday",
483
+ "savagery",
484
+ "scavenger",
485
+ "sensation",
486
+ "sociable",
487
+ "souvenir",
488
+ "specialist",
489
+ "speculate",
490
+ "stethoscope",
491
+ "stupendous",
492
+ "supportive",
493
+ "surrender",
494
+ "suspicious",
495
+ "sympathy",
496
+ "tambourine",
497
+ "telephone",
498
+ "therapist",
499
+ "tobacco",
500
+ "tolerance",
501
+ "tomorrow",
502
+ "torpedo",
503
+ "tradition",
504
+ "travesty",
505
+ "trombonist",
506
+ "truncated",
507
+ "typewriter",
508
+ "ultimate",
509
+ "undaunted",
510
+ "underfoot",
511
+ "unicorn",
512
+ "unify",
513
+ "universe",
514
+ "unravel",
515
+ "upcoming",
516
+ "vacancy",
517
+ "vagabond",
518
+ "vertigo",
519
+ "virginia",
520
+ "visitor",
521
+ "vocalist",
522
+ "voyager",
523
+ "warranty",
524
+ "waterloo",
525
+ "whimsical",
526
+ "wichita",
527
+ "wilmington",
528
+ "wyoming",
529
+ "yesteryear",
530
+ "yucatan",
531
+ ]);
@@ -1,9 +1,20 @@
1
- import { type PairingRole, type PairingSignal, type UnsignedPairingSignal } from "./types";
2
- /** Attaches an HMAC to a validated canonical SDP or ICE signaling message. */
3
- export declare function signPairingSignal(signal: UnsignedPairingSignal, signalingKey: string): PairingSignal;
4
- /** Verifies message authentication, room/role binding, and the exact next sequence number. */
5
- export declare function verifyPairingSignal(signal: unknown, signalingKey: string, expected: {
6
- roomId: string;
1
+ import { type AuthenticatedPairingSignal, type PairingPakeSignal, type PairingRole, type PairingSignal, type UnsignedPairingSignal } from "./types";
2
+ /** Builds the unauthenticated PAKE share message; it is always the first message of a role. */
3
+ export declare function createPairingPakeSignal(input: {
4
+ nameplate: number;
5
+ senderRole: PairingRole;
6
+ sequence: number;
7
+ share: string;
8
+ }): PairingPakeSignal;
9
+ /** Attaches an HMAC to a validated canonical transport, SDP, or ICE signaling message. */
10
+ export declare function signPairingSignal(signal: UnsignedPairingSignal, signalingKey: string): AuthenticatedPairingSignal;
11
+ /**
12
+ * Verifies room/role binding and the exact next sequence number for any relayed signal,
13
+ * plus message authentication for everything after the PAKE share. `signalingKey` may be
14
+ * undefined only while the PAKE is still in progress; any non-`pake` message is then rejected.
15
+ */
16
+ export declare function verifyPairingSignal(signal: unknown, signalingKey: string | undefined, expected: {
17
+ nameplate: number;
7
18
  senderRole: PairingRole;
8
19
  nextSequence: number;
9
20
  }): PairingSignal;
@@ -1,29 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPairingPakeSignal = createPairingPakeSignal;
3
4
  exports.signPairingSignal = signPairingSignal;
4
5
  exports.verifyPairingSignal = verifyPairingSignal;
6
+ const constants_1 = require("./constants");
5
7
  const crypto_1 = require("./crypto");
6
8
  const types_1 = require("./types");
7
- /** Attaches an HMAC to a validated canonical SDP or ICE signaling message. */
9
+ /** Builds the unauthenticated PAKE share message; it is always the first message of a role. */
10
+ function createPairingPakeSignal(input) {
11
+ return types_1.pairingPakeSignalSchema.parse({
12
+ version: constants_1.DEVICE_PAIRING_PROTOCOL_VERSION,
13
+ nameplate: input.nameplate,
14
+ senderRole: input.senderRole,
15
+ sequence: input.sequence,
16
+ kind: "pake",
17
+ payload: { share: input.share },
18
+ });
19
+ }
20
+ /** Attaches an HMAC to a validated canonical transport, SDP, or ICE signaling message. */
8
21
  function signPairingSignal(signal, signalingKey) {
9
22
  const parsed = types_1.unsignedPairingSignalSchema.parse(signal);
10
- return types_1.pairingSignalSchema.parse({
23
+ return types_1.authenticatedPairingSignalSchema.parse({
11
24
  ...parsed,
12
25
  mac: (0, crypto_1.computePairingSignalMac)(parsed, signalingKey),
13
26
  });
14
27
  }
15
- /** Verifies message authentication, room/role binding, and the exact next sequence number. */
28
+ /**
29
+ * Verifies room/role binding and the exact next sequence number for any relayed signal,
30
+ * plus message authentication for everything after the PAKE share. `signalingKey` may be
31
+ * undefined only while the PAKE is still in progress; any non-`pake` message is then rejected.
32
+ */
16
33
  function verifyPairingSignal(signal, signalingKey, expected) {
17
34
  const parsed = types_1.pairingSignalSchema.parse(signal);
35
+ if (parsed.nameplate !== expected.nameplate ||
36
+ parsed.senderRole !== expected.senderRole ||
37
+ parsed.sequence !== expected.nextSequence) {
38
+ throw new Error("Pairing signaling message is out of order");
39
+ }
40
+ if (parsed.kind === "pake") {
41
+ return parsed;
42
+ }
43
+ if (!signalingKey) {
44
+ throw new Error("Pairing signaling received before authentication completed");
45
+ }
18
46
  const { mac, ...unsignedValue } = parsed;
19
47
  const unsigned = types_1.unsignedPairingSignalSchema.parse(unsignedValue);
20
48
  if (!(0, crypto_1.isPairingSignalMacValid)(unsigned, mac, signalingKey)) {
21
49
  throw new Error("Pairing signaling authentication failed");
22
50
  }
23
- if (parsed.roomId !== expected.roomId ||
24
- parsed.senderRole !== expected.senderRole ||
25
- parsed.sequence !== expected.nextSequence) {
26
- throw new Error("Pairing signaling message is out of order");
27
- }
28
51
  return parsed;
29
52
  }
@@ -1,7 +1,7 @@
1
1
  import { type DevicePairingTranscript } from "./types";
2
2
  /** Extracts a canonical set of SHA-256 DTLS fingerprints from an SDP document. */
3
3
  export declare function extractSha256SdpFingerprint(sdp: string): string;
4
- /** Hashes the canonical identities, nonces, room, and SDP fingerprints for one ceremony. */
4
+ /** Builds the `wrtc` transport binding from the offer and answer SDP: `offerFp|answerFp`. */
5
+ export declare function webRtcPairingTransportBinding(offerSdp: string, answerSdp: string): string;
6
+ /** Hashes the canonical identities, nonces, rendezvous, and transport binding for one ceremony. */
5
7
  export declare function computeDevicePairingTranscriptHash(transcript: DevicePairingTranscript): string;
6
- /** Derives the same zero-padded six-digit SAS independently on both endpoints. */
7
- export declare function deriveDevicePairingSas(roomSecret: string, transcriptHash: string): string;
@@ -1,14 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractSha256SdpFingerprint = extractSha256SdpFingerprint;
4
+ exports.webRtcPairingTransportBinding = webRtcPairingTransportBinding;
4
5
  exports.computeDevicePairingTranscriptHash = computeDevicePairingTranscriptHash;
5
- exports.deriveDevicePairingSas = deriveDevicePairingSas;
6
- const hmac_1 = require("@noble/hashes/hmac");
7
- const sha2_1 = require("@noble/hashes/sha2");
8
6
  const keys_1 = require("../keys");
9
- const constants_1 = require("./constants");
10
7
  const types_1 = require("./types");
11
- const textEncoder = new TextEncoder();
12
8
  /** Extracts a canonical set of SHA-256 DTLS fingerprints from an SDP document. */
13
9
  function extractSha256SdpFingerprint(sdp) {
14
10
  const fingerprints = new Set();
@@ -25,14 +21,11 @@ function extractSha256SdpFingerprint(sdp) {
25
21
  }
26
22
  return [...fingerprints].sort().join(",");
27
23
  }
28
- /** Hashes the canonical identities, nonces, room, and SDP fingerprints for one ceremony. */
24
+ /** Builds the `wrtc` transport binding from the offer and answer SDP: `offerFp|answerFp`. */
25
+ function webRtcPairingTransportBinding(offerSdp, answerSdp) {
26
+ return `${extractSha256SdpFingerprint(offerSdp)}|${extractSha256SdpFingerprint(answerSdp)}`;
27
+ }
28
+ /** Hashes the canonical identities, nonces, rendezvous, and transport binding for one ceremony. */
29
29
  function computeDevicePairingTranscriptHash(transcript) {
30
30
  return types_1.pairingHashSchema.parse((0, keys_1.hashObject)(types_1.devicePairingTranscriptSchema.parse(transcript)));
31
31
  }
32
- /** Derives the same zero-padded six-digit SAS independently on both endpoints. */
33
- function deriveDevicePairingSas(roomSecret, transcriptHash) {
34
- types_1.pairingHashSchema.parse(transcriptHash);
35
- const digest = (0, hmac_1.hmac)(sha2_1.sha256, (0, keys_1.decodeBase64)(roomSecret), textEncoder.encode(`${constants_1.DEVICE_PAIRING_SAS_LABEL}${transcriptHash}`));
36
- const value = (((digest[0] << 24) >>> 0) | (digest[1] << 16) | (digest[2] << 8) | digest[3]) >>> 0;
37
- return (value % 1_000_000).toString().padStart(6, "0");
38
- }