|
1 | 1 | import type { DidDocument } from '@credo-ts/core' |
2 | 2 | import { |
3 | 3 | Agent, |
| 4 | + DidCommV1Service, |
4 | 5 | DidDocumentBuilder, |
5 | 6 | getEd25519VerificationKey2018, |
6 | 7 | getJsonWebKey2020, |
@@ -84,7 +85,7 @@ describe('Cheqd DID registrar', () => { |
84 | 85 | expect(did.didState).toMatchObject({ state: 'finished' }) |
85 | 86 | }) |
86 | 87 |
|
87 | | - it('should create a did:cheqd using JsonWebKey2020', async () => { |
| 88 | + it('should create a did:cheqd using JsonWebKey2020 and update with serviceEndpoint as array', async () => { |
88 | 89 | const createResult = await agent.dids.create<CheqdDidCreateOptions>({ |
89 | 90 | method: 'cheqd', |
90 | 91 |
|
@@ -135,6 +136,54 @@ describe('Cheqd DID registrar', () => { |
135 | 136 | expect(resolvedDocument.didDocumentMetadata.deactivated).toBe(true) |
136 | 137 | }) |
137 | 138 |
|
| 139 | + it('should create a did:cheqd using JsonWebKey2020 and update with DidCommV1Service', async () => { |
| 140 | + const createResult = await agent.dids.create<CheqdDidCreateOptions>({ |
| 141 | + method: 'cheqd', |
| 142 | + options: { |
| 143 | + createKey: { |
| 144 | + type: { |
| 145 | + crv: 'Ed25519', |
| 146 | + kty: 'OKP', |
| 147 | + }, |
| 148 | + keyId: 'another-key-id', |
| 149 | + }, |
| 150 | + network: 'testnet', |
| 151 | + methodSpecificIdAlgo: 'uuid', |
| 152 | + }, |
| 153 | + }) |
| 154 | + expect(createResult).toMatchObject({ |
| 155 | + didState: { |
| 156 | + state: 'finished', |
| 157 | + didDocument: { |
| 158 | + verificationMethod: [{ type: 'JsonWebKey2020' }], |
| 159 | + }, |
| 160 | + }, |
| 161 | + }) |
| 162 | + expect(createResult.didState.did).toBeDefined() |
| 163 | + const did = createResult.didState.did as string |
| 164 | + const didDocument = createResult.didState.didDocument as DidDocument |
| 165 | + const verificationMethodId = didDocument.verificationMethod?.[0]?.id |
| 166 | + const service1 = new DidCommV1Service({ |
| 167 | + id: `${did}#didcomm-1`, |
| 168 | + serviceEndpoint: 'https://this.endpoint.io', |
| 169 | + recipientKeys: [verificationMethodId ?? ''], |
| 170 | + accept: ['didcomm/aip2;env=rfc19'], |
| 171 | + priority: 0, |
| 172 | + }) |
| 173 | + didDocument.service = [service1] |
| 174 | + const updateResult = await agent.dids.update({ |
| 175 | + did, |
| 176 | + didDocument, |
| 177 | + }) |
| 178 | + expect(updateResult).toMatchObject({ |
| 179 | + didState: { |
| 180 | + state: 'finished', |
| 181 | + didDocument, |
| 182 | + }, |
| 183 | + }) |
| 184 | + expect(updateResult.didState.didDocument?.toJSON()).toMatchObject(didDocument.toJSON()) |
| 185 | + }) |
| 186 | + |
138 | 187 | it('should create a did:cheqd did using custom did document containing Ed25519 key', async () => { |
139 | 188 | const did = `did:cheqd:testnet:${utils.uuid()}` |
140 | 189 |
|
|
0 commit comments