@twin.org/standards-w3c-did 0.0.2-next.13 → 0.0.2-next.15
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/index.cjs +37 -37
- package/dist/esm/index.mjs +37 -37
- package/dist/types/signerVerifiers/dataIntegrityProofSignerVerifier.d.ts +1 -1
- package/dist/types/signerVerifiers/jsonWebSignature2020SignerVerifier.d.ts +1 -1
- package/docs/changelog.md +14 -0
- package/docs/reference/classes/DataIntegrityProofSignerVerifier.md +1 -1
- package/docs/reference/classes/JsonWebSignature2020SignerVerifier.md +1 -1
- package/locales/en.json +4 -8
- package/package.json +16 -2
package/dist/cjs/index.cjs
CHANGED
|
@@ -156,7 +156,7 @@ class DataIntegrityProofSignerVerifier {
|
|
|
156
156
|
/**
|
|
157
157
|
* Runtime name for the class.
|
|
158
158
|
*/
|
|
159
|
-
CLASS_NAME = "DataIntegrityProofSignerVerifier";
|
|
159
|
+
static CLASS_NAME = "DataIntegrityProofSignerVerifier";
|
|
160
160
|
/**
|
|
161
161
|
* Create a proof for the given data.
|
|
162
162
|
* @param unsecuredDocument The data to create the proof for.
|
|
@@ -165,12 +165,12 @@ class DataIntegrityProofSignerVerifier {
|
|
|
165
165
|
* @returns The created proof.
|
|
166
166
|
*/
|
|
167
167
|
async createProof(unsecuredDocument, unsignedProof, signKey) {
|
|
168
|
-
core.Guards.object(
|
|
169
|
-
core.Guards.object(
|
|
170
|
-
core.Guards.object(
|
|
168
|
+
core.Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
169
|
+
core.Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
170
|
+
core.Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "signKey", signKey);
|
|
171
171
|
const rawKeys = await web.Jwk.toRaw(signKey);
|
|
172
172
|
if (!core.Is.uint8Array(rawKeys.privateKey)) {
|
|
173
|
-
throw new core.GeneralError(
|
|
173
|
+
throw new core.GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, "missingPrivateKey");
|
|
174
174
|
}
|
|
175
175
|
const unsecuredDocumentClone = core.ObjectHelper.clone(unsecuredDocument);
|
|
176
176
|
const signedProof = core.ObjectHelper.clone(unsignedProof);
|
|
@@ -189,13 +189,13 @@ class DataIntegrityProofSignerVerifier {
|
|
|
189
189
|
* @returns True if the credential was verified.
|
|
190
190
|
*/
|
|
191
191
|
async verifyProof(securedDocument, signedProof, verifyKey) {
|
|
192
|
-
core.Guards.object(
|
|
193
|
-
core.Guards.object(
|
|
194
|
-
core.Guards.stringValue(
|
|
195
|
-
core.Guards.object(
|
|
192
|
+
core.Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "securedDocument", securedDocument);
|
|
193
|
+
core.Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "signedProof", signedProof);
|
|
194
|
+
core.Guards.stringValue(DataIntegrityProofSignerVerifier.CLASS_NAME, "signedProof.proofValue", signedProof.proofValue);
|
|
195
|
+
core.Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "verifyKey", verifyKey);
|
|
196
196
|
const rawKeys = await web.Jwk.toRaw(verifyKey);
|
|
197
197
|
if (!core.Is.uint8Array(rawKeys.publicKey)) {
|
|
198
|
-
throw new core.GeneralError(
|
|
198
|
+
throw new core.GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, "missingPublicKey");
|
|
199
199
|
}
|
|
200
200
|
const combinedHash = await this.createHash(securedDocument, signedProof);
|
|
201
201
|
return crypto.Ed25519.verify(rawKeys.publicKey, combinedHash, core.Converter.base58ToBytes(signedProof.proofValue.slice(1)));
|
|
@@ -207,16 +207,16 @@ class DataIntegrityProofSignerVerifier {
|
|
|
207
207
|
* @returns The created hash.
|
|
208
208
|
*/
|
|
209
209
|
async createHash(unsecuredDocument, unsignedProof) {
|
|
210
|
-
core.Guards.object(
|
|
211
|
-
core.Guards.object(
|
|
212
|
-
core.Guards.stringValue(
|
|
213
|
-
core.Guards.stringValue(
|
|
210
|
+
core.Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
211
|
+
core.Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
212
|
+
core.Guards.stringValue(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsignedProof.cryptosuite", unsignedProof.cryptosuite);
|
|
213
|
+
core.Guards.stringValue(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsignedProof.verificationMethod", unsignedProof.verificationMethod);
|
|
214
214
|
const unsecuredDocumentClone = core.ObjectHelper.clone(unsecuredDocument);
|
|
215
215
|
const proofOptionsClone = core.ObjectHelper.clone(unsignedProof);
|
|
216
216
|
delete unsecuredDocumentClone.proof;
|
|
217
217
|
delete proofOptionsClone.proofValue;
|
|
218
218
|
if (proofOptionsClone.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {
|
|
219
|
-
throw new core.GeneralError(
|
|
219
|
+
throw new core.GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, "cryptosuiteNotSupported", {
|
|
220
220
|
cryptoSuite: proofOptionsClone.cryptosuite
|
|
221
221
|
});
|
|
222
222
|
}
|
|
@@ -239,7 +239,7 @@ class JsonWebSignature2020SignerVerifier {
|
|
|
239
239
|
/**
|
|
240
240
|
* Runtime name for the class.
|
|
241
241
|
*/
|
|
242
|
-
CLASS_NAME = "JsonWebSignature2020SignerVerifier";
|
|
242
|
+
static CLASS_NAME = "JsonWebSignature2020SignerVerifier";
|
|
243
243
|
/**
|
|
244
244
|
* Create a proof for the given data.
|
|
245
245
|
* @param unsecuredDocument The data to create the proof for.
|
|
@@ -248,9 +248,9 @@ class JsonWebSignature2020SignerVerifier {
|
|
|
248
248
|
* @returns The created proof.
|
|
249
249
|
*/
|
|
250
250
|
async createProof(unsecuredDocument, unsignedProof, signKey) {
|
|
251
|
-
core.Guards.object(
|
|
252
|
-
core.Guards.object(
|
|
253
|
-
core.Guards.object(
|
|
251
|
+
core.Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
252
|
+
core.Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
253
|
+
core.Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "signKey", signKey);
|
|
254
254
|
const unsecuredDocumentClone = core.ObjectHelper.clone(unsecuredDocument);
|
|
255
255
|
unsecuredDocumentClone["@context"] = dataJsonLd.JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.ContextSecurityJws2020);
|
|
256
256
|
const hash = await this.createHash(unsecuredDocument, unsignedProof);
|
|
@@ -269,12 +269,12 @@ class JsonWebSignature2020SignerVerifier {
|
|
|
269
269
|
* @returns True if the credential was verified.
|
|
270
270
|
*/
|
|
271
271
|
async verifyProof(securedDocument, signedProof, verifyKey) {
|
|
272
|
-
core.Guards.object(
|
|
273
|
-
core.Guards.object(
|
|
274
|
-
core.Guards.object(
|
|
272
|
+
core.Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "securedDocument", securedDocument);
|
|
273
|
+
core.Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "signedProof", signedProof);
|
|
274
|
+
core.Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "verifyKey", verifyKey);
|
|
275
275
|
const jws = signedProof.jws;
|
|
276
276
|
if (!core.Is.stringValue(jws)) {
|
|
277
|
-
throw new core.GeneralError(
|
|
277
|
+
throw new core.GeneralError(JsonWebSignature2020SignerVerifier.CLASS_NAME, "missingJws");
|
|
278
278
|
}
|
|
279
279
|
const hash = await this.createHash(securedDocument, signedProof);
|
|
280
280
|
const cryptoKey = await web.Jwk.toCryptoKey(verifyKey);
|
|
@@ -287,9 +287,9 @@ class JsonWebSignature2020SignerVerifier {
|
|
|
287
287
|
* @returns The created hash.
|
|
288
288
|
*/
|
|
289
289
|
async createHash(unsecuredDocument, unsignedProof) {
|
|
290
|
-
core.Guards.object(
|
|
291
|
-
core.Guards.object(
|
|
292
|
-
core.Guards.stringValue(
|
|
290
|
+
core.Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
291
|
+
core.Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
292
|
+
core.Guards.stringValue(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsignedProof.verificationMethod", unsignedProof.verificationMethod);
|
|
293
293
|
const unsecuredDocumentClone = core.ObjectHelper.clone(unsecuredDocument);
|
|
294
294
|
const proofOptionsClone = core.ObjectHelper.clone(unsignedProof);
|
|
295
295
|
unsecuredDocumentClone["@context"] = dataJsonLd.JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.ContextSecurityJws2020);
|
|
@@ -403,8 +403,8 @@ class MultikeyHelper {
|
|
|
403
403
|
}
|
|
404
404
|
secretKeyRaw = core.Converter.base58ToBytes(multikey.secretKeyMultibase.slice(1));
|
|
405
405
|
if (secretKeyRaw[0] !== 0x80 || secretKeyRaw[1] !== 0x26) {
|
|
406
|
-
throw new core.GeneralError(MultikeyHelper.CLASS_NAME, "
|
|
407
|
-
|
|
406
|
+
throw new core.GeneralError(MultikeyHelper.CLASS_NAME, "secretKeyMultibaseMissingHeader", {
|
|
407
|
+
secretKeyMultibase: multikey.secretKeyMultibase
|
|
408
408
|
});
|
|
409
409
|
}
|
|
410
410
|
}
|
|
@@ -432,7 +432,7 @@ class ProofHelper {
|
|
|
432
432
|
* @throws GeneralError if the proof type is not supported.
|
|
433
433
|
*/
|
|
434
434
|
static createSignerVerifier(proofType) {
|
|
435
|
-
core.Guards.arrayOneOf(
|
|
435
|
+
core.Guards.arrayOneOf(ProofHelper.CLASS_NAME, "proofType", proofType, Object.values(ProofTypes));
|
|
436
436
|
let signerVerifier;
|
|
437
437
|
if (proofType === ProofTypes.DataIntegrityProof) {
|
|
438
438
|
signerVerifier = new DataIntegrityProofSignerVerifier();
|
|
@@ -454,10 +454,10 @@ class ProofHelper {
|
|
|
454
454
|
* @returns The created proof.
|
|
455
455
|
*/
|
|
456
456
|
static async createProof(proofType, unsecuredDocument, unsignedProof, signKey) {
|
|
457
|
-
core.Guards.arrayOneOf(
|
|
458
|
-
core.Guards.object(
|
|
459
|
-
core.Guards.object(
|
|
460
|
-
core.Guards.object(
|
|
457
|
+
core.Guards.arrayOneOf(ProofHelper.CLASS_NAME, "proofType", proofType, Object.values(ProofTypes));
|
|
458
|
+
core.Guards.object(ProofHelper.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
459
|
+
core.Guards.object(ProofHelper.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
460
|
+
core.Guards.object(ProofHelper.CLASS_NAME, "signKey", signKey);
|
|
461
461
|
return ProofHelper.createSignerVerifier(proofType).createProof(unsecuredDocument, unsignedProof, signKey);
|
|
462
462
|
}
|
|
463
463
|
/**
|
|
@@ -468,10 +468,10 @@ class ProofHelper {
|
|
|
468
468
|
* @returns True if the credential was verified.
|
|
469
469
|
*/
|
|
470
470
|
static async verifyProof(securedDocument, signedProof, verifyKey) {
|
|
471
|
-
core.Guards.object(
|
|
472
|
-
core.Guards.object(
|
|
473
|
-
core.Guards.stringValue(
|
|
474
|
-
core.Guards.object(
|
|
471
|
+
core.Guards.object(ProofHelper.CLASS_NAME, "securedDocument", securedDocument);
|
|
472
|
+
core.Guards.object(ProofHelper.CLASS_NAME, "signedProof", signedProof);
|
|
473
|
+
core.Guards.stringValue(ProofHelper.CLASS_NAME, "signedProof.type", signedProof.type);
|
|
474
|
+
core.Guards.object(ProofHelper.CLASS_NAME, "verifyKey", verifyKey);
|
|
475
475
|
const signerVerifier = ProofHelper.createSignerVerifier(signedProof.type);
|
|
476
476
|
return signerVerifier.verifyProof(securedDocument, signedProof, verifyKey);
|
|
477
477
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -154,7 +154,7 @@ class DataIntegrityProofSignerVerifier {
|
|
|
154
154
|
/**
|
|
155
155
|
* Runtime name for the class.
|
|
156
156
|
*/
|
|
157
|
-
CLASS_NAME = "DataIntegrityProofSignerVerifier";
|
|
157
|
+
static CLASS_NAME = "DataIntegrityProofSignerVerifier";
|
|
158
158
|
/**
|
|
159
159
|
* Create a proof for the given data.
|
|
160
160
|
* @param unsecuredDocument The data to create the proof for.
|
|
@@ -163,12 +163,12 @@ class DataIntegrityProofSignerVerifier {
|
|
|
163
163
|
* @returns The created proof.
|
|
164
164
|
*/
|
|
165
165
|
async createProof(unsecuredDocument, unsignedProof, signKey) {
|
|
166
|
-
Guards.object(
|
|
167
|
-
Guards.object(
|
|
168
|
-
Guards.object(
|
|
166
|
+
Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
167
|
+
Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
168
|
+
Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "signKey", signKey);
|
|
169
169
|
const rawKeys = await Jwk.toRaw(signKey);
|
|
170
170
|
if (!Is.uint8Array(rawKeys.privateKey)) {
|
|
171
|
-
throw new GeneralError(
|
|
171
|
+
throw new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, "missingPrivateKey");
|
|
172
172
|
}
|
|
173
173
|
const unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);
|
|
174
174
|
const signedProof = ObjectHelper.clone(unsignedProof);
|
|
@@ -187,13 +187,13 @@ class DataIntegrityProofSignerVerifier {
|
|
|
187
187
|
* @returns True if the credential was verified.
|
|
188
188
|
*/
|
|
189
189
|
async verifyProof(securedDocument, signedProof, verifyKey) {
|
|
190
|
-
Guards.object(
|
|
191
|
-
Guards.object(
|
|
192
|
-
Guards.stringValue(
|
|
193
|
-
Guards.object(
|
|
190
|
+
Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "securedDocument", securedDocument);
|
|
191
|
+
Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "signedProof", signedProof);
|
|
192
|
+
Guards.stringValue(DataIntegrityProofSignerVerifier.CLASS_NAME, "signedProof.proofValue", signedProof.proofValue);
|
|
193
|
+
Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "verifyKey", verifyKey);
|
|
194
194
|
const rawKeys = await Jwk.toRaw(verifyKey);
|
|
195
195
|
if (!Is.uint8Array(rawKeys.publicKey)) {
|
|
196
|
-
throw new GeneralError(
|
|
196
|
+
throw new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, "missingPublicKey");
|
|
197
197
|
}
|
|
198
198
|
const combinedHash = await this.createHash(securedDocument, signedProof);
|
|
199
199
|
return Ed25519.verify(rawKeys.publicKey, combinedHash, Converter.base58ToBytes(signedProof.proofValue.slice(1)));
|
|
@@ -205,16 +205,16 @@ class DataIntegrityProofSignerVerifier {
|
|
|
205
205
|
* @returns The created hash.
|
|
206
206
|
*/
|
|
207
207
|
async createHash(unsecuredDocument, unsignedProof) {
|
|
208
|
-
Guards.object(
|
|
209
|
-
Guards.object(
|
|
210
|
-
Guards.stringValue(
|
|
211
|
-
Guards.stringValue(
|
|
208
|
+
Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
209
|
+
Guards.object(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
210
|
+
Guards.stringValue(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsignedProof.cryptosuite", unsignedProof.cryptosuite);
|
|
211
|
+
Guards.stringValue(DataIntegrityProofSignerVerifier.CLASS_NAME, "unsignedProof.verificationMethod", unsignedProof.verificationMethod);
|
|
212
212
|
const unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);
|
|
213
213
|
const proofOptionsClone = ObjectHelper.clone(unsignedProof);
|
|
214
214
|
delete unsecuredDocumentClone.proof;
|
|
215
215
|
delete proofOptionsClone.proofValue;
|
|
216
216
|
if (proofOptionsClone.cryptosuite !== DidCryptoSuites.EdDSAJcs2022) {
|
|
217
|
-
throw new GeneralError(
|
|
217
|
+
throw new GeneralError(DataIntegrityProofSignerVerifier.CLASS_NAME, "cryptosuiteNotSupported", {
|
|
218
218
|
cryptoSuite: proofOptionsClone.cryptosuite
|
|
219
219
|
});
|
|
220
220
|
}
|
|
@@ -237,7 +237,7 @@ class JsonWebSignature2020SignerVerifier {
|
|
|
237
237
|
/**
|
|
238
238
|
* Runtime name for the class.
|
|
239
239
|
*/
|
|
240
|
-
CLASS_NAME = "JsonWebSignature2020SignerVerifier";
|
|
240
|
+
static CLASS_NAME = "JsonWebSignature2020SignerVerifier";
|
|
241
241
|
/**
|
|
242
242
|
* Create a proof for the given data.
|
|
243
243
|
* @param unsecuredDocument The data to create the proof for.
|
|
@@ -246,9 +246,9 @@ class JsonWebSignature2020SignerVerifier {
|
|
|
246
246
|
* @returns The created proof.
|
|
247
247
|
*/
|
|
248
248
|
async createProof(unsecuredDocument, unsignedProof, signKey) {
|
|
249
|
-
Guards.object(
|
|
250
|
-
Guards.object(
|
|
251
|
-
Guards.object(
|
|
249
|
+
Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
250
|
+
Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
251
|
+
Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "signKey", signKey);
|
|
252
252
|
const unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);
|
|
253
253
|
unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.ContextSecurityJws2020);
|
|
254
254
|
const hash = await this.createHash(unsecuredDocument, unsignedProof);
|
|
@@ -267,12 +267,12 @@ class JsonWebSignature2020SignerVerifier {
|
|
|
267
267
|
* @returns True if the credential was verified.
|
|
268
268
|
*/
|
|
269
269
|
async verifyProof(securedDocument, signedProof, verifyKey) {
|
|
270
|
-
Guards.object(
|
|
271
|
-
Guards.object(
|
|
272
|
-
Guards.object(
|
|
270
|
+
Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "securedDocument", securedDocument);
|
|
271
|
+
Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "signedProof", signedProof);
|
|
272
|
+
Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "verifyKey", verifyKey);
|
|
273
273
|
const jws = signedProof.jws;
|
|
274
274
|
if (!Is.stringValue(jws)) {
|
|
275
|
-
throw new GeneralError(
|
|
275
|
+
throw new GeneralError(JsonWebSignature2020SignerVerifier.CLASS_NAME, "missingJws");
|
|
276
276
|
}
|
|
277
277
|
const hash = await this.createHash(securedDocument, signedProof);
|
|
278
278
|
const cryptoKey = await Jwk.toCryptoKey(verifyKey);
|
|
@@ -285,9 +285,9 @@ class JsonWebSignature2020SignerVerifier {
|
|
|
285
285
|
* @returns The created hash.
|
|
286
286
|
*/
|
|
287
287
|
async createHash(unsecuredDocument, unsignedProof) {
|
|
288
|
-
Guards.object(
|
|
289
|
-
Guards.object(
|
|
290
|
-
Guards.stringValue(
|
|
288
|
+
Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
289
|
+
Guards.object(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
290
|
+
Guards.stringValue(JsonWebSignature2020SignerVerifier.CLASS_NAME, "unsignedProof.verificationMethod", unsignedProof.verificationMethod);
|
|
291
291
|
const unsecuredDocumentClone = ObjectHelper.clone(unsecuredDocument);
|
|
292
292
|
const proofOptionsClone = ObjectHelper.clone(unsignedProof);
|
|
293
293
|
unsecuredDocumentClone["@context"] = JsonLdProcessor.combineContexts(unsecuredDocumentClone["@context"], DidContexts.ContextSecurityJws2020);
|
|
@@ -401,8 +401,8 @@ class MultikeyHelper {
|
|
|
401
401
|
}
|
|
402
402
|
secretKeyRaw = Converter.base58ToBytes(multikey.secretKeyMultibase.slice(1));
|
|
403
403
|
if (secretKeyRaw[0] !== 0x80 || secretKeyRaw[1] !== 0x26) {
|
|
404
|
-
throw new GeneralError(MultikeyHelper.CLASS_NAME, "
|
|
405
|
-
|
|
404
|
+
throw new GeneralError(MultikeyHelper.CLASS_NAME, "secretKeyMultibaseMissingHeader", {
|
|
405
|
+
secretKeyMultibase: multikey.secretKeyMultibase
|
|
406
406
|
});
|
|
407
407
|
}
|
|
408
408
|
}
|
|
@@ -430,7 +430,7 @@ class ProofHelper {
|
|
|
430
430
|
* @throws GeneralError if the proof type is not supported.
|
|
431
431
|
*/
|
|
432
432
|
static createSignerVerifier(proofType) {
|
|
433
|
-
Guards.arrayOneOf(
|
|
433
|
+
Guards.arrayOneOf(ProofHelper.CLASS_NAME, "proofType", proofType, Object.values(ProofTypes));
|
|
434
434
|
let signerVerifier;
|
|
435
435
|
if (proofType === ProofTypes.DataIntegrityProof) {
|
|
436
436
|
signerVerifier = new DataIntegrityProofSignerVerifier();
|
|
@@ -452,10 +452,10 @@ class ProofHelper {
|
|
|
452
452
|
* @returns The created proof.
|
|
453
453
|
*/
|
|
454
454
|
static async createProof(proofType, unsecuredDocument, unsignedProof, signKey) {
|
|
455
|
-
Guards.arrayOneOf(
|
|
456
|
-
Guards.object(
|
|
457
|
-
Guards.object(
|
|
458
|
-
Guards.object(
|
|
455
|
+
Guards.arrayOneOf(ProofHelper.CLASS_NAME, "proofType", proofType, Object.values(ProofTypes));
|
|
456
|
+
Guards.object(ProofHelper.CLASS_NAME, "unsecuredDocument", unsecuredDocument);
|
|
457
|
+
Guards.object(ProofHelper.CLASS_NAME, "unsignedProof", unsignedProof);
|
|
458
|
+
Guards.object(ProofHelper.CLASS_NAME, "signKey", signKey);
|
|
459
459
|
return ProofHelper.createSignerVerifier(proofType).createProof(unsecuredDocument, unsignedProof, signKey);
|
|
460
460
|
}
|
|
461
461
|
/**
|
|
@@ -466,10 +466,10 @@ class ProofHelper {
|
|
|
466
466
|
* @returns True if the credential was verified.
|
|
467
467
|
*/
|
|
468
468
|
static async verifyProof(securedDocument, signedProof, verifyKey) {
|
|
469
|
-
Guards.object(
|
|
470
|
-
Guards.object(
|
|
471
|
-
Guards.stringValue(
|
|
472
|
-
Guards.object(
|
|
469
|
+
Guards.object(ProofHelper.CLASS_NAME, "securedDocument", securedDocument);
|
|
470
|
+
Guards.object(ProofHelper.CLASS_NAME, "signedProof", signedProof);
|
|
471
|
+
Guards.stringValue(ProofHelper.CLASS_NAME, "signedProof.type", signedProof.type);
|
|
472
|
+
Guards.object(ProofHelper.CLASS_NAME, "verifyKey", verifyKey);
|
|
473
473
|
const signerVerifier = ProofHelper.createSignerVerifier(signedProof.type);
|
|
474
474
|
return signerVerifier.verifyProof(securedDocument, signedProof, verifyKey);
|
|
475
475
|
}
|
|
@@ -11,7 +11,7 @@ export declare class DataIntegrityProofSignerVerifier implements IProofSignerVer
|
|
|
11
11
|
/**
|
|
12
12
|
* Runtime name for the class.
|
|
13
13
|
*/
|
|
14
|
-
readonly CLASS_NAME: string;
|
|
14
|
+
static readonly CLASS_NAME: string;
|
|
15
15
|
/**
|
|
16
16
|
* Create a proof for the given data.
|
|
17
17
|
* @param unsecuredDocument The data to create the proof for.
|
|
@@ -9,7 +9,7 @@ export declare class JsonWebSignature2020SignerVerifier implements IProofSignerV
|
|
|
9
9
|
/**
|
|
10
10
|
* Runtime name for the class.
|
|
11
11
|
*/
|
|
12
|
-
readonly CLASS_NAME: string;
|
|
12
|
+
static readonly CLASS_NAME: string;
|
|
13
13
|
/**
|
|
14
14
|
* Create a proof for the given data.
|
|
15
15
|
* @param unsecuredDocument The data to create the proof for.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @twin.org/standards-w3c-did - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.15](https://github.com/twinfoundation/standards/compare/standards-w3c-did-v0.0.2-next.14...standards-w3c-did-v0.0.2-next.15) (2025-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add validate-locales ([838389c](https://github.com/twinfoundation/standards/commit/838389c1daf62ed42397d5758d267c3d1a37fa4d))
|
|
9
|
+
|
|
10
|
+
## [0.0.2-next.14](https://github.com/twinfoundation/standards/compare/standards-w3c-did-v0.0.2-next.13...standards-w3c-did-v0.0.2-next.14) (2025-10-02)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Miscellaneous Chores
|
|
14
|
+
|
|
15
|
+
* **standards-w3c-did:** Synchronize repo versions
|
|
16
|
+
|
|
3
17
|
## [0.0.2-next.13](https://github.com/twinfoundation/standards/compare/standards-w3c-did-v0.0.2-next.12...standards-w3c-did-v0.0.2-next.13) (2025-09-22)
|
|
4
18
|
|
|
5
19
|
|
package/locales/en.json
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"error": {
|
|
3
3
|
"proofHelper": {
|
|
4
|
-
"unsupportedProofType": "Proof type \"{proofType}\" not supported."
|
|
5
|
-
"proofMissing": "Proof is missing."
|
|
4
|
+
"unsupportedProofType": "Proof type \"{proofType}\" not supported."
|
|
6
5
|
},
|
|
7
6
|
"jsonWebSignature2020SignerVerifier": {
|
|
8
|
-
"
|
|
9
|
-
"missingPublicKey": "Public key is missing.",
|
|
10
|
-
"missingProofValue": "Proof value is missing."
|
|
7
|
+
"missingJws": "JWS is missing from proof."
|
|
11
8
|
},
|
|
12
9
|
"dataIntegrityProofSignerVerifier": {
|
|
13
|
-
"cryptosuiteNotSupported": "Cryptosuite \"{
|
|
10
|
+
"cryptosuiteNotSupported": "Cryptosuite \"{cryptoSuite}\" is not supported.",
|
|
14
11
|
"missingPrivateKey": "Private key is missing.",
|
|
15
|
-
"missingPublicKey": "Public key is missing."
|
|
16
|
-
"missingProofValue": "Proof value is missing."
|
|
12
|
+
"missingPublicKey": "Public key is missing."
|
|
17
13
|
},
|
|
18
14
|
"multikeyHelper": {
|
|
19
15
|
"invalidPublicKeyMultibase": "Public key multibase \"{publicKeyMultibase}\" is invalid.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/standards-w3c-did",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.15",
|
|
4
4
|
"description": "Models which define the structure of W3C DID Standard",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,5 +37,19 @@
|
|
|
37
37
|
"dist/types",
|
|
38
38
|
"locales",
|
|
39
39
|
"docs"
|
|
40
|
-
]
|
|
40
|
+
],
|
|
41
|
+
"keywords": [
|
|
42
|
+
"twin",
|
|
43
|
+
"trade",
|
|
44
|
+
"iota",
|
|
45
|
+
"framework",
|
|
46
|
+
"blockchain",
|
|
47
|
+
"standards",
|
|
48
|
+
"schema",
|
|
49
|
+
"specification"
|
|
50
|
+
],
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "git+https://github.com/twinfoundation/standards/issues"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://twindev.org"
|
|
41
55
|
}
|