@partylayer/sdk 0.22.0 → 0.22.1

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.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import * as _partylayer_core from '@partylayer/core';
2
- import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, TransferIntent, TransferResult, TokenHoldingRef, TokenHoldingV2Ref, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts, PersistedSession } from '@partylayer/core';
3
- export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TRANSFER_INTENT_FIELDS, TimeoutError, TokenInstrumentId, TransactionStatus, TransferIntent, TransferResult, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter, toTransferIntent } from '@partylayer/core';
4
- import { RegistryClient, RegistryStatus } from '@partylayer/registry-client';
5
- export { Cip0103StatusForDetection, Cip0103Support, ProviderDetection, ProviderMatcher, RegistryStatus, deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
1
+ import { P as PartyLayerBaseConfig, a as PartyLayerClientBase, T as TelemetryConfig } from './application-ledger-reader-DYaIuRCD.js';
2
+ export { A as AdapterClass, b as ApplicationLedgerReaderOptions, c as CantonConnectEvent, C as ConnectOptions, D as DEFAULT_REGISTRY_URL, E as ErrorEvent, d as EventHandler, c as PartyLayerEvent, R as RegistryUpdatedEvent, S as SessionConnectedEvent, e as SessionDisconnectedEvent, f as SessionExpiredEvent, g as TxStatusEvent, W as WalletFilter, h as WalletHoldingsSnapshot, i as WalletHoldingsV2Snapshot, j as WalletLedgerClient, k as WalletLedgerReader, l as WalletLedgerReaderOptions, m as WalletTransactionConfirmation, n as WalletTransactionReference, o as WalletsChangedEvent, p as createApplicationLedgerReader, q as createWalletLedgerReader } from './application-ledger-reader-DYaIuRCD.js';
6
3
  import { BronAdapterConfig } from '@partylayer/adapter-bron';
7
4
  export { BronAdapter, BronAdapterConfig, BronApiConfig, BronAuthConfig } from '@partylayer/adapter-bron';
8
5
  import { WalletConnectAdapterConfig } from '@partylayer/adapter-walletconnect';
9
6
  export { WalletConnectAdapterConfig } from '@partylayer/adapter-walletconnect';
7
+ import { WalletAdapter, WalletId, CIP0103Provider, NetworkId, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, Session, SubmitTransactionParams, TxReceipt, OfficialProviderAdapter, OfficialAdapterFactory, NetworkHosts, PersistedSession, SignMessageParams, SignedMessage, TelemetryAdapter } from '@partylayer/core';
8
+ export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TRANSFER_INTENT_FIELDS, TimeoutError, TokenInstrumentId, TransactionStatus, TransferIntent, TransferResult, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter, toTransferIntent } from '@partylayer/core';
9
+ export { Cip0103StatusForDetection, Cip0103Support, ProviderDetection, ProviderMatcher, RegistryStatus, deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
10
10
  export { CANTON_NETWORKS, CIP0103Account, CIP0103ConnectResult, CIP0103Event, CIP0103EventBus, CIP0103Method, CIP0103Network, CIP0103Provider, CIP0103StatusEvent, CIP0103TxChangedEvent, CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, DiscoveredProvider, JSON_RPC_ERRORS, PartyLayerProvider, PartyLayerProviderOptions, ProviderRpcError, RPC_ERRORS, createProviderBridge, discoverInjectedProviders, fromCAIP2Network, isCIP0103Provider, isValidCAIP2, toCAIP2Network, waitForProvider } from '@partylayer/provider';
11
11
  export { Cantor8Adapter } from '@partylayer/adapter-cantor8';
12
12
  export { ConsoleAdapter } from '@partylayer/adapter-console';
@@ -14,727 +14,23 @@ export { LoopAdapter } from '@partylayer/adapter-loop';
14
14
  export { NightlyAdapter } from '@partylayer/adapter-nightly';
15
15
  export { SendAdapter } from '@partylayer/adapter-send';
16
16
 
17
- /**
18
- * Configuration types for PartyLayer SDK
19
- */
17
+ /** Browser options extend the transport-independent client configuration. */
20
18
 
21
- /**
22
- * Default registry URL for PartyLayer
23
- * This points to the official registry endpoint.
24
- */
25
- declare const DEFAULT_REGISTRY_URL = "https://registry.partylayer.xyz";
26
- /**
27
- * Telemetry configuration for opt-in metrics collection
28
- *
29
- * @since 0.3.0
30
- */
31
- interface TelemetryConfig {
32
- /**
33
- * Enable telemetry collection
34
- * @default false
35
- */
36
- enabled: boolean;
37
- /**
38
- * Metrics backend endpoint URL
39
- * If not provided, metrics are collected but not sent
40
- */
41
- endpoint?: string;
42
- /**
43
- * Sampling rate (0.0 to 1.0)
44
- * @default 1.0 (100% of events)
45
- */
46
- sampleRate?: number;
47
- /**
48
- * Application identifier (will be hashed for privacy)
49
- * Used to calculate Monthly Active dApps (MAD)
50
- */
51
- appId?: string;
52
- /**
53
- * Include hashed origin in metrics
54
- * @default false
55
- */
56
- includeOrigin?: boolean;
57
- /**
58
- * Number of events to buffer before sending
59
- * @default 10
60
- */
61
- batchSize?: number;
62
- /**
63
- * Interval to flush metrics in milliseconds
64
- * @default 30000 (30 seconds)
65
- */
66
- flushIntervalMs?: number;
67
- /**
68
- * Network to include in metrics
69
- * If not provided, uses the SDK's configured network
70
- */
71
- network?: NetworkId;
72
- }
73
- /**
74
- * Adapter class type (for instantiation)
75
- */
76
- type AdapterClass = new () => WalletAdapter;
77
- /**
78
- * PartyLayer configuration
79
- */
80
- interface PartyLayerConfig {
81
- /**
82
- * Delay browser subscriptions and automatic restoration until initialize()
83
- * or the first explicit client action. Frameworks use this for render safety.
84
- * @default false
85
- */
86
- deferInitialization?: boolean;
87
- /**
88
- * Registry base URL (optional). The client appends `/v1/{channel}/registry.json`,
89
- * so the default fetch is `https://registry.partylayer.xyz/v1/stable/registry.json`.
90
- * @default 'https://registry.partylayer.xyz'
91
- */
92
- registryUrl?: string;
93
- /** Registry channel */
94
- channel?: 'stable' | 'beta';
95
- /** Default network */
96
- network: NetworkId;
97
- /**
98
- * Network-mismatch enforcement policy (default: `'guard'`).
99
- *
100
- * When a connected wallet's effective network differs from `network`:
101
- * - `'off'` — detect + emit `session:networkMismatch` only; never block.
102
- * - `'guard'` — (default) block wrong-network TRANSACTIONS (signMessage,
103
- * signTransaction, submitTransaction, ledgerApi); connect still succeeds.
104
- * - `'strict'` — also block CONNECT (throws `NetworkMismatchError`).
105
- *
106
- * BEHAVIOR CHANGE: prior to this, wrong-network transactions always
107
- * proceeded. Set `'off'` to restore that.
108
- */
109
- networkEnforcement?: 'off' | 'guard' | 'strict';
110
- /**
111
- * Replace the default wallet catalog. Omit for all supported wallets on the
112
- * configured network/channel. Official wallet SDKs are included and loaded
113
- * lazily; no per-wallet installation or registration is required.
114
- */
115
- adapters?: (WalletAdapter | AdapterClass | OfficialProviderAdapter | OfficialAdapterFactory)[];
116
- /** Extend the default catalog with custom adapters (for example a test wallet). */
117
- additionalAdapters?: PartyLayerConfig['adapters'];
19
+ interface PartyLayerConfig extends PartyLayerBaseConfig {
118
20
  /** Enable WalletConnect with your application's Cloud project id. */
119
21
  walletConnect?: WalletConnectAdapterConfig;
120
22
  /** Enable the Bron remote signer with your application's OAuth/API configuration. */
121
23
  bron?: BronAdapterConfig;
122
- /** Storage adapter (default: browser localStorage-based encrypted) */
123
- storage?: StorageAdapter;
124
- /** Crypto adapter (default: WebCrypto) */
125
- crypto?: CryptoAdapter;
126
- /** Registry public keys for signature verification (ed25519) */
127
- registryPublicKeys?: string[];
128
- /**
129
- * EIP-6963-style announce discovery — the canonical Canton provider contract
130
- * (`canton:requestProvider` → `canton:announceProvider`, see provider.md).
131
- *
132
- * When enabled, `listWallets()` aggregates announced CIP-0103 wallets with
133
- * the `window.canton` namespace scan, the registry, and registered adapters:
134
- * - an announced id matching a registered/registry wallet's
135
- * `providerDetection` (provider.id) maps to that adapter — NO duplicate
136
- * picker entry (e.g. Console's announce `lpnf…` → the Console adapter);
137
- * - an UNKNOWN announced id surfaces as a dynamic entry routed to its own
138
- * extension `target` (collision-proof; future announce-capable wallets
139
- * appear with zero code changes).
140
- *
141
- * Default ON in the browser; ALWAYS skipped under SSR (`typeof window` guard).
142
- * With zero announcers, `listWallets()` output is byte-identical to before.
143
- */
144
- discovery?: {
145
- /** Aggregate `canton:announceProvider` wallets. @default true (in browser) */
146
- announce?: boolean;
147
- /** Announce-collection window in ms. @default 300 (canonical ~300ms) */
148
- announceTimeoutMs?: number;
149
- };
150
- /**
151
- * Telemetry configuration or adapter
152
- *
153
- * Can be either:
154
- * - TelemetryConfig object for built-in metrics collection
155
- * - TelemetryAdapter instance for custom telemetry
156
- *
157
- * @default undefined (telemetry disabled)
158
- * @since 0.3.0 - Added TelemetryConfig support
159
- */
160
- telemetry?: TelemetryAdapter | TelemetryConfig;
161
- /** Logger adapter (optional) */
162
- logger?: LoggerAdapter;
163
- /**
164
- * Log verbosity. Filtering happens centrally in the client before the adapter is
165
- * called, so adapters never filter themselves. `silent` suppresses everything.
166
- * Defaults to `info` when a logger is supplied; with no logger the client is
167
- * silent regardless.
168
- */
169
- logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
170
- /** Application metadata */
171
- app: {
172
- /** Application name */
173
- name: string;
174
- /** Origin (for origin binding checks, defaults to window.location.origin) */
175
- origin?: string;
176
- };
177
24
  }
178
- /**
179
- * Connect options
180
- */
181
- interface ConnectOptions {
182
- /** Specific wallet ID to connect to */
183
- walletId?: WalletId;
184
- /** Prefer installed wallets */
185
- preferInstalled?: boolean;
186
- /** Allow only specific wallets */
187
- allowWallets?: WalletId[];
188
- /** Required capabilities */
189
- requiredCapabilities?: string[];
190
- /** Timeout in milliseconds */
191
- timeoutMs?: number;
192
- /**
193
- * Called with a pairing/display URI (e.g. a WalletConnect `wc:` URI) the
194
- * moment the adapter produces one, before approval. Used by the connect UI
195
- * to render a QR / deep-link. Adapters without such a URI never call it.
196
- */
197
- onDisplayUri?: (uri: string) => void;
198
- }
199
- /**
200
- * Wallet filter options
201
- */
202
- interface WalletFilter {
203
- /** Required capabilities */
204
- requiredCapabilities?: string[];
205
- /** Include experimental wallets */
206
- includeExperimental?: boolean;
207
- }
208
-
209
- /**
210
- * Event types for PartyLayer SDK
211
- */
212
25
 
213
- /**
214
- * Registry updated event
215
- */
216
- interface RegistryUpdatedEvent {
217
- type: 'registry:updated';
218
- channel: 'stable' | 'beta';
219
- version: string;
220
- }
221
- /**
222
- * Registry status event
223
- */
224
- interface RegistryStatusEvent {
225
- type: 'registry:status';
226
- status: {
227
- source: 'network' | 'cache';
228
- verified: boolean;
229
- channel: 'stable' | 'beta';
230
- sequence: number;
231
- stale: boolean;
232
- fetchedAt: number;
233
- etag?: string;
234
- error?: Error;
235
- };
236
- }
237
- /**
238
- * Session connected event
239
- */
240
- interface SessionConnectedEvent {
241
- type: 'session:connected';
242
- session: Session;
243
- }
244
- /**
245
- * Session disconnected event
246
- */
247
- interface SessionDisconnectedEvent {
248
- type: 'session:disconnected';
249
- sessionId: SessionId;
250
- reason?: string;
251
- }
252
- /**
253
- * Session expired event
254
- */
255
- interface SessionExpiredEvent {
256
- type: 'session:expired';
257
- sessionId: SessionId;
258
- }
259
- /**
260
- * Network mismatch event — the connected wallet's effective network differs
261
- * from the dApp's configured network. Emitted under ALL policies (informational);
262
- * `enforced` is true when the active policy ('guard' | 'strict') will block.
263
- */
264
- interface SessionNetworkMismatchEvent {
265
- type: 'session:networkMismatch';
266
- sessionId: SessionId;
267
- /** dApp-configured (expected) network, CAIP-2 normalized. */
268
- expected: string;
269
- /** Wallet-reported (actual) network, CAIP-2 normalized. */
270
- actual: string;
271
- /** Whether the active policy will block (guard|strict) vs. detect-only (off). */
272
- enforced: boolean;
273
- }
274
- /**
275
- * Transaction status event
276
- */
277
- interface TxStatusEvent {
278
- type: 'tx:status';
279
- sessionId: SessionId;
280
- /**
281
- * The transaction id, when the wallet reported one. Optional for the same
282
- * reason as `TxReceipt.transactionHash`, which is where it comes from: a
283
- * wallet with no hash to give produces an event with no id, and saying so
284
- * beats emitting an invented one. Prefer reading `updateId` off the receipt
285
- * when you need a ledger identifier.
286
- */
287
- txId?: TransactionHash;
288
- status: TransactionStatus;
289
- raw?: unknown;
290
- }
291
- /**
292
- * Error event
293
- */
294
- interface ErrorEvent {
295
- type: 'error';
296
- error: Error;
297
- }
298
- /**
299
- * Wallet-list changed event — the set of listable wallets changed since the last
300
- * `listWallets()` (e.g. a wallet announced late via `canton:announceProvider`,
301
- * after the picker already loaded). SIGNAL-ONLY: it carries no wallet payload
302
- * because `listWallets()` does registry-merge + discovery-gating + identity-
303
- * bridging + filtering that a raw announce doesn't reflect — the authoritative
304
- * read is to re-call `listWallets()` (mirrors EIP-6963/mipd: store emits, UI
305
- * re-reads). Emitted debounced (coalesces a burst into one). Never emitted when
306
- * nothing announces (byte-identical idle).
307
- */
308
- interface WalletsChangedEvent {
309
- type: 'wallets:changed';
310
- /** Why the list changed. Currently only late/inject-time announce discovery. */
311
- reason: 'announced';
312
- }
313
- /**
314
- * All event types
315
- */
316
- type PartyLayerEvent = RegistryUpdatedEvent | RegistryStatusEvent | SessionConnectedEvent | SessionDisconnectedEvent | SessionExpiredEvent | SessionNetworkMismatchEvent | TxStatusEvent | WalletsChangedEvent | ErrorEvent;
317
- /**
318
- * Event handler type
319
- */
320
- type EventHandler<T extends PartyLayerEvent = PartyLayerEvent> = (event: T) => void | Promise<void>;
26
+ /** Browser client: preserve the full reviewed wallet catalog and discovery runtime. */
321
27
 
322
- declare class PartyLayerClient {
323
- private config;
324
- private adapters;
325
- private destroyed;
326
- private initialized;
327
- private readonly defaultLoads;
328
- private readonly registryDefaultIds;
329
- /**
330
- * Pre-resolved connect plans for popup/remote (GenericDiscoveryAdapter)
331
- * wallets, warmed on `listWallets()` (which the modal calls on open) so a
332
- * subsequent click can connect gesture-synchronously. Consumed (deleted) on
333
- * use and cleared on disconnect; a cold miss falls back to the normal path.
334
- */
335
- private readonly warmPlans;
336
- private eventHandlers;
337
- private activeSession;
338
- private sessionRevision;
339
- private connectionAttempt;
340
- private restoreTask;
341
- private restorationBlocked;
342
- private sessionStorageQueue;
343
- /**
344
- * True when `activeSession` was revived AS-IS (no live `status()` probe) because
345
- * its adapter wasn't registered yet at restore time (the lazy configured-announce
346
- * case). Cleared once a live probe validates it (or on fresh connect). When set,
347
- * `aggregateAnnouncedWallets` re-probes the session the moment that adapter is born.
348
- */
349
- private activeSessionNeedsProbe;
350
- readonly registryClient: RegistryClient;
351
- private logger;
352
- /** Configured log verbosity; filtering happens centrally in {@link log}. */
353
- private readonly logLevel;
354
- private crypto;
355
- private storage;
356
- private telemetry?;
357
- /** Cached announce-discovery picker entries (one-shot; cleared by refreshDiscovery). */
358
- private announceEntriesCache;
359
- private readonly announceRegistry;
360
- private readonly announceChannels;
361
- private announceUnsubscribe;
362
- /** Pending debounced `wallets:changed` emit (coalesces an announce burst). */
363
- private walletsChangedTimer;
364
- private origin;
365
- private readonly nativeOwner?;
366
- private sessionProvider?;
28
+ declare class PartyLayerClient extends PartyLayerClientBase {
367
29
  constructor(config: PartyLayerConfig);
368
- /** Start browser discovery/restoration once; safe for framework effect replay. */
369
- initialize(): void;
370
- private announceChannel;
371
- /**
372
- * Register a wallet adapter
373
- *
374
- * @internal
375
- * This is used internally by the SDK to register adapters.
376
- * In production, adapters would be auto-registered via registry.
377
- */
378
- registerAdapter(adapter: WalletAdapter): void;
379
- private onNativeIdentityChanged;
380
- /**
381
- * Look up a registered adapter by wallet id.
382
- *
383
- * Returns the adapter instance when one is registered for the given
384
- * `walletId`, or `undefined` otherwise. Intended for UI integrations
385
- * that need to call `adapter.detectInstalled()` directly to render a
386
- * per-wallet readiness indicator (instead of duplicating
387
- * transport-specific install detection logic in the picker). The
388
- * returned adapter is the same instance used internally for connect /
389
- * sign / submit flows; do not mutate it.
390
- *
391
- * Accepts both raw string ids and the branded `WalletId` form so
392
- * consumers can pass `walletInfo.walletId` or a string literal
393
- * interchangeably.
394
- */
395
- getAdapter(walletId: string | WalletId): WalletAdapter | undefined;
396
- /**
397
- * List available wallets
398
- */
399
- listWallets(filter?: WalletFilter): Promise<WalletInfo[]>;
400
- /** Resolve only reviewed default SDKs present in the active registry. */
401
- private ensureDefaultWallets;
402
- /**
403
- * Hide registry entries whose wallet needs an app-registered adapter that is
404
- * NOT registered. This is the library default (RainbowKit-style): never show a
405
- * wallet the app cannot actually connect.
406
- *
407
- * A wallet is connectable with NO app adapter only when it is driven by the
408
- * generic announce path (`adapter.transport: 'announce'`, e.g. Console, Send):
409
- * there the SDK builds a generic announce adapter from the registry entry on
410
- * demand, so installing the extension is enough and the entry stays visible.
411
- * Every other transport can only connect through an adapter the app registered:
412
- * a `discovery-adapter` popup/remote wallet whose official ProviderAdapter
413
- * the app supplies (bridged under `toWalletId(providerId)`), or a wallet that
414
- * ships a PartyLayer adapter package (Loop, Cantor8, Nightly, Bron,
415
- * WalletConnect). Without that adapter, clicking the entry can only fail
416
- * (connect throws), so it surfaces only when the adapter is present.
417
- *
418
- * The decision reads each entry's DECLARED transport, never a hardcoded wallet
419
- * list. No-op when the registry is unavailable (the list is already
420
- * adapters-only) or every non-announce entry is registered.
421
- */
422
- private gateUnconnectableEntries;
423
- /**
424
- * If `walletId` maps to a registry entry with `transport: 'discovery-adapter'`,
425
- * return the bits to build an actionable "register its adapter" error; else
426
- * null (truly-unknown or non-discovery → plain WalletNotFoundError). Reads the
427
- * UNGATED registry (SWR-cached); registry-unavailable → null (safe fallback).
428
- */
429
- private unregisteredDiscoveryInfo;
430
- /**
431
- * Whether announce discovery is active: explicit `discovery.announce`, else
432
- * ON in the browser and OFF under SSR (no `window`). Canonical: provider.md.
433
- */
434
- private get announceEnabled();
435
- /**
436
- * Clear the cached announce round-trip so the next `listWallets()` re-runs the
437
- * `canton:requestProvider` handshake (e.g. after a wallet is installed).
438
- */
439
- refreshDiscovery(): void;
440
- /**
441
- * Persistent-accumulator callback (mounted at construction). On each newly
442
- * announced provider:
443
- * 1. record it in the live `announceRegistry` (unchanged);
444
- * 2. invalidate the one-shot `announceEntriesCache` — the SAME invalidation
445
- * as {@link refreshDiscovery}, so the next `listWallets()` re-aggregates
446
- * and surfaces the wallet. This does NOT touch `warmPlans` (those hold
447
- * only GenericDiscoveryAdapter popup plans — a disjoint set);
448
- * 3. emit a DEBOUNCED `wallets:changed` signal so a reactive consumer (e.g.
449
- * the React provider) re-lists. The debounce coalesces a burst — and the
450
- * construction-time reply storm — into one emit (no re-discovery storm).
451
- *
452
- * Byte-identical idle: with zero announces this never fires — no invalidation,
453
- * no emit, no re-list.
454
- */
455
- private onAnnounceAccumulated;
456
- /**
457
- * Aggregate `canton:announceProvider` wallets into the picker list (A2).
458
- *
459
- * One-shot cached per client (refresh via {@link refreshDiscovery}); SSR-skipped.
460
- * For each discovered provider (announce ∪ `window.canton` scan, deduped):
461
- * - if its id matches a known wallet's `providerDetection` (provider.id) it
462
- * IS that wallet — no new entry (identity bridge: Console's `lpnf…` → the
463
- * `console` entry, Send's `ldmo…` → the `send` entry);
464
- * - otherwise it is surfaced as a dynamic `browser:ext:<id>` entry routed to
465
- * its own extension `target`, with a {@link GenericAnnounceAdapter}
466
- * registered so a click connects through that target ONLY (no shared slot).
467
- * With zero announcers this returns `base` unchanged.
468
- */
469
- private aggregateAnnouncedWallets;
470
- /** Active network-enforcement policy (default 'guard'). */
471
- private get enforcement();
472
- /**
473
- * Detect a confident network mismatch between the dApp's configured network
474
- * and the session's (wallet-reported) network. Returns null when they match
475
- * or the comparison isn't confident (conservative — never a false positive).
476
- */
477
- private networkMismatch;
478
- /**
479
- * Guard a transaction-class operation: throw `NetworkMismatchError` when the
480
- * session is on the wrong network AND the policy enforces it ('guard' |
481
- * 'strict'). Also protects restored sessions and mid-session network switches.
482
- */
483
- private assertNetworkOk;
484
- /**
485
- * Connect to a wallet
486
- */
487
- connect(options?: ConnectOptions): Promise<Session>;
488
- /**
489
- * Pre-resolve everything `adapter.connect()` needs WITHOUT calling it: wallet
490
- * selection, origin-allowlist + capability + install guards, and the adapter
491
- * context. `prefetchedWallets` (passed during warm-up from `listWallets`)
492
- * avoids a recursive `listWallets()` call.
493
- */
494
- private resolveConnectPlan;
495
- /**
496
- * Invoke `adapter.connect()` (its FIRST statement — no await precedes it) and
497
- * build / persist / emit the session. Separated from plan resolution so the
498
- * popup-safe fast-path can call it gesture-synchronously.
499
- */
500
- private completeConnect;
501
- /**
502
- * PUBLIC popup-safe primitive: pre-resolve a connect plan ahead of the user
503
- * gesture; the returned `connect()` invokes `adapter.connect()` as its first
504
- * statement (no await precedes it) so a popup/remote wallet's `window.open`
505
- * survives the gesture. For consumers driving such a wallet outside the modal
506
- * (the modal gets this for free via the `listWallets` warm-up + `connect()`).
507
- */
508
- prepareConnect(options?: ConnectOptions): Promise<{
509
- walletId: WalletId;
510
- connect: (o?: ConnectOptions) => Promise<Session>;
511
- }>;
512
- /**
513
- * Background warm-up of connect plans for popup/remote
514
- * (`GenericDiscoveryAdapter`) wallets. Popup-free — `resolveConnectPlan` only
515
- * runs read/guard probes. Skips already-warm entries; never throws.
516
- */
517
- private warmDiscoveryPlans;
518
- /**
519
- * SYNCHRONOUS fast-path: if a fresh warm plan exists for a popup/remote wallet
520
- * — and `options` carries no plan-affecting guards — consume it and START
521
- * `completeConnect` immediately, reaching `adapter.connect()` with no awaits.
522
- * Returns the in-flight Session promise, or null to fall back to the normal
523
- * path (e.g. cold cache, or a non-discovery wallet).
524
- */
525
- private tryFastConnect;
526
- /**
527
- * Disconnect from wallet
528
- */
529
- disconnect(): Promise<void>;
530
- /**
531
- * Get active session
532
- */
533
- getActiveSession(): Promise<Session | null>;
534
- /**
535
- * Sign a message
536
- */
537
- signMessage(params: SignMessageParams): Promise<SignedMessage>;
538
- /**
539
- * Sign a transaction
540
- */
541
- signTransaction(params: SignTransactionParams): Promise<SignedTransaction>;
542
- /**
543
- * Submit a transaction
544
- */
545
- submitTransaction(params: SubmitTransactionParams): Promise<TxReceipt>;
546
- /**
547
- * Proxy a JSON Ledger API request through the active wallet adapter
548
- */
549
- ledgerApi(params: LedgerApiParams): Promise<LedgerApiResult>;
550
- /**
551
- * Request a typed transfer. The application says what it wants; the wallet
552
- * builds the command, shows the user what they are authorising, obtains their
553
- * approval, signs, executes, and returns the real update id.
554
- *
555
- * The acting party comes from the active session, never from the caller, and
556
- * the intent is narrowed to the allowlisted fields before any adapter sees it,
557
- * so no caller-supplied option can reach the wallet.
558
- *
559
- * Throws `CapabilityNotSupportedError` when the active wallet does not
560
- * implement it. Ask first with `session.capabilitiesSnapshot.includes('transfer')`,
561
- * or require it at connect with `connect({ requiredCapabilities: ['transfer'] })`.
562
- */
563
- requestTransfer(intent: TransferIntent): Promise<TransferResult>;
564
- /**
565
- * Subscribe to events
566
- */
567
- on<T extends PartyLayerEvent>(event: T['type'], handler: EventHandler<T>): () => void;
568
- /**
569
- * Unsubscribe from events
570
- */
571
- off<T extends PartyLayerEvent>(event: T['type'], handler: EventHandler<T>): void;
572
- /**
573
- * Get the stable provider facade for this client.
574
- *
575
- * Browser-native connections expose the official owner's actual accounts,
576
- * network, execution/events and raw Ledger API response, including standard
577
- * path/query/header request fields. Signing keeps the reviewed encoding policy.
578
- * Existing proprietary/custom integrations retain their compatibility bridge.
579
- * `createProviderBridge(client)` remains available explicitly for legacy callers.
580
- * Full async server user-URL orchestration needs a verified direct provider path.
581
- *
582
- * @returns Stable CIP-0103 provider facade
583
- */
584
- asProvider(): _partylayer_core.CIP0103Provider;
585
- /**
586
- * Destroy client and cleanup
587
- */
588
- destroy(): void;
589
- /**
590
- * Create adapter context
591
- */
592
- private createAdapterContext;
593
- /**
594
- * Persist session to storage
595
- */
596
- private persistSession;
597
- /**
598
- * Remove session from storage.
599
- *
600
- * Accepts a sessionId for call-site symmetry, but since the SDK tracks one
601
- * active session we always remove the single SESSION_STORAGE_KEY.
602
- */
603
- private removeSession;
604
- /**
605
- * Restore session from storage
606
- */
607
- private restoreSession;
608
- private restoreSessionOnce;
609
- /**
610
- * Update registry status and emit event
611
- */
612
- private updateRegistryStatus;
613
- /**
614
- * Get registry status
615
- */
616
- getRegistryStatus(): RegistryStatus | null;
617
- /**
618
- * Emit event to handlers
619
- */
620
- /**
621
- * Central structured log. Filters by the configured level here, before the adapter
622
- * is called, so adapters never filter themselves; skips entirely when no real
623
- * logger was configured (the no-op default), so a silent client pays only a check.
624
- * Every line carries a machine readable payload `{ event, correlationId?, ...fields }`.
625
- * Privacy: callers pass only non identifying fields, the same rule as telemetry.
626
- */
627
- private log;
628
- private emit;
629
30
  }
630
- /**
631
- * Create PartyLayer client
632
- *
633
- * This is the main entry point for dApps.
634
- *
635
- * @example
636
- * ```typescript
637
- * const client = createPartyLayer({
638
- * registryUrl: 'https://registry.partylayer.xyz',
639
- * channel: 'stable',
640
- * network: 'devnet',
641
- * app: { name: 'My dApp' }
642
- * });
643
- *
644
- * const session = await client.connect();
645
- * ```
646
- */
31
+ /** Create a browser PartyLayer client with the supported default wallet catalog. */
647
32
  declare function createPartyLayer(config: PartyLayerConfig): PartyLayerClient;
648
33
 
649
- /** The authenticated wallet owns transport and authorization. No participant credentials are accepted. */
650
- interface WalletLedgerClient {
651
- getActiveSession(): Promise<Session | null>;
652
- asProvider(): {
653
- request<T = unknown>(args: {
654
- method: string;
655
- params?: unknown;
656
- }): Promise<T>;
657
- };
658
- }
659
- interface WalletLedgerReaderOptions {
660
- /** Explicit expected CAIP-2 network. Never infer a network from an update id. */
661
- networkId: string;
662
- /** Exact package-id-qualified HoldingV1 interface id from the asset deployment. */
663
- holdingInterfaceId?: string;
664
- /** Exact package-id-qualified HoldingV2 interface id; never inferred from V1. */
665
- holdingV2InterfaceId?: string;
666
- /** Default 30s; applies to the complete read, including session checks. */
667
- timeoutMs?: number;
668
- /** Reject snapshots at this boundary rather than display potentially incomplete balances. Default 1000. */
669
- maxContracts?: number;
670
- }
671
- interface WalletHoldingsSnapshot {
672
- walletId: string;
673
- partyId: string;
674
- networkId: string;
675
- offset: number;
676
- holdings: TokenHoldingRef[];
677
- }
678
- interface WalletHoldingsV2Snapshot extends Omit<WalletHoldingsSnapshot, 'holdings'> {
679
- holdings: TokenHoldingV2Ref[];
680
- }
681
- interface WalletTransactionReference {
682
- walletId: string;
683
- partyId: string;
684
- networkId: string;
685
- /** Original command id generated by the app BEFORE submission, not copied from an untrusted receipt. */
686
- commandId?: string;
687
- receipt?: TxReceipt;
688
- updateId?: string;
689
- }
690
- type WalletTransactionConfirmation = {
691
- status: 'confirmed';
692
- updateId: string;
693
- } | {
694
- status: 'unknown';
695
- reason: string;
696
- };
697
- /**
698
- * Read-only JSON Ledger API v2 adapter using CIP-0103 ledgerApi. Uses eventFormat
699
- * and update-by-id (not the removed transaction-by-id endpoint). A wallet may
700
- * restrict these endpoints; errors remain errors, never empty balances/success.
701
- */
702
- declare function createWalletLedgerReader(client: WalletLedgerClient, options: WalletLedgerReaderOptions): {
703
- /** A bounded, complete ACS snapshot of the connected party's configured HoldingV1 interface. */
704
- readHoldings(signal?: AbortSignal): Promise<WalletHoldingsSnapshot>;
705
- /** Owned V2 accounts only. Provider visibility and ownerless admin accounts do not confer ownership. */
706
- readHoldingsV2(signal?: AbortSignal): Promise<WalletHoldingsV2Snapshot>;
707
- /** One read, never polling or resubmission. Unknown remains unknown if ids cannot be correlated. */
708
- confirmTransaction({ transaction, signal }: {
709
- transaction: WalletTransactionReference;
710
- signal?: AbortSignal;
711
- }): Promise<WalletTransactionConfirmation>;
712
- };
713
- type WalletLedgerReader = ReturnType<typeof createWalletLedgerReader>;
714
-
715
- interface ApplicationLedgerReaderOptions extends WalletLedgerReaderOptions {
716
- /** Same-origin application endpoint implementing the narrow version-1 read contract. */
717
- endpoint: string;
718
- /** Stable app-owned ledger source name; never a caller-selected participant URL. */
719
- sourceId: string;
720
- /** Required outside the browser. In the browser it must equal location.origin. */
721
- origin?: string;
722
- fetch?: typeof globalThis.fetch;
723
- }
724
- /**
725
- * Cookie-authenticated application read preset. The server must derive party and
726
- * network from its own session and rebuild authorized read filters. No wallet
727
- * capability is invented when the app backend, rather than the wallet, reads.
728
- */
729
- declare function createApplicationLedgerReader(client: WalletLedgerClient, options: ApplicationLedgerReaderOptions): {
730
- readHoldings(signal?: AbortSignal): Promise<WalletHoldingsSnapshot>;
731
- readHoldingsV2(signal?: AbortSignal): Promise<WalletHoldingsV2Snapshot>;
732
- confirmTransaction({ transaction, signal }: {
733
- transaction: WalletTransactionReference;
734
- signal?: AbortSignal;
735
- }): Promise<WalletTransactionConfirmation>;
736
- };
737
-
738
34
  /**
739
35
  * Dynamic adapter for an announced CIP-0103 wallet that has no first-party
740
36
  * PartyLayer adapter.
@@ -1168,4 +464,4 @@ declare function isTelemetryConfig(value: unknown): value is TelemetryConfig;
1168
464
  */
1169
465
  declare function createTelemetryAdapter(config: TelemetryAdapter | TelemetryConfig | undefined): TelemetryAdapter | undefined;
1170
466
 
1171
- export { ANNOUNCED_WALLET_ID_PREFIX, type AdapterClass, type ApplicationLedgerReaderOptions, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, type PartyLayerEvent as CantonConnectEvent, type ConnectOptions, DEFAULT_REGISTRY_URL, type ErrorEvent, type EventHandler, GenericAnnounceAdapter, type GenericAnnounceAdapterArgs, GenericDiscoveryAdapter, type GenericDiscoveryAdapterArgs, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, type PartyLayerEvent, type RegistryUpdatedEvent, type SessionConnectedEvent, type SessionDisconnectedEvent, type SessionExpiredEvent, type TelemetryConfig, type TxStatusEvent, type WalletFilter, type WalletHoldingsSnapshot, type WalletHoldingsV2Snapshot, type WalletLedgerClient, type WalletLedgerReader, type WalletLedgerReaderOptions, type WalletTransactionConfirmation, type WalletTransactionReference, type WalletsChangedEvent, PartyLayerClient as _PartyLayerClientInternal, announcedWalletId, completeBronAuthorization, createApplicationLedgerReader, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, createWalletLedgerReader, getBuiltinAdapters, getDiscoveryCapabilities, isTelemetryConfig };
467
+ export { ANNOUNCED_WALLET_ID_PREFIX, PartyLayerClient as CantonConnectClient, type PartyLayerConfig as CantonConnectConfig, GenericAnnounceAdapter, type GenericAnnounceAdapterArgs, GenericDiscoveryAdapter, type GenericDiscoveryAdapterArgs, MetricsTelemetryAdapter, PartyLayerClient, type PartyLayerConfig, TelemetryConfig, PartyLayerClient as _PartyLayerClientInternal, announcedWalletId, completeBronAuthorization, createPartyLayer as createCantonConnect, createPartyLayer, createTelemetryAdapter, getBuiltinAdapters, getDiscoveryCapabilities, isTelemetryConfig };