@metamask/connect-multichain 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/LICENSE +18 -20
  3. package/dist/browser/es/connect-multichain.d.mts +3 -0
  4. package/dist/browser/es/connect-multichain.mjs +25 -35
  5. package/dist/browser/es/connect-multichain.mjs.map +1 -1
  6. package/dist/browser/es/metafile-esm.json +1 -1
  7. package/dist/browser/iife/connect-multichain.d.ts +3 -0
  8. package/dist/browser/iife/connect-multichain.js +25 -35
  9. package/dist/browser/iife/connect-multichain.js.map +1 -1
  10. package/dist/browser/iife/metafile-iife.json +1 -1
  11. package/dist/browser/umd/connect-multichain.d.ts +3 -0
  12. package/dist/browser/umd/connect-multichain.js +25 -35
  13. package/dist/browser/umd/connect-multichain.js.map +1 -1
  14. package/dist/browser/umd/metafile-cjs.json +1 -1
  15. package/dist/node/cjs/connect-multichain.d.ts +3 -0
  16. package/dist/node/cjs/connect-multichain.js +25 -35
  17. package/dist/node/cjs/connect-multichain.js.map +1 -1
  18. package/dist/node/cjs/metafile-cjs.json +1 -1
  19. package/dist/node/es/connect-multichain.d.mts +3 -0
  20. package/dist/node/es/connect-multichain.mjs +25 -35
  21. package/dist/node/es/connect-multichain.mjs.map +1 -1
  22. package/dist/node/es/metafile-esm.json +1 -1
  23. package/dist/react-native/es/connect-multichain.d.mts +3 -0
  24. package/dist/react-native/es/connect-multichain.mjs +25 -35
  25. package/dist/react-native/es/connect-multichain.mjs.map +1 -1
  26. package/dist/react-native/es/metafile-esm.json +1 -1
  27. package/dist/src/domain/multichain/types.d.ts +3 -0
  28. package/dist/src/domain/multichain/types.d.ts.map +1 -1
  29. package/dist/src/domain/platform/index.js +9 -10
  30. package/dist/src/domain/platform/index.js.map +1 -1
  31. package/dist/src/multichain/index.d.ts.map +1 -1
  32. package/dist/src/multichain/index.js +17 -24
  33. package/dist/src/multichain/index.js.map +1 -1
  34. package/dist/src/multichain/transports/mwp/index.d.ts +1 -0
  35. package/dist/src/multichain/transports/mwp/index.d.ts.map +1 -1
  36. package/dist/src/multichain/transports/mwp/index.js +1 -1
  37. package/dist/src/multichain/transports/mwp/index.js.map +1 -1
  38. package/dist/types/connect-multichain.d.ts +3 -0
  39. package/package.json +5 -7
