Skip to content

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

Merged
hugomrdias merged 10 commits intomainfrom
feat/types-updates
Sep 9, 2022
Merged

feat!: fix types for exported entrypoints and simplify others#50
hugomrdias merged 10 commits intomainfrom
feat/types-updates

Conversation

@hugomrdias
Copy link
Copy Markdown
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
@hugomrdias hugomrdias requested a review from Gozala September 6, 2022 15:28
Copy link
Copy Markdown
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.

Comment thread src/ucan.ts Outdated
Comment thread src/ucan.ts Outdated
Comment thread src/ucan.ts Outdated
Comment thread src/ucan.ts Outdated
Comment thread test/lib.spec.js
Comment thread package.json Outdated
".": "./src/lib.js",
"./did": "./src/did.js",
"./codec/cbor": "./src/codec/cbor.js",
"./codec/raw": "./src/codec/raw.js"
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
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 hugomrdias requested a review from Gozala September 7, 2022 10:38
@hugomrdias
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread 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
Copy Markdown
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.

Comment thread 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
Copy Markdown
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>

Comment thread src/ucan.ts
readonly byteLength: number
readonly bytes: ByteView<IPLDLink<Data, Format, Alg, V>>

// readonly asCID: this
Copy link
Copy Markdown
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