@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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#57](https://github.com/openfort-xyz/openfort-node/pull/57) [`a0024ae8e9ef5bdf557077c211cc097ce00f115e`](https://github.com/openfort-xyz/openfort-node/commit/a0024ae8e9ef5bdf557077c211cc097ce00f115e) Thanks [@jamalavedra](https://github.com/jamalavedra)! - fix toEvmAccount
8
+
3
9
  ## 0.7.6
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -719,7 +719,7 @@ function requiresWalletAuth(requestMethod, requestPath) {
719
719
  }
720
720
 
721
721
  // src/version.ts
722
- var VERSION = "0.7.6";
722
+ var VERSION = "0.7.7";
723
723
  var PACKAGE = "@openfort/openfort-node";
724
724
 
725
725
  // src/openapi-client/openfortApiClient.ts
@@ -3815,6 +3815,9 @@ var decryptExportedPrivateKey = (encryptedPrivateKeyBase64, privateKeyPem) => {
3815
3815
  return decrypted.toString("hex");
3816
3816
  };
3817
3817
 
3818
+ // src/wallets/evm/accounts/evmAccount.ts
3819
+ var import_viem = require("viem");
3820
+
3818
3821
  // src/wallets/evm/actions/signHash.ts
3819
3822
  async function signHash(options) {
3820
3823
  const { accountId, hash } = options;
@@ -3824,53 +3827,6 @@ async function signHash(options) {
3824
3827
  };
3825
3828
  }
3826
3829
 
3827
- // src/wallets/evm/actions/signMessage.ts
3828
- var import_viem = require("viem");
3829
- async function signMessage(options) {
3830
- const { accountId, message } = options;
3831
- let messageStr;
3832
- if (typeof message === "string") {
3833
- messageStr = message;
3834
- } else if (message instanceof Uint8Array) {
3835
- messageStr = (0, import_viem.toHex)(message);
3836
- } else if ("raw" in message) {
3837
- messageStr = typeof message.raw === "string" ? message.raw : (0, import_viem.toHex)(message.raw);
3838
- } else {
3839
- throw new UserInputValidationError("Invalid message format");
3840
- }
3841
- const messageHash = (0, import_viem.hashMessage)(messageStr);
3842
- const response = await sign(accountId, { data: messageHash });
3843
- return {
3844
- signature: response.signature
3845
- };
3846
- }
3847
-
3848
- // src/wallets/evm/actions/signTransaction.ts
3849
- var import_viem2 = require("viem");
3850
- async function signTransaction(options) {
3851
- const { accountId, transaction } = options;
3852
- const serialized = (0, import_viem2.serializeTransaction)(transaction);
3853
- const response = await sign(accountId, { data: serialized });
3854
- const signature2 = (0, import_viem2.parseSignature)(response.signature);
3855
- const signedTransaction = (0, import_viem2.serializeTransaction)(transaction, signature2);
3856
- const transactionHash = (0, import_viem2.keccak256)(signedTransaction);
3857
- return {
3858
- signedTransaction,
3859
- transactionHash
3860
- };
3861
- }
3862
-
3863
- // src/wallets/evm/actions/signTypedData.ts
3864
- var import_viem3 = require("viem");
3865
- async function signTypedData(options) {
3866
- const { accountId, typedData } = options;
3867
- const hash = (0, import_viem3.hashTypedData)(typedData);
3868
- const response = await sign(accountId, { data: hash });
3869
- return {
3870
- signature: response.signature
3871
- };
3872
- }
3873
-
3874
3830
  // src/wallets/evm/accounts/evmAccount.ts
