Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update multiformats, add JWS utilities, update deps #1

Merged
merged 4 commits into from
May 31, 2021

Conversation

rvagg
Copy link
Contributor

@rvagg rvagg commented May 15, 2021

breaking because encodeIdentityCID() is async now

Will follow up with a PR to jd-dag-jose that couples with (and uses) this and discuss over there.

Custom Jest resolver is pending fix being tracked @ jestjs/jest#9771

Copy link
Member

@oed oed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, been looking forward to using the new multiformats libs.

Can you bump the package version to 1.0?

Should we wait with merging this until the jest issue has been resolved?

}

export function decodeCleartext(b: Uint8Array): Record<string, any> {
return decodeIdentityCID(unpadCIDBytes(b))
return decodeIdentityCID(CID.decodeFirst(b)[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this seems like a new useful thing :)

### toJWSPayload(payload: EncodedPayload | CID): string
Transform an `EnvodedPayload` (from `encodePayload()`) or a CID into a JWS string for use with `createJWS()` in [did-jwt](https://github.com/decentralized-identity/did-jwt). The string form is simply the Base64url encoded form of the CID's byte representation.

### toJWSStrings(jose: any): string[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate that you need this method. Ideally did-jwt should support the General encoding, that the ´jose` object here has, out of the box!

README.md Outdated Show resolved Hide resolved
if (!cid) {
throw new Error('Payload must be an EncodedPayload or a CID')
}
return base64url.encode(cid.bytes).slice(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does base64url.encode return multibase and that's why we slice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, and there's no easy way to get to the plain base64 encoder (yet—this has annoyed me on a few occasions so I think I might go and do something about it)

README.md Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@rvagg
Copy link
Contributor Author

rvagg commented May 26, 2021

version bumped, typos fixed

Should we wait with merging this until the jest issue has been resolved?

No, I went down the rabbit hole on that one and the dependency chain of things that need to be resolved is deep and unlikely to be resolved any time soon unfortunately. A large collection of users are having to work around some of the Jest problems so maybe pressure will increase to find a more speedy resolution but for now it's on hold.

Copy link
Member

@oed oed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@oed oed merged commit 3c22ab3 into ceramicnetwork:master May 31, 2021
@oed
Copy link
Member

oed commented May 31, 2021

dag-jose-utils@1.0.0 published 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants