@enbox/browser 0.3.43 → 0.3.45

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 (48) hide show
  1. package/dist/browser.mjs +161 -155
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/browser-connect-handler.js +17 -20
  4. package/dist/esm/browser-connect-handler.js.map +1 -1
  5. package/dist/esm/dweb-connect-client.js +1 -1
  6. package/dist/esm/dweb-connect-client.js.map +1 -1
  7. package/dist/esm/index.js +4 -1
  8. package/dist/esm/index.js.map +1 -1
  9. package/dist/esm/relay-connect-runner.js +128 -0
  10. package/dist/esm/relay-connect-runner.js.map +1 -0
  11. package/dist/esm/ui/connect-modal.js +990 -0
  12. package/dist/esm/ui/connect-modal.js.map +1 -0
  13. package/dist/esm/ui/qr.js +468 -0
  14. package/dist/esm/ui/qr.js.map +1 -0
  15. package/dist/esm/ui/wallet-icon.js +55 -0
  16. package/dist/esm/ui/wallet-icon.js.map +1 -0
  17. package/dist/esm/ui/wallet-well-known.js +61 -0
  18. package/dist/esm/ui/wallet-well-known.js.map +1 -0
  19. package/dist/types/browser-connect-handler.d.ts +32 -7
  20. package/dist/types/browser-connect-handler.d.ts.map +1 -1
  21. package/dist/types/dweb-connect-client.d.ts +3 -1
  22. package/dist/types/dweb-connect-client.d.ts.map +1 -1
  23. package/dist/types/index.d.ts +8 -2
  24. package/dist/types/index.d.ts.map +1 -1
  25. package/dist/types/relay-connect-runner.d.ts +82 -0
  26. package/dist/types/relay-connect-runner.d.ts.map +1 -0
  27. package/dist/types/ui/connect-modal.d.ts +108 -0
  28. package/dist/types/ui/connect-modal.d.ts.map +1 -0
  29. package/dist/types/ui/qr.d.ts +55 -0
  30. package/dist/types/ui/qr.d.ts.map +1 -0
  31. package/dist/types/ui/wallet-icon.d.ts +13 -0
  32. package/dist/types/ui/wallet-icon.d.ts.map +1 -0
  33. package/dist/types/ui/wallet-well-known.d.ts +33 -0
  34. package/dist/types/ui/wallet-well-known.d.ts.map +1 -0
  35. package/package.json +7 -5
  36. package/src/browser-connect-handler.ts +51 -21
  37. package/src/dweb-connect-client.ts +1 -1
  38. package/src/index.ts +8 -2
  39. package/src/relay-connect-runner.ts +209 -0
  40. package/src/ui/connect-modal.ts +1201 -0
  41. package/src/ui/qr.ts +549 -0
  42. package/src/ui/wallet-icon.ts +63 -0
  43. package/src/ui/wallet-well-known.ts +57 -0
  44. package/dist/esm/ui/wallet-selector.js +0 -585
  45. package/dist/esm/ui/wallet-selector.js.map +0 -1
  46. package/dist/types/ui/wallet-selector.d.ts +0 -44
  47. package/dist/types/ui/wallet-selector.d.ts.map +0 -1
  48. package/src/ui/wallet-selector.ts +0 -658
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Wallet discovery via the `/.well-known/enbox-connect` document.
3
+ *
4
+ * Shared by the connect modal (relay discovery + custom-URL validation)
5
+ * and exported for dapps rolling their own wallet selection UI.
6
+ *
7
+ * @module
8
+ */
9
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
+ return new (P || (P = Promise))(function (resolve, reject) {
12
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
16
+ });
17
+ };
18
+ /** Path of the wallet's connect discovery document, relative to its origin. */
19
+ export const WALLET_WELL_KNOWN_PATH = '/.well-known/enbox-connect';
20
+ /** Timeout applied to the well-known validation fetch. */
21
+ const WELL_KNOWN_FETCH_TIMEOUT_MS = 6000;
22
+ /**
23
+ * Fetch a wallet's `/.well-known/enbox-connect` discovery document.
24
+ *
25
+ * Resolves the parsed document when it is reachable and names a
26
+ * `connectServerUrl`; resolves `undefined` for unreachable origins, non-2xx
27
+ * responses, CORS failures, and malformed documents.
28
+ */
29
+ export function fetchWalletWellKnown(origin) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ try {
32
+ const wellKnownUrl = new URL(WALLET_WELL_KNOWN_PATH, origin).toString();
33
+ const response = yield fetch(wellKnownUrl, { signal: AbortSignal.timeout(WELL_KNOWN_FETCH_TIMEOUT_MS) });
34
+ if (!response.ok) {
35
+ return undefined;
36
+ }
37
+ const payload = yield response.json();
38
+ if (typeof (payload === null || payload === void 0 ? void 0 : payload.connectServerUrl) !== 'string') {
39
+ return undefined;
40
+ }
41
+ return { connectServerUrl: payload.connectServerUrl };
42
+ }
43
+ catch (_a) {
44
+ return undefined;
45
+ }
46
+ });
47
+ }
48
+ /**
49
+ * Fetch a wallet's `/.well-known/enbox-connect` discovery document to confirm
50
+ * the origin hosts an Enbox-compatible wallet.
51
+ *
52
+ * Resolves `true` only when the document is reachable and names a
53
+ * `connectServerUrl`. Unreachable origins, non-2xx responses, CORS failures,
54
+ * and malformed documents resolve `false`.
55
+ */
56
+ export function probeWalletWellKnown(origin) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ return (yield fetchWalletWellKnown(origin)) !== undefined;
59
+ });
60
+ }
61
+ //# sourceMappingURL=wallet-well-known.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-well-known.js","sourceRoot":"","sources":["../../../src/ui/wallet-well-known.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;;;;;;;;;;AAEH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,sBAAsB,GAAG,4BAA4B,CAAC;AAEnE,0DAA0D;AAC1D,MAAM,2BAA2B,GAAG,IAAK,CAAC;AAQ1C;;;;;;GAMG;AACH,MAAM,UAAgB,oBAAoB,CAAC,MAAc;;QACvD,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;YACxE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,2BAA2B,CAAC,EAAE,CAAC,CAAC;YACzG,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAA2C,CAAC;YAC/E,IAAI,OAAO,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,CAAA,KAAK,QAAQ,EAAE,CAAC;gBAClD,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,EAAE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACxD,CAAC;QAAC,WAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CAAA;AAED;;;;;;;GAOG;AACH,MAAM,UAAgB,oBAAoB,CAAC,MAAc;;QACvD,OAAO,CAAC,MAAM,oBAAoB,CAAC,MAAM,CAAC,CAAC,KAAK,SAAS,CAAC;IAC5D,CAAC;CAAA"}
@@ -7,6 +7,7 @@
7
7
  * @module
