@partylayer/sdk 0.13.2 → 0.14.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.
package/README.md CHANGED
@@ -117,12 +117,20 @@ await client.disconnect();
117
117
 
118
118
  ## Supported Wallets
119
119
 
120
- | Wallet | ID | Type | Auto-Registered |
121
- |--------|-----|------|-----------------|
122
- | Console Wallet | `console` | Browser Extension | ✅ Yes |
123
- | 5N Loop | `loop` | Mobile / Web | ✅ Yes |
124
- | Cantor8 | `cantor8` | Browser Extension | ✅ Yes |
125
- | Bron | `bron` | Enterprise (OAuth) | ⚙️ Requires config |
120
+ <!-- WALLETS:START (generated by scripts/gen-readme.mjs — do not edit) -->
121
+ | Wallet | Networks | Capabilities | Opt-in | Adapter |
122
+ |--------|----------|--------------|--------|---------|
123
+ | Console Wallet | devnet, testnet, mainnet | signMessage, signTransaction, submitTransaction, transactionStatus | No | `@partylayer/adapter-console` |
124
+ | 5N Loop | devnet, testnet, mainnet | signMessage, submitTransaction, transactionStatus | No | `@partylayer/adapter-loop` |
125
+ | Cantor8 | devnet, testnet, mainnet | signMessage, signTransaction | No | `@partylayer/adapter-cantor8` |
126
+ | Bron | devnet, testnet, mainnet | signMessage, signTransaction | Yes | `@partylayer/adapter-bron` |
127
+ | Nightly | devnet, testnet, mainnet | signMessage, submitTransaction | No | `@partylayer/adapter-nightly` |
128
+ | Send | mainnet | signMessage, submitTransaction, transactionStatus | No | `@partylayer/adapter-send` |
129
+ | Walley | mainnet, testnet, devnet | signMessage, submitTransaction, transactionStatus | No | `@k2flabs/walley-dapp-sdk` |
130
+ | WalletConnect | devnet, testnet, mainnet | signMessage, submitTransaction | Yes | `@partylayer/adapter-walletconnect` |
131
+ <!-- WALLETS:END -->
132
+
133
+ > **Try it live:** [PartyLayer Studio](https://studio.partylayer.xyz) — runnable, editable scenarios · [Pattern Cookbook](https://partylayer.xyz/docs/cookbook) — copy-paste recipes.
126
134
 
127
135
  ---
128
136
 
package/dist/index.d.mts CHANGED
@@ -650,6 +650,15 @@ interface AnnounceAdapterConfig {
650
650
  ledgerApi?: boolean;
651
651
  /** Populate the richer `session.metadata` on connect when the provider returns it. */
652
652
  metadata?: boolean;
653
+ /**
654
+ * Base64-encode the `signMessage` payload. LIVE-VERIFIED: Console's
655
+ * `window.canton` signMessage expects `{ message: <base64 string> }` (base64 of
656
+ * the message's UTF-8 bytes, with NO `metaData`); raw text, `{ hex }`, and
657
+ * `metaData` all crash inside Console. Absent/false keeps the raw string the
658
+ * spec type declares (e.g. Send). Opt-in, like the other flags — no
659
+ * wallet-specific code in the adapter; the registry `adapter.config` drives it.
660
+ */
661
+ signMessageBase64?: boolean;
653
662
  /**
654
663
  * Declarative wallet-specific STATIC metadata (e.g. `{ signingMethod:
655
664
  * 'webauthn-prf' }`) — the wagmi connector-property pattern (like rdns/iconUrl).
@@ -693,6 +702,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
693
702
  private readonly metadataEnabled;
694
703
  private readonly staticMetadata?;
695
704
  private readonly mapError?;
705
+ private readonly signMessageBase64;
696
706
  restore?: WalletAdapter['restore'];
697
707
  on?: WalletAdapter['on'];
698
708
  ledgerApi?: WalletAdapter['ledgerApi'];
@@ -709,7 +719,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
709
719
  detectInstalled(): Promise<AdapterDetectResult>;
710
720
  connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
711
721
  disconnect(): Promise<void>;
712
- signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
722
+ signMessage(_ctx: AdapterContext, session: Session, params: SignMessageParams): Promise<SignedMessage>;
713
723
  submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
714
724
  /** events: bridge the provider's CIP-0103 `txChanged` push event → `txStatus`. */
715
725
  private makeOn;
@@ -854,18 +864,16 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
854
864
  * This function returns instances of all supported wallet adapters.
855
865
  * Called automatically by createPartyLayer() unless custom adapters are provided.
856
866
  *
857
- * Included adapters:
858
- * - ConsoleAdapter: Console Wallet browser extension + mobile (combined mode)
867
+ * Included adapters (returned by this function):
859
868
  * - LoopAdapter: 5N Loop mobile/web wallet
860
869
  * - Cantor8Adapter: Cantor8 wallet with deep link transport
861
870
  * - NightlyAdapter: Nightly multichain wallet with Canton support
862
- * - SendAdapter: Send Canton Wallet (passkey / WebAuthn-PRF, beta) — also
863
- * injects at `window.canton`; the adapter's kernel.id guard keeps it
864
- * and Console-spec wallets from claiming each other's provider.
865
871
  *
866
- * Note: ConsoleAdapter defaults to 'combined' mode which supports both browser
867
- * extension and mobile wallet connect (QR code / deep link). To restrict to
868
- * extension-only, pass { target: 'local' } to the constructor.
872
+ * Served via the generic CIP-0103 announce path (registry transport:'announce'),
873
+ * NOT in this default list — their adapters stay exported below for opt-in use:
874
+ * - ConsoleAdapter: Console Wallet (browser extension + mobile). Defaults to
875
+ * 'combined' mode; pass { target: 'local' } to restrict to extension-only.
876
+ * - SendAdapter: Send Canton Wallet (passkey / WebAuthn-PRF).
869
877
  *
870
878
  * Note: BronAdapter is NOT included by default because it requires OAuth configuration.
871
879
  * To use Bron, install @partylayer/adapter-bron and register it manually.
package/dist/index.d.ts CHANGED
@@ -650,6 +650,15 @@ interface AnnounceAdapterConfig {
650
650
  ledgerApi?: boolean;
651
651
  /** Populate the richer `session.metadata` on connect when the provider returns it. */
652
652
  metadata?: boolean;
653
+ /**
654
+ * Base64-encode the `signMessage` payload. LIVE-VERIFIED: Console's
655
+ * `window.canton` signMessage expects `{ message: <base64 string> }` (base64 of
656
+ * the message's UTF-8 bytes, with NO `metaData`); raw text, `{ hex }`, and
657
+ * `metaData` all crash inside Console. Absent/false keeps the raw string the
658
+ * spec type declares (e.g. Send). Opt-in, like the other flags — no
659
+ * wallet-specific code in the adapter; the registry `adapter.config` drives it.
660
+ */
661
+ signMessageBase64?: boolean;
653
662
  /**
654
663
  * Declarative wallet-specific STATIC metadata (e.g. `{ signingMethod:
655
664
  * 'webauthn-prf' }`) — the wagmi connector-property pattern (like rdns/iconUrl).
@@ -693,6 +702,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
693
702
  private readonly metadataEnabled;
694
703
  private readonly staticMetadata?;
695
704
  private readonly mapError?;
705
+ private readonly signMessageBase64;
696
706
  restore?: WalletAdapter['restore'];
697
707
  on?: WalletAdapter['on'];
698
708
  ledgerApi?: WalletAdapter['ledgerApi'];
@@ -709,7 +719,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
709
719
  detectInstalled(): Promise<AdapterDetectResult>;
710
720
  connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
711
721
  disconnect(): Promise<void>;
712
- signMessage(_ctx: AdapterContext, _session: Session, params: SignMessageParams): Promise<SignedMessage>;
722
+ signMessage(_ctx: AdapterContext, session: Session, params: SignMessageParams): Promise<SignedMessage>;
713
723
  submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
714
724
  /** events: bridge the provider's CIP-0103 `txChanged` push event → `txStatus`. */
715
725
  private makeOn;
@@ -854,18 +864,16 @@ declare class GenericDiscoveryAdapter implements WalletAdapter {
854
864
  * This function returns instances of all supported wallet adapters.
855
865
  * Called automatically by createPartyLayer() unless custom adapters are provided.
856
866
  *
857
- * Included adapters:
858
- * - ConsoleAdapter: Console Wallet browser extension + mobile (combined mode)
867
+ * Included adapters (returned by this function):
859
868
  * - LoopAdapter: 5N Loop mobile/web wallet
860
869
  * - Cantor8Adapter: Cantor8 wallet with deep link transport
861
870
  * - NightlyAdapter: Nightly multichain wallet with Canton support
862
- * - SendAdapter: Send Canton Wallet (passkey / WebAuthn-PRF, beta) — also
863
- * injects at `window.canton`; the adapter's kernel.id guard keeps it
864
- * and Console-spec wallets from claiming each other's provider.
865
871
  *
866
- * Note: ConsoleAdapter defaults to 'combined' mode which supports both browser
867
- * extension and mobile wallet connect (QR code / deep link). To restrict to
868
- * extension-only, pass { target: 'local' } to the constructor.
872
+ * Served via the generic CIP-0103 announce path (registry transport:'announce'),
873
+ * NOT in this default list — their adapters stay exported below for opt-in use:
874
+ * - ConsoleAdapter: Console Wallet (browser extension + mobile). Defaults to
875
+ * 'combined' mode; pass { target: 'local' } to restrict to extension-only.
876
+ * - SendAdapter: Send Canton Wallet (passkey / WebAuthn-PRF).
869
877
  *
870
878
  * Note: BronAdapter is NOT included by default because it requires OAuth configuration.
871
879
  * To use Bron, install @partylayer/adapter-bron and register it manually.
package/dist/index.js CHANGED
@@ -28,6 +28,12 @@ function mapTxStatus(status) {
28
28
  return "failed";
29
29
  }
30
30
  }
31
+ function toBase64Message(message) {
32
+ const bytes = new TextEncoder().encode(message);
33
+ let binary = "";
34
+ for (const b of bytes) binary += String.fromCharCode(b);
35
+ return btoa(binary);
36
+ }
31
37
  var GenericAnnounceAdapter = class {
32
38
  walletId;
33
39
  name;
@@ -37,6 +43,7 @@ var GenericAnnounceAdapter = class {
37
43
  metadataEnabled;
38
44
  staticMetadata;
39
45
  mapError;
46
+ signMessageBase64;
40
47
  // Optional WalletAdapter surface — assigned in the ctor ONLY when configured,
41
48
  // so `getCapabilities()` and `'x' in adapter` feature-detection stay honest.
42
49
  restore;
@@ -51,6 +58,7 @@ var GenericAnnounceAdapter = class {
51
58
  this.metadataEnabled = config?.metadata === true;
52
59
  this.staticMetadata = config?.staticMetadata;
53
60
  this.mapError = config?.mapError;
61
+ this.signMessageBase64 = config?.signMessageBase64 === true;
54
62
  if (config?.events) this.on = this.makeOn();
55
63
  if (config?.restore) this.restore = this.makeRestore();
56
64
  if (config?.ledgerApi) this.ledgerApi = this.makeLedgerApi();
@@ -86,10 +94,13 @@ var GenericAnnounceAdapter = class {
86
94
  }
87
95
  const reportedNetwork = status?.network?.networkId;
88
96
  const partyId = core.toPartyId(account.partyId);
97
+ const network = [reportedNetwork, account.networkId, ctx.network].find(
98
+ (n) => typeof n === "string" && core.isRecognizedNetwork(n)
99
+ ) ?? ctx.network;
89
100
  const session = {
90
101
  walletId: this.walletId,
91
102
  partyId,
92
- network: reportedNetwork ?? account.networkId ?? ctx.network
103
+ network
93
104
  };
94
105
  if (this.metadataEnabled) {
95
106
  session.metadata = { ...this.staticMetadata ?? {}, ...buildMetadata(status, account) };
@@ -103,13 +114,19 @@ var GenericAnnounceAdapter = class {
103
114
  } catch {
104
115
  }
105
116
  }
106
- async signMessage(_ctx, _session, params) {
107
- return this.guarded(
108
- () => this.provider.request({
109
- method: "signMessage",
110
- params: { message: params.message }
111
- })
112
- );
117
+ async signMessage(_ctx, session, params) {
118
+ return this.guarded(async () => {
119
+ const rpcParams = this.signMessageBase64 ? { message: toBase64Message(params.message) } : { message: params.message };
120
+ const res = await this.provider.request({ method: "signMessage", params: rpcParams });
121
+ const sig = typeof res === "string" ? res : res?.signature ?? "";
122
+ return {
123
+ signature: core.toSignature(String(sig)),
124
+ partyId: session.partyId,
125
+ message: params.message,
126
+ nonce: params.nonce,
127
+ domain: params.domain
128
+ };
129
+ });
113
130
  }
114
131
  async submitTransaction(_ctx, _session, params) {
115
132
  return this.guarded(
@@ -172,9 +189,9 @@ var GenericAnnounceAdapter = class {
172
189
  const result = await this.provider.request({
173
190
  method: "ledgerApi",
174
191
  params: {
175
- requestMethod: params.requestMethod,
192
+ requestMethod: core.normalizeLedgerMethodLower(params.requestMethod),
176
193
  resource: params.resource,
177
- body: params.body
194
+ body: core.ledgerApiBodyToObject(params.body)
178
195
  }
179
196
  });
180
197
  if (result && typeof result.response === "string") return { response: result.response };
@@ -516,14 +533,15 @@ var DefaultTelemetry = class {
516
533
  };
517
534
  function getBuiltinAdapters() {
518
535
  return [
519
- new adapterConsole.ConsoleAdapter(),
520
- // Console Wallet - extension + mobile (combined)
521
536
  new adapterLoop.LoopAdapter(),
522
537
  // 5N Loop - QR code / popup
523
538
  new adapterCantor8.Cantor8Adapter(),
524
539
  // Cantor8 - deep link transport
525
540
  new adapterNightly.NightlyAdapter()
526
541
  // Nightly - multichain wallet (injected)
542
+ // Console is served via the generic CIP-0103 announce path (registry
543
+ // transport:'announce') — no longer in defaults; ConsoleAdapter stays
544
+ // exported below for opt-in manual/bespoke use.
527
545
  // Send is served via the generic CIP-0103 announce path (registry
528
546
  // transport:'announce') — no longer in defaults; SendAdapter stays exported
529
547
  // below for opt-in manual/bespoke use.
@@ -721,7 +739,8 @@ function deriveAnnounceConfig(entry) {
721
739
  events: entry.capabilities?.events === true,
722
740
  restore: cfg.restore === true,
723
741
  ledgerApi: cfg.ledgerApi === true,
724
- metadata: cfg.metadata === true
742
+ metadata: cfg.metadata === true,
743
+ signMessageBase64: cfg.signMessageBase64 === true
725
744
  };
726
745
  const sm = cfg.staticMetadata;
727
746
  if (sm && typeof sm === "object") {