@binance/w3w-multichain-connector 1.0.6 → 1.0.8

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/dist/index.d.ts CHANGED
@@ -40,6 +40,35 @@ interface IConnectedWallet {
40
40
  binanceChainId: string;
41
41
  }[];
42
42
  }
43
+ interface SASRequestConfig {
44
+ publicKeyList: SASRequestPublicKeyVo[];
45
+ timestamp: number;
46
+ }
47
+ interface SASRequestPublicKeyVo {
48
+ binanceChainId: string;
49
+ attestationForKeyShareA: string;
50
+ /**
51
+ * attestation中的多个PCR0,配置在Apollo Configs,用于验证attestation
52
+ */
53
+ attestationPCR0s: string[];
54
+ publicKeyForKeyShareA: string;
55
+ spsVersion: string;
56
+ }
57
+ interface SASAuthorizeInfo {
58
+ walletType: 'SEED_PHRASE' | 'PRIVATE_KEY';
59
+ proofKeyPublicKey: string;
60
+ expireAt: number;
61
+ walletId: string;
62
+ extensionId: string;
63
+ authorizeList: SASAuthorizeInfoItem[];
64
+ }
65
+ interface SASAuthorizeInfoItem {
66
+ chain: 'evm' | 'sol';
67
+ encryptedKeyShareB: string;
68
+ encryptedKeyShareAData: string;
69
+ publicKey: string;
70
+ spsVersion: string;
71
+ }
43
72
  interface WalletEvents {
44
73
  walletLockedChanged: (isLocked: boolean) => void;
45
74
  autoSignEnabledChanged: (isEnabled: boolean) => void;
@@ -48,6 +77,72 @@ interface WalletEvents {
48
77
  }
49
78
  interface IWallet extends EventEmitter<WalletEvents> {
50
79
  requestConnect(binanceChainIds: string[]): Promise<IConnectedWallet[]>;
80
+ /**
81
+ * 链接插件的时候同时发起开启SAS的请求
82
+ * 如果用户同意,插件会记录下当前用户同意开启的SAS
83
+ */
84
+ requestConnectWithSAS(args: {
85
+ binanceChainIds: string[];
86
+ userId: string;
87
+ enabledWalletIds: string[];
88
+ }): Promise<{
89
+ wallet: IConnectedWallet;
90
+ aggreeEnableSAS: boolean;
91
+ }>;
92
+ /**
93
+ * 弹出要求用户同意开启SAS的弹窗
94
+ */
95
+ requestEnableSAS(arg: {
96
+ walletId: string;
97
+ userId: string;
98
+ }): Promise<{
99
+ aggreeEnableSAS: boolean;
100
+ }>;
101
+ /**
102
+ * 用户同意开启SAS后,获取SAS的keyshare
103
+ * 由于同一个钱包可能在app端被用户开启,所以插件不会校验用户有没有在插件端同意过
104
+ * 假如用户钱包锁住了,如果!isSilent, 会弹出解锁弹窗
105
+ * 否则keyshare获取失败,返回null
106
+ */
107
+ getSASKeyshare(arg: {
108
+ walletId: string;
109
+ userId: string;
110
+ requestConfig: SASRequestConfig;
111
+ isSlient?: false;
112
+ }): Promise<SASAuthorizeInfo>;
113
+ getSASKeyshare(arg: {
114
+ walletId: string;
115
+ userId: string;
116
+ requestConfig: SASRequestConfig;
117
+ isSlient: true;
118
+ }): Promise<SASAuthorizeInfo | null>;
119
+ /**
120
+ * 同步已链接钱包的SAS状态
121
+ */
122
+ syncSASStatus(arg: {
123
+ userId: string;
124
+ statusList: {
125
+ walletId: string;
126
+ enabled: boolean;
127
+ }[];
128
+ }): Promise<void>;
129
+ getConnectedWalletAndProofKey(arg: {
130
+ userId: string;
131
+ }): Promise<{
132
+ wallet: IConnectedWallet;
133
+ proofKeyPublicKey?: string;
134
+ }[]>;
135
+ /**
136
+ * 下单前获取ProofKey签名
137
+ */
138
+ getSASProofKeySignature(arg: {
139
+ walletId: string;
140
+ userId: string;
141
+ }): Promise<{
142
+ timeStamp: string;
143
+ proofKeyPublicKey: string;
144
+ timestampSignature: string;
145
+ }>;
51
146
  /**
52
147
  * 检查当前连接的钱包
53
148
  * 用户的当前活跃钱包会出现在数组的第一个
@@ -71,7 +166,7 @@ interface IWallet extends EventEmitter<WalletEvents> {
71
166
  signOrder(arg: {
72
167
  walletId: string;
73
168
  walletAddress: string;
74
- bianceChainId: string;
169
+ binanceChainId: string;
75
170
  txData: string;
76
171
  feeAmount: string;
77
172
  feeAmountLevel?: 'Low' | 'Medium' | 'High' | 'Custom';
@@ -97,4 +192,4 @@ declare const checkExtensionInstalled: () => boolean;
97
192
  declare const checkExtensionSupported: (feature: Features) => any;
98
193
  declare const getMultichainWallet: () => IWallet | null;
99
194
 
100
- export { ChainType, Features, IConnectedWallet, IWallet, WalletEvents, WalletType, checkExtensionInstalled, checkExtensionSupported, getMultichainWallet };
195
+ export { ChainType, Features, IConnectedWallet, IWallet, SASAuthorizeInfo, SASAuthorizeInfoItem, SASRequestConfig, SASRequestPublicKeyVo, WalletEvents, WalletType, checkExtensionInstalled, checkExtensionSupported, getMultichainWallet };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@binance/w3w-multichain-connector",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "A multichain connector for Binance Wallet",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
package/src/type.ts CHANGED
@@ -23,6 +23,38 @@ export interface IConnectedWallet {
23
23
  }[]
24
24
  }
25
25
 
26
+ export interface SASRequestConfig {
27
+ publicKeyList: SASRequestPublicKeyVo[]
28
+ timestamp: number
29
+ }
30
+ export interface SASRequestPublicKeyVo {
31
+ binanceChainId: string
32
+ attestationForKeyShareA: string
33
+ /**
34
+ * attestation中的多个PCR0,配置在Apollo Configs,用于验证attestation
35
+ */
36
+ attestationPCR0s: string[]
37
+ publicKeyForKeyShareA: string
38
+ spsVersion: string
39
+ }
40
+
41
+ export interface SASAuthorizeInfo {
42
+ walletType: 'SEED_PHRASE' | 'PRIVATE_KEY'
43
+ proofKeyPublicKey: string
44
+ expireAt: number
45
+ walletId: string
46
+ extensionId: string
47
+ authorizeList: SASAuthorizeInfoItem[]
48
+ }
49
+
50
+ export interface SASAuthorizeInfoItem {
51
+ chain: 'evm' | 'sol'
52
+ encryptedKeyShareB: string
53
+ encryptedKeyShareAData: string
54
+ publicKey: string
55
+ spsVersion: string
56
+ }
57
+
26
58
  export interface WalletEvents {
27
59
  walletLockedChanged: (isLocked: boolean) => void
28
60
  autoSignEnabledChanged: (isEnabled: boolean) => void
@@ -33,6 +65,73 @@ export interface WalletEvents {
33
65
  export interface IWallet extends EventEmitter<WalletEvents> {
34
66
  requestConnect(binanceChainIds: string[]): Promise<IConnectedWallet[]>
35
67
 
68
+ /**
69
+ * 链接插件的时候同时发起开启SAS的请求
70
+ * 如果用户同意,插件会记录下当前用户同意开启的SAS
71
+ */
72
+ requestConnectWithSAS(args: {
73
+ binanceChainIds: string[]
74
+ userId: string
75
+ enabledWalletIds: string[]
76
+ }): Promise<{
77
+ wallet: IConnectedWallet
78
+ aggreeEnableSAS: boolean
79
+ }>
80
+
81
+ /**
82
+ * 弹出要求用户同意开启SAS的弹窗
83
+ */
84
+ requestEnableSAS(arg: { walletId: string; userId: string }): Promise<{
85
+ aggreeEnableSAS: boolean
86
+ }>
87
+
88
+ /**
89
+ * 用户同意开启SAS后,获取SAS的keyshare
90
+ * 由于同一个钱包可能在app端被用户开启,所以插件不会校验用户有没有在插件端同意过
91
+ * 假如用户钱包锁住了,如果!isSilent, 会弹出解锁弹窗
92
+ * 否则keyshare获取失败,返回null
93
+ */
94
+ getSASKeyshare(arg: {
95
+ walletId: string
96
+ userId: string
97
+ requestConfig: SASRequestConfig
98
+ isSlient?: false
99
+ }): Promise<SASAuthorizeInfo>
100
+
101
+ getSASKeyshare(arg: {
102
+ walletId: string
103
+ userId: string
104
+ requestConfig: SASRequestConfig
105
+ isSlient: true
106
+ }): Promise<SASAuthorizeInfo | null>
107
+
108
+ /**
109
+ * 同步已链接钱包的SAS状态
110
+ */
111
+ syncSASStatus(arg: {
112
+ userId: string
113
+ statusList: {
114
+ walletId: string
115
+ enabled: boolean
116
+ }[]
117
+ }): Promise<void>
118
+
119
+ getConnectedWalletAndProofKey(arg: { userId: string }): Promise<
120
+ {
121
+ wallet: IConnectedWallet
122
+ proofKeyPublicKey?: string
123
+ }[]
124
+ >
125
+
126
+ /**
127
+ * 下单前获取ProofKey签名
128
+ */
129
+ getSASProofKeySignature(arg: { walletId: string; userId: string }): Promise<{
130
+ timeStamp: string
131
+ proofKeyPublicKey: string
132
+ timestampSignature: string
133
+ }>
134
+
36
135
  /**
37
136
  * 检查当前连接的钱包
38
137
  * 用户的当前活跃钱包会出现在数组的第一个
@@ -64,7 +163,7 @@ export interface IWallet extends EventEmitter<WalletEvents> {
64
163
  signOrder(arg: {
65
164
  walletId: string
66
165
  walletAddress: string
67
- bianceChainId: string
166
+ binanceChainId: string
68
167
  txData: string
69
168
  feeAmount: string
70
169
  feeAmountLevel?: 'Low' | 'Medium' | 'High' | 'Custom'