signify-ts 0.2.1 → 0.3.0-rc2
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/README.md +104 -34
- package/dist/exports.d.ts +40 -40
- package/dist/exports.js +40 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -8
- package/dist/keri/app/aiding.d.ts +34 -14
- package/{src/keri/app/aiding.ts → dist/keri/app/aiding.js} +104 -235
- package/dist/keri/app/clienting.d.ts +57 -22
- package/{src/keri/app/clienting.ts → dist/keri/app/clienting.js} +145 -234
- package/dist/keri/app/contacting.d.ts +33 -21
- package/{src/keri/app/contacting.ts → dist/keri/app/contacting.js} +25 -62
- package/dist/keri/app/controller.d.ts +49 -6
- package/{src/keri/app/controller.ts → dist/keri/app/controller.js} +79 -185
- package/dist/keri/app/coring.d.ts +30 -8
- package/{src/keri/app/coring.ts → dist/keri/app/coring.js} +62 -51
- package/dist/keri/app/credentialing.d.ts +183 -65
- package/dist/keri/app/credentialing.js +540 -0
- package/dist/keri/app/delegating.d.ts +18 -0
- package/dist/keri/app/delegating.js +24 -0
- package/dist/keri/app/escrowing.d.ts +1 -1
- package/{src/keri/app/escrowing.ts → dist/keri/app/escrowing.js} +2 -8
- package/dist/keri/app/exchanging.d.ts +7 -6
- package/{src/keri/app/exchanging.ts → dist/keri/app/exchanging.js} +33 -110
- package/dist/keri/app/grouping.d.ts +2 -2
- package/{src/keri/app/grouping.ts → dist/keri/app/grouping.js} +6 -25
- package/dist/keri/app/habery.d.ts +2 -2
- package/dist/keri/app/habery.js +117 -0
- package/dist/keri/app/notifying.d.ts +2 -2
- package/{src/keri/app/notifying.ts → dist/keri/app/notifying.js} +7 -17
- package/dist/keri/core/authing.d.ts +2 -2
- package/{src/keri/core/authing.ts → dist/keri/core/authing.js} +26 -42
- package/dist/keri/core/base64.d.ts +2 -0
- package/dist/keri/core/base64.js +16 -0
- package/dist/keri/core/bexter.d.ts +1 -1
- package/{src/keri/core/bexter.ts → dist/keri/core/bexter.js} +18 -32
- package/dist/keri/core/cigar.d.ts +2 -2
- package/dist/keri/core/cigar.js +13 -0
- package/dist/keri/core/cipher.d.ts +1 -1
- package/{src/keri/core/cipher.ts → dist/keri/core/cipher.js} +10 -19
- package/dist/keri/core/core.d.ts +117 -9
- package/dist/keri/core/core.js +385 -0
- package/dist/keri/core/counter.d.ts +2 -2
- package/dist/keri/core/counter.js +221 -0
- package/dist/keri/core/decrypter.d.ts +4 -4
- package/{src/keri/core/decrypter.ts → dist/keri/core/decrypter.js} +23 -40
- package/dist/keri/core/diger.d.ts +3 -3
- package/{src/keri/core/diger.ts → dist/keri/core/diger.js} +18 -33
- package/dist/keri/core/encrypter.d.ts +2 -2
- package/{src/keri/core/encrypter.ts → dist/keri/core/encrypter.js} +18 -38
- package/dist/keri/core/eventing.d.ts +4 -4
- package/{src/keri/core/eventing.ts → dist/keri/core/eventing.js} +134 -321
- package/dist/keri/core/httping.d.ts +11 -4
- package/{src/keri/core/httping.ts → dist/keri/core/httping.js} +36 -101
- package/dist/keri/core/indexer.d.ts +1 -1
- package/dist/keri/core/indexer.js +407 -0
- package/dist/keri/core/keeping.d.ts +98 -46
- package/dist/keri/core/keeping.js +365 -0
- package/{src/keri/core/kering.ts → dist/keri/core/kering.js} +1 -3
- package/dist/keri/core/keyState.d.ts +85 -0
- package/dist/keri/core/keyState.js +1 -0
- package/dist/keri/core/manager.d.ts +147 -12
- package/dist/keri/core/manager.js +880 -0
- package/dist/keri/core/matter.d.ts +1 -1
- package/dist/keri/core/matter.js +460 -0
- package/dist/keri/core/number.d.ts +1 -1
- package/{src/keri/core/number.ts → dist/keri/core/number.js} +21 -30
- package/dist/keri/core/pather.d.ts +2 -2
- package/{src/keri/core/pather.ts → dist/keri/core/pather.js} +12 -27
- package/dist/keri/core/prefixer.d.ts +10 -10
- package/dist/keri/core/prefixer.js +182 -0
- package/dist/keri/core/saider.d.ts +2 -12
- package/dist/keri/core/saider.js +107 -0
- package/dist/keri/core/salter.d.ts +45 -3
- package/dist/keri/core/salter.js +117 -0
- package/dist/keri/core/seqner.d.ts +1 -1
- package/{src/keri/core/seqner.ts → dist/keri/core/seqner.js} +20 -21
- package/dist/keri/core/serder.d.ts +25 -12
- package/dist/keri/core/serder.js +133 -0
- package/dist/keri/core/siger.d.ts +2 -2
- package/{src/keri/core/siger.ts → dist/keri/core/siger.js} +4 -14
- package/dist/keri/core/signer.d.ts +4 -4
- package/dist/keri/core/signer.js +84 -0
- package/{src/keri/core/tholder.ts → dist/keri/core/tholder.js} +69 -94
- package/dist/keri/core/utils.d.ts +1 -1
- package/{src/keri/core/utils.ts → dist/keri/core/utils.js} +30 -60
- package/dist/keri/core/vdring.d.ts +2 -2
- package/dist/keri/core/vdring.js +61 -0
- package/dist/keri/core/verfer.d.ts +2 -6
- package/dist/keri/core/verfer.js +37 -0
- package/dist/keri/end/ending.d.ts +10 -8
- package/dist/keri/end/ending.js +136 -0
- package/{src/ready.ts → dist/ready.js} +1 -2
- package/dist/types/keria-api-schema.d.ts +304 -0
- package/dist/types/keria-api-schema.js +2 -0
- package/package.json +53 -50
- package/dist/buffer-polyfill.d.ts +0 -1
- package/dist/math.d.ts +0 -1
- package/dist/signify-ts.cjs +0 -7842
- package/dist/signify-ts.cjs.development.js +0 -9501
- package/dist/signify-ts.cjs.development.js.map +0 -1
- package/dist/signify-ts.cjs.map +0 -7
- package/dist/signify-ts.cjs.production.min.js +0 -2
- package/dist/signify-ts.cjs.production.min.js.map +0 -1
- package/dist/signify-ts.esm.js +0 -9345
- package/dist/signify-ts.esm.js.map +0 -1
- package/dist/signify-ts.mjs +0 -7818
- package/dist/signify-ts.mjs.map +0 -7
- package/src/buffer-polyfill.ts +0 -5
- package/src/exports.ts +0 -44
- package/src/index.ts +0 -4
- package/src/keri/app/credentialing.ts +0 -841
- package/src/keri/app/habery.ts +0 -185
- package/src/keri/core/cigar.ts +0 -18
- package/src/keri/core/core.ts +0 -326
- package/src/keri/core/counter.ts +0 -273
- package/src/keri/core/indexer.ts +0 -509
- package/src/keri/core/keeping.ts +0 -684
- package/src/keri/core/manager.ts +0 -1183
- package/src/keri/core/matter.ts +0 -521
- package/src/keri/core/prefixer.ts +0 -233
- package/src/keri/core/saider.ts +0 -186
- package/src/keri/core/salter.ts +0 -120
- package/src/keri/core/serder.ts +0 -163
- package/src/keri/core/signer.ts +0 -133
- package/src/keri/core/vdring.ts +0 -94
- package/src/keri/core/verfer.ts +0 -47
- package/src/keri/end/ending.ts +0 -170
- package/src/math.ts +0 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fromByteArray, toByteArray } from 'base64-js';
|
|
2
|
+
export function encodeBase64Url(input) {
|
|
3
|
+
return fromByteArray(input)
|
|
4
|
+
.replace(/\+/g, '-')
|
|
5
|
+
.replace(/\//g, '_')
|
|
6
|
+
.replace(/=+/, '');
|
|
7
|
+
}
|
|
8
|
+
export function decodeBase64Url(input) {
|
|
9
|
+
if (!(typeof input === 'string')) {
|
|
10
|
+
throw new TypeError('`input` must be a string.');
|
|
11
|
+
}
|
|
12
|
+
const n = input.length % 4;
|
|
13
|
+
const padded = input + '='.repeat(n > 0 ? 4 - n : n);
|
|
14
|
+
const base64String = padded.replace(/-/g, '+').replace(/_/g, '/');
|
|
15
|
+
return toByteArray(base64String);
|
|
16
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { BexDex, Matter,
|
|
2
|
-
import { EmptyMaterialError } from
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { BexDex, Matter, MtrDex } from "./matter.js";
|
|
2
|
+
import { EmptyMaterialError } from "./kering.js";
|
|
3
|
+
import { decodeBase64Url, encodeBase64Url } from "./base64.js";
|
|
4
|
+
import { concat } from "./core.js";
|
|
5
5
|
const B64REX = '^[A-Za-z0-9\\-_]*$';
|
|
6
6
|
export const Reb64 = new RegExp(B64REX);
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
|
|
10
9
|
Bexter is subclass of Matter, cryptographic material, for variable length
|
|
@@ -80,59 +79,46 @@ export const Reb64 = new RegExp(B64REX);
|
|
|
80
79
|
|
|
81
80
|
|
|
82
81
|
*/
|
|
83
|
-
|
|
84
82
|
export class Bexter extends Matter {
|
|
85
|
-
constructor(
|
|
86
|
-
|
|
87
|
-
bext?: string
|
|
88
|
-
) {
|
|
89
|
-
if (
|
|
90
|
-
raw === undefined &&
|
|
83
|
+
constructor({ raw, code = MtrDex.StrB64_L0, qb64b, qb64, qb2 }, bext) {
|
|
84
|
+
if (raw === undefined &&
|
|
91
85
|
qb64b === undefined &&
|
|
92
86
|
qb64 === undefined &&
|
|
93
|
-
qb2 === undefined
|
|
94
|
-
) {
|
|
87
|
+
qb2 === undefined) {
|
|
95
88
|
if (bext === undefined)
|
|
96
89
|
throw new EmptyMaterialError('Missing bext string.');
|
|
97
|
-
|
|
98
90
|
const match = Reb64.exec(bext);
|
|
99
|
-
if (!match)
|
|
100
|
-
|
|
91
|
+
if (!match)
|
|
92
|
+
throw new Error('Invalid Base64.');
|
|
101
93
|
raw = Bexter._rawify(bext);
|
|
102
94
|
}
|
|
103
|
-
|
|
104
95
|
super({ raw, code, qb64b, qb64, qb2 });
|
|
105
|
-
|
|
106
96
|
if (!BexDex.has(this.code))
|
|
107
97
|
throw new Error(`Invalid code = ${this.code} for Bexter.`);
|
|
108
98
|
}
|
|
109
|
-
|
|
110
|
-
static _rawify(bext: string): Uint8Array {
|
|
99
|
+
static _rawify(bext) {
|
|
111
100
|
const ts = bext.length % 4; // bext size mod 4
|
|
112
101
|
const ws = (4 - ts) % 4; // pre conv wad size in chars
|
|
113
102
|
const ls = (3 - ts) % 3; // post conv lead size in bytes
|
|
114
103
|
const wad = new Array(ws);
|
|
115
104
|
wad.fill('A');
|
|
116
105
|
const base = wad.join('') + bext; // pre pad with wad of zeros in Base64 == 'A'
|
|
117
|
-
const raw =
|
|
118
|
-
|
|
106
|
+
const raw = decodeBase64Url(base); // [ls:] // convert and remove leader
|
|
119
107
|
return Uint8Array.from(raw).subarray(ls); // raw binary equivalent of text
|
|
120
108
|
}
|
|
121
|
-
|
|
122
|
-
get bext(): string {
|
|
109
|
+
get bext() {
|
|
123
110
|
const sizage = Matter.Sizes.get(this.code);
|
|
124
|
-
const wad = Uint8Array.from(new Array(sizage
|
|
125
|
-
const bext =
|
|
126
|
-
|
|
111
|
+
const wad = Uint8Array.from(new Array(sizage === null || sizage === void 0 ? void 0 : sizage.ls).fill(0));
|
|
112
|
+
const bext = encodeBase64Url(concat(wad, this.raw));
|
|
127
113
|
let ws = 0;
|
|
128
|
-
if (sizage
|
|
114
|
+
if ((sizage === null || sizage === void 0 ? void 0 : sizage.ls) === 0 && bext !== undefined) {
|
|
129
115
|
if (bext[0] === 'A') {
|
|
130
116
|
ws = 1;
|
|
131
117
|
}
|
|
132
|
-
} else {
|
|
133
|
-
ws = (sizage?.ls! + 1) % 4;
|
|
134
118
|
}
|
|
135
|
-
|
|
119
|
+
else {
|
|
120
|
+
ws = ((sizage === null || sizage === void 0 ? void 0 : sizage.ls) + 1) % 4;
|
|
121
|
+
}
|
|
136
122
|
return bext.substring(ws);
|
|
137
123
|
}
|
|
138
124
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Verfer } from './verfer';
|
|
2
|
-
import { Matter, MatterArgs } from './matter';
|
|
1
|
+
import { Verfer } from './verfer.ts';
|
|
2
|
+
import { Matter, MatterArgs } from './matter.ts';
|
|
3
3
|
export declare class Cigar extends Matter {
|
|
4
4
|
private _verfer;
|
|
5
5
|
constructor({ raw, code, qb64, qb64b, qb2 }: MatterArgs, verfer?: Verfer);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Matter } from "./matter.js";
|
|
2
|
+
export class Cigar extends Matter {
|
|
3
|
+
constructor({ raw, code, qb64, qb64b, qb2 }, verfer) {
|
|
4
|
+
super({ raw, code, qb64, qb64b, qb2 });
|
|
5
|
+
this._verfer = verfer;
|
|
6
|
+
}
|
|
7
|
+
get verfer() {
|
|
8
|
+
return this._verfer;
|
|
9
|
+
}
|
|
10
|
+
set verfer(verfer) {
|
|
11
|
+
this._verfer = verfer;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Matter, MatterArgs } from './matter';
|
|
1
|
+
import { Matter, MatterArgs } from './matter.ts';
|
|
2
2
|
export declare class Cipher extends Matter {
|
|
3
3
|
constructor({ raw, code, qb64, qb64b, qb2 }: MatterArgs);
|
|
4
4
|
decrypt(prikey?: Uint8Array | undefined, seed?: Uint8Array | undefined): any;
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
import { Matter,
|
|
2
|
-
import { Decrypter } from
|
|
3
|
-
|
|
1
|
+
import { Matter, MtrDex } from "./matter.js";
|
|
2
|
+
import { Decrypter } from "./decrypter.js";
|
|
4
3
|
export class Cipher extends Matter {
|
|
5
|
-
constructor({ raw, code, qb64, qb64b, qb2 }
|
|
4
|
+
constructor({ raw, code, qb64, qb64b, qb2 }) {
|
|
6
5
|
if (raw != undefined && code == undefined) {
|
|
7
6
|
if (raw.length == Matter._rawSize(MtrDex.X25519_Cipher_Salt)) {
|
|
8
7
|
code = MtrDex.X25519_Cipher_Salt;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
) {
|
|
8
|
+
}
|
|
9
|
+
else if (raw.length == Matter._rawSize(MtrDex.X25519_Cipher_Seed)) {
|
|
12
10
|
code = MtrDex.X25519_Cipher_Salt;
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
13
|
super({ raw: raw, code: code, qb64b: qb64b, qb64: qb64, qb2: qb2 });
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
MtrDex.X25519_Cipher_Seed,
|
|
21
|
-
]).includes(this.code)
|
|
22
|
-
) {
|
|
14
|
+
if (!Array.from([
|
|
15
|
+
MtrDex.X25519_Cipher_Salt,
|
|
16
|
+
MtrDex.X25519_Cipher_Seed,
|
|
17
|
+
]).includes(this.code)) {
|
|
23
18
|
throw new Error(`Unsupported Cipher code == ${this.code}`);
|
|
24
19
|
}
|
|
25
20
|
}
|
|
26
|
-
|
|
27
|
-
decrypt(
|
|
28
|
-
prikey: Uint8Array | undefined = undefined,
|
|
29
|
-
seed: Uint8Array | undefined = undefined
|
|
30
|
-
) {
|
|
21
|
+
decrypt(prikey = undefined, seed = undefined) {
|
|
31
22
|
const decrypter = new Decrypter({ qb64b: prikey }, seed);
|
|
32
23
|
return decrypter.decrypt(this.qb64b);
|
|
33
24
|
}
|
package/dist/keri/core/core.d.ts
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialization types supported by the KERI and ACDC protocols and this Signify implementation.
|
|
3
|
+
*/
|
|
1
4
|
export declare enum Serials {
|
|
2
5
|
JSON = "JSON"
|
|
3
6
|
}
|
|
4
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Protocol types supported by the KERI and ACDC protocols and this Signify implementation.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum Protocols {
|
|
5
11
|
KERI = "KERI",
|
|
6
12
|
ACDC = "ACDC"
|
|
7
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Represents a protocol version of the KERI, ACDC, or other protocol specified in a CESR version string.
|
|
16
|
+
*/
|
|
8
17
|
export declare class Version {
|
|
9
18
|
major: number;
|
|
10
19
|
minor: number;
|
|
11
20
|
constructor(major?: number, minor?: number);
|
|
12
21
|
}
|
|
13
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Denotes version 1.0 of a protocol.
|
|
24
|
+
*/
|
|
25
|
+
export declare const Vrsn_1_0: Version;
|
|
26
|
+
/**
|
|
27
|
+
* Types of KERI and ACDC events.
|
|
28
|
+
*/
|
|
14
29
|
export declare const Ilks: {
|
|
15
30
|
icp: string;
|
|
16
31
|
rot: string;
|
|
@@ -24,36 +39,129 @@ export declare const Ilks: {
|
|
|
24
39
|
vcp: string;
|
|
25
40
|
iss: string;
|
|
26
41
|
rev: string;
|
|
42
|
+
bis: string;
|
|
43
|
+
brv: string;
|
|
27
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Field labels for an inception event in V1 of the KERI protocol.
|
|
47
|
+
*/
|
|
28
48
|
export declare const IcpLabels: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Field labels for an delegated inception event in V1 of the KERI protocol.
|
|
51
|
+
*/
|
|
29
52
|
export declare const DipLabels: string[];
|
|
53
|
+
/**
|
|
54
|
+
* Field labels for a rotation event in V1 of the KERI protocol.
|
|
55
|
+
*/
|
|
30
56
|
export declare const RotLabels: string[];
|
|
57
|
+
/**
|
|
58
|
+
* Field labels for an delegated rotation event in V1 of the KERI protocol.
|
|
59
|
+
*/
|
|
31
60
|
export declare const DrtLabels: string[];
|
|
61
|
+
/**
|
|
62
|
+
* Field labels for an interaction event in V1 of the KERI protocol.
|
|
63
|
+
*/
|
|
32
64
|
export declare const IxnLabels: string[];
|
|
65
|
+
/**
|
|
66
|
+
* Field labels for a key state notice event in V1 of the KERI protocol.
|
|
67
|
+
*/
|
|
33
68
|
export declare const KsnLabels: string[];
|
|
69
|
+
/**
|
|
70
|
+
* Field labels for a reply event in V1 of the KERI protocol.
|
|
71
|
+
*/
|
|
34
72
|
export declare const RpyLabels: string[];
|
|
73
|
+
/**
|
|
74
|
+
* Full size of a CESR version string in bytes.
|
|
75
|
+
*/
|
|
35
76
|
export declare const VERFULLSIZE = 17;
|
|
77
|
+
/**
|
|
78
|
+
* Minimum number of bytes a CESR parser must sniff to receive the entire version string.
|
|
79
|
+
*/
|
|
36
80
|
export declare const MINSNIFFSIZE: number;
|
|
37
81
|
export declare const MINSIGSIZE = 4;
|
|
82
|
+
/**
|
|
83
|
+
* Regular expression for a version 1 CESR object version string.
|
|
84
|
+
*/
|
|
38
85
|
export declare const VEREX = "(KERI|ACDC)([0-9a-f])([0-9a-f])([A-Z]{4})([0-9a-f]{6})_";
|
|
86
|
+
/**
|
|
87
|
+
* An interface for a basic dictionary type keyed by string with any value type.
|
|
88
|
+
* Mimics the Python dictionary type.
|
|
89
|
+
*/
|
|
39
90
|
export interface Dict<TValue> {
|
|
40
91
|
[id: string]: TValue;
|
|
41
92
|
}
|
|
42
93
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* @param {string} versionString
|
|
46
|
-
* @return {Object}
|
|
47
|
-
*
|
|
94
|
+
* Parses a serialization version string into the protocol, protocol version, serialization type, and raw size.
|
|
95
|
+
* Uses regex matchers to validate and extract version string parts.
|
|
96
|
+
* @param {string} versionString version string
|
|
97
|
+
* @return {Object} tuple of prototol (KERI or ACDC), kind of serialization like cbor,json, or mgpk,
|
|
98
|
+
* protocol version, and raw size of serialization
|
|
99
|
+
*/
|
|
100
|
+
export declare function deversify(versionString: string): [Protocols, Serials, Version, string];
|
|
101
|
+
/**
|
|
102
|
+
* Returns a valid KERI serialization version string specifying the protocol,
|
|
103
|
+
* protocol version, serialization type, and raw byte size of the serialization.
|
|
104
|
+
*
|
|
105
|
+
* Defaults to version 1.0.
|
|
106
|
+
* @param ident
|
|
107
|
+
* @param version
|
|
108
|
+
* @param kind
|
|
109
|
+
* @param size
|
|
110
|
+
*/
|
|
111
|
+
export declare function versify(ident?: Protocols, version?: Version, kind?: Serials, size?: number): string;
|
|
112
|
+
/**
|
|
113
|
+
* Map allowing lookup of Base64URLSafe characters by index.
|
|
48
114
|
*/
|
|
49
|
-
export declare function deversify(versionString: string): [Ident, Serials, Version, string];
|
|
50
|
-
export declare function versify(ident?: Ident, version?: Version, kind?: Serials, size?: number): string;
|
|
51
115
|
export declare const B64ChrByIdx: Map<number, string>;
|
|
116
|
+
/**
|
|
117
|
+
* Map allowing lookup of Base64URLSafe index by character.
|
|
118
|
+
*/
|
|
52
119
|
export declare const B64IdxByChr: Map<string, number>;
|
|
120
|
+
/**
|
|
121
|
+
* Converts an integer to a Base64URLSafe encoded string, left padded as specified.
|
|
122
|
+
* @param i integer to convert
|
|
123
|
+
* @param l minimum length of Base64 digits left padded with Base64 0 == 'A' character.
|
|
124
|
+
*/
|
|
53
125
|
export declare function intToB64(i: number, l?: number): string;
|
|
126
|
+
/**
|
|
127
|
+
* Converts an integer to a Base64URLSafe encoded string to a byte array, left padded as specified.
|
|
128
|
+
* @param i integer to convert
|
|
129
|
+
* @param l minimum length of Base64 digits left padded with Base64 0 == 'A' character.
|
|
130
|
+
*/
|
|
54
131
|
export declare function intToB64b(n: number, l?: number): Uint8Array;
|
|
132
|
+
/**
|
|
133
|
+
* Converts a Base64URLSafe encoded string to an integer.
|
|
134
|
+
* @param s string to convert
|
|
135
|
+
*/
|
|
55
136
|
export declare function b64ToInt(s: string): number;
|
|
137
|
+
/**
|
|
138
|
+
* Converts a UTF-8 string to bytes.
|
|
139
|
+
* Output is an encoded array of bytes. Assumes UTF-8 encoding.
|
|
140
|
+
* @param s string to be encoded as an array of bytes
|
|
141
|
+
*/
|
|
56
142
|
export declare function b(s?: string): Uint8Array;
|
|
143
|
+
/**
|
|
144
|
+
* Convert bytes to UTF-8 string.
|
|
145
|
+
* @param u array of bytes to be converted to UTF-8 string.
|
|
146
|
+
*/
|
|
57
147
|
export declare function d(u?: Uint8Array): string;
|
|
148
|
+
/**
|
|
149
|
+
* Concatenates two byte arrays together in a new byte array.
|
|
150
|
+
* @param one first byte array to be concatenated
|
|
151
|
+
* @param two second byte array to be concatenated
|
|
152
|
+
*/
|
|
58
153
|
export declare function concat(one: Uint8Array, two: Uint8Array): Uint8Array;
|
|
154
|
+
/**
|
|
155
|
+
* Converts a big-endian byte array into an integer.
|
|
156
|
+
*
|
|
157
|
+
* @param array - A `Uint8Array` of bytes representing a big-endian integer.
|
|
158
|
+
* @returns The integer represented by the byte array.
|
|
159
|
+
*
|
|
160
|
+
* Example:
|
|
161
|
+
* readInt(Uint8Array([0x01, 0x02, 0x03])) // returns 66051
|
|
162
|
+
*
|
|
163
|
+
* How it works:
|
|
164
|
+
* - The function interprets the array as a big-endian number.
|
|
165
|
+
* - Each byte is added to the integer after shifting the previous value left by 8 bits (multiplying by 256).
|
|
166
|
+
*/
|
|
59
167
|
export declare function readInt(array: Uint8Array): number;
|