Skip to content

Commit

Permalink
feat: add createDagJWS method (#6)
Browse files Browse the repository at this point in the history
* feat: add createDagJWS method

* chore: update readme
  • Loading branch information
oed authored Aug 21, 2020
1 parent b31ca64 commit 03871cb
Show file tree
Hide file tree
Showing 9 changed files with 871 additions and 86 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ await alice.authenticate()
const aliceDID = alice.DID

// Create a JWS - this will throw an error if the DID instance is not authenticated
// CIDs and Buffers will be encoded to string
const jws = await alice.createJWS({ hello: 'world', link: new CID(...), data: Buffer.from('12ed', 'hex') })
const jws = await alice.createJWS({ hello: 'world' })

// Create a DagJWS - the payload will be encoded as ipld dag-cbor, the resulting JWS is dag-jose compatible
const { jws, linkedBlock } = await alice.createJWS({ hello: 'world' coolLink: new CID(...) })
```

### Resolving DIDs
Expand Down Expand Up @@ -66,10 +68,21 @@ interface AuthenticateOptions {

```ts
interface CreateJWSOptions {
did?: string
protected?: Record<string, any>
}
```

### DagJWSResult

```ts
interface DagJWSResult {
jws: string // base64-encoded
linkedBlock: string // base64-encoded
}
```


### ResolverRegistry

A record of DID methods to resolvers, as defined in the [DID resolver library](https://github.com/decentralized-identity/did-resolver).
Expand Down Expand Up @@ -157,6 +170,18 @@ export interface DIDOptions {

**Returns** `Promise<string>`

#### did.createDagJWS()
Creates a JWS that is compatible with [dag-jose](https://github.com/ceramicnetwork/js-dag-jose).

> The instance needs to be authenticated before calling this method
**Arguments**

1. `payload: Record<string, any>`
1. `options?: CreateJWSOptions` to specify the `protected` header, and did with keyFragment

**Returns** `Promise<DagJWSResult>`

#### did.resolve()

**Arguments**
Expand Down
Loading

0 comments on commit 03871cb

Please sign in to comment.