@did-core/did-cbor
Advanced tools
Comparing version 0.1.0 to 0.1.1-unstable.0
@@ -5,3 +5,3 @@ { | ||
"module": "dist/did-cbor.esm.js", | ||
"version": "0.1.0", | ||
"version": "0.1.1-unstable.0", | ||
"license": "Apache-2.0", | ||
@@ -26,3 +26,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@did-core/data-model": "^0.1.0", | ||
"@did-core/data-model": "^0.1.1-unstable.0", | ||
"@size-limit/preset-small-lib": "^4.9.2", | ||
@@ -58,3 +58,3 @@ "husky": "^5.0.9", | ||
}, | ||
"gitHead": "c955cf2e77280eec74a022449257defe52ea08b1" | ||
"gitHead": "e99bbf8ead282e2f496cd2f30a44351de46e7574" | ||
} |
@@ -6,1 +6,21 @@ # @did-core/did-cbor | ||
``` | ||
## Usage | ||
```ts | ||
import { factory, DidDocument } from '@did-core/data-model'; | ||
import { representation } from '@did-core/did-cbor'; | ||
const didDocument: DidDocument = factory.build({ | ||
entries: { | ||
// @context is required for use with jsonld verifiable credentials | ||
// but technically optional here | ||
'@context': 'https://www.w3.org/ns/did/v1', | ||
id: 'did:example:123', | ||
}, | ||
}); | ||
const representation: Buffer = await didDocument | ||
.addRepresentation({ 'application/did+cbor': representation }) | ||
.produce('application/did+cbor'); | ||
``` |
@@ -7,9 +7,10 @@ import { factory } from '@did-core/data-model'; | ||
it('can produce application/did+cbor', async () => { | ||
const didDocument = factory.build({ | ||
entries: { | ||
...jsonFixtures.example1, | ||
}, | ||
}); | ||
didDocument.addRepresentation(representations); | ||
const serialization = await didDocument.produce('application/did+cbor'); | ||
const serialization = await factory | ||
.build({ | ||
entries: { | ||
...jsonFixtures.example1, | ||
}, | ||
}) | ||
.addRepresentation(representations) | ||
.produce('application/did+cbor'); | ||
expect(serialization).toEqual(cborFixtures.example1); | ||
@@ -19,5 +20,6 @@ }); | ||
it('can consume application/did+cbor', async () => { | ||
let didDocument = factory.build(); | ||
didDocument.addRepresentation(representations); | ||
await didDocument.consume('application/did+cbor', cborFixtures.example1); | ||
let didDocument = await factory | ||
.build() | ||
.addRepresentation(representations) | ||
.consume('application/did+cbor', cborFixtures.example1); | ||
expect((didDocument.entries as any).id).toBe('did:example:123'); | ||
@@ -27,10 +29,11 @@ }); | ||
it('can produce example2 application/did+cbor', async () => { | ||
const didDocument = factory.build({ | ||
entries: { | ||
...jsonFixtures.example2, | ||
}, | ||
}); | ||
didDocument.addRepresentation(representations); | ||
const serialization = await didDocument.produce('application/did+cbor'); | ||
const serialization = await factory | ||
.build({ | ||
entries: { | ||
...jsonFixtures.example2, | ||
}, | ||
}) | ||
.addRepresentation(representations) | ||
.produce('application/did+cbor'); | ||
expect(serialization).toEqual(cborFixtures.example2); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
208072
1576
26