Skip to content

Commit

Permalink
Make base64 encoding target independent in KeyIdMemStore in wasm bi…
Browse files Browse the repository at this point in the history
…ndings (iotaledger#1386)
  • Loading branch information
wulfraem committed Jun 27, 2024
1 parent 2af02da commit bb13b38
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bindings/wasm/lib/key_id_storage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { encode as base64Encode } from "base64-arraybuffer";
import type { KeyIdStorage, MethodDigest } from "~identity_wasm";

export class KeyIdMemStore implements KeyIdStorage {
Expand Down Expand Up @@ -48,6 +49,5 @@ export class KeyIdMemStore implements KeyIdStorage {
*/
function methodDigestToString(methodDigest: MethodDigest): string {
let arrayBuffer = methodDigest.pack().buffer;
let buffer = Buffer.from(arrayBuffer);
return buffer.toString("base64");
return base64Encode(arrayBuffer);
}
14 changes: 14 additions & 0 deletions bindings/wasm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bindings/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"dependencies": {
"@noble/ed25519": "^1.7.3",
"@types/node-fetch": "^2.6.2",
"base64-arraybuffer": "^1.0.2",
"node-fetch": "^2.6.7"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl KeyIdStorageErrorKind {
Self::KeyIdNotFound => "key id not found in storage",
Self::Unavailable => "key id storage unavailable",
Self::Unauthenticated => "authentication with the key id storage failed",
Self::Unspecified => "key storage operation failed",
Self::Unspecified => "key id storage operation failed",
Self::RetryableIOFailure => "key id storage was unsuccessful because of an I/O failure",
Self::SerializationError => "(de)serialization error",
}
Expand Down
2 changes: 1 addition & 1 deletion identity_storage/src/storage/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum JwkStorageDocumentError {
#[error("storage operation failed: key storage error")]
KeyStorageError(KeyStorageError),
/// Caused by a failure in the key id storage.
#[error("storage operation failed: key id storage error")]
#[error("storage operation failed: key id storage error: {0}")]
KeyIdStorageError(KeyIdStorageError),
/// Caused by an attempt to add a method with a fragment that already exists.
#[error("could not add method: the fragment already exists")]
Expand Down

0 comments on commit bb13b38

Please sign in to comment.