@meshconnect/uwc-core 1.5.0-snapshot.4e344c2 → 1.5.0-snapshot.7469077

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.
@@ -1 +1 @@
1
- {"version":3,"file":"to-wallet-error.d.ts","sourceRoot":"","sources":["../../src/utils/to-wallet-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,wBAAwB,CAAA;AAW/B;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CASzD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQvD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,WAAW,CAAA;IACxB,MAAM,EAAE,WAAW,CAAA;CACpB,CAMA;AAmED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAUpD"}
1
+ {"version":3,"file":"to-wallet-error.d.ts","sourceRoot":"","sources":["../../src/utils/to-wallet-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,wBAAwB,CAAA;AAW/B;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CASzD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQvD;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,WAAW,CAAA;IACxB,MAAM,EAAE,WAAW,CAAA;CACpB,CAMA;AAsED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAUpD"}
@@ -59,20 +59,25 @@ export function classifyError(error) {
59
59
  }
60
60
  function classifyErrorUnguarded(error) {
61
61
  const code = error?.code;
62
- const hasNumericCode = typeof code === 'number';
62
+ // Only a finite integer is a valid JSON-RPC/EIP-1193 code. NaN/Infinity/floats
63
+ // are not — gating here keeps them from mis-attributing source or emitting a
64
+ // meaningless numeric errorCode, even when a raw error reaches this classifier.
65
+ const hasNumericCode = typeof code === 'number' && Number.isInteger(code);
63
66
  // Numeric codes pass through; STRING codes are wallet-controlled free-form
64
67
  // data headed for structured telemetry fields, so they get the same scrubber
65
68
  // as error.message plus a length cap. Known enum-likes ('ACTION_REJECTED')
66
69
  // are short and pattern-free — they pass unchanged.
67
- const errorCode = typeof code === 'number'
70
+ const errorCode = hasNumericCode
68
71
  ? String(code)
69
72
  : typeof code === 'string'
70
73
  ? scrubMessage(code).slice(0, MAX_ERROR_CODE_LENGTH)
71
74
  : undefined;
72
- const source = error instanceof WalletConnectorError
73
- ? 'connector'
74
- : hasNumericCode
75
- ? 'provider'
75
+ // A numeric code is the strongest origin signal, so it wins even when a
76
+ // connector re-wrapped the error (WalletConnectorError now carries it through).
77
+ const source = hasNumericCode
78
+ ? 'provider'
79
+ : error instanceof WalletConnectorError
80
+ ? 'connector'
76
81
  : 'unknown';
77
82
  let failureKind = 'unknown';
78
83
  if (isUserRejection(error)) {
@@ -1 +1 @@
1
- {"version":3,"file":"to-wallet-error.js","sourceRoot":"","sources":["../../src/utils/to-wallet-error.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAIjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAErD;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEhC;;;;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shot.7469077",
4
4
  "description": "Core functionality for Universal Wallet Connector",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,10 +16,10 @@
16
16
  "src"
17
17
  ],
18
18
  "dependencies": {
19
- "@meshconnect/uwc-injected-connector": "0.16.6-snapshot.4e344c2",
20
- "@meshconnect/uwc-ton-connector": "0.7.3-snapshot.4e344c2",
21
- "@meshconnect/uwc-types": "0.20.0-snapshot.4e344c2",
22
- "@meshconnect/uwc-wallet-connect-connector": "0.11.1-snapshot.4e344c2"
19
+ "@meshconnect/uwc-injected-connector": "0.16.6-snapshot.7469077",
20
+ "@meshconnect/uwc-ton-connector": "0.7.3-snapshot.7469077",
21
+ "@meshconnect/uwc-types": "0.20.0-snapshot.7469077",
22
+ "@meshconnect/uwc-wallet-connect-connector": "0.11.1-snapshot.7469077"
23
23
  },
24
24
  "devDependencies": {
25
25
  "typescript": "^5.9.3"
@@ -49,6 +49,38 @@ describe('classifyError', () => {
49
49
  )
50
50
  })
51
51
 
52
+ it('classifies a WalletConnectorError that carries a numeric code from its code (MFS-667)', () => {
53
+ // The fix: connectors wrap raw provider errors as WalletConnectorError. Before
54
+ // MFS-667 the numeric `.code` was dropped at wrap time, so a -32002 "already
55
+ // pending" landed as unknown/connector even though the classifier had a rule
56
+ // for it. With the code preserved, the rule fires and origin attributes to the
57
+ // provider — no message inference involved.
58
+ const wrapped = new WalletConnectorError({
59
+ type: 'unknown',
60
+ message: "Request of type 'wallet_requestPermissions' already pending",
61
+ code: -32002
62
+ })
63
+ expect(classifyError(wrapped)).toEqual({
64
+ errorCode: '-32002',
65
+ failureKind: 'provider_error',
66
+ source: 'provider'
67
+ })
68
+ })
69
+
70
+ it('still classifies a codeless WalletConnectorError as unknown/connector', () => {
71
+ // Guard against over-reach: a wrapped error with no numeric code keeps the
72
+ // connector attribution and stays unknown — the fix only lights up when a real
73
+ // code survives.
74
+ const wrapped = new WalletConnectorError({
75
+ type: 'unknown',
76
+ message: 'No accounts returned from wallet'
77
+ })
78
+ expect(classifyError(wrapped)).toEqual({
79
+ failureKind: 'unknown',
80
+ source: 'connector'
81
+ })
82
+ })
83
+
52
84
  it('classifies an expired WalletConnectorError', () => {
53
85
  const err = new WalletConnectorError({ type: 'expired', message: 'gone' })
54
86
  expect(classifyError(err)).toEqual({
@@ -67,6 +99,17 @@ describe('classifyError', () => {
67
99
  expect(classifyError({ code: 4901 }).failureKind).toBe('network_error')
68
100
  })
69
101
 
102
+ it('ignores non-integer numeric codes (NaN / Infinity / float)', () => {
103
+ // classifyError is public and receives raw errors, so a non-integer code must
104
+ // not flip source to provider or emit a meaningless errorCode.
105
+ for (const code of [NaN, Infinity, -Infinity, 1.5]) {
106
+ expect(classifyError({ code, message: 'x' })).toEqual({
107
+ failureKind: 'unknown',
108
+ source: 'unknown'
109
+ })
110
+ }
111
+ })
112
+
70
113
  it('falls back to unknown/unknown for a plain Error (no reliable signal)', () => {
71
114
  // RELIABLE-ONLY: a plain Error carries no code and is not a typed connector
72
115
  // error, so we never guess a kind from its message.
@@ -75,25 +75,28 @@ function classifyErrorUnguarded(error: unknown): {
75
75
  source: ErrorSource
76
76
  } {
77
77
  const code = (error as { code?: unknown } | null | undefined)?.code
78
- const hasNumericCode = typeof code === 'number'
78
+ // Only a finite integer is a valid JSON-RPC/EIP-1193 code. NaN/Infinity/floats
79
+ // are not — gating here keeps them from mis-attributing source or emitting a
80
+ // meaningless numeric errorCode, even when a raw error reaches this classifier.
81
+ const hasNumericCode = typeof code === 'number' && Number.isInteger(code)
79
82
 
80
83
  // Numeric codes pass through; STRING codes are wallet-controlled free-form
81
84
  // data headed for structured telemetry fields, so they get the same scrubber
82
85
  // as error.message plus a length cap. Known enum-likes ('ACTION_REJECTED')
83
86
  // are short and pattern-free — they pass unchanged.
84
- const errorCode =
85
- typeof code === 'number'
86
- ? String(code)
87
- : typeof code === 'string'
88
- ? scrubMessage(code).slice(0, MAX_ERROR_CODE_LENGTH)
89
- : undefined
87
+ const errorCode = hasNumericCode
88
+ ? String(code)
89
+ : typeof code === 'string'
90
+ ? scrubMessage(code).slice(0, MAX_ERROR_CODE_LENGTH)
91
+ : undefined
90
92
 
91
- const source: ErrorSource =
92
- error instanceof WalletConnectorError
93
+ // A numeric code is the strongest origin signal, so it wins even when a
94
+ // connector re-wrapped the error (WalletConnectorError now carries it through).
95
+ const source: ErrorSource = hasNumericCode
96
+ ? 'provider'
97
+ : error instanceof WalletConnectorError
93
98
  ? 'connector'
94
- : hasNumericCode
95
- ? 'provider'
96
- : 'unknown'
99
+ : 'unknown'
97
100
 
98
101
  let failureKind: FailureKind = 'unknown'
99
102
  if (isUserRejection(error)) {