8
8
  */
9
9
  import type { ConnectHandler } from '@enbox/auth';
10
+ import type { ConnectMethod } from './ui/connect-modal.js';
10
11
  /** A wallet entry shown in the wallet selector modal. */
11
12
  export interface WalletOption {
12
13
  /** Display name (e.g. "Enbox"). */
@@ -48,16 +49,40 @@ export interface BrowserConnectHandlerOptions {
48
49
  * Defaults to `${window.location.origin}/favicon.ico` if omitted.
49
50
  */
50
51
  appIcon?: string;
52
+ /**
53
+ * Preferred connect method on open: `'phone'` (QR / deep link via the
54
+ * relay) or `'browser'` (wallet popup on this device). Overrides the
55
+ * remembered choice.
56
+ * @default 'phone'
57
+ */
58
+ preferredMethod?: ConnectMethod;
59
+ /**
60
+ * Remember the successful method + wallet in localStorage and pre-shape
61
+ * the next connect session accordingly.
62
+ * @default true
63
+ */
64
+ rememberChoice?: boolean;
65
+ /**
66
+ * Relay base URL override for the phone path. When omitted, each wallet's
67
+ * `connectServerUrl` is discovered from its `/.well-known/enbox-connect`
68
+ * document.
69
+ */
70
+ connectServerUrl?: string;
71
+ /**
72
+ * Path appended to the wallet origin to form the phone path's QR /
73
+ * deep-link target.
74
+ * @default '/connect/app'
75
+ */
76
+ relayWalletPath?: string;
51
77
  }
52
78
  /**
53
- * Create a browser-native connect handler using DWeb Connect
54
- * (popup + postMessage).
79
+ * Create a browser-native connect handler over the connect modal.
55
80
  *
56
- * This handler:
57
- * 1. Shows a wallet selector modal (or uses a provided walletUrl).
58
- * 2. Opens the selected wallet as a popup window.
59
- * 3. Runs the DWeb Connect postMessage protocol.
60
- * 4. Returns the delegate credentials on success.
81
+ * The modal owns the whole session on one surface: the phone path (a QR /
82
+ * deep link over the relay, with pairing-code entry) is the default, the
83
+ * in-browser wallet popup is the alternate, and the wallet catalog plus
84
+ * custom-URL entry live in a disclosure. It resolves with the delegate
85
+ * credentials on success and `undefined` when the user denies.
61
86
  *
62
87
  * @example
63
88
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"browser-connect-handler.d.ts","sourceRoot":"","sources":["../../src/browser-connect-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,aAAa,CAAC;AAKjE,yDAAyD;AACzD,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IAEb,0EAA0E;IAC1E,GAAG,EAAE,MAAM,CAAC;IAEZ,mEAAmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,eAAe,EAAE,YAAY,EAqBzC,CAAC;AAEF,oDAAoD;AACpD,MAAM,WAAW,4BAA4B;IAC3C;;;OAGG;IACH,OAAO,CAAC,EAAE,YAAY,EAAE,CAA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,OAAO,CAAC;IAEzB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,4BAAiC,GACzC,cAAc,CA+BhB"}
@@ -19,7 +19,7 @@
19
19
  *
20
20
  * @module
21
21
  */
22
- import type { ConnectPermissionRequest, ConnectRequestProfile, ConnectResult, ConnectTransport } from '@enbox/connect';
22
+ import type { ConnectClientMetadata, ConnectPermissionRequest, ConnectRequestProfile, ConnectResult, ConnectTransport } from '@enbox/connect';
23
23
  /**
24
24
  * Thrown when the user closes the wallet popup before the wallet finished
25
25
  * loading (i.e. before its `loaded` beacon arrived). Callers typically treat
@@ -132,6 +132,8 @@ export type PopupConnectOptions = {
132
132
  */
133
133
  appIcon?: string;
134
134
  };
