Skip to content

Commit

Permalink
chore(ref-imp): remove controller and add context to deactivated docu…
Browse files Browse the repository at this point in the history
…ment (#1006)
  • Loading branch information
isaacJChen committed Jan 20, 2021
1 parent 29f09de commit c07bfec
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 13 deletions.
13 changes: 8 additions & 5 deletions lib/core/versions/latest/DocumentComposer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import SidetreeError from '../../../common/SidetreeError';
*/
export default class DocumentComposer {

private static resolutionObjectContextUrl = 'https://w3id.org/did-resolution/v1';
private static didDocumentContextUrl = 'https://www.w3.org/ns/did/v1';

/**
* Transforms the given DID state into a DID Document.
*/
Expand All @@ -37,7 +40,6 @@ export default class DocumentComposer {
const id = '#' + publicKey.id;
const didDocumentPublicKey = {
id: id,
controller: '',
type: publicKey.type,
publicKeyJwk: publicKey.publicKeyJwk
};
Expand All @@ -48,7 +50,7 @@ export default class DocumentComposer {
verificationMethod.push(didDocumentPublicKey);

if (purposeSet.size > 0) {
const reference = didDocumentPublicKey.controller + didDocumentPublicKey.id;
const reference = didDocumentPublicKey.id;

for (const purpose of purposeSet) {
if (!verificationRelationships.has(purpose)) {
Expand Down Expand Up @@ -79,7 +81,7 @@ export default class DocumentComposer {
const baseId = did.isShortForm ? did.shortForm : did.longForm;
const didDocument: any = {
id: baseId,
'@context': ['https://www.w3.org/ns/did/v1', { '@base': baseId }],
'@context': [DocumentComposer.didDocumentContextUrl, { '@base': baseId }],
service: services
};

Expand All @@ -92,7 +94,7 @@ export default class DocumentComposer {
});

const didResolutionResult: any = {
'@context': 'https://w3id.org/did-resolution/v1',
'@context': DocumentComposer.resolutionObjectContextUrl,
didDocument: didDocument,
didDocumentMetadata: {
method: {
Expand All @@ -119,7 +121,7 @@ export default class DocumentComposer {
private static createDeactivatedResolutionResult (did: string, published: boolean) {
const didDocument = {
id: did,
'@context': ['https://www.w3.org/ns/did/v1', { '@base': did }]
'@context': [DocumentComposer.didDocumentContextUrl, { '@base': did }]
};
const didDocumentMetadata = {
method: {
Expand All @@ -128,6 +130,7 @@ export default class DocumentComposer {
canonicalId: did
};
return {
'@context': DocumentComposer.resolutionObjectContextUrl,
didDocument,
didDocumentMetadata
};
Expand Down
3 changes: 0 additions & 3 deletions tests/core/DocumentComposer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,16 @@ describe('DocumentComposer', async () => {
verificationMethod: [
{
id: '#anySigningKey',
controller: '',
type: 'EcdsaSecp256k1VerificationKey2019',
publicKeyJwk: { kty: 'EC', crv: 'secp256k1', x: anySigningPublicKey.publicKeyJwk.x, y: anySigningPublicKey.publicKeyJwk.y }
},
{
id: '#authPublicKey',
controller: '',
type: 'EcdsaSecp256k1VerificationKey2019',
publicKeyJwk: { kty: 'EC', crv: 'secp256k1', x: authPublicKey.publicKeyJwk.x, y: authPublicKey.publicKeyJwk.y }
},
{
id: '#noPurposePublicKey',
controller: '',
type: 'EcdsaSecp256k1VerificationKey2019',
publicKeyJwk: { kty: 'EC', crv: 'secp256k1', x: noPurposePublicKey.publicKeyJwk.x, y: noPurposePublicKey.publicKeyJwk.y }
}
Expand Down
1 change: 0 additions & 1 deletion tests/vectors/resolution/afterCreate.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"verificationMethod": [
{
"id": "#publicKeyModel1Id",
"controller": "",
"type": "EcdsaSecp256k1VerificationKey2019",
"publicKeyJwk": {
"kty": "EC",
Expand Down
1 change: 1 addition & 0 deletions tests/vectors/resolution/afterDeactivate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"@context": "https://w3id.org/did-resolution/v1",
"didDocument": {
"id": "did:sidetree:EiDyOQbbZAa3aiRzeCkV7LOx3SERjjH93EXoIM3UoN4oWg",
"@context": [
Expand Down
1 change: 0 additions & 1 deletion tests/vectors/resolution/afterRecover.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"verificationMethod": [
{
"id": "#newKey",
"controller": "",
"type": "EcdsaSecp256k1VerificationKey2019",
"publicKeyJwk": {
"kty": "EC",
Expand Down
2 changes: 0 additions & 2 deletions tests/vectors/resolution/afterUpdate.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"verificationMethod": [
{
"id": "#publicKeyModel1Id",
"controller": "",
"type": "EcdsaSecp256k1VerificationKey2019",
"publicKeyJwk": {
"kty": "EC",
Expand All @@ -29,7 +28,6 @@
},
{
"id": "#additional-key",
"controller": "",
"type": "EcdsaSecp256k1VerificationKey2019",
"publicKeyJwk": {
"kty": "EC",
Expand Down
1 change: 0 additions & 1 deletion tests/vectors/resolution/longFormResponseDidDocument.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"verificationMethod": [
{
"id": "#publicKeyModel1Id",
"controller": "",
"type": "EcdsaSecp256k1VerificationKey2019",
"publicKeyJwk": {
"crv": "secp256k1",
Expand Down

0 comments on commit c07bfec

Please sign in to comment.