Skip to content

Commit efa0789

Browse files
committed
docs
1 parent 90736b3 commit efa0789

File tree

2 files changed

+80
-31
lines changed

2 files changed

+80
-31
lines changed

docs/reference/auth.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ export class MasterCertificate extends Certificate {
502502
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>>
503503
static async issueCertificateForSubject(certifierWallet: ProtoWallet, subject: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, string>, certificateType: string, getRevocationOutpoint = async (_serial: string): Promise<string> => {
504504
void _serial;
505-
return "Certificate revocation not tracked.";
505+
return "00".repeat(32);
506506
}, serialNumber?: string): Promise<MasterCertificate>
507507
static async decryptFields(subjectOrCertifierWallet: ProtoWallet, masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, fields: Record<CertificateFieldNameUnder50Bytes, Base64String>, counterparty: WalletCounterparty, privileged?: boolean, privilegedReason?: string): Promise<Record<CertificateFieldNameUnder50Bytes, string>>
508508
static async decryptField(subjectOrCertifierWallet: ProtoWallet, masterKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>, fieldName: Base64String, fieldValue: Base64String, counterparty: WalletCounterparty, privileged?: boolean, privilegedReason?: string): Promise<{
@@ -634,7 +634,7 @@ can also includes a revocation outpoint to manage potential revocation.
634634
```ts
635635
static async issueCertificateForSubject(certifierWallet: ProtoWallet, subject: WalletCounterparty, fields: Record<CertificateFieldNameUnder50Bytes, string>, certificateType: string, getRevocationOutpoint = async (_serial: string): Promise<string> => {
636636
void _serial;
637-
return "Certificate revocation not tracked.";
637+
return "00".repeat(32);
638638
}, serialNumber?: string): Promise<MasterCertificate>
639639
```
640640
See also: [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [MasterCertificate](./auth.md#class-mastercertificate), [ProtoWallet](./wallet.md#class-protowallet), [WalletCounterparty](./wallet.md#type-walletcounterparty)

docs/reference/primitives.md

Lines changed: 78 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4963,8 +4963,10 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
49634963
| [AES](#function-aes) |
49644964
| [AESGCM](#function-aesgcm) |
49654965
| [AESGCMDecrypt](#function-aesgcmdecrypt) |
4966+
| [assertValidHex](#function-assertvalidhex) |
49664967
| [base64ToArray](#function-base64toarray) |
49674968
| [ghash](#function-ghash) |
4969+
| [normalizeHex](#function-normalizehex) |
49684970
| [pbkdf2](#function-pbkdf2) |
49694971
| [red](#function-red) |
49704972
| [toArray](#function-toarray) |
@@ -5004,6 +5006,15 @@ export function AESGCMDecrypt(cipherText: number[], additionalAuthenticatedData:
50045006

50055007
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
50065008

5009+
---
5010+
### Function: assertValidHex
5011+
5012+
```ts
5013+
export function assertValidHex(msg: string): void
5014+
```
5015+
5016+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
5017+
50075018
---
50085019
### Function: base64ToArray
50095020

@@ -5022,6 +5033,15 @@ export function ghash(input: number[], hashSubKey: number[]): number[]
50225033

50235034
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
50245035

5036+
---
5037+
### Function: normalizeHex
5038+
5039+
```ts
5040+
export function normalizeHex(msg: string): string
5041+
```
5042+
5043+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
5044+
50255045
---
50265046
### Function: pbkdf2
50275047

@@ -6100,49 +6120,78 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
61006120
```ts
61016121
toUTF8 = (arr: number[]): string => {
61026122
let result = "";
6103-
let skip = 0;
6123+
const replacementChar = "\uFFFD";
61046124
for (let i = 0; i < arr.length; i++) {
6105-
const byte = arr[i];
6106-
if (skip > 0) {
6107-
skip--;
6108-
continue;
6109-
}
6110-
if (byte <= 127) {
6111-
result += String.fromCharCode(byte);
6125+
const byte1 = arr[i];
6126+
if (byte1 <= 127) {
6127+
result += String.fromCharCode(byte1);
61126128
continue;
61136129
}
6114-
if (byte >= 192 && byte <= 223) {
6115-
const avail = arr.length - (i + 1);
6116-
const byte2 = avail >= 1 ? arr[i + 1] : 0;
6117-
skip = Math.min(1, avail);
6118-
const codePoint = ((byte & 31) << 6) | (byte2 & 63);
6130+
const emitReplacement = (): void => {
6131+
result += replacementChar;
6132+
};
6133+
if (byte1 >= 192 && byte1 <= 223) {
6134+
if (i + 1 >= arr.length) {
6135+
emitReplacement();
6136+
continue;
6137+
}
6138+
const byte2 = arr[i + 1];
6139+
if ((byte2 & 192) !== 128) {
6140+
emitReplacement();
6141+
i += 1;
6142+
continue;
6143+
}
6144+
const codePoint = ((byte1 & 31) << 6) | (byte2 & 63);
61196145
result += String.fromCharCode(codePoint);
6146+
i += 1;
61206147
continue;
61216148
}
6122-
if (byte >= 224 && byte <= 239) {
6123-
const avail = arr.length - (i + 1);
6124-
const byte2 = avail >= 1 ? arr[i + 1] : 0;
6125-
const byte3 = avail >= 2 ? arr[i + 2] : 0;
6126-
skip = Math.min(2, avail);
6127-
const codePoint = ((byte & 15) << 12) | ((byte2 & 63) << 6) | (byte3 & 63);
6149+
if (byte1 >= 224 && byte1 <= 239) {
6150+
if (i + 2 >= arr.length) {
6151+
emitReplacement();
6152+
continue;
6153+
}
6154+
const byte2 = arr[i + 1];
6155+
const byte3 = arr[i + 2];
6156+
if ((byte2 & 192) !== 128 || (byte3 & 192) !== 128) {
6157+
emitReplacement();
6158+
i += 2;
6159+
continue;
6160+
}
6161+
const codePoint = ((byte1 & 15) << 12) |
6162+
((byte2 & 63) << 6) |
6163+
(byte3 & 63);
61286164
result += String.fromCharCode(codePoint);
6165+
i += 2;
61296166
continue;
61306167
}
6131-
if (byte >= 240 && byte <= 247) {
6132-
const avail = arr.length - (i + 1);
6133-
const byte2 = avail >= 1 ? arr[i + 1] : 0;
6134-
const byte3 = avail >= 2 ? arr[i + 2] : 0;
6135-
const byte4 = avail >= 3 ? arr[i + 3] : 0;
6136-
skip = Math.min(3, avail);
6137-
const codePoint = ((byte & 7) << 18) |
6168+
if (byte1 >= 240 && byte1 <= 247) {
6169+
if (i + 3 >= arr.length) {
6170+
emitReplacement();
6171+
continue;
6172+
}
6173+
const byte2 = arr[i + 1];
6174+
const byte3 = arr[i + 2];
6175+
const byte4 = arr[i + 3];
6176+
if ((byte2 & 192) !== 128 ||
6177+
(byte3 & 192) !== 128 ||
6178+
(byte4 & 192) !== 128) {
6179+
emitReplacement();
6180+
i += 3;
6181+
continue;
6182+
}
6183+
const codePoint = ((byte1 & 7) << 18) |
61386184
((byte2 & 63) << 12) |
61396185
((byte3 & 63) << 6) |
61406186
(byte4 & 63);
6141-
const surrogate1 = 55296 + ((codePoint - 65536) >> 10);
6142-
const surrogate2 = 56320 + ((codePoint - 65536) & 1023);
6143-
result += String.fromCharCode(surrogate1, surrogate2);
6187+
const offset = codePoint - 65536;
6188+
const highSurrogate = 55296 + (offset >> 10);
6189+
const lowSurrogate = 56320 + (offset & 1023);
6190+
result += String.fromCharCode(highSurrogate, lowSurrogate);
6191+
i += 3;
61446192
continue;
61456193
}
6194+
emitReplacement();
61466195
}
61476196
return result;
61486197
}

0 commit comments

Comments
 (0)