From ccd6b84ed13381689c4fab00dc459f32e8bc0f10 Mon Sep 17 00:00:00 2001 From: Brian Richter Date: Fri, 25 Oct 2024 11:46:00 -0700 Subject: [PATCH] Allow proof purpose of assertionMethod --- src/assertions.ts | 2 +- src/cryptography.ts | 4 ++-- test/fixtures/not-authorized.log | 4 ++-- test/happy-path.test.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/assertions.ts b/src/assertions.ts index 5da0178..609cd4f 100644 --- a/src/assertions.ts +++ b/src/assertions.ts @@ -45,7 +45,7 @@ export const documentStateIsValid = async (doc: any, updateKeys: string[], witne if (proof.type !== 'DataIntegrityProof') { throw new Error(`Unknown proof type ${proof.type}`); } - if (proof.proofPurpose !== 'authentication') { + if (proof.proofPurpose !== 'authentication' && proof.proofPurpose !== 'assertionMethod') { throw new Error(`Unknown proof purpose ${proof.proofPurpose}`); } if (proof.cryptosuite !== 'eddsa-jcs-2022') { diff --git a/src/cryptography.ts b/src/cryptography.ts index 5921b06..2fddc8c 100644 --- a/src/cryptography.ts +++ b/src/cryptography.ts @@ -14,7 +14,7 @@ export const createSigner = (vm: VerificationMethod, useStatic: boolean = true) cryptosuite: 'eddsa-jcs-2022', verificationMethod: useStatic ? `did:key:${vm.publicKeyMultibase}#${vm.publicKeyMultibase}` : vm.id, created: createDate(), - proofPurpose: 'authentication' + proofPurpose: 'assertionMethod' } const dataHash = createHash('sha256').update(canonicalize(doc)).digest(); const proofHash = createHash('sha256').update(canonicalize(proof)).digest(); @@ -41,7 +41,7 @@ export const generateEd25519VerificationMethod = async (): Promise { didLog = [...updatedLog]; expect(updatedDID).toBe(did); expect(updatedDoc.controller).toContain(externalAuthKey.controller); - expect(updatedDoc.authentication[1]).toContain(externalAuthKey.controller!.slice(-6)); + expect(updatedDoc.assertionMethod[1]).toContain(externalAuthKey.controller!.slice(-6)); expect(updatedDoc.verificationMethod[1].controller).toBe(externalAuthKey.controller); expect(meta.versionId.split('-')[0]).toBe("5");