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

'import' syntax compatible and TypeScript declaration file #1038

Merged
merged 31 commits into from
Nov 28, 2023
Merged

'import' syntax compatible and TypeScript declaration file #1038

merged 31 commits into from
Nov 28, 2023

Conversation

radetsky
Copy link
Contributor

@radetsky radetsky commented Nov 22, 2023

  • Added compatibility with import syntax to jsthemis
  • TypeScript declaration file
  • Increased the version of package.json
  • Updated CHANGELOG.md

Checklist

  • Change is covered by automated tests
  • Changelog is updated (in case of notable or breaking changes)

@@ -0,0 +1,60 @@
export declare class KeyPair {
Copy link
Collaborator

Choose a reason for hiding this comment

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

did you write this file manually or somehow generated from the sources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Manually. I did not find the tool that can read .node file to make a declaration file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need constructor() here too similar to SymmetricKey? KeyPair looks like has constructor too -

void KeyPair::New(const Nan::FunctionCallbackInfo<v8::Value>& args)

And not obvious that it constructed from public + private

constructor(peerID: Uint8Array, privateKey: Uint8Array, getPublicKeyCallback: GetPublicKeyCallback);
isEstablished(): boolean;
connectRequest(): Uint8Array;
sendToPeer(message: Uint8Array): void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't find these functions in secureSession.cpp to find result type. Where this function is declared?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed. Thank you. I did not write tests for SecureSession.

@radetsky radetsky marked this pull request as draft November 23, 2023 10:21
@radetsky radetsky changed the title WIP: import syntax compatible and TypeScript declaration file 'import' syntax compatible and TypeScript declaration file Nov 23, 2023
@radetsky radetsky marked this pull request as ready for review November 24, 2023 09:12
Copy link
Contributor

@vixentael vixentael left a comment

Choose a reason for hiding this comment

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

@Lagovas looks good for you?

@vixentael vixentael added the W-JsThemis 🍭 Wrapper: JsThemis for Node.js, JavaScript API, npm packages label Nov 24, 2023
Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

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

And I see, that you tried to add examples and update tests on CI but reverted changes. Did you met any problems with tests with new import syntax?

@@ -0,0 +1,60 @@
export declare class KeyPair {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need constructor() here too similar to SymmetricKey? KeyPair looks like has constructor too -

void KeyPair::New(const Nan::FunctionCallbackInfo<v8::Value>& args)

And not obvious that it constructed from public + private

token: Uint8Array;
}

export declare class SecureCellTokenProtect {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like TokenProtect has constructor that expects key too -


or somehow used as WithKey.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've checked. We do not announce that we can do it, but construction with new SecureCellTokenProtect(masterkey) will also work the same as SecureCellTokenProtect.withKey(masterKey). It wraps one function into a constructor.
I'm adding the constructor declaration.

@vixentael
Copy link
Contributor

Should we add tests for this file?

@radetsky
Copy link
Contributor Author

And I see, that you tried to add examples and update tests on CI but reverted changes. Did you met any problems with tests with new import syntax?

Nope, I met the issues with node >= 18. Decided to provide it later because of OpenSSL 3 issues.

@Lagovas
Copy link
Collaborator

Lagovas commented Nov 24, 2023

Nope, I met the issues with node >= 18. Decided to provide it later because of OpenSSL 3 issues.

can we test it for openssl1.0/node <= 18?

Copy link
Collaborator

Choose a reason for hiding this comment

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

do we need this file here? looks like it's generated file from the .ts

run: |
cd $GITHUB_WORKSPACE/docs/examples/js/
echo "Test import syntax..."
node import_module.mjs
Copy link
Collaborator

Choose a reason for hiding this comment

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

just to be sure, did you tried some failed script to check some failure case to be sure that it's not always echo ok?

I found documentation for run where described that by default shell used with -e flag. But real world can be unsynchronized from documentation and we met situations when tests ran but didn't exit with errors on failures.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-11-28 at 12 55 54 Is it enough? Should I do a unit test?

Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

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

lgtm. merge after removing redundant .js file as discussed

@radetsky radetsky merged commit 26665c0 into cossacklabs:release/0.15.0 Nov 28, 2023
10 checks passed
@radetsky radetsky deleted the rad/jsthemis_exports branch December 7, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
W-JsThemis 🍭 Wrapper: JsThemis for Node.js, JavaScript API, npm packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants