@tezos-x/octez.connect-core 5.0.1 → 5.0.3
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/cjs/package.json +3 -3
- package/dist/cjs/src/clients/client/Client.js +1 -1
- package/dist/cjs/src/clients/client/Client.js.map +1 -1
- package/dist/cjs/src/constants.d.ts +9 -0
- package/dist/cjs/src/constants.js +11 -2
- package/dist/cjs/src/constants.js.map +1 -1
- package/dist/cjs/src/index.d.ts +3 -3
- package/dist/cjs/src/index.js +4 -2
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/utils/message-utils.d.ts +33 -0
- package/dist/cjs/src/utils/message-utils.js +42 -1
- package/dist/cjs/src/utils/message-utils.js.map +1 -1
- package/dist/esm/package.json +3 -3
- package/dist/esm/src/clients/client/Client.js +2 -2
- package/dist/esm/src/clients/client/Client.js.map +1 -1
- package/dist/esm/src/constants.d.ts +9 -0
- package/dist/esm/src/constants.js +10 -1
- package/dist/esm/src/constants.js.map +1 -1
- package/dist/esm/src/index.d.ts +3 -3
- package/dist/esm/src/index.js +3 -3
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/utils/message-utils.d.ts +33 -0
- package/dist/esm/src/utils/message-utils.js +40 -0
- package/dist/esm/src/utils/message-utils.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -20,4 +20,4 @@ This package is published from the Trilitech-maintained octez.connect repository
|
|
|
20
20
|
## Notes
|
|
21
21
|
|
|
22
22
|
- Trilitech publishes these packages under the `@tezos-x/octez.connect-*` scope
|
|
23
|
-
- Release notes
|
|
23
|
+
- Release notes live on the [GitHub Releases page](https://github.com/trilitech/octez.connect/releases); package policy lives in [CONTRIBUTING.md](https://github.com/trilitech/octez.connect/blob/master/CONTRIBUTING.md) and [MAINTAINERS.md](https://github.com/trilitech/octez.connect/blob/master/MAINTAINERS.md)
|
package/dist/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tezos-x/octez.connect-core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "This package contains internal methods that are used by both the dApp and wallet client.",
|
|
5
5
|
"author": "Blockchain Infra <blockchain.infra@trili.tech>",
|
|
6
6
|
"homepage": "https://octez-connect.tezos.com",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@stablelib/nacl": "^2.0.1",
|
|
39
39
|
"@stablelib/utf8": "^2.1.0",
|
|
40
40
|
"@stablelib/x25519-session": "^2.0.1",
|
|
41
|
-
"@tezos-x/octez.connect-types": "5.0.
|
|
42
|
-
"@tezos-x/octez.connect-utils": "5.0.
|
|
41
|
+
"@tezos-x/octez.connect-types": "5.0.3",
|
|
42
|
+
"@tezos-x/octez.connect-utils": "5.0.3",
|
|
43
43
|
"broadcast-channel": "^7.3.0",
|
|
44
44
|
"bs58check": "4.0.0"
|
|
45
45
|
}
|
|
@@ -260,7 +260,7 @@ class Client extends BeaconClient_1.BeaconClient {
|
|
|
260
260
|
// The disconnect ships in the peer's negotiated dialect: wrapped for
|
|
261
261
|
// v3+ peers, the flat legacy shape for v2 peers (which would silently
|
|
262
262
|
// ignore a wrapped envelope).
|
|
263
|
-
const request = (0, message_utils_1.buildDisconnectMessage)({ id, senderId },
|
|
263
|
+
const request = (0, message_utils_1.buildDisconnectMessage)({ id, senderId }, (0, message_utils_1.effectivePeerVersion)(peer));
|
|
264
264
|
const protocolVersion = this.getPeerProtocolVersion(peer);
|
|
265
265
|
const payload = yield new Serializer_1.Serializer(protocolVersion).serialize(request);
|
|
266
266
|
const selectedTransport = transport !== null && transport !== void 0 ? transport : (yield this.transport);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../../../src/clients/client/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sEAA2E;AAC3E,sEAYqC;AACrC,+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AAC,oCAAwB,CAAA;IAC9B,CAAC;IAEO,0BAA0B,CAAC,IAAe;QAChD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,oCAAwB,CAAA;QACjC,CAAC;QAED,MAAM,eAAe,GACnB,OAAO,IAAI,CAAC,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QAEhG,OAAO,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,eAAe,IAAI,oCAAwB;YACpF,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,oCAAwB,CAAA;IAC9B,CAAC;IAES,sBAAsB,CAAC,IAAe;QAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAA;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAA;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IAC5C,CAAC;CACF;AA7SD,wBA6SC","sourcesContent":["import { ExposedPromise, generateGUID } from '@tezos-x/octez.connect-utils'\nimport {\n ConnectionContext,\n TransportType,\n TransportStatus,\n BeaconBaseMessage,\n AccountInfo,\n PeerInfo,\n AppMetadata,\n BeaconRequestMessage,\n BeaconMessageWrapper,\n NodeDistributions,\n Blockchain\n} from '@tezos-x/octez.connect-types'\nimport { DEFAULT_PROTOCOL_VERSION } from '../../constants'\nimport { BeaconClient } from '../beacon-client/BeaconClient'\nimport { AccountManager } from '../../managers/AccountManager'\nimport { getSenderId } from '../../utils/get-sender-id'\nimport { Logger } from '../../utils/Logger'\nimport { ClientOptions } from './ClientOptions'\nimport { Transport } from '../../transports/Transport'\nimport { Serializer } from '../../Serializer'\nimport { buildDisconnectMessage } from '../../utils/message-utils'\nimport { getPreferredMessageProtocolVersion } from '../../message-protocol'\n\nconst logger = new Logger('Client')\n\n/**\n * @internalapi\n *\n * This abstract class handles the a big part of the logic that is shared between the dapp and wallet client.\n * For example, it selects and manages the transport and accounts.\n */\nexport abstract class Client extends BeaconClient {\n protected readonly accountManager: AccountManager\n protected readonly blockchains: Map<string, Blockchain> = new Map()\n\n protected handleResponse: (\n _event: BeaconRequestMessage | BeaconMessageWrapper<BeaconBaseMessage>,\n connectionInfo: ConnectionContext\n ) => void\n\n /**\n * How many requests can be sent after another\n */\n protected readonly rateLimit: number = 2\n /**\n * The time window in seconds in which the \"rateLimit\" is checked\n */\n protected readonly rateLimitWindowInSeconds: number = 5\n\n /**\n * Stores the times when requests have been made to determine if the rate limit has been reached\n */\n protected requestCounter: number[] = []\n\n protected readonly matrixNodes: NodeDistributions\n\n private transportListeners: Map<\n TransportType,\n (message: any, connectionInfo: ConnectionContext) => Promise<void>\n > = new Map()\n\n protected _transport: ExposedPromise<Transport<any>> = new ExposedPromise()\n protected get transport(): Promise<Transport<any>> {\n return this._transport.promise\n }\n\n /**\n * Returns the connection status of the Client\n */\n public get connectionStatus(): TransportStatus {\n return this._transport.promiseResult?.connectionStatus ?? TransportStatus.NOT_CONNECTED\n }\n\n /**\n * Returns whether or not the transaport is ready\n */\n public get ready(): Promise<void> {\n return this.transport.then(() => undefined)\n }\n\n constructor(config: ClientOptions) {\n super(config)\n\n this.accountManager = new AccountManager(config.storage)\n this.matrixNodes = config.matrixNodes ?? {}\n\n this.handleResponse = (\n message: BeaconBaseMessage | BeaconMessageWrapper<BeaconBaseMessage>,\n connectionInfo: ConnectionContext\n ): void => {\n throw new Error(\n `not overwritten${JSON.stringify(message)} - ${JSON.stringify(connectionInfo)}`\n )\n }\n }\n protected async cleanup() {\n if (!this.transportListeners.size) {\n return\n }\n\n if (this._transport.isResolved()) {\n const transport = await this.transport\n await Promise.all(\n Array.from(this.transportListeners.values()).map((listener) =>\n transport.removeListener(listener)\n )\n )\n this.transportListeners.clear()\n }\n }\n\n /**\n * Register a blockchain to the client\n * @param chain The blockchain to register\n */\n public addBlockchain(chain: Blockchain) {\n this.blockchains.set(chain.identifier, chain)\n for (const legacyIdentifier of chain.legacyIdentifiers ?? []) {\n this.blockchains.set(legacyIdentifier, chain)\n }\n }\n\n /**\n * Remove a blockchain from the client by its identifier\n * @param chainIdentifier The identifier of the blockchain to remove\n */\n public removeBlockchain(chainIdentifier: string) {\n const chain = this.blockchains.get(chainIdentifier)\n this.blockchains.delete(chainIdentifier)\n for (const legacyIdentifier of chain?.legacyIdentifiers ?? []) {\n this.blockchains.delete(legacyIdentifier)\n }\n }\n\n /**\n * Return all locally known accounts\n */\n public async getAccounts(): Promise<AccountInfo[]> {\n return this.accountManager.getAccounts()\n }\n\n /**\n * Return the account by ID\n * @param accountIdentifier The ID of an account\n */\n public async getAccount(accountIdentifier: string): Promise<AccountInfo | undefined> {\n return this.accountManager.getAccount(accountIdentifier)\n }\n\n /**\n * Remove the account by ID\n * @param accountIdentifier The ID of an account\n */\n public async removeAccount(accountIdentifier: string): Promise<void> {\n return this.accountManager.removeAccount(accountIdentifier)\n }\n\n /**\n * Remove all locally stored accounts\n */\n public async removeAllAccounts(): Promise<void> {\n return this.accountManager.removeAllAccounts()\n }\n\n /**\n * Add a new request (current timestamp) to the pending requests, remove old ones and check if we are above the limit\n */\n public async addRequestAndCheckIfRateLimited(): Promise<boolean> {\n const now: number = new Date().getTime()\n this.requestCounter = this.requestCounter.filter(\n (date) => date + this.rateLimitWindowInSeconds * 1000 > now\n )\n\n this.requestCounter.push(now)\n\n return this.requestCounter.length > this.rateLimit\n }\n\n /**\n * This method initializes the client. It will check if the connection should be established to a\n * browser extension or if the P2P transport should be used.\n *\n * @param transport A transport that can be provided by the user\n */\n public async init(transport: Transport<any, any, any>): Promise<TransportType> {\n if (this._transport.isResolved()) {\n return (await this.transport).type\n }\n\n await this.setTransport(transport) // Let users define their own transport\n\n return transport.type\n }\n\n /**\n * Returns the metadata of this DApp\n */\n public async getOwnAppMetadata(): Promise<AppMetadata> {\n return {\n senderId: await getSenderId(await this.beaconId),\n name: this.name,\n icon: this.iconUrl\n }\n }\n\n /**\n * Return all known peers\n */\n public async getPeers(): Promise<PeerInfo[]> {\n return (await this.transport).getPeers()\n }\n\n /**\n * Add a new peer to the known peers\n * @param peer The new peer to add\n */\n public async addPeer(peer: PeerInfo): Promise<void> {\n return (await this.transport).addPeer(peer)\n }\n\n public async destroy(): Promise<void> {\n if (this._transport.isResolved()) {\n const transport = await this.transport\n await this.cleanup()\n await transport.disconnect()\n if (transport.type === TransportType.WALLETCONNECT) {\n await (transport as any).doClientCleanup() // any because I cannot import the type definition\n }\n }\n await super.destroy()\n }\n\n /**\n * A \"setter\" for when the transport needs to be changed.\n */\n protected async setTransport(transport?: Transport<any>): Promise<void> {\n if (transport) {\n if (this._transport.isSettled()) {\n // If the promise has already been resolved we need to create a new one.\n this._transport = ExposedPromise.resolve(transport)\n } else {\n this._transport.resolve(transport)\n }\n } else {\n if (this._transport.isSettled()) {\n // If the promise has already been resolved we need to create a new one.\n this._transport = new ExposedPromise()\n }\n }\n }\n\n protected async addListener(transport: Transport<any>): Promise<void> {\n // in beacon we subscribe to the transport on client init only\n // unsubscribing from the transport is only beneficial when running\n // a single page dApp.\n // However, while running a multiple tabs setup, if one of the dApps disconnects\n // the others wont't recover until after a page refresh\n\n if (this.transportListeners.has(transport.type)) {\n await transport.removeListener(this.transportListeners.get(transport.type)!)\n }\n\n const subscription = async (message: any, connectionInfo: ConnectionContext) => {\n if (typeof message !== 'string') {\n return\n }\n\n const peer = await this.findPeer(connectionInfo.id)\n const protocolVersion = this.getPeerProtocolVersion(peer)\n\n const deserializedMessage = (await new Serializer(protocolVersion).deserialize(\n message\n )) as BeaconRequestMessage\n this.handleResponse(deserializedMessage, connectionInfo)\n }\n\n this.transportListeners.set(transport.type, subscription)\n\n transport.addListener(subscription).catch((error) => logger.error('addListener', error))\n }\n\n protected async sendDisconnectToPeer(peer: PeerInfo, transport?: Transport<any>): Promise<void> {\n const id = await generateGUID()\n const senderId = await getSenderId(await this.beaconId)\n\n // The disconnect ships in the peer's negotiated dialect: wrapped for\n // v3+ peers, the flat legacy shape for v2 peers (which would silently\n // ignore a wrapped envelope).\n const request = buildDisconnectMessage({ id, senderId }, peer.version)\n\n const protocolVersion = this.getPeerProtocolVersion(peer)\n const payload = await new Serializer(protocolVersion).serialize(request)\n const selectedTransport = transport ?? (await this.transport)\n\n await selectedTransport.send(payload, peer)\n }\n\n protected async findPeer(publicKey?: string): Promise<PeerInfo | undefined> {\n if (!publicKey) {\n return undefined\n }\n\n const transport = await this.transport\n const peers = await transport.getPeers()\n return peers.find((peerInfo) => peerInfo.publicKey === publicKey)\n }\n\n private getLocalProtocolVersion(): number {\n const localPreferredRaw = Number(getPreferredMessageProtocolVersion())\n return Number.isFinite(localPreferredRaw) && localPreferredRaw >= DEFAULT_PROTOCOL_VERSION\n ? localPreferredRaw\n : DEFAULT_PROTOCOL_VERSION\n }\n\n private extractPeerProtocolVersion(peer?: PeerInfo): number {\n if (!peer) {\n return DEFAULT_PROTOCOL_VERSION\n }\n\n const peerProtocolRaw =\n typeof peer.protocolVersion === 'number' ? peer.protocolVersion : Number(peer.protocolVersion)\n\n return Number.isFinite(peerProtocolRaw) && peerProtocolRaw >= DEFAULT_PROTOCOL_VERSION\n ? peerProtocolRaw\n : DEFAULT_PROTOCOL_VERSION\n }\n\n protected getPeerProtocolVersion(peer?: PeerInfo): number {\n const localVersion = this.getLocalProtocolVersion()\n const peerVersion = this.extractPeerProtocolVersion(peer)\n return Math.min(peerVersion, localVersion)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../../../src/clients/client/Client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sEAA2E;AAC3E,sEAYqC;AACrC,+CAA0D;AAC1D,gEAA4D;AAC5D,kEAA8D;AAC9D,6DAAuD;AACvD,+CAA2C;AAG3C,iDAA6C;AAC7C,6DAAwF;AACxF,6DAA2E;AAE3E,MAAM,MAAM,GAAG,IAAI,eAAM,CA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AM,eAAe,GACnB,OAAO,IAAI,CAAC,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QAEhG,OAAO,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,eAAe,IAAI,oCAAwB;YACpF,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,oCAAwB,CAAA;IAC9B,CAAC;IAES,sBAAsB,CAAC,IAAe;QAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAA;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAA;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IAC5C,CAAC;CACF;AA7SD,wBA6SC","sourcesContent":["import { ExposedPromise, generateGUID } from '@tezos-x/octez.connect-utils'\nimport {\n ConnectionContext,\n TransportType,\n TransportStatus,\n BeaconBaseMessage,\n AccountInfo,\n PeerInfo,\n AppMetadata,\n BeaconRequestMessage,\n BeaconMessageWrapper,\n NodeDistributions,\n Blockchain\n} from '@tezos-x/octez.connect-types'\nimport { DEFAULT_PROTOCOL_VERSION } from '../../constants'\nimport { BeaconClient } from '../beacon-client/BeaconClient'\nimport { AccountManager } from '../../managers/AccountManager'\nimport { getSenderId } from '../../utils/get-sender-id'\nimport { Logger } from '../../utils/Logger'\nimport { ClientOptions } from './ClientOptions'\nimport { Transport } from '../../transports/Transport'\nimport { Serializer } from '../../Serializer'\nimport { buildDisconnectMessage, effectivePeerVersion } from '../../utils/message-utils'\nimport { getPreferredMessageProtocolVersion } from '../../message-protocol'\n\nconst logger = new Logger('Client')\n\n/**\n * @internalapi\n *\n * This abstract class handles the a big part of the logic that is shared between the dapp and wallet client.\n * For example, it selects and manages the transport and accounts.\n */\nexport abstract class Client extends BeaconClient {\n protected readonly accountManager: AccountManager\n protected readonly blockchains: Map<string, Blockchain> = new Map()\n\n protected handleResponse: (\n _event: BeaconRequestMessage | BeaconMessageWrapper<BeaconBaseMessage>,\n connectionInfo: ConnectionContext\n ) => void\n\n /**\n * How many requests can be sent after another\n */\n protected readonly rateLimit: number = 2\n /**\n * The time window in seconds in which the \"rateLimit\" is checked\n */\n protected readonly rateLimitWindowInSeconds: number = 5\n\n /**\n * Stores the times when requests have been made to determine if the rate limit has been reached\n */\n protected requestCounter: number[] = []\n\n protected readonly matrixNodes: NodeDistributions\n\n private transportListeners: Map<\n TransportType,\n (message: any, connectionInfo: ConnectionContext) => Promise<void>\n > = new Map()\n\n protected _transport: ExposedPromise<Transport<any>> = new ExposedPromise()\n protected get transport(): Promise<Transport<any>> {\n return this._transport.promise\n }\n\n /**\n * Returns the connection status of the Client\n */\n public get connectionStatus(): TransportStatus {\n return this._transport.promiseResult?.connectionStatus ?? TransportStatus.NOT_CONNECTED\n }\n\n /**\n * Returns whether or not the transaport is ready\n */\n public get ready(): Promise<void> {\n return this.transport.then(() => undefined)\n }\n\n constructor(config: ClientOptions) {\n super(config)\n\n this.accountManager = new AccountManager(config.storage)\n this.matrixNodes = config.matrixNodes ?? {}\n\n this.handleResponse = (\n message: BeaconBaseMessage | BeaconMessageWrapper<BeaconBaseMessage>,\n connectionInfo: ConnectionContext\n ): void => {\n throw new Error(\n `not overwritten${JSON.stringify(message)} - ${JSON.stringify(connectionInfo)}`\n )\n }\n }\n protected async cleanup() {\n if (!this.transportListeners.size) {\n return\n }\n\n if (this._transport.isResolved()) {\n const transport = await this.transport\n await Promise.all(\n Array.from(this.transportListeners.values()).map((listener) =>\n transport.removeListener(listener)\n )\n )\n this.transportListeners.clear()\n }\n }\n\n /**\n * Register a blockchain to the client\n * @param chain The blockchain to register\n */\n public addBlockchain(chain: Blockchain) {\n this.blockchains.set(chain.identifier, chain)\n for (const legacyIdentifier of chain.legacyIdentifiers ?? []) {\n this.blockchains.set(legacyIdentifier, chain)\n }\n }\n\n /**\n * Remove a blockchain from the client by its identifier\n * @param chainIdentifier The identifier of the blockchain to remove\n */\n public removeBlockchain(chainIdentifier: string) {\n const chain = this.blockchains.get(chainIdentifier)\n this.blockchains.delete(chainIdentifier)\n for (const legacyIdentifier of chain?.legacyIdentifiers ?? []) {\n this.blockchains.delete(legacyIdentifier)\n }\n }\n\n /**\n * Return all locally known accounts\n */\n public async getAccounts(): Promise<AccountInfo[]> {\n return this.accountManager.getAccounts()\n }\n\n /**\n * Return the account by ID\n * @param accountIdentifier The ID of an account\n */\n public async getAccount(accountIdentifier: string): Promise<AccountInfo | undefined> {\n return this.accountManager.getAccount(accountIdentifier)\n }\n\n /**\n * Remove the account by ID\n * @param accountIdentifier The ID of an account\n */\n public async removeAccount(accountIdentifier: string): Promise<void> {\n return this.accountManager.removeAccount(accountIdentifier)\n }\n\n /**\n * Remove all locally stored accounts\n */\n public async removeAllAccounts(): Promise<void> {\n return this.accountManager.removeAllAccounts()\n }\n\n /**\n * Add a new request (current timestamp) to the pending requests, remove old ones and check if we are above the limit\n */\n public async addRequestAndCheckIfRateLimited(): Promise<boolean> {\n const now: number = new Date().getTime()\n this.requestCounter = this.requestCounter.filter(\n (date) => date + this.rateLimitWindowInSeconds * 1000 > now\n )\n\n this.requestCounter.push(now)\n\n return this.requestCounter.length > this.rateLimit\n }\n\n /**\n * This method initializes the client. It will check if the connection should be established to a\n * browser extension or if the P2P transport should be used.\n *\n * @param transport A transport that can be provided by the user\n */\n public async init(transport: Transport<any, any, any>): Promise<TransportType> {\n if (this._transport.isResolved()) {\n return (await this.transport).type\n }\n\n await this.setTransport(transport) // Let users define their own transport\n\n return transport.type\n }\n\n /**\n * Returns the metadata of this DApp\n */\n public async getOwnAppMetadata(): Promise<AppMetadata> {\n return {\n senderId: await getSenderId(await this.beaconId),\n name: this.name,\n icon: this.iconUrl\n }\n }\n\n /**\n * Return all known peers\n */\n public async getPeers(): Promise<PeerInfo[]> {\n return (await this.transport).getPeers()\n }\n\n /**\n * Add a new peer to the known peers\n * @param peer The new peer to add\n */\n public async addPeer(peer: PeerInfo): Promise<void> {\n return (await this.transport).addPeer(peer)\n }\n\n public async destroy(): Promise<void> {\n if (this._transport.isResolved()) {\n const transport = await this.transport\n await this.cleanup()\n await transport.disconnect()\n if (transport.type === TransportType.WALLETCONNECT) {\n await (transport as any).doClientCleanup() // any because I cannot import the type definition\n }\n }\n await super.destroy()\n }\n\n /**\n * A \"setter\" for when the transport needs to be changed.\n */\n protected async setTransport(transport?: Transport<any>): Promise<void> {\n if (transport) {\n if (this._transport.isSettled()) {\n // If the promise has already been resolved we need to create a new one.\n this._transport = ExposedPromise.resolve(transport)\n } else {\n this._transport.resolve(transport)\n }\n } else {\n if (this._transport.isSettled()) {\n // If the promise has already been resolved we need to create a new one.\n this._transport = new ExposedPromise()\n }\n }\n }\n\n protected async addListener(transport: Transport<any>): Promise<void> {\n // in beacon we subscribe to the transport on client init only\n // unsubscribing from the transport is only beneficial when running\n // a single page dApp.\n // However, while running a multiple tabs setup, if one of the dApps disconnects\n // the others wont't recover until after a page refresh\n\n if (this.transportListeners.has(transport.type)) {\n await transport.removeListener(this.transportListeners.get(transport.type)!)\n }\n\n const subscription = async (message: any, connectionInfo: ConnectionContext) => {\n if (typeof message !== 'string') {\n return\n }\n\n const peer = await this.findPeer(connectionInfo.id)\n const protocolVersion = this.getPeerProtocolVersion(peer)\n\n const deserializedMessage = (await new Serializer(protocolVersion).deserialize(\n message\n )) as BeaconRequestMessage\n this.handleResponse(deserializedMessage, connectionInfo)\n }\n\n this.transportListeners.set(transport.type, subscription)\n\n transport.addListener(subscription).catch((error) => logger.error('addListener', error))\n }\n\n protected async sendDisconnectToPeer(peer: PeerInfo, transport?: Transport<any>): Promise<void> {\n const id = await generateGUID()\n const senderId = await getSenderId(await this.beaconId)\n\n // The disconnect ships in the peer's negotiated dialect: wrapped for\n // v3+ peers, the flat legacy shape for v2 peers (which would silently\n // ignore a wrapped envelope).\n const request = buildDisconnectMessage({ id, senderId }, effectivePeerVersion(peer))\n\n const protocolVersion = this.getPeerProtocolVersion(peer)\n const payload = await new Serializer(protocolVersion).serialize(request)\n const selectedTransport = transport ?? (await this.transport)\n\n await selectedTransport.send(payload, peer)\n }\n\n protected async findPeer(publicKey?: string): Promise<PeerInfo | undefined> {\n if (!publicKey) {\n return undefined\n }\n\n const transport = await this.transport\n const peers = await transport.getPeers()\n return peers.find((peerInfo) => peerInfo.publicKey === publicKey)\n }\n\n private getLocalProtocolVersion(): number {\n const localPreferredRaw = Number(getPreferredMessageProtocolVersion())\n return Number.isFinite(localPreferredRaw) && localPreferredRaw >= DEFAULT_PROTOCOL_VERSION\n ? localPreferredRaw\n : DEFAULT_PROTOCOL_VERSION\n }\n\n private extractPeerProtocolVersion(peer?: PeerInfo): number {\n if (!peer) {\n return DEFAULT_PROTOCOL_VERSION\n }\n\n const peerProtocolRaw =\n typeof peer.protocolVersion === 'number' ? peer.protocolVersion : Number(peer.protocolVersion)\n\n return Number.isFinite(peerProtocolRaw) && peerProtocolRaw >= DEFAULT_PROTOCOL_VERSION\n ? peerProtocolRaw\n : DEFAULT_PROTOCOL_VERSION\n }\n\n protected getPeerProtocolVersion(peer?: PeerInfo): number {\n const localVersion = this.getLocalProtocolVersion()\n const peerVersion = this.extractPeerProtocolVersion(peer)\n return Math.min(peerVersion, localVersion)\n }\n}\n"]}
|
|
@@ -6,3 +6,12 @@ export declare const LATEST_PROTOCOL_VERSION = 2;
|
|
|
6
6
|
export declare const DEFAULT_PROTOCOL_VERSION = 1;
|
|
7
7
|
export declare const NOTIFICATION_ORACLE_URL: string;
|
|
8
8
|
export declare const BACKEND_URL: string;
|
|
9
|
+
/**
|
|
10
|
+
* Shared ecosystem WalletConnect Cloud projectId, applied by default so dApps
|
|
11
|
+
* can offer WalletConnect wallets (e.g. Kukai Mobile) without registering
|
|
12
|
+
* their own project — WalletConnect's free tier comfortably covers the Tezos
|
|
13
|
+
* ecosystem's volume. Override per dApp via
|
|
14
|
+
* `DAppClientOptions.walletConnectOptions.projectId`; opt out entirely via
|
|
15
|
+
* `disableWalletConnect`. Same id that 4.8.x shipped as its built-in default.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_WALLETCONNECT_PROJECT_ID = "24469fd0a06df227b6e5f7dc7de0ff4f";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BACKEND_URL = exports.NOTIFICATION_ORACLE_URL = exports.DEFAULT_PROTOCOL_VERSION = exports.LATEST_PROTOCOL_VERSION = exports.PROTOCOL_VERSION_V2 = exports.PROTOCOL_VERSION_V1 = exports.BEACON_VERSION = exports.SDK_VERSION = void 0;
|
|
4
|
-
exports.SDK_VERSION = '5.0.
|
|
3
|
+
exports.DEFAULT_WALLETCONNECT_PROJECT_ID = exports.BACKEND_URL = exports.NOTIFICATION_ORACLE_URL = exports.DEFAULT_PROTOCOL_VERSION = exports.LATEST_PROTOCOL_VERSION = exports.PROTOCOL_VERSION_V2 = exports.PROTOCOL_VERSION_V1 = exports.BEACON_VERSION = exports.SDK_VERSION = void 0;
|
|
4
|
+
exports.SDK_VERSION = '5.0.3';
|
|
5
5
|
exports.BEACON_VERSION = '4';
|
|
6
6
|
exports.PROTOCOL_VERSION_V1 = 1;
|
|
7
7
|
exports.PROTOCOL_VERSION_V2 = 2;
|
|
@@ -9,4 +9,13 @@ exports.LATEST_PROTOCOL_VERSION = exports.PROTOCOL_VERSION_V2;
|
|
|
9
9
|
exports.DEFAULT_PROTOCOL_VERSION = exports.PROTOCOL_VERSION_V1;
|
|
10
10
|
exports.NOTIFICATION_ORACLE_URL = 'https://beacon-notification-oracle.dev.gke.papers.tech';
|
|
11
11
|
exports.BACKEND_URL = 'https://beacon-backend.prod.gke.papers.tech';
|
|
12
|
+
/**
|
|
13
|
+
* Shared ecosystem WalletConnect Cloud projectId, applied by default so dApps
|
|
14
|
+
* can offer WalletConnect wallets (e.g. Kukai Mobile) without registering
|
|
15
|
+
* their own project — WalletConnect's free tier comfortably covers the Tezos
|
|
16
|
+
* ecosystem's volume. Override per dApp via
|
|
17
|
+
* `DAppClientOptions.walletConnectOptions.projectId`; opt out entirely via
|
|
18
|
+
* `disableWalletConnect`. Same id that 4.8.x shipped as its built-in default.
|
|
19
|
+
*/
|
|
20
|
+
exports.DEFAULT_WALLETCONNECT_PROJECT_ID = '24469fd0a06df227b6e5f7dc7de0ff4f';
|
|
12
21
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAW,OAAO,CAAA;AAC7B,QAAA,cAAc,GAAW,GAAG,CAAA;AAC5B,QAAA,mBAAmB,GAAG,CAAC,CAAA;AACvB,QAAA,mBAAmB,GAAG,CAAC,CAAA;AACvB,QAAA,uBAAuB,GAAG,2BAAmB,CAAA;AAC7C,QAAA,wBAAwB,GAAG,2BAAmB,CAAA;AAE9C,QAAA,uBAAuB,GAClC,wDAAwD,CAAA;AAE7C,QAAA,WAAW,GAAW,6CAA6C,CAAA","sourcesContent":["export const SDK_VERSION: string = '5.0.
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAW,OAAO,CAAA;AAC7B,QAAA,cAAc,GAAW,GAAG,CAAA;AAC5B,QAAA,mBAAmB,GAAG,CAAC,CAAA;AACvB,QAAA,mBAAmB,GAAG,CAAC,CAAA;AACvB,QAAA,uBAAuB,GAAG,2BAAmB,CAAA;AAC7C,QAAA,wBAAwB,GAAG,2BAAmB,CAAA;AAE9C,QAAA,uBAAuB,GAClC,wDAAwD,CAAA;AAE7C,QAAA,WAAW,GAAW,6CAA6C,CAAA;AAEhF;;;;;;;GAOG;AACU,QAAA,gCAAgC,GAAG,kCAAkC,CAAA","sourcesContent":["export const SDK_VERSION: string = '5.0.3'\nexport const BEACON_VERSION: string = '4'\nexport const PROTOCOL_VERSION_V1 = 1\nexport const PROTOCOL_VERSION_V2 = 2\nexport const LATEST_PROTOCOL_VERSION = PROTOCOL_VERSION_V2\nexport const DEFAULT_PROTOCOL_VERSION = PROTOCOL_VERSION_V1\n\nexport const NOTIFICATION_ORACLE_URL: string =\n 'https://beacon-notification-oracle.dev.gke.papers.tech'\n\nexport const BACKEND_URL: string = 'https://beacon-backend.prod.gke.papers.tech'\n\n/**\n * Shared ecosystem WalletConnect Cloud projectId, applied by default so dApps\n * can offer WalletConnect wallets (e.g. Kukai Mobile) without registering\n * their own project — WalletConnect's free tier comfortably covers the Tezos\n * ecosystem's volume. Override per dApp via\n * `DAppClientOptions.walletConnectOptions.projectId`; opt out entirely via\n * `disableWalletConnect`. Same id that 4.8.x shipped as its built-in default.\n */\nexport const DEFAULT_WALLETCONNECT_PROJECT_ID = '24469fd0a06df227b6e5f7dc7de0ff4f'\n"]}
|
package/dist/cjs/src/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { LocalStorage } from './storage/LocalStorage';
|
|
|
19
19
|
import { getStorage } from './storage/getStorage';
|
|
20
20
|
import { Serializer } from './Serializer';
|
|
21
21
|
import { ClientOptions } from './clients/client/ClientOptions';
|
|
22
|
-
import { SDK_VERSION, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION } from './constants';
|
|
22
|
+
import { SDK_VERSION, DEFAULT_WALLETCONNECT_PROJECT_ID, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION } from './constants';
|
|
23
23
|
import { getPreferredMessageProtocolVersion, setPreferredMessageProtocolVersion } from './message-protocol';
|
|
24
24
|
import { AccountManager } from './managers/AccountManager';
|
|
25
25
|
import { AppMetadataManager } from './managers/AppMetadataManager';
|
|
@@ -51,9 +51,9 @@ export { getError, BeaconError, AbortedBeaconError, BroadcastBeaconError, Networ
|
|
|
51
51
|
export { Transport, MessageBasedClient, CommunicationClient };
|
|
52
52
|
export { ChromeStorage, LocalStorage, WCStorage, IndexedDBStorage, StorageValidator, getStorage };
|
|
53
53
|
export { PeerManager, AccountManager, AppMetadataManager, PermissionManager };
|
|
54
|
-
export { SDK_VERSION, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION, getPreferredMessageProtocolVersion, setPreferredMessageProtocolVersion };
|
|
54
|
+
export { SDK_VERSION, DEFAULT_WALLETCONNECT_PROJECT_ID, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION, getPreferredMessageProtocolVersion, setPreferredMessageProtocolVersion };
|
|
55
55
|
export { getSenderId, getAccountIdentifier, windowRef, MultiTabChannel };
|
|
56
|
-
export { usesWrappedMessages, MESSAGE_WRAPPED_FROM_VERSION, MULTI_NETWORK_FROM_VERSION, compareBeaconVersion, isAtLeastVersion, isMultiNetworkVersion, negotiateEnvelopeVersion, wrapBeaconMessage, unwrapBeaconMessage } from './utils/message-utils';
|
|
56
|
+
export { usesWrappedMessages, MESSAGE_WRAPPED_FROM_VERSION, MULTI_NETWORK_FROM_VERSION, compareBeaconVersion, isAtLeastVersion, isMultiNetworkVersion, negotiateEnvelopeVersion, effectivePeerVersion, wrapBeaconMessage, unwrapBeaconMessage } from './utils/message-utils';
|
|
57
57
|
export { normalizeTezosCaip2, isValidTezosCaip2, networkFromTezosCaip2, TEZOS_NETWORK_GENESIS_IDS, tezosCaip2FromNetworkType, networkTypeFromTezosCaip2 } from './utils/caip2';
|
|
58
58
|
export { assertNever } from './utils/assert-never';
|
|
59
59
|
export { resolveRequiredMinimumVersion } from './utils/required-minimum-version';
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
exports.BACKEND_URL = exports.NOTIFICATION_ORACLE_URL = exports.getDebugEnabled = exports.setDebugEnabled = exports.getLogger = exports.setLogger = exports.Logger = exports.Serializer = exports.BEACON_ERROR_CODES = exports.BLOCKCHAIN_ERROR_CODES = exports.PM_ERROR_CODES = exports.MATRIX_ERROR_CODES = exports.WC_ERROR_CODES = exports.ERROR_CODES = exports.SENSITIVE_STORAGE_KEYS = exports.copyErrorContextToClipboard = exports.serializeErrorContext = exports.buildErrorContext = exports.gatherDiagnostics = exports.resolveRequiredMinimumVersion = exports.assertNever = exports.networkTypeFromTezosCaip2 = exports.tezosCaip2FromNetworkType = exports.TEZOS_NETWORK_GENESIS_IDS = exports.networkFromTezosCaip2 = exports.isValidTezosCaip2 = exports.normalizeTezosCaip2 = exports.unwrapBeaconMessage = exports.wrapBeaconMessage = exports.negotiateEnvelopeVersion = void 0;
|
|
6
|
+
exports.isAtLeastVersion = exports.compareBeaconVersion = exports.MULTI_NETWORK_FROM_VERSION = exports.MESSAGE_WRAPPED_FROM_VERSION = exports.usesWrappedMessages = exports.MultiTabChannel = exports.windowRef = exports.getAccountIdentifier = exports.getSenderId = exports.setPreferredMessageProtocolVersion = exports.getPreferredMessageProtocolVersion = exports.DEFAULT_PROTOCOL_VERSION = exports.LATEST_PROTOCOL_VERSION = exports.PROTOCOL_VERSION_V2 = exports.PROTOCOL_VERSION_V1 = exports.BEACON_VERSION = exports.DEFAULT_WALLETCONNECT_PROJECT_ID = exports.SDK_VERSION = exports.PermissionManager = exports.AppMetadataManager = exports.AccountManager = exports.PeerManager = exports.getStorage = exports.StorageValidator = exports.IndexedDBStorage = exports.WCStorage = exports.LocalStorage = exports.ChromeStorage = exports.CommunicationClient = exports.MessageBasedClient = exports.Transport = exports.InvalidBeaconVersionError = exports.NetworksUnsupportedBeaconError = exports.InvalidRequiredMinimumVersionError = exports.VersionUnsupportedBeaconError = exports.UnknownBeaconError = exports.SignatureTypeNotSupportedBeaconError = exports.TransactionInvalidBeaconError = exports.TooManyOperationsBeaconError = exports.ParametersInvalidBeaconError = exports.NotGrantedBeaconError = exports.NoPrivateKeyBeaconError = exports.NoAddressBeaconError = exports.NetworkNotSupportedBeaconError = exports.BroadcastBeaconError = exports.AbortedBeaconError = exports.BeaconError = exports.getError = exports.Client = exports.BeaconClient = void 0;
|
|
7
|
+
exports.BACKEND_URL = exports.NOTIFICATION_ORACLE_URL = exports.getDebugEnabled = exports.setDebugEnabled = exports.getLogger = exports.setLogger = exports.Logger = exports.Serializer = exports.BEACON_ERROR_CODES = exports.BLOCKCHAIN_ERROR_CODES = exports.PM_ERROR_CODES = exports.MATRIX_ERROR_CODES = exports.WC_ERROR_CODES = exports.ERROR_CODES = exports.SENSITIVE_STORAGE_KEYS = exports.copyErrorContextToClipboard = exports.serializeErrorContext = exports.buildErrorContext = exports.gatherDiagnostics = exports.resolveRequiredMinimumVersion = exports.assertNever = exports.networkTypeFromTezosCaip2 = exports.tezosCaip2FromNetworkType = exports.TEZOS_NETWORK_GENESIS_IDS = exports.networkFromTezosCaip2 = exports.isValidTezosCaip2 = exports.normalizeTezosCaip2 = exports.unwrapBeaconMessage = exports.wrapBeaconMessage = exports.effectivePeerVersion = exports.negotiateEnvelopeVersion = exports.isMultiNetworkVersion = void 0;
|
|
8
8
|
/**
|
|
9
9
|
* General docs
|
|
10
10
|
* @module public
|
|
@@ -43,6 +43,7 @@ const Serializer_1 = require("./Serializer");
|
|
|
43
43
|
Object.defineProperty(exports, "Serializer", { enumerable: true, get: function () { return Serializer_1.Serializer; } });
|
|
44
44
|
const constants_1 = require("./constants");
|
|
45
45
|
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return constants_1.SDK_VERSION; } });
|
|
46
|
+
Object.defineProperty(exports, "DEFAULT_WALLETCONNECT_PROJECT_ID", { enumerable: true, get: function () { return constants_1.DEFAULT_WALLETCONNECT_PROJECT_ID; } });
|
|
46
47
|
Object.defineProperty(exports, "BEACON_VERSION", { enumerable: true, get: function () { return constants_1.BEACON_VERSION; } });
|
|
47
48
|
Object.defineProperty(exports, "PROTOCOL_VERSION_V1", { enumerable: true, get: function () { return constants_1.PROTOCOL_VERSION_V1; } });
|
|
48
49
|
Object.defineProperty(exports, "PROTOCOL_VERSION_V2", { enumerable: true, get: function () { return constants_1.PROTOCOL_VERSION_V2; } });
|
|
@@ -111,6 +112,7 @@ Object.defineProperty(exports, "compareBeaconVersion", { enumerable: true, get:
|
|
|
111
112
|
Object.defineProperty(exports, "isAtLeastVersion", { enumerable: true, get: function () { return message_utils_1.isAtLeastVersion; } });
|
|
112
113
|
Object.defineProperty(exports, "isMultiNetworkVersion", { enumerable: true, get: function () { return message_utils_1.isMultiNetworkVersion; } });
|
|
113
114
|
Object.defineProperty(exports, "negotiateEnvelopeVersion", { enumerable: true, get: function () { return message_utils_1.negotiateEnvelopeVersion; } });
|
|
115
|
+
Object.defineProperty(exports, "effectivePeerVersion", { enumerable: true, get: function () { return message_utils_1.effectivePeerVersion; } });
|
|
114
116
|
Object.defineProperty(exports, "wrapBeaconMessage", { enumerable: true, get: function () { return message_utils_1.wrapBeaconMessage; } });
|
|
115
117
|
Object.defineProperty(exports, "unwrapBeaconMessage", { enumerable: true, get: function () { return message_utils_1.unwrapBeaconMessage; } });
|
|
116
118
|
var caip2_1 = require("./utils/caip2");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;AAAA;;;GAGG;AACH,oDAAgD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;AAAA;;;GAGG;AACH,oDAAgD;AA+DJ,uFA/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AA,qBAAqB,OAAA;AACrB,yHAAA,wBAAwB,OAAA;AACxB,qHAAA,oBAAoB,OAAA;AACpB,kHAAA,iBAAiB,OAAA;AACjB,oHAAA,mBAAmB,OAAA;AAErB,uCAOsB;AANpB,4GAAA,mBAAmB,OAAA;AACnB,0GAAA,iBAAiB,OAAA;AACjB,8GAAA,qBAAqB,OAAA;AACrB,kHAAA,yBAAyB,OAAA;AACzB,kHAAA,yBAAyB,OAAA;AACzB,kHAAA,yBAAyB,OAAA;AAE3B,qDAAkD;AAAzC,2GAAA,WAAW,OAAA;AACpB,6EAAgF;AAAvE,yIAAA,6BAA6B,OAAA;AAEtC,cAAc;AACd,mDAM4B;AAL1B,gHAAA,iBAAiB,OAAA;AACjB,gHAAA,iBAAiB,OAAA;AACjB,oHAAA,qBAAqB,OAAA;AACrB,0HAAA,2BAA2B,OAAA;AAC3B,qHAAA,sBAAsB,OAAA;AAGxB,cAAc;AACd,oDAAkJ;AAAzI,0GAAA,WAAW,OAAA;AAAE,6GAAA,cAAc,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AAAE,6GAAA,cAAc,OAAA;AAAE,qHAAA,sBAAsB,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AASpH,yCAAkE;AAAzD,oHAAA,uBAAuB,OAAA;AAAE,wGAAA,WAAW,OAAA","sourcesContent":["/**\n * General docs\n * @module public\n */\nimport { Client } from './clients/client/Client'\nimport { BeaconError } from './errors/BeaconError'\nimport { BroadcastBeaconError } from './errors/BroadcastBeaconError'\nimport { NetworkNotSupportedBeaconError } from './errors/NetworkNotSupportedBeaconError'\nimport { NoAddressBeaconError } from './errors/NoAddressBeaconError'\nimport { NoPrivateKeyBeaconError } from './errors/NoPrivateKeyBeaconError'\nimport { NotGrantedBeaconError } from './errors/NotGrantedBeaconError'\nimport { ParametersInvalidBeaconError } from './errors/ParametersInvalidBeaconError'\nimport { TooManyOperationsBeaconError } from './errors/TooManyOperationsBeaconError'\nimport { TransactionInvalidBeaconError } from './errors/TransactionInvalidBeaconError'\nimport { UnknownBeaconError } from './errors/UnknownBeaconError'\nimport { Transport } from './transports/Transport'\nimport { ChromeStorage } from './storage/ChromeStorage'\nimport { LocalStorage } from './storage/LocalStorage'\nimport { getStorage } from './storage/getStorage'\nimport { Serializer } from './Serializer'\n// import { RequestEncryptPayloadInput } from './types/RequestEncryptPayloadInput'\nimport { ClientOptions } from './clients/client/ClientOptions'\nimport {\n SDK_VERSION,\n DEFAULT_WALLETCONNECT_PROJECT_ID,\n BEACON_VERSION,\n PROTOCOL_VERSION_V1,\n PROTOCOL_VERSION_V2,\n LATEST_PROTOCOL_VERSION,\n DEFAULT_PROTOCOL_VERSION\n} from './constants'\nimport {\n getPreferredMessageProtocolVersion,\n setPreferredMessageProtocolVersion\n} from './message-protocol'\nimport { AccountManager } from './managers/AccountManager'\nimport { AppMetadataManager } from './managers/AppMetadataManager'\nimport { PermissionManager } from './managers/PermissionManager'\nimport { BeaconClient } from './clients/beacon-client/BeaconClient'\nimport { BeaconClientOptions } from './clients/beacon-client/BeaconClientOptions'\nimport { getAccountIdentifier } from './utils/get-account-identifier'\nimport { AbortedBeaconError } from './errors/AbortedBeaconError'\nimport { getSenderId } from './utils/get-sender-id'\nimport { PeerManager } from './managers/PeerManager'\nimport { MessageBasedClient } from './transports/clients/MessageBasedClient'\nimport { setDebugEnabled, getDebugEnabled } from './debug'\n// import { EncryptPayloadRequest } from './types/beacon/messages/EncryptPayloadRequest'\n// import { EncryptPayloadResponse } from './types/beacon/messages/EncryptPayloadResponse'\n// import { EncryptionTypeNotSupportedBeaconError } from './errors/EncryptionTypeNotSupportedBeaconError'\nimport { SignatureTypeNotSupportedBeaconError } from './errors/SignatureTypeNotSupportedBeaconError'\nimport { VersionUnsupportedBeaconError } from './errors/VersionUnsupportedBeaconError'\nimport { InvalidRequiredMinimumVersionError } from './errors/InvalidRequiredMinimumVersionError'\nimport { NetworksUnsupportedBeaconError } from './errors/NetworksUnsupportedBeaconError'\nimport { InvalidBeaconVersionError } from './errors/InvalidBeaconVersionError'\nimport { getLogger, Logger, setLogger } from './utils/Logger'\nimport { windowRef } from './MockWindow'\nimport { CommunicationClient } from './transports/clients/CommunicationClient'\nimport { ClientEvents } from './transports/clients/ClientEvents'\nimport { WCStorage } from './storage/WCStorage'\nimport { IndexedDBStorage } from './storage/IndexedDBStorage'\nimport { StorageValidator } from './storage/StorageValidator'\nimport { MultiTabChannel } from './utils/multi-tab-channel'\nimport getError from './errors/get-error'\n// import { EncryptionType } from './types/EncryptionType'\n// import { EncryptionOperation } from './types/EncryptionOperation'\n\n// Clients\nexport { BeaconClient, BeaconClientOptions, Client, ClientOptions, ClientEvents }\n\n// Errors\nexport {\n getError,\n BeaconError,\n AbortedBeaconError,\n BroadcastBeaconError,\n NetworkNotSupportedBeaconError,\n NoAddressBeaconError,\n NoPrivateKeyBeaconError,\n NotGrantedBeaconError,\n ParametersInvalidBeaconError,\n TooManyOperationsBeaconError,\n TransactionInvalidBeaconError,\n SignatureTypeNotSupportedBeaconError,\n // EncryptionTypeNotSupportedBeaconError,\n UnknownBeaconError,\n VersionUnsupportedBeaconError,\n InvalidRequiredMinimumVersionError,\n NetworksUnsupportedBeaconError,\n InvalidBeaconVersionError\n}\n\n// Transport\nexport { Transport, MessageBasedClient, CommunicationClient }\n\n// Storage\nexport { ChromeStorage, LocalStorage, WCStorage, IndexedDBStorage, StorageValidator, getStorage }\n\n// Managers\nexport { PeerManager, AccountManager, AppMetadataManager, PermissionManager }\n\n// Constants\nexport {\n SDK_VERSION,\n DEFAULT_WALLETCONNECT_PROJECT_ID,\n BEACON_VERSION,\n PROTOCOL_VERSION_V1,\n PROTOCOL_VERSION_V2,\n LATEST_PROTOCOL_VERSION,\n DEFAULT_PROTOCOL_VERSION,\n getPreferredMessageProtocolVersion,\n setPreferredMessageProtocolVersion\n}\n\n// Utils\nexport { getSenderId, getAccountIdentifier, windowRef, MultiTabChannel }\nexport {\n usesWrappedMessages,\n MESSAGE_WRAPPED_FROM_VERSION,\n MULTI_NETWORK_FROM_VERSION,\n compareBeaconVersion,\n isAtLeastVersion,\n isMultiNetworkVersion,\n negotiateEnvelopeVersion,\n effectivePeerVersion,\n wrapBeaconMessage,\n unwrapBeaconMessage\n} from './utils/message-utils'\nexport {\n normalizeTezosCaip2,\n isValidTezosCaip2,\n networkFromTezosCaip2,\n TEZOS_NETWORK_GENESIS_IDS,\n tezosCaip2FromNetworkType,\n networkTypeFromTezosCaip2\n} from './utils/caip2'\nexport { assertNever } from './utils/assert-never'\nexport { resolveRequiredMinimumVersion } from './utils/required-minimum-version'\n\n// Diagnostics\nexport {\n gatherDiagnostics,\n buildErrorContext,\n serializeErrorContext,\n copyErrorContextToClipboard,\n SENSITIVE_STORAGE_KEYS\n} from './utils/diagnostics'\n\n// Error codes\nexport { ERROR_CODES, WC_ERROR_CODES, MATRIX_ERROR_CODES, PM_ERROR_CODES, BLOCKCHAIN_ERROR_CODES, BEACON_ERROR_CODES } from './errors/error-codes'\nexport type { ErrorCode } from './errors/error-codes'\n\n// Others\nexport { Serializer, Logger, setLogger, getLogger }\n\n// Debug\nexport { setDebugEnabled, getDebugEnabled }\n\nexport { NOTIFICATION_ORACLE_URL, BACKEND_URL } from './constants'\n"]}
|
|
@@ -56,6 +56,39 @@ export declare const LEGACY_ENVELOPE_VERSION = "2";
|
|
|
56
56
|
* @category Utility
|
|
57
57
|
*/
|
|
58
58
|
export declare const negotiateEnvelopeVersion: (peerVersion: string | undefined) => string;
|
|
59
|
+
/**
|
|
60
|
+
* The peer's version as safe to feed into capability negotiation
|
|
61
|
+
* ({@link negotiateEnvelopeVersion}, multi-network gating, minimum-version
|
|
62
|
+
* enforcement).
|
|
63
|
+
*
|
|
64
|
+
* `peer.version` alone CANNOT be trusted: legacy wallets (octez.connect
|
|
65
|
+
* 4.8.x and upstream beacon-sdk forks) build their pairing response with the
|
|
66
|
+
* version field of the dApp's pairing REQUEST — they echo the dApp's own
|
|
67
|
+
* version back instead of declaring theirs. A v5 dApp reading that echo sees
|
|
68
|
+
* '4', serves a wrapped v4 envelope, and the legacy wallet silently drops it
|
|
69
|
+
* after pairing ("Pairing complete! Waiting for permission request…").
|
|
70
|
+
*
|
|
71
|
+
* The reliable capability marker is `protocolVersion`: v5+ pairing responses
|
|
72
|
+
* attach it on every transport that can carry it (P2P, PostMessage), legacy
|
|
73
|
+
* responses never do, and it cannot be echoed (legacy constructors don't
|
|
74
|
+
* know the field). A peer that DECLARES a version without a valid marker
|
|
75
|
+
* (a positive protocol version, matching the protocol's minimum of 1) is
|
|
76
|
+
* therefore treated as a legacy flat-v2 speaker regardless of its echoed
|
|
77
|
+
* `version` — exactly the wire a 4.8.x dApp would have served it.
|
|
78
|
+
*
|
|
79
|
+
* A peer that declares NO version at all keeps the long-standing "unknown"
|
|
80
|
+
* semantics and maps to `undefined` (WalletConnect pairings, where beacon
|
|
81
|
+
* versions are never fabricated and capability is negotiated via session
|
|
82
|
+
* namespaces): version gates treat unknown as allowed-through and response
|
|
83
|
+
* handling falls back to the response envelope's version. The echo problem
|
|
84
|
+
* by definition only exists for peers that DO carry a version.
|
|
85
|
+
*
|
|
86
|
+
* @category Utility
|
|
87
|
+
*/
|
|
88
|
+
export declare const effectivePeerVersion: (peer: {
|
|
89
|
+
version?: string;
|
|
90
|
+
protocolVersion?: unknown;
|
|
91
|
+
} | undefined) => string | undefined;
|
|
59
92
|
/**
|
|
60
93
|
* Build a wrapped beacon envelope. Single source of truth for the
|
|
61
94
|
* `{ id, version, senderId, message }` wire shape so senders cannot drift.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildDisconnectMessage = exports.unwrapBeaconMessage = exports.wrapBeaconMessage = exports.negotiateEnvelopeVersion = exports.LEGACY_ENVELOPE_VERSION = exports.usesWrappedMessages = exports.isMultiNetworkVersion = exports.isAtLeastVersion = exports.compareBeaconVersion = exports.parseStrictDecimalInteger = exports.MULTI_NETWORK_FROM_VERSION = exports.MESSAGE_WRAPPED_FROM_VERSION = void 0;
|
|
3
|
+
exports.buildDisconnectMessage = exports.unwrapBeaconMessage = exports.wrapBeaconMessage = exports.effectivePeerVersion = exports.negotiateEnvelopeVersion = exports.LEGACY_ENVELOPE_VERSION = exports.usesWrappedMessages = exports.isMultiNetworkVersion = exports.isAtLeastVersion = exports.compareBeaconVersion = exports.parseStrictDecimalInteger = exports.MULTI_NETWORK_FROM_VERSION = exports.MESSAGE_WRAPPED_FROM_VERSION = void 0;
|
|
4
4
|
const octez_connect_types_1 = require("@tezos-x/octez.connect-types");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const InvalidBeaconVersionError_1 = require("../errors/InvalidBeaconVersionError");
|
|
@@ -110,6 +110,47 @@ const negotiateEnvelopeVersion = (peerVersion) => {
|
|
|
110
110
|
return (0, exports.isAtLeastVersion)(peerVersion, constants_1.BEACON_VERSION) ? constants_1.BEACON_VERSION : peerVersion;
|
|
111
111
|
};
|
|
112
112
|
exports.negotiateEnvelopeVersion = negotiateEnvelopeVersion;
|
|
113
|
+
/**
|
|
114
|
+
* The peer's version as safe to feed into capability negotiation
|
|
115
|
+
* ({@link negotiateEnvelopeVersion}, multi-network gating, minimum-version
|
|
116
|
+
* enforcement).
|
|
117
|
+
*
|
|
118
|
+
* `peer.version` alone CANNOT be trusted: legacy wallets (octez.connect
|
|
119
|
+
* 4.8.x and upstream beacon-sdk forks) build their pairing response with the
|
|
120
|
+
* version field of the dApp's pairing REQUEST — they echo the dApp's own
|
|
121
|
+
* version back instead of declaring theirs. A v5 dApp reading that echo sees
|
|
122
|
+
* '4', serves a wrapped v4 envelope, and the legacy wallet silently drops it
|
|
123
|
+
* after pairing ("Pairing complete! Waiting for permission request…").
|
|
124
|
+
*
|
|
125
|
+
* The reliable capability marker is `protocolVersion`: v5+ pairing responses
|
|
126
|
+
* attach it on every transport that can carry it (P2P, PostMessage), legacy
|
|
127
|
+
* responses never do, and it cannot be echoed (legacy constructors don't
|
|
128
|
+
* know the field). A peer that DECLARES a version without a valid marker
|
|
129
|
+
* (a positive protocol version, matching the protocol's minimum of 1) is
|
|
130
|
+
* therefore treated as a legacy flat-v2 speaker regardless of its echoed
|
|
131
|
+
* `version` — exactly the wire a 4.8.x dApp would have served it.
|
|
132
|
+
*
|
|
133
|
+
* A peer that declares NO version at all keeps the long-standing "unknown"
|
|
134
|
+
* semantics and maps to `undefined` (WalletConnect pairings, where beacon
|
|
135
|
+
* versions are never fabricated and capability is negotiated via session
|
|
136
|
+
* namespaces): version gates treat unknown as allowed-through and response
|
|
137
|
+
* handling falls back to the response envelope's version. The echo problem
|
|
138
|
+
* by definition only exists for peers that DO carry a version.
|
|
139
|
+
*
|
|
140
|
+
* @category Utility
|
|
141
|
+
*/
|
|
142
|
+
const effectivePeerVersion = (peer) => {
|
|
143
|
+
if (!peer || peer.version == null) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
// `Number(null)` is 0 (finite) — treat null like absent, not like v5.
|
|
147
|
+
const protocolRaw = peer.protocolVersion == null ? Number.NaN : Number(peer.protocolVersion);
|
|
148
|
+
// Positive protocol versions only (the protocol's minimum is 1): `0`,
|
|
149
|
+
// negatives, and non-numeric noise are malformed markers and must stay on
|
|
150
|
+
// the legacy path, like an absent marker.
|
|
151
|
+
return Number.isFinite(protocolRaw) && protocolRaw >= 1 ? peer.version : exports.LEGACY_ENVELOPE_VERSION;
|
|
152
|
+
};
|
|
153
|
+
exports.effectivePeerVersion = effectivePeerVersion;
|
|
113
154
|
/**
|
|
114
155
|
* Build a wrapped beacon envelope. Single source of truth for the
|
|
115
156
|
* `{ id, version, senderId, message }` wire shape so senders cannot drift.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-utils.js","sourceRoot":"","sources":["../../../../src/utils/message-utils.ts"],"names":[],"mappings":";;;AAAA,sEAIqC;AACrC,4CAA6C;AAO7C,mFAA+E;AAElE,QAAA,4BAA4B,GAAG,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EAAE,QAAQ,CAAC,OAAO;IACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;IAC3B,OAAO;CACR,CAAC,CAAA;AARW,QAAA,iBAAiB,qBAQ5B;AAEF;;;;;;;GAOG;AACI,MAAM,mBAAmB,GAAG,CAA2B,SAG7D,EAAiB,EAAE,CAAC,CAAC,IAAA,2BAAmB,EAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;AAHhF,QAAA,mBAAmB,uBAG6D;AAE7F;;;;;;;GAOG;AACI,MAAM,sBAAsB,GAAG,CACpC,QAA0C,EAC1C,WAA+B,EACmD,EAAE;IACpF,MAAM,OAAO,GAAG,IAAA,gCAAwB,EAAC,WAAW,CAAC,CAAA;IAErD,OAAO,IAAA,2BAAmB,EAAC,OAAO,CAAC;QACjC,CAAC,CAAC,IAAA,yBAAiB,EACf,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,EACzD,EAAE,IAAI,EAAE,uCAAiB,CAAC,UAAU,EAAE,CACvC;QACH,CAAC,CAAC;YACE,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,OAAO;YACP,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,IAAI,EAAE,uCAAiB,CAAC,UAAU;SACnC,CAAA;AACP,CAAC,CAAA;AAjBY,QAAA,sBAAsB,0BAiBlC","sourcesContent":["import {\n BeaconMessageType,\n BeaconMessageWrapper,\n DisconnectMessage\n} from '@tezos-x/octez.connect-types'\nimport { BEACON_VERSION } from '../constants'\n\n// Structural stand-in for the beaconV3 BeaconBaseMessage ({ type: unknown }).\n// The types barrel re-exports the flat BeaconBaseMessage (which also carries\n// id/version/senderId) under the same name, so constraining on the barrel\n// type would wrongly require envelope fields on the inner payload.\ninterface WrappedPayload { type: unknown }\nimport { InvalidBeaconVersionError } from '../errors/InvalidBeaconVersionError'\n\nexport const MESSAGE_WRAPPED_FROM_VERSION = 3\n\n// peer.version at or above which the multi-network (v4) protocol applies.\nexport const MULTI_NETWORK_FROM_VERSION = '4'\n\n// Strict decimal-integer: a lone `0` or non-zero digit followed by digits.\n// Rejects leading zeros on multi-digit values (e.g. `'04'`). A lone `0` is\n// kept valid so legacy compat paths can use it as a fallback/unknown version.\nconst DECIMAL_INTEGER_RE = /^(0|[1-9]\\d*)$/\n\nexport const parseStrictDecimalInteger = (value: unknown): number | null => {\n if (typeof value !== 'string') {\n return null\n }\n if (!DECIMAL_INTEGER_RE.test(value)) {\n return null\n }\n const parsed = Number(value)\n if (!Number.isFinite(parsed) || parsed > Number.MAX_SAFE_INTEGER) {\n return null\n }\n\n return parsed\n}\n\n/**\n * Compare two `peer.version` strings as strict decimal integers.\n *\n * Returns < 0 if `a < b`, 0 if equal, > 0 if `a > b` — same convention as\n * `Array.prototype.sort` comparators.\n *\n * Throws `InvalidBeaconVersionError` if either operand is not a decimal-\n * integer string in `[0, Number.MAX_SAFE_INTEGER]`. Leading signs, leading\n * zeros, decimal points, exponent notation, hex, whitespace, `'NaN'` and\n * `'Infinity'` all reject.\n *\n * @category Utility\n */\nexport const compareBeaconVersion = (a: unknown, b: unknown): number => {\n const na = parseStrictDecimalInteger(a)\n const nb = parseStrictDecimalInteger(b)\n\n if (na === null || nb === null) {\n throw new InvalidBeaconVersionError(a, b)\n }\n\n return na - nb\n}\n\n/**\n * Whether `version` is a valid peer.version at or above `threshold`.\n *\n * Single source of truth for the \"is this peer at least version X\" decision.\n * Returns `false` for an absent version and for any value that fails the\n * strict decimal-integer contract of `compareBeaconVersion` — i.e. malformed\n * or untrusted input is always treated as below the threshold, so a hostile\n * peer cannot trip a higher-version code path.\n *\n * @category Utility\n */\nexport const isAtLeastVersion = (version: string | undefined, threshold: string): boolean => {\n if (version === undefined) {\n return false\n }\n try {\n return compareBeaconVersion(version, threshold) >= 0\n } catch {\n return false\n }\n}\n\n/**\n * Whether `version` is at or above the multi-network (v4) threshold.\n *\n * @category Utility\n */\nexport const isMultiNetworkVersion = (version: string | undefined): boolean =>\n isAtLeastVersion(version, MULTI_NETWORK_FROM_VERSION)\n\nexport const usesWrappedMessages = (version?: string): boolean => {\n // Use the same strict decimal-integer contract as compareBeaconVersion so\n // wrapped-message routing agrees with the v4/multi-network routing: a loose\n // value like '3.0', ' 3 ' or '03' (which Number() would accept) is treated\n // as malformed and routed as non-wrapped rather than inconsistently.\n const parsed = parseStrictDecimalInteger(version)\n\n return parsed !== null && parsed >= MESSAGE_WRAPPED_FROM_VERSION\n}\n\n/** The flat legacy wire dialect served to peers below the wrapped baseline. */\nexport const LEGACY_ENVELOPE_VERSION = '2'\n\n/**\n * The envelope version to stamp on an outgoing message for a peer that\n * declared `peerVersion` at pairing: `min(peerVersion, BEACON_VERSION)` with\n * a floor at the flat legacy dialect ('2').\n *\n * This is the backward-compatibility pivot: a peer that declared '2' — or\n * never declared a version at all (legacy pairings, WalletConnect peers,\n * malformed values) — is served the flat v2 dialect it has always spoken; a\n * v3 peer receives '3' wrapped envelopes and never sees v4 payload fields;\n * a v4 peer gets the full wrapped v4 wire. Callers pick the message SHAPE\n * with `usesWrappedMessages(negotiated)` and gate v4 fields (`networks`/\n * `accounts`) on `isMultiNetworkVersion(negotiated)`.\n *\n * @category Utility\n */\nexport const negotiateEnvelopeVersion = (peerVersion: string | undefined): string => {\n if (!isAtLeastVersion(peerVersion, String(MESSAGE_WRAPPED_FROM_VERSION))) {\n return LEGACY_ENVELOPE_VERSION\n }\n\n return isAtLeastVersion(peerVersion, BEACON_VERSION) ? BEACON_VERSION : (peerVersion as string)\n}\n\n/**\n * Build a wrapped beacon envelope. Single source of truth for the\n * `{ id, version, senderId, message }` wire shape so senders cannot drift.\n *\n * @category Utility\n */\nexport const wrapBeaconMessage = <T extends WrappedPayload>(\n envelope: { id: string; version: string; senderId: string },\n message: T\n): BeaconMessageWrapper<T> => ({\n id: envelope.id,\n version: envelope.version,\n senderId: envelope.senderId,\n message\n})\n\n/**\n * Extract the inner payload of a wrapped beacon envelope, or `undefined`\n * when the candidate's version does not follow the wrapped (v3+) contract.\n * Callers must treat `undefined` as \"not a wrapped message\" and drop or\n * tombstone it — never fall back to reading flat fields.\n *\n * @category Utility\n */\nexport const unwrapBeaconMessage = <T extends WrappedPayload>(candidate: {\n version?: string\n message?: T\n}): T | undefined => (usesWrappedMessages(candidate.version) ? candidate.message : undefined)\n\n/**\n * Build a disconnect message in the peer's negotiated dialect: a wrapped\n * envelope for v3+ peers, the flat legacy shape for v2 peers. A legacy peer\n * routes on the top-level `type` and would silently ignore a wrapped\n * envelope — the goodbye must be spoken in the dialect the peer parses.\n *\n * @category Utility\n */\nexport const buildDisconnectMessage = (\n envelope: { id: string; senderId: string },\n peerVersion: string | undefined\n): DisconnectMessage | BeaconMessageWrapper<{ type: BeaconMessageType.Disconnect }> => {\n const version = negotiateEnvelopeVersion(peerVersion)\n\n return usesWrappedMessages(version)\n ? wrapBeaconMessage(\n { id: envelope.id, version, senderId: envelope.senderId },\n { type: BeaconMessageType.Disconnect }\n )\n : {\n id: envelope.id,\n version,\n senderId: envelope.senderId,\n type: BeaconMessageType.Disconnect\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message-utils.js","sourceRoot":"","sources":["../../../../src/utils/message-utils.ts"],"names":[],"mappings":";;;AAAA,sEAIqC;AACrC,4CAA6C;AAO7C,mFAA+E;AAElE,QAAA,4BAA4B,GAAG,CAAC,CAAA;AAE7C,0EAA0E;AAC7D,QAAA,0BAA0B,GAAG,GAAG,CAAA;AAE7C,2EAA2E;AAC3E,2EAA2E;AAC3E,8EAA8E;AAC9E,MAAM,kBAAkB,GAAG,gBAAgB,CAAA;AAEpC,MAAM,yBAAyB,GAAG,CAAC,KAAc,EAAiB,EAAE;IACzE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,CAAC,kB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Content":["import {\n BeaconMessageType,\n BeaconMessageWrapper,\n DisconnectMessage\n} from '@tezos-x/octez.connect-types'\nimport { BEACON_VERSION } from '../constants'\n\n// Structural stand-in for the beaconV3 BeaconBaseMessage ({ type: unknown }).\n// The types barrel re-exports the flat BeaconBaseMessage (which also carries\n// id/version/senderId) under the same name, so constraining on the barrel\n// type would wrongly require envelope fields on the inner payload.\ninterface WrappedPayload { type: unknown }\nimport { InvalidBeaconVersionError } from '../errors/InvalidBeaconVersionError'\n\nexport const MESSAGE_WRAPPED_FROM_VERSION = 3\n\n// peer.version at or above which the multi-network (v4) protocol applies.\nexport const MULTI_NETWORK_FROM_VERSION = '4'\n\n// Strict decimal-integer: a lone `0` or non-zero digit followed by digits.\n// Rejects leading zeros on multi-digit values (e.g. `'04'`). A lone `0` is\n// kept valid so legacy compat paths can use it as a fallback/unknown version.\nconst DECIMAL_INTEGER_RE = /^(0|[1-9]\\d*)$/\n\nexport const parseStrictDecimalInteger = (value: unknown): number | null => {\n if (typeof value !== 'string') {\n return null\n }\n if (!DECIMAL_INTEGER_RE.test(value)) {\n return null\n }\n const parsed = Number(value)\n if (!Number.isFinite(parsed) || parsed > Number.MAX_SAFE_INTEGER) {\n return null\n }\n\n return parsed\n}\n\n/**\n * Compare two `peer.version` strings as strict decimal integers.\n *\n * Returns < 0 if `a < b`, 0 if equal, > 0 if `a > b` — same convention as\n * `Array.prototype.sort` comparators.\n *\n * Throws `InvalidBeaconVersionError` if either operand is not a decimal-\n * integer string in `[0, Number.MAX_SAFE_INTEGER]`. Leading signs, leading\n * zeros, decimal points, exponent notation, hex, whitespace, `'NaN'` and\n * `'Infinity'` all reject.\n *\n * @category Utility\n */\nexport const compareBeaconVersion = (a: unknown, b: unknown): number => {\n const na = parseStrictDecimalInteger(a)\n const nb = parseStrictDecimalInteger(b)\n\n if (na === null || nb === null) {\n throw new InvalidBeaconVersionError(a, b)\n }\n\n return na - nb\n}\n\n/**\n * Whether `version` is a valid peer.version at or above `threshold`.\n *\n * Single source of truth for the \"is this peer at least version X\" decision.\n * Returns `false` for an absent version and for any value that fails the\n * strict decimal-integer contract of `compareBeaconVersion` — i.e. malformed\n * or untrusted input is always treated as below the threshold, so a hostile\n * peer cannot trip a higher-version code path.\n *\n * @category Utility\n */\nexport const isAtLeastVersion = (version: string | undefined, threshold: string): boolean => {\n if (version === undefined) {\n return false\n }\n try {\n return compareBeaconVersion(version, threshold) >= 0\n } catch {\n return false\n }\n}\n\n/**\n * Whether `version` is at or above the multi-network (v4) threshold.\n *\n * @category Utility\n */\nexport const isMultiNetworkVersion = (version: string | undefined): boolean =>\n isAtLeastVersion(version, MULTI_NETWORK_FROM_VERSION)\n\nexport const usesWrappedMessages = (version?: string): boolean => {\n // Use the same strict decimal-integer contract as compareBeaconVersion so\n // wrapped-message routing agrees with the v4/multi-network routing: a loose\n // value like '3.0', ' 3 ' or '03' (which Number() would accept) is treated\n // as malformed and routed as non-wrapped rather than inconsistently.\n const parsed = parseStrictDecimalInteger(version)\n\n return parsed !== null && parsed >= MESSAGE_WRAPPED_FROM_VERSION\n}\n\n/** The flat legacy wire dialect served to peers below the wrapped baseline. */\nexport const LEGACY_ENVELOPE_VERSION = '2'\n\n/**\n * The envelope version to stamp on an outgoing message for a peer that\n * declared `peerVersion` at pairing: `min(peerVersion, BEACON_VERSION)` with\n * a floor at the flat legacy dialect ('2').\n *\n * This is the backward-compatibility pivot: a peer that declared '2' — or\n * never declared a version at all (legacy pairings, WalletConnect peers,\n * malformed values) — is served the flat v2 dialect it has always spoken; a\n * v3 peer receives '3' wrapped envelopes and never sees v4 payload fields;\n * a v4 peer gets the full wrapped v4 wire. Callers pick the message SHAPE\n * with `usesWrappedMessages(negotiated)` and gate v4 fields (`networks`/\n * `accounts`) on `isMultiNetworkVersion(negotiated)`.\n *\n * @category Utility\n */\nexport const negotiateEnvelopeVersion = (peerVersion: string | undefined): string => {\n if (!isAtLeastVersion(peerVersion, String(MESSAGE_WRAPPED_FROM_VERSION))) {\n return LEGACY_ENVELOPE_VERSION\n }\n\n return isAtLeastVersion(peerVersion, BEACON_VERSION) ? BEACON_VERSION : (peerVersion as string)\n}\n\n/**\n * The peer's version as safe to feed into capability negotiation\n * ({@link negotiateEnvelopeVersion}, multi-network gating, minimum-version\n * enforcement).\n *\n * `peer.version` alone CANNOT be trusted: legacy wallets (octez.connect\n * 4.8.x and upstream beacon-sdk forks) build their pairing response with the\n * version field of the dApp's pairing REQUEST — they echo the dApp's own\n * version back instead of declaring theirs. A v5 dApp reading that echo sees\n * '4', serves a wrapped v4 envelope, and the legacy wallet silently drops it\n * after pairing (\"Pairing complete! Waiting for permission request…\").\n *\n * The reliable capability marker is `protocolVersion`: v5+ pairing responses\n * attach it on every transport that can carry it (P2P, PostMessage), legacy\n * responses never do, and it cannot be echoed (legacy constructors don't\n * know the field). A peer that DECLARES a version without a valid marker\n * (a positive protocol version, matching the protocol's minimum of 1) is\n * therefore treated as a legacy flat-v2 speaker regardless of its echoed\n * `version` — exactly the wire a 4.8.x dApp would have served it.\n *\n * A peer that declares NO version at all keeps the long-standing \"unknown\"\n * semantics and maps to `undefined` (WalletConnect pairings, where beacon\n * versions are never fabricated and capability is negotiated via session\n * namespaces): version gates treat unknown as allowed-through and response\n * handling falls back to the response envelope's version. The echo problem\n * by definition only exists for peers that DO carry a version.\n *\n * @category Utility\n */\nexport const effectivePeerVersion = (\n peer: { version?: string; protocolVersion?: unknown } | undefined\n): string | undefined => {\n if (!peer || peer.version == null) {\n return undefined\n }\n // `Number(null)` is 0 (finite) — treat null like absent, not like v5.\n const protocolRaw = peer.protocolVersion == null ? Number.NaN : Number(peer.protocolVersion)\n\n // Positive protocol versions only (the protocol's minimum is 1): `0`,\n // negatives, and non-numeric noise are malformed markers and must stay on\n // the legacy path, like an absent marker.\n return Number.isFinite(protocolRaw) && protocolRaw >= 1 ? peer.version : LEGACY_ENVELOPE_VERSION\n}\n\n/**\n * Build a wrapped beacon envelope. Single source of truth for the\n * `{ id, version, senderId, message }` wire shape so senders cannot drift.\n *\n * @category Utility\n */\nexport const wrapBeaconMessage = <T extends WrappedPayload>(\n envelope: { id: string; version: string; senderId: string },\n message: T\n): BeaconMessageWrapper<T> => ({\n id: envelope.id,\n version: envelope.version,\n senderId: envelope.senderId,\n message\n})\n\n/**\n * Extract the inner payload of a wrapped beacon envelope, or `undefined`\n * when the candidate's version does not follow the wrapped (v3+) contract.\n * Callers must treat `undefined` as \"not a wrapped message\" and drop or\n * tombstone it — never fall back to reading flat fields.\n *\n * @category Utility\n */\nexport const unwrapBeaconMessage = <T extends WrappedPayload>(candidate: {\n version?: string\n message?: T\n}): T | undefined => (usesWrappedMessages(candidate.version) ? candidate.message : undefined)\n\n/**\n * Build a disconnect message in the peer's negotiated dialect: a wrapped\n * envelope for v3+ peers, the flat legacy shape for v2 peers. A legacy peer\n * routes on the top-level `type` and would silently ignore a wrapped\n * envelope — the goodbye must be spoken in the dialect the peer parses.\n *\n * @category Utility\n */\nexport const buildDisconnectMessage = (\n envelope: { id: string; senderId: string },\n peerVersion: string | undefined\n): DisconnectMessage | BeaconMessageWrapper<{ type: BeaconMessageType.Disconnect }> => {\n const version = negotiateEnvelopeVersion(peerVersion)\n\n return usesWrappedMessages(version)\n ? wrapBeaconMessage(\n { id: envelope.id, version, senderId: envelope.senderId },\n { type: BeaconMessageType.Disconnect }\n )\n : {\n id: envelope.id,\n version,\n senderId: envelope.senderId,\n type: BeaconMessageType.Disconnect\n }\n}\n"]}
|
package/dist/esm/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tezos-x/octez.connect-core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "This package contains internal methods that are used by both the dApp and wallet client.",
|
|
5
5
|
"author": "Blockchain Infra <blockchain.infra@trili.tech>",
|
|
6
6
|
"homepage": "https://octez-connect.tezos.com",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@stablelib/nacl": "^2.0.1",
|
|
39
39
|
"@stablelib/utf8": "^2.1.0",
|
|
40
40
|
"@stablelib/x25519-session": "^2.0.1",
|
|
41
|
-
"@tezos-x/octez.connect-types": "5.0.
|
|
42
|
-
"@tezos-x/octez.connect-utils": "5.0.
|
|
41
|
+
"@tezos-x/octez.connect-types": "5.0.3",
|
|
42
|
+
"@tezos-x/octez.connect-utils": "5.0.3",
|
|
43
43
|
"broadcast-channel": "^7.3.0",
|
|
44
44
|
"bs58check": "4.0.0"
|
|
45
45
|
}
|
|
@@ -6,7 +6,7 @@ import { AccountManager } from '../../managers/AccountManager';
|
|
|
6
6
|
import { getSenderId } from '../../utils/get-sender-id';
|
|
7
7
|
import { Logger } from '../../utils/Logger';
|
|
8
8
|
import { Serializer } from '../../Serializer';
|
|
9
|
-
import { buildDisconnectMessage } from '../../utils/message-utils';
|
|
9
|
+
import { buildDisconnectMessage, effectivePeerVersion } from '../../utils/message-utils';
|
|
10
10
|
import { getPreferredMessageProtocolVersion } from '../../message-protocol';
|
|
11
11
|
const logger = new Logger('Client');
|
|
12
12
|
/**
|
|
@@ -217,7 +217,7 @@ export class Client extends BeaconClient {
|
|
|
217
217
|
// The disconnect ships in the peer's negotiated dialect: wrapped for
|
|
218
218
|
// v3+ peers, the flat legacy shape for v2 peers (which would silently
|
|
219
219
|
// ignore a wrapped envelope).
|
|
220
|
-
const request = buildDisconnectMessage({ id, senderId }, peer
|
|
220
|
+
const request = buildDisconnectMessage({ id, senderId }, effectivePeerVersion(peer));
|
|
221
221
|
const protocolVersion = this.getPeerProtocolVersion(peer);
|
|
222
222
|
const payload = await new Serializer(protocolVersion).serialize(request);
|
|
223
223
|
const selectedTransport = transport ?? (await this.transport);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.js","sourceRoot":"","sources":["../../../../../src/clients/client/Client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3E,OAAO,EA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KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA;IACnE,CAAC;IAEO,uBAAuB;QAC7B,MAAM,iBAAiB,GAAG,MAAM,CAAC,kCAAkC,EAAE,CAAC,CAAA;QACtE,OAAO,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,IAAI,wBAAwB;YACxF,CAAC,CAAC,iBAAiB;YACnB,CAAC,CAAC,wBAAwB,CAAA;IAC9B,CAAC;IAEO,0BAA0B,CAAC,IAAe;QAChD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,wBAAwB,CAAA;QACjC,CAAC;QAED,MAAM,eAAe,GACnB,OAAO,IAAI,CAAC,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QAEhG,OAAO,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,eAAe,IAAI,wBAAwB;YACpF,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,wBAAwB,CAAA;IAC9B,CAAC;IAES,sBAAsB,CAAC,IAAe;QAC9C,MAAM,YAAY,GAAG,IAAI,CAAC,uBAAuB,EAAE,CAAA;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAA;QACzD,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IAC5C,CAAC;CACF","sourcesContent":["import { ExposedPromise, generateGUID } from '@tezos-x/octez.connect-utils'\nimport {\n ConnectionContext,\n TransportType,\n TransportStatus,\n BeaconBaseMessage,\n AccountInfo,\n PeerInfo,\n AppMetadata,\n BeaconRequestMessage,\n BeaconMessageWrapper,\n NodeDistributions,\n Blockchain\n} from '@tezos-x/octez.connect-types'\nimport { DEFAULT_PROTOCOL_VERSION } from '../../constants'\nimport { BeaconClient } from '../beacon-client/BeaconClient'\nimport { AccountManager } from '../../managers/AccountManager'\nimport { getSenderId } from '../../utils/get-sender-id'\nimport { Logger } from '../../utils/Logger'\nimport { ClientOptions } from './ClientOptions'\nimport { Transport } from '../../transports/Transport'\nimport { Serializer } from '../../Serializer'\nimport { buildDisconnectMessage } from '../../utils/message-utils'\nimport { getPreferredMessageProtocolVersion } from '../../message-protocol'\n\nconst logger = new Logger('Client')\n\n/**\n * @internalapi\n *\n * This abstract class handles the a big part of the logic that is shared between the dapp and wallet client.\n * For example, it selects and manages the transport and accounts.\n */\nexport abstract class Client extends BeaconClient {\n protected readonly accountManager: AccountManager\n protected readonly blockchains: Map<string, Blockchain> = new Map()\n\n protected handleResponse: (\n _event: BeaconRequestMessage | BeaconMessageWrapper<BeaconBaseMessage>,\n connectionInfo: ConnectionContext\n ) => void\n\n /**\n * How many requests can be sent after another\n */\n protected readonly rateLimit: number = 2\n /**\n * The time window in seconds in which the \"rateLimit\" is checked\n */\n protected readonly rateLimitWindowInSeconds: number = 5\n\n /**\n * Stores the times when requests have been made to determine if the rate limit has been reached\n */\n protected requestCounter: number[] = []\n\n protected readonly matrixNodes: NodeDistributions\n\n private transportListeners: Map<\n TransportType,\n (message: any, connectionInfo: ConnectionContext) => Promise<void>\n > = new Map()\n\n protected _transport: ExposedPromise<Transport<any>> = new ExposedPromise()\n protected get transport(): Promise<Transport<any>> {\n return this._transport.promise\n }\n\n /**\n * Returns the connection status of the Client\n */\n public get connectionStatus(): TransportStatus {\n return this._transport.promiseResult?.connectionStatus ?? TransportStatus.NOT_CONNECTED\n }\n\n /**\n * Returns whether or not the transaport is ready\n */\n public get ready(): Promise<void> {\n return this.transport.then(() => undefined)\n }\n\n constructor(config: ClientOptions) {\n super(config)\n\n this.accountManager = new AccountManager(config.storage)\n this.matrixNodes = config.matrixNodes ?? {}\n\n this.handleResponse = (\n message: BeaconBaseMessage | BeaconMessageWrapper<BeaconBaseMessage>,\n connectionInfo: ConnectionContext\n ): void => {\n throw new Error(\n `not overwritten${JSON.stringify(message)} - ${JSON.stringify(connectionInfo)}`\n )\n }\n }\n protected async cleanup() {\n if (!this.transportListeners.size) {\n return\n }\n\n if (this._transport.isResolved()) {\n const transport = await this.transport\n await Promise.all(\n Array.from(this.transportListeners.values()).map((listener) =>\n transport.removeListener(listener)\n )\n )\n this.transportListeners.clear()\n }\n }\n\n /**\n * Register a blockchain to the client\n * @param chain The blockchain to register\n */\n public addBlockchain(chain: Blockchain) {\n this.blockchains.set(chain.identifier, chain)\n for (const legacyIdentifier of chain.legacyIdentifiers ?? []) {\n this.blockchains.set(legacyIdentifier, chain)\n }\n }\n\n /**\n * Remove a blockchain from the client by its identifier\n * @param chainIdentifier The identifier of the blockchain to remove\n */\n public removeBlockchain(chainIdentifier: string) {\n const chain = this.blockchains.get(chainIdentifier)\n this.blockchains.delete(chainIdentifier)\n for (const legacyIdentifier of chain?.legacyIdentifiers ?? []) {\n this.blockchains.delete(legacyIdentifier)\n }\n }\n\n /**\n * Return all locally known accounts\n */\n public async getAccounts(): Promise<AccountInfo[]> {\n return this.accountManager.getAccounts()\n }\n\n /**\n * Return the account by ID\n * @param accountIdentifier The ID of an account\n */\n public async getAccount(accountIdentifier: string): Promise<AccountInfo | undefined> {\n return this.accountManager.getAccount(accountIdentifier)\n }\n\n /**\n * Remove the account by ID\n * @param accountIdentifier The ID of an account\n */\n public async removeAccount(accountIdentifier: string): Promise<void> {\n return this.accountManager.removeAccount(accountIdentifier)\n }\n\n /**\n * Remove all locally stored accounts\n */\n public async removeAllAccounts(): Promise<void> {\n return this.accountManager.removeAllAccounts()\n }\n\n /**\n * Add a new request (current timestamp) to the pending requests, remove old ones and check if we are above the limit\n */\n public async addRequestAndCheckIfRateLimited(): Promise<boolean> {\n const now: number = new Date().getTime()\n this.requestCounter = this.requestCounter.filter(\n (date) => date + this.rateLimitWindowInSeconds * 1000 > now\n )\n\n this.requestCounter.push(now)\n\n return this.requestCounter.length > this.rateLimit\n }\n\n /**\n * This method initializes the client. It will check if the connection should be established to a\n * browser extension or if the P2P transport should be used.\n *\n * @param transport A transport that can be provided by the user\n */\n public async init(transport: Transport<any, any, any>): Promise<TransportType> {\n if (this._transport.isResolved()) {\n return (await this.transport).type\n }\n\n await this.setTransport(transport) // Let users define their own transport\n\n return transport.type\n }\n\n /**\n * Returns the metadata of this DApp\n */\n public async getOwnAppMetadata(): Promise<AppMetadata> {\n return {\n senderId: await getSenderId(await this.beaconId),\n name: this.name,\n icon: this.iconUrl\n }\n }\n\n /**\n * Return all known peers\n */\n public async getPeers(): Promise<PeerInfo[]> {\n return (await this.transport).getPeers()\n }\n\n /**\n * Add a new peer to the known peers\n * @param peer The new peer to add\n */\n public async addPeer(peer: PeerInfo): Promise<void> {\n return (await this.transport).addPeer(peer)\n }\n\n public async destroy(): Promise<void> {\n if (this._transport.isResolved()) {\n const transport = await this.transport\n await this.cleanup()\n await transport.disconnect()\n if (transport.type === TransportType.WALLETCONNECT) {\n await (transport as any).doClientCleanup() // any because I cannot import the type definition\n }\n }\n await super.destroy()\n }\n\n /**\n * A \"setter\" for when the transport needs to be changed.\n */\n protected async setTransport(transport?: Transport<any>): Promise<void> {\n if (transport) {\n if (this._transport.isSettled()) {\n // If the promise has already been resolved we need to create a new one.\n this._transport = ExposedPromise.resolve(transport)\n } else {\n this._transport.resolve(transport)\n }\n } else {\n if (this._transport.isSettled()) {\n // If the promise has already been resolved we need to create a new one.\n this._transport = new ExposedPromise()\n }\n }\n }\n\n protected async addListener(transport: Transport<any>): Promise<void> {\n // in beacon we subscribe to the transport on client init only\n // unsubscribing from the transport is only beneficial when running\n // a single page dApp.\n // However, while running a multiple tabs setup, if one of the dApps disconnects\n // the others wont't recover until after a page refresh\n\n if (this.transportListeners.has(transport.type)) {\n await transport.removeListener(this.transportListeners.get(transport.type)!)\n }\n\n const subscription = async (message: any, connectionInfo: ConnectionContext) => {\n if (typeof message !== 'string') {\n return\n }\n\n const peer = await this.findPeer(connectionInfo.id)\n const protocolVersion = this.getPeerProtocolVersion(peer)\n\n const deserializedMessage = (await new Serializer(protocolVersion).deserialize(\n message\n )) as BeaconRequestMessage\n this.handleResponse(deserializedMessage, connectionInfo)\n }\n\n this.transportListeners.set(transport.type, subscription)\n\n transport.addListener(subscription).catch((error) => logger.error('addListener', error))\n }\n\n protected async sendDisconnectToPeer(peer: PeerInfo, transport?: Transport<any>): Promise<void> {\n const id = await generateGUID()\n const senderId = await getSenderId(await this.beaconId)\n\n // The disconnect ships in the peer's negotiated dialect: wrapped for\n // v3+ peers, the flat legacy shape for v2 peers (which would silently\n // ignore a wrapped envelope).\n const request = buildDisconnectMessage({ id, senderId }, peer.version)\n\n const protocolVersion = this.getPeerProtocolVersion(peer)\n const payload = await new Serializer(protocolVersion).serialize(request)\n const selectedTransport = transport ?? (await this.transport)\n\n await selectedTransport.send(payload, peer)\n }\n\n protected async findPeer(publicKey?: string): Promise<PeerInfo | undefined> {\n if (!publicKey) {\n return undefined\n }\n\n const transport = await this.transport\n const peers = await transport.getPeers()\n return peers.find((peerInfo) => peerInfo.publicKey === publicKey)\n }\n\n private getLocalProtocolVersion(): number {\n const localPreferredRaw = Number(getPreferredMessageProtocolVersion())\n return Number.isFinite(localPreferredRaw) && localPreferredRaw >= DEFAULT_PROTOCOL_VERSION\n ? localPreferredRaw\n : DEFAULT_PROTOCOL_VERSION\n }\n\n private extractPeerProtocolVersion(peer?: PeerInfo): number {\n if (!peer) {\n return DEFAULT_PROTOCOL_VERSION\n }\n\n const peerProtocolRaw =\n typeof peer.protocolVersion === 'number' ? peer.protocolVersion : Number(peer.protocolVersion)\n\n return Number.isFinite(peerProtocolRaw) && peerProtocolRaw >= DEFAULT_PROTOCOL_VERSION\n ? peerProtocolRaw\n : DEFAULT_PROTOCOL_VERSION\n }\n\n protected getPeerProtocolVersion(peer?: PeerInfo): number {\n const localVersion = this.getLocalProtocolVersion()\n const peerVersion = this.extractPeerProtocolVersion(peer)\n return Math.min(peerVersion, localVersion)\n }\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\n ConnectionContext,\n TransportType,\n TransportStatus,\n BeaconBaseMessage,\n AccountInfo,\n PeerInfo,\n AppMetadata,\n BeaconRequestMessage,\n BeaconMessageWrapper,\n NodeDistributions,\n Blockchain\n} from '@tezos-x/octez.connect-types'\nimport { DEFAULT_PROTOCOL_VERSION } from '../../constants'\nimport { BeaconClient } from '../beacon-client/BeaconClient'\nimport { AccountManager } from '../../managers/AccountManager'\nimport { getSenderId } from '../../utils/get-sender-id'\nimport { Logger } from '../../utils/Logger'\nimport { ClientOptions } from './ClientOptions'\nimport { Transport } from '../../transports/Transport'\nimport { Serializer } from '../../Serializer'\nimport { buildDisconnectMessage, effectivePeerVersion } from '../../utils/message-utils'\nimport { getPreferredMessageProtocolVersion } from '../../message-protocol'\n\nconst logger = new Logger('Client')\n\n/**\n * @internalapi\n *\n * This abstract class handles the a big part of the logic that is shared between the dapp and wallet client.\n * For example, it selects and manages the transport and accounts.\n */\nexport abstract class Client extends BeaconClient {\n protected readonly accountManager: AccountManager\n protected readonly blockchains: Map<string, Blockchain> = new Map()\n\n protected handleResponse: (\n _event: BeaconRequestMessage | BeaconMessageWrapper<BeaconBaseMessage>,\n connectionInfo: ConnectionContext\n ) => void\n\n /**\n * How many requests can be sent after another\n */\n protected readonly rateLimit: number = 2\n /**\n * The time window in seconds in which the \"rateLimit\" is checked\n */\n protected readonly rateLimitWindowInSeconds: number = 5\n\n /**\n * Stores the times when requests have been made to determine if the rate limit has been reached\n */\n protected requestCounter: number[] = []\n\n protected readonly matrixNodes: NodeDistributions\n\n private transportListeners: Map<\n TransportType,\n (message: any, connectionInfo: ConnectionContext) => Promise<void>\n > = new Map()\n\n protected _transport: ExposedPromise<Transport<any>> = new ExposedPromise()\n protected get transport(): Promise<Transport<any>> {\n return this._transport.promise\n }\n\n /**\n * Returns the connection status of the Client\n */\n public get connectionStatus(): TransportStatus {\n return this._transport.promiseResult?.connectionStatus ?? TransportStatus.NOT_CONNECTED\n }\n\n /**\n * Returns whether or not the transaport is ready\n */\n public get ready(): Promise<void> {\n return this.transport.then(() => undefined)\n }\n\n constructor(config: ClientOptions) {\n super(config)\n\n this.accountManager = new AccountManager(config.storage)\n this.matrixNodes = config.matrixNodes ?? {}\n\n this.handleResponse = (\n message: BeaconBaseMessage | BeaconMessageWrapper<BeaconBaseMessage>,\n connectionInfo: ConnectionContext\n ): void => {\n throw new Error(\n `not overwritten${JSON.stringify(message)} - ${JSON.stringify(connectionInfo)}`\n )\n }\n }\n protected async cleanup() {\n if (!this.transportListeners.size) {\n return\n }\n\n if (this._transport.isResolved()) {\n const transport = await this.transport\n await Promise.all(\n Array.from(this.transportListeners.values()).map((listener) =>\n transport.removeListener(listener)\n )\n )\n this.transportListeners.clear()\n }\n }\n\n /**\n * Register a blockchain to the client\n * @param chain The blockchain to register\n */\n public addBlockchain(chain: Blockchain) {\n this.blockchains.set(chain.identifier, chain)\n for (const legacyIdentifier of chain.legacyIdentifiers ?? []) {\n this.blockchains.set(legacyIdentifier, chain)\n }\n }\n\n /**\n * Remove a blockchain from the client by its identifier\n * @param chainIdentifier The identifier of the blockchain to remove\n */\n public removeBlockchain(chainIdentifier: string) {\n const chain = this.blockchains.get(chainIdentifier)\n this.blockchains.delete(chainIdentifier)\n for (const legacyIdentifier of chain?.legacyIdentifiers ?? []) {\n this.blockchains.delete(legacyIdentifier)\n }\n }\n\n /**\n * Return all locally known accounts\n */\n public async getAccounts(): Promise<AccountInfo[]> {\n return this.accountManager.getAccounts()\n }\n\n /**\n * Return the account by ID\n * @param accountIdentifier The ID of an account\n */\n public async getAccount(accountIdentifier: string): Promise<AccountInfo | undefined> {\n return this.accountManager.getAccount(accountIdentifier)\n }\n\n /**\n * Remove the account by ID\n * @param accountIdentifier The ID of an account\n */\n public async removeAccount(accountIdentifier: string): Promise<void> {\n return this.accountManager.removeAccount(accountIdentifier)\n }\n\n /**\n * Remove all locally stored accounts\n */\n public async removeAllAccounts(): Promise<void> {\n return this.accountManager.removeAllAccounts()\n }\n\n /**\n * Add a new request (current timestamp) to the pending requests, remove old ones and check if we are above the limit\n */\n public async addRequestAndCheckIfRateLimited(): Promise<boolean> {\n const now: number = new Date().getTime()\n this.requestCounter = this.requestCounter.filter(\n (date) => date + this.rateLimitWindowInSeconds * 1000 > now\n )\n\n this.requestCounter.push(now)\n\n return this.requestCounter.length > this.rateLimit\n }\n\n /**\n * This method initializes the client. It will check if the connection should be established to a\n * browser extension or if the P2P transport should be used.\n *\n * @param transport A transport that can be provided by the user\n */\n public async init(transport: Transport<any, any, any>): Promise<TransportType> {\n if (this._transport.isResolved()) {\n return (await this.transport).type\n }\n\n await this.setTransport(transport) // Let users define their own transport\n\n return transport.type\n }\n\n /**\n * Returns the metadata of this DApp\n */\n public async getOwnAppMetadata(): Promise<AppMetadata> {\n return {\n senderId: await getSenderId(await this.beaconId),\n name: this.name,\n icon: this.iconUrl\n }\n }\n\n /**\n * Return all known peers\n */\n public async getPeers(): Promise<PeerInfo[]> {\n return (await this.transport).getPeers()\n }\n\n /**\n * Add a new peer to the known peers\n * @param peer The new peer to add\n */\n public async addPeer(peer: PeerInfo): Promise<void> {\n return (await this.transport).addPeer(peer)\n }\n\n public async destroy(): Promise<void> {\n if (this._transport.isResolved()) {\n const transport = await this.transport\n await this.cleanup()\n await transport.disconnect()\n if (transport.type === TransportType.WALLETCONNECT) {\n await (transport as any).doClientCleanup() // any because I cannot import the type definition\n }\n }\n await super.destroy()\n }\n\n /**\n * A \"setter\" for when the transport needs to be changed.\n */\n protected async setTransport(transport?: Transport<any>): Promise<void> {\n if (transport) {\n if (this._transport.isSettled()) {\n // If the promise has already been resolved we need to create a new one.\n this._transport = ExposedPromise.resolve(transport)\n } else {\n this._transport.resolve(transport)\n }\n } else {\n if (this._transport.isSettled()) {\n // If the promise has already been resolved we need to create a new one.\n this._transport = new ExposedPromise()\n }\n }\n }\n\n protected async addListener(transport: Transport<any>): Promise<void> {\n // in beacon we subscribe to the transport on client init only\n // unsubscribing from the transport is only beneficial when running\n // a single page dApp.\n // However, while running a multiple tabs setup, if one of the dApps disconnects\n // the others wont't recover until after a page refresh\n\n if (this.transportListeners.has(transport.type)) {\n await transport.removeListener(this.transportListeners.get(transport.type)!)\n }\n\n const subscription = async (message: any, connectionInfo: ConnectionContext) => {\n if (typeof message !== 'string') {\n return\n }\n\n const peer = await this.findPeer(connectionInfo.id)\n const protocolVersion = this.getPeerProtocolVersion(peer)\n\n const deserializedMessage = (await new Serializer(protocolVersion).deserialize(\n message\n )) as BeaconRequestMessage\n this.handleResponse(deserializedMessage, connectionInfo)\n }\n\n this.transportListeners.set(transport.type, subscription)\n\n transport.addListener(subscription).catch((error) => logger.error('addListener', error))\n }\n\n protected async sendDisconnectToPeer(peer: PeerInfo, transport?: Transport<any>): Promise<void> {\n const id = await generateGUID()\n const senderId = await getSenderId(await this.beaconId)\n\n // The disconnect ships in the peer's negotiated dialect: wrapped for\n // v3+ peers, the flat legacy shape for v2 peers (which would silently\n // ignore a wrapped envelope).\n const request = buildDisconnectMessage({ id, senderId }, effectivePeerVersion(peer))\n\n const protocolVersion = this.getPeerProtocolVersion(peer)\n const payload = await new Serializer(protocolVersion).serialize(request)\n const selectedTransport = transport ?? (await this.transport)\n\n await selectedTransport.send(payload, peer)\n }\n\n protected async findPeer(publicKey?: string): Promise<PeerInfo | undefined> {\n if (!publicKey) {\n return undefined\n }\n\n const transport = await this.transport\n const peers = await transport.getPeers()\n return peers.find((peerInfo) => peerInfo.publicKey === publicKey)\n }\n\n private getLocalProtocolVersion(): number {\n const localPreferredRaw = Number(getPreferredMessageProtocolVersion())\n return Number.isFinite(localPreferredRaw) && localPreferredRaw >= DEFAULT_PROTOCOL_VERSION\n ? localPreferredRaw\n : DEFAULT_PROTOCOL_VERSION\n }\n\n private extractPeerProtocolVersion(peer?: PeerInfo): number {\n if (!peer) {\n return DEFAULT_PROTOCOL_VERSION\n }\n\n const peerProtocolRaw =\n typeof peer.protocolVersion === 'number' ? peer.protocolVersion : Number(peer.protocolVersion)\n\n return Number.isFinite(peerProtocolRaw) && peerProtocolRaw >= DEFAULT_PROTOCOL_VERSION\n ? peerProtocolRaw\n : DEFAULT_PROTOCOL_VERSION\n }\n\n protected getPeerProtocolVersion(peer?: PeerInfo): number {\n const localVersion = this.getLocalProtocolVersion()\n const peerVersion = this.extractPeerProtocolVersion(peer)\n return Math.min(peerVersion, localVersion)\n }\n}\n"]}
|
|
@@ -6,3 +6,12 @@ export declare const LATEST_PROTOCOL_VERSION = 2;
|
|
|
6
6
|
export declare const DEFAULT_PROTOCOL_VERSION = 1;
|
|
7
7
|
export declare const NOTIFICATION_ORACLE_URL: string;
|
|
8
8
|
export declare const BACKEND_URL: string;
|
|
9
|
+
/**
|
|
10
|
+
* Shared ecosystem WalletConnect Cloud projectId, applied by default so dApps
|
|
11
|
+
* can offer WalletConnect wallets (e.g. Kukai Mobile) without registering
|
|
12
|
+
* their own project — WalletConnect's free tier comfortably covers the Tezos
|
|
13
|
+
* ecosystem's volume. Override per dApp via
|
|
14
|
+
* `DAppClientOptions.walletConnectOptions.projectId`; opt out entirely via
|
|
15
|
+
* `disableWalletConnect`. Same id that 4.8.x shipped as its built-in default.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_WALLETCONNECT_PROJECT_ID = "24469fd0a06df227b6e5f7dc7de0ff4f";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const SDK_VERSION = '5.0.
|
|
1
|
+
export const SDK_VERSION = '5.0.3';
|
|
2
2
|
export const BEACON_VERSION = '4';
|
|
3
3
|
export const PROTOCOL_VERSION_V1 = 1;
|
|
4
4
|
export const PROTOCOL_VERSION_V2 = 2;
|
|
@@ -6,4 +6,13 @@ export const LATEST_PROTOCOL_VERSION = PROTOCOL_VERSION_V2;
|
|
|
6
6
|
export const DEFAULT_PROTOCOL_VERSION = PROTOCOL_VERSION_V1;
|
|
7
7
|
export const NOTIFICATION_ORACLE_URL = 'https://beacon-notification-oracle.dev.gke.papers.tech';
|
|
8
8
|
export const BACKEND_URL = 'https://beacon-backend.prod.gke.papers.tech';
|
|
9
|
+
/**
|
|
10
|
+
* Shared ecosystem WalletConnect Cloud projectId, applied by default so dApps
|
|
11
|
+
* can offer WalletConnect wallets (e.g. Kukai Mobile) without registering
|
|
12
|
+
* their own project — WalletConnect's free tier comfortably covers the Tezos
|
|
13
|
+
* ecosystem's volume. Override per dApp via
|
|
14
|
+
* `DAppClientOptions.walletConnectOptions.projectId`; opt out entirely via
|
|
15
|
+
* `disableWalletConnect`. Same id that 4.8.x shipped as its built-in default.
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_WALLETCONNECT_PROJECT_ID = '24469fd0a06df227b6e5f7dc7de0ff4f';
|
|
9
18
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAW,OAAO,CAAA;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAW,GAAG,CAAA;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AACpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAA;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAA;AAE3D,MAAM,CAAC,MAAM,uBAAuB,GAClC,wDAAwD,CAAA;AAE1D,MAAM,CAAC,MAAM,WAAW,GAAW,6CAA6C,CAAA","sourcesContent":["export const SDK_VERSION: string = '5.0.
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAW,OAAO,CAAA;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAW,GAAG,CAAA;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AACpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,mBAAmB,CAAA;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAA;AAE3D,MAAM,CAAC,MAAM,uBAAuB,GAClC,wDAAwD,CAAA;AAE1D,MAAM,CAAC,MAAM,WAAW,GAAW,6CAA6C,CAAA;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,kCAAkC,CAAA","sourcesContent":["export const SDK_VERSION: string = '5.0.3'\nexport const BEACON_VERSION: string = '4'\nexport const PROTOCOL_VERSION_V1 = 1\nexport const PROTOCOL_VERSION_V2 = 2\nexport const LATEST_PROTOCOL_VERSION = PROTOCOL_VERSION_V2\nexport const DEFAULT_PROTOCOL_VERSION = PROTOCOL_VERSION_V1\n\nexport const NOTIFICATION_ORACLE_URL: string =\n 'https://beacon-notification-oracle.dev.gke.papers.tech'\n\nexport const BACKEND_URL: string = 'https://beacon-backend.prod.gke.papers.tech'\n\n/**\n * Shared ecosystem WalletConnect Cloud projectId, applied by default so dApps\n * can offer WalletConnect wallets (e.g. Kukai Mobile) without registering\n * their own project — WalletConnect's free tier comfortably covers the Tezos\n * ecosystem's volume. Override per dApp via\n * `DAppClientOptions.walletConnectOptions.projectId`; opt out entirely via\n * `disableWalletConnect`. Same id that 4.8.x shipped as its built-in default.\n */\nexport const DEFAULT_WALLETCONNECT_PROJECT_ID = '24469fd0a06df227b6e5f7dc7de0ff4f'\n"]}
|
package/dist/esm/src/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { LocalStorage } from './storage/LocalStorage';
|
|
|
19
19
|
import { getStorage } from './storage/getStorage';
|
|
20
20
|
import { Serializer } from './Serializer';
|
|
21
21
|
import { ClientOptions } from './clients/client/ClientOptions';
|
|
22
|
-
import { SDK_VERSION, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION } from './constants';
|
|
22
|
+
import { SDK_VERSION, DEFAULT_WALLETCONNECT_PROJECT_ID, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION } from './constants';
|
|
23
23
|
import { getPreferredMessageProtocolVersion, setPreferredMessageProtocolVersion } from './message-protocol';
|
|
24
24
|
import { AccountManager } from './managers/AccountManager';
|
|
25
25
|
import { AppMetadataManager } from './managers/AppMetadataManager';
|
|
@@ -51,9 +51,9 @@ export { getError, BeaconError, AbortedBeaconError, BroadcastBeaconError, Networ
|
|
|
51
51
|
export { Transport, MessageBasedClient, CommunicationClient };
|
|
52
52
|
export { ChromeStorage, LocalStorage, WCStorage, IndexedDBStorage, StorageValidator, getStorage };
|
|
53
53
|
export { PeerManager, AccountManager, AppMetadataManager, PermissionManager };
|
|
54
|
-
export { SDK_VERSION, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION, getPreferredMessageProtocolVersion, setPreferredMessageProtocolVersion };
|
|
54
|
+
export { SDK_VERSION, DEFAULT_WALLETCONNECT_PROJECT_ID, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION, getPreferredMessageProtocolVersion, setPreferredMessageProtocolVersion };
|
|
55
55
|
export { getSenderId, getAccountIdentifier, windowRef, MultiTabChannel };
|
|
56
|
-
export { usesWrappedMessages, MESSAGE_WRAPPED_FROM_VERSION, MULTI_NETWORK_FROM_VERSION, compareBeaconVersion, isAtLeastVersion, isMultiNetworkVersion, negotiateEnvelopeVersion, wrapBeaconMessage, unwrapBeaconMessage } from './utils/message-utils';
|
|
56
|
+
export { usesWrappedMessages, MESSAGE_WRAPPED_FROM_VERSION, MULTI_NETWORK_FROM_VERSION, compareBeaconVersion, isAtLeastVersion, isMultiNetworkVersion, negotiateEnvelopeVersion, effectivePeerVersion, wrapBeaconMessage, unwrapBeaconMessage } from './utils/message-utils';
|
|
57
57
|
export { normalizeTezosCaip2, isValidTezosCaip2, networkFromTezosCaip2, TEZOS_NETWORK_GENESIS_IDS, tezosCaip2FromNetworkType, networkTypeFromTezosCaip2 } from './utils/caip2';
|
|
58
58
|
export { assertNever } from './utils/assert-never';
|
|
59
59
|
export { resolveRequiredMinimumVersion } from './utils/required-minimum-version';
|
package/dist/esm/src/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { ChromeStorage } from './storage/ChromeStorage';
|
|
|
18
18
|
import { LocalStorage } from './storage/LocalStorage';
|
|
19
19
|
import { getStorage } from './storage/getStorage';
|
|
20
20
|
import { Serializer } from './Serializer';
|
|
21
|
-
import { SDK_VERSION, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION } from './constants';
|
|
21
|
+
import { SDK_VERSION, DEFAULT_WALLETCONNECT_PROJECT_ID, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION } from './constants';
|
|
22
22
|
import { getPreferredMessageProtocolVersion, setPreferredMessageProtocolVersion } from './message-protocol';
|
|
23
23
|
import { AccountManager } from './managers/AccountManager';
|
|
24
24
|
import { AppMetadataManager } from './managers/AppMetadataManager';
|
|
@@ -61,10 +61,10 @@ export { ChromeStorage, LocalStorage, WCStorage, IndexedDBStorage, StorageValida
|
|
|
61
61
|
// Managers
|
|
62
62
|
export { PeerManager, AccountManager, AppMetadataManager, PermissionManager };
|
|
63
63
|
// Constants
|
|
64
|
-
export { SDK_VERSION, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION, getPreferredMessageProtocolVersion, setPreferredMessageProtocolVersion };
|
|
64
|
+
export { SDK_VERSION, DEFAULT_WALLETCONNECT_PROJECT_ID, BEACON_VERSION, PROTOCOL_VERSION_V1, PROTOCOL_VERSION_V2, LATEST_PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION, getPreferredMessageProtocolVersion, setPreferredMessageProtocolVersion };
|
|
65
65
|
// Utils
|
|
66
66
|
export { getSenderId, getAccountIdentifier, windowRef, MultiTabChannel };
|
|
67
|
-
export { usesWrappedMessages, MESSAGE_WRAPPED_FROM_VERSION, MULTI_NETWORK_FROM_VERSION, compareBeaconVersion, isAtLeastVersion, isMultiNetworkVersion, negotiateEnvelopeVersion, wrapBeaconMessage, unwrapBeaconMessage } from './utils/message-utils';
|
|
67
|
+
export { usesWrappedMessages, MESSAGE_WRAPPED_FROM_VERSION, MULTI_NETWORK_FROM_VERSION, compareBeaconVersion, isAtLeastVersion, isMultiNetworkVersion, negotiateEnvelopeVersion, effectivePeerVersion, wrapBeaconMessage, unwrapBeaconMessage } from './utils/message-utils';
|
|
68
68
|
export { normalizeTezosCaip2, isValidTezosCaip2, networkFromTezosCaip2, TEZOS_NETWORK_GENESIS_IDS, tezosCaip2FromNetworkType, networkTypeFromTezosCaip2 } from './utils/caip2';
|
|
69
69
|
export { assertNever } from './utils/assert-never';
|
|
70
70
|
export { resolveRequiredMinimumVersion } from './utils/required-minimum-version';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAA;AACxF,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,uBAAuB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3C,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA","sourcesContent":["/**\n * General docs\n * @module public\n */\nimport { Client } from './clients/client/Client'\nimport { BeaconError } from './errors/BeaconError'\nimport { BroadcastBeaconError } from './errors/BroadcastBeaconError'\nimport { NetworkNotSupportedBeaconError } from './errors/NetworkNotSupportedBeaconError'\nimport { NoAddressBeaconError } from './errors/NoAddressBeaconError'\nimport { NoPrivateKeyBeaconError } from './errors/NoPrivateKeyBeaconError'\nimport { NotGrantedBeaconError } from './errors/NotGrantedBeaconError'\nimport { ParametersInvalidBeaconError } from './errors/ParametersInvalidBeaconError'\nimport { TooManyOperationsBeaconError } from './errors/TooManyOperationsBeaconError'\nimport { TransactionInvalidBeaconError } from './errors/TransactionInvalidBeaconError'\nimport { UnknownBeaconError } from './errors/UnknownBeaconError'\nimport { Transport } from './transports/Transport'\nimport { ChromeStorage } from './storage/ChromeStorage'\nimport { LocalStorage } from './storage/LocalStorage'\nimport { getStorage } from './storage/getStorage'\nimport { Serializer } from './Serializer'\n// import { RequestEncryptPayloadInput } from './types/RequestEncryptPayloadInput'\nimport { ClientOptions } from './clients/client/ClientOptions'\nimport {\n SDK_VERSION,\n BEACON_VERSION,\n PROTOCOL_VERSION_V1,\n PROTOCOL_VERSION_V2,\n LATEST_PROTOCOL_VERSION,\n DEFAULT_PROTOCOL_VERSION\n} from './constants'\nimport {\n getPreferredMessageProtocolVersion,\n setPreferredMessageProtocolVersion\n} from './message-protocol'\nimport { AccountManager } from './managers/AccountManager'\nimport { AppMetadataManager } from './managers/AppMetadataManager'\nimport { PermissionManager } from './managers/PermissionManager'\nimport { BeaconClient } from './clients/beacon-client/BeaconClient'\nimport { BeaconClientOptions } from './clients/beacon-client/BeaconClientOptions'\nimport { getAccountIdentifier } from './utils/get-account-identifier'\nimport { AbortedBeaconError } from './errors/AbortedBeaconError'\nimport { getSenderId } from './utils/get-sender-id'\nimport { PeerManager } from './managers/PeerManager'\nimport { MessageBasedClient } from './transports/clients/MessageBasedClient'\nimport { setDebugEnabled, getDebugEnabled } from './debug'\n// import { EncryptPayloadRequest } from './types/beacon/messages/EncryptPayloadRequest'\n// import { EncryptPayloadResponse } from './types/beacon/messages/EncryptPayloadResponse'\n// import { EncryptionTypeNotSupportedBeaconError } from './errors/EncryptionTypeNotSupportedBeaconError'\nimport { SignatureTypeNotSupportedBeaconError } from './errors/SignatureTypeNotSupportedBeaconError'\nimport { VersionUnsupportedBeaconError } from './errors/VersionUnsupportedBeaconError'\nimport { InvalidRequiredMinimumVersionError } from './errors/InvalidRequiredMinimumVersionError'\nimport { NetworksUnsupportedBeaconError } from './errors/NetworksUnsupportedBeaconError'\nimport { InvalidBeaconVersionError } from './errors/InvalidBeaconVersionError'\nimport { getLogger, Logger, setLogger } from './utils/Logger'\nimport { windowRef } from './MockWindow'\nimport { CommunicationClient } from './transports/clients/CommunicationClient'\nimport { ClientEvents } from './transports/clients/ClientEvents'\nimport { WCStorage } from './storage/WCStorage'\nimport { IndexedDBStorage } from './storage/IndexedDBStorage'\nimport { StorageValidator } from './storage/StorageValidator'\nimport { MultiTabChannel } from './utils/multi-tab-channel'\nimport getError from './errors/get-error'\n// import { EncryptionType } from './types/EncryptionType'\n// import { EncryptionOperation } from './types/EncryptionOperation'\n\n// Clients\nexport { BeaconClient, BeaconClientOptions, Client, ClientOptions, ClientEvents }\n\n// Errors\nexport {\n getError,\n BeaconError,\n AbortedBeaconError,\n BroadcastBeaconError,\n NetworkNotSupportedBeaconError,\n NoAddressBeaconError,\n NoPrivateKeyBeaconError,\n NotGrantedBeaconError,\n ParametersInvalidBeaconError,\n TooManyOperationsBeaconError,\n TransactionInvalidBeaconError,\n SignatureTypeNotSupportedBeaconError,\n // EncryptionTypeNotSupportedBeaconError,\n UnknownBeaconError,\n VersionUnsupportedBeaconError,\n InvalidRequiredMinimumVersionError,\n NetworksUnsupportedBeaconError,\n InvalidBeaconVersionError\n}\n\n// Transport\nexport { Transport, MessageBasedClient, CommunicationClient }\n\n// Storage\nexport { ChromeStorage, LocalStorage, WCStorage, IndexedDBStorage, StorageValidator, getStorage }\n\n// Managers\nexport { PeerManager, AccountManager, AppMetadataManager, PermissionManager }\n\n// Constants\nexport {\n SDK_VERSION,\n BEACON_VERSION,\n PROTOCOL_VERSION_V1,\n PROTOCOL_VERSION_V2,\n LATEST_PROTOCOL_VERSION,\n DEFAULT_PROTOCOL_VERSION,\n getPreferredMessageProtocolVersion,\n setPreferredMessageProtocolVersion\n}\n\n// Utils\nexport { getSenderId, getAccountIdentifier, windowRef, MultiTabChannel }\nexport {\n usesWrappedMessages,\n MESSAGE_WRAPPED_FROM_VERSION,\n MULTI_NETWORK_FROM_VERSION,\n compareBeaconVersion,\n isAtLeastVersion,\n isMultiNetworkVersion,\n negotiateEnvelopeVersion,\n wrapBeaconMessage,\n unwrapBeaconMessage\n} from './utils/message-utils'\nexport {\n normalizeTezosCaip2,\n isValidTezosCaip2,\n networkFromTezosCaip2,\n TEZOS_NETWORK_GENESIS_IDS,\n tezosCaip2FromNetworkType,\n networkTypeFromTezosCaip2\n} from './utils/caip2'\nexport { assertNever } from './utils/assert-never'\nexport { resolveRequiredMinimumVersion } from './utils/required-minimum-version'\n\n// Diagnostics\nexport {\n gatherDiagnostics,\n buildErrorContext,\n serializeErrorContext,\n copyErrorContextToClipboard,\n SENSITIVE_STORAGE_KEYS\n} from './utils/diagnostics'\n\n// Error codes\nexport { ERROR_CODES, WC_ERROR_CODES, MATRIX_ERROR_CODES, PM_ERROR_CODES, BLOCKCHAIN_ERROR_CODES, BEACON_ERROR_CODES } from './errors/error-codes'\nexport type { ErrorCode } from './errors/error-codes'\n\n// Others\nexport { Serializer, Logger, setLogger, getLogger }\n\n// Debug\nexport { setDebugEnabled, getDebugEnabled }\n\nexport { NOTIFICATION_ORACLE_URL, BACKEND_URL } from './constants'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;GA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2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,qBAAqB,CAAA;AAE5B,cAAc;AACd,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAGlJ,SAAS;AACT,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAA;AAEnD,QAAQ;AACR,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAA;AAE3C,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA","sourcesContent":["/**\n * General docs\n * @module public\n */\nimport { Client } from './clients/client/Client'\nimport { BeaconError } from './errors/BeaconError'\nimport { BroadcastBeaconError } from './errors/BroadcastBeaconError'\nimport { NetworkNotSupportedBeaconError } from './errors/NetworkNotSupportedBeaconError'\nimport { NoAddressBeaconError } from './errors/NoAddressBeaconError'\nimport { NoPrivateKeyBeaconError } from './errors/NoPrivateKeyBeaconError'\nimport { NotGrantedBeaconError } from './errors/NotGrantedBeaconError'\nimport { ParametersInvalidBeaconError } from './errors/ParametersInvalidBeaconError'\nimport { TooManyOperationsBeaconError } from './errors/TooManyOperationsBeaconError'\nimport { TransactionInvalidBeaconError } from './errors/TransactionInvalidBeaconError'\nimport { UnknownBeaconError } from './errors/UnknownBeaconError'\nimport { Transport } from './transports/Transport'\nimport { ChromeStorage } from './storage/ChromeStorage'\nimport { LocalStorage } from './storage/LocalStorage'\nimport { getStorage } from './storage/getStorage'\nimport { Serializer } from './Serializer'\n// import { RequestEncryptPayloadInput } from './types/RequestEncryptPayloadInput'\nimport { ClientOptions } from './clients/client/ClientOptions'\nimport {\n SDK_VERSION,\n DEFAULT_WALLETCONNECT_PROJECT_ID,\n BEACON_VERSION,\n PROTOCOL_VERSION_V1,\n PROTOCOL_VERSION_V2,\n LATEST_PROTOCOL_VERSION,\n DEFAULT_PROTOCOL_VERSION\n} from './constants'\nimport {\n getPreferredMessageProtocolVersion,\n setPreferredMessageProtocolVersion\n} from './message-protocol'\nimport { AccountManager } from './managers/AccountManager'\nimport { AppMetadataManager } from './managers/AppMetadataManager'\nimport { PermissionManager } from './managers/PermissionManager'\nimport { BeaconClient } from './clients/beacon-client/BeaconClient'\nimport { BeaconClientOptions } from './clients/beacon-client/BeaconClientOptions'\nimport { getAccountIdentifier } from './utils/get-account-identifier'\nimport { AbortedBeaconError } from './errors/AbortedBeaconError'\nimport { getSenderId } from './utils/get-sender-id'\nimport { PeerManager } from './managers/PeerManager'\nimport { MessageBasedClient } from './transports/clients/MessageBasedClient'\nimport { setDebugEnabled, getDebugEnabled } from './debug'\n// import { EncryptPayloadRequest } from './types/beacon/messages/EncryptPayloadRequest'\n// import { EncryptPayloadResponse } from './types/beacon/messages/EncryptPayloadResponse'\n// import { EncryptionTypeNotSupportedBeaconError } from './errors/EncryptionTypeNotSupportedBeaconError'\nimport { SignatureTypeNotSupportedBeaconError } from './errors/SignatureTypeNotSupportedBeaconError'\nimport { VersionUnsupportedBeaconError } from './errors/VersionUnsupportedBeaconError'\nimport { InvalidRequiredMinimumVersionError } from './errors/InvalidRequiredMinimumVersionError'\nimport { NetworksUnsupportedBeaconError } from './errors/NetworksUnsupportedBeaconError'\nimport { InvalidBeaconVersionError } from './errors/InvalidBeaconVersionError'\nimport { getLogger, Logger, setLogger } from './utils/Logger'\nimport { windowRef } from './MockWindow'\nimport { CommunicationClient } from './transports/clients/CommunicationClient'\nimport { ClientEvents } from './transports/clients/ClientEvents'\nimport { WCStorage } from './storage/WCStorage'\nimport { IndexedDBStorage } from './storage/IndexedDBStorage'\nimport { StorageValidator } from './storage/StorageValidator'\nimport { MultiTabChannel } from './utils/multi-tab-channel'\nimport getError from './errors/get-error'\n// import { EncryptionType } from './types/EncryptionType'\n// import { EncryptionOperation } from './types/EncryptionOperation'\n\n// Clients\nexport { BeaconClient, BeaconClientOptions, Client, ClientOptions, ClientEvents }\n\n// Errors\nexport {\n getError,\n BeaconError,\n AbortedBeaconError,\n BroadcastBeaconError,\n NetworkNotSupportedBeaconError,\n NoAddressBeaconError,\n NoPrivateKeyBeaconError,\n NotGrantedBeaconError,\n ParametersInvalidBeaconError,\n TooManyOperationsBeaconError,\n TransactionInvalidBeaconError,\n SignatureTypeNotSupportedBeaconError,\n // EncryptionTypeNotSupportedBeaconError,\n UnknownBeaconError,\n VersionUnsupportedBeaconError,\n InvalidRequiredMinimumVersionError,\n NetworksUnsupportedBeaconError,\n InvalidBeaconVersionError\n}\n\n// Transport\nexport { Transport, MessageBasedClient, CommunicationClient }\n\n// Storage\nexport { ChromeStorage, LocalStorage, WCStorage, IndexedDBStorage, StorageValidator, getStorage }\n\n// Managers\nexport { PeerManager, AccountManager, AppMetadataManager, PermissionManager }\n\n// Constants\nexport {\n SDK_VERSION,\n DEFAULT_WALLETCONNECT_PROJECT_ID,\n BEACON_VERSION,\n PROTOCOL_VERSION_V1,\n PROTOCOL_VERSION_V2,\n LATEST_PROTOCOL_VERSION,\n DEFAULT_PROTOCOL_VERSION,\n getPreferredMessageProtocolVersion,\n setPreferredMessageProtocolVersion\n}\n\n// Utils\nexport { getSenderId, getAccountIdentifier, windowRef, MultiTabChannel }\nexport {\n usesWrappedMessages,\n MESSAGE_WRAPPED_FROM_VERSION,\n MULTI_NETWORK_FROM_VERSION,\n compareBeaconVersion,\n isAtLeastVersion,\n isMultiNetworkVersion,\n negotiateEnvelopeVersion,\n effectivePeerVersion,\n wrapBeaconMessage,\n unwrapBeaconMessage\n} from './utils/message-utils'\nexport {\n normalizeTezosCaip2,\n isValidTezosCaip2,\n networkFromTezosCaip2,\n TEZOS_NETWORK_GENESIS_IDS,\n tezosCaip2FromNetworkType,\n networkTypeFromTezosCaip2\n} from './utils/caip2'\nexport { assertNever } from './utils/assert-never'\nexport { resolveRequiredMinimumVersion } from './utils/required-minimum-version'\n\n// Diagnostics\nexport {\n gatherDiagnostics,\n buildErrorContext,\n serializeErrorContext,\n copyErrorContextToClipboard,\n SENSITIVE_STORAGE_KEYS\n} from './utils/diagnostics'\n\n// Error codes\nexport { ERROR_CODES, WC_ERROR_CODES, MATRIX_ERROR_CODES, PM_ERROR_CODES, BLOCKCHAIN_ERROR_CODES, BEACON_ERROR_CODES } from './errors/error-codes'\nexport type { ErrorCode } from './errors/error-codes'\n\n// Others\nexport { Serializer, Logger, setLogger, getLogger }\n\n// Debug\nexport { setDebugEnabled, getDebugEnabled }\n\nexport { NOTIFICATION_ORACLE_URL, BACKEND_URL } from './constants'\n"]}
|
|
@@ -56,6 +56,39 @@ export declare const LEGACY_ENVELOPE_VERSION = "2";
|
|
|
56
56
|
* @category Utility
|
|
57
57
|
*/
|
|
58
58
|
export declare const negotiateEnvelopeVersion: (peerVersion: string | undefined) => string;
|
|
59
|
+
/**
|
|
60
|
+
* The peer's version as safe to feed into capability negotiation
|
|
61
|
+
* ({@link negotiateEnvelopeVersion}, multi-network gating, minimum-version
|
|
62
|
+
* enforcement).
|
|
63
|
+
*
|
|
64
|
+
* `peer.version` alone CANNOT be trusted: legacy wallets (octez.connect
|
|
65
|
+
* 4.8.x and upstream beacon-sdk forks) build their pairing response with the
|
|
66
|
+
* version field of the dApp's pairing REQUEST — they echo the dApp's own
|
|
67
|
+
* version back instead of declaring theirs. A v5 dApp reading that echo sees
|
|
68
|
+
* '4', serves a wrapped v4 envelope, and the legacy wallet silently drops it
|
|
69
|
+
* after pairing ("Pairing complete! Waiting for permission request…").
|
|
70
|
+
*
|
|
71
|
+
* The reliable capability marker is `protocolVersion`: v5+ pairing responses
|
|
72
|
+
* attach it on every transport that can carry it (P2P, PostMessage), legacy
|
|
73
|
+
* responses never do, and it cannot be echoed (legacy constructors don't
|
|
74
|
+
* know the field). A peer that DECLARES a version without a valid marker
|
|
75
|
+
* (a positive protocol version, matching the protocol's minimum of 1) is
|
|
76
|
+
* therefore treated as a legacy flat-v2 speaker regardless of its echoed
|
|
77
|
+
* `version` — exactly the wire a 4.8.x dApp would have served it.
|
|
78
|
+
*
|
|
79
|
+
* A peer that declares NO version at all keeps the long-standing "unknown"
|
|
80
|
+
* semantics and maps to `undefined` (WalletConnect pairings, where beacon
|
|
81
|
+
* versions are never fabricated and capability is negotiated via session
|
|
82
|
+
* namespaces): version gates treat unknown as allowed-through and response
|
|
83
|
+
* handling falls back to the response envelope's version. The echo problem
|
|
84
|
+
* by definition only exists for peers that DO carry a version.
|
|
85
|
+
*
|
|
86
|
+
* @category Utility
|
|
87
|
+
*/
|
|
88
|
+
export declare const effectivePeerVersion: (peer: {
|
|
89
|
+
version?: string;
|
|
90
|
+
protocolVersion?: unknown;
|
|
91
|
+
} | undefined) => string | undefined;
|
|
59
92
|
/**
|
|
60
93
|
* Build a wrapped beacon envelope. Single source of truth for the
|
|
61
94
|
* `{ id, version, senderId, message }` wire shape so senders cannot drift.
|
|
@@ -101,6 +101,46 @@ export const negotiateEnvelopeVersion = (peerVersion) => {
|
|
|
101
101
|
}
|
|
102
102
|
return isAtLeastVersion(peerVersion, BEACON_VERSION) ? BEACON_VERSION : peerVersion;
|
|
103
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* The peer's version as safe to feed into capability negotiation
|
|
106
|
+
* ({@link negotiateEnvelopeVersion}, multi-network gating, minimum-version
|
|
107
|
+
* enforcement).
|
|
108
|
+
*
|
|
109
|
+
* `peer.version` alone CANNOT be trusted: legacy wallets (octez.connect
|
|
110
|
+
* 4.8.x and upstream beacon-sdk forks) build their pairing response with the
|
|
111
|
+
* version field of the dApp's pairing REQUEST — they echo the dApp's own
|
|
112
|
+
* version back instead of declaring theirs. A v5 dApp reading that echo sees
|
|
113
|
+
* '4', serves a wrapped v4 envelope, and the legacy wallet silently drops it
|
|
114
|
+
* after pairing ("Pairing complete! Waiting for permission request…").
|
|
115
|
+
*
|
|
116
|
+
* The reliable capability marker is `protocolVersion`: v5+ pairing responses
|
|
117
|
+
* attach it on every transport that can carry it (P2P, PostMessage), legacy
|
|
118
|
+
* responses never do, and it cannot be echoed (legacy constructors don't
|
|
119
|
+
* know the field). A peer that DECLARES a version without a valid marker
|
|
120
|
+
* (a positive protocol version, matching the protocol's minimum of 1) is
|
|
121
|
+
* therefore treated as a legacy flat-v2 speaker regardless of its echoed
|
|
122
|
+
* `version` — exactly the wire a 4.8.x dApp would have served it.
|
|
123
|
+
*
|
|
124
|
+
* A peer that declares NO version at all keeps the long-standing "unknown"
|
|
125
|
+
* semantics and maps to `undefined` (WalletConnect pairings, where beacon
|
|
126
|
+
* versions are never fabricated and capability is negotiated via session
|
|
127
|
+
* namespaces): version gates treat unknown as allowed-through and response
|
|
128
|
+
* handling falls back to the response envelope's version. The echo problem
|
|
129
|
+
* by definition only exists for peers that DO carry a version.
|
|
130
|
+
*
|
|
131
|
+
* @category Utility
|
|
132
|
+
*/
|
|
133
|
+
export const effectivePeerVersion = (peer) => {
|
|
134
|
+
if (!peer || peer.version == null) {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
// `Number(null)` is 0 (finite) — treat null like absent, not like v5.
|
|
138
|
+
const protocolRaw = peer.protocolVersion == null ? Number.NaN : Number(peer.protocolVersion);
|
|
139
|
+
// Positive protocol versions only (the protocol's minimum is 1): `0`,
|
|
140
|
+
// negatives, and non-numeric noise are malformed markers and must stay on
|
|
141
|
+
// the legacy path, like an absent marker.
|
|
142
|
+
return Number.isFinite(protocolRaw) && protocolRaw >= 1 ? peer.version : LEGACY_ENVELOPE_VERSION;
|
|
143
|
+
};
|
|
104
144
|
/**
|
|
105
145
|
* Build a wrapped beacon envelope. Single source of truth for the
|
|
106
146
|
* `{ id, version, senderId, message }` wire shape so senders cannot drift.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-utils.js","sourceRoot":"","sources":["../../../../src/utils/message-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGlB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAO7C,OAAO,EAAE,yB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,QAAQ,EAAE,QAAQ,CAAC,QAAQ;IAC3B,OAAO;CACR,CAAC,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2B,SAG7D,EAAiB,EAAE,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;AAE7F;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,QAA0C,EAC1C,WAA+B,EACmD,EAAE;IACpF,MAAM,OAAO,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAA;IAErD,OAAO,mBAAmB,CAAC,OAAO,CAAC;QACjC,CAAC,CAAC,iBAAiB,CACf,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,EACzD,EAAE,IAAI,EAAE,iBAAiB,CAAC,UAAU,EAAE,CACvC;QACH,CAAC,CAAC;YACE,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,OAAO;YACP,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,IAAI,EAAE,iBAAiB,CAAC,UAAU;SACnC,CAAA;AACP,CAAC,CAAA","sourcesContent":["import {\n BeaconMessageType,\n BeaconMessageWrapper,\n DisconnectMessage\n} from '@tezos-x/octez.connect-types'\nimport { BEACON_VERSION } from '../constants'\n\n// Structural stand-in for the beaconV3 BeaconBaseMessage ({ type: unknown }).\n// The types barrel re-exports the flat BeaconBaseMessage (which also carries\n// id/version/senderId) under the same name, so constraining on the barrel\n// type would wrongly require envelope fields on the inner payload.\ninterface WrappedPayload { type: unknown }\nimport { InvalidBeaconVersionError } from '../errors/InvalidBeaconVersionError'\n\nexport const MESSAGE_WRAPPED_FROM_VERSION = 3\n\n// peer.version at or above which the multi-network (v4) protocol applies.\nexport const MULTI_NETWORK_FROM_VERSION = '4'\n\n// Strict decimal-integer: a lone `0` or non-zero digit followed by digits.\n// Rejects leading zeros on multi-digit values (e.g. `'04'`). A lone `0` is\n// kept valid so legacy compat paths can use it as a fallback/unknown version.\nconst DECIMAL_INTEGER_RE = /^(0|[1-9]\\d*)$/\n\nexport const parseStrictDecimalInteger = (value: unknown): number | null => {\n if (typeof value !== 'string') {\n return null\n }\n if (!DECIMAL_INTEGER_RE.test(value)) {\n return null\n }\n const parsed = Number(value)\n if (!Number.isFinite(parsed) || parsed > Number.MAX_SAFE_INTEGER) {\n return null\n }\n\n return parsed\n}\n\n/**\n * Compare two `peer.version` strings as strict decimal integers.\n *\n * Returns < 0 if `a < b`, 0 if equal, > 0 if `a > b` — same convention as\n * `Array.prototype.sort` comparators.\n *\n * Throws `InvalidBeaconVersionError` if either operand is not a decimal-\n * integer string in `[0, Number.MAX_SAFE_INTEGER]`. Leading signs, leading\n * zeros, decimal points, exponent notation, hex, whitespace, `'NaN'` and\n * `'Infinity'` all reject.\n *\n * @category Utility\n */\nexport const compareBeaconVersion = (a: unknown, b: unknown): number => {\n const na = parseStrictDecimalInteger(a)\n const nb = parseStrictDecimalInteger(b)\n\n if (na === null || nb === null) {\n throw new InvalidBeaconVersionError(a, b)\n }\n\n return na - nb\n}\n\n/**\n * Whether `version` is a valid peer.version at or above `threshold`.\n *\n * Single source of truth for the \"is this peer at least version X\" decision.\n * Returns `false` for an absent version and for any value that fails the\n * strict decimal-integer contract of `compareBeaconVersion` — i.e. malformed\n * or untrusted input is always treated as below the threshold, so a hostile\n * peer cannot trip a higher-version code path.\n *\n * @category Utility\n */\nexport const isAtLeastVersion = (version: string | undefined, threshold: string): boolean => {\n if (version === undefined) {\n return false\n }\n try {\n return compareBeaconVersion(version, threshold) >= 0\n } catch {\n return false\n }\n}\n\n/**\n * Whether `version` is at or above the multi-network (v4) threshold.\n *\n * @category Utility\n */\nexport const isMultiNetworkVersion = (version: string | undefined): boolean =>\n isAtLeastVersion(version, MULTI_NETWORK_FROM_VERSION)\n\nexport const usesWrappedMessages = (version?: string): boolean => {\n // Use the same strict decimal-integer contract as compareBeaconVersion so\n // wrapped-message routing agrees with the v4/multi-network routing: a loose\n // value like '3.0', ' 3 ' or '03' (which Number() would accept) is treated\n // as malformed and routed as non-wrapped rather than inconsistently.\n const parsed = parseStrictDecimalInteger(version)\n\n return parsed !== null && parsed >= MESSAGE_WRAPPED_FROM_VERSION\n}\n\n/** The flat legacy wire dialect served to peers below the wrapped baseline. */\nexport const LEGACY_ENVELOPE_VERSION = '2'\n\n/**\n * The envelope version to stamp on an outgoing message for a peer that\n * declared `peerVersion` at pairing: `min(peerVersion, BEACON_VERSION)` with\n * a floor at the flat legacy dialect ('2').\n *\n * This is the backward-compatibility pivot: a peer that declared '2' — or\n * never declared a version at all (legacy pairings, WalletConnect peers,\n * malformed values) — is served the flat v2 dialect it has always spoken; a\n * v3 peer receives '3' wrapped envelopes and never sees v4 payload fields;\n * a v4 peer gets the full wrapped v4 wire. Callers pick the message SHAPE\n * with `usesWrappedMessages(negotiated)` and gate v4 fields (`networks`/\n * `accounts`) on `isMultiNetworkVersion(negotiated)`.\n *\n * @category Utility\n */\nexport const negotiateEnvelopeVersion = (peerVersion: string | undefined): string => {\n if (!isAtLeastVersion(peerVersion, String(MESSAGE_WRAPPED_FROM_VERSION))) {\n return LEGACY_ENVELOPE_VERSION\n }\n\n return isAtLeastVersion(peerVersion, BEACON_VERSION) ? BEACON_VERSION : (peerVersion as string)\n}\n\n/**\n * Build a wrapped beacon envelope. Single source of truth for the\n * `{ id, version, senderId, message }` wire shape so senders cannot drift.\n *\n * @category Utility\n */\nexport const wrapBeaconMessage = <T extends WrappedPayload>(\n envelope: { id: string; version: string; senderId: string },\n message: T\n): BeaconMessageWrapper<T> => ({\n id: envelope.id,\n version: envelope.version,\n senderId: envelope.senderId,\n message\n})\n\n/**\n * Extract the inner payload of a wrapped beacon envelope, or `undefined`\n * when the candidate's version does not follow the wrapped (v3+) contract.\n * Callers must treat `undefined` as \"not a wrapped message\" and drop or\n * tombstone it — never fall back to reading flat fields.\n *\n * @category Utility\n */\nexport const unwrapBeaconMessage = <T extends WrappedPayload>(candidate: {\n version?: string\n message?: T\n}): T | undefined => (usesWrappedMessages(candidate.version) ? candidate.message : undefined)\n\n/**\n * Build a disconnect message in the peer's negotiated dialect: a wrapped\n * envelope for v3+ peers, the flat legacy shape for v2 peers. A legacy peer\n * routes on the top-level `type` and would silently ignore a wrapped\n * envelope — the goodbye must be spoken in the dialect the peer parses.\n *\n * @category Utility\n */\nexport const buildDisconnectMessage = (\n envelope: { id: string; senderId: string },\n peerVersion: string | undefined\n): DisconnectMessage | BeaconMessageWrapper<{ type: BeaconMessageType.Disconnect }> => {\n const version = negotiateEnvelopeVersion(peerVersion)\n\n return usesWrappedMessages(version)\n ? wrapBeaconMessage(\n { id: envelope.id, version, senderId: envelope.senderId },\n { type: BeaconMessageType.Disconnect }\n )\n : {\n id: envelope.id,\n version,\n senderId: envelope.senderId,\n type: BeaconMessageType.Disconnect\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message-utils.js","sourceRoot":"","sources":["../../../../src/utils/message-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGlB,MAAM,8BAA8B,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAO7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAA;AAE/E,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAA;AAE7C,0EAA0E;AAC1E,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAA;AAE7C,2EAA2E;AAC3E,2EAA2E;AAC3E,8EAA8E;AAC9E,MAAM,kBAAkB,GAAG,gBAAgB,CAAA;AAE3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,KAAc,EAAiB,EAAE;IACzE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAA;IACb,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;AAClG,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,QAA2D,EAC3D,OAAU,EACe,EAAE,CAAC,CAAC;IAC7B,EAAE,EAAE,QAAQ,CAAC,EAAE;IACf,OAAO,EAAE,QAAQ,CAAC,OAAO;IACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;IAC3B,OAAO;CACR,CAAC,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAA2B,SAG7D,EAAiB,EAAE,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;AAE7F;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,QAA0C,EAC1C,WAA+B,EACmD,EAAE;IACpF,MAAM,OAAO,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAA;IAErD,OAAO,mBAAmB,CAAC,OAAO,CAAC;QACjC,CAAC,CAAC,iBAAiB,CACf,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,EACzD,EAAE,IAAI,EAAE,iBAAiB,CAAC,UAAU,EAAE,CACvC;QACH,CAAC,CAAC;YACE,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,OAAO;YACP,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,IAAI,EAAE,iBAAiB,CAAC,UAAU;SACnC,CAAA;AACP,CAAC,CAAA","sourcesContent":["import {\n BeaconMessageType,\n BeaconMessageWrapper,\n DisconnectMessage\n} from '@tezos-x/octez.connect-types'\nimport { BEACON_VERSION } from '../constants'\n\n// Structural stand-in for the beaconV3 BeaconBaseMessage ({ type: unknown }).\n// The types barrel re-exports the flat BeaconBaseMessage (which also carries\n// id/version/senderId) under the same name, so constraining on the barrel\n// type would wrongly require envelope fields on the inner payload.\ninterface WrappedPayload { type: unknown }\nimport { InvalidBeaconVersionError } from '../errors/InvalidBeaconVersionError'\n\nexport const MESSAGE_WRAPPED_FROM_VERSION = 3\n\n// peer.version at or above which the multi-network (v4) protocol applies.\nexport const MULTI_NETWORK_FROM_VERSION = '4'\n\n// Strict decimal-integer: a lone `0` or non-zero digit followed by digits.\n// Rejects leading zeros on multi-digit values (e.g. `'04'`). A lone `0` is\n// kept valid so legacy compat paths can use it as a fallback/unknown version.\nconst DECIMAL_INTEGER_RE = /^(0|[1-9]\\d*)$/\n\nexport const parseStrictDecimalInteger = (value: unknown): number | null => {\n if (typeof value !== 'string') {\n return null\n }\n if (!DECIMAL_INTEGER_RE.test(value)) {\n return null\n }\n const parsed = Number(value)\n if (!Number.isFinite(parsed) || parsed > Number.MAX_SAFE_INTEGER) {\n return null\n }\n\n return parsed\n}\n\n/**\n * Compare two `peer.version` strings as strict decimal integers.\n *\n * Returns < 0 if `a < b`, 0 if equal, > 0 if `a > b` — same convention as\n * `Array.prototype.sort` comparators.\n *\n * Throws `InvalidBeaconVersionError` if either operand is not a decimal-\n * integer string in `[0, Number.MAX_SAFE_INTEGER]`. Leading signs, leading\n * zeros, decimal points, exponent notation, hex, whitespace, `'NaN'` and\n * `'Infinity'` all reject.\n *\n * @category Utility\n */\nexport const compareBeaconVersion = (a: unknown, b: unknown): number => {\n const na = parseStrictDecimalInteger(a)\n const nb = parseStrictDecimalInteger(b)\n\n if (na === null || nb === null) {\n throw new InvalidBeaconVersionError(a, b)\n }\n\n return na - nb\n}\n\n/**\n * Whether `version` is a valid peer.version at or above `threshold`.\n *\n * Single source of truth for the \"is this peer at least version X\" decision.\n * Returns `false` for an absent version and for any value that fails the\n * strict decimal-integer contract of `compareBeaconVersion` — i.e. malformed\n * or untrusted input is always treated as below the threshold, so a hostile\n * peer cannot trip a higher-version code path.\n *\n * @category Utility\n */\nexport const isAtLeastVersion = (version: string | undefined, threshold: string): boolean => {\n if (version === undefined) {\n return false\n }\n try {\n return compareBeaconVersion(version, threshold) >= 0\n } catch {\n return false\n }\n}\n\n/**\n * Whether `version` is at or above the multi-network (v4) threshold.\n *\n * @category Utility\n */\nexport const isMultiNetworkVersion = (version: string | undefined): boolean =>\n isAtLeastVersion(version, MULTI_NETWORK_FROM_VERSION)\n\nexport const usesWrappedMessages = (version?: string): boolean => {\n // Use the same strict decimal-integer contract as compareBeaconVersion so\n // wrapped-message routing agrees with the v4/multi-network routing: a loose\n // value like '3.0', ' 3 ' or '03' (which Number() would accept) is treated\n // as malformed and routed as non-wrapped rather than inconsistently.\n const parsed = parseStrictDecimalInteger(version)\n\n return parsed !== null && parsed >= MESSAGE_WRAPPED_FROM_VERSION\n}\n\n/** The flat legacy wire dialect served to peers below the wrapped baseline. */\nexport const LEGACY_ENVELOPE_VERSION = '2'\n\n/**\n * The envelope version to stamp on an outgoing message for a peer that\n * declared `peerVersion` at pairing: `min(peerVersion, BEACON_VERSION)` with\n * a floor at the flat legacy dialect ('2').\n *\n * This is the backward-compatibility pivot: a peer that declared '2' — or\n * never declared a version at all (legacy pairings, WalletConnect peers,\n * malformed values) — is served the flat v2 dialect it has always spoken; a\n * v3 peer receives '3' wrapped envelopes and never sees v4 payload fields;\n * a v4 peer gets the full wrapped v4 wire. Callers pick the message SHAPE\n * with `usesWrappedMessages(negotiated)` and gate v4 fields (`networks`/\n * `accounts`) on `isMultiNetworkVersion(negotiated)`.\n *\n * @category Utility\n */\nexport const negotiateEnvelopeVersion = (peerVersion: string | undefined): string => {\n if (!isAtLeastVersion(peerVersion, String(MESSAGE_WRAPPED_FROM_VERSION))) {\n return LEGACY_ENVELOPE_VERSION\n }\n\n return isAtLeastVersion(peerVersion, BEACON_VERSION) ? BEACON_VERSION : (peerVersion as string)\n}\n\n/**\n * The peer's version as safe to feed into capability negotiation\n * ({@link negotiateEnvelopeVersion}, multi-network gating, minimum-version\n * enforcement).\n *\n * `peer.version` alone CANNOT be trusted: legacy wallets (octez.connect\n * 4.8.x and upstream beacon-sdk forks) build their pairing response with the\n * version field of the dApp's pairing REQUEST — they echo the dApp's own\n * version back instead of declaring theirs. A v5 dApp reading that echo sees\n * '4', serves a wrapped v4 envelope, and the legacy wallet silently drops it\n * after pairing (\"Pairing complete! Waiting for permission request…\").\n *\n * The reliable capability marker is `protocolVersion`: v5+ pairing responses\n * attach it on every transport that can carry it (P2P, PostMessage), legacy\n * responses never do, and it cannot be echoed (legacy constructors don't\n * know the field). A peer that DECLARES a version without a valid marker\n * (a positive protocol version, matching the protocol's minimum of 1) is\n * therefore treated as a legacy flat-v2 speaker regardless of its echoed\n * `version` — exactly the wire a 4.8.x dApp would have served it.\n *\n * A peer that declares NO version at all keeps the long-standing \"unknown\"\n * semantics and maps to `undefined` (WalletConnect pairings, where beacon\n * versions are never fabricated and capability is negotiated via session\n * namespaces): version gates treat unknown as allowed-through and response\n * handling falls back to the response envelope's version. The echo problem\n * by definition only exists for peers that DO carry a version.\n *\n * @category Utility\n */\nexport const effectivePeerVersion = (\n peer: { version?: string; protocolVersion?: unknown } | undefined\n): string | undefined => {\n if (!peer || peer.version == null) {\n return undefined\n }\n // `Number(null)` is 0 (finite) — treat null like absent, not like v5.\n const protocolRaw = peer.protocolVersion == null ? Number.NaN : Number(peer.protocolVersion)\n\n // Positive protocol versions only (the protocol's minimum is 1): `0`,\n // negatives, and non-numeric noise are malformed markers and must stay on\n // the legacy path, like an absent marker.\n return Number.isFinite(protocolRaw) && protocolRaw >= 1 ? peer.version : LEGACY_ENVELOPE_VERSION\n}\n\n/**\n * Build a wrapped beacon envelope. Single source of truth for the\n * `{ id, version, senderId, message }` wire shape so senders cannot drift.\n *\n * @category Utility\n */\nexport const wrapBeaconMessage = <T extends WrappedPayload>(\n envelope: { id: string; version: string; senderId: string },\n message: T\n): BeaconMessageWrapper<T> => ({\n id: envelope.id,\n version: envelope.version,\n senderId: envelope.senderId,\n message\n})\n\n/**\n * Extract the inner payload of a wrapped beacon envelope, or `undefined`\n * when the candidate's version does not follow the wrapped (v3+) contract.\n * Callers must treat `undefined` as \"not a wrapped message\" and drop or\n * tombstone it — never fall back to reading flat fields.\n *\n * @category Utility\n */\nexport const unwrapBeaconMessage = <T extends WrappedPayload>(candidate: {\n version?: string\n message?: T\n}): T | undefined => (usesWrappedMessages(candidate.version) ? candidate.message : undefined)\n\n/**\n * Build a disconnect message in the peer's negotiated dialect: a wrapped\n * envelope for v3+ peers, the flat legacy shape for v2 peers. A legacy peer\n * routes on the top-level `type` and would silently ignore a wrapped\n * envelope — the goodbye must be spoken in the dialect the peer parses.\n *\n * @category Utility\n */\nexport const buildDisconnectMessage = (\n envelope: { id: string; senderId: string },\n peerVersion: string | undefined\n): DisconnectMessage | BeaconMessageWrapper<{ type: BeaconMessageType.Disconnect }> => {\n const version = negotiateEnvelopeVersion(peerVersion)\n\n return usesWrappedMessages(version)\n ? wrapBeaconMessage(\n { id: envelope.id, version, senderId: envelope.senderId },\n { type: BeaconMessageType.Disconnect }\n )\n : {\n id: envelope.id,\n version,\n senderId: envelope.senderId,\n type: BeaconMessageType.Disconnect\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tezos-x/octez.connect-core",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "This package contains internal methods that are used by both the dApp and wallet client.",
|
|
5
5
|
"author": "Blockchain Infra <blockchain.infra@trili.tech>",
|
|
6
6
|
"homepage": "https://octez-connect.tezos.com",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@stablelib/nacl": "^2.0.1",
|
|
39
39
|
"@stablelib/utf8": "^2.1.0",
|
|
40
40
|
"@stablelib/x25519-session": "^2.0.1",
|
|
41
|
-
"@tezos-x/octez.connect-types": "5.0.
|
|
42
|
-
"@tezos-x/octez.connect-utils": "5.0.
|
|
41
|
+
"@tezos-x/octez.connect-types": "5.0.3",
|
|
42
|
+
"@tezos-x/octez.connect-utils": "5.0.3",
|
|
43
43
|
"broadcast-channel": "^7.3.0",
|
|
44
44
|
"bs58check": "4.0.0"
|
|
45
45
|
}
|