@getpara/rest-sdk 3.25.0 → 3.26.0

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.
@@ -51,11 +51,29 @@ var __async = (__this, __arguments, generator) => {
51
51
  };
52
52
  var viem_exports = {};
53
53
  __export(viem_exports, {
54
+ createParaDelegatedViemAccount: () => createParaDelegatedViemAccount,
54
55
  createParaRestViemAccount: () => createParaRestViemAccount
55
56
  });
56
57
  module.exports = __toCommonJS(viem_exports);
57
58
  var import_viem = require("viem");
58
59
  var import__ = require("../index.js");
60
+ function hasDelegatedClient(options) {
61
+ return options.client !== void 0;
62
+ }
63
+ function createParaDelegatedViemAccount(options) {
64
+ const client = hasDelegatedClient(options) ? options.client : new import__.ParaRestClient({
65
+ apiKey: options.apiKey,
66
+ env: options.env,
67
+ fetch: options.fetch,
68
+ requestIdGenerator: options.requestIdGenerator
69
+ });
70
+ return createParaRestViemAccount({
71
+ client,
72
+ walletId: options.walletId,
73
+ address: options.address,
74
+ publicKey: options.publicKey
75
+ });
76
+ }
59
77
  function createParaRestViemAccount(options) {
60
78
  const { client, walletId, address, publicKey = "0x" } = options;
61
79
  return {
@@ -80,7 +98,7 @@ function createParaRestViemAccount(options) {
80
98
  });
81
99
  return normalizeSignature(res2.signature);
82
100
  }
83
- const res = yield client.signMessage(walletId, { message });
101
+ const res = yield client.signMessage(walletId, { message, walletType: "EVM" });
84
102
  return normalizeSignature(res.signature);
85
103
  }),
86
104
  signTypedData: (typedDataDefinition) => __async(null, null, function* () {
@@ -94,6 +112,7 @@ function createParaRestViemAccount(options) {
94
112
  throw new import__.ParaRestValidationError("custom transaction serializers are not supported by the REST signer");
95
113
  }
96
114
  const res = yield client.signTransaction(walletId, {
115
+ walletType: "EVM",
97
116
  transaction: toRestTransaction(transaction)
98
117
  });
99
118
  return res.signedTransaction;
@@ -174,5 +193,6 @@ function omitUndefined(value) {
174
193
  }
175
194
  // Annotate the CommonJS export names for ESM import in node:
176
195
  0 && (module.exports = {
196
+ createParaDelegatedViemAccount,
177
197
  createParaRestViemAccount
178
198
  });
@@ -35,7 +35,24 @@ var __async = (__this, __arguments, generator) => {
35
35
  });
36
36
  };
37
37
  import { hashMessage, parseSignature, serializeSignature } from "viem";
38
- import { ParaRestValidationError } from "../index.js";
38
+ import { ParaRestClient as ParaRestClientImplementation, ParaRestValidationError } from "../index.js";
39
+ function hasDelegatedClient(options) {
40
+ return options.client !== void 0;
41
+ }
42
+ function createParaDelegatedViemAccount(options) {
43
+ const client = hasDelegatedClient(options) ? options.client : new ParaRestClientImplementation({
44
+ apiKey: options.apiKey,
45
+ env: options.env,
46
+ fetch: options.fetch,
47
+ requestIdGenerator: options.requestIdGenerator
48
+ });
49
+ return createParaRestViemAccount({
50
+ client,
51
+ walletId: options.walletId,
52
+ address: options.address,
53
+ publicKey: options.publicKey
54
+ });
55
+ }
39
56
  function createParaRestViemAccount(options) {
40
57
  const { client, walletId, address, publicKey = "0x" } = options;
41
58
  return {
@@ -60,7 +77,7 @@ function createParaRestViemAccount(options) {
60
77
  });
61
78
  return normalizeSignature(res2.signature);
62
79
  }
63
- const res = yield client.signMessage(walletId, { message });
80
+ const res = yield client.signMessage(walletId, { message, walletType: "EVM" });
64
81
  return normalizeSignature(res.signature);
65
82
  }),
