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

Provide hmac keys on the napi #1450

Merged
merged 3 commits into from
Jan 2, 2025
Merged

Provide hmac keys on the napi #1450

merged 3 commits into from
Jan 2, 2025

Conversation

codabrink
Copy link
Contributor

No description provided.

@codabrink codabrink requested a review from a team as a code owner January 2, 2025 16:52
@@ -97,6 +98,21 @@ impl From<ListConversationsOptions> for GroupQueryArgs {
}
}

#[napi(object)]
pub struct NodeHMACKey {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you make this just HmacKey and alias the import as XmtpHmacKey? it makes the generated types usable without having to rename them in the SDK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

#[napi(object)]
pub struct NodeHMACKey {
pub key: Vec<u8>,
pub epoch: i64,
Copy link
Collaborator

Choose a reason for hiding this comment

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

i64 will be typed as a number in javascript. not sure if that's desirable or an issue, just wanted to point it out. while the rust i64 type supports a range of −2^63 to 2^63 − 1, the javascript type only supports -2^53 + 1 to 2^53 - 1.

there's a BigInt type in NAPI that should provide full precision, if necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, the number will never get that large, but I can change it over for correctness. Thanks for letting me know.

Copy link
Collaborator

Choose a reason for hiding this comment

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

cool, yea, it's not a big deal to keep as is. we can always change in future if it becomes an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All good. Swapped it out for BigInt.

@codabrink codabrink enabled auto-merge (squash) January 2, 2025 17:15
@codabrink codabrink merged commit fcdce97 into main Jan 2, 2025
8 checks passed
@codabrink codabrink deleted the coda/napi-hmac branch January 2, 2025 17:17
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.

2 participants