@bsv/sdk 1.3.32 → 1.3.33
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/auth/certificates/MasterCertificate.js +25 -15
- package/dist/cjs/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js +6 -2
- package/dist/cjs/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/auth/certificates/MasterCertificate.js +25 -15
- package/dist/esm/src/auth/certificates/MasterCertificate.js.map +1 -1
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js +6 -2
- package/dist/esm/src/auth/certificates/VerifiableCertificate.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts +10 -4
- package/dist/types/src/auth/certificates/MasterCertificate.d.ts.map +1 -1
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts +3 -1
- package/dist/types/src/auth/certificates/VerifiableCertificate.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/auth.md +25 -9
- package/package.json +1 -1
- package/src/auth/certificates/MasterCertificate.ts +37 -13
- package/src/auth/certificates/VerifiableCertificate.ts +8 -2
package/docs/auth.md
CHANGED
|
@@ -463,14 +463,14 @@ export class MasterCertificate extends Certificate {
|
|
|
463
463
|
declare signature?: HexString;
|
|
464
464
|
masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>;
|
|
465
465
|
constructor(type: Base64String, serialNumber: Base64String, subject: PubKeyHex, certifier: PubKeyHex, revocationOutpoint: OutpointString, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, signature?: HexString)
|
|
466
|
-
static async createCertificateFields(creatorWallet: ProtoWallet, certifierOrSubject: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, string
|
|
467
|
-
static async createKeyringForVerifier(subjectWallet: ProtoWallet, certifier: WalletCounterparty, verifier: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, fieldsToReveal: string[], masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, serialNumber: Base64String): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
466
|
+
static async createCertificateFields(creatorWallet: ProtoWallet, certifierOrSubject: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, string>, privileged?: boolean, privilegedReason?: string): Promise<CreateCertificateFieldsResult>
|
|
467
|
+
static async createKeyringForVerifier(subjectWallet: ProtoWallet, certifier: WalletCounterparty, verifier: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, fieldsToReveal: string[], masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, serialNumber: Base64String, privileged?: boolean, privilegedReason?: string): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
468
468
|
static async issueCertificateForSubject(certifierWallet: ProtoWallet, subject: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, string>, certificateType: string, getRevocationOutpoint = async (_serial: string): Promise<string> => {
|
|
469
469
|
void _serial;
|
|
470
470
|
return "Certificate revocation not tracked.";
|
|
471
471
|
}, serialNumber?: string): Promise<MasterCertificate>
|
|
472
|
-
static async decryptFields(subjectOrCertifierWallet: ProtoWallet, masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, counterparty: WalletCounterparty): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
473
|
-
static async decryptField(subjectOrCertifierWallet: ProtoWallet, masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, fieldName: Base64String, fieldValue: Base64String, counterparty: WalletCounterparty): Promise<{
|
|
472
|
+
static async decryptFields(subjectOrCertifierWallet: ProtoWallet, masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, counterparty: WalletCounterparty, privileged?: boolean, privilegedReason?: string): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
473
|
+
static async decryptField(subjectOrCertifierWallet: ProtoWallet, masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, fieldName: Base64String, fieldValue: Base64String, counterparty: WalletCounterparty, privileged?: boolean, privilegedReason?: string): Promise<{
|
|
474
474
|
fieldRevelationKey: number[];
|
|
475
475
|
decryptedFieldValue: string;
|
|
476
476
|
}>
|
|
@@ -486,7 +486,7 @@ This method returns a master keyring tied to a specific certifier or subject who
|
|
|
486
486
|
and sign off on the fields, along with the encrypted certificate fields.
|
|
487
487
|
|
|
488
488
|
```ts
|
|
489
|
-
static async createCertificateFields(creatorWallet: ProtoWallet, certifierOrSubject: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, string
|
|
489
|
+
static async createCertificateFields(creatorWallet: ProtoWallet, certifierOrSubject: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, string>, privileged?: boolean, privilegedReason?: string): Promise<CreateCertificateFieldsResult>
|
|
490
490
|
```
|
|
491
491
|
See also: [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [ProtoWallet](./wallet.md#class-protowallet), [WalletCounterparty](./wallet.md#type-walletcounterparty)
|
|
492
492
|
|
|
@@ -506,6 +506,10 @@ Argument Details
|
|
|
506
506
|
+ The certifier or subject who will validate the certificate fields.
|
|
507
507
|
+ **fields**
|
|
508
508
|
+ A record of certificate field names (under 50 bytes) mapped to their values.
|
|
509
|
+
+ **privileged**
|
|
510
|
+
+ Whether this is a privileged request.
|
|
511
|
+
+ **privilegedReason**
|
|
512
|
+
+ Reason provided for privileged access, required if this is a privileged operation. *
|
|
509
513
|
|
|
510
514
|
#### Method createKeyringForVerifier
|
|
511
515
|
|
|
@@ -515,7 +519,7 @@ for the verifier's identity key. The result is a keyring containing the keys nec
|
|
|
515
519
|
for the verifier to access the designated fields.
|
|
516
520
|
|
|
517
521
|
```ts
|
|
518
|
-
static async createKeyringForVerifier(subjectWallet: ProtoWallet, certifier: WalletCounterparty, verifier: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, fieldsToReveal: string[], masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, serialNumber: Base64String): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
522
|
+
static async createKeyringForVerifier(subjectWallet: ProtoWallet, certifier: WalletCounterparty, verifier: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, fieldsToReveal: string[], masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, serialNumber: Base64String, privileged?: boolean, privilegedReason?: string): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
519
523
|
```
|
|
520
524
|
See also: [Base64String](./wallet.md#type-base64string), [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [ProtoWallet](./wallet.md#class-protowallet), [WalletCounterparty](./wallet.md#type-walletcounterparty)
|
|
521
525
|
|
|
@@ -533,6 +537,10 @@ Argument Details
|
|
|
533
537
|
+ An array of field names to be revealed to the verifier. Must be a subset of the certificate's fields.
|
|
534
538
|
+ **originator**
|
|
535
539
|
+ Optional originator identifier, used if additional context is needed for decryption and encryption operations.
|
|
540
|
+
+ **privileged**
|
|
541
|
+
+ Whether this is a privileged request.
|
|
542
|
+
+ **privilegedReason**
|
|
543
|
+
+ Reason provided for privileged access, required if this is a privileged operation. *
|
|
536
544
|
|
|
537
545
|
Throws
|
|
538
546
|
|
|
@@ -552,7 +560,7 @@ The counterparty used for decryption depends on how the certificate fields were
|
|
|
552
560
|
- Otherwise, the counterparty should always be the other party involved in the certificate issuance process (the subject or certifier).
|
|
553
561
|
|
|
554
562
|
```ts
|
|
555
|
-
static async decryptFields(subjectOrCertifierWallet: ProtoWallet, masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, counterparty: WalletCounterparty): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
563
|
+
static async decryptFields(subjectOrCertifierWallet: ProtoWallet, masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, counterparty: WalletCounterparty, privileged?: boolean, privilegedReason?: string): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
556
564
|
```
|
|
557
565
|
See also: [Base64String](./wallet.md#type-base64string), [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [ProtoWallet](./wallet.md#class-protowallet), [WalletCounterparty](./wallet.md#type-walletcounterparty)
|
|
558
566
|
|
|
@@ -570,6 +578,10 @@ Argument Details
|
|
|
570
578
|
+ A record of encrypted field names and their values.
|
|
571
579
|
+ **counterparty**
|
|
572
580
|
+ The counterparty responsible for creating or signing the certificate. For self-signed certificates, use 'self'.
|
|
581
|
+
+ **privileged**
|
|
582
|
+
+ Whether this is a privileged request.
|
|
583
|
+
+ **privilegedReason**
|
|
584
|
+
+ Reason provided for privileged access, required if this is a privileged operation.
|
|
573
585
|
|
|
574
586
|
Throws
|
|
575
587
|
|
|
@@ -1094,7 +1106,7 @@ export class VerifiableCertificate extends Certificate {
|
|
|
1094
1106
|
keyring: Record<CertificateFieldNameUnder50Bytes, string>;
|
|
1095
1107
|
decryptedFields?: Record<CertificateFieldNameUnder50Bytes, Base64String>;
|
|
1096
1108
|
constructor(type: Base64String, serialNumber: Base64String, subject: PubKeyHex, certifier: PubKeyHex, revocationOutpoint: OutpointString, fields: Record<CertificateFieldNameUnder50Bytes, string>, keyring: Record<CertificateFieldNameUnder50Bytes, string>, signature?: HexString, decryptedFields?: Record<CertificateFieldNameUnder50Bytes, Base64String>)
|
|
1097
|
-
async decryptFields(verifierWallet: ProtoWallet): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
1109
|
+
async decryptFields(verifierWallet: ProtoWallet, privileged?: boolean, privilegedReason?: string): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
1098
1110
|
}
|
|
1099
1111
|
```
|
|
1100
1112
|
|
|
@@ -1105,7 +1117,7 @@ See also: [Base64String](./wallet.md#type-base64string), [Certificate](./auth.md
|
|
|
1105
1117
|
Decrypts selectively revealed certificate fields using the provided keyring and verifier wallet
|
|
1106
1118
|
|
|
1107
1119
|
```ts
|
|
1108
|
-
async decryptFields(verifierWallet: ProtoWallet): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
1120
|
+
async decryptFields(verifierWallet: ProtoWallet, privileged?: boolean, privilegedReason?: string): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
|
|
1109
1121
|
```
|
|
1110
1122
|
See also: [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [ProtoWallet](./wallet.md#class-protowallet)
|
|
1111
1123
|
|
|
@@ -1117,6 +1129,10 @@ Argument Details
|
|
|
1117
1129
|
|
|
1118
1130
|
+ **verifierWallet**
|
|
1119
1131
|
+ The wallet instance of the certificate's verifier, used to decrypt field keys.
|
|
1132
|
+
+ **privileged**
|
|
1133
|
+
+ Whether this is a privileged request.
|
|
1134
|
+
+ **privilegedReason**
|
|
1135
|
+
+ Reason provided for privileged access, required if this is a privileged operation.
|
|
1120
1136
|
|
|
1121
1137
|
Throws
|
|
1122
1138
|
|
package/package.json
CHANGED
|
@@ -76,6 +76,8 @@ export class MasterCertificate extends Certificate {
|
|
|
76
76
|
* @param {ProtoWallet} creatorWallet - The wallet of the creator responsible for encrypting the fields.
|
|
77
77
|
* @param {WalletCounterparty} certifierOrSubject - The certifier or subject who will validate the certificate fields.
|
|
78
78
|
* @param {Record<CertificateFieldNameUnder50Bytes, string>} fields - A record of certificate field names (under 50 bytes) mapped to their values.
|
|
79
|
+
* @param {BooleanDefaultFalse} [privileged] - Whether this is a privileged request.
|
|
80
|
+
* @param {DescriptionString5to50Bytes} [privilegedReason] - Reason provided for privileged access, required if this is a privileged operation. *
|
|
79
81
|
* @returns {Promise<CreateCertificateFieldsResult>} A promise resolving to an object containing:
|
|
80
82
|
* - `certificateFields` {Record<CertificateFieldNameUnder50Bytes, Base64String>}:
|
|
81
83
|
* The encrypted certificate fields.
|
|
@@ -85,7 +87,9 @@ export class MasterCertificate extends Certificate {
|
|
|
85
87
|
static async createCertificateFields(
|
|
86
88
|
creatorWallet: ProtoWallet,
|
|
87
89
|
certifierOrSubject: WalletCounterparty,
|
|
88
|
-
fields: Record<CertificateFieldNameUnder50Bytes, string
|
|
90
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>,
|
|
91
|
+
privileged?: boolean,
|
|
92
|
+
privilegedReason?: string
|
|
89
93
|
): Promise<CreateCertificateFieldsResult> {
|
|
90
94
|
const certificateFields: Record<
|
|
91
95
|
CertificateFieldNameUnder50Bytes,
|
|
@@ -109,7 +113,9 @@ export class MasterCertificate extends Certificate {
|
|
|
109
113
|
{
|
|
110
114
|
plaintext: fieldSymmetricKey.toArray(),
|
|
111
115
|
...Certificate.getCertificateFieldEncryptionDetails(fieldName), // Only fieldName used on MasterCertificate
|
|
112
|
-
counterparty: certifierOrSubject
|
|
116
|
+
counterparty: certifierOrSubject,
|
|
117
|
+
privileged,
|
|
118
|
+
privilegedReason
|
|
113
119
|
}
|
|
114
120
|
)
|
|
115
121
|
masterKeyring[fieldName] = Utils.toBase64(encryptedFieldRevelationKey)
|
|
@@ -132,6 +138,8 @@ export class MasterCertificate extends Certificate {
|
|
|
132
138
|
* @param {string[]} fieldsToReveal - An array of field names to be revealed to the verifier. Must be a subset of the certificate's fields.
|
|
133
139
|
* @param {string} [originator] - Optional originator identifier, used if additional context is needed for decryption and encryption operations.
|
|
134
140
|
* @returns {Promise<Record<CertificateFieldNameUnder50Bytes, string>>} - A keyring mapping field names to encrypted field revelation keys, allowing the verifier to decrypt specified fields.
|
|
141
|
+
* @param {BooleanDefaultFalse} [privileged] - Whether this is a privileged request.
|
|
142
|
+
* @param {DescriptionString5to50Bytes} [privilegedReason] - Reason provided for privileged access, required if this is a privileged operation. *
|
|
135
143
|
* @throws {Error} Throws an error if:
|
|
136
144
|
* - fieldsToReveal is not an array of strings.
|
|
137
145
|
* - A field in `fieldsToReveal` does not exist in the certificate.
|
|
@@ -144,7 +152,9 @@ export class MasterCertificate extends Certificate {
|
|
|
144
152
|
fields: Record<CertificateFieldNameUnder50Bytes, Base64String>,
|
|
145
153
|
fieldsToReveal: string[],
|
|
146
154
|
masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>,
|
|
147
|
-
serialNumber: Base64String
|
|
155
|
+
serialNumber: Base64String,
|
|
156
|
+
privileged?: boolean,
|
|
157
|
+
privilegedReason?: string
|
|
148
158
|
): Promise<Record<CertificateFieldNameUnder50Bytes, string>> {
|
|
149
159
|
if (!Array.isArray(fieldsToReveal)) {
|
|
150
160
|
throw new Error('fieldsToReveal must be an array of strings')
|
|
@@ -165,7 +175,9 @@ export class MasterCertificate extends Certificate {
|
|
|
165
175
|
masterKeyring,
|
|
166
176
|
fieldName,
|
|
167
177
|
fields[fieldName],
|
|
168
|
-
certifier
|
|
178
|
+
certifier,
|
|
179
|
+
privileged,
|
|
180
|
+
privilegedReason
|
|
169
181
|
)
|
|
170
182
|
).fieldRevelationKey
|
|
171
183
|
|
|
@@ -178,7 +190,9 @@ export class MasterCertificate extends Certificate {
|
|
|
178
190
|
fieldName,
|
|
179
191
|
serialNumber
|
|
180
192
|
),
|
|
181
|
-
counterparty: verifier
|
|
193
|
+
counterparty: verifier,
|
|
194
|
+
privileged,
|
|
195
|
+
privilegedReason
|
|
182
196
|
}
|
|
183
197
|
)
|
|
184
198
|
|
|
@@ -220,22 +234,22 @@ export class MasterCertificate extends Certificate {
|
|
|
220
234
|
void _serial // Explicitly acknowledge unused parameter
|
|
221
235
|
return 'Certificate revocation not tracked.'
|
|
222
236
|
},
|
|
223
|
-
serialNumber?: string
|
|
237
|
+
serialNumber?: string
|
|
224
238
|
): Promise<MasterCertificate> {
|
|
225
239
|
// 1. Generate a random serialNumber if not provided
|
|
226
|
-
const finalSerialNumber = serialNumber ?? Utils.toBase64(Random(32))
|
|
240
|
+
const finalSerialNumber = serialNumber ?? Utils.toBase64(Random(32))
|
|
227
241
|
|
|
228
242
|
// 2. Create encrypted certificate fields and associated master keyring
|
|
229
243
|
const { certificateFields, masterKeyring } =
|
|
230
244
|
await this.createCertificateFields(certifierWallet, subject, fields)
|
|
231
245
|
|
|
232
246
|
// 3. Obtain a revocation outpoint
|
|
233
|
-
const revocationOutpoint = await getRevocationOutpoint(finalSerialNumber)
|
|
247
|
+
const revocationOutpoint = await getRevocationOutpoint(finalSerialNumber)
|
|
234
248
|
|
|
235
249
|
// 4. Create new MasterCertificate instance
|
|
236
250
|
const certificate = new MasterCertificate(
|
|
237
251
|
certificateType,
|
|
238
|
-
finalSerialNumber,
|
|
252
|
+
finalSerialNumber,
|
|
239
253
|
subject,
|
|
240
254
|
(await certifierWallet.getPublicKey({ identityKey: true })).publicKey,
|
|
241
255
|
revocationOutpoint,
|
|
@@ -261,6 +275,8 @@ export class MasterCertificate extends Certificate {
|
|
|
261
275
|
* @param {Record<CertificateFieldNameUnder50Bytes, Base64String>} masterKeyring - A record containing encrypted keys for each field.
|
|
262
276
|
* @param {Record<CertificateFieldNameUnder50Bytes, Base64String>} fields - A record of encrypted field names and their values.
|
|
263
277
|
* @param {WalletCounterparty} counterparty - The counterparty responsible for creating or signing the certificate. For self-signed certificates, use 'self'.
|
|
278
|
+
* @param {BooleanDefaultFalse} [privileged] - Whether this is a privileged request.
|
|
279
|
+
* @param {DescriptionString5to50Bytes} [privilegedReason] - Reason provided for privileged access, required if this is a privileged operation.
|
|
264
280
|
* @returns {Promise<Record<CertificateFieldNameUnder50Bytes, string>>} A promise resolving to a record of field names and their decrypted values in plaintext.
|
|
265
281
|
*
|
|
266
282
|
* @throws {Error} Throws an error if the `masterKeyring` is invalid or if decryption fails for any field.
|
|
@@ -269,7 +285,9 @@ export class MasterCertificate extends Certificate {
|
|
|
269
285
|
subjectOrCertifierWallet: ProtoWallet,
|
|
270
286
|
masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>,
|
|
271
287
|
fields: Record<CertificateFieldNameUnder50Bytes, Base64String>,
|
|
272
|
-
counterparty: WalletCounterparty
|
|
288
|
+
counterparty: WalletCounterparty,
|
|
289
|
+
privileged?: boolean,
|
|
290
|
+
privilegedReason?: string
|
|
273
291
|
): Promise<Record<CertificateFieldNameUnder50Bytes, string>> {
|
|
274
292
|
if (masterKeyring == null || Object.keys(masterKeyring).length === 0) {
|
|
275
293
|
throw new Error('A MasterCertificate must have a valid masterKeyring!')
|
|
@@ -285,7 +303,9 @@ export class MasterCertificate extends Certificate {
|
|
|
285
303
|
masterKeyring,
|
|
286
304
|
fieldName,
|
|
287
305
|
fields[fieldName],
|
|
288
|
-
counterparty
|
|
306
|
+
counterparty,
|
|
307
|
+
privileged,
|
|
308
|
+
privilegedReason
|
|
289
309
|
)
|
|
290
310
|
).decryptedFieldValue
|
|
291
311
|
}
|
|
@@ -300,7 +320,9 @@ export class MasterCertificate extends Certificate {
|
|
|
300
320
|
masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>,
|
|
301
321
|
fieldName: Base64String,
|
|
302
322
|
fieldValue: Base64String,
|
|
303
|
-
counterparty: WalletCounterparty
|
|
323
|
+
counterparty: WalletCounterparty,
|
|
324
|
+
privileged?: boolean,
|
|
325
|
+
privilegedReason?: string
|
|
304
326
|
): Promise<{ fieldRevelationKey: number[], decryptedFieldValue: string }> {
|
|
305
327
|
if (masterKeyring == null || Object.keys(masterKeyring).length === 0) {
|
|
306
328
|
throw new Error('A MasterCertificate must have a valid masterKeyring!')
|
|
@@ -311,7 +333,9 @@ export class MasterCertificate extends Certificate {
|
|
|
311
333
|
{
|
|
312
334
|
ciphertext: Utils.toArray(masterKeyring[fieldName], 'base64'),
|
|
313
335
|
...Certificate.getCertificateFieldEncryptionDetails(fieldName), // Only fieldName used on MasterCertificate
|
|
314
|
-
counterparty
|
|
336
|
+
counterparty,
|
|
337
|
+
privileged,
|
|
338
|
+
privilegedReason
|
|
315
339
|
}
|
|
316
340
|
)
|
|
317
341
|
|
|
@@ -54,10 +54,14 @@ export class VerifiableCertificate extends Certificate {
|
|
|
54
54
|
* Decrypts selectively revealed certificate fields using the provided keyring and verifier wallet
|
|
55
55
|
* @param {ProtoWallet} verifierWallet - The wallet instance of the certificate's verifier, used to decrypt field keys.
|
|
56
56
|
* @returns {Promise<Record<CertificateFieldNameUnder50Bytes, string>>} - A promise that resolves to an object where each key is a field name and each value is the decrypted field value as a string.
|
|
57
|
+
* @param {BooleanDefaultFalse} [privileged] - Whether this is a privileged request.
|
|
58
|
+
* @param {DescriptionString5to50Bytes} [privilegedReason] - Reason provided for privileged access, required if this is a privileged operation.
|
|
57
59
|
* @throws {Error} Throws an error if any of the decryption operations fail, with a message indicating the failure context.
|
|
58
60
|
*/
|
|
59
61
|
async decryptFields(
|
|
60
|
-
verifierWallet: ProtoWallet
|
|
62
|
+
verifierWallet: ProtoWallet,
|
|
63
|
+
privileged?: boolean,
|
|
64
|
+
privilegedReason?: string
|
|
61
65
|
): Promise<Record<CertificateFieldNameUnder50Bytes, string>> {
|
|
62
66
|
if (this.keyring == null || Object.keys(this.keyring).length === 0) { // ✅ Explicitly check null and empty object
|
|
63
67
|
throw new Error(
|
|
@@ -75,7 +79,9 @@ export class VerifiableCertificate extends Certificate {
|
|
|
75
79
|
fieldName,
|
|
76
80
|
this.serialNumber
|
|
77
81
|
),
|
|
78
|
-
counterparty: this.subject
|
|
82
|
+
counterparty: this.subject,
|
|
83
|
+
privileged,
|
|
84
|
+
privilegedReason
|
|
79
85
|
})
|
|
80
86
|
|
|
81
87
|
const fieldValue = new SymmetricKey(fieldRevelationKey).decrypt(
|