@did-btcr2/common 1.1.0
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/LICENSE +373 -0
- package/README.md +3 -0
- package/dist/cjs/canonicalization.js +163 -0
- package/dist/cjs/canonicalization.js.map +1 -0
- package/dist/cjs/constants.js +116 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/errors.js +151 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/exts.js +182 -0
- package/dist/cjs/exts.js.map +1 -0
- package/dist/cjs/index.js +10 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces.js +2 -0
- package/dist/cjs/interfaces.js.map +1 -0
- package/dist/cjs/logger.browser.js +77 -0
- package/dist/cjs/logger.browser.js.map +1 -0
- package/dist/cjs/logger.js +139 -0
- package/dist/cjs/logger.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/patch.js +163 -0
- package/dist/cjs/patch.js.map +1 -0
- package/dist/cjs/types.js +20 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/canonicalization.js +163 -0
- package/dist/esm/canonicalization.js.map +1 -0
- package/dist/esm/constants.js +116 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/errors.js +151 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/exts.js +182 -0
- package/dist/esm/exts.js.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces.js +2 -0
- package/dist/esm/interfaces.js.map +1 -0
- package/dist/esm/logger.browser.js +77 -0
- package/dist/esm/logger.browser.js.map +1 -0
- package/dist/esm/logger.js +139 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/patch.js +163 -0
- package/dist/esm/patch.js.map +1 -0
- package/dist/esm/types.js +20 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/canonicalization.d.ts +106 -0
- package/dist/types/canonicalization.d.ts.map +1 -0
- package/dist/types/constants.d.ts +103 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/errors.d.ts +113 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/exts.d.ts +82 -0
- package/dist/types/exts.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interfaces.d.ts +282 -0
- package/dist/types/interfaces.d.ts.map +1 -0
- package/dist/types/logger.browser.d.ts +28 -0
- package/dist/types/logger.browser.d.ts.map +1 -0
- package/dist/types/logger.d.ts +45 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/patch.d.ts +63 -0
- package/dist/types/patch.d.ts.map +1 -0
- package/dist/types/types.d.ts +104 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +109 -0
- package/src/canonicalization.ts +180 -0
- package/src/constants.ts +123 -0
- package/src/errors.ts +224 -0
- package/src/exts.ts +293 -0
- package/src/index.ts +11 -0
- package/src/interfaces.ts +311 -0
- package/src/logger.browser.ts +92 -0
- package/src/logger.ts +162 -0
- package/src/patch.ts +181 -0
- package/src/rdf-canonize.d.ts +6 -0
- package/src/types.ts +113 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Btc1Error } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Implementation of {@link https://datatracker.ietf.org/doc/html/rfc6902 | IETF RFC 6902 JSON Patch}.
|
|
4
|
+
*
|
|
5
|
+
* JavaScript Object Notation (JSON) Patch defines a JSON document structure for expressing a sequence of operations to
|
|
6
|
+
* apply to a JavaScript Object Notation (JSON) document; it is suitable for use with the HTTP PATCH method. The
|
|
7
|
+
* "application/json-patch+json" media type is used to identify such patch documents.
|
|
8
|
+
*
|
|
9
|
+
* @class Patch
|
|
10
|
+
* @type {Patch}
|
|
11
|
+
*/
|
|
12
|
+
export class Patch {
|
|
13
|
+
/**
|
|
14
|
+
* Applies a JSON Patch to a source document and returns the patched document.
|
|
15
|
+
* @param {JSONObject} sourceDocument The source document to patch.
|
|
16
|
+
* @param {PatchOperation[]} operations The JSON Patch operations to apply.
|
|
17
|
+
* @returns {JSONObject} The patched document.
|
|
18
|
+
* @throws {Error} If an unsupported operation is provided.
|
|
19
|
+
*/
|
|
20
|
+
apply(sourceDocument, operations) {
|
|
21
|
+
const patchedDocument = JSON.normalize(sourceDocument);
|
|
22
|
+
for (const operation of operations) {
|
|
23
|
+
const { op, path, value, from } = operation;
|
|
24
|
+
const segments = path.split('/').slice(1);
|
|
25
|
+
switch (op) {
|
|
26
|
+
case 'add':
|
|
27
|
+
this.setValue(patchedDocument, segments, value);
|
|
28
|
+
break;
|
|
29
|
+
case 'remove':
|
|
30
|
+
this.removeValue(patchedDocument, segments);
|
|
31
|
+
break;
|
|
32
|
+
case 'replace':
|
|
33
|
+
this.setValue(patchedDocument, segments, value);
|
|
34
|
+
break;
|
|
35
|
+
case 'move': {
|
|
36
|
+
if (!from)
|
|
37
|
+
throw new Error('Missing \'from\' in move operation');
|
|
38
|
+
const fromSegments = from.split('/').slice(1);
|
|
39
|
+
const movedValue = this.getValue(patchedDocument, fromSegments);
|
|
40
|
+
this.removeValue(patchedDocument, fromSegments);
|
|
41
|
+
this.setValue(patchedDocument, segments, movedValue);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case 'copy': {
|
|
45
|
+
if (!from)
|
|
46
|
+
throw new Error('Missing \'from\' in copy operation');
|
|
47
|
+
const copiedValue = this.getValue(patchedDocument, from.split('/').slice(1));
|
|
48
|
+
this.setValue(patchedDocument, segments, copiedValue);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case 'test': {
|
|
52
|
+
const existingValue = this.getValue(patchedDocument, segments);
|
|
53
|
+
if (JSON.stringify(existingValue) !== JSON.stringify(value)) {
|
|
54
|
+
throw new Btc1Error(`Test operation failed at path`, 'JSON_PATCH_APPLY_ERROR', { path });
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
default:
|
|
59
|
+
throw new Btc1Error(`Unsupported JSON Patch operation`, 'JSON_PATCH_APPLY_ERROR', { op });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return patchedDocument;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Constructs a JSON Patch with a single operation (e.g. add service).
|
|
66
|
+
* @param {PatchOperation} patches - The patch operation to create.
|
|
67
|
+
* @param {string} patch.op - The patch operation type (e.g. 'add').
|
|
68
|
+
* @param {string} patch.path - The JSON Pointer path to apply the operation.
|
|
69
|
+
* @param {*} patch.value - The value to apply (if applicable).
|
|
70
|
+
* @returns {PatchOperation[]} A single-entry JSON Patch array.
|
|
71
|
+
*/
|
|
72
|
+
create(patches) {
|
|
73
|
+
return patches.map(({ op, path, value, from }) => {
|
|
74
|
+
const operation = { op, path };
|
|
75
|
+
if (value !== undefined) {
|
|
76
|
+
operation.value = value;
|
|
77
|
+
}
|
|
78
|
+
if (from !== undefined) {
|
|
79
|
+
operation.from = from;
|
|
80
|
+
}
|
|
81
|
+
return operation;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Find the diff between a source and target document constructing the patch operations from source => target.
|
|
86
|
+
* @param {JSONObject} sourceDocument The original JSON object.
|
|
87
|
+
* @param {JSONObject} targetDocument The target JSON object to transform into.
|
|
88
|
+
* @returns {PatchOperation[]} An array of JSON Patch operations.
|
|
89
|
+
*/
|
|
90
|
+
diff(sourceDocument, targetDocument, path) {
|
|
91
|
+
const operations = [];
|
|
92
|
+
const sourceKeys = new Set(Object.keys(sourceDocument || {}));
|
|
93
|
+
const targetKeys = new Set(Object.keys(targetDocument || {}));
|
|
94
|
+
// Handle removed keys
|
|
95
|
+
for (const key of sourceKeys) {
|
|
96
|
+
if (!targetKeys.has(key)) {
|
|
97
|
+
operations.push({ op: 'remove', path: `${path}/${key}` });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Handle added or updated keys
|
|
101
|
+
for (const key of targetKeys) {
|
|
102
|
+
const sourceVal = sourceDocument?.[key];
|
|
103
|
+
const targetVal = targetDocument?.[key];
|
|
104
|
+
const currentPath = `${path}/${key}`;
|
|
105
|
+
if (!(key in (sourceDocument || {}))) {
|
|
106
|
+
operations.push({ op: 'add', path: currentPath, value: targetVal });
|
|
107
|
+
}
|
|
108
|
+
else if (typeof sourceVal === 'object' && sourceVal !== null && typeof targetVal === 'object' && targetVal !== null) {
|
|
109
|
+
operations.push(...this.diff(sourceVal, targetVal, currentPath));
|
|
110
|
+
}
|
|
111
|
+
else if (JSON.stringify(sourceVal) !== JSON.stringify(targetVal)) {
|
|
112
|
+
operations.push({ op: 'replace', path: currentPath, value: targetVal });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return operations;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Gets the value at a given path in an object.
|
|
119
|
+
* @private
|
|
120
|
+
* @param {*} obj The object to get the value from.
|
|
121
|
+
* @param {string[]} path The path to the value.
|
|
122
|
+
* @returns {*} The value at the given path.
|
|
123
|
+
*/
|
|
124
|
+
getValue(obj, path) {
|
|
125
|
+
return path.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), obj);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Sets the value at a given path in an object.
|
|
129
|
+
* @private
|
|
130
|
+
* @param {*} obj The object to set the value in.
|
|
131
|
+
* @param {string[]} path The path to the value.
|
|
132
|
+
* @param {*} value The value to set.
|
|
133
|
+
* @returns {*} The object with the value set.
|
|
134
|
+
*/
|
|
135
|
+
setValue(obj, path, value) {
|
|
136
|
+
let current = obj;
|
|
137
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
138
|
+
const key = path[i];
|
|
139
|
+
if (!(key in current))
|
|
140
|
+
current[key] = {};
|
|
141
|
+
current = current[key];
|
|
142
|
+
}
|
|
143
|
+
current[path[path.length - 1]] = value;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Removes the value at a given path in an object.
|
|
147
|
+
* @private
|
|
148
|
+
* @param {*} obj The object to remove the value from.
|
|
149
|
+
* @param {string[]} path The path to the value.
|
|
150
|
+
* @returns {*} The object with the value removed.
|
|
151
|
+
*/
|
|
152
|
+
removeValue(obj, path) {
|
|
153
|
+
let current = obj;
|
|
154
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
155
|
+
const key = path[i];
|
|
156
|
+
if (!(key in current))
|
|
157
|
+
return;
|
|
158
|
+
current = current[key];
|
|
159
|
+
}
|
|
160
|
+
delete current[path[path.length - 1]];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=patch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../src/patch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;GASG;AACH,MAAM,OAAO,KAAK;IAChB;;;;;;OAMG;IACI,KAAK,CAAC,cAA0B,EAAE,UAA4B;QACnE,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAEvD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;YAE5C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAE1C,QAAQ,EAAE,EAAE,CAAC;gBACX,KAAK,KAAK;oBACR,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;oBAChD,MAAM;gBAER,KAAK,QAAQ;oBACX,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;oBAC5C,MAAM;gBAER,KAAK,SAAS;oBACZ,IAAI,CAAC,QA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";
|
|
5
|
+
})(Btc1IdentifierTypes || (Btc1IdentifierTypes = {}));
|
|
6
|
+
export var Btc1IdentifierHrp;
|
|
7
|
+
(function (Btc1IdentifierHrp) {
|
|
8
|
+
Btc1IdentifierHrp["k"] = "k";
|
|
9
|
+
Btc1IdentifierHrp["x"] = "x";
|
|
10
|
+
})(Btc1IdentifierHrp || (Btc1IdentifierHrp = {}));
|
|
11
|
+
export var BitcoinNetworkNames;
|
|
12
|
+
(function (BitcoinNetworkNames) {
|
|
13
|
+
BitcoinNetworkNames[BitcoinNetworkNames["bitcoin"] = 0] = "bitcoin";
|
|
14
|
+
BitcoinNetworkNames[BitcoinNetworkNames["signet"] = 1] = "signet";
|
|
15
|
+
BitcoinNetworkNames[BitcoinNetworkNames["regtest"] = 2] = "regtest";
|
|
16
|
+
BitcoinNetworkNames[BitcoinNetworkNames["testnet3"] = 3] = "testnet3";
|
|
17
|
+
BitcoinNetworkNames[BitcoinNetworkNames["testnet4"] = 4] = "testnet4";
|
|
18
|
+
BitcoinNetworkNames[BitcoinNetworkNames["mutinynet"] = 5] = "mutinynet";
|
|
19
|
+
})(BitcoinNetworkNames || (BitcoinNetworkNames = {}));
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAsEA,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC3B,kCAAW,CAAA;IACX,4CAAqB,CAAA;AACzB,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B;AACD,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IACzB,4BAAO,CAAA;IACP,4BAAO,CAAA;AACX,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;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"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { sha256 } from '@noble/hashes/sha2';
|
|
2
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
3
|
+
import { canonicalize as jcsa } from 'json-canonicalize';
|
|
4
|
+
import { base58btc } from 'multiformats/bases/base58';
|
|
5
|
+
import rdf from 'rdf-canonize';
|
|
6
|
+
import { CanonicalizationError } from './errors.js';
|
|
7
|
+
/**
|
|
8
|
+
* Canonicalization class provides methods for canonicalizing JSON objects
|
|
9
|
+
* and hashing them using SHA-256. It supports different canonicalization
|
|
10
|
+
* algorithms and encoding formats (hex and base58).
|
|
11
|
+
* @class Canonicalization
|
|
12
|
+
* @type {Canonicalization}
|
|
13
|
+
*/
|
|
14
|
+
export class Canonicalization {
|
|
15
|
+
_algorithm;
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the Canonicalization class with the specified algorithm.
|
|
18
|
+
* @param {CanonicalizationAlgorithm} algorithm The canonicalization algorithm to use ('jcs' or 'rdfc').
|
|
19
|
+
*/
|
|
20
|
+
// TODO: Need to move to using RDFC by default
|
|
21
|
+
constructor(algorithm = 'jcs') {
|
|
22
|
+
this._algorithm = algorithm;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Sets the canonicalization algorithm.
|
|
26
|
+
* @param {'jcs' | 'rdfc'} algorithm Either 'jcs' or 'rdfc'.
|
|
27
|
+
*/
|
|
28
|
+
set algorithm(algorithm) {
|
|
29
|
+
// Normalize the passed algorithm to lowercase
|
|
30
|
+
algorithm = algorithm.toLowerCase();
|
|
31
|
+
// Validate the algorithm is either 'jcs' or 'rdfc'
|
|
32
|
+
if (!['jcs', 'rdfc'].includes(algorithm)) {
|
|
33
|
+
throw new CanonicalizationError(`Unsupported algorithm: ${algorithm}`, 'ALGORITHM_ERROR');
|
|
34
|
+
}
|
|
35
|
+
// Set the algorithm
|
|
36
|
+
this._algorithm = algorithm;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets the canonicalization algorithm.
|
|
40
|
+
* @returns {CanonicalizationAlgorithm} The current canonicalization algorithm.
|
|
41
|
+
*/
|
|
42
|
+
get algorithm() {
|
|
43
|
+
return this._algorithm;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Implements {@link http://dcdpr.github.io/did-btcr2/#json-canonicalization-and-hash | 9.2 JSON Canonicalization and Hash}.
|
|
47
|
+
*
|
|
48
|
+
* A macro function that takes in a JSON document, document, and canonicalizes it following the JSON Canonicalization
|
|
49
|
+
* Scheme. The function returns the canonicalizedBytes.
|
|
50
|
+
*
|
|
51
|
+
* Optionally encodes a sha256 hashed canonicalized JSON object.
|
|
52
|
+
* Step 1 Canonicalize (JCS/RDFC) → Step 2 Hash (SHA256) → Step 3 Encode (Hex/Base58).
|
|
53
|
+
*
|
|
54
|
+
* @param {JSONObject} object The object to process.
|
|
55
|
+
* @param {string} encoding The encoding format ('hex' or 'base58').
|
|
56
|
+
* @returns {Promise<string>} The final SHA-256 hash bytes as a hex string.
|
|
57
|
+
*/
|
|
58
|
+
async process(object, encoding = 'hex') {
|
|
59
|
+
// Step 1: Canonicalize
|
|
60
|
+
const canonicalized = await this.canonicalize(object);
|
|
61
|
+
// Step 2: Hash
|
|
62
|
+
const hashed = this.hash(canonicalized);
|
|
63
|
+
// Step 3: Encode
|
|
64
|
+
const encoded = this.encode(hashed, encoding);
|
|
65
|
+
// Return the encoded string
|
|
66
|
+
return encoded;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Step 1: Uses this.algorithm to determine the method (JCS/RDFC).
|
|
70
|
+
* @param {JSONObject} object The object to canonicalize.
|
|
71
|
+
* @returns {Promise<string>} The canonicalized object.
|
|
72
|
+
*/
|
|
73
|
+
async canonicalize(object) {
|
|
74
|
+
return await this[this.algorithm](object);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Step 1: Canonicalizes an object using JCS (JSON Canonicalization Scheme).
|
|
78
|
+
* @param {JSONObject} object The object to canonicalize.
|
|
79
|
+
* @returns {string} The canonicalized object.
|
|
80
|
+
*/
|
|
81
|
+
jcs(object) {
|
|
82
|
+
return jcsa(object);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Step 1: Canonicalizes an object using RDF Canonicalization (RDFC).
|
|
86
|
+
* @param {JSONObject} object The object to canonicalize.
|
|
87
|
+
* @returns {Promise<string>} The canonicalized object.
|
|
88
|
+
*/
|
|
89
|
+
rdfc(object) {
|
|
90
|
+
return rdf.canonize([object], { algorithm: 'RDFC-1.0' });
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Step 2: SHA-256 hashes a canonicalized object.
|
|
94
|
+
* @param {string} canonicalized The canonicalized object.
|
|
95
|
+
* @returns {HashBytes} The SHA-256 HashBytes (Uint8Array).
|
|
96
|
+
*/
|
|
97
|
+
hash(canonicalized) {
|
|
98
|
+
return sha256(canonicalized);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Step 3: Encodes SHA-256 hashed, canonicalized object as a hex or base58 string.
|
|
102
|
+
* @param {string} canonicalizedhash The canonicalized object to encode.
|
|
103
|
+
* @param {string} encoding The encoding format ('hex' or 'base58').
|
|
104
|
+
* @throws {CanonicalizationError} If the encoding format is not supported.
|
|
105
|
+
* @returns {string} The encoded string.
|
|
106
|
+
*/
|
|
107
|
+
encode(canonicalizedhash, encoding = 'hex') {
|
|
108
|
+
switch (encoding) {
|
|
109
|
+
case 'hex':
|
|
110
|
+
return this.hex(canonicalizedhash);
|
|
111
|
+
case 'base58':
|
|
112
|
+
return this.base58(canonicalizedhash);
|
|
113
|
+
default:
|
|
114
|
+
throw new CanonicalizationError(`Unsupported encoding: ${encoding}`, 'ENCODING_ERROR');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Step 3.1: Encodes HashBytes (Uint8Array) to a hex string.
|
|
119
|
+
* @param {HashBytes} hashBytes The hash as a Uint8Array.
|
|
120
|
+
* @returns {string} The hash as a hex string.
|
|
121
|
+
*/
|
|
122
|
+
hex(hashBytes) {
|
|
123
|
+
return bytesToHex(hashBytes);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Step 3.2: Encodes HashBytes (Uint8Array) to a base58btc string.
|
|
127
|
+
* @param {HashBytes} hashBytes The hash as a Uint8Array.
|
|
128
|
+
* @returns {string} The hash as a hex string.
|
|
129
|
+
*/
|
|
130
|
+
base58(hashBytes) {
|
|
131
|
+
return base58btc.encode(hashBytes);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Canonicalizes an object, hashes it and returns it as hash bytes.
|
|
135
|
+
* Step 1-2: Canonicalize → Hash.
|
|
136
|
+
* @param {JSONObject} object The object to process.
|
|
137
|
+
* @returns {Promise<HashBytes>} The final SHA-256 hash bytes.
|
|
138
|
+
*/
|
|
139
|
+
async canonicalhash(object) {
|
|
140
|
+
const canonicalized = await this.canonicalize(object);
|
|
141
|
+
return this.hash(canonicalized);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Computes the SHA-256 hash of a canonicalized object and encodes it as a hex string.
|
|
145
|
+
* Step 2-3: Hash → Encode(Hex).
|
|
146
|
+
* @param {string} canonicalized The canonicalized object to hash.
|
|
147
|
+
* @returns {string} The SHA-256 hash as a hex string.
|
|
148
|
+
*/
|
|
149
|
+
hashhex(canonicalized) {
|
|
150
|
+
return this.encode(this.hash(canonicalized));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Computes the SHA-256 hashes of canonicalized object and encodes it as a base58 string.
|
|
154
|
+
* Step 2-3: Hash → Encode(base58).
|
|
155
|
+
* @param {string} canonicalized The canonicalized object to hash.
|
|
156
|
+
* @returns {string} The SHA-256 hash as a base58 string.
|
|
157
|
+
*/
|
|
158
|
+
hashb58(canonicalized) {
|
|
159
|
+
return this.encode(this.hash(canonicalized), 'base58');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export const canonicalization = new Canonicalization();
|
|
163
|
+
//# sourceMappingURL=canonicalization.js.map
|
|
@@ -0,0 +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;AACjD,OAAO,EAAE,YAAY,IAAI,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,GAAG,MAAM,cAAc,CAAC;AAE/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACnB,UAAU,CAA4B;IAE9C;;;OAGG;IACH,8CAA8C;IAC9C,YAAY,YAAuC,KAAK;QACtD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS,CAAC,SAAyB;QACrC,8CAA8C;QAC9C,SAAS,GAAG,SAAS,CAAC,WAAW,EAA+B,CAAC;QAEjE,mDAAmD;QACnD,IAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAC,CAAC;YACvC,MAAM,IAAI,qBAAqB,CAAC,0BAA0B,SAAS,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAC5F,CAAC;QACD,oBAAoB;QACpB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,KAAK,C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AoB;QAC7B,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,SAAoB;QAChC,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CAAC,MAAkB;QAC3C,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,aAAqB;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,aAAqB;QAClC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC;IACzD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { sha256 } from '@noble/hashes/sha2';
|
|
2
|
+
export const ID_PLACEHOLDER_VALUE = 'did:btcr2:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
|
|
3
|
+
export const OP_RETURN = 0x6a;
|
|
4
|
+
export const OP_PUSH32 = 0x20;
|
|
5
|
+
export const VALID_HRP = ['k', 'x'];
|
|
6
|
+
export const MULTIBASE_URI_PREFIX = 'urn:mb:';
|
|
7
|
+
export const INITIAL_BLOCK_REWARD = 50;
|
|
8
|
+
export const HALVING_INTERVAL = 150;
|
|
9
|
+
export const COINBASE_MATURITY_DELAY = 100;
|
|
10
|
+
export const POLAR_BOB_CLIENT_CONFIG = {
|
|
11
|
+
username: 'polaruser',
|
|
12
|
+
password: 'polarpass',
|
|
13
|
+
host: 'http://127.0.0.1:18443',
|
|
14
|
+
allowDefaultWallet: true,
|
|
15
|
+
version: '28.1.0'
|
|
16
|
+
};
|
|
17
|
+
export const POLAR_ALICE_CLIENT_CONFIG = {
|
|
18
|
+
username: 'polaruser',
|
|
19
|
+
password: 'polarpass',
|
|
20
|
+
host: 'http://127.0.0.1:18444',
|
|
21
|
+
allowDefaultWallet: true,
|
|
22
|
+
version: '28.1.0'
|
|
23
|
+
};
|
|
24
|
+
export const DEFAULT_REST_CONFIG = { host: 'http://localhost:3000' };
|
|
25
|
+
export const DEFAULT_RPC_CONFIG = POLAR_BOB_CLIENT_CONFIG;
|
|
26
|
+
export const DEFAULT_BLOCK_CONFIRMATIONS = 7;
|
|
27
|
+
// Fixed public key header bytes per the Data Integrity BIP340 Cryptosuite spec: [0xe7, 0x01] / [231, 1]
|
|
28
|
+
export const BIP340_PUBLIC_KEY_MULTIBASE_PREFIX = new Uint8Array([0xe7, 0x01]);
|
|
29
|
+
// Hash of the BIP-340 Multikey prefix
|
|
30
|
+
export const BIP340_PUBLIC_KEY_MULTIBASE_PREFIX_HASH = Buffer.from(sha256(BIP340_PUBLIC_KEY_MULTIBASE_PREFIX)).toString('hex');
|
|
31
|
+
// Fixed secret key header bytes per the Data Integrity BIP340 Cryptosuite spec: [0x81, 0x26] / [129, 38]
|
|
32
|
+
export const BIP340_SECRET_KEY_MULTIBASE_PREFIX = new Uint8Array([0x81, 0x26]);
|
|
33
|
+
// Hash of the BIP-340 Multikey prefix
|
|
34
|
+
export const BIP340_SECRET_KEY_MULTIBASE_PREFIX_HASH = Buffer.from(sha256(BIP340_SECRET_KEY_MULTIBASE_PREFIX)).toString('hex');
|
|
35
|
+
// curve's field size
|
|
36
|
+
export const B256 = 2n ** 256n;
|
|
37
|
+
// curve's field prime
|
|
38
|
+
export const P = B256 - 0x1000003d1n;
|
|
39
|
+
// curve (group) order
|
|
40
|
+
export const N = B256 - 0x14551231950b75fc4402da1732fc9bebfn;
|
|
41
|
+
// base point x
|
|
42
|
+
export const Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n;
|
|
43
|
+
// base point y
|
|
44
|
+
export const Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;
|
|
45
|
+
// curve parameters
|
|
46
|
+
export const a = 0n;
|
|
47
|
+
export const b = 7n;
|
|
48
|
+
export const p = P;
|
|
49
|
+
export const n = N;
|
|
50
|
+
export const CURVE = {
|
|
51
|
+
p,
|
|
52
|
+
n,
|
|
53
|
+
a,
|
|
54
|
+
b,
|
|
55
|
+
Gx,
|
|
56
|
+
Gy
|
|
57
|
+
};
|
|
58
|
+
export const W3C_DID_V1 = 'https://www.w3.org/ns/did/v1';
|
|
59
|
+
export const W3C_DID_V1_1 = 'https://www.w3.org/TR/did-1.1';
|
|
60
|
+
export const W3C_DATA_INTEGRITY_V1 = 'https://w3id.org/security/data-integrity/v1';
|
|
61
|
+
export const W3C_DATA_INTEGRITY_V2 = 'https://w3id.org/security/data-integrity/v2';
|
|
62
|
+
export const W3C_SECURITY_V2 = 'https://w3id.org/security/v2';
|
|
63
|
+
export const BTC1_METHOD_CONTEXT = 'https://btcr2.dev/context/v1';
|
|
64
|
+
export const W3C_ZCAP_V1 = 'https://w3id.org/zcap/v1';
|
|
65
|
+
export const W3C_JSONLD_PATCH_V1 = 'https://w3id.org/json-ld-patch/v1';
|
|
66
|
+
export const W3C_MULTIKEY_V1 = 'https://w3id.org/security/multikey/v1';
|
|
67
|
+
export const W3C_DID_RESOLUTION_V1 = 'https://w3id.org/did-resolution/v1';
|
|
68
|
+
export const CONTEXT_URL_MAP = {
|
|
69
|
+
w3c: {
|
|
70
|
+
did: {
|
|
71
|
+
v1: 'https://www.w3.org/ns/did/v1',
|
|
72
|
+
v1_1: 'https://www.w3.org/TR/did-1.1',
|
|
73
|
+
},
|
|
74
|
+
didresolution: {
|
|
75
|
+
v1: 'https://w3id.org/did-resolution/v1',
|
|
76
|
+
},
|
|
77
|
+
security: {
|
|
78
|
+
v2: 'https://w3id.org/security/v2',
|
|
79
|
+
},
|
|
80
|
+
dataintegrity: {
|
|
81
|
+
v1: 'https://w3id.org/security/data-integrity/v1',
|
|
82
|
+
v2: 'https://w3id.org/security/data-integrity/v2',
|
|
83
|
+
},
|
|
84
|
+
zcap: {
|
|
85
|
+
v1: 'https://w3id.org/zcap/v1',
|
|
86
|
+
},
|
|
87
|
+
jsonldpatch: {
|
|
88
|
+
v1: 'https://w3id.org/json-ld-patch/v1',
|
|
89
|
+
},
|
|
90
|
+
multikey: {
|
|
91
|
+
v1: 'https://w3id.org/security/multikey/v1',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
btcr2: {
|
|
95
|
+
diddocument: {
|
|
96
|
+
v1: 'https://dcdpr.github.io/did-btcr2-js/ns/did-document/v1',
|
|
97
|
+
},
|
|
98
|
+
method: {
|
|
99
|
+
v1: 'https://btcr2.dev/context/v1'
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
export const BTC1_DID_DOCUMENT_CONTEXT = [
|
|
104
|
+
CONTEXT_URL_MAP.w3c.did.v1_1,
|
|
105
|
+
CONTEXT_URL_MAP.btcr2.method.v1,
|
|
106
|
+
];
|
|
107
|
+
export const BTC1_MULTIKEY_CONTEXT = [
|
|
108
|
+
CONTEXT_URL_MAP.w3c.did.v1,
|
|
109
|
+
CONTEXT_URL_MAP.w3c.multikey.v1
|
|
110
|
+
];
|
|
111
|
+
export const BTC1_DID_UPDATE_PAYLOAD_CONTEXT = [
|
|
112
|
+
CONTEXT_URL_MAP.w3c.security.v2,
|
|
113
|
+
CONTEXT_URL_MAP.w3c.zcap.v1,
|
|
114
|
+
CONTEXT_URL_MAP.w3c.jsonldpatch.v1,
|
|
115
|
+
];
|
|
116
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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C,MAAM,+BAA+B,GAAG;IAC7C,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"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An enumeration of possible DID error codes.
|
|
3
|
+
*/
|
|
4
|
+
export var Btc1ErrorCode;
|
|
5
|
+
(function (Btc1ErrorCode) {
|
|
6
|
+
/** The DID supplied does not conform to valid syntax. */
|
|
7
|
+
Btc1ErrorCode["INVALID_DID"] = "INVALID_DID";
|
|
8
|
+
/** The supplied method name is not supported by the DID method and/or DID resolver implementation. */
|
|
9
|
+
Btc1ErrorCode["METHOD_NOT_SUPPORTED"] = "METHOD_NOT_SUPPORTED";
|
|
10
|
+
/** An unexpected error occurred during the requested DID operation. */
|
|
11
|
+
Btc1ErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
|
|
12
|
+
/** The DID document supplied does not conform to valid syntax. */
|
|
13
|
+
Btc1ErrorCode["INVALID_DID_DOCUMENT"] = "INVALID_DID_DOCUMENT";
|
|
14
|
+
/** The DID Update supplied does not conform to valid syntax. */
|
|
15
|
+
Btc1ErrorCode["INVALID_DID_UPDATE"] = "INVALID_DID_UPDATE";
|
|
16
|
+
/** The byte length of a DID document does not match the expected value. */
|
|
17
|
+
Btc1ErrorCode["INVALID_DID_DOCUMENT_LENGTH"] = "INVALID_DID_DOCUMENT_LENGTH";
|
|
18
|
+
/** The DID URL supplied to the dereferencing function does not conform to valid syntax. */
|
|
19
|
+
Btc1ErrorCode["INVALID_DID_URL"] = "INVALID_DID_URL";
|
|
20
|
+
/** The given proof of a previous DID is invalid */
|
|
21
|
+
Btc1ErrorCode["INVALID_PREVIOUS_DID_PROOF"] = "INVALID_PREVIOUS_DID_PROOF";
|
|
22
|
+
/** An invalid public key is detected during a DID operation. */
|
|
23
|
+
Btc1ErrorCode["INVALID_PUBLIC_KEY"] = "INVALID_PUBLIC_KEY";
|
|
24
|
+
/** An invalid multibase format is detected on the public key during a DID operation. */
|
|
25
|
+
Btc1ErrorCode["INVALID_PUBLIC_KEY_MULTIBASE"] = "INVALID_PUBLIC_KEY_MULTIBASE";
|
|
26
|
+
/** The byte length of a public key does not match the expected value. */
|
|
27
|
+
Btc1ErrorCode["INVALID_PUBLIC_KEY_LENGTH"] = "INVALID_PUBLIC_KEY_LENGTH";
|
|
28
|
+
/** An invalid public key type was detected during a DID operation. */
|
|
29
|
+
Btc1ErrorCode["INVALID_PUBLIC_KEY_TYPE"] = "INVALID_PUBLIC_KEY_TYPE";
|
|
30
|
+
/** Verification of a signature failed during a DID operation. */
|
|
31
|
+
Btc1ErrorCode["INVALID_SIGNATURE"] = "INVALID_SIGNATURE";
|
|
32
|
+
/** General: The resource requested was not found. */
|
|
33
|
+
/** DID Resolution: The DID resolver was unable to find the DID document resulting from the resolution request. */
|
|
34
|
+
Btc1ErrorCode["NOT_FOUND"] = "NOT_FOUND";
|
|
35
|
+
/**
|
|
36
|
+
* The representation requested via the `accept` input metadata property is not supported by the
|
|
37
|
+
* DID method and/or DID resolver implementation.
|
|
38
|
+
*/
|
|
39
|
+
Btc1ErrorCode["REPRESENTATION_NOT_SUPPORTED"] = "REPRESENTATION_NOT_SUPPORTED";
|
|
40
|
+
/** The type of a public key is not supported by the DID method and/or DID resolver implementation. */
|
|
41
|
+
Btc1ErrorCode["UNSUPPORTED_PUBLIC_KEY_TYPE"] = "UNSUPPORTED_PUBLIC_KEY_TYPE";
|
|
42
|
+
/** The proof verification operation failed. */
|
|
43
|
+
Btc1ErrorCode["PROOF_VERIFICATION_ERROR"] = "PROOF_VERIFICATION_ERROR";
|
|
44
|
+
/** The proof generation operation failed. */
|
|
45
|
+
Btc1ErrorCode["PROOF_GENERATION_ERROR"] = "PROOF_GENERATION_ERROR";
|
|
46
|
+
/** The proof serialization operation failed. */
|
|
47
|
+
Btc1ErrorCode["PROOF_SERIALIZATION_ERROR"] = "PROOF_SERIALIZATION_ERROR";
|
|
48
|
+
/** The proof could not be parsed properly. */
|
|
49
|
+
Btc1ErrorCode["PROOF_PARSING_ERROR"] = "PROOF_PARSING_ERROR";
|
|
50
|
+
/** The verification method was formed improperly. */
|
|
51
|
+
Btc1ErrorCode["VERIFICATION_METHOD_ERROR"] = "VERIFICATION_METHOD_ERROR";
|
|
52
|
+
/** Something about the DID Update Payload indicates the potential for late publishing. */
|
|
53
|
+
Btc1ErrorCode["LATE_PUBLISHING_ERROR"] = "LATE_PUBLISHING_ERROR";
|
|
54
|
+
/** The sidecar data in the DID Update Payload was invalid. */
|
|
55
|
+
Btc1ErrorCode["INVALID_SIDECAR_DATA"] = "INVALID_SIDECAR_DATA";
|
|
56
|
+
/** The proof is missing or has a malformed challenge field. */
|
|
57
|
+
Btc1ErrorCode["INVALID_CHALLENGE_ERROR"] = "INVALID_CHALLENGE_ERROR";
|
|
58
|
+
/** The proof is missing or has a malformed domain field. */
|
|
59
|
+
Btc1ErrorCode["INVALID_DOMAIN_ERROR"] = "INVALID_DOMAIN_ERROR";
|
|
60
|
+
})(Btc1ErrorCode || (Btc1ErrorCode = {}));
|
|
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, INVALID_CHALLENGE_ERROR, INVALID_DOMAIN_ERROR } = Btc1ErrorCode;
|
|
62
|
+
export class DidBtc1Error extends Error {
|
|
63
|
+
name = 'DidBtc1Error';
|
|
64
|
+
type = 'DidBtc1Error';
|
|
65
|
+
data;
|
|
66
|
+
constructor(message, options = {}) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.type = options.type ?? this.type;
|
|
69
|
+
this.name = options.name ?? this.name;
|
|
70
|
+
this.data = options.data;
|
|
71
|
+
// Ensures that instanceof works properly, the correct prototype chain when using inheritance,
|
|
72
|
+
// and that V8 stack traces (like Chrome, Edge, and Node.js) are more readable and relevant.
|
|
73
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
74
|
+
// Captures the stack trace in V8 engines (like Chrome, Edge, and Node.js).
|
|
75
|
+
// In non-V8 environments, the stack trace will still be captured.
|
|
76
|
+
if (Error.captureStackTrace) {
|
|
77
|
+
Error.captureStackTrace(this, DidBtc1Error);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export class Btc1Error extends DidBtc1Error {
|
|
82
|
+
constructor(message, type, data) {
|
|
83
|
+
super(message, { type, name: type, data });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export class Btc1ReadError extends DidBtc1Error {
|
|
87
|
+
constructor(message, type = 'Btc1ReadError', data) {
|
|
88
|
+
super(message, { type, name: 'Btc1ReadError', data });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export class Btc1KeyManagerError extends DidBtc1Error {
|
|
92
|
+
constructor(message, type = 'Btc1KeyManagerError', data) {
|
|
93
|
+
super(message, { type, name: type, data });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export class DidDocumentError extends DidBtc1Error {
|
|
97
|
+
constructor(message, type = 'DidDocumentError', data) {
|
|
98
|
+
super(message, { type, name: type, data });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export class CryptosuiteError extends DidBtc1Error {
|
|
102
|
+
constructor(message, type = 'CryptosuiteError', data) {
|
|
103
|
+
super(message, { type, name: type, data });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export class KeyPairError extends DidBtc1Error {
|
|
107
|
+
constructor(message, type = 'KeyPairError', data) {
|
|
108
|
+
super(message, { type, name: type, data });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export class SecretKeyError extends DidBtc1Error {
|
|
112
|
+
constructor(message, type = 'SecretKeyError', data) {
|
|
113
|
+
super(message, { type, name: type, data });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export class PublicKeyError extends DidBtc1Error {
|
|
117
|
+
constructor(message, type = 'PublicKeyError', data) {
|
|
118
|
+
super(message, { type, name: type, data });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export class MultikeyError extends DidBtc1Error {
|
|
122
|
+
constructor(message, type = 'MultikeyError', data) {
|
|
123
|
+
super(message, { type, name: type, data });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export class ProofError extends DidBtc1Error {
|
|
127
|
+
constructor(message, type = 'ProofError', data) {
|
|
128
|
+
super(message, { type, name: type, data });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export class SingletonBeaconError extends DidBtc1Error {
|
|
132
|
+
constructor(message, type = 'SingletonBeaconError', data) {
|
|
133
|
+
super(message, { type, name: type, data });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export class CIDAggregateBeaconError extends DidBtc1Error {
|
|
137
|
+
constructor(message, type = 'CIDAggregateBeaconError', data) {
|
|
138
|
+
super(message, { type, name: type, data });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export class SMTAggregateBeaconError extends DidBtc1Error {
|
|
142
|
+
constructor(message, type = 'SMTAggregateBeaconError', data) {
|
|
143
|
+
super(message, { type, name: type, data });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export class CanonicalizationError extends DidBtc1Error {
|
|
147
|
+
constructor(message, type = 'CanonicalizationError', data) {
|
|
148
|
+
super(message, { type, name: type, data });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,aA+EX;AA/ED,WAAY,aAAa;IACvB,yDAAyD;IACzD,4CAA2B,CAAA;IAE3B,sGAAsG;IACtG,8DAA6C,CAAA;IAE7C,uEAAuE;IACvE,kDAAiC,CAAA;IAEjC,kEAAkE;IAClE,8DAA6C,CAAA;IAE7C,gEAAgE;IAChE,0DAAyC,CAAA;IAEzC,2EAA2E;IAC3E,4EAA2D,CAAA;IAE3D,2FAA2F;IAC3F,oDAAmC,CAAA;IAEnC,mDAAmD;IACnD,0EAAyD,CAAA;IAEzD,gEAAgE;IAChE,0DAAyC,CAAA;IAEzC,wFAAwF;IACxF,8EAA6D,CAAA;IAE7D,yEAAyE;IACzE,wEAAuD,CAAA;IAEvD,sEAAsE;IACtE,oEAAmD,CAAA;IAEnD,iEAAiE;IACjE,wDAAuC,CAAA;IAEvC,qDAAqD;IACrD,mHAAmH;IACnH,wCAAuB,CAAA;IAEvB;;;OAGG;IACH,8EAA6D,CAAA;IAE7D,sGAAsG;IACtG,4EAA2D,CAAA;IAE3D,+CAA+C;IAC/C,sEAAqD,CAAA;IAErD,6CAA6C;IAC7C,kEAAiD,CAAA;IAEjD,gDAAgD;IAChD,wEAAuD,CAAA;IAEvD,8CAA8C;IAC9C,4DAA2C,CAAA;IAE3C,qDAAqD;IACrD,wEAAuD,CAAA;IAExD,0FAA0F;IACzF,gEAA+C,CAAA;IAE/C,8DAA8D;IAC9D,8DAA6C,CAAA;IAE7C,+DAA+D;IAC/D,oEAAmD,CAAA;IAEnD,4DAA4D;IAC5D,8DAA6C,CAAA;AAC/C,CAAC,EA/EW,aAAa,KA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