@partylayer/sdk 0.13.3 → 0.14.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/README.md +1 -1
- package/dist/index.d.mts +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.js +30 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { toWalletId, toPartyId, ledgerApiBodyToObject, normalizeLedgerMethodLower,
|
|
1
|
+
import { toWalletId, toPartyId, isRecognizedNetwork, toSignature, ledgerApiBodyToObject, normalizeLedgerMethodLower, hashForPrivacy, createMetricsPayload, isOfficialAdapterFactory, isOfficialProviderAdapter, mapUnknownErrorToPartyLayerError, findMatchingWalletInfo, detectNetworkMismatch, NetworkMismatchError, METRICS, AdapterNotRegisteredError, WalletNotFoundError, capabilityGuard, installGuard, toSessionId, CapabilityNotSupportedError, errorMetricName } from '@partylayer/core';
|
|
2
2
|
export { AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, InternalError, METRICS, OriginNotAllowedError, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, SessionExpiredError, TimeoutError, TransportError, UserRejectedError, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
|
|
3
3
|
import { RegistryClient } from '@partylayer/registry-client';
|
|
4
4
|
export { deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
|
|
5
5
|
import { subscribeAnnouncedProviders, createExtensionChannelProvider, discoverProviders, createProviderBridge } from '@partylayer/provider';
|
|
6
6
|
export { CANTON_NETWORKS, CIP0103EventBus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, JSON_RPC_ERRORS, PartyLayerProvider, ProviderRpcError, RPC_ERRORS, createProviderBridge, discoverInjectedProviders, fromCAIP2Network, isCIP0103Provider, isValidCAIP2, toCAIP2Network, waitForProvider } from '@partylayer/provider';
|
|
7
|
-
import { ConsoleAdapter } from '@partylayer/adapter-console';
|
|
8
7
|
export { ConsoleAdapter } from '@partylayer/adapter-console';
|
|
9
8
|
import { LoopAdapter } from '@partylayer/adapter-loop';
|
|
10
9
|
export { LoopAdapter } from '@partylayer/adapter-loop';
|
|
@@ -33,6 +32,12 @@ function mapTxStatus(status) {
|
|
|
33
32
|
return "failed";
|
|
34
33
|
}
|
|
35
34
|
}
|
|
35
|
+
function toBase64Message(message) {
|
|
36
|
+
const bytes = new TextEncoder().encode(message);
|
|
37
|
+
let binary = "";
|
|
38
|
+
for (const b of bytes) binary += String.fromCharCode(b);
|
|
39
|
+
return btoa(binary);
|
|
40
|
+
}
|
|
36
41
|
var GenericAnnounceAdapter = class {
|
|
37
42
|
walletId;
|
|
38
43
|
name;
|
|
@@ -42,6 +47,7 @@ var GenericAnnounceAdapter = class {
|
|
|
42
47
|
metadataEnabled;
|
|
43
48
|
staticMetadata;
|
|
44
49
|
mapError;
|
|
50
|
+
signMessageBase64;
|
|
45
51
|
// Optional WalletAdapter surface — assigned in the ctor ONLY when configured,
|
|
46
52
|
// so `getCapabilities()` and `'x' in adapter` feature-detection stay honest.
|
|
47
53
|
restore;
|
|
@@ -56,6 +62,7 @@ var GenericAnnounceAdapter = class {
|
|
|
56
62
|
this.metadataEnabled = config?.metadata === true;
|
|
57
63
|
this.staticMetadata = config?.staticMetadata;
|
|
58
64
|
this.mapError = config?.mapError;
|
|
65
|
+
this.signMessageBase64 = config?.signMessageBase64 === true;
|
|
59
66
|
if (config?.events) this.on = this.makeOn();
|
|
60
67
|
if (config?.restore) this.restore = this.makeRestore();
|
|
61
68
|
if (config?.ledgerApi) this.ledgerApi = this.makeLedgerApi();
|
|
@@ -91,10 +98,13 @@ var GenericAnnounceAdapter = class {
|
|
|
91
98
|
}
|
|
92
99
|
const reportedNetwork = status?.network?.networkId;
|
|
93
100
|
const partyId = toPartyId(account.partyId);
|
|
101
|
+
const network = [reportedNetwork, account.networkId, ctx.network].find(
|
|
102
|
+
(n) => typeof n === "string" && isRecognizedNetwork(n)
|
|
103
|
+
) ?? ctx.network;
|
|
94
104
|
const session = {
|
|
95
105
|
walletId: this.walletId,
|
|
96
106
|
partyId,
|
|
97
|
-
network
|
|
107
|
+
network
|
|
98
108
|
};
|
|
99
109
|
if (this.metadataEnabled) {
|
|
100
110
|
session.metadata = { ...this.staticMetadata ?? {}, ...buildMetadata(status, account) };
|
|
@@ -108,13 +118,19 @@ var GenericAnnounceAdapter = class {
|
|
|
108
118
|
} catch {
|
|
109
119
|
}
|
|
110
120
|
}
|
|
111
|
-
async signMessage(_ctx,
|
|
112
|
-
return this.guarded(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
async signMessage(_ctx, session, params) {
|
|
122
|
+
return this.guarded(async () => {
|
|
123
|
+
const rpcParams = this.signMessageBase64 ? { message: toBase64Message(params.message) } : { message: params.message };
|
|
124
|
+
const res = await this.provider.request({ method: "signMessage", params: rpcParams });
|
|
125
|
+
const sig = typeof res === "string" ? res : res?.signature ?? "";
|
|
126
|
+
return {
|
|
127
|
+
signature: toSignature(String(sig)),
|
|
128
|
+
partyId: session.partyId,
|
|
129
|
+
message: params.message,
|
|
130
|
+
nonce: params.nonce,
|
|
131
|
+
domain: params.domain
|
|
132
|
+
};
|
|
133
|
+
});
|
|
118
134
|
}
|
|
119
135
|
async submitTransaction(_ctx, _session, params) {
|
|
120
136
|
return this.guarded(
|
|
@@ -521,14 +537,15 @@ var DefaultTelemetry = class {
|
|
|
521
537
|
};
|
|
522
538
|
function getBuiltinAdapters() {
|
|
523
539
|
return [
|
|
524
|
-
new ConsoleAdapter(),
|
|
525
|
-
// Console Wallet - extension + mobile (combined)
|
|
526
540
|
new LoopAdapter(),
|
|
527
541
|
// 5N Loop - QR code / popup
|
|
528
542
|
new Cantor8Adapter(),
|
|
529
543
|
// Cantor8 - deep link transport
|
|
530
544
|
new NightlyAdapter()
|
|
531
545
|
// Nightly - multichain wallet (injected)
|
|
546
|
+
// Console is served via the generic CIP-0103 announce path (registry
|
|
547
|
+
// transport:'announce') — no longer in defaults; ConsoleAdapter stays
|
|
548
|
+
// exported below for opt-in manual/bespoke use.
|
|
532
549
|
// Send is served via the generic CIP-0103 announce path (registry
|
|
533
550
|
// transport:'announce') — no longer in defaults; SendAdapter stays exported
|
|
534
551
|
// below for opt-in manual/bespoke use.
|
|
@@ -726,7 +743,8 @@ function deriveAnnounceConfig(entry) {
|
|
|
726
743
|
events: entry.capabilities?.events === true,
|
|
727
744
|
restore: cfg.restore === true,
|
|
728
745
|
ledgerApi: cfg.ledgerApi === true,
|
|
729
|
-
metadata: cfg.metadata === true
|
|
746
|
+
metadata: cfg.metadata === true,
|
|
747
|
+
signMessageBase64: cfg.signMessageBase64 === true
|
|
730
748
|
};
|
|
731
749
|
const sm = cfg.staticMetadata;
|
|
732
750
|
if (sm && typeof sm === "object") {
|