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

feat!: fix types for exported entrypoints and simplify others #50

Merged
merged 10 commits into from
Sep 9, 2022

Conversation

hugomrdias
Copy link
Member

@hugomrdias hugomrdias commented Sep 6, 2022

closes #49

- JWT<C> its just a string and phantom to retain C
- SignPayload removed, not really useful
- Block removed not used anywhere
- New `UCANBlock` type, if make the Capability generic an array we can merge this type with ucanto transport block
- DID is now DIDString
- Authority is now DIDVerifier
- Some more tweaks and fixes for new TS version

closes #49
@hugomrdias hugomrdias changed the title feat!: types feat!: fix types for exported entrypoints and simplify others Sep 6, 2022
Copy link
Collaborator

@Gozala Gozala left a comment

Choose a reason for hiding this comment

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

Thanks @hugomrdias I'm mostly onboard with all the changes here, even if I don't like some of the new names.

I do however disagree with changes in regards to CID / Link stuff. It took me a lot of time and effort to introduce changes that would move from CID class to Link interface in multiformats and changes here seem to go into opposite direction. Can we please not do that, I know it causes some pain right now but as soon as new multiformats is out it will be all nice & pretty. We would also be able to remove some of the local types here in favor of ones in multiformats.

src/ucan.ts Outdated Show resolved Hide resolved
src/ucan.ts Outdated Show resolved Hide resolved
src/ucan.ts Outdated Show resolved Hide resolved
src/ucan.ts Outdated Show resolved Hide resolved
test/lib.spec.js Show resolved Hide resolved
package.json Outdated
".": "./src/lib.js",
"./did": "./src/did.js",
"./codec/cbor": "./src/codec/cbor.js",
"./codec/raw": "./src/codec/raw.js"
Copy link
Collaborator

Choose a reason for hiding this comment

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

TS is moving to export maps and I think it would be a good idea to follow

Copy link
Member Author

Choose a reason for hiding this comment

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

give me links please, i would love to but what was there before didnt work.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

tried to do this but we cant change module in tsconfig yet it breaks other dep imports ...

@hugomrdias
Copy link
Member Author

in the last commit i changed DID back to being a string a renamed DID to Agent. Identity is still there because removing it breaks ucanto. We can remove it later after upgraded ucanto

Copy link
Collaborator

@Gozala Gozala left a comment

Choose a reason for hiding this comment

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

Pointed out few things, but I leave it up to you to decide what to do about them. Feel free to land as is or address some of those things and then land, I don't think we need another round of review here.

If you want to rename Agent to something else before landing that's cool with me as well.

src/ucan.ts Outdated
/**
* Entity that can sign UCANs with keys from a {@link Agent} using the signing algorithm A
*/
export interface Signer<A extends number = number>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I kind of liked Issuer name better a role was a lot more clear. Also idea was that we could add more things to the interface in the future if we need to.

src/ucan.ts Outdated
export type Link<
Cap extends Capability = Capability,
Alg extends number = number
> = IPLDLink<Model<Cap>, typeof CBOR_CODE, Alg, 1> | IPLDLink<JWT<Cap>,typeof RAW_CODE, Alg, 1>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: You could leave out version as 1 is a default.

Suggested change
> = IPLDLink<Model<Cap>, typeof CBOR_CODE, Alg, 1> | IPLDLink<JWT<Cap>,typeof RAW_CODE, Alg, 1>
> = IPLDLink<Model<Cap>, typeof CBOR_CODE, Alg> | IPLDLink<JWT<Cap>,typeof RAW_CODE, Alg>


// readonly asCID: this
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was used in bunch of places & also a reason why I could not extend CID class because it's marked private there and that caused TS to complain.

I don't mind adding //@ts-expect-error in those places if this is really important, but just want to make sure you're aware of this.

@hugomrdias hugomrdias merged commit f7ce660 into main Sep 9, 2022
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.

UCAN.parse should not complain on plain string
2 participants