66
83
  signTypedData: (typedDataDefinition) => __async(null, null, function* () {
@@ -74,6 +91,7 @@ function createParaRestViemAccount(options) {
74
91
  throw new ParaRestValidationError("custom transaction serializers are not supported by the REST signer");
75
92
  }
76
93
  const res = yield client.signTransaction(walletId, {
94
+ walletType: "EVM",
77
95
  transaction: toRestTransaction(transaction)
78
96
  });
79
97
  return res.signedTransaction;
@@ -153,5 +171,6 @@ function omitUndefined(value) {
153
171
  return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
154
172
  }
155
173
  export {
174
+ createParaDelegatedViemAccount,
156
175
  createParaRestViemAccount
157
176
  };
@@ -84,12 +84,14 @@ export interface SignRawResponse {
84
84
  }
85
85
  export interface SignMessageRequest extends RestSigningRequestContext {
86
86
  message: string;
87
+ walletType?: WalletType;
87
88
  }
88
89
  export interface SignMessageResponse {
89
90
  signature: string;
90
91
  }
91
92
  export interface SignTransactionRequest extends RestSigningRequestContext {
92
93
  transaction: EvmSignTransactionRequest | string;
94
+ walletType?: WalletType;
93
95
  broadcast?: boolean;
94
96
  network?: SolanaNetwork | SuiNetwork;
95
97
  networkPassphrase?: string;
@@ -1,5 +1,5 @@
1
1
  import type { Address, Hex, LocalAccount } from 'viem';
2
- import type { ParaRestClient } from '../index.js';
2
+ import type { ParaRestClient, ParaRestClientOptions } from '../index.js';
3
3
  type ParaRestViemClient = Pick<ParaRestClient, 'signRaw' | 'signMessage' | 'signTypedData' | 'signTransaction' | 'signAuthorization'>;
4
4
  export interface CreateParaRestViemAccountOptions {
5
5
  client: ParaRestViemClient;
@@ -7,5 +7,23 @@ export interface CreateParaRestViemAccountOptions {
7
7
  address: Address;
8
8
  publicKey?: Hex;
9
9
  }
10
+ type ParaDelegatedViemAccountIdentity = Omit<CreateParaRestViemAccountOptions, 'client'>;
11
+ export type CreateParaDelegatedViemAccountOptions = ParaDelegatedViemAccountIdentity & ({
12
+ client: ParaRestViemClient;
13
+ apiKey?: never;
14
+ } | (ParaRestClientOptions & {
15
+ client?: never;
16
+ }));
17
+ /**
18
+ * Creates a server-side viem account for a user-owned wallet whose signing
19
+ * authority is enforced by an active Para signing grant.
20
+ *
21
+ * This intentionally accepts partner REST credentials and a wallet id, never a
22
+ * ParaCore user session or grant id. Para resolves the active grant on every
23
+ * normal REST signing request. While the grant is active, only a request that
24
+ * its policy allows is signed. Every other request fails with 403
25
+ * `SIGNING_GRANT_REQUIRED`.
26
+ */
27
+ export declare function createParaDelegatedViemAccount(options: CreateParaDelegatedViemAccountOptions): LocalAccount;
10
28
  export declare function createParaRestViemAccount(options: CreateParaRestViemAccountOptions): LocalAccount;
11
29
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/rest-sdk",
3
- "version": "3.25.0",
3
+ "version": "3.26.0",
4
4
  "description": "Typed server-side SDK for Para REST wallet management and signing",
5
5
  "author": "Para Team <hello@getpara.com> (https://getpara.com)",
6
6
  "homepage": "https://docs.getpara.com/v3/rest/sdk",
@@ -27,7 +27,7 @@
27
27
  "vitest": "^3.2.4"
28
28
  },
29
29
  "dependencies": {
30
- "@getpara/shared": "^1.40.0"
30
+ "@getpara/shared": "^1.42.0"
31
31
  },
32
32
  "exports": {
33
33
  ".": {
@@ -111,5 +111,5 @@
111
111
  }
112
112
  },
113
113
  "typings": "dist/types/index.d.ts",
114
- "gitHead": "757f086d7e0ff8adcc488ad0fc0801ec56366ee2"
114
+ "gitHead": "3da03ae598e47dddcad44773264bcba424537e9d"
115
115
  }