verus-rpc 0.1.0
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/LICENSE +202 -0
- package/README.md +139 -0
- package/dist/amount.d.ts +32 -0
- package/dist/amount.d.ts.map +1 -0
- package/dist/amount.js +65 -0
- package/dist/amount.js.map +1 -0
- package/dist/client.d.ts +60 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +61 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +107 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/lossless.d.ts +32 -0
- package/dist/lossless.d.ts.map +1 -0
- package/dist/lossless.js +64 -0
- package/dist/lossless.js.map +1 -0
- package/dist/mapping.d.ts +41 -0
- package/dist/mapping.d.ts.map +1 -0
- package/dist/mapping.js +139 -0
- package/dist/mapping.js.map +1 -0
- package/dist/methods/addressindex.d.ts +69 -0
- package/dist/methods/addressindex.d.ts.map +1 -0
- package/dist/methods/addressindex.js +97 -0
- package/dist/methods/addressindex.js.map +1 -0
- package/dist/methods/blockchain.d.ts +99 -0
- package/dist/methods/blockchain.d.ts.map +1 -0
- package/dist/methods/blockchain.js +141 -0
- package/dist/methods/blockchain.js.map +1 -0
- package/dist/methods/chain.d.ts +39 -0
- package/dist/methods/chain.d.ts.map +1 -0
- package/dist/methods/chain.js +44 -0
- package/dist/methods/chain.js.map +1 -0
- package/dist/methods/currency.d.ts +210 -0
- package/dist/methods/currency.d.ts.map +1 -0
- package/dist/methods/currency.js +303 -0
- package/dist/methods/currency.js.map +1 -0
- package/dist/methods/identity.d.ts +284 -0
- package/dist/methods/identity.d.ts.map +1 -0
- package/dist/methods/identity.js +333 -0
- package/dist/methods/identity.js.map +1 -0
- package/dist/methods/shielded.d.ts +136 -0
- package/dist/methods/shielded.d.ts.map +1 -0
- package/dist/methods/shielded.js +175 -0
- package/dist/methods/shielded.js.map +1 -0
- package/dist/methods/t2.d.ts +8 -0
- package/dist/methods/t2.d.ts.map +1 -0
- package/dist/methods/t2.js +10 -0
- package/dist/methods/t2.js.map +1 -0
- package/dist/methods/wallet-types.d.ts +143 -0
- package/dist/methods/wallet-types.d.ts.map +1 -0
- package/dist/methods/wallet-types.js +6 -0
- package/dist/methods/wallet-types.js.map +1 -0
- package/dist/methods/wallet.d.ts +206 -0
- package/dist/methods/wallet.d.ts.map +1 -0
- package/dist/methods/wallet.js +455 -0
- package/dist/methods/wallet.js.map +1 -0
- package/dist/mock.d.ts +28 -0
- package/dist/mock.d.ts.map +1 -0
- package/dist/mock.js +61 -0
- package/dist/mock.js.map +1 -0
- package/dist/resilience.d.ts +20 -0
- package/dist/resilience.d.ts.map +1 -0
- package/dist/resilience.js +32 -0
- package/dist/resilience.js.map +1 -0
- package/dist/transport.d.ts +38 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +79 -0
- package/dist/transport.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import type { RpcTransport } from "../transport.js";
|
|
2
|
+
/** The identity object embedded in `getidentity`-style responses. */
|
|
3
|
+
export interface IdentityDefinition {
|
|
4
|
+
version: number;
|
|
5
|
+
flags: number;
|
|
6
|
+
primaryaddresses: string[];
|
|
7
|
+
minimumsignatures: number;
|
|
8
|
+
name: string;
|
|
9
|
+
identityaddress: string;
|
|
10
|
+
parent: string;
|
|
11
|
+
systemid: string;
|
|
12
|
+
contentmap?: Record<string, unknown> | undefined;
|
|
13
|
+
contentmultimap?: Record<string, unknown> | undefined;
|
|
14
|
+
revocationauthority: string;
|
|
15
|
+
recoveryauthority: string;
|
|
16
|
+
privateaddress?: string | undefined;
|
|
17
|
+
timelock?: number | undefined;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface GetIdentityResult {
|
|
21
|
+
fullyqualifiedname?: string | undefined;
|
|
22
|
+
friendlyname?: string | undefined;
|
|
23
|
+
identity: IdentityDefinition;
|
|
24
|
+
/** "active" | "revoked" — daemon-reported lifecycle state. */
|
|
25
|
+
status?: string | undefined;
|
|
26
|
+
canspendfor?: boolean | undefined;
|
|
27
|
+
cansignfor?: boolean | undefined;
|
|
28
|
+
blockheight?: number | undefined;
|
|
29
|
+
txid?: string | undefined;
|
|
30
|
+
vout?: number | undefined;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
}
|
|
33
|
+
export interface GetIdentityOptions {
|
|
34
|
+
/** `name@` or i-address. */
|
|
35
|
+
nameOrAddress: string;
|
|
36
|
+
/** Return the identity as of this height (default: current). */
|
|
37
|
+
height?: number;
|
|
38
|
+
/** Include a transaction proof. */
|
|
39
|
+
txProof?: boolean;
|
|
40
|
+
/** Height for which to return the proof. */
|
|
41
|
+
txProofHeight?: number;
|
|
42
|
+
}
|
|
43
|
+
export interface GetIdentityContentOptions {
|
|
44
|
+
nameOrAddress: string;
|
|
45
|
+
heightStart?: number;
|
|
46
|
+
heightEnd?: number;
|
|
47
|
+
txProofs?: boolean;
|
|
48
|
+
txProofHeight?: number;
|
|
49
|
+
/** Restrict contentmultimap to this VDXF key. */
|
|
50
|
+
vdxfKey?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface GetIdentityHistoryOptions {
|
|
53
|
+
nameOrAddress: string;
|
|
54
|
+
heightStart?: number;
|
|
55
|
+
heightEnd?: number;
|
|
56
|
+
txProofs?: boolean;
|
|
57
|
+
txProofHeight?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface IdentityHistoryEntry {
|
|
60
|
+
blockhash?: string | undefined;
|
|
61
|
+
height: number;
|
|
62
|
+
/** Raw outpoint info (txid/voutnum) — passthrough. */
|
|
63
|
+
output?: unknown;
|
|
64
|
+
identity: IdentityDefinition;
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
}
|
|
67
|
+
export interface GetIdentityHistoryResult {
|
|
68
|
+
fullyqualifiedname?: string | undefined;
|
|
69
|
+
friendlyname?: string | undefined;
|
|
70
|
+
status?: string | undefined;
|
|
71
|
+
canspendfor?: boolean | undefined;
|
|
72
|
+
cansignfor?: boolean | undefined;
|
|
73
|
+
blockheight?: number | undefined;
|
|
74
|
+
history: IdentityHistoryEntry[];
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
export interface ListIdentitiesOptions {
|
|
78
|
+
includeCanSpend?: boolean;
|
|
79
|
+
includeCanSign?: boolean;
|
|
80
|
+
includeWatchOnly?: boolean;
|
|
81
|
+
}
|
|
82
|
+
/** Query object for the getidentitieswith* index methods. */
|
|
83
|
+
export interface IdentitiesByAddressQuery {
|
|
84
|
+
address: string;
|
|
85
|
+
fromHeight?: number;
|
|
86
|
+
toHeight?: number;
|
|
87
|
+
/** Only identities whose defining output is unspent. */
|
|
88
|
+
unspent?: boolean;
|
|
89
|
+
}
|
|
90
|
+
export interface IdentitiesByAuthorityQuery {
|
|
91
|
+
identityId: string;
|
|
92
|
+
fromHeight?: number;
|
|
93
|
+
toHeight?: number;
|
|
94
|
+
unspent?: boolean;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Flat identity entry returned by the getidentitieswith* index methods —
|
|
98
|
+
* the definition itself, not wrapped in `{identity: …}`.
|
|
99
|
+
*/
|
|
100
|
+
export type IndexedIdentity = IdentityDefinition;
|
|
101
|
+
/** Identity JSON accepted by register/update/recover — daemon field names. */
|
|
102
|
+
export interface IdentitySpec {
|
|
103
|
+
name: string;
|
|
104
|
+
parent?: string;
|
|
105
|
+
primaryaddresses?: string[];
|
|
106
|
+
minimumsignatures?: number;
|
|
107
|
+
revocationauthority?: string;
|
|
108
|
+
recoveryauthority?: string;
|
|
109
|
+
privateaddress?: string;
|
|
110
|
+
contentmap?: Record<string, string>;
|
|
111
|
+
contentmultimap?: Record<string, unknown>;
|
|
112
|
+
timelock?: number;
|
|
113
|
+
version?: number;
|
|
114
|
+
flags?: number;
|
|
115
|
+
[key: string]: unknown;
|
|
116
|
+
}
|
|
117
|
+
export interface RegisterNameCommitmentOptions {
|
|
118
|
+
/** Name to commit, without parent suffix (`"myname"`). */
|
|
119
|
+
name: string;
|
|
120
|
+
/** Transparent address that controls the commitment. */
|
|
121
|
+
controlAddress: string;
|
|
122
|
+
/** Identity that referred the registration (fee discount). */
|
|
123
|
+
referralIdentity?: string;
|
|
124
|
+
/** Parent name/currency for sub-ID registration (default: current chain). */
|
|
125
|
+
parent?: string;
|
|
126
|
+
/** Address/identity that funds the commitment. */
|
|
127
|
+
sourceOfFunds?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface NameReservation {
|
|
130
|
+
name: string;
|
|
131
|
+
salt: string;
|
|
132
|
+
version?: number | undefined;
|
|
133
|
+
referral?: string | undefined;
|
|
134
|
+
parent?: string | undefined;
|
|
135
|
+
nameid?: string | undefined;
|
|
136
|
+
[key: string]: unknown;
|
|
137
|
+
}
|
|
138
|
+
export interface NameCommitmentResult {
|
|
139
|
+
txid: string;
|
|
140
|
+
namereservation: NameReservation;
|
|
141
|
+
[key: string]: unknown;
|
|
142
|
+
}
|
|
143
|
+
export interface RegisterIdentityOptions {
|
|
144
|
+
/** Commitment txid from `registerNameCommitment`. */
|
|
145
|
+
txid: string;
|
|
146
|
+
/** Reservation from `registerNameCommitment`, verbatim. */
|
|
147
|
+
namereservation: NameReservation;
|
|
148
|
+
identity: IdentitySpec;
|
|
149
|
+
/** Return the raw tx hex instead of broadcasting. */
|
|
150
|
+
returnTx?: boolean;
|
|
151
|
+
/** Registration fee offer — bigint sats. */
|
|
152
|
+
feeOffer?: bigint;
|
|
153
|
+
sourceOfFunds?: string;
|
|
154
|
+
}
|
|
155
|
+
export interface UpdateIdentityOptions {
|
|
156
|
+
/** Full identity JSON (typically a modified `getidentity` result's `identity`). */
|
|
157
|
+
identity: IdentitySpec;
|
|
158
|
+
returnTx?: boolean;
|
|
159
|
+
/** Sub-ID on a token-managed currency. */
|
|
160
|
+
tokenUpdate?: boolean;
|
|
161
|
+
feeOffer?: bigint;
|
|
162
|
+
sourceOfFunds?: string;
|
|
163
|
+
}
|
|
164
|
+
export interface RevokeIdentityOptions {
|
|
165
|
+
nameOrId: string;
|
|
166
|
+
returnTx?: boolean;
|
|
167
|
+
tokenRevoke?: boolean;
|
|
168
|
+
feeOffer?: bigint;
|
|
169
|
+
sourceOfFunds?: string;
|
|
170
|
+
}
|
|
171
|
+
export interface RecoverIdentityOptions {
|
|
172
|
+
/** New identity JSON signed by the recovery authority. */
|
|
173
|
+
identity: IdentitySpec;
|
|
174
|
+
returnTx?: boolean;
|
|
175
|
+
tokenRecover?: boolean;
|
|
176
|
+
feeOffer?: bigint;
|
|
177
|
+
sourceOfFunds?: string;
|
|
178
|
+
}
|
|
179
|
+
export interface SetIdentityTimelockOptions {
|
|
180
|
+
nameOrId: string;
|
|
181
|
+
/** Absolute block height to unlock at… */
|
|
182
|
+
unlockAtBlock?: number;
|
|
183
|
+
/** …or a delay (blocks) applied when unlock is requested. */
|
|
184
|
+
setUnlockDelay?: number;
|
|
185
|
+
returnTx?: boolean;
|
|
186
|
+
feeOffer?: bigint;
|
|
187
|
+
sourceOfFunds?: string;
|
|
188
|
+
}
|
|
189
|
+
export interface RegisterIdentityFlowOptions {
|
|
190
|
+
name: string;
|
|
191
|
+
controlAddress: string;
|
|
192
|
+
referralIdentity?: string;
|
|
193
|
+
parent?: string;
|
|
194
|
+
/** Overrides for the registered identity (defaults derive from name/controlAddress). */
|
|
195
|
+
identity?: Partial<IdentitySpec>;
|
|
196
|
+
feeOffer?: bigint;
|
|
197
|
+
sourceOfFunds?: string;
|
|
198
|
+
/** Poll interval while waiting for the commitment to confirm. Default 5s. */
|
|
199
|
+
pollIntervalMs?: number;
|
|
200
|
+
/** Deadline for the commitment confirmation. Default 10 min. */
|
|
201
|
+
confirmationTimeoutMs?: number;
|
|
202
|
+
}
|
|
203
|
+
export interface RegisterIdentityFlowResult {
|
|
204
|
+
commitment: NameCommitmentResult;
|
|
205
|
+
registrationTxid: string;
|
|
206
|
+
}
|
|
207
|
+
export interface SignFileOptions {
|
|
208
|
+
signer: string;
|
|
209
|
+
/** Server-side file path. */
|
|
210
|
+
filename: string;
|
|
211
|
+
currentSignature?: string;
|
|
212
|
+
}
|
|
213
|
+
export declare function mapIdentityDefinition(raw: unknown, method: string, field: string): IdentityDefinition;
|
|
214
|
+
export declare function mapIdentityResult(raw: unknown, method?: string): GetIdentityResult;
|
|
215
|
+
/** Back-compat alias for the Etappe-1 export name. */
|
|
216
|
+
export declare const mapGetIdentity: typeof mapIdentityResult;
|
|
217
|
+
export declare function mapIdentityHistory(raw: unknown): GetIdentityHistoryResult;
|
|
218
|
+
export declare function mapNameCommitment(raw: unknown): NameCommitmentResult;
|
|
219
|
+
/** VerusID family — reads, lifecycle, and the guided registration flow. */
|
|
220
|
+
export declare class IdentityApi {
|
|
221
|
+
private readonly transport;
|
|
222
|
+
constructor(transport: RpcTransport);
|
|
223
|
+
/** Look up a VerusID by `name@` or i-address. */
|
|
224
|
+
getIdentity(options: GetIdentityOptions): Promise<GetIdentityResult>;
|
|
225
|
+
/** Identity incl. aggregated contentmultimap over a height range. */
|
|
226
|
+
getIdentityContent(options: GetIdentityContentOptions): Promise<GetIdentityResult>;
|
|
227
|
+
/** Every historical state of an identity. */
|
|
228
|
+
getIdentityHistory(options: GetIdentityHistoryOptions): Promise<GetIdentityHistoryResult>;
|
|
229
|
+
/** Identities this wallet can spend/sign for. */
|
|
230
|
+
listIdentities(options?: ListIdentitiesOptions): Promise<GetIdentityResult[]>;
|
|
231
|
+
/** Identities containing an address in their primary addresses (index query). */
|
|
232
|
+
getIdentitiesWithAddress(query: IdentitiesByAddressQuery): Promise<IndexedIdentity[]>;
|
|
233
|
+
/** Identities that name this identity as revocation authority. */
|
|
234
|
+
getIdentitiesWithRevocation(query: IdentitiesByAuthorityQuery): Promise<IndexedIdentity[]>;
|
|
235
|
+
/** Identities that name this identity as recovery authority. */
|
|
236
|
+
getIdentitiesWithRecovery(query: IdentitiesByAuthorityQuery): Promise<IndexedIdentity[]>;
|
|
237
|
+
private identitiesByAuthority;
|
|
238
|
+
/** Step 1 of registration: commit to a name. Keep the result — it is required for step 2. */
|
|
239
|
+
registerNameCommitment(options: RegisterNameCommitmentOptions): Promise<NameCommitmentResult>;
|
|
240
|
+
/** Step 2 of registration: register the identity for a confirmed commitment. Returns the txid. */
|
|
241
|
+
registerIdentity(options: RegisterIdentityOptions): Promise<string>;
|
|
242
|
+
/** Update an identity (addresses, authorities, content, …). Returns the txid. */
|
|
243
|
+
updateIdentity(options: UpdateIdentityOptions): Promise<string>;
|
|
244
|
+
/** Revoke an identity — only its recovery authority can recover it. Returns the txid. */
|
|
245
|
+
revokeIdentity(options: RevokeIdentityOptions): Promise<string>;
|
|
246
|
+
/** Recover a revoked identity (signed by the recovery authority). Returns the txid. */
|
|
247
|
+
recoverIdentity(options: RecoverIdentityOptions): Promise<string>;
|
|
248
|
+
/** Timelock an identity (absolute unlock height or unlock delay). Returns the txid. */
|
|
249
|
+
setIdentityTimelock(options: SetIdentityTimelockOptions): Promise<string>;
|
|
250
|
+
private lifecycleCall;
|
|
251
|
+
/**
|
|
252
|
+
* Guided registration: commitment → wait for confirmation → register.
|
|
253
|
+
* Defaults: single-sig identity controlled by `controlAddress`.
|
|
254
|
+
* Throws `OperationTimeoutError` if the commitment does not confirm in time.
|
|
255
|
+
*/
|
|
256
|
+
registerIdentityFlow(options: RegisterIdentityFlowOptions): Promise<RegisterIdentityFlowResult>;
|
|
257
|
+
/** Sign structured data/messages/hashes (daemon JSON options, passthrough). T2. */
|
|
258
|
+
signData(options: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
259
|
+
/** Sign a server-side file with an address or identity key. T2. */
|
|
260
|
+
signFile(options: SignFileOptions): Promise<Record<string, unknown>>;
|
|
261
|
+
/** Verify a file signature. T2. */
|
|
262
|
+
verifyFile(options: {
|
|
263
|
+
signer: string;
|
|
264
|
+
signature: string;
|
|
265
|
+
filename: string;
|
|
266
|
+
checkLatest?: boolean;
|
|
267
|
+
}): Promise<boolean>;
|
|
268
|
+
/** Verify a hash signature. T2. */
|
|
269
|
+
verifyHash(options: {
|
|
270
|
+
signer: string;
|
|
271
|
+
signature: string;
|
|
272
|
+
hash: string;
|
|
273
|
+
checkLatest?: boolean;
|
|
274
|
+
}): Promise<boolean>;
|
|
275
|
+
/** Verify structured-data signatures (daemon JSON options, passthrough). T2. */
|
|
276
|
+
verifySignature(options: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
277
|
+
/** Trust ratings this wallet keeps for identities. T2. */
|
|
278
|
+
getIdentityTrust(options?: {
|
|
279
|
+
identityIds?: string[];
|
|
280
|
+
}): Promise<Record<string, unknown>>;
|
|
281
|
+
/** Set/clear wallet-local identity trust ratings (daemon JSON options). T2. */
|
|
282
|
+
setIdentityTrust(options: Record<string, unknown>): Promise<void>;
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/methods/identity.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAA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AA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAK9F,+EAA+E;IACzE,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAGxE"}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { formatAmount } from "../amount.js";
|
|
2
|
+
import { OperationTimeoutError } from "../errors.js";
|
|
3
|
+
import { LosslessNumber, toSafeNumbers } from "../lossless.js";
|
|
4
|
+
import { expectArray, expectObject, mapBooleanOptional, mapInt, mapIntOptional, mapString, mapStringArray, mapStringOptional, withPassthrough, } from "../mapping.js";
|
|
5
|
+
import { requestT2 } from "./t2.js";
|
|
6
|
+
import { mapGetTransaction } from "./wallet.js";
|
|
7
|
+
export function mapIdentityDefinition(raw, method, field) {
|
|
8
|
+
const obj = expectObject(raw, method);
|
|
9
|
+
const ctx = (name) => ({ method, field: `${field}.${name}` });
|
|
10
|
+
return withPassthrough(obj, {
|
|
11
|
+
version: mapInt(obj["version"], ctx("version")),
|
|
12
|
+
flags: mapInt(obj["flags"], ctx("flags")),
|
|
13
|
+
primaryaddresses: mapStringArray(obj["primaryaddresses"], ctx("primaryaddresses")),
|
|
14
|
+
minimumsignatures: mapInt(obj["minimumsignatures"], ctx("minimumsignatures")),
|
|
15
|
+
name: mapString(obj["name"], ctx("name")),
|
|
16
|
+
identityaddress: mapString(obj["identityaddress"], ctx("identityaddress")),
|
|
17
|
+
parent: mapString(obj["parent"], ctx("parent")),
|
|
18
|
+
systemid: mapString(obj["systemid"], ctx("systemid")),
|
|
19
|
+
contentmap: obj["contentmap"] === undefined || obj["contentmap"] === null
|
|
20
|
+
? undefined
|
|
21
|
+
: toSafeNumbers(expectObject(obj["contentmap"], method)),
|
|
22
|
+
contentmultimap: obj["contentmultimap"] === undefined || obj["contentmultimap"] === null
|
|
23
|
+
? undefined
|
|
24
|
+
: toSafeNumbers(expectObject(obj["contentmultimap"], method)),
|
|
25
|
+
revocationauthority: mapString(obj["revocationauthority"], ctx("revocationauthority")),
|
|
26
|
+
recoveryauthority: mapString(obj["recoveryauthority"], ctx("recoveryauthority")),
|
|
27
|
+
privateaddress: mapStringOptional(obj["privateaddress"], ctx("privateaddress")),
|
|
28
|
+
timelock: mapIntOptional(obj["timelock"], ctx("timelock")),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export function mapIdentityResult(raw, method = "getidentity") {
|
|
32
|
+
const obj = expectObject(raw, method);
|
|
33
|
+
const ctx = (field) => ({ method, field });
|
|
34
|
+
return withPassthrough(obj, {
|
|
35
|
+
fullyqualifiedname: mapStringOptional(obj["fullyqualifiedname"], ctx("fullyqualifiedname")),
|
|
36
|
+
friendlyname: mapStringOptional(obj["friendlyname"], ctx("friendlyname")),
|
|
37
|
+
identity: mapIdentityDefinition(obj["identity"], method, "identity"),
|
|
38
|
+
status: mapStringOptional(obj["status"], ctx("status")),
|
|
39
|
+
canspendfor: mapBooleanOptional(obj["canspendfor"], ctx("canspendfor")),
|
|
40
|
+
cansignfor: mapBooleanOptional(obj["cansignfor"], ctx("cansignfor")),
|
|
41
|
+
blockheight: mapIntOptional(obj["blockheight"], ctx("blockheight")),
|
|
42
|
+
txid: mapStringOptional(obj["txid"], ctx("txid")),
|
|
43
|
+
vout: mapIntOptional(obj["vout"], ctx("vout")),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** Back-compat alias for the Etappe-1 export name. */
|
|
47
|
+
export const mapGetIdentity = mapIdentityResult;
|
|
48
|
+
export function mapIdentityHistory(raw) {
|
|
49
|
+
const method = "getidentityhistory";
|
|
50
|
+
const obj = expectObject(raw, method);
|
|
51
|
+
const ctx = (field) => ({ method, field });
|
|
52
|
+
const history = expectArray(obj["history"] ?? [], method, "history").map((item, i) => {
|
|
53
|
+
const entry = expectObject(item, method);
|
|
54
|
+
const ectx = (field) => ({ method, field: `history[${i}].${field}` });
|
|
55
|
+
return withPassthrough(entry, {
|
|
56
|
+
blockhash: mapStringOptional(entry["blockhash"], ectx("blockhash")),
|
|
57
|
+
height: mapInt(entry["height"], ectx("height")),
|
|
58
|
+
output: entry["output"] === undefined ? undefined : toSafeNumbers(entry["output"]),
|
|
59
|
+
identity: mapIdentityDefinition(entry["identity"], method, `history[${i}].identity`),
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return withPassthrough(obj, {
|
|
63
|
+
fullyqualifiedname: mapStringOptional(obj["fullyqualifiedname"], ctx("fullyqualifiedname")),
|
|
64
|
+
friendlyname: mapStringOptional(obj["friendlyname"], ctx("friendlyname")),
|
|
65
|
+
status: mapStringOptional(obj["status"], ctx("status")),
|
|
66
|
+
canspendfor: mapBooleanOptional(obj["canspendfor"], ctx("canspendfor")),
|
|
67
|
+
cansignfor: mapBooleanOptional(obj["cansignfor"], ctx("cansignfor")),
|
|
68
|
+
blockheight: mapIntOptional(obj["blockheight"], ctx("blockheight")),
|
|
69
|
+
history,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function mapNameCommitment(raw) {
|
|
73
|
+
const method = "registernamecommitment";
|
|
74
|
+
const obj = expectObject(raw, method);
|
|
75
|
+
const reservation = expectObject(obj["namereservation"], method);
|
|
76
|
+
const rctx = (field) => ({ method, field: `namereservation.${field}` });
|
|
77
|
+
return withPassthrough(obj, {
|
|
78
|
+
txid: mapString(obj["txid"], { method, field: "txid" }),
|
|
79
|
+
namereservation: withPassthrough(reservation, {
|
|
80
|
+
name: mapString(reservation["name"], rctx("name")),
|
|
81
|
+
salt: mapString(reservation["salt"], rctx("salt")),
|
|
82
|
+
version: mapIntOptional(reservation["version"], rctx("version")),
|
|
83
|
+
referral: mapStringOptional(reservation["referral"], rctx("referral")),
|
|
84
|
+
parent: mapStringOptional(reservation["parent"], rctx("parent")),
|
|
85
|
+
nameid: mapStringOptional(reservation["nameid"], rctx("nameid")),
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function feeParam(sats) {
|
|
90
|
+
return new LosslessNumber(formatAmount(sats));
|
|
91
|
+
}
|
|
92
|
+
function sleep(ms) {
|
|
93
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
94
|
+
}
|
|
95
|
+
/** VerusID family — reads, lifecycle, and the guided registration flow. */
|
|
96
|
+
export class IdentityApi {
|
|
97
|
+
transport;
|
|
98
|
+
constructor(transport) {
|
|
99
|
+
this.transport = transport;
|
|
100
|
+
}
|
|
101
|
+
// -------------------------------------------------------------------------
|
|
102
|
+
// T1 — reads
|
|
103
|
+
/** Look up a VerusID by `name@` or i-address. */
|
|
104
|
+
async getIdentity(options) {
|
|
105
|
+
const params = [options.nameOrAddress];
|
|
106
|
+
const needHeight = options.height !== undefined || options.txProof !== undefined || options.txProofHeight !== undefined;
|
|
107
|
+
if (needHeight)
|
|
108
|
+
params.push(options.height ?? 0);
|
|
109
|
+
if (options.txProof !== undefined || options.txProofHeight !== undefined)
|
|
110
|
+
params.push(options.txProof ?? false);
|
|
111
|
+
if (options.txProofHeight !== undefined)
|
|
112
|
+
params.push(options.txProofHeight);
|
|
113
|
+
return mapIdentityResult(await this.transport.request("getidentity", params));
|
|
114
|
+
}
|
|
115
|
+
/** Identity incl. aggregated contentmultimap over a height range. */
|
|
116
|
+
async getIdentityContent(options) {
|
|
117
|
+
const params = [options.nameOrAddress];
|
|
118
|
+
const opts = [options.heightStart, options.heightEnd, options.txProofs, options.txProofHeight, options.vdxfKey];
|
|
119
|
+
const defaults = [0, 0, false, 0, null];
|
|
120
|
+
const lastSet = opts.reduce((last, value, i) => (value === undefined ? last : i), -1);
|
|
121
|
+
for (let i = 0; i <= lastSet; i++)
|
|
122
|
+
params.push(opts[i] ?? defaults[i]);
|
|
123
|
+
return mapIdentityResult(await this.transport.request("getidentitycontent", params), "getidentitycontent");
|
|
124
|
+
}
|
|
125
|
+
/** Every historical state of an identity. */
|
|
126
|
+
async getIdentityHistory(options) {
|
|
127
|
+
const params = [options.nameOrAddress];
|
|
128
|
+
const opts = [options.heightStart, options.heightEnd, options.txProofs, options.txProofHeight];
|
|
129
|
+
const defaults = [0, 0, false, 0];
|
|
130
|
+
const lastSet = opts.reduce((last, value, i) => (value === undefined ? last : i), -1);
|
|
131
|
+
for (let i = 0; i <= lastSet; i++)
|
|
132
|
+
params.push(opts[i] ?? defaults[i]);
|
|
133
|
+
return mapIdentityHistory(await this.transport.request("getidentityhistory", params));
|
|
134
|
+
}
|
|
135
|
+
/** Identities this wallet can spend/sign for. */
|
|
136
|
+
async listIdentities(options) {
|
|
137
|
+
const params = [];
|
|
138
|
+
const opts = [options?.includeCanSpend, options?.includeCanSign, options?.includeWatchOnly];
|
|
139
|
+
const defaults = [true, true, false];
|
|
140
|
+
const lastSet = opts.reduce((last, value, i) => (value === undefined ? last : i), -1);
|
|
141
|
+
for (let i = 0; i <= lastSet; i++)
|
|
142
|
+
params.push(opts[i] ?? defaults[i]);
|
|
143
|
+
const result = expectArray(await this.transport.request("listidentities", params), "listidentities");
|
|
144
|
+
return result.map((item) => mapIdentityResult(item, "listidentities"));
|
|
145
|
+
}
|
|
146
|
+
/** Identities containing an address in their primary addresses (index query). */
|
|
147
|
+
async getIdentitiesWithAddress(query) {
|
|
148
|
+
const raw = { address: query.address };
|
|
149
|
+
if (query.fromHeight !== undefined)
|
|
150
|
+
raw["fromheight"] = query.fromHeight;
|
|
151
|
+
if (query.toHeight !== undefined)
|
|
152
|
+
raw["toheight"] = query.toHeight;
|
|
153
|
+
if (query.unspent !== undefined)
|
|
154
|
+
raw["unspent"] = query.unspent;
|
|
155
|
+
const result = expectArray(await this.transport.request("getidentitieswithaddress", [raw]), "getidentitieswithaddress");
|
|
156
|
+
return result.map((item, i) => mapIdentityDefinition(item, "getidentitieswithaddress", `[${i}]`));
|
|
157
|
+
}
|
|
158
|
+
/** Identities that name this identity as revocation authority. */
|
|
159
|
+
async getIdentitiesWithRevocation(query) {
|
|
160
|
+
return this.identitiesByAuthority("getidentitieswithrevocation", query);
|
|
161
|
+
}
|
|
162
|
+
/** Identities that name this identity as recovery authority. */
|
|
163
|
+
async getIdentitiesWithRecovery(query) {
|
|
164
|
+
return this.identitiesByAuthority("getidentitieswithrecovery", query);
|
|
165
|
+
}
|
|
166
|
+
async identitiesByAuthority(method, query) {
|
|
167
|
+
const raw = { identityid: query.identityId };
|
|
168
|
+
if (query.fromHeight !== undefined)
|
|
169
|
+
raw["fromheight"] = query.fromHeight;
|
|
170
|
+
if (query.toHeight !== undefined)
|
|
171
|
+
raw["toheight"] = query.toHeight;
|
|
172
|
+
if (query.unspent !== undefined)
|
|
173
|
+
raw["unspent"] = query.unspent;
|
|
174
|
+
const result = expectArray(await this.transport.request(method, [raw]), method);
|
|
175
|
+
return result.map((item, i) => mapIdentityDefinition(item, method, `[${i}]`));
|
|
176
|
+
}
|
|
177
|
+
// -------------------------------------------------------------------------
|
|
178
|
+
// T1 — lifecycle
|
|
179
|
+
/** Step 1 of registration: commit to a name. Keep the result — it is required for step 2. */
|
|
180
|
+
async registerNameCommitment(options) {
|
|
181
|
+
const params = [options.name, options.controlAddress];
|
|
182
|
+
const opts = [options.referralIdentity, options.parent, options.sourceOfFunds];
|
|
183
|
+
const lastSet = opts.reduce((last, value, i) => (value === undefined ? last : i), -1);
|
|
184
|
+
// Skipped middle positions are sent as JSON null (daemon treats null as "not provided").
|
|
185
|
+
for (let i = 0; i <= lastSet; i++)
|
|
186
|
+
params.push(opts[i] ?? null);
|
|
187
|
+
return mapNameCommitment(await this.transport.request("registernamecommitment", params));
|
|
188
|
+
}
|
|
189
|
+
/** Step 2 of registration: register the identity for a confirmed commitment. Returns the txid. */
|
|
190
|
+
async registerIdentity(options) {
|
|
191
|
+
const first = {
|
|
192
|
+
txid: options.txid,
|
|
193
|
+
namereservation: options.namereservation,
|
|
194
|
+
identity: options.identity,
|
|
195
|
+
};
|
|
196
|
+
const params = [first];
|
|
197
|
+
const opts = [
|
|
198
|
+
options.returnTx,
|
|
199
|
+
options.feeOffer === undefined ? undefined : feeParam(options.feeOffer),
|
|
200
|
+
options.sourceOfFunds,
|
|
201
|
+
];
|
|
202
|
+
const lastSet = opts.reduce((last, value, i) => (value === undefined ? last : i), -1);
|
|
203
|
+
for (let i = 0; i <= lastSet; i++)
|
|
204
|
+
params.push(opts[i] ?? (i === 0 ? false : null));
|
|
205
|
+
return mapString(await this.transport.request("registeridentity", params), {
|
|
206
|
+
method: "registeridentity",
|
|
207
|
+
field: "(result)",
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
/** Update an identity (addresses, authorities, content, …). Returns the txid. */
|
|
211
|
+
async updateIdentity(options) {
|
|
212
|
+
return this.lifecycleCall("updateidentity", options.identity, options.returnTx, options.tokenUpdate, options.feeOffer, options.sourceOfFunds);
|
|
213
|
+
}
|
|
214
|
+
/** Revoke an identity — only its recovery authority can recover it. Returns the txid. */
|
|
215
|
+
async revokeIdentity(options) {
|
|
216
|
+
return this.lifecycleCall("revokeidentity", options.nameOrId, options.returnTx, options.tokenRevoke, options.feeOffer, options.sourceOfFunds);
|
|
217
|
+
}
|
|
218
|
+
/** Recover a revoked identity (signed by the recovery authority). Returns the txid. */
|
|
219
|
+
async recoverIdentity(options) {
|
|
220
|
+
return this.lifecycleCall("recoveridentity", options.identity, options.returnTx, options.tokenRecover, options.feeOffer, options.sourceOfFunds);
|
|
221
|
+
}
|
|
222
|
+
/** Timelock an identity (absolute unlock height or unlock delay). Returns the txid. */
|
|
223
|
+
async setIdentityTimelock(options) {
|
|
224
|
+
if ((options.unlockAtBlock === undefined) === (options.setUnlockDelay === undefined)) {
|
|
225
|
+
throw new TypeError("setIdentityTimelock: exactly one of unlockAtBlock / setUnlockDelay is required");
|
|
226
|
+
}
|
|
227
|
+
const lockSpec = options.unlockAtBlock !== undefined
|
|
228
|
+
? { unlockatblock: options.unlockAtBlock }
|
|
229
|
+
: { setunlockdelay: options.setUnlockDelay };
|
|
230
|
+
const params = [options.nameOrId, lockSpec];
|
|
231
|
+
const opts = [
|
|
232
|
+
options.returnTx,
|
|
233
|
+
options.feeOffer === undefined ? undefined : feeParam(options.feeOffer),
|
|
234
|
+
options.sourceOfFunds,
|
|
235
|
+
];
|
|
236
|
+
const lastSet = opts.reduce((last, value, i) => (value === undefined ? last : i), -1);
|
|
237
|
+
for (let i = 0; i <= lastSet; i++)
|
|
238
|
+
params.push(opts[i] ?? (i === 0 ? false : null));
|
|
239
|
+
return mapString(await this.transport.request("setidentitytimelock", params), {
|
|
240
|
+
method: "setidentitytimelock",
|
|
241
|
+
field: "(result)",
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
async lifecycleCall(method, first, returnTx, tokenFlag, feeOffer, sourceOfFunds) {
|
|
245
|
+
const params = [first];
|
|
246
|
+
const opts = [returnTx, tokenFlag, feeOffer === undefined ? undefined : feeParam(feeOffer), sourceOfFunds];
|
|
247
|
+
const lastSet = opts.reduce((last, value, i) => (value === undefined ? last : i), -1);
|
|
248
|
+
for (let i = 0; i <= lastSet; i++)
|
|
249
|
+
params.push(opts[i] ?? (i <= 1 ? false : null));
|
|
250
|
+
return mapString(await this.transport.request(method, params), { method, field: "(result)" });
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Guided registration: commitment → wait for confirmation → register.
|
|
254
|
+
* Defaults: single-sig identity controlled by `controlAddress`.
|
|
255
|
+
* Throws `OperationTimeoutError` if the commitment does not confirm in time.
|
|
256
|
+
*/
|
|
257
|
+
async registerIdentityFlow(options) {
|
|
258
|
+
const interval = options.pollIntervalMs ?? 5_000;
|
|
259
|
+
const timeout = options.confirmationTimeoutMs ?? 600_000;
|
|
260
|
+
const commitment = await this.registerNameCommitment({
|
|
261
|
+
name: options.name,
|
|
262
|
+
controlAddress: options.controlAddress,
|
|
263
|
+
...(options.referralIdentity !== undefined ? { referralIdentity: options.referralIdentity } : {}),
|
|
264
|
+
...(options.parent !== undefined ? { parent: options.parent } : {}),
|
|
265
|
+
...(options.sourceOfFunds !== undefined ? { sourceOfFunds: options.sourceOfFunds } : {}),
|
|
266
|
+
});
|
|
267
|
+
const deadline = Date.now() + timeout;
|
|
268
|
+
for (;;) {
|
|
269
|
+
const tx = mapGetTransaction(await this.transport.request("gettransaction", [commitment.txid]));
|
|
270
|
+
if (tx.confirmations >= 1)
|
|
271
|
+
break;
|
|
272
|
+
const remaining = deadline - Date.now();
|
|
273
|
+
if (remaining <= 0) {
|
|
274
|
+
throw new OperationTimeoutError(commitment.txid, timeout);
|
|
275
|
+
}
|
|
276
|
+
await sleep(Math.min(interval, remaining));
|
|
277
|
+
}
|
|
278
|
+
const registrationTxid = await this.registerIdentity({
|
|
279
|
+
txid: commitment.txid,
|
|
280
|
+
namereservation: commitment.namereservation,
|
|
281
|
+
identity: {
|
|
282
|
+
name: options.name,
|
|
283
|
+
primaryaddresses: [options.controlAddress],
|
|
284
|
+
minimumsignatures: 1,
|
|
285
|
+
...options.identity,
|
|
286
|
+
},
|
|
287
|
+
...(options.feeOffer !== undefined ? { feeOffer: options.feeOffer } : {}),
|
|
288
|
+
...(options.sourceOfFunds !== undefined ? { sourceOfFunds: options.sourceOfFunds } : {}),
|
|
289
|
+
});
|
|
290
|
+
return { commitment, registrationTxid };
|
|
291
|
+
}
|
|
292
|
+
// -------------------------------------------------------------------------
|
|
293
|
+
// T2 — signatures, trust, data
|
|
294
|
+
/** Sign structured data/messages/hashes (daemon JSON options, passthrough). T2. */
|
|
295
|
+
async signData(options) {
|
|
296
|
+
return requestT2(this.transport, "signdata", [options]);
|
|
297
|
+
}
|
|
298
|
+
/** Sign a server-side file with an address or identity key. T2. */
|
|
299
|
+
async signFile(options) {
|
|
300
|
+
const params = [options.signer, options.filename];
|
|
301
|
+
if (options.currentSignature !== undefined)
|
|
302
|
+
params.push(options.currentSignature);
|
|
303
|
+
return requestT2(this.transport, "signfile", params);
|
|
304
|
+
}
|
|
305
|
+
/** Verify a file signature. T2. */
|
|
306
|
+
async verifyFile(options) {
|
|
307
|
+
const params = [options.signer, options.signature, options.filename];
|
|
308
|
+
if (options.checkLatest !== undefined)
|
|
309
|
+
params.push(options.checkLatest);
|
|
310
|
+
return requestT2(this.transport, "verifyfile", params);
|
|
311
|
+
}
|
|
312
|
+
/** Verify a hash signature. T2. */
|
|
313
|
+
async verifyHash(options) {
|
|
314
|
+
const params = [options.signer, options.signature, options.hash];
|
|
315
|
+
if (options.checkLatest !== undefined)
|
|
316
|
+
params.push(options.checkLatest);
|
|
317
|
+
return requestT2(this.transport, "verifyhash", params);
|
|
318
|
+
}
|
|
319
|
+
/** Verify structured-data signatures (daemon JSON options, passthrough). T2. */
|
|
320
|
+
async verifySignature(options) {
|
|
321
|
+
return requestT2(this.transport, "verifysignature", [options]);
|
|
322
|
+
}
|
|
323
|
+
/** Trust ratings this wallet keeps for identities. T2. */
|
|
324
|
+
async getIdentityTrust(options) {
|
|
325
|
+
const params = options?.identityIds === undefined ? [] : [{ identities: options.identityIds }];
|
|
326
|
+
return requestT2(this.transport, "getidentitytrust", params);
|
|
327
|
+
}
|
|
328
|
+
/** Set/clear wallet-local identity trust ratings (daemon JSON options). T2. */
|
|
329
|
+
async setIdentityTrust(options) {
|
|
330
|
+
await this.transport.request("setidentitytrust", [options]);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=identity.js.map
|