@bsv/sdk 1.7.0 → 1.7.2
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/package.json +1 -1
- package/dist/cjs/src/identity/IdentityClient.js +22 -6
- package/dist/cjs/src/identity/IdentityClient.js.map +1 -1
- package/dist/cjs/src/overlay-tools/LookupResolver.js +153 -75
- package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/identity/IdentityClient.js +22 -6
- package/dist/esm/src/identity/IdentityClient.js.map +1 -1
- package/dist/esm/src/overlay-tools/LookupResolver.js +160 -75
- package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/identity/IdentityClient.d.ts +4 -2
- package/dist/types/src/identity/IdentityClient.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts +29 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +3 -3
- package/dist/umd/bundle.js.map +1 -1
- package/docs/reference/identity.md +8 -4
- package/docs/reference/overlay-tools.md +10 -1
- package/docs/reference/storage.md +1 -1
- package/package.json +1 -1
- package/src/identity/IdentityClient.ts +32 -6
- package/src/identity/__tests/IdentityClient.test.ts +172 -45
- package/src/overlay-tools/LookupResolver.ts +168 -81
- package/src/overlay-tools/__tests/LookupResolver.test.ts +0 -47
|
@@ -130,8 +130,8 @@ IdentityClient lets you discover who others are, and let the world know who you
|
|
|
130
130
|
export class IdentityClient {
|
|
131
131
|
constructor(wallet?: WalletInterface, private readonly options = DEFAULT_IDENTITY_CLIENT_OPTIONS, private readonly originator?: OriginatorDomainNameStringUnder250Bytes)
|
|
132
132
|
async publiclyRevealAttributes(certificate: WalletCertificate, fieldsToReveal: CertificateFieldNameUnder50Bytes[]): Promise<BroadcastResponse | BroadcastFailure>
|
|
133
|
-
async resolveByIdentityKey(args: DiscoverByIdentityKeyArgs): Promise<DisplayableIdentity[]>
|
|
134
|
-
async resolveByAttributes(args: DiscoverByAttributesArgs): Promise<DisplayableIdentity[]>
|
|
133
|
+
async resolveByIdentityKey(args: DiscoverByIdentityKeyArgs, overrideWithContacts = true): Promise<DisplayableIdentity[]>
|
|
134
|
+
async resolveByAttributes(args: DiscoverByAttributesArgs, overrideWithContacts = true): Promise<DisplayableIdentity[]>
|
|
135
135
|
public async getContacts(identityKey?: PubKeyHex, forceRefresh = false): Promise<Contact[]>
|
|
136
136
|
public async saveContact(contact: DisplayableIdentity, metadata?: Record<string, any>): Promise<void>
|
|
137
137
|
public async removeContact(identityKey: PubKeyHex): Promise<void>
|
|
@@ -228,7 +228,7 @@ Argument Details
|
|
|
228
228
|
Resolves displayable identity certificates by specific identity attributes, issued by a trusted entity.
|
|
229
229
|
|
|
230
230
|
```ts
|
|
231
|
-
async resolveByAttributes(args: DiscoverByAttributesArgs): Promise<DisplayableIdentity[]>
|
|
231
|
+
async resolveByAttributes(args: DiscoverByAttributesArgs, overrideWithContacts = true): Promise<DisplayableIdentity[]>
|
|
232
232
|
```
|
|
233
233
|
See also: [DiscoverByAttributesArgs](./wallet.md#interface-discoverbyattributesargs), [DisplayableIdentity](./identity.md#interface-displayableidentity)
|
|
234
234
|
|
|
@@ -240,13 +240,15 @@ Argument Details
|
|
|
240
240
|
|
|
241
241
|
+ **args**
|
|
242
242
|
+ Attributes and optional parameters used to discover certificates.
|
|
243
|
+
+ **overrideWithContacts**
|
|
244
|
+
+ Whether to override the results with personal contacts if available.
|
|
243
245
|
|
|
244
246
|
#### Method resolveByIdentityKey
|
|
245
247
|
|
|
246
248
|
Resolves displayable identity certificates, issued to a given identity key by a trusted certifier.
|
|
247
249
|
|
|
248
250
|
```ts
|
|
249
|
-
async resolveByIdentityKey(args: DiscoverByIdentityKeyArgs): Promise<DisplayableIdentity[]>
|
|
251
|
+
async resolveByIdentityKey(args: DiscoverByIdentityKeyArgs, overrideWithContacts = true): Promise<DisplayableIdentity[]>
|
|
250
252
|
```
|
|
251
253
|
See also: [DiscoverByIdentityKeyArgs](./wallet.md#interface-discoverbyidentitykeyargs), [DisplayableIdentity](./identity.md#interface-displayableidentity)
|
|
252
254
|
|
|
@@ -258,6 +260,8 @@ Argument Details
|
|
|
258
260
|
|
|
259
261
|
+ **args**
|
|
260
262
|
+ Arguments for requesting the discovery based on the identity key.
|
|
263
|
+
+ **overrideWithContacts**
|
|
264
|
+
+ Whether to override the results with personal contacts if available.
|
|
261
265
|
|
|
262
266
|
#### Method saveContact
|
|
263
267
|
|
|
@@ -100,6 +100,7 @@ export interface LookupResolverConfig {
|
|
|
100
100
|
slapTrackers?: string[];
|
|
101
101
|
hostOverrides?: Record<string, string[]>;
|
|
102
102
|
additionalHosts?: Record<string, string[]>;
|
|
103
|
+
cache?: CacheOptions;
|
|
103
104
|
}
|
|
104
105
|
```
|
|
105
106
|
|
|
@@ -113,6 +114,14 @@ Map of lookup service names to arrays of hosts to use in addition to resolving v
|
|
|
113
114
|
additionalHosts?: Record<string, string[]>
|
|
114
115
|
```
|
|
115
116
|
|
|
117
|
+
#### Property cache
|
|
118
|
+
|
|
119
|
+
Optional cache tuning.
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
cache?: CacheOptions
|
|
123
|
+
```
|
|
124
|
+
|
|
116
125
|
#### Property facilitator
|
|
117
126
|
|
|
118
127
|
The facilitator used to make requests to Overlay Services hosts.
|
|
@@ -327,7 +336,7 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
327
336
|
---
|
|
328
337
|
### Class: LookupResolver
|
|
329
338
|
|
|
330
|
-
Represents
|
|
339
|
+
Represents a Lookup Resolver.
|
|
331
340
|
|
|
332
341
|
```ts
|
|
333
342
|
export default class LookupResolver {
|
|
@@ -354,7 +354,7 @@ getURLForFile = (file: Uint8Array | number[]): string => {
|
|
|
354
354
|
}
|
|
355
355
|
```
|
|
356
356
|
|
|
357
|
-
See also: [getURLForHash](./storage.md#variable-geturlforhash)
|
|
357
|
+
See also: [SHA256](./primitives.md#class-sha256), [getURLForHash](./storage.md#variable-geturlforhash)
|
|
358
358
|
|
|
359
359
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
360
360
|
|
package/package.json
CHANGED
|
@@ -116,11 +116,21 @@ export class IdentityClient {
|
|
|
116
116
|
* Resolves displayable identity certificates, issued to a given identity key by a trusted certifier.
|
|
117
117
|
*
|
|
118
118
|
* @param {DiscoverByIdentityKeyArgs} args - Arguments for requesting the discovery based on the identity key.
|
|
119
|
+
* @param {boolean} [overrideWithContacts=true] - Whether to override the results with personal contacts if available.
|
|
119
120
|
* @returns {Promise<DisplayableIdentity[]>} The promise resolves to displayable identities.
|
|
120
121
|
*/
|
|
121
122
|
async resolveByIdentityKey (
|
|
122
|
-
args: DiscoverByIdentityKeyArgs
|
|
123
|
+
args: DiscoverByIdentityKeyArgs,
|
|
124
|
+
overrideWithContacts = true
|
|
123
125
|
): Promise<DisplayableIdentity[]> {
|
|
126
|
+
if (overrideWithContacts) {
|
|
127
|
+
// Override results with personal contacts if available
|
|
128
|
+
const contacts = await this.contactsManager.getContacts(args.identityKey)
|
|
129
|
+
if (contacts.length > 0) {
|
|
130
|
+
return contacts
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
124
134
|
const { certificates } = await this.wallet.discoverByIdentityKey(args, this.originator)
|
|
125
135
|
return certificates.map(cert => {
|
|
126
136
|
return IdentityClient.parseIdentity(cert)
|
|
@@ -131,15 +141,31 @@ export class IdentityClient {
|
|
|
131
141
|
* Resolves displayable identity certificates by specific identity attributes, issued by a trusted entity.
|
|
132
142
|
*
|
|
133
143
|
* @param {DiscoverByAttributesArgs} args - Attributes and optional parameters used to discover certificates.
|
|
144
|
+
* @param {boolean} [overrideWithContacts=true] - Whether to override the results with personal contacts if available.
|
|
134
145
|
* @returns {Promise<DisplayableIdentity[]>} The promise resolves to displayable identities.
|
|
135
146
|
*/
|
|
136
147
|
async resolveByAttributes (
|
|
137
|
-
args: DiscoverByAttributesArgs
|
|
148
|
+
args: DiscoverByAttributesArgs,
|
|
149
|
+
overrideWithContacts = true
|
|
138
150
|
): Promise<DisplayableIdentity[]> {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
151
|
+
// Run both queries in parallel for better performance
|
|
152
|
+
const [contacts, certificatesResult] = await Promise.all([
|
|
153
|
+
overrideWithContacts ? this.contactsManager.getContacts() : Promise.resolve([]),
|
|
154
|
+
this.wallet.discoverByAttributes(args, this.originator)
|
|
155
|
+
])
|
|
156
|
+
|
|
157
|
+
// Fast lookup by identityKey
|
|
158
|
+
const contactByKey = new Map<PubKeyHex, Contact>(
|
|
159
|
+
contacts.map(contact => [contact.identityKey, contact] as const)
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
// Guard if certificates might be absent
|
|
163
|
+
const certs = certificatesResult?.certificates ?? []
|
|
164
|
+
|
|
165
|
+
// Parse certificates and substitute with contacts where available
|
|
166
|
+
return certs.map(cert =>
|
|
167
|
+
contactByKey.get(cert.subject) ?? IdentityClient.parseIdentity(cert)
|
|
168
|
+
)
|
|
143
169
|
}
|
|
144
170
|
|
|
145
171
|
/**
|
|
@@ -226,6 +226,43 @@ describe('IdentityClient', () => {
|
|
|
226
226
|
badgeClickURL: 'https://socialcert.net'
|
|
227
227
|
})
|
|
228
228
|
})
|
|
229
|
+
|
|
230
|
+
it('should prioritize contacts over discovered identities for same identity key', async () => {
|
|
231
|
+
const contact = {
|
|
232
|
+
name: 'Alice Smith (Personal Contact)',
|
|
233
|
+
identityKey: 'alice-identity-key',
|
|
234
|
+
avatarURL: 'alice-avatar.png',
|
|
235
|
+
abbreviatedKey: 'alice-i...',
|
|
236
|
+
badgeIconURL: '',
|
|
237
|
+
badgeLabel: '',
|
|
238
|
+
badgeClickURL: ''
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const discoveredCertificate = {
|
|
242
|
+
type: KNOWN_IDENTITY_TYPES.xCert,
|
|
243
|
+
subject: 'alice-identity-key',
|
|
244
|
+
decryptedFields: {
|
|
245
|
+
userName: 'Alice Public',
|
|
246
|
+
profilePhoto: 'public-photo.png'
|
|
247
|
+
},
|
|
248
|
+
certifierInfo: {
|
|
249
|
+
name: 'CertifierX',
|
|
250
|
+
iconUrl: 'certifier-icon.png'
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Mock ContactsManager to return contact for the specific identity key
|
|
255
|
+
const mockContactsManager = identityClient['contactsManager']
|
|
256
|
+
mockContactsManager.getContacts = jest.fn().mockResolvedValue([contact])
|
|
257
|
+
walletMock.discoverByIdentityKey = jest.fn().mockResolvedValue({ certificates: [discoveredCertificate] })
|
|
258
|
+
|
|
259
|
+
const identities = await identityClient.resolveByIdentityKey({ identityKey: 'alice-identity-key' })
|
|
260
|
+
|
|
261
|
+
expect(identities).toHaveLength(1)
|
|
262
|
+
expect(identities[0].name).toBe('Alice Smith (Personal Contact)') // Contact should be returned, not discovered identity
|
|
263
|
+
// Wallet method should not be called when contact is found
|
|
264
|
+
expect(walletMock.discoverByIdentityKey).not.toHaveBeenCalled()
|
|
265
|
+
})
|
|
229
266
|
})
|
|
230
267
|
|
|
231
268
|
it('should throw if createAction returns no tx', async () => {
|
|
@@ -256,34 +293,124 @@ describe('IdentityClient', () => {
|
|
|
256
293
|
})
|
|
257
294
|
|
|
258
295
|
describe('resolveByAttributes', () => {
|
|
259
|
-
|
|
296
|
+
beforeEach(() => {
|
|
297
|
+
// Mock both getContacts and discoverByAttributes
|
|
298
|
+
walletMock.discoverByAttributes = jest.fn().mockResolvedValue({ certificates: [] })
|
|
299
|
+
identityClient.getContacts = jest.fn().mockResolvedValue([])
|
|
300
|
+
})
|
|
301
|
+
|
|
302
|
+
it('should return parsed identities from discovered certificates only', async () => {
|
|
260
303
|
const dummyCertificate = {
|
|
261
304
|
type: KNOWN_IDENTITY_TYPES.emailCert,
|
|
262
|
-
subject: '
|
|
305
|
+
subject: 'alice-identity-key',
|
|
263
306
|
decryptedFields: {
|
|
264
|
-
|
|
265
|
-
|
|
307
|
+
identityKey: 'alice-identity-key',
|
|
308
|
+
email: 'alice@example.com'
|
|
266
309
|
},
|
|
267
310
|
certifierInfo: {
|
|
268
|
-
name: '
|
|
269
|
-
iconUrl: '
|
|
311
|
+
name: 'Email Certifier',
|
|
312
|
+
iconUrl: 'certifier-icon.png',
|
|
313
|
+
publicKey: 'certifier-public-key',
|
|
314
|
+
website: 'https://certifier.example.com'
|
|
270
315
|
}
|
|
271
316
|
}
|
|
272
|
-
|
|
317
|
+
|
|
273
318
|
walletMock.discoverByAttributes = jest.fn().mockResolvedValue({ certificates: [dummyCertificate] })
|
|
274
319
|
|
|
275
320
|
const identities = await identityClient.resolveByAttributes({ attributes: { email: 'alice@example.com' } })
|
|
276
|
-
expect(walletMock.discoverByAttributes).toHaveBeenCalledWith({ attributes: { email: 'alice@example.com' } }, undefined)
|
|
277
321
|
expect(identities).toHaveLength(1)
|
|
278
|
-
expect(identities[0]).
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
322
|
+
expect(identities[0].name).toBe('alice@example.com')
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
it('should prioritize contacts over discovered identities for same identity key', async () => {
|
|
326
|
+
const contact = {
|
|
327
|
+
name: 'Alice Smith (Personal)',
|
|
328
|
+
identityKey: 'alice-identity-key',
|
|
329
|
+
avatarURL: 'alice-avatar.png',
|
|
330
|
+
abbreviatedKey: 'alice-i...',
|
|
331
|
+
badgeIconURL: '',
|
|
332
|
+
badgeLabel: '',
|
|
333
|
+
badgeClickURL: ''
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const discoveredCertificate = {
|
|
337
|
+
type: KNOWN_IDENTITY_TYPES.emailCert,
|
|
338
|
+
subject: 'alice-identity-key',
|
|
339
|
+
decryptedFields: {
|
|
340
|
+
email: 'alice@example.com'
|
|
341
|
+
},
|
|
342
|
+
certifierInfo: {
|
|
343
|
+
name: 'Email Certifier',
|
|
344
|
+
iconUrl: 'certifier-icon.png',
|
|
345
|
+
publicKey: 'certifier-public-key',
|
|
346
|
+
website: 'https://certifier.example.com'
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Mock the ContactsManager's getContacts method instead of the IdentityClient method
|
|
351
|
+
const mockContactsManager = identityClient['contactsManager']
|
|
352
|
+
mockContactsManager.getContacts = jest.fn().mockResolvedValue([contact])
|
|
353
|
+
walletMock.discoverByAttributes = jest.fn().mockResolvedValue({ certificates: [discoveredCertificate] })
|
|
354
|
+
|
|
355
|
+
const identities = await identityClient.resolveByAttributes({ attributes: { name: 'Alice' } })
|
|
356
|
+
|
|
357
|
+
expect(identities).toHaveLength(1)
|
|
358
|
+
expect(identities[0].name).toBe('Alice Smith (Personal)') // Contact should be returned, not discovered identity
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
it('should return empty array for empty search terms', async () => {
|
|
362
|
+
const contacts = [
|
|
363
|
+
{
|
|
364
|
+
name: 'Alice Smith',
|
|
365
|
+
identityKey: 'alice-key',
|
|
366
|
+
avatarURL: '', abbreviatedKey: 'alice-i...', badgeIconURL: '', badgeLabel: '', badgeClickURL: ''
|
|
367
|
+
}
|
|
368
|
+
]
|
|
369
|
+
|
|
370
|
+
const mockContactsManager = identityClient['contactsManager']
|
|
371
|
+
mockContactsManager.getContacts = jest.fn().mockResolvedValue(contacts)
|
|
372
|
+
|
|
373
|
+
const identities = await identityClient.resolveByAttributes({ attributes: { name: '', email: ' ' } })
|
|
374
|
+
|
|
375
|
+
expect(identities).toHaveLength(0)
|
|
376
|
+
})
|
|
377
|
+
|
|
378
|
+
it('should return only discovered identities when overrideWithContacts is false', async () => {
|
|
379
|
+
const contacts = [
|
|
380
|
+
{
|
|
381
|
+
name: 'Alice Smith (Personal)',
|
|
382
|
+
identityKey: 'alice-key',
|
|
383
|
+
avatarURL: '', abbreviatedKey: 'alice-i...', badgeIconURL: '', badgeLabel: '', badgeClickURL: ''
|
|
384
|
+
}
|
|
385
|
+
]
|
|
386
|
+
|
|
387
|
+
const discoveredCertificate = {
|
|
388
|
+
type: KNOWN_IDENTITY_TYPES.emailCert,
|
|
389
|
+
subject: 'alice-key', // Same key as contact but should not be filtered out
|
|
390
|
+
decryptedFields: {
|
|
391
|
+
email: 'alice@example.com'
|
|
392
|
+
},
|
|
393
|
+
certifierInfo: {
|
|
394
|
+
name: 'Email Certifier',
|
|
395
|
+
iconUrl: 'certifier-icon.png',
|
|
396
|
+
publicKey: 'certifier-public-key',
|
|
397
|
+
website: 'https://certifier.example.com'
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const mockContactsManager = identityClient['contactsManager']
|
|
402
|
+
mockContactsManager.getContacts = jest.fn().mockResolvedValue(contacts)
|
|
403
|
+
walletMock.discoverByAttributes = jest.fn().mockResolvedValue({ certificates: [discoveredCertificate] })
|
|
404
|
+
|
|
405
|
+
// With overrideWithContacts = false, should ignore contacts entirely
|
|
406
|
+
const identities = await identityClient.resolveByAttributes(
|
|
407
|
+
{ attributes: { name: 'Alice' } },
|
|
408
|
+
false
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
expect(identities).toHaveLength(1)
|
|
412
|
+
expect(identities[0].name).toBe('alice@example.com') // Should be discovered identity, not contact
|
|
413
|
+
expect(mockContactsManager.getContacts).not.toHaveBeenCalled() // Should not fetch contacts
|
|
287
414
|
})
|
|
288
415
|
})
|
|
289
416
|
|
|
@@ -434,14 +561,14 @@ describe('IdentityClient', () => {
|
|
|
434
561
|
customInstructions: JSON.stringify({ keyID: 'existingKeyID' })
|
|
435
562
|
}
|
|
436
563
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
564
|
+
; (walletMock.listOutputs as jest.Mock).mockResolvedValueOnce({
|
|
565
|
+
outputs: [existingOutput],
|
|
566
|
+
BEEF: [1, 2, 3]
|
|
567
|
+
})
|
|
441
568
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
569
|
+
; (walletMock.decrypt as jest.Mock).mockResolvedValue({
|
|
570
|
+
plaintext: new TextEncoder().encode(JSON.stringify(mockContact))
|
|
571
|
+
})
|
|
445
572
|
|
|
446
573
|
const updatedContact = { ...mockContact, name: 'Alice Updated' }
|
|
447
574
|
await identityClient.saveContact(updatedContact)
|
|
@@ -489,14 +616,14 @@ describe('IdentityClient', () => {
|
|
|
489
616
|
customInstructions: JSON.stringify({ keyID: 'mockKeyID' })
|
|
490
617
|
}
|
|
491
618
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
619
|
+
; (walletMock.listOutputs as jest.Mock).mockResolvedValue({
|
|
620
|
+
outputs: [mockOutput],
|
|
621
|
+
BEEF: [1, 2, 3]
|
|
622
|
+
})
|
|
496
623
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
624
|
+
; (walletMock.decrypt as jest.Mock).mockResolvedValue({
|
|
625
|
+
plaintext: new TextEncoder().encode(JSON.stringify(mockContact))
|
|
626
|
+
})
|
|
500
627
|
|
|
501
628
|
const result = await identityClient.getContacts()
|
|
502
629
|
|
|
@@ -523,11 +650,11 @@ describe('IdentityClient', () => {
|
|
|
523
650
|
})
|
|
524
651
|
await identityClient.saveContact(mockContact)
|
|
525
652
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
653
|
+
// Mock empty result for force refresh
|
|
654
|
+
; (walletMock.listOutputs as jest.Mock).mockResolvedValue({
|
|
655
|
+
outputs: [],
|
|
656
|
+
BEEF: []
|
|
657
|
+
})
|
|
531
658
|
|
|
532
659
|
const result = await identityClient.getContacts(undefined, true)
|
|
533
660
|
|
|
@@ -542,7 +669,7 @@ describe('IdentityClient', () => {
|
|
|
542
669
|
BEEF: []
|
|
543
670
|
})
|
|
544
671
|
await identityClient.saveContact(mockContact)
|
|
545
|
-
|
|
672
|
+
|
|
546
673
|
const otherContact = { ...mockContact, identityKey: 'different-key', name: 'Bob' }
|
|
547
674
|
await identityClient.saveContact(otherContact)
|
|
548
675
|
|
|
@@ -575,7 +702,7 @@ describe('IdentityClient', () => {
|
|
|
575
702
|
BEEF: []
|
|
576
703
|
})
|
|
577
704
|
await identityClient.saveContact(mockContact)
|
|
578
|
-
|
|
705
|
+
|
|
579
706
|
const otherContact = { ...mockContact, identityKey: 'other-key', name: 'Bob' }
|
|
580
707
|
await identityClient.saveContact(otherContact)
|
|
581
708
|
|
|
@@ -585,14 +712,14 @@ describe('IdentityClient', () => {
|
|
|
585
712
|
customInstructions: JSON.stringify({ keyID: 'mockKeyID' })
|
|
586
713
|
}
|
|
587
714
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
715
|
+
; (walletMock.listOutputs as jest.Mock).mockResolvedValue({
|
|
716
|
+
outputs: [mockOutput],
|
|
717
|
+
BEEF: [1, 2, 3]
|
|
718
|
+
})
|
|
592
719
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
720
|
+
; (walletMock.decrypt as jest.Mock).mockResolvedValue({
|
|
721
|
+
plaintext: new TextEncoder().encode(JSON.stringify(mockContact))
|
|
722
|
+
})
|
|
596
723
|
|
|
597
724
|
await identityClient.removeContact(mockContact.identityKey)
|
|
598
725
|
|