package/CHANGELOG.md CHANGED
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.12.0]
11
+
12
+ ### Added
13
+
14
+ - Include `analytics.remote_session_id` in V2 connection metadata so the wallet can correlate dapp-side and wallet-side analytics events ([#256](https://github.com/MetaMask/connect-monorepo/pull/256))
15
+
16
+ ## [0.11.1]
17
+
18
+ ### Changed
19
+
20
+ - chore: align sub-package licenses with root ConsenSys 2022 license ([#241](https://github.com/MetaMask/connect-monorepo/pull/241))
21
+ - chore: turborepo ([#239](https://github.com/MetaMask/connect-monorepo/pull/239))
22
+
23
+ ### Fixed
24
+
25
+ - `MWPTransport.connect()` now accepts and forwards a `forceRequest` option. When `true`, `onResumeSuccess` skips the `isSameScopesAndAccounts` check and unconditionally sends `wallet_createSession`, allowing consumers to re-prompt account selection on an existing MWP session. Previously `forceRequest` was silently ignored, causing `wallet_requestPermissions` to no-op on mobile. ([#243](https://github.com/MetaMask/connect-monorepo/pull/243))
26
+ - Fix platform detection for Hermes-based React Native apps: `isReactNative()` now checks `global.navigator.product` before `window.navigator.product`, so modern RN environments where `window` is undefined correctly resolve to `PlatformType.ReactNative` instead of `PlatformType.NonBrowser`. This restores analytics for all React Native consumers — analytics were silently disabled because `#setupAnalytics()` only calls `analytics.enable()` for browser and `ReactNative` platforms ([#238](https://github.com/MetaMask/connect-monorepo/pull/238))
27
+
10
28
  ## [0.11.0]
11
29
 
12
30
  ### Changed
@@ -227,7 +245,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
227
245
 
228
246
  - Initial release
229
247
 
230
- [Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.11.0...HEAD
248
+ [Unreleased]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.12.0...HEAD
249
+ [0.12.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.11.1...@metamask/connect-multichain@0.12.0
250
+ [0.11.1]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.11.0...@metamask/connect-multichain@0.11.1
231
251
  [0.11.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.10.0...@metamask/connect-multichain@0.11.0
232
252
  [0.10.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.9.0...@metamask/connect-multichain@0.10.0
233
253
  [0.9.0]: https://github.com/MetaMask/connect-monorepo/compare/@metamask/connect-multichain@0.8.0...@metamask/connect-multichain@0.9.0
package/LICENSE CHANGED
@@ -1,20 +1,18 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 MetaMask
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ Copyright ConsenSys Software Inc. 2022. All rights reserved.
2
+
3
+ You acknowledge and agree that ConsenSys Software Inc. ("ConsenSys") (or ConsenSys's licensors) own all legal right, title and interest in and to the work, software, application, source code, documentation and any other documents in this repository (collectively, the "Program"), including any intellectual property rights which subsist in the Program (whether those rights happen to be registered or not, and wherever in the world those rights may exist), whether in source code or any other form.
4
+
5
+ Subject to the limited license below, you may not (and you may not permit anyone else to) distribute, publish, copy, modify, merge, combine with another program, create derivative works of, reverse engineer, decompile or otherwise attempt to extract the source code of, the Program or any part thereof, except that you may contribute to this repository.
6
+
7
+ You are granted a non-exclusive, non-transferable, non-sublicensable license to distribute, publish, copy, modify, merge, combine with another program or create derivative works of the Program (such resulting program, collectively, the "Resulting Program") solely for Non-Commercial Use as long as you:
8
+ 1. give prominent notice ("Notice") with each copy of the Resulting Program that the Program is used in the Resulting Program and that the Program is the copyright of ConsenSys; and
9
+ 2. subject the Resulting Program and any distribution, publication, copy, modification, merger therewith, combination with another program or derivative works thereof to the same Notice requirement and Non-Commercial Use restriction set forth herein.
10
+
11
+ "Non-Commercial Use" means each use as described in clauses (1)-(3) below, as reasonably determined by ConsenSys in its sole discretion:
12
+ 1. personal use for research, personal study, private entertainment, hobby projects or amateur pursuits, in each case without any anticipated commercial application;
13
+ 2. use by any charitable organization, educational institution, public research organization, public safety or health organization, environmental protection organization or government institution; or
14
+ 3. the number of monthly active users of the Resulting Program across all versions thereof and platforms globally do not exceed 10,000 at any time.
15
+
16
+ You will not use any trade mark, service mark, trade name, logo of ConsenSys or any other company or organization in a way that is likely or intended to cause confusion about the owner or authorized user of such marks, names or logos.
17
+
18
+ If you have any questions, comments or interest in pursuing any other use cases, please reach out to us at metamask.license@consensys.net.
@@ -393,6 +393,9 @@ type ConnectionRequest = {
393
393
  version: string;
394
394
  platform: PlatformType;
395
395
  };
396
+ analytics?: {
397
+ remote_session_id: string;
398
+ };
396
399
  };
397
400
  };
398
401
  /**
@@ -506,26 +506,21 @@ var init_multichain = __esm({
506
506
  // src/domain/platform/index.ts
507
507
  import Bowser from "bowser";
508
508
  function isNotBrowser() {
509
- var _a3;
510
509
  if (typeof window === "undefined") {
511
510
  return true;
512
511
  }
513
512
  if (!(window == null ? void 0 : window.navigator)) {
514
513
  return true;
515
514
  }
516
- if (typeof global !== "undefined" && ((_a3 = global == null ? void 0 : global.navigator) == null ? void 0 : _a3.product) === "ReactNative") {
517
- return true;
518
- }
519
515
  return (navigator == null ? void 0 : navigator.product) === "ReactNative";
520
516
  }
521
517
  function isReactNative() {
522
- var _a3;
523
- const hasWindowNavigator = typeof window !== "undefined" && window.navigator !== void 0;
524
- const nav = hasWindowNavigator ? window.navigator : void 0;
525
- if (!nav) {
526
- return false;
518
+ var _a3, _b;
519
+ if (typeof global !== "undefined" && ((_a3 = global == null ? void 0 : global.navigator) == null ? void 0 : _a3.product) === "ReactNative") {
520
+ return true;
527
521
  }
528
- return hasWindowNavigator && ((_a3 = window.navigator) == null ? void 0 : _a3.product) === "ReactNative";
522
+ const hasWindowNavigator = typeof window !== "undefined" && window.navigator !== void 0;
523
+ return hasWindowNavigator && ((_b = window.navigator) == null ? void 0 : _b.product) === "ReactNative";
529
524
  }
530
525
  function isMetaMaskMobileWebView() {
531
526
  return typeof window !== "undefined" && // @ts-expect-error ReactNativeWebView should be defined
@@ -2262,7 +2257,7 @@ var MWPTransport = class {
2262
2257
  walletSession,
2263
2258
  proposedCaipAccountIds
2264
2259
  );
2265
- if (!hasSameScopesAndAccounts) {
2260
+ if (options.forceRequest || !hasSameScopesAndAccounts) {
2266
2261
  const optionalScopes = addValidAccounts(
2267
2262
  getOptionalScopes((_d = options == null ? void 0 : options.scopes) != null ? _d : []),
2268
2263
  getValidAccounts((_e = options == null ? void 0 : options.caipAccountIds) != null ? _e : [])
@@ -2745,7 +2740,7 @@ var keymanager = new KeyManager();
2745
2740
  init_utils2();
2746
2741
  var logger2 = createLogger("metamask-sdk:core");
2747
2742
  var SINGLETON_KEY = "__METAMASK_CONNECT_MULTICHAIN_SINGLETON__";
2748
- var _a2, _provider, _providerTransportWrapper, _transport2, _dappClient, _beforeUnloadListener, _listener, _sdkInfo, _MetaMaskConnectMultichain_instances, setupAnalytics_fn, onTransportNotification_fn, getStoredTransport_fn, setupTransport_fn, init_fn2, createDappClient_fn, setupMWP_fn, onBeforeUnload_fn, createBeforeUnloadListener_fn, renderInstallModalAsync_fn, showInstallModal_fn, headlessConnect_fn, setupDefaultTransport_fn, deeplinkConnect_fn, handleConnection_fn, getCaipSession_fn, openConnectDeeplinkIfNeeded_fn;
2743
+ var _a2, _provider, _providerTransportWrapper, _transport2, _dappClient, _beforeUnloadListener, _listener, _anonId, _sdkInfo, _MetaMaskConnectMultichain_instances, setupAnalytics_fn, onTransportNotification_fn, getStoredTransport_fn, setupTransport_fn, buildConnectionMetadata_fn, init_fn2, createDappClient_fn, setupMWP_fn, onBeforeUnload_fn, createBeforeUnloadListener_fn, renderInstallModalAsync_fn, showInstallModal_fn, headlessConnect_fn, setupDefaultTransport_fn, deeplinkConnect_fn, handleConnection_fn, getCaipSession_fn, openConnectDeeplinkIfNeeded_fn;
2749
2744
  var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends MultichainCore {
2750
2745
  constructor(options) {
2751
2746
  var _a3, _b, _c, _d, _e, _f;
@@ -2763,7 +2758,7 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2763
2758
  versions: __spreadValues({
2764
2759
  // typeof guard needed: Metro (React Native) bundles TS source directly,
2765
2760
  // bypassing the tsup build that substitutes __PACKAGE_VERSION__.
2766
- "connect-multichain": false ? "unknown" : "0.11.0"
2761
+ "connect-multichain": false ? "unknown" : "0.12.0"
2767
2762
  }, (_f = options.versions) != null ? _f : {})
2768
2763
  });
2769
2764
  super(allOptions);
@@ -2775,6 +2770,7 @@ var _MetaMaskConnectMultichain = class _MetaMaskConnectMultichain extends Multic
2775
2770
  __privateAdd(this, _beforeUnloadListener);
2776
2771
  this._status = "pending";
2777
2772
  __privateAdd(this, _listener);
2773
+ __privateAdd(this, _anonId);
2778
2774
  __privateAdd(this, _sdkInfo, `Sdk/Javascript SdkVersion/${getVersion()} Platform/${getPlatformType()} dApp/${(_a2 = this.options.dapp.url) != null ? _a2 : this.options.dapp.name} dAppTitle/${this.options.dapp.name}`);
2779
2775
  __privateSet(this, _providerTransportWrapper, new MultichainApiClientWrapperTransport(
2780
2776
  this
@@ -3034,6 +3030,7 @@ _transport2 = new WeakMap();
3034
3030
  _dappClient = new WeakMap();
3035
3031
  _beforeUnloadListener = new WeakMap();
3036
3032
  _listener = new WeakMap();
3033
+ _anonId = new WeakMap();
3037
3034
  _sdkInfo = new WeakMap();
3038
3035
  _MetaMaskConnectMultichain_instances = new WeakSet();
3039
3036
  setupAnalytics_fn = function() {
@@ -3047,6 +3044,7 @@ setupAnalytics_fn = function() {
3047
3044
  }
3048
3045
  const dappId = getDappId(this.options.dapp);
3049
3046
  const anonId = yield this.storage.getAnonId();
3047
+ __privateSet(this, _anonId, anonId);
3050
3048
  const { integrationType } = (_a3 = this.options.analytics) != null ? _a3 : {
3051
3049
  integrationType: ""
3052
3050
  };
@@ -3141,6 +3139,16 @@ setupTransport_fn = function() {
3141
3139
  }
3142
3140
  });
3143
3141
  };
3142
+ buildConnectionMetadata_fn = function() {
3143
+ const metadata = {
3144
+ dapp: this.options.dapp,
3145
+ sdk: { version: getVersion(), platform: getPlatformType() }
3146
+ };
3147
+ if (__privateGet(this, _anonId)) {
3148
+ metadata.analytics = { remote_session_id: __privateGet(this, _anonId) };
3149
+ }
3150
+ return metadata;
3151
+ };
3144
3152
  init_fn2 = function() {
3145
3153
  return __async(this, null, function* () {
3146
3154
  try {
@@ -3221,13 +3229,7 @@ renderInstallModalAsync_fn = function(desktopPreferred, scopes, caipAccountIds,
3221
3229
  (sessionRequest) => {
3222
3230
  _resolve({
3223
3231
  sessionRequest,
3224
- metadata: {
3225
- dapp: this.options.dapp,
3226
- sdk: {
3227
- version: getVersion(),
3228
- platform: getPlatformType()
3229
- }
3230
- }
3232
+ metadata: __privateMethod(this, _MetaMaskConnectMultichain_instances, buildConnectionMetadata_fn).call(this)
3231
3233
  });
3232
3234
  }
3233
3235
  );
@@ -3302,13 +3304,7 @@ headlessConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
3302
3304
  (sessionRequest) => {
3303
3305
  const connectionRequest = {
3304
3306
  sessionRequest,
3305
- metadata: {
3306
- dapp: this.options.dapp,
3307
- sdk: {
3308
- version: getVersion(),
3309
- platform: getPlatformType()
3310
- }
3311
- }
3307
+ metadata: __privateMethod(this, _MetaMaskConnectMultichain_instances, buildConnectionMetadata_fn).call(this)
3312
3308
  };
3313
3309
  const deeplink = this.options.ui.factory.createConnectionDeeplink(connectionRequest);
3314
3310
  this.emit("display_uri", deeplink);
@@ -3381,10 +3377,7 @@ deeplinkConnect_fn = function(scopes, caipAccountIds, sessionProperties) {
3381
3377
  var _a3;
3382
3378
  const connectionRequest = {
3383
3379
  sessionRequest,
3384
- metadata: {
3385
- dapp: this.options.dapp,
3386
- sdk: { version: getVersion(), platform: getPlatformType() }
3387
- }
3380
+ metadata: __privateMethod(this, _MetaMaskConnectMultichain_instances, buildConnectionMetadata_fn).call(this)
3388
3381
  };
3389
3382
  const deeplink = this.options.ui.factory.createConnectionDeeplink(
3390
3383
  connectionRequest
@@ -3492,10 +3485,7 @@ openConnectDeeplinkIfNeeded_fn = function() {
3492
3485
  }
3493
3486
  const connectionRequest = {
3494
3487
  sessionRequest: storedSessionRequest,
3495
- metadata: {
3496
- dapp: this.options.dapp,
3497
- sdk: { version: getVersion(), platform: getPlatformType() }
3498
- }
3488
+ metadata: __privateMethod(this, _MetaMaskConnectMultichain_instances, buildConnectionMetadata_fn).call(this)
3499
3489
  };
3500
3490
  const deeplink = this.options.ui.factory.createConnectionDeeplink(connectionRequest);
3501
3491
  const universalLink = this.options.ui.factory.createConnectionUniversalLink(connectionRequest);