rise-wallet 0.3.2 → 0.3.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rise-wallet",
3
3
  "description": "Next-gen Account for Ethereum",
4
- "version": "0.3.2",
4
+ "version": "0.3.3",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "porto": "./dist/cli/bin/index.js"
@@ -991,10 +991,13 @@ export function requiresConfirmation(
991
991
  if (policy.modes?.headless) {
992
992
  if (
993
993
  typeof policy.modes.headless === 'object' &&
994
- policy.modes.headless.sameOrigin &&
995
- targetOrigin !== window.location.origin
994
+ ((policy.modes.headless.sameOrigin &&
995
+ targetOrigin === window.location.origin) ||
996
+ policy.modes.headless.privilegedOrigins?.some((origin) =>
997
+ window.location.origin.endsWith(origin),
998
+ ))
996
999
  )
997
- return true
1000
+ return false
998
1001
  return false
999
1002
  }
1000
1003
  return true
@@ -89,12 +89,12 @@ export function onDialogRequest(
89
89
  if (rule) {
90
90
  if (
91
91
  typeof rule === 'object' &&
92
- rule.sameOrigin &&
93
- event.origin !== window.location.origin
92
+ ((rule.sameOrigin && event.origin === window.location.origin) ||
93
+ rule.privilegedOrigins?.some((origin) =>
94
+ event.origin.endsWith(origin),
95
+ ))
94
96
  ) {
95
- // Allow bypass for RISEx origins
96
- const risexOrigins = ['localhost:3009', 'rise.trade']
97
- return risexOrigins.some((origin) => event.origin.endsWith(origin))
97
+ return true
98
98
  }
99
99
  return true
100
100
  }
@@ -8,6 +8,7 @@ export type MethodPolicy = {
8
8
  | true
9
9
  | {
10
10
  sameOrigin?: boolean | undefined
11
+ privilegedOrigins?: string[] | undefined
11
12
  }
12
13
  | undefined
13
14
  dialog?:
@@ -22,12 +23,19 @@ export type MethodPolicy = {
22
23
  }
23
24
  export type MethodPolicies = readonly MethodPolicy[]
24
25
 
26
+ export const privilegedOrigins = [
27
+ 'rise.trade',
28
+ 'wallet.risechain.com',
29
+ 'localhost:3009',
30
+ ]
31
+
25
32
  export const methodPolicies = [
26
33
  {
27
34
  method: 'eth_requestAccounts',
28
35
  modes: {
29
36
  dialog: true,
30
37
  headless: {
38
+ privilegedOrigins,
31
39
  sameOrigin: true,
32
40
  },
33
41
  },
@@ -79,6 +87,7 @@ export const methodPolicies = [
79
87
  dialog: true,
80
88
  headless: !UserAgent.isSafari()
81
89
  ? {
90
+ privilegedOrigins,
82
91
  sameOrigin: true,
83
92
  }
84
93
  : undefined,