@bsv/sdk 1.4.24 → 1.5.1
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 +14 -0
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/script/Script.js +21 -1
- package/dist/cjs/src/script/Script.js.map +1 -1
- package/dist/cjs/src/wallet/WalletClient.js +12 -2
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/ReactNativeWebView.js +165 -0
- package/dist/cjs/src/wallet/substrates/ReactNativeWebView.js.map +1 -0
- package/dist/cjs/src/wallet/substrates/index.js +3 -1
- package/dist/cjs/src/wallet/substrates/index.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/script/Script.js +21 -1
- package/dist/esm/src/script/Script.js.map +1 -1
- package/dist/esm/src/wallet/WalletClient.js +12 -2
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/src/wallet/substrates/ReactNativeWebView.js +137 -0
- package/dist/esm/src/wallet/substrates/ReactNativeWebView.js.map +1 -0
- package/dist/esm/src/wallet/substrates/index.js +1 -0
- package/dist/esm/src/wallet/substrates/index.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/script/Script.d.ts.map +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/ReactNativeWebView.d.ts +412 -0
- package/dist/types/src/wallet/substrates/ReactNativeWebView.d.ts.map +1 -0
- package/dist/types/src/wallet/substrates/index.d.ts +1 -0
- package/dist/types/src/wallet/substrates/index.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/auth.md +47 -101
- package/docs/compat.md +24 -48
- package/docs/identity.md +8 -14
- package/docs/kvstore.md +3 -9
- package/docs/messages.md +4 -4
- package/docs/overlay-tools.md +21 -69
- package/docs/primitives.md +235 -379
- package/docs/registry.md +14 -20
- package/docs/script.md +32 -80
- package/docs/storage.md +11 -17
- package/docs/totp.md +5 -11
- package/docs/transaction.md +66 -144
- package/docs/wallet.md +586 -183
- package/package.json +1 -1
- package/src/script/Script.ts +22 -1
- package/src/wallet/WalletClient.ts +13 -4
- package/src/wallet/substrates/ReactNativeWebView.ts +560 -0
- package/src/wallet/substrates/index.ts +1 -0
package/package.json
CHANGED
package/src/script/Script.ts
CHANGED
|
@@ -125,10 +125,28 @@ export default class Script {
|
|
|
125
125
|
bin = [...bin]
|
|
126
126
|
const chunks: ScriptChunk[] = []
|
|
127
127
|
|
|
128
|
+
let inConditionalBlock: number = 0
|
|
129
|
+
|
|
128
130
|
const br = new Reader(bin)
|
|
129
131
|
while (!br.eof()) {
|
|
130
132
|
const op = br.readUInt8()
|
|
131
133
|
|
|
134
|
+
// if OP_RETURN and not in a conditional block, do not parse the rest of the data,
|
|
135
|
+
// rather just return the last chunk as data without prefixing with data length.
|
|
136
|
+
if (op === OP.OP_RETURN && inConditionalBlock === 0) {
|
|
137
|
+
chunks.push({
|
|
138
|
+
op,
|
|
139
|
+
data: br.read()
|
|
140
|
+
})
|
|
141
|
+
break
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (op === OP.OP_IF || op === OP.OP_NOTIF || op === OP.OP_VERIF || op === OP.OP_VERNOTIF) {
|
|
145
|
+
inConditionalBlock++
|
|
146
|
+
} else if (op === OP.OP_ENDIF) {
|
|
147
|
+
inConditionalBlock--
|
|
148
|
+
}
|
|
149
|
+
|
|
132
150
|
let len = 0
|
|
133
151
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
134
152
|
let data: number[] = []
|
|
@@ -225,7 +243,10 @@ export default class Script {
|
|
|
225
243
|
const chunk = this.chunks[i]
|
|
226
244
|
const op = chunk.op
|
|
227
245
|
writer.writeUInt8(op)
|
|
228
|
-
if (chunk.data != null) {
|
|
246
|
+
if (op === OP.OP_RETURN && chunk.data != null) { // special case for unformatted data
|
|
247
|
+
writer.write(chunk.data)
|
|
248
|
+
break
|
|
249
|
+
} else if (chunk.data != null) {
|
|
229
250
|
if (op < OP.OP_PUSHDATA1) {
|
|
230
251
|
writer.write(chunk.data)
|
|
231
252
|
} else if (op === OP.OP_PUSHDATA1) {
|
|
@@ -40,6 +40,7 @@ import XDMSubstrate from './substrates/XDM.js'
|
|
|
40
40
|
import WalletWireTransceiver from './substrates/WalletWireTransceiver.js'
|
|
41
41
|
import HTTPWalletWire from './substrates/HTTPWalletWire.js'
|
|
42
42
|
import HTTPWalletJSON from './substrates/HTTPWalletJSON.js'
|
|
43
|
+
import ReactNativeWebView from './substrates/ReactNativeWebView.js'
|
|
43
44
|
|
|
44
45
|
const MAX_XDM_RESPONSE_WAIT = 200
|
|
45
46
|
|
|
@@ -91,6 +92,7 @@ export default class WalletClient implements WalletInterface {
|
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
try {
|
|
95
|
+
console.log('Connecting to substrate...')
|
|
94
96
|
sub = new WindowCWISubstrate()
|
|
95
97
|
await checkSub()
|
|
96
98
|
this.substrate = sub
|
|
@@ -113,10 +115,17 @@ export default class WalletClient implements WalletInterface {
|
|
|
113
115
|
await checkSub()
|
|
114
116
|
this.substrate = sub
|
|
115
117
|
} catch (e) {
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
// HTTP JSON failed, attempt the next...
|
|
119
|
+
try {
|
|
120
|
+
sub = new ReactNativeWebView(this.originator)
|
|
121
|
+
await checkSub()
|
|
122
|
+
this.substrate = sub
|
|
123
|
+
} catch (e) {
|
|
124
|
+
// No comms. Tell the user to install a BSV wallet.
|
|
125
|
+
throw new Error(
|
|
126
|
+
'No wallet available over any communication substrate. Install a BSV wallet today!'
|
|
127
|
+
)
|
|
128
|
+
}
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
}
|
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Base64String,
|
|
3
|
+
BasketStringUnder300Bytes,
|
|
4
|
+
BEEF,
|
|
5
|
+
BooleanDefaultFalse,
|
|
6
|
+
BooleanDefaultTrue,
|
|
7
|
+
Byte,
|
|
8
|
+
CertificateFieldNameUnder50Bytes,
|
|
9
|
+
DescriptionString5to50Bytes,
|
|
10
|
+
EntityIconURLStringMax500Bytes,
|
|
11
|
+
EntityNameStringMax100Bytes,
|
|
12
|
+
HexString,
|
|
13
|
+
ISOTimestampString,
|
|
14
|
+
KeyIDStringUnder800Bytes,
|
|
15
|
+
LabelStringUnder300Bytes,
|
|
16
|
+
OutpointString,
|
|
17
|
+
OutputTagStringUnder300Bytes,
|
|
18
|
+
PositiveInteger,
|
|
19
|
+
PositiveIntegerDefault10Max10000,
|
|
20
|
+
PositiveIntegerMax10,
|
|
21
|
+
PositiveIntegerOrZero,
|
|
22
|
+
ProtocolString5To400Bytes,
|
|
23
|
+
PubKeyHex,
|
|
24
|
+
SatoshiValue,
|
|
25
|
+
SecurityLevel,
|
|
26
|
+
TXIDHexString,
|
|
27
|
+
VersionString7To30Bytes,
|
|
28
|
+
WalletInterface
|
|
29
|
+
} from '../Wallet.interfaces.js'
|
|
30
|
+
import Random from '../../primitives/Random.js'
|
|
31
|
+
import * as Utils from '../../primitives/utils.js'
|
|
32
|
+
import { WalletError } from '../WalletError.js'
|
|
33
|
+
import { CallType } from './WalletWireCalls.js'
|
|
34
|
+
|
|
35
|
+
type ReactNativeWindow = Window & {
|
|
36
|
+
ReactNativeWebView: {
|
|
37
|
+
postMessage: (message: any) => void
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Facilitates wallet operations over cross-document messaging.
|
|
43
|
+
*/
|
|
44
|
+
export default class ReactNativeWebView implements WalletInterface {
|
|
45
|
+
private readonly domain: string
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
constructor(domain: string = '*') {
|
|
49
|
+
if (typeof window !== 'object') {
|
|
50
|
+
throw new Error('The XDM substrate requires a global window object.')
|
|
51
|
+
}
|
|
52
|
+
if (!(window as unknown as ReactNativeWindow).hasOwnProperty("ReactNativeWebView")) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
'The window object does not have a ReactNativeWebView property.'
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
if (typeof (window as unknown as ReactNativeWindow).ReactNativeWebView.postMessage !== 'function') {
|
|
58
|
+
throw new Error(
|
|
59
|
+
'The window.ReactNativeWebView property does not seem to support postMessage calls.'
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
this.domain = domain
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async invoke(call: CallType, args: any): Promise<any> {
|
|
66
|
+
return await new Promise((resolve, reject) => {
|
|
67
|
+
const id = Utils.toBase64(Random(12))
|
|
68
|
+
const listener = (e: MessageEvent): void => {
|
|
69
|
+
const data = JSON.parse(e.data)
|
|
70
|
+
if (
|
|
71
|
+
data.type !== 'CWI' ||
|
|
72
|
+
data.id !== id ||
|
|
73
|
+
data.isInvocation === true
|
|
74
|
+
) {
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
if (typeof window.removeEventListener === 'function') {
|
|
78
|
+
window.removeEventListener('message', listener)
|
|
79
|
+
}
|
|
80
|
+
if (data.status === 'error') {
|
|
81
|
+
const err = new WalletError(data.description, data.code)
|
|
82
|
+
reject(err)
|
|
83
|
+
} else {
|
|
84
|
+
resolve(data.result)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
window.addEventListener('message', listener)
|
|
88
|
+
;(window as unknown as ReactNativeWindow).ReactNativeWebView.postMessage(
|
|
89
|
+
JSON.stringify({
|
|
90
|
+
type: 'CWI',
|
|
91
|
+
isInvocation: true,
|
|
92
|
+
id,
|
|
93
|
+
call,
|
|
94
|
+
args
|
|
95
|
+
})
|
|
96
|
+
)
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async createAction(args: {
|
|
101
|
+
description: DescriptionString5to50Bytes
|
|
102
|
+
inputs?: Array<{
|
|
103
|
+
tx?: BEEF
|
|
104
|
+
outpoint: OutpointString
|
|
105
|
+
unlockingScript?: HexString
|
|
106
|
+
unlockingScriptLength?: PositiveInteger
|
|
107
|
+
inputDescription: DescriptionString5to50Bytes
|
|
108
|
+
sequenceNumber?: PositiveIntegerOrZero
|
|
109
|
+
}>
|
|
110
|
+
outputs?: Array<{
|
|
111
|
+
lockingScript: HexString
|
|
112
|
+
satoshis: SatoshiValue
|
|
113
|
+
outputDescription: DescriptionString5to50Bytes
|
|
114
|
+
basket?: BasketStringUnder300Bytes
|
|
115
|
+
customInstructions?: string
|
|
116
|
+
tags?: OutputTagStringUnder300Bytes[]
|
|
117
|
+
}>
|
|
118
|
+
lockTime?: PositiveIntegerOrZero
|
|
119
|
+
version?: PositiveIntegerOrZero
|
|
120
|
+
labels?: LabelStringUnder300Bytes[]
|
|
121
|
+
options?: {
|
|
122
|
+
signAndProcess?: BooleanDefaultTrue
|
|
123
|
+
acceptDelayedBroadcast?: BooleanDefaultTrue
|
|
124
|
+
trustSelf?: 'known'
|
|
125
|
+
knownTxids?: TXIDHexString[]
|
|
126
|
+
returnTXIDOnly?: BooleanDefaultFalse
|
|
127
|
+
noSend?: BooleanDefaultFalse
|
|
128
|
+
noSendChange?: OutpointString[]
|
|
129
|
+
sendWith?: TXIDHexString[]
|
|
130
|
+
}
|
|
131
|
+
}): Promise<{
|
|
132
|
+
txid?: TXIDHexString
|
|
133
|
+
tx?: BEEF
|
|
134
|
+
noSendChange?: OutpointString[]
|
|
135
|
+
sendWithResults?: Array<{
|
|
136
|
+
txid: TXIDHexString
|
|
137
|
+
status: 'unproven' | 'sending' | 'failed'
|
|
138
|
+
}>
|
|
139
|
+
signableTransaction?: { tx: BEEF, reference: Base64String }
|
|
140
|
+
}> {
|
|
141
|
+
return await this.invoke('createAction', args)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async signAction(args: {
|
|
145
|
+
spends: Record<
|
|
146
|
+
PositiveIntegerOrZero,
|
|
147
|
+
{ unlockingScript: HexString, sequenceNumber?: PositiveIntegerOrZero }
|
|
148
|
+
>
|
|
149
|
+
reference: Base64String
|
|
150
|
+
options?: {
|
|
151
|
+
acceptDelayedBroadcast?: BooleanDefaultTrue
|
|
152
|
+
returnTXIDOnly?: BooleanDefaultFalse
|
|
153
|
+
noSend?: BooleanDefaultFalse
|
|
154
|
+
noSendChange?: OutpointString[]
|
|
155
|
+
sendWith: TXIDHexString[]
|
|
156
|
+
}
|
|
157
|
+
}): Promise<{
|
|
158
|
+
txid?: TXIDHexString
|
|
159
|
+
tx?: BEEF
|
|
160
|
+
noSendChange?: OutpointString[]
|
|
161
|
+
sendWithResults?: Array<{
|
|
162
|
+
txid: TXIDHexString
|
|
163
|
+
status: 'unproven' | 'sending' | 'failed'
|
|
164
|
+
}>
|
|
165
|
+
}> {
|
|
166
|
+
return await this.invoke('signAction', args)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async abortAction(args: {
|
|
170
|
+
reference: Base64String
|
|
171
|
+
}): Promise<{ aborted: true }> {
|
|
172
|
+
return await this.invoke('abortAction', args)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async listActions(args: {
|
|
176
|
+
labels: LabelStringUnder300Bytes[]
|
|
177
|
+
labelQueryMode?: 'any' | 'all'
|
|
178
|
+
includeLabels?: BooleanDefaultFalse
|
|
179
|
+
includeInputs?: BooleanDefaultFalse
|
|
180
|
+
includeInputSourceLockingScripts?: BooleanDefaultFalse
|
|
181
|
+
includeInputUnlockingScripts?: BooleanDefaultFalse
|
|
182
|
+
includeOutputs?: BooleanDefaultFalse
|
|
183
|
+
includeOutputLockingScripts?: BooleanDefaultFalse
|
|
184
|
+
limit?: PositiveIntegerDefault10Max10000
|
|
185
|
+
offset?: PositiveIntegerOrZero
|
|
186
|
+
}): Promise<{
|
|
187
|
+
totalActions: PositiveIntegerOrZero
|
|
188
|
+
actions: Array<{
|
|
189
|
+
txid: TXIDHexString
|
|
190
|
+
satoshis: SatoshiValue
|
|
191
|
+
status:
|
|
192
|
+
| 'completed'
|
|
193
|
+
| 'unprocessed'
|
|
194
|
+
| 'sending'
|
|
195
|
+
| 'unproven'
|
|
196
|
+
| 'unsigned'
|
|
197
|
+
| 'nosend'
|
|
198
|
+
| 'nonfinal'
|
|
199
|
+
isOutgoing: boolean
|
|
200
|
+
description: DescriptionString5to50Bytes
|
|
201
|
+
labels?: LabelStringUnder300Bytes[]
|
|
202
|
+
version: PositiveIntegerOrZero
|
|
203
|
+
lockTime: PositiveIntegerOrZero
|
|
204
|
+
inputs?: Array<{
|
|
205
|
+
sourceOutpoint: OutpointString
|
|
206
|
+
sourceSatoshis: SatoshiValue
|
|
207
|
+
sourceLockingScript?: HexString
|
|
208
|
+
unlockingScript?: HexString
|
|
209
|
+
inputDescription: DescriptionString5to50Bytes
|
|
210
|
+
sequenceNumber: PositiveIntegerOrZero
|
|
211
|
+
}>
|
|
212
|
+
outputs?: Array<{
|
|
213
|
+
outputIndex: PositiveIntegerOrZero
|
|
214
|
+
satoshis: SatoshiValue
|
|
215
|
+
lockingScript?: HexString
|
|
216
|
+
spendable: boolean
|
|
217
|
+
outputDescription: DescriptionString5to50Bytes
|
|
218
|
+
basket: BasketStringUnder300Bytes
|
|
219
|
+
tags: OutputTagStringUnder300Bytes[]
|
|
220
|
+
customInstructions?: string
|
|
221
|
+
}>
|
|
222
|
+
}>
|
|
223
|
+
}> {
|
|
224
|
+
return await this.invoke('listActions', args)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async internalizeAction(args: {
|
|
228
|
+
tx: BEEF
|
|
229
|
+
outputs: Array<{
|
|
230
|
+
outputIndex: PositiveIntegerOrZero
|
|
231
|
+
protocol: 'wallet payment' | 'basket insertion'
|
|
232
|
+
paymentRemittance?: {
|
|
233
|
+
derivationPrefix: Base64String
|
|
234
|
+
derivationSuffix: Base64String
|
|
235
|
+
senderIdentityKey: PubKeyHex
|
|
236
|
+
}
|
|
237
|
+
insertionRemittance?: {
|
|
238
|
+
basket: BasketStringUnder300Bytes
|
|
239
|
+
customInstructions?: string
|
|
240
|
+
tags?: OutputTagStringUnder300Bytes[]
|
|
241
|
+
}
|
|
242
|
+
}>
|
|
243
|
+
description: DescriptionString5to50Bytes
|
|
244
|
+
labels?: LabelStringUnder300Bytes[]
|
|
245
|
+
}): Promise<{ accepted: true }> {
|
|
246
|
+
return await this.invoke('internalizeAction', args)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
async listOutputs(args: {
|
|
250
|
+
basket: BasketStringUnder300Bytes
|
|
251
|
+
tags?: OutputTagStringUnder300Bytes[]
|
|
252
|
+
tagQueryMode?: 'all' | 'any'
|
|
253
|
+
include?: 'locking scripts' | 'entire transactions'
|
|
254
|
+
includeCustomInstructions?: BooleanDefaultFalse
|
|
255
|
+
includeTags?: BooleanDefaultFalse
|
|
256
|
+
includeLabels?: BooleanDefaultFalse
|
|
257
|
+
limit?: PositiveIntegerDefault10Max10000
|
|
258
|
+
offset?: PositiveIntegerOrZero
|
|
259
|
+
}): Promise<{
|
|
260
|
+
totalOutputs: PositiveIntegerOrZero
|
|
261
|
+
outputs: Array<{
|
|
262
|
+
outpoint: OutpointString
|
|
263
|
+
satoshis: SatoshiValue
|
|
264
|
+
lockingScript?: HexString
|
|
265
|
+
tx?: BEEF
|
|
266
|
+
spendable: boolean
|
|
267
|
+
customInstructions?: string
|
|
268
|
+
tags?: OutputTagStringUnder300Bytes[]
|
|
269
|
+
labels?: LabelStringUnder300Bytes[]
|
|
270
|
+
}>
|
|
271
|
+
}> {
|
|
272
|
+
return await this.invoke('listOutputs', args)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async relinquishOutput(args: {
|
|
276
|
+
basket: BasketStringUnder300Bytes
|
|
277
|
+
output: OutpointString
|
|
278
|
+
}): Promise<{ relinquished: true }> {
|
|
279
|
+
return await this.invoke('relinquishOutput', args)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async getPublicKey(args: {
|
|
283
|
+
identityKey?: true
|
|
284
|
+
protocolID?: [SecurityLevel, ProtocolString5To400Bytes]
|
|
285
|
+
keyID?: KeyIDStringUnder800Bytes
|
|
286
|
+
privileged?: BooleanDefaultFalse
|
|
287
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
288
|
+
counterparty?: PubKeyHex | 'self' | 'anyone'
|
|
289
|
+
forSelf?: BooleanDefaultFalse
|
|
290
|
+
}): Promise<{ publicKey: PubKeyHex }> {
|
|
291
|
+
return await this.invoke('getPublicKey', args)
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
async revealCounterpartyKeyLinkage(args: {
|
|
295
|
+
counterparty: PubKeyHex
|
|
296
|
+
verifier: PubKeyHex
|
|
297
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
298
|
+
privileged?: BooleanDefaultFalse
|
|
299
|
+
}): Promise<{
|
|
300
|
+
prover: PubKeyHex
|
|
301
|
+
verifier: PubKeyHex
|
|
302
|
+
counterparty: PubKeyHex
|
|
303
|
+
revelationTime: ISOTimestampString
|
|
304
|
+
encryptedLinkage: Byte[]
|
|
305
|
+
encryptedLinkageProof: Byte[]
|
|
306
|
+
}> {
|
|
307
|
+
return await this.invoke('revealCounterpartyKeyLinkage', args)
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
async revealSpecificKeyLinkage(args: {
|
|
311
|
+
counterparty: PubKeyHex
|
|
312
|
+
verifier: PubKeyHex
|
|
313
|
+
protocolID: [SecurityLevel, ProtocolString5To400Bytes]
|
|
314
|
+
keyID: KeyIDStringUnder800Bytes
|
|
315
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
316
|
+
privileged?: BooleanDefaultFalse
|
|
317
|
+
}): Promise<{
|
|
318
|
+
prover: PubKeyHex
|
|
319
|
+
verifier: PubKeyHex
|
|
320
|
+
counterparty: PubKeyHex
|
|
321
|
+
protocolID: [SecurityLevel, ProtocolString5To400Bytes]
|
|
322
|
+
keyID: KeyIDStringUnder800Bytes
|
|
323
|
+
encryptedLinkage: Byte[]
|
|
324
|
+
encryptedLinkageProof: Byte[]
|
|
325
|
+
proofType: Byte
|
|
326
|
+
}> {
|
|
327
|
+
return await this.invoke('revealSpecificKeyLinkage', args)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async encrypt(args: {
|
|
331
|
+
plaintext: Byte[]
|
|
332
|
+
protocolID: [SecurityLevel, ProtocolString5To400Bytes]
|
|
333
|
+
keyID: KeyIDStringUnder800Bytes
|
|
334
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
335
|
+
counterparty?: PubKeyHex | 'self' | 'anyone'
|
|
336
|
+
privileged?: BooleanDefaultFalse
|
|
337
|
+
}): Promise<{ ciphertext: Byte[] }> {
|
|
338
|
+
return await this.invoke('encrypt', args)
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async decrypt(args: {
|
|
342
|
+
ciphertext: Byte[]
|
|
343
|
+
protocolID: [SecurityLevel, ProtocolString5To400Bytes]
|
|
344
|
+
keyID: KeyIDStringUnder800Bytes
|
|
345
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
346
|
+
counterparty?: PubKeyHex | 'self' | 'anyone'
|
|
347
|
+
privileged?: BooleanDefaultFalse
|
|
348
|
+
}): Promise<{ plaintext: Byte[] }> {
|
|
349
|
+
return await this.invoke('decrypt', args)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
async createHmac(args: {
|
|
353
|
+
data: Byte[]
|
|
354
|
+
protocolID: [SecurityLevel, ProtocolString5To400Bytes]
|
|
355
|
+
keyID: KeyIDStringUnder800Bytes
|
|
356
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
357
|
+
counterparty?: PubKeyHex | 'self' | 'anyone'
|
|
358
|
+
privileged?: BooleanDefaultFalse
|
|
359
|
+
}): Promise<{ hmac: Byte[] }> {
|
|
360
|
+
return await this.invoke('createHmac', args)
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
async verifyHmac(args: {
|
|
364
|
+
data: Byte[]
|
|
365
|
+
hmac: Byte[]
|
|
366
|
+
protocolID: [SecurityLevel, ProtocolString5To400Bytes]
|
|
367
|
+
keyID: KeyIDStringUnder800Bytes
|
|
368
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
369
|
+
counterparty?: PubKeyHex | 'self' | 'anyone'
|
|
370
|
+
privileged?: BooleanDefaultFalse
|
|
371
|
+
}): Promise<{ valid: true }> {
|
|
372
|
+
return await this.invoke('verifyHmac', args)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async createSignature(args: {
|
|
376
|
+
data?: Byte[]
|
|
377
|
+
hashToDirectlySign?: Byte[]
|
|
378
|
+
protocolID: [SecurityLevel, ProtocolString5To400Bytes]
|
|
379
|
+
keyID: KeyIDStringUnder800Bytes
|
|
380
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
381
|
+
counterparty?: PubKeyHex | 'self' | 'anyone'
|
|
382
|
+
privileged?: BooleanDefaultFalse
|
|
383
|
+
}): Promise<{ signature: Byte[] }> {
|
|
384
|
+
return await this.invoke('createSignature', args)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async verifySignature(args: {
|
|
388
|
+
data?: Byte[]
|
|
389
|
+
hashToDirectlyVerify?: Byte[]
|
|
390
|
+
signature: Byte[]
|
|
391
|
+
protocolID: [SecurityLevel, ProtocolString5To400Bytes]
|
|
392
|
+
keyID: KeyIDStringUnder800Bytes
|
|
393
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
394
|
+
counterparty?: PubKeyHex | 'self' | 'anyone'
|
|
395
|
+
forSelf?: BooleanDefaultFalse
|
|
396
|
+
privileged?: BooleanDefaultFalse
|
|
397
|
+
}): Promise<{ valid: true }> {
|
|
398
|
+
return await this.invoke('verifySignature', args)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
async acquireCertificate(args: {
|
|
402
|
+
type: Base64String
|
|
403
|
+
subject: PubKeyHex
|
|
404
|
+
serialNumber: Base64String
|
|
405
|
+
revocationOutpoint: OutpointString
|
|
406
|
+
signature: HexString
|
|
407
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
408
|
+
certifier: PubKeyHex
|
|
409
|
+
keyringRevealer: PubKeyHex | 'certifier'
|
|
410
|
+
keyringForSubject: Record<CertificateFieldNameUnder50Bytes, Base64String>
|
|
411
|
+
acquisitionProtocol: 'direct' | 'issuance'
|
|
412
|
+
certifierUrl?: string
|
|
413
|
+
}): Promise<{
|
|
414
|
+
type: Base64String
|
|
415
|
+
subject: PubKeyHex
|
|
416
|
+
serialNumber: Base64String
|
|
417
|
+
certifier: PubKeyHex
|
|
418
|
+
revocationOutpoint: OutpointString
|
|
419
|
+
signature: HexString
|
|
420
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
421
|
+
}> {
|
|
422
|
+
return await this.invoke('acquireCertificate', args)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
async listCertificates(args: {
|
|
426
|
+
certifiers: PubKeyHex[]
|
|
427
|
+
types: Base64String[]
|
|
428
|
+
limit?: PositiveIntegerDefault10Max10000
|
|
429
|
+
offset?: PositiveIntegerOrZero
|
|
430
|
+
privileged?: BooleanDefaultFalse
|
|
431
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
432
|
+
}): Promise<{
|
|
433
|
+
totalCertificates: PositiveIntegerOrZero
|
|
434
|
+
certificates: Array<{
|
|
435
|
+
type: Base64String
|
|
436
|
+
subject: PubKeyHex
|
|
437
|
+
serialNumber: Base64String
|
|
438
|
+
certifier: PubKeyHex
|
|
439
|
+
revocationOutpoint: OutpointString
|
|
440
|
+
signature: HexString
|
|
441
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
442
|
+
}>
|
|
443
|
+
}> {
|
|
444
|
+
return await this.invoke('listCertificates', args)
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
async proveCertificate(args: {
|
|
448
|
+
certificate: {
|
|
449
|
+
type: Base64String
|
|
450
|
+
subject: PubKeyHex
|
|
451
|
+
serialNumber: Base64String
|
|
452
|
+
certifier: PubKeyHex
|
|
453
|
+
revocationOutpoint: OutpointString
|
|
454
|
+
signature: HexString
|
|
455
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
456
|
+
}
|
|
457
|
+
fieldsToReveal: CertificateFieldNameUnder50Bytes[]
|
|
458
|
+
verifier: PubKeyHex
|
|
459
|
+
privileged?: BooleanDefaultFalse
|
|
460
|
+
privilegedReason?: DescriptionString5to50Bytes
|
|
461
|
+
}): Promise<{
|
|
462
|
+
keyringForVerifier: Record<CertificateFieldNameUnder50Bytes, Base64String>
|
|
463
|
+
}> {
|
|
464
|
+
return await this.invoke('proveCertificate', args)
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
async relinquishCertificate(args: {
|
|
468
|
+
type: Base64String
|
|
469
|
+
serialNumber: Base64String
|
|
470
|
+
certifier: PubKeyHex
|
|
471
|
+
}): Promise<{ relinquished: true }> {
|
|
472
|
+
return await this.invoke('relinquishCertificate', args)
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
async discoverByIdentityKey(args: {
|
|
476
|
+
identityKey: PubKeyHex
|
|
477
|
+
limit?: PositiveIntegerDefault10Max10000
|
|
478
|
+
offset?: PositiveIntegerOrZero
|
|
479
|
+
}): Promise<{
|
|
480
|
+
totalCertificates: PositiveIntegerOrZero
|
|
481
|
+
certificates: Array<{
|
|
482
|
+
type: Base64String
|
|
483
|
+
subject: PubKeyHex
|
|
484
|
+
serialNumber: Base64String
|
|
485
|
+
certifier: PubKeyHex
|
|
486
|
+
revocationOutpoint: OutpointString
|
|
487
|
+
signature: HexString
|
|
488
|
+
fields: Record<CertificateFieldNameUnder50Bytes, Base64String>
|
|
489
|
+
certifierInfo: {
|
|
490
|
+
name: EntityNameStringMax100Bytes
|
|
491
|
+
iconUrl: EntityIconURLStringMax500Bytes
|
|
492
|
+
description: DescriptionString5to50Bytes
|
|
493
|
+
trust: PositiveIntegerMax10
|
|
494
|
+
}
|
|
495
|
+
publiclyRevealedKeyring: Record<
|
|
496
|
+
CertificateFieldNameUnder50Bytes,
|
|
497
|
+
Base64String
|
|
498
|
+
>
|
|
499
|
+
decryptedFields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
500
|
+
}>
|
|
501
|
+
}> {
|
|
502
|
+
return await this.invoke('discoverByIdentityKey', args)
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
async discoverByAttributes(args: {
|
|
506
|
+
attributes: Record<CertificateFieldNameUnder50Bytes, string>
|
|
507
|
+
limit?: PositiveIntegerDefault10Max10000
|
|
508
|
+
offset?: PositiveIntegerOrZero
|
|
509
|
+
}): Promise<{
|
|
510
|
+
totalCertificates: PositiveIntegerOrZero
|
|
511
|
+
certificates: Array<{
|
|
512
|
+
type: Base64String
|
|
513
|
+
subject: PubKeyHex
|
|
514
|
+
serialNumber: Base64String
|
|
515
|
+
certifier: PubKeyHex
|
|
516
|
+
revocationOutpoint: OutpointString
|
|
517
|
+
signature: HexString
|
|
518
|
+
fields: Record<CertificateFieldNameUnder50Bytes, Base64String>
|
|
519
|
+
certifierInfo: {
|
|
520
|
+
name: EntityNameStringMax100Bytes
|
|
521
|
+
iconUrl: EntityIconURLStringMax500Bytes
|
|
522
|
+
description: DescriptionString5to50Bytes
|
|
523
|
+
trust: PositiveIntegerMax10
|
|
524
|
+
}
|
|
525
|
+
publiclyRevealedKeyring: Record<
|
|
526
|
+
CertificateFieldNameUnder50Bytes,
|
|
527
|
+
Base64String
|
|
528
|
+
>
|
|
529
|
+
decryptedFields: Record<CertificateFieldNameUnder50Bytes, string>
|
|
530
|
+
}>
|
|
531
|
+
}> {
|
|
532
|
+
return await this.invoke('discoverByAttributes', args)
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
async isAuthenticated(args: {}): Promise<{ authenticated: true }> {
|
|
536
|
+
return await this.invoke('isAuthenticated', args)
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
async waitForAuthentication(args: {}): Promise<{ authenticated: true }> {
|
|
540
|
+
return await this.invoke('waitForAuthentication', args)
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
async getHeight(args: {}): Promise<{ height: PositiveInteger }> {
|
|
544
|
+
return await this.invoke('getHeight', args)
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
async getHeaderForHeight(args: {
|
|
548
|
+
height: PositiveInteger
|
|
549
|
+
}): Promise<{ header: HexString }> {
|
|
550
|
+
return await this.invoke('getHeaderForHeight', args)
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
async getNetwork(args: {}): Promise<{ network: 'mainnet' | 'testnet' }> {
|
|
554
|
+
return await this.invoke('getNetwork', args)
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
async getVersion(args: {}): Promise<{ version: VersionString7To30Bytes }> {
|
|
558
|
+
return await this.invoke('getVersion', args)
|
|
559
|
+
}
|
|
560
|
+
}
|
|
@@ -6,3 +6,4 @@ export { default as WalletWireTransceiver } from './WalletWireTransceiver.js'
|
|
|
6
6
|
export { default as WalletWireProcessor } from './WalletWireProcessor.js'
|
|
7
7
|
export { default as HTTPWalletWire } from './HTTPWalletWire.js'
|
|
8
8
|
export { default as HTTPWalletJSON } from './HTTPWalletJSON.js'
|
|
9
|
+
export { default as ReactNativeWebView } from './ReactNativeWebView.js'
|