Commit 85d60db
feat: invite-code mode core API (WDP-73 / APP-9428)
Adds a code-based discovery channel to the existing Bridge proof flow.
The RP shows the user a 6-character code; the user types it into World
App on their phone and completes the existing Selfie Check / proof
flow. Same proof flow, same poll loop, same Status enum — only the
discovery channel changes.
Wire shape (matches wallet-bridge APP-9425 and world-app-ios APP-9424):
- Code is canonical 6-char Crockford Base32 (5 random data chars + 1
mod-32 weighted check digit, weights 1/3/5/7/9 — all coprime to 32,
so 100% of single-char substitutions are caught). UI may format as
"ABC-DEF" but the canonical form has no separator.
- HKDF-SHA256, no salt, 32-byte output, IKM = canonical code's UTF-8
bytes. info="dx" → lookup index (lowercase hex on the wire);
info="key" → AES-256-GCM key. The encryption key never reaches the
bridge — only the index and ciphertext do.
- POST /request body has the new `request_code_enabled: true, iv,
payload, index` shape with `iv`/`payload` as standard base64 (same
as the URL/QR path).
- Response carries `session_nonce` and `code_expires_at`. Polling
attaches `Authorization: Bearer <session_nonce>` so we're forward-
compatible with the bridge's session_nonce gate (release-blocking
follow-up on Bridge). URL-mode connections keep `session_nonce: None`
and the header is omitted, so existing bridge behavior is unchanged.
Cross-device implications:
- Original WDP-73 mermaid minted a `delivery_token` ferried back via
universal link. Universal links route to the device that opened them,
so a desktop browser ↔ phone flow never receives the token. We drop
delivery_token from idkit's surface entirely. Anti-collusion in the
code path now degrades to "10-min TTL + one-shot redeem + per-IP
rate limit."
API surface (mirrors existing URL-mode):
- Rust: `BridgeConnection::create_for_invite_code` (retry-once-on-409),
`.invite_code()` / `.code_expires_at()` accessors. New crypto.rs
primitives: `generate_invite_code`, `parse_invite_code`,
`hkdf_invite_index_hex`, `hkdf_invite_key`, `generate_nonce`.
- FFI: `IDKitInviteCodeRequest` sibling to `IDKitRequestWrapper`. New
builder methods `constraints_with_invite_code` /
`preset_with_invite_code` on `IDKitBuilder`.
- WASM: `IDKitInviteCodeRequest` sibling to `IDKitRequest`,
`constraintsWithInviteCode` / `presetWithInviteCode` on the WASM
builder.
- TypeScript: `IDKitInviteCodeRequest` interface + impl,
`IDKitInviteCodeBuilder`, `IDKit.requestWithInviteCode(...)` entry
point. Code mode is bridge-only by definition (user is on a different
device than World App), so the builder skips the `isInWorldApp()`
branch.
- React: `IDKitInviteCodeRequestWidget`, `useIDKitInviteCodeRequest`,
`useIDKitInviteCodeFlow` hooks. New `InviteCodeState` UI component.
- Swift: `presetWithInviteCode(_:)` / `constraintsWithInviteCode(_:)`
on the builder; `IDKitInviteCodeRequest` wrapper exposing `code` and
`expiresAt: Date`.
Adopter diff is two lines per integration:
// before
const req = await IDKit.request(config).constraints(...);
showQR(req.connectorURI);
// after
const req = await IDKit.requestWithInviteCode(config).constraints(...);
showCode(req.code);
Tests:
- 9 new Rust unit tests covering code generation, parser (round-trip,
separator stripping, lowercase normalization, Crockford ambiguity
collapse, U-rejection, length validation, check-digit validation,
exhaustive single-char substitution detection), HKDF determinism,
hex output shape, index/key differentiation across info strings.
- 86 existing rust tests pass; 54 core JS tests pass; 23 React tests
pass. Clippy clean on native + ffi feature combos.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent da524d8 commit 85d60db
20 files changed
Lines changed: 1879 additions & 69 deletions
File tree
- js/packages
- core/src
- react/src
- components/States
- hooks
- types
- widget
- rust/core
- src
- swift/Sources/IDKit
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
75 | 115 | | |
76 | 116 | | |
77 | 117 | | |
| |||
98 | 138 | | |
99 | 139 | | |
100 | 140 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
107 | 145 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
112 | 168 | | |
113 | | - | |
114 | | - | |
115 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
116 | 186 | | |
117 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
118 | 190 | | |
119 | | - | |
120 | | - | |
121 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
122 | 194 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
130 | 198 | | |
131 | | - | |
132 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
133 | 205 | | |
134 | 206 | | |
135 | 207 | | |
| |||
547 | 619 | | |
548 | 620 | | |
549 | 621 | | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
550 | 698 | | |
551 | 699 | | |
552 | 700 | | |
| |||
623 | 771 | | |
624 | 772 | | |
625 | 773 | | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
626 | 831 | | |
627 | 832 | | |
628 | 833 | | |
| |||
757 | 962 | | |
758 | 963 | | |
759 | 964 | | |
| 965 | + | |
| 966 | + | |
760 | 967 | | |
761 | 968 | | |
762 | 969 | | |
| |||
0 commit comments