@openfort/openfort-node 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -374,7 +374,7 @@ function requiresWalletAuth(requestMethod, requestPath) {
374
374
  }
375
375
 
376
376
  // src/version.ts
377
- var VERSION = "0.7.6";
377
+ var VERSION = "0.7.7";
378
378
  var PACKAGE = "@openfort/openfort-node";
379
379
 
380
380
  // src/openapi-client/openfortApiClient.ts
@@ -3475,60 +3475,18 @@ var decryptExportedPrivateKey = (encryptedPrivateKeyBase64, privateKeyPem) => {
3475
3475
  return decrypted.toString("hex");
3476
3476
  };
3477
3477
 
3478
- // src/wallets/evm/actions/signHash.ts
3479
- async function signHash(options) {
3480
- const { accountId, hash } = options;
3481
- const response = await sign(accountId, { data: hash });
3482
- return {
3483
- signature: response.signature
3484
- };
3485
- }
3486
-
3487
- // src/wallets/evm/actions/signMessage.ts
3488
- import { hashMessage, toHex } from "viem";
3489
- async function signMessage(options) {
3490
- const { accountId, message } = options;
3491
- let messageStr;
3492
- if (typeof message === "string") {
3493
- messageStr = message;
3494
- } else if (message instanceof Uint8Array) {
3495
- messageStr = toHex(message);
3496
- } else if ("raw" in message) {
3497
- messageStr = typeof message.raw === "string" ? message.raw : toHex(message.raw);
3498
- } else {
3499
- throw new UserInputValidationError("Invalid message format");
3500
- }
3501
- const messageHash = hashMessage(messageStr);
3502
- const response = await sign(accountId, { data: messageHash });
3503
- return {
3504
- signature: response.signature
3505
- };
3506
- }
3507
-
3508
- // src/wallets/evm/actions/signTransaction.ts
3478
+ // src/wallets/evm/accounts/evmAccount.ts
3509
3479
  import {
3510
- keccak256,
3480
+ getTypesForEIP712Domain,
3481
+ hashMessage,
3482
+ hashTypedData,
3511
3483
  parseSignature,
3512
3484
  serializeTransaction
3513
3485
  } from "viem";
3514
- async function signTransaction(options) {
3515
- const { accountId, transaction } = options;
3516
- const serialized = serializeTransaction(transaction);
3517
- const response = await sign(accountId, { data: serialized });
3518
- const signature2 = parseSignature(response.signature);
3519
- const signedTransaction = serializeTransaction(transaction, signature2);
3520
- const transactionHash = keccak256(signedTransaction);
3521
- return {
3522
- signedTransaction,
3523
- transactionHash
3524
- };
3525
- }
3526
3486
 
