diff --git a/packages/indy-vdr/src/dids/IndyVdrIndyDidRegistrar.ts b/packages/indy-vdr/src/dids/IndyVdrIndyDidRegistrar.ts index 7f998e247d..09e2c4e4a1 100644 --- a/packages/indy-vdr/src/dids/IndyVdrIndyDidRegistrar.ts +++ b/packages/indy-vdr/src/dids/IndyVdrIndyDidRegistrar.ts @@ -319,6 +319,7 @@ export class IndyVdrIndyDidRegistrar implements DidRegistrar { verificationKey, alias, diddocContent, + role: options.options.role, }) if (services && useEndpointAttrib) { @@ -388,6 +389,7 @@ export class IndyVdrIndyDidRegistrar implements DidRegistrar { signingKey?: Key alias: string | undefined diddocContent?: Record + role?: NymRequestRole }) { const { agentContext, @@ -397,6 +399,7 @@ export class IndyVdrIndyDidRegistrar implements DidRegistrar { verificationKey, alias, signingKey, + role, } = options // FIXME: Add diddocContent when supported by indy-vdr @@ -408,7 +411,8 @@ export class IndyVdrIndyDidRegistrar implements DidRegistrar { submitterDid: submitterNamespaceIdentifier, dest: namespaceIdentifier, verkey: verificationKey.publicKeyBase58, - alias: alias, + alias, + role, }) if (!signingKey) return request @@ -487,7 +491,7 @@ interface IndyVdrDidCreateOptionsBase extends DidCreateOptions { didDocument?: never // Not yet supported options: { alias?: string - role?: string + role?: NymRequestRole services?: DidDocumentService[] useEndpointAttrib?: boolean verkey?: string @@ -566,3 +570,5 @@ export interface EndorseDidTxAction extends DidOperationStateActionBase { } export type IndyVdrDidCreateResult = DidCreateResult + +export type NymRequestRole = 'STEWARD' | 'TRUSTEE' | 'ENDORSER' | 'NETWORK_MONITOR' diff --git a/packages/indy-vdr/tests/indy-vdr-did-registrar.e2e.test.ts b/packages/indy-vdr/tests/indy-vdr-did-registrar.e2e.test.ts index 95e8742dd6..526391871f 100644 --- a/packages/indy-vdr/tests/indy-vdr-did-registrar.e2e.test.ts +++ b/packages/indy-vdr/tests/indy-vdr-did-registrar.e2e.test.ts @@ -155,91 +155,17 @@ describe('Indy VDR Indy Did Registrar', () => { }) }) - test('can register a did:indy without services with endorser', async () => { - const didCreateTobeEndorsedResult = (await agent.dids.create({ + test('cannot create a did with TRUSTEE role', async () => { + const didRegistrationResult = await endorser.dids.create({ method: 'indy', options: { - endorserMode: 'external', endorserDid, - }, - })) as IndyVdrDidCreateResult - - const didState = didCreateTobeEndorsedResult.didState - if (didState.state !== 'action' || didState.action !== 'endorseIndyTransaction') throw Error('unexpected did state') - - const signedNymRequest = await endorser.modules.indyVdr.endorseTransaction( - didState.nymRequest, - didState.endorserDid - ) - const didCreateSubmitResult = await agent.dids.create({ - did: didState.did, - options: { - endorserMode: 'external', - endorsedTransaction: { - nymRequest: signedNymRequest, - }, - }, - secret: didState.secret, - }) - - expect(JsonTransformer.toJSON(didCreateSubmitResult)).toMatchObject({ - didDocumentMetadata: {}, - didRegistrationMetadata: {}, - didState: { - state: 'finished', - did: expect.stringMatching(didIndyRegex), - didDocument: { - '@context': ['https://w3id.org/did/v1', 'https://w3id.org/security/suites/ed25519-2018/v1'], - id: expect.stringMatching(didIndyRegex), - alsoKnownAs: undefined, - controller: undefined, - verificationMethod: [ - { - type: 'Ed25519VerificationKey2018', - controller: expect.stringMatching(didIndyRegex), - id: expect.stringContaining('#verkey'), - publicKeyBase58: expect.any(String), - }, - ], - capabilityDelegation: undefined, - capabilityInvocation: undefined, - authentication: [expect.stringContaining('#verkey')], - service: undefined, - }, + endorserMode: 'internal', + role: 'TRUSTEE', }, }) - const did = didCreateSubmitResult.didState.did - if (!did) throw Error('did not defined') - - // Wait some time pass to let ledger settle the object - await sleep(1000) - - const didResolutionResult = await endorser.dids.resolve(did) - expect(JsonTransformer.toJSON(didResolutionResult)).toMatchObject({ - didDocument: { - '@context': ['https://w3id.org/did/v1', 'https://w3id.org/security/suites/ed25519-2018/v1'], - id: did, - alsoKnownAs: undefined, - controller: undefined, - verificationMethod: [ - { - type: 'Ed25519VerificationKey2018', - controller: did, - id: `${did}#verkey`, - publicKeyBase58: expect.any(String), - }, - ], - capabilityDelegation: undefined, - capabilityInvocation: undefined, - authentication: [`${did}#verkey`], - service: undefined, - }, - didDocumentMetadata: {}, - didResolutionMetadata: { - contentType: 'application/did+ld+json', - }, - }) + expect(JsonTransformer.toJSON(didRegistrationResult.didState.state)).toBe('failed') }) test('can register an endorsed did:indy without services - did and verkey specified', async () => {