@bsv/sdk 1.4.15 → 1.4.17

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.
@@ -0,0 +1,225 @@
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
+ | [DisplayableIdentity](#interface-displayableidentity) |
10
+ | [IdentityClientOptions](#interface-identityclientoptions) |
11
+
12
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
13
+
14
+ ---
15
+
16
+ ### Interface: DisplayableIdentity
17
+
18
+ ```ts
19
+ export interface DisplayableIdentity {
20
+ name: string;
21
+ avatarURL: string;
22
+ abbreviatedKey: string;
23
+ identityKey: string;
24
+ badgeIconURL: string;
25
+ badgeLabel: string;
26
+ badgeClickURL: string;
27
+ }
28
+ ```
29
+
30
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
31
+
32
+ ---
33
+ ### Interface: IdentityClientOptions
34
+
35
+ ```ts
36
+ export interface IdentityClientOptions {
37
+ protocolID: WalletProtocol;
38
+ keyID: string;
39
+ tokenAmount: number;
40
+ outputIndex: number;
41
+ }
42
+ ```
43
+
44
+ See also: [WalletProtocol](./wallet.md#type-walletprotocol)
45
+
46
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
47
+
48
+ ---
49
+ ## Classes
50
+
51
+ ### Class: IdentityClient
52
+
53
+ IdentityClient lets you discover who others are, and let the world know who you are.
54
+
55
+ ```ts
56
+ export class IdentityClient {
57
+ constructor(wallet?: WalletInterface, private readonly options = DEFAULT_IDENTITY_CLIENT_OPTIONS, private readonly originator?: OriginatorDomainNameStringUnder250Bytes)
58
+ async publiclyRevealAttributes(certificate: WalletCertificate, fieldsToReveal: CertificateFieldNameUnder50Bytes[]): Promise<BroadcastResponse | BroadcastFailure>
59
+ async resolveByIdentityKey(args: DiscoverByIdentityKeyArgs): Promise<DisplayableIdentity[]>
60
+ async resolveByAttributes(args: DiscoverByAttributesArgs): Promise<DisplayableIdentity[]>
61
+ static parseIdentity(identityToParse: IdentityCertificate): DisplayableIdentity
62
+ }
63
+ ```
64
+
65
+ See also: [BroadcastFailure](./transaction.md#interface-broadcastfailure), [BroadcastResponse](./transaction.md#interface-broadcastresponse), [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [DEFAULT_IDENTITY_CLIENT_OPTIONS](./identity.md#variable-default_identity_client_options), [DiscoverByAttributesArgs](./wallet.md#interface-discoverbyattributesargs), [DiscoverByIdentityKeyArgs](./wallet.md#interface-discoverbyidentitykeyargs), [DisplayableIdentity](./identity.md#interface-displayableidentity), [IdentityCertificate](./wallet.md#interface-identitycertificate), [OriginatorDomainNameStringUnder250Bytes](./wallet.md#type-originatordomainnamestringunder250bytes), [WalletCertificate](./wallet.md#interface-walletcertificate), [WalletInterface](./wallet.md#interface-walletinterface)
66
+
67
+ #### Method parseIdentity
68
+
69
+ TODO: Implement once revocation overlay is created
70
+ Remove public certificate revelation from overlay services by spending the identity token
71
+
72
+ Parse out identity and certifier attributes to display from an IdentityCertificate
73
+
74
+ ```ts
75
+ static parseIdentity(identityToParse: IdentityCertificate): DisplayableIdentity
76
+ ```
77
+ See also: [DisplayableIdentity](./identity.md#interface-displayableidentity), [IdentityCertificate](./wallet.md#interface-identitycertificate)
78
+
79
+ Returns
80
+
81
+ - IdentityToDisplay
82
+
83
+ Argument Details
84
+
85
+ + **serialNumber**
86
+ + Unique serial number of the certificate to revoke revelation
87
+ + **identityToParse**
88
+ + The Identity Certificate to parse
89
+
90
+ #### Method publiclyRevealAttributes
91
+
92
+ Publicly reveals selected fields from a given certificate by creating a publicly verifiable certificate.
93
+ The publicly revealed certificate is included in a blockchain transaction and broadcast to a federated overlay node.
94
+
95
+ ```ts
96
+ async publiclyRevealAttributes(certificate: WalletCertificate, fieldsToReveal: CertificateFieldNameUnder50Bytes[]): Promise<BroadcastResponse | BroadcastFailure>
97
+ ```
98
+ See also: [BroadcastFailure](./transaction.md#interface-broadcastfailure), [BroadcastResponse](./transaction.md#interface-broadcastresponse), [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [WalletCertificate](./wallet.md#interface-walletcertificate)
99
+
100
+ Returns
101
+
102
+ A promise that resolves with the broadcast result from the overlay network.
103
+
104
+ Argument Details
105
+
106
+ + **certificate**
107
+ + The master certificate to selectively reveal.
108
+ + **fieldsToReveal**
109
+ + An array of certificate field names to reveal. Only these fields will be included in the public certificate.
110
+
111
+ Throws
112
+
113
+ Throws an error if the certificate is invalid, the fields cannot be revealed, or if the broadcast fails.
114
+
115
+ #### Method resolveByAttributes
116
+
117
+ Resolves displayable identity certificates by specific identity attributes, issued by a trusted entity.
118
+
119
+ ```ts
120
+ async resolveByAttributes(args: DiscoverByAttributesArgs): Promise<DisplayableIdentity[]>
121
+ ```
122
+ See also: [DiscoverByAttributesArgs](./wallet.md#interface-discoverbyattributesargs), [DisplayableIdentity](./identity.md#interface-displayableidentity)
123
+
124
+ Returns
125
+
126
+ The promise resolves to displayable identities.
127
+
128
+ Argument Details
129
+
130
+ + **args**
131
+ + Attributes and optional parameters used to discover certificates.
132
+
133
+ #### Method resolveByIdentityKey
134
+
135
+ Resolves displayable identity certificates, issued to a given identity key by a trusted certifier.
136
+
137
+ ```ts
138
+ async resolveByIdentityKey(args: DiscoverByIdentityKeyArgs): Promise<DisplayableIdentity[]>
139
+ ```
140
+ See also: [DiscoverByIdentityKeyArgs](./wallet.md#interface-discoverbyidentitykeyargs), [DisplayableIdentity](./identity.md#interface-displayableidentity)
141
+
142
+ Returns
143
+
144
+ The promise resolves to displayable identities.
145
+
146
+ Argument Details
147
+
148
+ + **args**
149
+ + Arguments for requesting the discovery based on the identity key.
150
+
151
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
152
+
153
+ ---
154
+ ## Functions
155
+
156
+ ## Types
157
+
158
+ ## Enums
159
+
160
+ ## Variables
161
+
162
+ | |
163
+ | --- |
164
+ | [DEFAULT_IDENTITY_CLIENT_OPTIONS](#variable-default_identity_client_options) |
165
+ | [KNOWN_IDENTITY_TYPES](#variable-known_identity_types) |
166
+ | [defaultIdentity](#variable-defaultidentity) |
167
+
168
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
169
+
170
+ ---
171
+
172
+ ### Variable: DEFAULT_IDENTITY_CLIENT_OPTIONS
173
+
174
+ ```ts
175
+ DEFAULT_IDENTITY_CLIENT_OPTIONS: IdentityClientOptions = {
176
+ protocolID: [1, "identity"],
177
+ keyID: "1",
178
+ tokenAmount: 1,
179
+ outputIndex: 0
180
+ }
181
+ ```
182
+
183
+ See also: [IdentityClientOptions](./identity.md#interface-identityclientoptions)
184
+
185
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
186
+
187
+ ---
188
+ ### Variable: KNOWN_IDENTITY_TYPES
189
+
190
+ ```ts
191
+ KNOWN_IDENTITY_TYPES = {
192
+ identiCert: "z40BOInXkI8m7f/wBrv4MJ09bZfzZbTj2fJqCtONqCY=",
193
+ discordCert: "2TgqRC35B1zehGmB21xveZNc7i5iqHc0uxMb+1NMPW4=",
194
+ phoneCert: "mffUklUzxbHr65xLohn0hRL0Tq2GjW1GYF/OPfzqJ6A=",
195
+ xCert: "vdDWvftf1H+5+ZprUw123kjHlywH+v20aPQTuXgMpNc=",
196
+ registrant: "YoPsbfR6YQczjzPdHCoGC7nJsOdPQR50+SYqcWpJ0y0=",
197
+ emailCert: "exOl3KM0dIJ04EW5pZgbZmPag6MdJXd3/a1enmUU/BA=",
198
+ anyone: "mfkOMfLDQmrr3SBxBQ5WeE+6Hy3VJRFq6w4A5Ljtlis=",
199
+ self: "Hkge6X5JRxt1cWXtHLCrSTg6dCVTxjQJJ48iOYd7n3g=",
200
+ coolCert: "AGfk/WrT1eBDXpz3mcw386Zww2HmqcIn3uY6x4Af1eo="
201
+ }
202
+ ```
203
+
204
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
205
+
206
+ ---
207
+ ### Variable: defaultIdentity
208
+
209
+ ```ts
210
+ defaultIdentity: DisplayableIdentity = {
211
+ name: "Unknown Identity",
212
+ avatarURL: "XUUB8bbn9fEthk15Ge3zTQXypUShfC94vFjp65v7u5CQ8qkpxzst",
213
+ identityKey: "",
214
+ abbreviatedKey: "",
215
+ badgeIconURL: "XUUV39HVPkpmMzYNTx7rpKzJvXfeiVyQWg2vfSpjBAuhunTCA9uG",
216
+ badgeLabel: "Not verified by anyone you trust.",
217
+ badgeClickURL: "https://projectbabbage.com/docs/unknown-identity"
218
+ }
219
+ ```
220
+
221
+ See also: [DisplayableIdentity](./identity.md#interface-displayableidentity)
222
+
223
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
224
+
225
+ ---
@@ -0,0 +1,132 @@
1
+ # API
2
+
3
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
4
+
5
+ ## Interfaces
6
+
7
+ ## Classes
8
+
9
+ ### Class: LocalKVStore
10
+
11
+ Implements a key-value storage system backed by transaction outputs managed by a wallet.
12
+ Each key-value pair is represented by a PushDrop token output in a specific context (basket).
13
+ Allows setting, getting, and removing key-value pairs, with optional encryption.
14
+
15
+ ```ts
16
+ export default class LocalKVStore {
17
+ constructor(wallet: WalletInterface = new WalletClient(), context = "kvstore-default", encrypt = true)
18
+ async get(key: string, defaultValue: string | undefined = undefined): Promise<string | undefined>
19
+ async set(key: string, value: string): Promise<OutpointString>
20
+ async remove(key: string): Promise<OutpointString | undefined>
21
+ }
22
+ ```
23
+
24
+ See also: [OutpointString](./wallet.md#type-outpointstring), [WalletClient](./wallet.md#class-walletclient), [WalletInterface](./wallet.md#interface-walletinterface), [encrypt](./messages.md#variable-encrypt)
25
+
26
+ #### Constructor
27
+
28
+ Creates an instance of the localKVStore.
29
+
30
+ ```ts
31
+ constructor(wallet: WalletInterface = new WalletClient(), context = "kvstore-default", encrypt = true)
32
+ ```
33
+ See also: [WalletClient](./wallet.md#class-walletclient), [WalletInterface](./wallet.md#interface-walletinterface), [encrypt](./messages.md#variable-encrypt)
34
+
35
+ Argument Details
36
+
37
+ + **wallet**
38
+ + The wallet interface to use. Defaults to a new WalletClient instance.
39
+ + **context**
40
+ + The context (basket) for namespacing keys. Defaults to 'kvstore-default'.
41
+ + **encrypt**
42
+ + Whether to encrypt values. Defaults to true.
43
+
44
+ Throws
45
+
46
+ If the context is missing or empty.
47
+
48
+ #### Method get
49
+
50
+ Retrieves the value associated with a given key.
51
+
52
+ ```ts
53
+ async get(key: string, defaultValue: string | undefined = undefined): Promise<string | undefined>
54
+ ```
55
+
56
+ Returns
57
+
58
+ A promise that resolves to the value as a string,
59
+ the defaultValue if the key is not found, or undefined if no defaultValue is provided.
60
+
61
+ Argument Details
62
+
63
+ + **key**
64
+ + The key to retrieve the value for.
65
+ + **defaultValue**
66
+ + The value to return if the key is not found.
67
+
68
+ Throws
69
+
70
+ If multiple outputs are found for the key (ambiguous state).
71
+
72
+ If the found output's locking script cannot be decoded or represents an invalid token format.
73
+
74
+ #### Method remove
75
+
76
+ Removes the key-value pair associated with the given key.
77
+ It finds the existing output(s) for the key and spends them without creating a new output.
78
+ If multiple outputs exist, they are all spent in the same transaction.
79
+ If the key does not exist, it does nothing.
80
+ If signing the removal transaction fails, it relinquishes the original outputs instead of spending.
81
+
82
+ ```ts
83
+ async remove(key: string): Promise<OutpointString | undefined>
84
+ ```
85
+ See also: [OutpointString](./wallet.md#type-outpointstring)
86
+
87
+ Returns
88
+
89
+ A promise that resolves to the txid of the removal transaction if successful.
90
+
91
+ Argument Details
92
+
93
+ + **key**
94
+ + The key to remove.
95
+
96
+ #### Method set
97
+
98
+ Sets or updates the value associated with a given key.
99
+ If the key already exists (one or more outputs found), it spends the existing output(s)
100
+ and creates a new one with the updated value. If multiple outputs exist for the key,
101
+ they are collapsed into a single new output.
102
+ If the key does not exist, it creates a new output.
103
+ Handles encryption if enabled.
104
+ If signing the update/collapse transaction fails, it relinquishes the original outputs and starts over with a new chain.
105
+
106
+ ```ts
107
+ async set(key: string, value: string): Promise<OutpointString>
108
+ ```
109
+ See also: [OutpointString](./wallet.md#type-outpointstring)
110
+
111
+ Returns
112
+
113
+ A promise that resolves to the outpoint string (txid.vout) of the new or updated token output.
114
+
115
+ Argument Details
116
+
117
+ + **key**
118
+ + The key to set or update.
119
+ + **value**
120
+ + The value to associate with the key.
121
+
122
+ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
123
+
124
+ ---
125
+ ## Functions
126
+
127
+ ## Types
128
+
129
+ ## Enums
130
+
131
+ ## Variables
132
+