3875
3831
  function toEvmAccount(data) {
3876
3832
  const { id, address } = data;
@@ -3886,27 +3842,44 @@ function toEvmAccount(data) {
3886
3842
  return result.signature;
3887
3843
  },
3888
3844
  async signMessage(parameters) {
3889
- const result = await signMessage({
3890
- address,
3891
- accountId: id,
3892
- message: parameters.message
3893
- });
3845
+ const { message } = parameters;
3846
+ if (typeof message === "string") {
3847
+ const hash2 = (0, import_viem.hashMessage)(message);
3848
+ const result2 = await sign(id, { data: hash2 });
3849
+ return result2.signature;
3850
+ }
3851
+ const hash = (0, import_viem.hashMessage)(message);
3852
+ const result = await sign(id, { data: hash });
3894
3853
  return result.signature;
3895
3854
  },
3896
3855
  async signTransaction(transaction) {
3897
- const result = await signTransaction({
3898
- address,
3899
- accountId: id,
3900
- transaction
3901
- });
3902
- return result.signedTransaction;
3856
+ const serialized = (0, import_viem.serializeTransaction)(transaction);
3857
+ const response = await sign(id, { data: serialized });
3858
+ const signature2 = (0, import_viem.parseSignature)(response.signature);
3859
+ const signedTransaction = (0, import_viem.serializeTransaction)(
3860
+ transaction,
3861
+ signature2
3862
+ );
3863
+ return signedTransaction;
3903
3864
  },
3904
3865
  async signTypedData(parameters) {
3905
- const result = await signTypedData({
3906
- address,
3907
- accountId: id,
3908
- typedData: parameters
3909
- });
3866
+ const {
3867
+ domain = {},
3868
+ message,
3869
+ primaryType
3870
+ } = parameters;
3871
+ const types = {
3872
+ EIP712Domain: (0, import_viem.getTypesForEIP712Domain)({ domain }),
3873
+ ...parameters.types
3874
+ };
3875
+ const openApiMessage = {
3876
+ domain,
3877
+ types,
3878
+ primaryType,
3879
+ message
3880
+ };
3881
+ const hash = (0, import_viem.hashTypedData)(openApiMessage);
3882
+ const result = await sign(id, { data: hash });
3910
3883
  return result.signature;
3911
3884
  }
3912
3885
  };
@@ -4130,7 +4103,7 @@ EvmClient.type = "evmWallet";
4130
4103
  var import_bs58 = __toESM(require("bs58"));
4131
4104
 
4132
4105
  // src/wallets/solana/actions/signMessage.ts
4133
- async function signMessage2(options) {
4106
+ async function signMessage(options) {
4134
4107
  const { accountId, message } = options;
4135
4108
  const messageBytes = Buffer.from(message, "utf-8");
4136
4109
  const messageHex = `0x${messageBytes.toString("hex")}`;
@@ -4141,7 +4114,7 @@ async function signMessage2(options) {
4141
4114
  }
4142
4115
 
4143
4116
  // src/wallets/solana/actions/signTransaction.ts
4144
- async function signTransaction2(options) {
4117
+ async function signTransaction(options) {
4145
4118
  const { accountId, transaction } = options;
4146
4119
  const txBytes = Buffer.from(transaction, "base64");
4147
4120
  const txHex = `0x${txBytes.toString("hex")}`;
@@ -4159,14 +4132,14 @@ function toSolanaAccount(data) {
4159
4132
  address,
4160
4133
  custody: "Developer",
4161
4134
  async signMessage(parameters) {
4162
- const result = await signMessage2({
4135
+ const result = await signMessage({
4163
4136
  accountId: id,
4164
4137
  message: parameters.message
4165
4138
  });
4166
4139
  return result.signature;
4167
4140
  },
4168
4141
  async signTransaction(parameters) {
4169
- const result = await signTransaction2({
4142
+ const result = await signTransaction({
4170
4143
  accountId: id,
4171
4144
  transaction: parameters.transaction
4172
4145
  });
@@ -4404,6 +4377,17 @@ SolanaClient.type = "solanaWallet";
4404
4377
 
4405
4378
  // src/index.ts
4406
4379
  var import_shield_js2 = require("@openfort/shield-js");
4380
+
4381
+ // src/wallets/evm/actions/signMessage.ts
4382
+ var import_viem2 = require("viem");
4383
+
4384
+ // src/wallets/evm/actions/signTransaction.ts
4385
+ var import_viem3 = require("viem");
4386
+
4387
+ // src/wallets/evm/actions/signTypedData.ts
4388
+ var import_viem4 = require("viem");
4389
+
4390
+ // src/index.ts
4407
4391
  function isValidSecretKey(key) {
4408
4392
  return key.startsWith("sk_test_") || key.startsWith("sk_live_");
4409
4393
  }