Skip to content

Commit d37d9ef

Browse files
authored
Merge branch 'master' into fix/mobile-random-values
2 parents 5631b50 + 8f1dfd3 commit d37d9ef

File tree

4 files changed

+127
-2
lines changed

4 files changed

+127
-2
lines changed

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ All notable changes to this project will be documented in this file. The format
55
## Table of Contents
66

77
- [Unreleased](#unreleased)
8-
- [1.9.11 - 2025-11-16](#1910---2025-11-16)
8+
- [1.9.11 - 2025-11-24](#1911---2025-11-24)
9+
- [1.9.10 - 2025-11-17](#1910---2025-11-17)
910
- [1.9.9 - 2025-11-15](#199---2025-11-15)
1011
- [1.9.8 - 2025-11-15](#198---2025-11-15)
1112
- [1.9.7 - 2025-11-14](#197---2025-11-14)
@@ -182,12 +183,22 @@ All notable changes to this project will be documented in this file. The format
182183
### Security
183184

184185
---
185-
### [1.9.11] - 2025-11-16
186+
### [1.9.11] - 2025-11-24
187+
188+
### Removed
186189

187190
- Removed dependency on react-native-get-random-values polyfill from Random.ts
188191

189192

190193
---
194+
### [1.9.10] - 2025-11-17
195+
196+
### Added
197+
198+
- Added `Certificate.fromObject` method for creating Certificate instances from plain objects.
199+
200+
---
201+
191202
### [1.9.9] - 2025-11-15
192203

193204
### Fixed

docs/reference/auth.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ export default class Certificate {
218218
protocolID: WalletProtocol;
219219
keyID: string;
220220
}
221+
static fromObject(obj: {
222+
type: Base64String;
223+
serialNumber: Base64String;
224+
subject: PubKeyHex;
225+
certifier: PubKeyHex;
226+
revocationOutpoint: OutpointString;
227+
fields: Record<CertificateFieldNameUnder50Bytes, Base64String>;
228+
signature?: HexString;
229+
}): Certificate
221230
}
222231
```
223232

@@ -330,6 +339,32 @@ Argument Details
330339
+ **bin**
331340
+ The binary data representing the certificate.
332341

342+
#### Method fromObject
343+
344+
Creates a Certificate instance from a plain object representation.
345+
346+
```ts
347+
static fromObject(obj: {
348+
type: Base64String;
349+
serialNumber: Base64String;
350+
subject: PubKeyHex;
351+
certifier: PubKeyHex;
352+
revocationOutpoint: OutpointString;
353+
fields: Record<CertificateFieldNameUnder50Bytes, Base64String>;
354+
signature?: HexString;
355+
}): Certificate
356+
```
357+
See also: [Base64String](./wallet.md#type-base64string), [Certificate](./auth.md#class-certificate), [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [HexString](./wallet.md#type-hexstring), [OutpointString](./wallet.md#type-outpointstring), [PubKeyHex](./wallet.md#type-pubkeyhex)
358+
359+
Returns
360+
361+
A new Certificate instance.
362+
363+
Argument Details
364+
365+
+ **obj**
366+
+ The object containing certificate data.
367+
333368
#### Method getCertificateFieldEncryptionDetails
334369

335370
Helper function which retrieves the protocol ID and key ID for certificate field encryption.

src/auth/certificates/Certificate.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,32 @@ export default class Certificate {
280280
keyID: serialNumber ? `${serialNumber} ${fieldName}` : fieldName
281281
}
282282
}
283+
284+
/**
285+
* Creates a Certificate instance from a plain object representation.
286+
*
287+
* @param obj - The object containing certificate data.
288+
* @returns A new Certificate instance.
289+
*/
290+
static fromObject(obj: {
291+
type: Base64String,
292+
serialNumber: Base64String,
293+
subject: PubKeyHex,
294+
certifier: PubKeyHex,
295+
revocationOutpoint: OutpointString,
296+
fields: Record<CertificateFieldNameUnder50Bytes, Base64String>,
297+
signature?: HexString
298+
}): Certificate {
299+
const cert = new Certificate(
300+
obj.type,
301+
obj.serialNumber,
302+
obj.subject,
303+
obj.certifier,
304+
obj.revocationOutpoint,
305+
obj.fields,
306+
obj.signature
307+
);
308+
309+
return cert;
310+
}
283311
}

src/auth/certificates/__tests/Certificate.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,55 @@ describe('Certificate', () => {
332332
expect(certificateWithMismatch.certifier).toBe(certifierPubKey)
333333
expect(await certificateWithMismatch.verify()).toBe(true)
334334
})
335+
336+
it('should create a Certificate from an object using fromObject()', () => {
337+
const certificateObject = {
338+
type: 'Q29tbW9uU291cmNlIGlkZW50aXR5',
339+
subject: '028e2e075e1e57ba4c62c90125468109f9b4e2a7741da3dd76ccd0c73b2a8a37ad',
340+
serialNumber: 'UegX3uufsqHsbEKeBSxUd9AziLSyru86TnwfhPoZJYE=',
341+
certifier: '03c644fe2fd97673a5d86555a58587e7936390be6582ece262bc387014bcff6fe4',
342+
revocationOutpoint: '0245242bd144a85053b4c1e4a0ed5467c79a4d172680ca77a970ebabd682d564.0',
343+
signature: '304402202c86ef816c469fe657289ddea12d2c444f006ef5ab5851f00107c7724eb67ea602202786244c077567c8f3ec5da78bd61ce0c35bf1eeac0488e026c03b21c403b0fd',
344+
fields: {
345+
displayName: 'eqsSpUgTKk891y1EkyCPPg+C4YoVZJvB0EQ4iore7VofkM5TB9Ctj7x2PgBaWI0A9tfATDO9',
346+
email: 'n6HVUvyHkIDMvB4ERxVGxmX6lgRBM+e7kbbC5DiRCKe5a60BJeXr05g4POq6OHYO9Wl/b1Xxe+JKsejl',
347+
phoneNumber: '5yWyN9kOGaZs5G6yvXUWnWj4rm7kDAug4YIsn4BQLKGYRzDx8s1dytb43ega6BnSp0gUTnskcjiM8ekqul2a',
348+
lat: 'lc3u6SFKQ5Mpxp5vc+6s4aXe7lOyQQLfN+CbOu4XlBYsj7Jlc78gt4sGCwDSxbzvA41eElCjlc2Our5bpLcsg1I6',
349+
lng: 'FmY3iM/2/LDfYNEeXpcj7Epn933tRHz50WoBkBrqYv6jmZ6dXE6RRYId9TcaxIvB0D7Y14aD5vjSV6Bx48hdic5g'
350+
}
351+
}
352+
353+
const certificate = Certificate.fromObject(certificateObject)
354+
355+
expect(certificate.type).toEqual(certificateObject.type)
356+
expect(certificate.serialNumber).toEqual(certificateObject.serialNumber)
357+
expect(certificate.subject).toEqual(certificateObject.subject)
358+
expect(certificate.certifier).toEqual(certificateObject.certifier)
359+
expect(certificate.revocationOutpoint).toEqual(certificateObject.revocationOutpoint)
360+
expect(certificate.signature).toEqual(certificateObject.signature)
361+
expect(certificate.fields).toEqual(certificateObject.fields)
362+
})
363+
364+
it('should create a Certificate from an object without signature using fromObject()', () => {
365+
const certificateObject = {
366+
type: 'Q29tbW9uU291cmNlIGlkZW50aXR5',
367+
subject: '028e2e075e1e57ba4c62c90125468109f9b4e2a7741da3dd76ccd0c73b2a8a37ad',
368+
serialNumber: 'UegX3uufsqHsbEKeBSxUd9AziLSyru86TnwfhPoZJYE=',
369+
certifier: '03c644fe2fd97673a5d86555a58587e7936390be6582ece262bc387014bcff6fe4',
370+
revocationOutpoint: '0245242bd144a85053b4c1e4a0ed5467c79a4d172680ca77a970ebabd682d564.0',
371+
fields: {
372+
displayName: 'eqsSpUgTKk891y1EkyCPPg+C4YoVZJvB0EQ4iore7VofkM5TB9Ctj7x2PgBaWI0A9tfATDO9'
373+
}
374+
}
375+
376+
const certificate = Certificate.fromObject(certificateObject)
377+
378+
expect(certificate.type).toEqual(certificateObject.type)
379+
expect(certificate.serialNumber).toEqual(certificateObject.serialNumber)
380+
expect(certificate.subject).toEqual(certificateObject.subject)
381+
expect(certificate.certifier).toEqual(certificateObject.certifier)
382+
expect(certificate.revocationOutpoint).toEqual(certificateObject.revocationOutpoint)
383+
expect(certificate.signature).toBeUndefined()
384+
expect(certificate.fields).toEqual(certificateObject.fields)
385+
})
335386
})

0 commit comments

Comments
 (0)