@bsv/sdk 1.3.36 → 1.4.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/dist/cjs/mod.js +3 -0
- package/dist/cjs/mod.js.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/auth/Peer.js +42 -14
- package/dist/cjs/src/auth/Peer.js.map +1 -1
- package/dist/cjs/src/auth/certificates/Certificate.js +50 -22
- package/dist/cjs/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/MasterCertificate.js +35 -10
- package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +28 -4
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js +5 -2
- package/dist/cjs/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/cjs/src/auth/clients/AuthFetch.js +50 -20
- package/dist/cjs/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js +40 -17
- package/dist/cjs/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/cjs/src/auth/utils/createNonce.js +31 -4
- package/dist/cjs/src/auth/utils/createNonce.js.map +1 -1
- package/dist/cjs/src/auth/utils/verifyNonce.js +26 -3
- package/dist/cjs/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/cjs/src/identity/IdentityClient.js +258 -0
- package/dist/cjs/src/identity/IdentityClient.js.map +1 -0
- package/dist/cjs/src/identity/index.js +19 -0
- package/dist/cjs/src/identity/index.js.map +1 -0
- package/dist/cjs/src/identity/types/index.js +30 -0
- package/dist/cjs/src/identity/types/index.js.map +1 -0
- package/dist/cjs/src/overlay-tools/LookupResolver.js +2 -2
- package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/cjs/src/primitives/utils.js.map +1 -1
- package/dist/cjs/src/registry/RegistryClient.js +392 -0
- package/dist/cjs/src/registry/RegistryClient.js.map +1 -0
- package/dist/cjs/src/registry/index.js +19 -0
- package/dist/cjs/src/registry/index.js.map +1 -0
- package/dist/cjs/src/registry/types/index.js +3 -0
- package/dist/cjs/src/registry/types/index.js.map +1 -0
- package/dist/cjs/src/storage/StorageUploader.js +93 -0
- package/dist/cjs/src/storage/StorageUploader.js.map +1 -0
- package/dist/cjs/src/storage/StorageUtils.js +73 -0
- package/dist/cjs/src/storage/StorageUtils.js.map +1 -0
- package/dist/cjs/src/storage/__test/StorageUploader.test.js +92 -0
- package/dist/cjs/src/storage/__test/StorageUploader.test.js.map +1 -0
- package/dist/cjs/src/storage/__test/StorageUtils.test.js +97 -0
- package/dist/cjs/src/storage/__test/StorageUtils.test.js.map +1 -0
- package/dist/cjs/src/storage/index.js +30 -0
- package/dist/cjs/src/storage/index.js.map +1 -0
- package/dist/cjs/src/wallet/WalletClient.js +4 -4
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js +26 -3
- package/dist/cjs/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +178 -155
- package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +171 -148
- package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/XDM.js +29 -2
- package/dist/cjs/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/mod.js +3 -0
- package/dist/esm/mod.js.map +1 -1
- package/dist/esm/src/auth/Peer.js +7 -5
- package/dist/esm/src/auth/Peer.js.map +1 -1
- package/dist/esm/src/auth/certificates/Certificate.js +3 -1
- package/dist/esm/src/auth/certificates/Certificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js +3 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js +2 -1
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js +1 -1
- package/dist/esm/src/auth/certificates/__tests/CompletedProtoWallet.js.map +1 -1
- package/dist/esm/src/auth/clients/AuthFetch.js +5 -1
- package/dist/esm/src/auth/clients/AuthFetch.js.map +1 -1
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js +1 -1
- package/dist/esm/src/auth/transports/SimplifiedFetchTransport.js.map +1 -1
- package/dist/esm/src/auth/utils/createNonce.js +2 -1
- package/dist/esm/src/auth/utils/createNonce.js.map +1 -1
- package/dist/esm/src/auth/utils/verifyNonce.js +1 -1
- package/dist/esm/src/auth/utils/verifyNonce.js.map +1 -1
- package/dist/esm/src/identity/IdentityClient.js +255 -0
- package/dist/esm/src/identity/IdentityClient.js.map +1 -0
- package/dist/esm/src/identity/index.js +3 -0
- package/dist/esm/src/identity/index.js.map +1 -0
- package/dist/esm/src/identity/types/index.js +27 -0
- package/dist/esm/src/identity/types/index.js.map +1 -0
- package/dist/esm/src/overlay-tools/LookupResolver.js +2 -2
- package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/esm/src/primitives/utils.js.map +1 -1
- package/dist/esm/src/registry/RegistryClient.js +388 -0
- package/dist/esm/src/registry/RegistryClient.js.map +1 -0
- package/dist/esm/src/registry/index.js +3 -0
- package/dist/esm/src/registry/index.js.map +1 -0
- package/dist/esm/src/registry/types/index.js +2 -0
- package/dist/esm/src/registry/types/index.js.map +1 -0
- package/dist/esm/src/storage/StorageUploader.js +68 -0
- package/dist/esm/src/storage/StorageUploader.js.map +1 -0
- package/dist/esm/src/storage/StorageUtils.js +65 -0
- package/dist/esm/src/storage/StorageUtils.js.map +1 -0
- package/dist/esm/src/storage/__test/StorageUploader.test.js +64 -0
- package/dist/esm/src/storage/__test/StorageUploader.test.js.map +1 -0
- package/dist/esm/src/storage/__test/StorageUtils.test.js +72 -0
- package/dist/esm/src/storage/__test/StorageUtils.test.js.map +1 -0
- package/dist/esm/src/storage/index.js +3 -0
- package/dist/esm/src/storage/index.js.map +1 -0
- package/dist/esm/src/wallet/WalletClient.js +4 -4
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletWire.js +1 -1
- package/dist/esm/src/wallet/substrates/HTTPWalletWire.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +2 -2
- package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
- package/dist/esm/src/wallet/substrates/XDM.js +2 -1
- package/dist/esm/src/wallet/substrates/XDM.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/mod.d.ts +3 -0
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/types/src/auth/Peer.d.ts +1 -1
- package/dist/types/src/auth/Peer.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/Certificate.d.ts +2 -1
- package/dist/types/src/auth/certificates/Certificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts +2 -1
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts +2 -1
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts +1 -1
- package/dist/types/src/auth/certificates/__tests/CompletedProtoWallet.d.ts.map +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts +1 -1
- package/dist/types/src/auth/clients/AuthFetch.d.ts.map +1 -1
- package/dist/types/src/auth/utils/createNonce.d.ts +1 -1
- package/dist/types/src/auth/utils/createNonce.d.ts.map +1 -1
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts +1 -1
- package/dist/types/src/auth/utils/getVerifiableCertificates.d.ts.map +1 -1
- package/dist/types/src/auth/utils/verifyNonce.d.ts +1 -1
- package/dist/types/src/auth/utils/verifyNonce.d.ts.map +1 -1
- package/dist/types/src/identity/IdentityClient.d.ts +50 -0
- package/dist/types/src/identity/IdentityClient.d.ts.map +1 -0
- package/dist/types/src/identity/index.d.ts +3 -0
- package/dist/types/src/identity/index.d.ts.map +1 -0
- package/dist/types/src/identity/types/index.d.ts +30 -0
- package/dist/types/src/identity/types/index.d.ts.map +1 -0
- package/dist/types/src/primitives/utils.d.ts +4 -1
- package/dist/types/src/primitives/utils.d.ts.map +1 -1
- package/dist/types/src/registry/RegistryClient.d.ts +94 -0
- package/dist/types/src/registry/RegistryClient.d.ts.map +1 -0
- package/dist/types/src/registry/index.d.ts +3 -0
- package/dist/types/src/registry/index.d.ts.map +1 -0
- package/dist/types/src/registry/types/index.d.ts +86 -0
- package/dist/types/src/registry/types/index.d.ts.map +1 -0
- package/dist/types/src/storage/StorageUploader.d.ts +40 -0
- package/dist/types/src/storage/StorageUploader.d.ts.map +1 -0
- package/dist/types/src/storage/StorageUtils.d.ts +31 -0
- package/dist/types/src/storage/StorageUtils.d.ts.map +1 -0
- package/dist/types/src/storage/__test/StorageUploader.test.d.ts +2 -0
- package/dist/types/src/storage/__test/StorageUploader.test.d.ts.map +1 -0
- package/dist/types/src/storage/__test/StorageUtils.test.d.ts +2 -0
- package/dist/types/src/storage/__test/StorageUtils.test.d.ts.map +1 -0
- package/dist/types/src/storage/index.d.ts +3 -0
- package/dist/types/src/storage/index.d.ts.map +1 -0
- package/dist/types/src/wallet/substrates/XDM.d.ts +1 -1
- package/dist/types/src/wallet/substrates/XDM.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/primitives.md +4 -1
- package/docs/storage.md +210 -0
- package/docs/wallet-substrates.md +0 -225
- package/mod.ts +3 -0
- package/package.json +11 -1
- package/src/auth/Peer.ts +8 -5
- package/src/auth/__tests/Peer.test.ts +31 -31
- package/src/auth/certificates/Certificate.ts +5 -5
- package/src/auth/certificates/MasterCertificate.ts +5 -5
- package/src/auth/certificates/VerifiableCertificate.ts +6 -6
- package/src/auth/certificates/__tests/CompletedProtoWallet.ts +1 -15
- package/src/auth/clients/AuthFetch.ts +6 -1
- package/src/auth/transports/SimplifiedFetchTransport.ts +1 -1
- package/src/auth/utils/createNonce.ts +3 -3
- package/src/auth/utils/getVerifiableCertificates.ts +1 -1
- package/src/auth/utils/verifyNonce.ts +2 -1
- package/src/identity/IdentityClient.ts +305 -0
- package/src/identity/README.md +93 -0
- package/src/identity/__tests/IdentityClient.test.ts +278 -0
- package/src/identity/index.ts +2 -0
- package/src/identity/types/index.ts +46 -0
- package/src/overlay-tools/LookupResolver.ts +2 -2
- package/src/primitives/utils.ts +1 -1
- package/src/registry/RegistryClient.ts +493 -0
- package/src/registry/__tests/RegistryClient.test.ts +444 -0
- package/src/registry/index.ts +2 -0
- package/src/registry/types/index.ts +101 -0
- package/src/storage/StorageUploader.ts +108 -0
- package/src/storage/StorageUtils.ts +66 -0
- package/src/storage/__test/StorageUploader.test.ts +80 -0
- package/src/storage/__test/StorageUtils.test.ts +86 -0
- package/src/storage/index.ts +2 -0
- package/src/wallet/WalletClient.ts +4 -4
- package/src/wallet/substrates/HTTPWalletWire.ts +1 -1
- package/src/wallet/substrates/WalletWireProcessor.ts +1 -1
- package/src/wallet/substrates/WalletWireTransceiver.ts +2 -2
- package/src/wallet/substrates/XDM.ts +3 -2
package/docs/primitives.md
CHANGED
|
@@ -7885,7 +7885,10 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
7885
7885
|
### Variable: fromBase58Check
|
|
7886
7886
|
|
|
7887
7887
|
```ts
|
|
7888
|
-
fromBase58Check = (str: string, enc?: "hex", prefixLength: number = 1):
|
|
7888
|
+
fromBase58Check = (str: string, enc?: "hex", prefixLength: number = 1): {
|
|
7889
|
+
data: number[] | string;
|
|
7890
|
+
prefix: number[] | string;
|
|
7891
|
+
} => {
|
|
7889
7892
|
const bin = fromBase58(str);
|
|
7890
7893
|
let prefix: string | number[] = bin.slice(0, prefixLength);
|
|
7891
7894
|
let data: string | number[] = bin.slice(prefixLength, -4);
|
package/docs/storage.md
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
4
|
+
|
|
5
|
+
## Interfaces
|
|
6
|
+
|
|
7
|
+
| |
|
|
8
|
+
| --- |
|
|
9
|
+
| [UploadFileResult](#interface-uploadfileresult) |
|
|
10
|
+
| [UploadableFile](#interface-uploadablefile) |
|
|
11
|
+
| [UploaderConfig](#interface-uploaderconfig) |
|
|
12
|
+
|
|
13
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
### Interface: UploadFileResult
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
export interface UploadFileResult {
|
|
21
|
+
published: boolean;
|
|
22
|
+
uhrpURL: string;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
### Interface: UploadableFile
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
export interface UploadableFile {
|
|
33
|
+
data: number[];
|
|
34
|
+
type: string;
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
### Interface: UploaderConfig
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
export interface UploaderConfig {
|
|
45
|
+
storageURL: string;
|
|
46
|
+
wallet: WalletInterface;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
See also: [WalletInterface](./wallet.md#interface-walletinterface)
|
|
51
|
+
|
|
52
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
## Classes
|
|
56
|
+
|
|
57
|
+
### Class: StorageUploader
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
export class StorageUploader {
|
|
61
|
+
constructor(config: UploaderConfig)
|
|
62
|
+
public async publishFile(params: {
|
|
63
|
+
file: UploadableFile;
|
|
64
|
+
retentionPeriod: number;
|
|
65
|
+
}): Promise<UploadFileResult>
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
See also: [UploadFileResult](./storage.md#interface-uploadfileresult), [UploadableFile](./storage.md#interface-uploadablefile), [UploaderConfig](./storage.md#interface-uploaderconfig)
|
|
70
|
+
|
|
71
|
+
#### Method publishFile
|
|
72
|
+
|
|
73
|
+
Publishes a file to the storage server with the specified retention period.
|
|
74
|
+
|
|
75
|
+
This will:
|
|
76
|
+
1. Request an upload URL from the server.
|
|
77
|
+
2. Perform an HTTP PUT to upload the file’s raw bytes.
|
|
78
|
+
3. Return a UHRP URL referencing the file once published.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
public async publishFile(params: {
|
|
82
|
+
file: UploadableFile;
|
|
83
|
+
retentionPeriod: number;
|
|
84
|
+
}): Promise<UploadFileResult>
|
|
85
|
+
```
|
|
86
|
+
See also: [UploadFileResult](./storage.md#interface-uploadfileresult), [UploadableFile](./storage.md#interface-uploadablefile)
|
|
87
|
+
|
|
88
|
+
Returns
|
|
89
|
+
|
|
90
|
+
An object indicating whether the file was published successfully and the resulting UHRP URL.
|
|
91
|
+
|
|
92
|
+
Argument Details
|
|
93
|
+
|
|
94
|
+
+ **params.file**
|
|
95
|
+
+ An object describing the file’s data (number[] array of bytes) and mime type.
|
|
96
|
+
+ **params.retentionPeriod**
|
|
97
|
+
+ Number of minutes to keep the file hosted.
|
|
98
|
+
|
|
99
|
+
Throws
|
|
100
|
+
|
|
101
|
+
If either the upload info request or the subsequent file upload request fails (non-OK HTTP status).
|
|
102
|
+
|
|
103
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
## Functions
|
|
107
|
+
|
|
108
|
+
## Types
|
|
109
|
+
|
|
110
|
+
## Enums
|
|
111
|
+
|
|
112
|
+
## Variables
|
|
113
|
+
|
|
114
|
+
| |
|
|
115
|
+
| --- |
|
|
116
|
+
| [getHashFromURL](#variable-gethashfromurl) |
|
|
117
|
+
| [getURLForFile](#variable-geturlforfile) |
|
|
118
|
+
| [getURLForHash](#variable-geturlforhash) |
|
|
119
|
+
| [isValidURL](#variable-isvalidurl) |
|
|
120
|
+
| [normalizeURL](#variable-normalizeurl) |
|
|
121
|
+
|
|
122
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### Variable: getHashFromURL
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
getHashFromURL = (URL: string): number[] => {
|
|
130
|
+
URL = normalizeURL(URL);
|
|
131
|
+
const { data, prefix } = fromBase58Check(URL, undefined, 2);
|
|
132
|
+
if (data.length !== 32) {
|
|
133
|
+
throw new Error("Invalid length!");
|
|
134
|
+
}
|
|
135
|
+
if (toHex(prefix as number[]) !== "ce00") {
|
|
136
|
+
throw new Error("Bad prefix");
|
|
137
|
+
}
|
|
138
|
+
return data as number[];
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
See also: [fromBase58Check](./primitives.md#variable-frombase58check), [normalizeURL](./storage.md#variable-normalizeurl), [toHex](./primitives.md#variable-tohex)
|
|
143
|
+
|
|
144
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
### Variable: getURLForFile
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
getURLForFile = (file: number[]): string => {
|
|
151
|
+
const hash = sha256(file);
|
|
152
|
+
return getURLForHash(hash);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
See also: [getURLForHash](./storage.md#variable-geturlforhash), [sha256](./primitives.md#variable-sha256)
|
|
157
|
+
|
|
158
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
### Variable: getURLForHash
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
getURLForHash = (hash: number[]): string => {
|
|
165
|
+
if (hash.length !== 32) {
|
|
166
|
+
throw new Error("Hash length must be 32 bytes (sha256)");
|
|
167
|
+
}
|
|
168
|
+
return toBase58Check(hash, toArray("ce00", "hex"));
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
See also: [toArray](./primitives.md#variable-toarray), [toBase58Check](./primitives.md#variable-tobase58check)
|
|
173
|
+
|
|
174
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
### Variable: isValidURL
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
isValidURL = (URL: string): boolean => {
|
|
181
|
+
try {
|
|
182
|
+
getHashFromURL(URL);
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
See also: [getHashFromURL](./storage.md#variable-gethashfromurl)
|
|
192
|
+
|
|
193
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
### Variable: normalizeURL
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
normalizeURL = (URL: string): string => {
|
|
200
|
+
if (URL.toLowerCase().startsWith("uhrp:"))
|
|
201
|
+
URL = URL.slice(5);
|
|
202
|
+
if (URL.startsWith("//"))
|
|
203
|
+
URL = URL.slice(2);
|
|
204
|
+
return URL;
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
209
|
+
|
|
210
|
+
---
|
|
@@ -21,7 +21,6 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
21
21
|
|
|
22
22
|
| |
|
|
23
23
|
| --- |
|
|
24
|
-
| [HTTPWalletJSON](#class-httpwalletjson) |
|
|
25
24
|
| [HTTPWalletWire](#class-httpwalletwire) |
|
|
26
25
|
| [WalletWireProcessor](#class-walletwireprocessor) |
|
|
27
26
|
| [WalletWireTransceiver](#class-walletwiretransceiver) |
|
|
@@ -32,230 +31,6 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
32
31
|
|
|
33
32
|
---
|
|
34
33
|
|
|
35
|
-
### Class: HTTPWalletJSON
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
export default class HTTPWalletJSON implements WalletInterface {
|
|
39
|
-
baseUrl: string;
|
|
40
|
-
httpClient: typeof fetch;
|
|
41
|
-
originator: OriginatorDomainNameStringUnder250Bytes | undefined;
|
|
42
|
-
api: (call: string, args: object) => Promise<unknown>;
|
|
43
|
-
constructor(originator: OriginatorDomainNameStringUnder250Bytes | undefined, baseUrl: string = "http://localhost:3321", httpClient = fetch)
|
|
44
|
-
async createAction(args: CreateActionArgs): Promise<CreateActionResult>
|
|
45
|
-
async signAction(args: SignActionArgs): Promise<SignActionResult>
|
|
46
|
-
async abortAction(args: {
|
|
47
|
-
reference: Base64String;
|
|
48
|
-
}): Promise<{
|
|
49
|
-
aborted: true;
|
|
50
|
-
}>
|
|
51
|
-
async listActions(args: ListActionsArgs): Promise<ListActionsResult>
|
|
52
|
-
async internalizeAction(args: InternalizeActionArgs): Promise<{
|
|
53
|
-
accepted: true;
|
|
54
|
-
}>
|
|
55
|
-
async listOutputs(args: ListOutputsArgs): Promise<ListOutputsResult>
|
|
56
|
-
async relinquishOutput(args: {
|
|
57
|
-
basket: BasketStringUnder300Bytes;
|
|
58
|
-
output: OutpointString;
|
|
59
|
-
}): Promise<{
|
|
60
|
-
relinquished: true;
|
|
61
|
-
}>
|
|
62
|
-
async getPublicKey(args: {
|
|
63
|
-
seekPermission?: BooleanDefaultTrue;
|
|
64
|
-
identityKey?: true;
|
|
65
|
-
protocolID?: [
|
|
66
|
-
SecurityLevel,
|
|
67
|
-
ProtocolString5To400Bytes
|
|
68
|
-
];
|
|
69
|
-
keyID?: KeyIDStringUnder800Bytes;
|
|
70
|
-
privileged?: BooleanDefaultFalse;
|
|
71
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
72
|
-
counterparty?: PubKeyHex | "self" | "anyone";
|
|
73
|
-
forSelf?: BooleanDefaultFalse;
|
|
74
|
-
}): Promise<{
|
|
75
|
-
publicKey: PubKeyHex;
|
|
76
|
-
}>
|
|
77
|
-
async revealCounterpartyKeyLinkage(args: {
|
|
78
|
-
counterparty: PubKeyHex;
|
|
79
|
-
verifier: PubKeyHex;
|
|
80
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
81
|
-
privileged?: BooleanDefaultFalse;
|
|
82
|
-
}): Promise<{
|
|
83
|
-
prover: PubKeyHex;
|
|
84
|
-
verifier: PubKeyHex;
|
|
85
|
-
counterparty: PubKeyHex;
|
|
86
|
-
revelationTime: ISOTimestampString;
|
|
87
|
-
encryptedLinkage: Byte[];
|
|
88
|
-
encryptedLinkageProof: number[];
|
|
89
|
-
}>
|
|
90
|
-
async revealSpecificKeyLinkage(args: {
|
|
91
|
-
counterparty: PubKeyHex;
|
|
92
|
-
verifier: PubKeyHex;
|
|
93
|
-
protocolID: [
|
|
94
|
-
SecurityLevel,
|
|
95
|
-
ProtocolString5To400Bytes
|
|
96
|
-
];
|
|
97
|
-
keyID: KeyIDStringUnder800Bytes;
|
|
98
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
99
|
-
privileged?: BooleanDefaultFalse;
|
|
100
|
-
}): Promise<{
|
|
101
|
-
prover: PubKeyHex;
|
|
102
|
-
verifier: PubKeyHex;
|
|
103
|
-
counterparty: PubKeyHex;
|
|
104
|
-
protocolID: [
|
|
105
|
-
SecurityLevel,
|
|
106
|
-
ProtocolString5To400Bytes
|
|
107
|
-
];
|
|
108
|
-
keyID: KeyIDStringUnder800Bytes;
|
|
109
|
-
encryptedLinkage: Byte[];
|
|
110
|
-
encryptedLinkageProof: Byte[];
|
|
111
|
-
proofType: Byte;
|
|
112
|
-
}>
|
|
113
|
-
async encrypt(args: {
|
|
114
|
-
seekPermission?: BooleanDefaultTrue;
|
|
115
|
-
plaintext: Byte[];
|
|
116
|
-
protocolID: [
|
|
117
|
-
SecurityLevel,
|
|
118
|
-
ProtocolString5To400Bytes
|
|
119
|
-
];
|
|
120
|
-
keyID: KeyIDStringUnder800Bytes;
|
|
121
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
122
|
-
counterparty?: PubKeyHex | "self" | "anyone";
|
|
123
|
-
privileged?: BooleanDefaultFalse;
|
|
124
|
-
}): Promise<{
|
|
125
|
-
ciphertext: Byte[];
|
|
126
|
-
}>
|
|
127
|
-
async decrypt(args: {
|
|
128
|
-
seekPermission?: BooleanDefaultTrue;
|
|
129
|
-
ciphertext: Byte[];
|
|
130
|
-
protocolID: [
|
|
131
|
-
SecurityLevel,
|
|
132
|
-
ProtocolString5To400Bytes
|
|
133
|
-
];
|
|
134
|
-
keyID: KeyIDStringUnder800Bytes;
|
|
135
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
136
|
-
counterparty?: PubKeyHex | "self" | "anyone";
|
|
137
|
-
privileged?: BooleanDefaultFalse;
|
|
138
|
-
}): Promise<{
|
|
139
|
-
plaintext: Byte[];
|
|
140
|
-
}>
|
|
141
|
-
async createHmac(args: {
|
|
142
|
-
seekPermission?: BooleanDefaultTrue;
|
|
143
|
-
data: Byte[];
|
|
144
|
-
protocolID: [
|
|
145
|
-
SecurityLevel,
|
|
146
|
-
ProtocolString5To400Bytes
|
|
147
|
-
];
|
|
148
|
-
keyID: KeyIDStringUnder800Bytes;
|
|
149
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
150
|
-
counterparty?: PubKeyHex | "self" | "anyone";
|
|
151
|
-
privileged?: BooleanDefaultFalse;
|
|
152
|
-
}): Promise<{
|
|
153
|
-
hmac: Byte[];
|
|
154
|
-
}>
|
|
155
|
-
async verifyHmac(args: {
|
|
156
|
-
seekPermission?: BooleanDefaultTrue;
|
|
157
|
-
data: Byte[];
|
|
158
|
-
hmac: Byte[];
|
|
159
|
-
protocolID: [
|
|
160
|
-
SecurityLevel,
|
|
161
|
-
ProtocolString5To400Bytes
|
|
162
|
-
];
|
|
163
|
-
keyID: KeyIDStringUnder800Bytes;
|
|
164
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
165
|
-
counterparty?: PubKeyHex | "self" | "anyone";
|
|
166
|
-
privileged?: BooleanDefaultFalse;
|
|
167
|
-
}): Promise<{
|
|
168
|
-
valid: true;
|
|
169
|
-
}>
|
|
170
|
-
async createSignature(args: {
|
|
171
|
-
seekPermission?: BooleanDefaultTrue;
|
|
172
|
-
data?: Byte[];
|
|
173
|
-
hashToDirectlySign?: Byte[];
|
|
174
|
-
protocolID: [
|
|
175
|
-
SecurityLevel,
|
|
176
|
-
ProtocolString5To400Bytes
|
|
177
|
-
];
|
|
178
|
-
keyID: KeyIDStringUnder800Bytes;
|
|
179
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
180
|
-
counterparty?: PubKeyHex | "self" | "anyone";
|
|
181
|
-
privileged?: BooleanDefaultFalse;
|
|
182
|
-
}): Promise<{
|
|
183
|
-
signature: Byte[];
|
|
184
|
-
}>
|
|
185
|
-
async verifySignature(args: {
|
|
186
|
-
seekPermission?: BooleanDefaultTrue;
|
|
187
|
-
data?: Byte[];
|
|
188
|
-
hashToDirectlyVerify?: Byte[];
|
|
189
|
-
signature: Byte[];
|
|
190
|
-
protocolID: [
|
|
191
|
-
SecurityLevel,
|
|
192
|
-
ProtocolString5To400Bytes
|
|
193
|
-
];
|
|
194
|
-
keyID: KeyIDStringUnder800Bytes;
|
|
195
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
196
|
-
counterparty?: PubKeyHex | "self" | "anyone";
|
|
197
|
-
forSelf?: BooleanDefaultFalse;
|
|
198
|
-
privileged?: BooleanDefaultFalse;
|
|
199
|
-
}): Promise<{
|
|
200
|
-
valid: true;
|
|
201
|
-
}>
|
|
202
|
-
async acquireCertificate(args: AcquireCertificateArgs): Promise<AcquireCertificateResult>
|
|
203
|
-
async listCertificates(args: {
|
|
204
|
-
certifiers: PubKeyHex[];
|
|
205
|
-
types: Base64String[];
|
|
206
|
-
limit?: PositiveIntegerDefault10Max10000;
|
|
207
|
-
offset?: PositiveIntegerOrZero;
|
|
208
|
-
privileged?: BooleanDefaultFalse;
|
|
209
|
-
privilegedReason?: DescriptionString5to50Bytes;
|
|
210
|
-
}): Promise<ListCertificatesResult>
|
|
211
|
-
async proveCertificate(args: ProveCertificateArgs): Promise<ProveCertificateResult>
|
|
212
|
-
async relinquishCertificate(args: {
|
|
213
|
-
type: Base64String;
|
|
214
|
-
serialNumber: Base64String;
|
|
215
|
-
certifier: PubKeyHex;
|
|
216
|
-
}): Promise<{
|
|
217
|
-
relinquished: true;
|
|
218
|
-
}>
|
|
219
|
-
async discoverByIdentityKey(args: {
|
|
220
|
-
seekPermission?: BooleanDefaultTrue;
|
|
221
|
-
identityKey: PubKeyHex;
|
|
222
|
-
limit?: PositiveIntegerDefault10Max10000;
|
|
223
|
-
offset?: PositiveIntegerOrZero;
|
|
224
|
-
}): Promise<DiscoverCertificatesResult>
|
|
225
|
-
async discoverByAttributes(args: {
|
|
226
|
-
seekPermission?: BooleanDefaultTrue;
|
|
227
|
-
attributes: Record<CertificateFieldNameUnder50Bytes, string>;
|
|
228
|
-
limit?: PositiveIntegerDefault10Max10000;
|
|
229
|
-
offset?: PositiveIntegerOrZero;
|
|
230
|
-
}): Promise<DiscoverCertificatesResult>
|
|
231
|
-
async isAuthenticated(args: object): Promise<{
|
|
232
|
-
authenticated: true;
|
|
233
|
-
}>
|
|
234
|
-
async waitForAuthentication(args: object): Promise<{
|
|
235
|
-
authenticated: true;
|
|
236
|
-
}>
|
|
237
|
-
async getHeight(args: object): Promise<{
|
|
238
|
-
height: PositiveInteger;
|
|
239
|
-
}>
|
|
240
|
-
async getHeaderForHeight(args: {
|
|
241
|
-
height: PositiveInteger;
|
|
242
|
-
}): Promise<{
|
|
243
|
-
header: HexString;
|
|
244
|
-
}>
|
|
245
|
-
async getNetwork(args: object): Promise<{
|
|
246
|
-
network: "mainnet" | "testnet";
|
|
247
|
-
}>
|
|
248
|
-
async getVersion(args: object): Promise<{
|
|
249
|
-
version: VersionString7To30Bytes;
|
|
250
|
-
}>
|
|
251
|
-
}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
See also: [AcquireCertificateArgs](./wallet.md#interface-acquirecertificateargs), [AcquireCertificateResult](./wallet.md#type-acquirecertificateresult), [Base64String](./wallet.md#type-base64string), [BasketStringUnder300Bytes](./wallet.md#type-basketstringunder300bytes), [BooleanDefaultFalse](./wallet.md#type-booleandefaultfalse), [BooleanDefaultTrue](./wallet.md#type-booleandefaulttrue), [Byte](./wallet.md#type-byte), [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [CreateActionArgs](./wallet.md#interface-createactionargs), [CreateActionResult](./wallet.md#interface-createactionresult), [DescriptionString5to50Bytes](./wallet.md#type-descriptionstring5to50bytes), [DiscoverCertificatesResult](./wallet.md#interface-discovercertificatesresult), [HexString](./wallet.md#type-hexstring), [ISOTimestampString](./wallet.md#type-isotimestampstring), [InternalizeActionArgs](./wallet.md#interface-internalizeactionargs), [KeyIDStringUnder800Bytes](./wallet.md#type-keyidstringunder800bytes), [ListActionsArgs](./wallet.md#interface-listactionsargs), [ListActionsResult](./wallet.md#interface-listactionsresult), [ListCertificatesResult](./wallet.md#interface-listcertificatesresult), [ListOutputsArgs](./wallet.md#interface-listoutputsargs), [ListOutputsResult](./wallet.md#interface-listoutputsresult), [OriginatorDomainNameStringUnder250Bytes](./wallet.md#type-originatordomainnamestringunder250bytes), [OutpointString](./wallet.md#type-outpointstring), [PositiveInteger](./wallet.md#type-positiveinteger), [PositiveIntegerDefault10Max10000](./wallet.md#type-positiveintegerdefault10max10000), [PositiveIntegerOrZero](./wallet.md#type-positiveintegerorzero), [ProtocolString5To400Bytes](./wallet.md#type-protocolstring5to400bytes), [ProveCertificateArgs](./wallet.md#interface-provecertificateargs), [ProveCertificateResult](./wallet.md#interface-provecertificateresult), [PubKeyHex](./wallet.md#type-pubkeyhex), [SecurityLevel](./wallet.md#type-securitylevel), [SignActionArgs](./wallet.md#interface-signactionargs), [SignActionResult](./wallet.md#interface-signactionresult), [VersionString7To30Bytes](./wallet.md#type-versionstring7to30bytes), [WalletInterface](./wallet.md#interface-walletinterface), [decrypt](./messages.md#variable-decrypt), [encrypt](./messages.md#variable-encrypt)
|
|
255
|
-
|
|
256
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
257
|
-
|
|
258
|
-
---
|
|
259
34
|
### Class: HTTPWalletWire
|
|
260
35
|
|
|
261
36
|
```ts
|
package/mod.ts
CHANGED
|
@@ -13,3 +13,6 @@ export * from './src/wallet/index.js'
|
|
|
13
13
|
export * from './src/wallet/substrates/index.js'
|
|
14
14
|
export * from './src/auth/index.js'
|
|
15
15
|
export * from './src/overlay-tools/index.js'
|
|
16
|
+
export * from './src/storage/index.js'
|
|
17
|
+
export * from './src/identity/index.js'
|
|
18
|
+
export * from './src/registry/index.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsv/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "BSV Blockchain Software Development Kit",
|
|
6
6
|
"main": "dist/cjs/mod.js",
|
|
@@ -184,6 +184,16 @@
|
|
|
184
184
|
"require": "./dist/cjs/src/overlay-tools/*.js",
|
|
185
185
|
"types": "./dist/types/src/overlay-tools/*.d.ts"
|
|
186
186
|
},
|
|
187
|
+
"./storage": {
|
|
188
|
+
"import": "./dist/esm/src/storage/index.js",
|
|
189
|
+
"require": "./dist/cjs/src/storage/index.js",
|
|
190
|
+
"types": "./dist/types/src/storage/index.d.ts"
|
|
191
|
+
},
|
|
192
|
+
"./storage/*": {
|
|
193
|
+
"import": "./dist/esm/src/storage/*.js",
|
|
194
|
+
"require": "./dist/cjs/src/storage/*.js",
|
|
195
|
+
"types": "./dist/types/src/storage/*.d.ts"
|
|
196
|
+
},
|
|
187
197
|
"./umd": {
|
|
188
198
|
"import": "./dist/umd/bundle.js"
|
|
189
199
|
}
|
package/src/auth/Peer.ts
CHANGED
|
@@ -12,7 +12,9 @@ import {
|
|
|
12
12
|
Transport
|
|
13
13
|
} from './types.js'
|
|
14
14
|
import { VerifiableCertificate } from './certificates/VerifiableCertificate.js'
|
|
15
|
-
import
|
|
15
|
+
import Random from '../primitives/Random.js'
|
|
16
|
+
import * as Utils from '../primitives/utils.js'
|
|
17
|
+
import { WalletInterface } from '../wallet/Wallet.interfaces.js'
|
|
16
18
|
|
|
17
19
|
const AUTH_VERSION = '0.1'
|
|
18
20
|
|
|
@@ -82,7 +84,9 @@ export class Peer {
|
|
|
82
84
|
certifiers: [],
|
|
83
85
|
types: {}
|
|
84
86
|
}
|
|
85
|
-
this.transport.onData(this.handleIncomingMessage.bind(this)).catch(
|
|
87
|
+
this.transport.onData(this.handleIncomingMessage.bind(this)).catch(e => {
|
|
88
|
+
throw e
|
|
89
|
+
})
|
|
86
90
|
this.sessionManager =
|
|
87
91
|
sessionManager != null ? sessionManager : new SessionManager()
|
|
88
92
|
if (autoPersistLastSession === false) {
|
|
@@ -424,10 +428,9 @@ export class Peer {
|
|
|
424
428
|
*/
|
|
425
429
|
private async handleIncomingMessage (message: AuthMessage): Promise<void> {
|
|
426
430
|
if (typeof message.version !== 'string' || message.version !== AUTH_VERSION) {
|
|
427
|
-
|
|
431
|
+
throw new Error(
|
|
428
432
|
`Invalid or unsupported message auth version! Received: ${message.version}, expected: ${AUTH_VERSION}`
|
|
429
433
|
)
|
|
430
|
-
return
|
|
431
434
|
}
|
|
432
435
|
|
|
433
436
|
switch (message.messageType) {
|
|
@@ -447,7 +450,7 @@ export class Peer {
|
|
|
447
450
|
await this.processGeneralMessage(message)
|
|
448
451
|
break
|
|
449
452
|
default:
|
|
450
|
-
|
|
453
|
+
throw new Error(
|
|
451
454
|
`Unknown message type of ${String(message.messageType)} from ${String(
|
|
452
455
|
message.identityKey
|
|
453
456
|
)}`
|