135
+ /** Collects self-reported environment hints for the wallet's session display. */
136
+ export declare function collectBrowserClientMetadata(): ConnectClientMetadata;
135
137
  /**
136
138
  * Runs one DWeb Connect popup handshake end-to-end: opens the wallet popup,
137
139
  * drives the `@enbox/connect` kernel client over a {@link PopupClientTransport},
@@ -1 +1 @@
1
- {"version":3,"file":"dweb-connect-client.d.ts","sourceRoot":"","sources":["../../src/dweb-connect-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAEV,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AA+BxB;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;;CAKhD;AAED,+DAA+D;AAC/D,MAAM,MAAM,2BAA2B,GAAG;IACxC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;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CAAC,CAA2B;IACrD,OAAO,CAAC,gBAAgB,CAAC,CAAyB;IAElD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkB;IACnD,OAAO,CAAC,gBAAgB,CAAC,CAA4B;IACrD,OAAO,CAAC,eAAe,CAAC,CAAyB;gBAErC,OAAO,EAAE,2BAA2B;IA8ChD;;;;;;;;;;;;;OAaG;IACU,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAU1E;;;OAGG;IACU,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvD;;;;OAIG;IACU,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAI7C,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,IAAI;IASZ,OAAO,CAAC,OAAO;CAQhB;AAED,2DAA2D;AAC3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAElB,sEAAsE;IACtE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;IAE/C;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,4BAA4B,IAAI,qBAAqB,CAcpE;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAqBtG"}
@@ -38,8 +38,14 @@ export { WalletPostMessageTransport } from './dweb-connect-wallet.js';
38
38
  export type { WalletPostMessageTransportOptions } from './dweb-connect-wallet.js';
39
39
  export { DWEB_CONNECT_LOADED_MESSAGE_TYPE, DWEB_CONNECT_PATH, DWEB_CONNECT_REQUEST_MESSAGE_TYPE, DWEB_CONNECT_RESPONSE_MESSAGE_TYPE, } from './dweb-connect-messages.js';
40
40
  export type { DWebConnectLoadedMessage, DWebConnectRequestMessage, DWebConnectResponseMessage, } from './dweb-connect-messages.js';
41
- export type { WalletSelectorOptions } from './ui/wallet-selector.js';
42
- export { probeWalletWellKnown, showWalletSelector, WALLET_WELL_KNOWN_PATH } from './ui/wallet-selector.js';
41
+ export { fetchWalletWellKnown, probeWalletWellKnown, WALLET_WELL_KNOWN_PATH } from './ui/wallet-well-known.js';
42
+ export type { WalletWellKnownDocument } from './ui/wallet-well-known.js';
43
+ export { discoverWalletConnectServerUrl, runConnectModal } from './ui/connect-modal.js';
44
+ export type { ConnectMethod, ConnectModalDeps, ConnectModalOptions } from './ui/connect-modal.js';
45
+ export { MAX_PIN_ATTEMPTS, RelayConnectCancelledError, runRelayConnect } from './relay-connect-runner.js';
46
+ export type { RelayConnectOptions } from './relay-connect-runner.js';
47
+ export { encodeQr, qrToSvg } from './ui/qr.js';
48
+ export type { QrCode, QrSvgOptions } from './ui/qr.js';
43
49
  export { TypedRecord } from '@enbox/api';
44
50
  export { BrowserStorage } from '@enbox/auth/browser';
45
51
  export type { ProviderAuthParams, ProviderAuthResult } from '@enbox/auth/browser';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAMH,OAAO,EACL,KAAK,EACL,cAAc,EACd,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAMpB,OAAO,EACL,WAAW,EACX,WAAW,EACX,yBAAyB,EACzB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,SAAS,EACT,gBAAgB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AAkB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Relay connect runner — the dapp side of the QR/deep-link connect flow,
3
+ * with interactive PIN retry.
4
+ *
5
+ * This mirrors the `@enbox/connect` kernel `ConnectClient` step-for-step and
6
+ * is composed entirely from the kernel's exported primitives (`sealRequest`,
7
+ * `openResponse`, `RelayClientTransport`); no cryptography is reimplemented
8
+ * here. It exists as a separate orchestrator for one reason the kernel
9
+ * client cannot express today: **PIN retry against the delivered response**.
10
+ * `ConnectClient` collects the PIN once and opens the response once, so a
11
+ * mistyped code fails the whole handshake — the wallet user would have to
12
+ * scan and approve again. The connect modal instead keeps the sealed
13
+ * response and re-runs `openResponse` per attempt, which is safe because
14
+ * opening is a pure decrypt-and-verify step.
15
+ *
16
+ * If the kernel later grows a PIN-attempts seam, this module collapses into
17
+ * `ConnectClient` usage.
18
+ *
19
+ * @module
20
+ */
21
+ import type { ConnectClientMetadata, ConnectPermissionRequest, ConnectResult, WalletUriHandoff } from '@enbox/connect';
22
+ import { RelayClientTransport } from '@enbox/connect';
23
+ /** Maximum interactive PIN attempts before the handshake fails. */
24
+ export declare const MAX_PIN_ATTEMPTS = 6;
25
+ /** Thrown internally when a relay handshake is cancelled by the UI. */
26
+ export declare class RelayConnectCancelledError extends Error {
27
+ constructor();
28
+ }
29
+ /** Options for {@link runRelayConnect}. */
30
+ export interface RelayConnectOptions {
31
+ /** Relay base URL (the wallet's `connectServerUrl`). */
32
+ connectServerUrl: string;
33
+ /** Wallet URI the request pointer is attached to (QR / deep-link target). */
34
+ walletUri: string;
35
+ /** The user-friendly name of the app, shown in the wallet consent UI. */
36
+ appName: string;
37
+ /** Optional icon URL for the app, shown in the wallet consent UI. */
38
+ appIcon?: string;
39
+ /** Optional client/environment metadata for wallet session display. */
40
+ clientMetadata?: ConnectClientMetadata;
41
+ /** DWN protocols and permission scopes being requested. */
42
+ permissionRequests: ConnectPermissionRequest[];
43
+ /** Total milliseconds to poll the relay for a wallet response. */
44
+ timeoutMs?: number;
45
+ /** Milliseconds between relay polling attempts. */
46
+ pollIntervalMs?: number;
47
+ /**
48
+ * Receives the wallet URI handoff (with the request pointer TTL) as soon
49
+ * as the request is delivered — render it as a QR code or deep link.
50
+ */
51
+ onWalletUriReady: (handoff: WalletUriHandoff) => void;
52
+ /**
53
+ * Collects one PIN attempt from the user. Called again (with the attempt
54
+ * number, 1-based, and the previous failure) after a wrong code, up to
55
+ * {@link MAX_PIN_ATTEMPTS} times.
56
+ */
57
+ requestPin: (attempt: number, previousError?: Error) => Promise<string>;
58
+ /**
59
+ * Cancellation signal: when it settles, polling stops and the handshake
60
+ * rejects with {@link RelayConnectCancelledError}.
61
+ */
62
+ cancelled?: Promise<never> | undefined;
63
+ /**
64
+ * Invoked once when the relay reports the wallet has claimed (fetched)
65
+ * the pushed request — the app can show "phone connected" progress.
66
+ */
67
+ onClaimed?: () => void;
68
+ /** Transport factory override (tests). */
69
+ createTransport?: (options: {
70
+ connectServerUrl: string;
71
+ walletUri: string;
72
+ timeoutMs?: number;
73
+ pollIntervalMs?: number;
74
+ onClaimed?: () => void;
75
+ }) => Pick<RelayClientTransport, 'requestProfile' | 'deliverRequest' | 'awaitResponse' | 'requiresPin'>;
76
+ }
77
+ /**
78
+ * Runs one relay-mediated connect handshake end-to-end and returns the
79
+ * delegated credentials, or `undefined` when the user denied in the wallet.
80
+ */
81
+ export declare function runRelayConnect(options: RelayConnectOptions): Promise<ConnectResult | undefined>;
82
+ //# sourceMappingURL=relay-connect-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-connect-runner.d.ts","sourceRoot":"","sources":["../../src/relay-connect-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EAExB,aAAa,EACb,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAIL,oBAAoB,EAErB,MAAM,gBAA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,CAAC;CACzG;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA4FtG"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Connect modal — the single surface that owns a whole connect session.
3
+ *
4
+ * One Shadow-DOM dialog whose stage morphs in place through the session:
5
+ * QR (phone path) → pairing code → connected, with the in-browser popup
6
+ * path and the wallet catalog folded in as in-place alternates. The modal
7
+ * never chains into a second modal and stays mounted until the session
8
+ * resolves (connected / denied / cancelled).
9
+ *
10
+ * Layout: three zones —
11
+ *
12
+ * 1. **Header** — requesting app identity + close.
13
+ * 2. **Stage** — a height-stable region where states crossfade: the QR
14
+ * (or deep link on phones), the pairing-code input, progress, success,
15
+ * and error states.
16
+ * 3. **Footer** — the alternate-method link and the wallet switcher
17
+ * disclosure (catalog + custom URL — the entire legacy selector,
18
+ * demoted to an option).
19
+ *
20
+ * The phone path drives the `@enbox/connect` relay transport via
21
+ * {@link runRelayConnect}; the browser path drives the popup transport via
22
+ * the kernel `ConnectClient`. Wallet `connectServerUrl`s are discovered
23
+ * from each wallet's `/.well-known/enbox-connect` document unless
24
+ * overridden.
25
+ *
26
+ * @module
27
+ */
28
+ import type { WalletOption } from '../browser-connect-handler.js';
29
+ import type { ConnectPermissionRequest, ConnectResult } from '@enbox/connect';
30
+ import { runRelayConnect } from '../relay-connect-runner.js';
31
+ /** How the user carries out the approval. */
32
+ export type ConnectMethod = 'phone' | 'browser';
33
+ /** Options for {@link runConnectModal}. */
34
+ export interface ConnectModalOptions {
35
+ /** Wallet catalog shown in the wallet switcher. */
36
+ wallets?: WalletOption[];
37
+ /**
38
+ * Explicit wallet URL: hides the catalog switcher and uses this wallet
39
+ * for both methods.
40
+ */
41
+ walletUrl?: string;
42
+ /** Preferred method on open; overrides the remembered choice. */
43
+ preferredMethod?: ConnectMethod;
44
+ /**
45
+ * Remember the successful method + wallet in localStorage and pre-shape
46
+ * the next session accordingly.
47
+ * @default true
48
+ */
49
+ rememberChoice?: boolean;
50
+ /** Display name of the requesting application. */
51
+ appName?: string;
52
+ /** Icon URL of the requesting application. */
53
+ appIcon?: string;
54
+ /**
55
+ * Relay base URL override for the phone path. When omitted, each wallet's
56
+ * `connectServerUrl` is discovered from its `/.well-known/enbox-connect`
57
+ * document.
58
+ */
59
+ connectServerUrl?: string;
60
+ /**
61
+ * Path appended to the wallet origin to form the QR / deep-link target.
62
+ * @default '/connect/app'
63
+ */
64
+ relayWalletPath?: string;
65
+ /** Timeout in milliseconds for either method's handshake. */
66
+ timeout?: number;
67
+ /** DWN protocols and permission scopes being requested. */
68
+ permissionRequests: ConnectPermissionRequest[];
69
+ /** Internal dependency seams (tests). */
70
+ deps?: Partial<ConnectModalDeps>;
71
+ }
72
+ /** Injectable collaborators, defaulted to the real implementations. */
73
+ export interface ConnectModalDeps {
74
+ /** Runs one relay handshake (phone path). */
75
+ runRelay: typeof runRelayConnect;
76
+ /** Runs one popup handshake (browser path); must open the popup synchronously. */
77
+ runPopup: (options: {
78
+ walletUrl: string;
79
+ permissionRequests: ConnectPermissionRequest[];
80
+ appName: string;
81
+ appIcon?: string;
82
+ timeoutMs?: number;
83
+ }) => Promise<ConnectResult | undefined>;
84
+ /** Resolves a wallet origin to its relay `connectServerUrl` (or undefined). */
85
+ discoverConnectServerUrl: (walletOrigin: string) => Promise<string | undefined>;
86
+ /** Validates a pasted custom wallet URL. */
87
+ validateWalletUrl: (origin: string) => Promise<boolean>;
88
+ /** Whether to present the deep-link (same-device) variant of the phone path. */
89
+ isMobile: () => boolean;
90
+ /** Persistence for the remembered choice. */
91
+ storage: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'> | undefined;
92
+ }
93
+ /**
94
+ * Resolves a wallet origin to its relay `connectServerUrl` via the wallet's
95
+ * `/.well-known/enbox-connect` document ({@link fetchWalletWellKnown} — the
96
+ * same machinery the wallet selector uses for custom-URL validation).
97
+ */
98
+ export declare function discoverWalletConnectServerUrl(walletOrigin: string): Promise<string | undefined>;
99
+ /**
100
+ * Opens the connect modal and resolves when the session ends.
101
+ *
102
+ * @returns The delegated credentials; `undefined` when the user denied the
103
+ * request in the wallet (or dismissed after a denial).
104
+ * @throws When the user cancels the modal, or the session fails and the
105
+ * user dismisses the error.
106
+ */
107
+ export declare function runConnectModal(options: ConnectModalOptions): Promise<ConnectResult | undefined>;
108
+ //# sourceMappingURL=connect-modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect-modal.d.ts","sourceRoot":"","sources":["../../../src/ui/connect-modal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,aAAa,EAAoB,MAAM,gBAAgB,CAAC;AAYhG,OAAO,EAA8B,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEzF,6CAA6C;AAC7C,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;AAchD,2CAA2C;AAC3C,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IAEzB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iEAAiE;IACjE,eAAe,CAAC,EAAE,aAAa,CAAC;IAEhC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2DAA2D;IAC3D,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;IAE/C,yCAAyC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAClC;AAED,uEAAuE;AACvE,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,QAAQ,EAAE,OAAO,eAAe,CAAC;IAEjC,kFAAkF;IAClF,QAAQ,EAAE,CAAC,OAAO,EAAE;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;QAC/C,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAEzC,+EAA+E;IAC/E,wBAAwB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEhF,4CAA4C;IAC5C,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAExD,gFAAgF;IAChF,QAAQ,EAAE,MAAM,OAAO,CAAC;IAExB,6CAA6C;IAC7C,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC,GAAG,SAAS,CAAC;CAC1E;AAED;;;;GAIG;AACH,wBAAsB,8BAA8B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEtG;AAgGD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAsnBhG"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Minimal QR code encoder — dependency-free, byte mode, ECC level M,
3
+ * versions 1–10 with automatic version selection and standard mask
4
+ * evaluation (ISO/IEC 18004 penalty rules N1–N4).
5
+ *
6
+ * Scope is deliberately narrow: it exists to render wallet-connect URIs in
7
+ * the connect modal without adding a third-party runtime dependency. The
8
+ * encoding pipeline follows the standard exactly — segment → codewords →
9
+ * Reed-Solomon blocks → interleave → placement → mask — and the test suite
10
+ * verifies full module-matrix equality against the `qrcode` npm package
11
+ * (dev-only oracle) across versions and mask patterns.
12
+ *
13
+ * @module
14
+ */
15
+ /** An encoded QR symbol: `modules[y][x]` is `true` for dark modules. */
16
+ export interface QrCode {
17
+ /** Symbol width/height in modules (17 + 4×version). */
18
+ size: number;
19
+ /** Dark/light module matrix, row-major. */
20
+ modules: boolean[][];
21
+ /** Symbol version (1–10). */
22
+ version: number;
23
+ /** Applied mask pattern (0–7). */
24
+ mask: number;
25
+ }
26
+ /**
27
+ * Encodes UTF-8 text as a byte-mode QR symbol at ECC level M.
28
+ *
29
+ * @param text - The payload; encoded as UTF-8 bytes.
30
+ * @param forcedMask - Optional mask override (0–7); defaults to the
31
+ * penalty-minimising mask per the standard.
32
+ * @returns The encoded symbol.
33
+ * @throws If the payload does not fit in a version-10 level-M symbol.
34
+ */
35
+ export declare function encodeQr(text: string, forcedMask?: number): QrCode;
36
+ /** Options for {@link qrToSvg}. */
37
+ export interface QrSvgOptions {
38
+ /** Dark module colour. @default '#000000' */
39
+ dark?: string;
40
+ /** Light/background colour; `'transparent'` is allowed. @default '#ffffff' */
41
+ light?: string;
42
+ /** Quiet-zone width in modules on each side. @default 2 */
43
+ quietZone?: number;
44
+ }
45
+ /**
46
+ * Renders an encoded symbol as a crisp, scalable `<svg>` element. One
47
+ * `<path>` carries all dark modules so the output stays compact.
48
+ *
49
+ * Built with `createElementNS`/`setAttribute` rather than markup strings so
50
+ * caller-supplied colours can never be interpreted as HTML (CodeQL
51
+ * js/html-constructed-from-input). Append the returned element directly;
52
+ * never serialize it back through `innerHTML`.
53
+ */
54
+ export declare function qrToSvg(qr: QrCode, options?: QrSvgOptions): SVGSVGElement;
55
+ //# sourceMappingURL=qr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qr.d.ts","sourceRoot":"","sources":["../../../src/ui/qr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,wEAAwE;AACxE,MAAM,WAAW,MAAM;IACrB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,2CAA2C;IAC3C,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;IAErB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAEhB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CA4ElE;AAuWD,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC3B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,aAAa,CAgC7E"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Wallet icon builder shared by the connect modal's wallet switcher.
3
+ *
4
+ * Prefers the wallet's own favicon and degrades to a letter badge. We never
5
+ * call a third-party favicon proxy: those 404 for many origins and leak the
6
+ * wallet URL to the proxy.
7
+ *
8
+ * @module
9
+ */
10
+ import type { WalletOption } from '../browser-connect-handler.js';
11
+ /** Build a wallet icon element (own favicon with a letter-badge fallback). */
12
+ export declare function buildWalletIcon(wallet: WalletOption): HTMLElement;
13
+ //# sourceMappingURL=wallet-icon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-icon.d.ts","sourceRoot":"","sources":["../../../src/ui/wallet-icon.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAiCjE"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Wallet discovery via the `/.well-known/enbox-connect` document.
3
+ *
4
+ * Shared by the connect modal (relay discovery + custom-URL validation)
5
+ * and exported for dapps rolling their own wallet selection UI.
6
+ *
7
+ * @module
8
+ */
9
+ /** Path of the wallet's connect discovery document, relative to its origin. */
10
+ export declare const WALLET_WELL_KNOWN_PATH = "/.well-known/enbox-connect";
11
+ /** The wallet's `/.well-known/enbox-connect` discovery document. */
12
+ export interface WalletWellKnownDocument {
13
+ /** Base URL of the relay that brokers this wallet's remote connects. */
14
+ connectServerUrl: string;
15
+ }
16
+ /**
17
+ * Fetch a wallet's `/.well-known/enbox-connect` discovery document.
18
+ *
19
+ * Resolves the parsed document when it is reachable and names a
20
+ * `connectServerUrl`; resolves `undefined` for unreachable origins, non-2xx
21
+ * responses, CORS failures, and malformed documents.
22
+ */
23
+ export declare function fetchWalletWellKnown(origin: string): Promise<WalletWellKnownDocument | undefined>;
24
+ /**
25
+ * Fetch a wallet's `/.well-known/enbox-connect` discovery document to confirm
26
+ * the origin hosts an Enbox-compatible wallet.
27
+ *
28
+ * Resolves `true` only when the document is reachable and names a
29
+ * `connectServerUrl`. Unreachable origins, non-2xx responses, CORS failures,
30
+ * and malformed documents resolve `false`.
31
+ */
32
+ export declare function probeWalletWellKnown(origin: string): Promise<boolean>;
33
+ //# sourceMappingURL=wallet-well-known.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-well-known.d.ts","sourceRoot":"","sources":["../../../src/ui/wallet-well-known.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,sBAAsB,+BAA+B,CAAC;AAKnE,oEAAoE;AACpE,MAAM,WAAW,uBAAuB;IACtC,wEAAwE;IACxE,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAgBvG;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE3E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/browser",
3
- "version": "0.3.43",
3
+ "version": "0.3.45",
4
4
  "description": "Enbox tools and features to use in the browser",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -66,21 +66,23 @@
