Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@did-core/did-cbor

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@did-core/did-cbor - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1-unstable.0

6

package.json

@@ -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);
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc