Skip to content

Commit

Permalink
feat: update sdk using different decoding for buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
eruizgar91 committed Jun 28, 2024
1 parent f02e652 commit 22cf902
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nevermined-io/sdk",
"version": "3.0.15",
"version": "3.0.16-rc0",
"description": "Javascript SDK for connecting with Nevermined Data Platform ",
"main": "./dist/node/sdk.js",
"typings": "./dist/node/sdk.d.ts",
Expand Down
18 changes: 9 additions & 9 deletions src/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ export async function decryptMessage(encryptedMessage: string, privateKey: strin
}

export function serializeECIES(ecies: any) {
return btoa(
JSON.stringify({
iv: Buffer.from(ecies.iv).toString('base64'),
ephemPublicKey: Buffer.from(ecies.ephemPublicKey).toString('base64'),
ciphertext: Buffer.from(ecies.ciphertext).toString('base64'),
mac: Buffer.from(ecies.mac).toString('base64'),
}),
)
const serialized = JSON.stringify({
iv: Buffer.from(ecies.iv).toString('base64'),
ephemPublicKey: Buffer.from(ecies.ephemPublicKey).toString('base64'),
ciphertext: Buffer.from(ecies.ciphertext).toString('base64'),
mac: Buffer.from(ecies.mac).toString('base64'),
})
return Buffer.from(serialized).toString('binary')
}

export function deserializeECIES(serialized: any) {
const _obj = JSON.parse(atob(serialized))
const decoded = Buffer.from(serialized, 'binary').toString()
const _obj = JSON.parse(decoded)
return {
iv: Buffer.from(_obj.iv, 'base64'),
ephemPublicKey: Buffer.from(_obj.ephemPublicKey, 'base64'),
Expand Down

0 comments on commit 22cf902

Please sign in to comment.