3527
- // src/wallets/evm/actions/signTypedData.ts
3528
- import { hashTypedData } from "viem";
3529
- async function signTypedData(options) {
3530
- const { accountId, typedData } = options;
3531
- const hash = hashTypedData(typedData);
3487
+ // src/wallets/evm/actions/signHash.ts
3488
+ async function signHash(options) {
3489
+ const { accountId, hash } = options;
3532
3490
  const response = await sign(accountId, { data: hash });
3533
3491
  return {
3534
3492
  signature: response.signature
@@ -3550,27 +3508,44 @@ function toEvmAccount(data) {
3550
3508
  return result.signature;
3551
3509
  },
3552
3510
  async signMessage(parameters) {
3553
- const result = await signMessage({
3554
- address,
3555
- accountId: id,
3556
- message: parameters.message
3557
- });
3511
+ const { message } = parameters;
3512
+ if (typeof message === "string") {
3513
+ const hash2 = hashMessage(message);
3514
+ const result2 = await sign(id, { data: hash2 });
3515
+ return result2.signature;
3516
+ }
3517
+ const hash = hashMessage(message);
3518
+ const result = await sign(id, { data: hash });
3558
3519
  return result.signature;
3559
3520
  },
3560
3521
  async signTransaction(transaction) {
3561
- const result = await signTransaction({
3562
- address,
3563
- accountId: id,
3564
- transaction
3565
- });
3566
- return result.signedTransaction;
3522
+ const serialized = serializeTransaction(transaction);
3523
+ const response = await sign(id, { data: serialized });
3524
+ const signature2 = parseSignature(response.signature);
3525
+ const signedTransaction = serializeTransaction(
3526
+ transaction,
3527
+ signature2
3528
+ );
3529
+ return signedTransaction;
3567
3530
  },
3568
3531
  async signTypedData(parameters) {
3569
- const result = await signTypedData({
3570
- address,
3571
- accountId: id,
3572
- typedData: parameters
3573
- });
3532
+ const {
3533
+ domain = {},
3534
+ message,
3535
+ primaryType
3536
+ } = parameters;
3537
+ const types = {
3538
+ EIP712Domain: getTypesForEIP712Domain({ domain }),
3539
+ ...parameters.types
3540
+ };
3541
+ const openApiMessage = {
3542
+ domain,
3543
+ types,
3544
+ primaryType,
3545
+ message
3546
+ };
3547
+ const hash = hashTypedData(openApiMessage);
3548
+ const result = await sign(id, { data: hash });
3574
3549
  return result.signature;
3575
3550
  }
3576
3551
  };
@@ -3794,7 +3769,7 @@ EvmClient.type = "evmWallet";
3794
3769
  import bs58 from "bs58";
3795
3770
 
3796
3771
  // src/wallets/solana/actions/signMessage.ts
3797
- async function signMessage2(options) {
3772
+ async function signMessage(options) {
3798
3773
  const { accountId, message } = options;
3799
3774
  const messageBytes = Buffer.from(message, "utf-8");
3800
3775
  const messageHex = `0x${messageBytes.toString("hex")}`;
@@ -3805,7 +3780,7 @@ async function signMessage2(options) {
3805
3780
  }
3806
3781
 
3807
3782
  // src/wallets/solana/actions/signTransaction.ts
3808
- async function signTransaction2(options) {
3783
+ async function signTransaction(options) {
3809
3784
  const { accountId, transaction } = options;
3810
3785
  const txBytes = Buffer.from(transaction, "base64");
3811
3786
  const txHex = `0x${txBytes.toString("hex")}`;
@@ -3823,14 +3798,14 @@ function toSolanaAccount(data) {
3823
3798
  address,
3824
3799
  custody: "Developer",
3825
3800
  async signMessage(parameters) {
3826
- const result = await signMessage2({
3801
+ const result = await signMessage({
3827
3802
  accountId: id,
3828
3803
  message: parameters.message
3829
3804
  });
3830
3805
  return result.signature;
3831
3806
  },
3832
3807
  async signTransaction(parameters) {
3833
- const result = await signTransaction2({
3808
+ const result = await signTransaction({
3834
3809
  accountId: id,
3835
3810
  transaction: parameters.transaction
3836
3811
  });
@@ -4068,6 +4043,21 @@ SolanaClient.type = "solanaWallet";
4068
4043
 
4069
4044
  // src/index.ts
4070
4045
  import { ShieldAuthProvider as ShieldAuthProvider2 } from "@openfort/shield-js";
4046
+
4047
+ // src/wallets/evm/actions/signMessage.ts
4048
+ import { hashMessage as hashMessage2, toHex } from "viem";
4049
+
4050
+ // src/wallets/evm/actions/signTransaction.ts
4051
+ import {
4052
+ keccak256,
4053
+ parseSignature as parseSignature2,
4054
+ serializeTransaction as serializeTransaction2
4055
+ } from "viem";
4056
+
4057
+ // src/wallets/evm/actions/signTypedData.ts
4058
+ import { hashTypedData as hashTypedData2 } from "viem";
4059
+
4060
+ // src/index.ts
4071
4061
  function isValidSecretKey(key) {
4072
4062
  return key.startsWith("sk_test_") || key.startsWith("sk_live_");
4073
4063
  }