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(KeyObject) #5940

Merged
merged 52 commits into from
Oct 7, 2023
Merged

feat(KeyObject) #5940

merged 52 commits into from
Oct 7, 2023

Conversation

cirospaciari
Copy link
Collaborator

@cirospaciari cirospaciari commented Sep 23, 2023

@danny-avila
Copy link

Does this address #2036 and #1454?

@panva
Copy link
Contributor

panva commented Oct 2, 2023

I may just not be reading the code right but it's important that createPublicKey and createPrivateKey also handle the format: 'jwk' option.

@cirospaciari cirospaciari changed the title WIP: feat(KeyObject) feat(KeyObject) Oct 7, 2023
@cirospaciari cirospaciari marked this pull request as ready for review October 7, 2023 04:49
@github-actions
Copy link

github-actions bot commented Oct 7, 2023

prettier errors have been resolved. Thank you.

#0beed3057b6eecf6464e578e92093581811d5508

@github-actions
Copy link

github-actions bot commented Oct 7, 2023

@cirospaciari 9 files with test failures on bun-darwin-aarch64:

  • test/bundler/esbuild/default.test.ts
  • test/cli/install/bun-install.test.ts
  • test/integration/next/default-pages-dir/test/dev-server.test.ts
  • test/integration/next/default-pages-dir/test/next-build.test.ts
  • test/js/bun/spawn/spawn.test.ts
  • test/js/bun/test/test-test.test.ts
  • test/js/bun/util/filesink.test.ts
  • test/js/node/watch/fs.watch.test.ts
  • test/js/node/worker_threads/worker_threads.test.ts

View test output

#0beed3057b6eecf6464e578e92093581811d5508

@github-actions
Copy link

github-actions bot commented Oct 7, 2023

@cirospaciari 4 files with test failures on linux-x64-baseline:

  • test/bundler/esbuild/splitting.test.ts
  • test/cli/install/bun-install.test.ts
  • test/js/node/watch/fs.watch.test.ts
  • test/js/web/worker.test.ts

View test output

#0beed3057b6eecf6464e578e92093581811d5508

@github-actions
Copy link

github-actions bot commented Oct 7, 2023

@cirospaciari 5 files with test failures on linux-x64:

  • test/bundler/esbuild/splitting.test.ts
  • test/cli/install/bun-install.test.ts
  • test/js/node/watch/fs.watch.test.ts
  • test/js/node/watch/fs.watchFile.test.ts
  • test/js/web/fetch/fetch-gzip.test.ts

View test output

#0beed3057b6eecf6464e578e92093581811d5508

@github-actions
Copy link

github-actions bot commented Oct 7, 2023

@cirospaciari 6 files with test failures on bun-darwin-x64-baseline:

  • test/cli/install/bun-install.test.ts
  • test/js/bun/spawn/spawn.test.ts
  • test/js/bun/util/filesink.test.ts
  • test/js/node/fs/fs.test.ts
  • test/js/third_party/webpack/webpack.test.ts
  • test/js/web/timers/setTimeout.test.js

View test output

#0beed3057b6eecf6464e578e92093581811d5508

key.indexOf("PRIVATE KEY-----") !== -1 && (key = _createPublicKey(key).export());
}
return key;
}
function getArrayBufferOrView(buffer, name, encoding) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should move this one to native code in a future PR

if (key instanceof KeyObject) {
key = key.export();
} else if (key instanceof CryptoKey) {
key = KeyObject.from(key).export();
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we should make export a static method that does this as one function instead of two

but we can do that in a future PR

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed on 59ebd2d

return hash.update(this._opad).update(h).digest();
};
module.exports = function (alg, key) {
if (key instanceof KeyObject) {
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
Collaborator Author

Choose a reason for hiding this comment

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

Fixed on 59ebd2d

}
};

function _generateKeyPairSync(algorithm, options) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why didn't we do these functions in native code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I am not sure either, I will change that to move most of it to native and only use KeyObject.from when needed.


switch (type) {

case DataViewType:
Copy link
Collaborator

Choose a reason for hiding this comment

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

at some point we should add a macro for this

Float16Array will be a thing in like a year probably

https://github.com/tc39/proposal-float16array

Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner left a comment

Choose a reason for hiding this comment

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

Looks great.

@Jarred-Sumner Jarred-Sumner merged commit 3510916 into main Oct 7, 2023
15 of 20 checks passed
@Jarred-Sumner Jarred-Sumner deleted the ciro/key-object branch October 7, 2023 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants