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
Get TypeScript type definitions up to date and working again #561
Comments
Hi Lucas, Unfortunately, I also have very little experience with Typescript. If you'd like to submit a fix for this I'd be happy to merge it. |
I also need the updated Typings for the libary, so I am currently putting some work into that. For example the function encrypt(...) in the openpgp module returns a "encrypted (and optional signed message)". So that is another message object than from the function encryptSessionKey? Hopefully someone can help me to handle with this. |
Hi @CB-Giepa, So you should think of an OpenPGP message as sort of a container. Most encrypted messages will have an encrypted data packet and one or more key packets for the recipients. encryptSessionKey's Message object just has key packets. The data packet is then added by the rest of 'encrypt' function. encryptSessionKey is exposed as well as encrypt because it can be useful to manipulate the (small) key packets separately from the (large) data packet. |
Hi @CB-Giepa, |
Sadly this issue seems a bit abandoned, is there any progress of creating updated type definitions? |
It would be great to have someone from the community take this on now that OpenPGP.js 3 is out. None of the core devs have much experience with TypeScript. |
On behalf of @FlowCrypt I'll send a $100 bounty to the author of the first accepted PR. |
I got mine merged in! Hopefully they are good, they were good enough for my use case. |
Hi @errietta ! I just tried your types in the context of StencilJS (a web framework similar to Vue, etc.) and in the IDE (VSCode) I'm trying to import it like so (after I don't know if I'm doing this right. Can anybody help me ? Thanks. |
Hi @up4 . That seems fine for me. Which version of @types/openpgp do you have, you need 0.0.30 |
Hi @errietta ! Thanks for your reply ! I got it working by looking at your code demos and using Also : good job !!! Thanks for taking the time to do this ! |
It's interesting, both work for me, thanks for the feedback though, glad you got it working 🎉 😄 |
@errietta thanks for the PR! Do you want to claim the bounty? |
Spotted a mistake: // from types
function digest(algo: enums.hash, data: string): string; // try in node
let openpgp = require('openpgp');
openpgp.crypto.hash.digest(openpgp.enums.hash.sha1, 'test'); outputs:
Types show a string but it's actually Uint8Array returned. |
@errietta Also, I found that declaring the types as follows: declare module 'openpgp' {
export interface ...
...
} Allows me to import it as follows:
without installing How did you convince TS to use the definitions locally in the current form? |
@tomholub You can test locally using these instructions - https://github.com/DefinitelyTyped/DefinitelyTyped#test-editing-an-existing-package |
Thanks, I'll try that. There's actually more issues: v3 functions often return promises, but this is not always reflected in the definitions, eg this: Line 1113 in 6efcce1
Is an async function which always returns a promise, but here: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/openpgp/index.d.ts#L514 It's not showing a promise. I guess I'll just be fixing these issues on my end as I discover them, and make another pull request later to address these. You can still claim the bounty if you like, the contribution is helpful as is, although not completely consistent with the api. |
@tomholub thank you for this, I'm using this on my project as well, so it's good to have them fixed 😄 |
Sweet @tomholub thanks a lot 👍 🎉 |
I'm still working on this. You can track progress at FlowCrypt/types#1 & feel free to use updated types from the repo. When I'm satisfied with it, I'll make another PR. |
I cleaned up the code and fixed some return types: DefinitelyTyped/DefinitelyTyped#27609 |
@ffflorian did you include changes from FlowCrypt/types#1 ? There were loads of stuff missing. |
@tomholub I saw that too late, sorry. Will hold the PR until I merged your changes. |
That would be great. I have extended and updated it quite a bit.
…On Thu, Jul 26, 2018, 22:02 Florian Keller ***@***.***> wrote:
@tomholub <https://github.com/tomholub> I saw that too late, sorry. Will
hold the PR until I merged your changes.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#561 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGA8kdlidt4C4g-UgNupOTS7TFSrYSySks5uKdoFgaJpZM4OWk12>
.
|
I have further updated the definitions at https://github.com/FlowCrypt/types/blob/master/openpgp.d.ts to reflect OpenPGP v4 api, streaming, etc. The improvements are ongoing It would be better to include TypeScript API definitions in this repository. That way we can keep the changes easily in sync. Also, nodejs users would automatically get type definitions when they I'm ok to personally keep the definitions up to date since our company is heavily invested in TypeScript. |
@tomholub so, we have that repository, and also https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/openpgp/index.d.ts, is there any idea as to what we can do about not keeping both diverging? 😂 |
@errietta I am new to Angular and have been using openpgp with nodejs successfully. I am porting the openpgp functions to Angular, but am having the problems discussed in this issue. |
@duggabe how are you importing? Youmay need to do this:
|
@errietta We're getting there, but now there seems to be a path problem: What now? I really appreciate your help! |
@errietta I do believe I have received a goahead on including TS definitions in this repo from the maintainers.. somewhere.. forgot where. I'm pretty sure they will be down with it. |
There are a few more updates I wanted to make, and then I think it'll be ready for a PR to merge here. |
@duggabe this is probably out of scope for this GitHub repo, but you seem to not be including '.js' there (or a full path to the library). You'll have to figure out what the proper way to include 3rd party is in whatever environment / build mechanism you are using. |
Importing openpgp this way is not really an Angular thing, I think it's typescript preferred way to import. We could keep this in mind - once we add TypeScript as part of this repo, maybe the docs can touch on TS support and how to import the lib. |
@errietta Here is another related types issue: |
Looks like missing definitions |
@errietta do you have unreleased HKP type defs I could patch into index.d.ts to try? Have you or any of the others used the HKP functions in TypeScript? |
@duggabe no, I've got nothing unreleased. I've not tried it so it may well not be covered 😞 I can certainly take a look later though.. |
@errietta OK thanks. Once you have something you want to try, I have a good platform to test it. |
@duggabe do you want to try this? https://github.com/DefinitelyTyped/DefinitelyTyped/pull/33410/files |
@errietta Thanks, that fixed the HKP class def. Should there have been a |
@errietta I have loaded version 4.4.10. The HKP definitions are fixed. The 'hkp.lookup' would work except for a CORS problem. The 'hkp.upload' still produces the error above. I looked at the code, and I don't understand it enough to know what's wrong. |
Is anyone else having issues with the type definition for The source code for the fromText method returns an instance of |
Take a look at https://github.com/FlowCrypt/types/blob/master/openpgp.d.ts (I'm on mobile now). Does it look better? |
My main hesitation about working on getting my types (which I maintained) merged into OpenPGP.js is that they are incompatible with the current types published DefinitelyTyped. But since there will be a breaking v5 release, it will be worth to do the types as well in the same step. So @twiss if you put this into a v5 milestone then someone on our team will work on updating my types from https://github.com/FlowCrypt/types/blob/master/openpgp.d.ts to match v5 structure and we can have the types here going forward. I don't know when the release for v5 is planned but sometime November I should have someone free enough to do this. |
That would be great, thanks! We will start making prereleases soon, but won't make the final release before November. I think we can wait for this with that. |
@tomholub Gentle ping, do you guys have bandwidth for this? I would like to merge the v5 branch into master sometime soon, and hopefully release v5 this month. |
I'll do a coarse grained one, that gives the basic functionality of
whatever is in readme and high level docs. Still better then nothing or old
types. That gives us some structure to start improving on, and other folks
should start contributing towards it until it covers most stuff over time.
Does that sound ok?
Where is the best place to find high level v5 user APIs?
…On Wed, 9 Dec 2020, 17:22 Daniel Huigens, ***@***.***> wrote:
@tomholub <https://github.com/tomholub> Gentle ping, do you guys have
bandwidth for this? I would like to merge the v5 branch into master
sometime soon, and hopefully release v5 this month.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#561 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQDZEN2SO6NRS6NHHYAIYLST6P3XANCNFSM4DS2JV3A>
.
|
Sounds good, thanks! A high-level changelog (including examples) is here: https://github.com/openpgpjs/openpgpjs/wiki/V5-Changelog After merging the v5 branch I'll update the documentation as well. |
This has been merged to v5 branch. Although it's not released to users yet, it may make sense to close this issue & track any improvements that come up in separate issues later. |
I'll merge the v5 branch and clean up the issues soon :) |
Sorry if this is not desired here or just the wrong place, but I wanted to bring up an issue over at the DefinitelyTyped project. Openpgpjs has type definitions there but they are not working. I am using openpgpjs in my own TypeScript project and not having the type definitions is a bummer. I would be willing to look into it myself but I am pretty new at TypeScript.
The current implementation is also not in the correct format I believe as there are no exports from the index.d.ts.
The text was updated successfully, but these errors were encountered: