@did-btcr2/common 3.0.0 → 4.0.1
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/canonicalization.js +79 -43
- package/dist/cjs/canonicalization.js.map +1 -1
- package/dist/cjs/constants.js +0 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/errors.js +20 -3
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/date.js +92 -1
- package/dist/cjs/utils/date.js.map +1 -1
- package/dist/esm/canonicalization.js +79 -43
- package/dist/esm/canonicalization.js.map +1 -1
- package/dist/esm/constants.js +0 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/errors.js +20 -3
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/date.js +92 -1
- package/dist/esm/utils/date.js.map +1 -1
- package/dist/types/canonicalization.d.ts +37 -28
- package/dist/types/canonicalization.d.ts.map +1 -1
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/errors.d.ts +14 -3
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/interfaces.d.ts +0 -271
- package/dist/types/interfaces.d.ts.map +1 -1
- package/dist/types/types.d.ts +3 -3
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/date.d.ts +21 -1
- package/dist/types/utils/date.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/canonicalization.ts +96 -52
- package/src/constants.ts +0 -1
- package/src/errors.ts +25 -3
- package/src/interfaces.ts +0 -300
- package/src/types.ts +3 -3
- package/src/utils/date.ts +99 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sha256 } from '@noble/hashes/sha2';
|
|
2
|
-
import { bytesToHex } from '@noble/hashes/utils';
|
|
2
|
+
import { bytesToHex, hexToBytes } from '@noble/hashes/utils';
|
|
3
3
|
import { canonicalize as jcsa } from 'json-canonicalize';
|
|
4
4
|
import { base58btc } from 'multiformats/bases/base58';
|
|
5
5
|
import { CanonicalizationError } from './errors.js';
|
|
@@ -11,21 +11,6 @@ import { CanonicalizationError } from './errors.js';
|
|
|
11
11
|
* @type {Canonicalization}
|
|
12
12
|
*/
|
|
13
13
|
export class Canonicalization {
|
|
14
|
-
_defaultAlgorithm;
|
|
15
|
-
/**
|
|
16
|
-
* Initializes the Canonicalization class with the specified algorithm.
|
|
17
|
-
* @param {CanonicalizationAlgorithm} algorithm The canonicalization algorithm to use ('jcs').
|
|
18
|
-
*/
|
|
19
|
-
constructor(algorithm = 'jcs') {
|
|
20
|
-
this._defaultAlgorithm = Canonicalization.normalizeAlgorithm(algorithm);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Gets the canonicalization algorithm.
|
|
24
|
-
* @returns {CanonicalizationAlgorithm} The current canonicalization algorithm.
|
|
25
|
-
*/
|
|
26
|
-
get algorithm() {
|
|
27
|
-
return this._defaultAlgorithm;
|
|
28
|
-
}
|
|
29
14
|
/**
|
|
30
15
|
* Normalizes the canonicalization algorithm.
|
|
31
16
|
* @param {CanonicalizationAlgorithm} algorithm
|
|
@@ -65,17 +50,19 @@ export class Canonicalization {
|
|
|
65
50
|
* @param {Object} [options] Options for processing.
|
|
66
51
|
* @param {CanonicalizationEncoding} [options.encoding='hex'] The encoding format ('hex' or 'base58').
|
|
67
52
|
* @param {CanonicalizationAlgorithm} [options.algorithm] The canonicalization algorithm to use.
|
|
68
|
-
* @returns {
|
|
53
|
+
* @returns {string} The final SHA-256 hash bytes as a hex string.
|
|
69
54
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
55
|
+
static process(object, options) {
|
|
56
|
+
// Normalize the algorithm
|
|
57
|
+
const algorithm = Canonicalization.normalizeAlgorithm(options?.algorithm ?? 'jcs');
|
|
58
|
+
// Normalize the encoding
|
|
59
|
+
const encoding = Canonicalization.normalizeEncoding(options?.encoding ?? 'hex');
|
|
73
60
|
// Step 1: Canonicalize
|
|
74
|
-
const canonicalized =
|
|
61
|
+
const canonicalized = this.canonicalize(object, algorithm);
|
|
75
62
|
// Step 2: Hash
|
|
76
|
-
const hashed = this.
|
|
63
|
+
const hashed = this.toHash(canonicalized);
|
|
77
64
|
// Step 3: Encode
|
|
78
|
-
const encoded = this.encode(hashed, encoding
|
|
65
|
+
const encoded = this.encode(hashed, encoding);
|
|
79
66
|
// Return the encoded string
|
|
80
67
|
return encoded;
|
|
81
68
|
}
|
|
@@ -83,9 +70,9 @@ export class Canonicalization {
|
|
|
83
70
|
* Step 1: Uses this.algorithm to determine the method (JCS).
|
|
84
71
|
* @param {Record<any, any>} object The object to canonicalize.
|
|
85
72
|
* @param {CanonicalizationAlgorithm} [algorithm] The algorithm to use.
|
|
86
|
-
* @returns {
|
|
73
|
+
* @returns {string} The canonicalized object.
|
|
87
74
|
*/
|
|
88
|
-
|
|
75
|
+
static canonicalize(object, algorithm = 'jcs') {
|
|
89
76
|
switch (Canonicalization.normalizeAlgorithm(algorithm)) {
|
|
90
77
|
case 'jcs':
|
|
91
78
|
return this.jcs(object);
|
|
@@ -98,7 +85,7 @@ export class Canonicalization {
|
|
|
98
85
|
* @param {Record<any, any>} object The object to canonicalize.
|
|
99
86
|
* @returns {string} The canonicalized object.
|
|
100
87
|
*/
|
|
101
|
-
jcs(object) {
|
|
88
|
+
static jcs(object) {
|
|
102
89
|
return jcsa(object);
|
|
103
90
|
}
|
|
104
91
|
/**
|
|
@@ -106,7 +93,7 @@ export class Canonicalization {
|
|
|
106
93
|
* @param {string} canonicalized The canonicalized object.
|
|
107
94
|
* @returns {HashBytes} The SHA-256 HashBytes (Uint8Array).
|
|
108
95
|
*/
|
|
109
|
-
|
|
96
|
+
static toHash(canonicalized) {
|
|
110
97
|
return sha256(canonicalized);
|
|
111
98
|
}
|
|
112
99
|
/**
|
|
@@ -116,32 +103,72 @@ export class Canonicalization {
|
|
|
116
103
|
* @throws {CanonicalizationError} If the encoding format is not supported.
|
|
117
104
|
* @returns {string} The encoded string.
|
|
118
105
|
*/
|
|
119
|
-
encode(canonicalizedhash, encoding = 'hex'
|
|
106
|
+
static encode(canonicalizedhash, encoding = 'hex') {
|
|
107
|
+
// Normalize encoding
|
|
120
108
|
const normalized = Canonicalization.normalizeEncoding(encoding);
|
|
121
|
-
|
|
122
|
-
|
|
109
|
+
// If encoding is hex, encode to hex
|
|
110
|
+
if (normalized === 'hex') {
|
|
111
|
+
return this.toHex(canonicalizedhash);
|
|
112
|
+
}
|
|
113
|
+
// If encoding is base58, encode to base58
|
|
123
114
|
if (normalized === 'base58') {
|
|
124
|
-
|
|
125
|
-
return multibase ? `z${encoded}` : encoded;
|
|
115
|
+
return this.toBase58(canonicalizedhash);
|
|
126
116
|
}
|
|
117
|
+
// Throw error if encoding is unsupported
|
|
127
118
|
throw new CanonicalizationError(`Unsupported encoding: ${encoding}`, 'ENCODING_ERROR');
|
|
128
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Decodes SHA-256 hashed, canonicalized object as a hex or base58 string.
|
|
122
|
+
* @param {string} canonicalizedhash The canonicalized object to encode.
|
|
123
|
+
* @param {CanonicalizationEncoding} encoding The encoding format ('hex' or 'base58').
|
|
124
|
+
* @throws {CanonicalizationError} If the encoding format is not supported.
|
|
125
|
+
* @returns {string} The encoded string.
|
|
126
|
+
*/
|
|
127
|
+
static decode(canonicalizedhash, encoding = 'hex') {
|
|
128
|
+
// Normalize encoding
|
|
129
|
+
const normalized = Canonicalization.normalizeEncoding(encoding);
|
|
130
|
+
// If encoding is hex, decode from hex
|
|
131
|
+
if (normalized === 'hex') {
|
|
132
|
+
return this.fromHex(canonicalizedhash);
|
|
133
|
+
}
|
|
134
|
+
// If encoding is base58, decode from base58
|
|
135
|
+
if (normalized === 'base58') {
|
|
136
|
+
return this.fromBase58(canonicalizedhash);
|
|
137
|
+
}
|
|
138
|
+
// Throw error if encoding is unsupported
|
|
139
|
+
throw new CanonicalizationError(`Unsupported encoding: ${encoding}`, 'DECODING_ERROR');
|
|
140
|
+
}
|
|
129
141
|
/**
|
|
130
142
|
* Step 3.1: Encodes HashBytes (Uint8Array) to a hex string.
|
|
131
143
|
* @param {HashBytes} hashBytes The hash as a Uint8Array.
|
|
132
144
|
* @returns {string} The hash as a hex string.
|
|
133
145
|
*/
|
|
134
|
-
|
|
146
|
+
static toHex(hashBytes) {
|
|
135
147
|
return bytesToHex(hashBytes);
|
|
136
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Decodes a hex string to HashBytes (Uint8Array).
|
|
151
|
+
* @param {HexString} hexString The hash as a hex string.
|
|
152
|
+
* @returns {HashBytes} The hash bytes.
|
|
153
|
+
*/
|
|
154
|
+
static fromHex(hexString) {
|
|
155
|
+
return hexToBytes(hexString);
|
|
156
|
+
}
|
|
137
157
|
/**
|
|
138
158
|
* Step 3.2: Encodes HashBytes (Uint8Array) to a base58btc string.
|
|
139
159
|
* @param {HashBytes} hashBytes The hash as a Uint8Array.
|
|
140
160
|
* @returns {string} The hash as a hex string.
|
|
141
161
|
*/
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
162
|
+
static toBase58(hashBytes) {
|
|
163
|
+
return base58btc.encode(hashBytes);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Decodes a base58 string to HashBytes (Uint8Array).
|
|
167
|
+
* @param {string} b58str The hash as a base58 string.
|
|
168
|
+
* @returns {HashBytes} The hash bytes.
|
|
169
|
+
*/
|
|
170
|
+
static fromBase58(b58str) {
|
|
171
|
+
return base58btc.decode(b58str);
|
|
145
172
|
}
|
|
146
173
|
/**
|
|
147
174
|
* Canonicalizes an object, hashes it and returns it as hash bytes.
|
|
@@ -149,9 +176,13 @@ export class Canonicalization {
|
|
|
149
176
|
* @param {Record<any, any>} object The object to process.
|
|
150
177
|
* @returns {Promise<HashBytes>} The final SHA-256 hash bytes.
|
|
151
178
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
179
|
+
static andHash(object, algorithm = 'jcs') {
|
|
180
|
+
// Step 1: Canonicalize
|
|
181
|
+
const canonicalized = this.canonicalize(object, algorithm);
|
|
182
|
+
// Step 2: Hash
|
|
183
|
+
const hashed = this.toHash(canonicalized);
|
|
184
|
+
// Return canonicalized hash bytes
|
|
185
|
+
return hashed;
|
|
155
186
|
}
|
|
156
187
|
/**
|
|
157
188
|
* Computes the SHA-256 hash of a canonicalized object and encodes it as a hex string.
|
|
@@ -159,8 +190,13 @@ export class Canonicalization {
|
|
|
159
190
|
* @param {string} canonicalized The canonicalized object to hash.
|
|
160
191
|
* @returns {string} The SHA-256 hash as a hex string.
|
|
161
192
|
*/
|
|
162
|
-
|
|
163
|
-
|
|
193
|
+
static andHashToHex(canonicalized) {
|
|
194
|
+
// Step 2: Hash
|
|
195
|
+
const hashed = this.toHash(canonicalized);
|
|
196
|
+
// Step 3: Encode (Hex)
|
|
197
|
+
const hexed = this.toHex(hashed);
|
|
198
|
+
// Return the hashed encoded string
|
|
199
|
+
return hexed;
|
|
164
200
|
}
|
|
165
201
|
/**
|
|
166
202
|
* Computes the SHA-256 hashes of canonicalized object and encodes it as a base58 string.
|
|
@@ -168,8 +204,8 @@ export class Canonicalization {
|
|
|
168
204
|
* @param {string} canonicalized The canonicalized object to hash.
|
|
169
205
|
* @returns {string} The SHA-256 hash as a base58 string.
|
|
170
206
|
*/
|
|
171
|
-
|
|
172
|
-
return this.encode(this.
|
|
207
|
+
static andHashToBase58(canonicalized) {
|
|
208
|
+
return this.encode(this.toHash(canonicalized), 'base58');
|
|
173
209
|
}
|
|
174
210
|
}
|
|
175
211
|
//# sourceMappingURL=canonicalization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonicalization.js","sourceRoot":"","sources":["../../src/canonicalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|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K;QAE5C,uBAAuB;QACvB,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAC3D,eAAe;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC1C,kCAAkC;QAClC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,aAAqB;QACvC,eAAe;QACf,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC1C,uBAAuB;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACjC,mCAAmC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,aAAqB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { sha256 } from '@noble/hashes/sha2';
|
|
2
2
|
import { bytesToHex } from '@noble/hashes/utils';
|
|
3
|
-
export const ID_PLACEHOLDER_VALUE = 'did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
|
|
4
3
|
export const OP_RETURN = 0x6a;
|
|
5
4
|
export const OP_PUSH32 = 0x20;
|
|
6
5
|
export const VALID_HRP = ['k', 'x'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,MAAM,CAAC,MAAM,
|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AM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;IAC/B,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;IAC/B,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;IAC3B,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;CACnC,CAAC"}
|
package/dist/esm/errors.js
CHANGED
|
@@ -53,12 +53,14 @@ export var MethodErrorCode;
|
|
|
53
53
|
MethodErrorCode["LATE_PUBLISHING_ERROR"] = "LATE_PUBLISHING_ERROR";
|
|
54
54
|
/** The sidecar data in the DID Update Payload was invalid. */
|
|
55
55
|
MethodErrorCode["INVALID_SIDECAR_DATA"] = "INVALID_SIDECAR_DATA";
|
|
56
|
-
/** The
|
|
57
|
-
MethodErrorCode["
|
|
56
|
+
/** The update data required for resolution is missing. */
|
|
57
|
+
MethodErrorCode["MISSING_UPDATE_DATA"] = "MISSING_UPDATE_DATA";
|
|
58
|
+
/** The update is missing or has a malformed field(s). */
|
|
59
|
+
MethodErrorCode["INVALID_UPDATE"] = "INVALID_UPDATE";
|
|
58
60
|
/** The proof is missing or has a malformed domain field. */
|
|
59
61
|
MethodErrorCode["INVALID_DOMAIN_ERROR"] = "INVALID_DOMAIN_ERROR";
|
|
60
62
|
})(MethodErrorCode || (MethodErrorCode = {}));
|
|
61
|
-
export const { INVALID_DID, METHOD_NOT_SUPPORTED, INTERNAL_ERROR, INVALID_DID_DOCUMENT, INVALID_DID_UPDATE, INVALID_DID_DOCUMENT_LENGTH, INVALID_DID_URL, INVALID_PREVIOUS_DID_PROOF, INVALID_PUBLIC_KEY, INVALID_PUBLIC_KEY_MULTIBASE, INVALID_PUBLIC_KEY_LENGTH, INVALID_PUBLIC_KEY_TYPE, INVALID_SIGNATURE, NOT_FOUND, REPRESENTATION_NOT_SUPPORTED, UNSUPPORTED_PUBLIC_KEY_TYPE, PROOF_VERIFICATION_ERROR, PROOF_GENERATION_ERROR, PROOF_SERIALIZATION_ERROR, PROOF_PARSING_ERROR, VERIFICATION_METHOD_ERROR, LATE_PUBLISHING_ERROR, INVALID_SIDECAR_DATA,
|
|
63
|
+
export const { INVALID_DID, METHOD_NOT_SUPPORTED, INTERNAL_ERROR, INVALID_DID_DOCUMENT, INVALID_DID_UPDATE, INVALID_DID_DOCUMENT_LENGTH, INVALID_DID_URL, INVALID_PREVIOUS_DID_PROOF, INVALID_PUBLIC_KEY, INVALID_PUBLIC_KEY_MULTIBASE, INVALID_PUBLIC_KEY_LENGTH, INVALID_PUBLIC_KEY_TYPE, INVALID_SIGNATURE, NOT_FOUND, REPRESENTATION_NOT_SUPPORTED, UNSUPPORTED_PUBLIC_KEY_TYPE, PROOF_VERIFICATION_ERROR, PROOF_GENERATION_ERROR, PROOF_SERIALIZATION_ERROR, PROOF_PARSING_ERROR, VERIFICATION_METHOD_ERROR, LATE_PUBLISHING_ERROR, INVALID_SIDECAR_DATA, MISSING_UPDATE_DATA, INVALID_UPDATE, INVALID_DOMAIN_ERROR } = MethodErrorCode;
|
|
62
64
|
export class NotImplementedError extends Error {
|
|
63
65
|
name = 'NotImplementedError';
|
|
64
66
|
type = 'NotImplementedError';
|
|
@@ -100,6 +102,16 @@ export class MethodError extends DidMethodError {
|
|
|
100
102
|
super(message, { type, name: type, data });
|
|
101
103
|
}
|
|
102
104
|
}
|
|
105
|
+
export class IdentifierError extends DidMethodError {
|
|
106
|
+
constructor(message, type = 'IdentifierError', data) {
|
|
107
|
+
super(message, { type, name: type, data });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export class UpdateError extends DidMethodError {
|
|
111
|
+
constructor(message, type = 'UpdateError', data) {
|
|
112
|
+
super(message, { type, name: type, data });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
103
115
|
export class ResolveError extends DidMethodError {
|
|
104
116
|
constructor(message, type = 'ResolveError', data) {
|
|
105
117
|
super(message, { type, name: 'ResolveError', data });
|
|
@@ -120,6 +132,11 @@ export class CryptosuiteError extends DidMethodError {
|
|
|
120
132
|
super(message, { type, name: type, data });
|
|
121
133
|
}
|
|
122
134
|
}
|
|
135
|
+
export class DataIntegrityProofError extends DidMethodError {
|
|
136
|
+
constructor(message, type = 'DataIntegrityProofError', data) {
|
|
137
|
+
super(message, { type, name: type, data });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
123
140
|
export class KeyPairError extends DidMethodError {
|
|
124
141
|
constructor(message, type = 'KeyPairError', data) {
|
|
125
142
|
super(message, { type, name: type, data });
|
package/dist/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,eAkFX;AAlFD,WAAY,eAAe;IACzB,yDAAyD;IACzD,8CAA2B,CAAA;IAE3B,sGAAsG;IACtG,gEAA6C,CAAA;IAE7C,uEAAuE;IACvE,oDAAiC,CAAA;IAEjC,kEAAkE;IAClE,gEAA6C,CAAA;IAE7C,gEAAgE;IAChE,4DAAyC,CAAA;IAEzC,2EAA2E;IAC3E,8EAA2D,CAAA;IAE3D,2FAA2F;IAC3F,sDAAmC,CAAA;IAEnC,mDAAmD;IACnD,4EAAyD,CAAA;IAEzD,gEAAgE;IAChE,4DAAyC,CAAA;IAEzC,wFAAwF;IACxF,gFAA6D,CAAA;IAE7D,yEAAyE;IACzE,0EAAuD,CAAA;IAEvD,sEAAsE;IACtE,sEAAmD,CAAA;IAEnD,iEAAiE;IACjE,0DAAuC,CAAA;IAEvC,qDAAqD;IACrD,mHAAmH;IACnH,0CAAuB,CAAA;IAEvB;;;OAGG;IACH,gFAA6D,CAAA;IAE7D,sGAAsG;IACtG,8EAA2D,CAAA;IAE3D,+CAA+C;IAC/C,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AC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,cAAc;IACzD,YAAY,OAAe,EAAE,OAAe,yBAAyB,EAAE,IAA0B;QAC/F,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,OAAO,uBAAwB,SAAQ,cAAc;IACzD,YAAY,OAAe,EAAE,OAAe,yBAAyB,EAAE,IAA0B;QAC/F,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,cAAc;IACvD,YAAY,OAAe,EAAE,OAAe,uBAAuB,EAAE,IAA0B;QAC7F,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF"}
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAqDA,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACvB,8BAAW,CAAA;IACX,wCAAqB,CAAA;AACzB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AACD,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,wBAAO,CAAA;IACP,wBAAO,CAAA;AACX,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AACD,MAAM,CAAN,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC3B,mEAAW,CAAA;IACX,iEAAU,CAAA;IACV,mEAAW,CAAA;IACX,qEAAY,CAAA;IACZ,qEAAY,CAAA;IACZ,uEAAa,CAAA;AACjB,CAAC,EAPW,mBAAmB,KAAnB,mBAAmB,QAO9B"}
|
package/dist/esm/utils/date.js
CHANGED
|
@@ -9,7 +9,7 @@ export class DateUtils {
|
|
|
9
9
|
* @param {Date} [date=new Date()] - The date to format.
|
|
10
10
|
* @returns {string} The formatted date string.
|
|
11
11
|
*/
|
|
12
|
-
static
|
|
12
|
+
static toISOStringNonFractional(date = new Date()) {
|
|
13
13
|
const time = date.getTime();
|
|
14
14
|
if (Number.isNaN(time)) {
|
|
15
15
|
throw new Error(`Invalid date: ${date}`);
|
|
@@ -28,5 +28,96 @@ export class DateUtils {
|
|
|
28
28
|
}
|
|
29
29
|
return Math.floor(date.getTime() / 1000);
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Validate if a string is a valid UTC date string.
|
|
33
|
+
* @param {string} dateString - The date string to validate.
|
|
34
|
+
* @returns {boolean} True if valid, otherwise false.
|
|
35
|
+
* @throws {Error} If the date string is invalid.
|
|
36
|
+
*/
|
|
37
|
+
static dateStringToTimestamp(dateString) {
|
|
38
|
+
const date = new Date(dateString);
|
|
39
|
+
if (Number.isNaN(date.getTime())) {
|
|
40
|
+
return new Date(0);
|
|
41
|
+
}
|
|
42
|
+
return date;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Convert a blocktime (Unix timestamp in seconds) to a Date object.
|
|
46
|
+
* @param {number} blocktime - The blocktime in seconds.
|
|
47
|
+
* @returns {Date} The corresponding Date object.
|
|
48
|
+
*/
|
|
49
|
+
static blocktimeToTimestamp(blocktime) {
|
|
50
|
+
return new Date(blocktime * 1000);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Validates an XMLSCHEMA11-2 dateTime string.
|
|
54
|
+
* Format: [-]YYYY-MM-DDThh:mm:ss[.fractional][Z|(+|-)hh:mm]
|
|
55
|
+
*
|
|
56
|
+
* @see https://www.w3.org/TR/xmlschema11-2/#dateTime
|
|
57
|
+
*/
|
|
58
|
+
static isValidXsdDateTime(value) {
|
|
59
|
+
// Empty or undefined value is not a valid dateTime
|
|
60
|
+
if (!value)
|
|
61
|
+
return false;
|
|
62
|
+
// Regex for XML Schema dateTime:
|
|
63
|
+
// - Optional leading minus for BCE years
|
|
64
|
+
// - Year: 4+ digits
|
|
65
|
+
// - Month: 01-12
|
|
66
|
+
// - Day: 01-31 (further validated below)
|
|
67
|
+
// - T separator
|
|
68
|
+
// - Hour: 00-23 (24:00:00 is valid end-of-day per spec)
|
|
69
|
+
// - Minute: 00-59
|
|
70
|
+
// - Second: 00-59 (with optional fractional part)
|
|
71
|
+
// - Timezone: Z or (+|-)hh:mm
|
|
72
|
+
const xsdDateTimeRegex = /^-?(\d{4,})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
73
|
+
const match = value.match(xsdDateTimeRegex);
|
|
74
|
+
if (!match)
|
|
75
|
+
return false;
|
|
76
|
+
const [, y, m, d, H, M, S, , tz] = match;
|
|
77
|
+
const year = parseInt(y, 10);
|
|
78
|
+
const month = parseInt(m, 10);
|
|
79
|
+
const day = parseInt(d, 10);
|
|
80
|
+
const hour = parseInt(H, 10);
|
|
81
|
+
const minute = parseInt(M, 10);
|
|
82
|
+
const second = parseInt(S, 10);
|
|
83
|
+
// Year 0000 is not valid in XML Schema (no year zero)
|
|
84
|
+
if (year === 0)
|
|
85
|
+
return false;
|
|
86
|
+
// Month: 1-12
|
|
87
|
+
if (month < 1 || month > 12)
|
|
88
|
+
return false;
|
|
89
|
+
// Day: validate against month (and leap year for February)
|
|
90
|
+
const daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
91
|
+
const isLeapYear = (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
|
|
92
|
+
const maxDay = month === 2 && isLeapYear ? 29 : daysInMonth[month - 1];
|
|
93
|
+
if (day < 1 || day > maxDay)
|
|
94
|
+
return false;
|
|
95
|
+
// Hour: 00-23, or 24:00:00 exactly (end-of-day)
|
|
96
|
+
if (hour === 24) {
|
|
97
|
+
if (minute !== 0 || second !== 0)
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
else if (hour > 23) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
// Minute: 00-59
|
|
104
|
+
if (minute > 59)
|
|
105
|
+
return false;
|
|
106
|
+
// Second: 00-59 (leap second 60 is debatable; XML Schema doesn't explicitly allow it)
|
|
107
|
+
if (second > 59)
|
|
108
|
+
return false;
|
|
109
|
+
// Validate timezone offset if present
|
|
110
|
+
if (tz && tz !== 'Z') {
|
|
111
|
+
const tzMatch = tz.match(/^[+-](\d{2}):(\d{2})$/);
|
|
112
|
+
if (tzMatch) {
|
|
113
|
+
const tzHour = parseInt(tzMatch[1], 10);
|
|
114
|
+
const tzMin = parseInt(tzMatch[2], 10);
|
|
115
|
+
if (tzHour > 14 || (tzHour === 14 && tzMin !== 0) || tzMin > 59) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
31
122
|
}
|
|
32
123
|
//# sourceMappingURL=date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../src/utils/date.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../src/utils/date.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAC,wBAAwB,CAAC,OAAa,IAAI,IAAI,EAAE;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,IA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AU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACvE,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,MAAM;YAAE,OAAO,KAAK,CAAC;QAE1C,gDAAgD;QAChD,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;YAChB,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;QACjD,CAAC;aAAM,IAAI,IAAI,GAAG,EAAE,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,gBAAgB;QAChB,IAAI,MAAM,GAAG,EAAE;YAAE,OAAO,KAAK,CAAC;QAE9B,sFAAsF;QACtF,IAAI,MAAM,GAAG,EAAE;YAAE,OAAO,KAAK,CAAC;QAE9B,sCAAsC;QACtC,IAAI,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACrB,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAClD,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACvC,IAAI,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,KAAK,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;oBAChE,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { CanonicalizationAlgorithm, CanonicalizationEncoding, HashBytes } from './types.js';
|
|
1
|
+
import { CanonicalizationAlgorithm, CanonicalizationEncoding, HashBytes, HexString } from './types.js';
|
|
2
|
+
export interface CanonicalizationOptions {
|
|
3
|
+
algorithm?: CanonicalizationAlgorithm;
|
|
4
|
+
encoding?: CanonicalizationEncoding;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Canonicalization class provides methods for canonicalizing JSON objects
|
|
4
8
|
* and hashing them using SHA-256. It supports different canonicalization
|
|
@@ -7,17 +11,6 @@ import { CanonicalizationAlgorithm, CanonicalizationEncoding, HashBytes } from '
|
|
|
7
11
|
* @type {Canonicalization}
|
|
8
12
|
*/
|
|
9
13
|
export declare class Canonicalization {
|
|
10
|
-
private readonly _defaultAlgorithm;
|
|
11
|
-
/**
|
|
12
|
-
* Initializes the Canonicalization class with the specified algorithm.
|
|
13
|
-
* @param {CanonicalizationAlgorithm} algorithm The canonicalization algorithm to use ('jcs').
|
|
14
|
-
*/
|
|
15
|
-
constructor(algorithm?: CanonicalizationAlgorithm);
|
|
16
|
-
/**
|
|
17
|
-
* Gets the canonicalization algorithm.
|
|
18
|
-
* @returns {CanonicalizationAlgorithm} The current canonicalization algorithm.
|
|
19
|
-
*/
|
|
20
|
-
get algorithm(): CanonicalizationAlgorithm;
|
|
21
14
|
/**
|
|
22
15
|
* Normalizes the canonicalization algorithm.
|
|
23
16
|
* @param {CanonicalizationAlgorithm} algorithm
|
|
@@ -45,32 +38,28 @@ export declare class Canonicalization {
|
|
|
45
38
|
* @param {Object} [options] Options for processing.
|
|
46
39
|
* @param {CanonicalizationEncoding} [options.encoding='hex'] The encoding format ('hex' or 'base58').
|
|
47
40
|
* @param {CanonicalizationAlgorithm} [options.algorithm] The canonicalization algorithm to use.
|
|
48
|
-
* @returns {
|
|
41
|
+
* @returns {string} The final SHA-256 hash bytes as a hex string.
|
|
49
42
|
*/
|
|
50
|
-
process(object: Record<any, any>, options?:
|
|
51
|
-
encoding?: CanonicalizationEncoding;
|
|
52
|
-
algorithm?: CanonicalizationAlgorithm;
|
|
53
|
-
multibase?: boolean;
|
|
54
|
-
}): Promise<string>;
|
|
43
|
+
static process(object: Record<any, any>, options?: CanonicalizationOptions): string;
|
|
55
44
|
/**
|
|
56
45
|
* Step 1: Uses this.algorithm to determine the method (JCS).
|
|
57
46
|
* @param {Record<any, any>} object The object to canonicalize.
|
|
58
47
|
* @param {CanonicalizationAlgorithm} [algorithm] The algorithm to use.
|
|
59
|
-
* @returns {
|
|
48
|
+
* @returns {string} The canonicalized object.
|
|
60
49
|
*/
|
|
61
|
-
canonicalize(object: Record<any, any>, algorithm?: CanonicalizationAlgorithm):
|
|
50
|
+
static canonicalize(object: Record<any, any>, algorithm?: CanonicalizationAlgorithm): string;
|
|
62
51
|
/**
|
|
63
52
|
* Step 1: Canonicalizes an object using JCS (JSON Canonicalization Scheme).
|
|
64
53
|
* @param {Record<any, any>} object The object to canonicalize.
|
|
65
54
|
* @returns {string} The canonicalized object.
|
|
66
55
|
*/
|
|
67
|
-
jcs(object: Record<any, any>): string;
|
|
56
|
+
static jcs(object: Record<any, any>): string;
|
|
68
57
|
/**
|
|
69
58
|
* Step 2: SHA-256 hashes a canonicalized object.
|
|
70
59
|
* @param {string} canonicalized The canonicalized object.
|
|
71
60
|
* @returns {HashBytes} The SHA-256 HashBytes (Uint8Array).
|
|
72
61
|
*/
|
|
73
|
-
|
|
62
|
+
static toHash(canonicalized: string): HashBytes;
|
|
74
63
|
/**
|
|
75
64
|
* Step 3: Encodes SHA-256 hashed, canonicalized object as a hex or base58 string.
|
|
76
65
|
* @param {string} canonicalizedhash The canonicalized object to encode.
|
|
@@ -78,38 +67,58 @@ export declare class Canonicalization {
|
|
|
78
67
|
* @throws {CanonicalizationError} If the encoding format is not supported.
|
|
79
68
|
* @returns {string} The encoded string.
|
|
80
69
|
*/
|
|
81
|
-
encode(canonicalizedhash: HashBytes, encoding?: CanonicalizationEncoding
|
|
70
|
+
static encode(canonicalizedhash: HashBytes, encoding?: CanonicalizationEncoding): string;
|
|
71
|
+
/**
|
|
72
|
+
* Decodes SHA-256 hashed, canonicalized object as a hex or base58 string.
|
|
73
|
+
* @param {string} canonicalizedhash The canonicalized object to encode.
|
|
74
|
+
* @param {CanonicalizationEncoding} encoding The encoding format ('hex' or 'base58').
|
|
75
|
+
* @throws {CanonicalizationError} If the encoding format is not supported.
|
|
76
|
+
* @returns {string} The encoded string.
|
|
77
|
+
*/
|
|
78
|
+
static decode(canonicalizedhash: string, encoding?: CanonicalizationEncoding): HashBytes;
|
|
82
79
|
/**
|
|
83
80
|
* Step 3.1: Encodes HashBytes (Uint8Array) to a hex string.
|
|
84
81
|
* @param {HashBytes} hashBytes The hash as a Uint8Array.
|
|
85
82
|
* @returns {string} The hash as a hex string.
|
|
86
83
|
*/
|
|
87
|
-
|
|
84
|
+
static toHex(hashBytes: HashBytes): string;
|
|
85
|
+
/**
|
|
86
|
+
* Decodes a hex string to HashBytes (Uint8Array).
|
|
87
|
+
* @param {HexString} hexString The hash as a hex string.
|
|
88
|
+
* @returns {HashBytes} The hash bytes.
|
|
89
|
+
*/
|
|
90
|
+
static fromHex(hexString: HexString): HashBytes;
|
|
88
91
|
/**
|
|
89
92
|
* Step 3.2: Encodes HashBytes (Uint8Array) to a base58btc string.
|
|
90
93
|
* @param {HashBytes} hashBytes The hash as a Uint8Array.
|
|
91
94
|
* @returns {string} The hash as a hex string.
|
|
92
95
|
*/
|
|
93
|
-
|
|
96
|
+
static toBase58(hashBytes: HashBytes): string;
|
|
97
|
+
/**
|
|
98
|
+
* Decodes a base58 string to HashBytes (Uint8Array).
|
|
99
|
+
* @param {string} b58str The hash as a base58 string.
|
|
100
|
+
* @returns {HashBytes} The hash bytes.
|
|
101
|
+
*/
|
|
102
|
+
static fromBase58(b58str: string): HashBytes;
|
|
94
103
|
/**
|
|
95
104
|
* Canonicalizes an object, hashes it and returns it as hash bytes.
|
|
96
105
|
* Step 1-2: Canonicalize → Hash.
|
|
97
106
|
* @param {Record<any, any>} object The object to process.
|
|
98
107
|
* @returns {Promise<HashBytes>} The final SHA-256 hash bytes.
|
|
99
108
|
*/
|
|
100
|
-
|
|
109
|
+
static andHash(object: Record<any, any>, algorithm?: CanonicalizationAlgorithm): HashBytes;
|
|
101
110
|
/**
|
|
102
111
|
* Computes the SHA-256 hash of a canonicalized object and encodes it as a hex string.
|
|
103
112
|
* Step 2-3: Hash → Encode(Hex).
|
|
104
113
|
* @param {string} canonicalized The canonicalized object to hash.
|
|
105
114
|
* @returns {string} The SHA-256 hash as a hex string.
|
|
106
115
|
*/
|
|
107
|
-
|
|
116
|
+
static andHashToHex(canonicalized: string): string;
|
|
108
117
|
/**
|
|
109
118
|
* Computes the SHA-256 hashes of canonicalized object and encodes it as a base58 string.
|
|
110
119
|
* Step 2-3: Hash → Encode(base58).
|
|
111
120
|
* @param {string} canonicalized The canonicalized object to hash.
|
|
112
121
|
* @returns {string} The SHA-256 hash as a base58 string.
|
|
113
122
|
*/
|
|
114
|
-
|
|
123
|
+
static andHashToBase58(canonicalized: string): string;
|
|
115
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonicalization.d.ts","sourceRoot":"","sources":["../../src/canonicalization.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"canonicalization.d.ts","sourceRoot":"","sources":["../../src/canonicalization.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvG,MAAM,WAAW,uBAAuB;IACtC,SAAS,CAAC,EAAE,yBAAyB,CAAC;IACtC,QAAQ,CAAC,EAAE,wBAAwB,CAAC;CACrC;AAED;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B;;;;;OAKG;IACH,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAE,yBAAyB,GAAG,yBAAyB;IAQ1F;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC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AAM;IASlD;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;CAGtD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Bytes, HashHex } from './types.js';
|
|
2
|
-
export declare const ID_PLACEHOLDER_VALUE = "did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
|
3
2
|
export declare const OP_RETURN = 106;
|
|
4
3
|
export declare const OP_PUSH32 = 32;
|
|
5
4
|
export declare const VALID_HRP: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,SAAS,MAAO,CAAC;AAC9B,eAAO,MAAM,SAAS,KAAO,CAAC;AAC9B,eAAO,MAAM,SAAS,UAAa,CAAC;AACpC,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,oBAAoB;;;;;;CAMhC,CAAC;AACF,eAAO,MAAM,mBAAmB;;CAAoC,CAAC;AACrE,eAAO,MAAM,kBAAkB;;;;;;CAAuB,CAAC;AACvD,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,oBAAoB,CAOjE;AAGD,eAAO,MAAM,kCAAkC,EAAE,KAAoC,CAAC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