66
66
  "access": "public"
67
67
  },
68
68
  "dependencies": {
69
- "@enbox/agent": "0.8.18",
70
- "@enbox/api": "0.6.56",
71
- "@enbox/auth": "0.6.64",
69
+ "@enbox/agent": "0.8.19",
70
+ "@enbox/api": "0.6.57",
71
+ "@enbox/auth": "0.6.65",
72
72
  "@enbox/common": "0.1.3",
73
- "@enbox/connect": "0.1.1",
73
+ "@enbox/connect": "0.1.2",
74
74
  "@enbox/crypto": "0.1.5",
75
75
  "@enbox/dids": "0.1.5",
76
76
  "@enbox/dwn-sdk-js": "0.4.10"
77
77
  },
78
78
  "devDependencies": {
79
+ "@types/qrcode": "^1.5.6",
79
80
  "@typescript-eslint/eslint-plugin": "8.32.1",
80
81
  "@typescript-eslint/parser": "8.32.1",
81
82
  "@vitest/browser-playwright": "4.0.18",
82
83
  "@vitest/coverage-istanbul": "4.0.18",
83
84
  "eslint": "9.7.0",
85
+ "qrcode": "1.5.4",
84
86
  "typescript": "5.9.3",
85
87
  "vitest": "4.0.18"
86
88
  }