@getpara/rest-sdk 3.18.0 → 3.20.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.
package/README.md CHANGED
@@ -135,6 +135,55 @@ methods as the read model: fetch the record immediately after a broadcast, backf
135
135
  reconcile your database against Para's persisted transaction state. See the Para webhook docs for signature
136
136
  verification and `rest.transaction.confirmed` / `rest.transaction.failed` payload examples.
137
137
 
138
+ ## On-Ramp Purchases
139
+
140
+ `getOnRampPurchase` looks up a fiat on-ramp purchase by the id the SDK reports on the `ONRAMP_LAUNCHED` event — the
141
+ same id that arrives as `purchaseId` on the `onramp.completed` webhook.
142
+
143
+ ```ts
144
+ const purchase = await para.getOnRampPurchase(purchaseId);
145
+
146
+ if (purchase.status === 'FINISHED') {
147
+ console.log(purchase.transactionHash, purchase.asset.symbol, purchase.assetQuantity);
148
+ }
149
+ ```
150
+
151
+ The response is the `onramp.completed` payload plus a lifecycle `status`. A purchase that hasn't settled returns
152
+ partial data — `transactionHash` and `completedAt` are `null` until `status` is `FINISHED` — so branch on `status`
153
+ rather than inferring completion from the hash, and treat an unrecognized status as non-terminal.
154
+
155
+ As with transaction history, webhooks are the preferred way to learn about settlement; use this to backfill a missed
156
+ delivery or to check a purchase still in flight. Check `testMode` before recording a purchase in production
157
+ accounting: test purchases run a real quote but are never charged.
158
+
159
+ ## Webhook Types
160
+
161
+ Webhooks are delivered to your backend, so the types for handling them live here. `ParaWebhookEvent` is a
162
+ discriminated union, so a `switch` on `event.type` narrows `event.data` to that event's payload:
163
+
164
+ ```ts
165
+ import { WebhookEventType, type ParaWebhookEvent } from '@getpara/rest-sdk';
166
+
167
+ export function handleParaWebhook(event: ParaWebhookEvent) {
168
+ switch (event.type) {
169
+ case WebhookEventType.ONRAMP_COMPLETED:
170
+ // event.data is OnrampCompletedPayload
171
+ return credit(event.data.purchaseId, event.data.transactionHash);
172
+ case WebhookEventType.REST_TRANSACTION_CONFIRMED:
173
+ // event.data is RestTransactionConfirmedPayload
174
+ return settle(event.data.transactionId, event.data.hash);
175
+ }
176
+ }
177
+ ```
178
+
179
+ Use `ParaWebhookEvent` rather than the generic `WebhookEvent`, whose `type` and `data` are uncorrelated — `data`
180
+ stays the union of every payload regardless of `type`. Individual payload interfaces (`OnrampCompletedPayload`,
181
+ `WalletCreatedPayload`, …), the `WebhookEventPayloadMap`, and `ParaWebhookPayload<K>` are exported too, for typing a
182
+ single-event handler.
183
+
184
+ These are types only — this package does not receive, verify, or dispatch webhooks. Verify the signature on the raw
185
+ request body before trusting a delivery; see the Para webhook docs for the procedure.
186
+
138
187
  ## Adapters
139
188
 
140
189
  ```ts
package/dist/cjs/index.js CHANGED
@@ -14,6 +14,7 @@ var __copyProps = (to, from, except, desc) => {
14
14
  }
15
15
  return to;
16
16
  };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
19
  var __async = (__this, __arguments, generator) => {
19
20
  return new Promise((resolve, reject) => {
@@ -40,10 +41,15 @@ __export(index_exports, {
40
41
  ParaRestClient: () => ParaRestClient,
41
42
  ParaRestError: () => ParaRestError,
42
43
  ParaRestSerializationError: () => ParaRestSerializationError,
43
- ParaRestValidationError: () => ParaRestValidationError,
44
+ ParaRestValidationError: () => import_validation2.ParaRestValidationError,
44
45
  toRestJson: () => toRestJson
45
46
  });
46
47
  module.exports = __toCommonJS(index_exports);
48
+ var import_permissions = require("./permissions.js");
49
+ var import_validation = require("./validation.js");
50
+ __reExport(index_exports, require("./permissions.js"), module.exports);
51
+ __reExport(index_exports, require("./webhooks.js"), module.exports);
52
+ var import_validation2 = require("./validation.js");
47
53
  class ParaRestError extends Error {
48
54
  constructor({
49
55
  status,
@@ -67,12 +73,6 @@ class ParaRestSerializationError extends Error {
67
73
  this.name = "ParaRestSerializationError";
68
74
  }
69
75
  }
70
- class ParaRestValidationError extends Error {
71
- constructor(message) {
72
- super(message);
73
- this.name = "ParaRestValidationError";
74
- }
75
- }
76
76
  const BASE_URLS = {
77
77
  PROD: "https://api.getpara.com",
78
78
  BETA: "https://api.beta.getpara.com",
@@ -103,11 +103,12 @@ function toRestJson(body) {
103
103
  }
104
104
  return json;
105
105
  }
106
- class ParaRestClient {
106
+ class ParaRestClient extends import_permissions.RestPermissionsClient {
107
107
  constructor(options) {
108
108
  var _a, _b, _c;
109
+ super();
109
110
  if (!options.apiKey) {
110
- throw new ParaRestValidationError("apiKey is required");
111
+ throw new import_validation.ParaRestValidationError("apiKey is required");
111
112
  }
112
113
  this.apiKey = options.apiKey;
113
114
  this.baseUrl = resolveBaseUrl((_a = options.env) != null ? _a : "PROD");
@@ -115,10 +116,10 @@ class ParaRestClient {
115
116
  this.requestIdGenerator = (_c = options.requestIdGenerator) != null ? _c : defaultRequestId;
116
117
  }
117
118
  createWallet(body, options) {
118
- requireBody(body, "body");
119
- requireNonEmpty(body.type, "type");
120
- requireNonEmpty(body.userIdentifier, "userIdentifier");
121
- requireNonEmpty(body.userIdentifierType, "userIdentifierType");
119
+ (0, import_validation.requireBody)(body, "body");
120
+ (0, import_validation.requireNonEmpty)(body.type, "type");
121
+ (0, import_validation.requireNonEmpty)(body.userIdentifier, "userIdentifier");
122
+ (0, import_validation.requireNonEmpty)(body.userIdentifierType, "userIdentifierType");
122
123
  return this.request("POST", "/v1/wallets", { body, options, expectedStatus: 201 });
123
124
  }
124
125
  listWallets(query, options) {
@@ -128,16 +129,16 @@ class ParaRestClient {
128
129
  return this.request("GET", `/v1/wallets/${walletPath(walletId)}`, { options });
129
130
  }
130
131
  updateWalletIdentifier(walletId, body, options) {
131
- requireNonEmpty(walletId, "walletId");
132
- requireBody(body, "body");
133
- requireNonEmpty(body.userIdentifier, "userIdentifier");
134
- requireNonEmpty(body.userIdentifierType, "userIdentifierType");
132
+ (0, import_validation.requireNonEmpty)(walletId, "walletId");
133
+ (0, import_validation.requireBody)(body, "body");
134
+ (0, import_validation.requireNonEmpty)(body.userIdentifier, "userIdentifier");
135
+ (0, import_validation.requireNonEmpty)(body.userIdentifierType, "userIdentifierType");
135
136
  return this.request("PATCH", `/v1/wallets/${walletPath(walletId)}`, { body, options });
136
137
  }
137
138
  migrateShare(walletId, body, options) {
138
- requireNonEmpty(walletId, "walletId");
139
- requireBody(body, "body");
140
- requireNonEmpty(body.encryptedPayload, "encryptedPayload");
139
+ (0, import_validation.requireNonEmpty)(walletId, "walletId");
140
+ (0, import_validation.requireBody)(body, "body");
141
+ (0, import_validation.requireNonEmpty)(body.encryptedPayload, "encryptedPayload");
141
142
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/migrate-share`, { body, options });
142
143
  }
143
144
  getEnclavePublicKey(options) {
@@ -147,67 +148,67 @@ class ParaRestClient {
147
148
  return this.request("GET", `/v1/wallets/${walletPath(walletId)}/balance${queryString(query)}`, { options });
148
149
  }
149
150
  signRaw(walletId, body, options) {
150
- requireNonEmpty(walletId, "walletId");
151
- requireBody(body, "body");
152
- requireNonEmpty(body.data, "data");
151
+ (0, import_validation.requireNonEmpty)(walletId, "walletId");
152
+ (0, import_validation.requireBody)(body, "body");
153
+ (0, import_validation.requireNonEmpty)(body.data, "data");
153
154
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/sign-raw`, { body, options });
154
155
  }
155
156
  signMessage(walletId, body, options) {
156
- requireNonEmpty(walletId, "walletId");
157
- requireBody(body, "body");
158
- requireNonEmpty(body.message, "message");
157
+ (0, import_validation.requireNonEmpty)(walletId, "walletId");
158
+ (0, import_validation.requireBody)(body, "body");
159
+ (0, import_validation.requireNonEmpty)(body.message, "message");
159
160
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/sign-message`, { body, options });
160
161
  }
161
162
  signTransaction(walletId, body, options) {
162
- requireNonEmpty(walletId, "walletId");
163
- requireBody(body, "body");
163
+ (0, import_validation.requireNonEmpty)(walletId, "walletId");
164
+ (0, import_validation.requireBody)(body, "body");
164
165
  if (body.transaction == null || body.transaction === "") {
165
- throw new ParaRestValidationError("transaction is required");
166
+ throw new import_validation.ParaRestValidationError("transaction is required");
166
167
  }
167
168
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/sign-transaction`, { body, options });
168
169
  }
169
170
  signTypedData(walletId, body, options) {
170
- requireNonEmpty(walletId, "walletId");
171
- requireBody(body, "body");
172
- requireBody(body.typedData, "typedData");
173
- requireBody(body.typedData.domain, "typedData.domain");
174
- requireBody(body.typedData.types, "typedData.types");
175
- requireNonEmpty(body.typedData.primaryType, "typedData.primaryType");
176
- requireBody(body.typedData.message, "typedData.message");
171
+ (0, import_validation.requireNonEmpty)(walletId, "walletId");
172
+ (0, import_validation.requireBody)(body, "body");
173
+ (0, import_validation.requireBody)(body.typedData, "typedData");
174
+ (0, import_validation.requireBody)(body.typedData.domain, "typedData.domain");
175
+ (0, import_validation.requireBody)(body.typedData.types, "typedData.types");
176
+ (0, import_validation.requireNonEmpty)(body.typedData.primaryType, "typedData.primaryType");
177
+ (0, import_validation.requireBody)(body.typedData.message, "typedData.message");
177
178
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/sign-typed-data`, { body, options });
178
179
  }
179
180
  signAuthorization(walletId, body, options) {
180
- requireNonEmpty(walletId, "walletId");
181
- requireBody(body, "body");
182
- requireBody(body.authorization, "authorization");
181
+ (0, import_validation.requireNonEmpty)(walletId, "walletId");
182
+ (0, import_validation.requireBody)(body, "body");
183
+ (0, import_validation.requireBody)(body.authorization, "authorization");
183
184
  if (!body.authorization.address && !body.authorization.contractAddress) {
184
- throw new ParaRestValidationError("authorization.address is required");
185
+ throw new import_validation.ParaRestValidationError("authorization.address is required");
185
186
  }
186
187
  if (body.authorization.chainId == null) {
187
- throw new ParaRestValidationError("authorization.chainId is required");
188
+ throw new import_validation.ParaRestValidationError("authorization.chainId is required");
188
189
  }
189
190
  if (body.authorization.nonce == null) {
190
- throw new ParaRestValidationError("authorization.nonce is required");
191
+ throw new import_validation.ParaRestValidationError("authorization.nonce is required");
191
192
  }
192
193
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/sign-authorization`, { body, options });
193
194
  }
194
195
  transfer(walletId, body, options) {
195
- requireNonEmpty(walletId, "walletId");
196
- requireBody(body, "body");
197
- requireNonEmpty(body.to, "to");
198
- requireNonEmpty(body.value, "value");
196
+ (0, import_validation.requireNonEmpty)(walletId, "walletId");
197
+ (0, import_validation.requireBody)(body, "body");
198
+ (0, import_validation.requireNonEmpty)(body.to, "to");
199
+ (0, import_validation.requireNonEmpty)(body.value, "value");
199
200
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/transfer`, { body, options });
200
201
  }
201
202
  estimateFee(walletId, body, options) {
202
- requireNonEmpty(walletId, "walletId");
203
- requireBody(body, "body");
204
- requireNonEmpty(body.to, "to");
205
- requireNonEmpty(body.value, "value");
203
+ (0, import_validation.requireNonEmpty)(walletId, "walletId");
204
+ (0, import_validation.requireBody)(body, "body");
205
+ (0, import_validation.requireNonEmpty)(body.to, "to");
206
+ (0, import_validation.requireNonEmpty)(body.value, "value");
206
207
  return this.request("POST", `/v1/wallets/${walletPath(walletId)}/estimate-fee`, { body, options });
207
208
  }
208
209
  requestFaucet(body, options) {
209
- requireBody(body, "body");
210
- requireNonEmpty(body.walletId, "walletId");
210
+ (0, import_validation.requireBody)(body, "body");
211
+ (0, import_validation.requireNonEmpty)(body.walletId, "walletId");
211
212
  return this.request("POST", "/faucet", { body, options });
212
213
  }
213
214
  listRestTransactions(walletId, query, options) {
@@ -216,12 +217,23 @@ class ParaRestClient {
216
217
  getRestTransaction(walletId, transactionId, options) {
217
218
  return this.request(
218
219
  "GET",
219
- `/v1/wallets/${walletPath(walletId)}/transactions/${pathSegment("transactionId", transactionId)}`,
220
+ `/v1/wallets/${walletPath(walletId)}/transactions/${(0, import_validation.pathSegment)("transactionId", transactionId)}`,
220
221
  {
221
222
  options
222
223
  }
223
224
  );
224
225
  }
226
+ /**
227
+ * Look up a fiat on-ramp purchase by id — the id the SDK reports on the `ONRAMP_LAUNCHED` event, and the
228
+ * `purchaseId` on the `onramp.completed` webhook. Use it to reconcile a delivery you missed, or to check one still in flight.
229
+ *
230
+ * Scoped to the calling partner: a purchase that doesn't exist, is malformed, or belongs to another partner all
231
+ * raise an identical `ParaRestError` with status 404, so a 404 never confirms that some other partner's purchase
232
+ * id exists.
233
+ */
234
+ getOnRampPurchase(purchaseId, options) {
235
+ return this.request("GET", `/v1/onramp/purchases/${(0, import_validation.pathSegment)("purchaseId", purchaseId)}`, { options });
236
+ }
225
237
  request(_0, _1) {
226
238
  return __async(this, arguments, function* (method, path, {
227
239
  body,
@@ -267,14 +279,14 @@ class ParaRestClient {
267
279
  function resolveBaseUrl(env) {
268
280
  const baseUrl = typeof env === "string" ? BASE_URLS[env] : env.baseUrl;
269
281
  if (!baseUrl) {
270
- throw new ParaRestValidationError("baseUrl is required");
282
+ throw new import_validation.ParaRestValidationError("baseUrl is required");
271
283
  }
272
284
  return baseUrl.replace(/\/+$/, "");
273
285
  }
274
286
  function getGlobalFetch() {
275
287
  const fetchImpl = globalThis.fetch;
276
288
  if (!fetchImpl) {
277
- throw new ParaRestValidationError("fetch is required in this runtime; pass options.fetch");
289
+ throw new import_validation.ParaRestValidationError("fetch is required in this runtime; pass options.fetch");
278
290
  }
279
291
  return fetchImpl;
280
292
  }
@@ -286,21 +298,7 @@ function defaultRequestId() {
286
298
  return `req_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
287
299
  }
288
300
  function walletPath(walletId) {
289
- return pathSegment("walletId", walletId);
290
- }
291
- function pathSegment(name, value) {
292
- requireNonEmpty(value, name);
293
- return encodeURIComponent(value);
294
- }
295
- function requireBody(value, name) {
296
- if (!isRecord(value)) {
297
- throw new ParaRestValidationError(`${name} is required`);
298
- }
299
- }
300
- function requireNonEmpty(value, name) {
301
- if (value == null || value === "") {
302
- throw new ParaRestValidationError(`${name} is required`);
303
- }
301
+ return (0, import_validation.pathSegment)("walletId", walletId);
304
302
  }
305
303
  function queryString(query) {
306
304
  if (!query) return "";
@@ -335,5 +333,7 @@ function stringField(value) {
335
333
  ParaRestError,
336
334
  ParaRestSerializationError,
337
335
  ParaRestValidationError,
338
- toRestJson
336
+ toRestJson,
337
+ ...require("./permissions.js"),
338
+ ...require("./webhooks.js")
339
339
  });
@@ -0,0 +1,219 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __objRest = (source, exclude) => {
20
+ var target = {};
21
+ for (var prop in source)
22
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
23
+ target[prop] = source[prop];
24
+ if (source != null && __getOwnPropSymbols)
25
+ for (var prop of __getOwnPropSymbols(source)) {
26
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
27
+ target[prop] = source[prop];
28
+ }
29
+ return target;
30
+ };
31
+ var __export = (target, all) => {
32
+ for (var name in all)
33
+ __defProp(target, name, { get: all[name], enumerable: true });
34
+ };
35
+ var __copyProps = (to, from, except, desc) => {
36
+ if (from && typeof from === "object" || typeof from === "function") {
37
+ for (let key of __getOwnPropNames(from))
38
+ if (!__hasOwnProp.call(to, key) && key !== except)
39
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
40
+ }
41
+ return to;
42
+ };
43
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
44
+ var permissions_exports = {};
45
+ __export(permissions_exports, {
46
+ RestPermissionsClient: () => RestPermissionsClient
47
+ });
48
+ module.exports = __toCommonJS(permissions_exports);
49
+ var import_validation = require("./validation.js");
50
+ const basePath = "/v1/permissions-v2";
51
+ function queryString(query) {
52
+ if (!query) return "";
53
+ const params = new URLSearchParams();
54
+ for (const [key, value] of Object.entries(query)) {
55
+ if (value != null) params.set(key, String(value));
56
+ }
57
+ const serialized = params.toString();
58
+ return serialized ? `?${serialized}` : "";
59
+ }
60
+ function requirementPath(reference) {
61
+ return `${basePath}/authorization-scopes/${(0, import_validation.pathSegment)(
62
+ "authorizationScopeId",
63
+ reference.authorizationScopeId
64
+ )}/policies/${(0, import_validation.pathSegment)(
65
+ "policyId",
66
+ reference.policyId
67
+ )}/versions/${(0, import_validation.pathSegment)("policyVersion", reference.policyVersion)}/requirements/${(0, import_validation.pathSegment)(
68
+ "requirementId",
69
+ reference.requirementId
70
+ )}`;
71
+ }
72
+ class RestPermissionsClient {
73
+ listPartnerPolicies(options) {
74
+ return this.request("GET", `${basePath}/policies`, { options });
75
+ }
76
+ getPartnerPolicy(policyId, options) {
77
+ return this.request("GET", `${basePath}/policies/${(0, import_validation.pathSegment)("policyId", policyId)}`, { options });
78
+ }
79
+ listPartnerPolicyVersions(policyId, options) {
80
+ return this.request("GET", `${basePath}/policies/${(0, import_validation.pathSegment)("policyId", policyId)}/versions`, { options });
81
+ }
82
+ listUserPolicyConsents(userId, context, options) {
83
+ return this.request(
84
+ "GET",
85
+ `${basePath}/users/${(0, import_validation.pathSegment)("userId", userId)}/delegation-consents${queryString(context)}`,
86
+ { options }
87
+ );
88
+ }
89
+ getUserPolicyConsent(userId, policyId, context, options) {
90
+ return this.request(
91
+ "GET",
92
+ `${basePath}/users/${(0, import_validation.pathSegment)("userId", userId)}/delegation-consents/${(0, import_validation.pathSegment)(
93
+ "policyId",
94
+ policyId
95
+ )}${queryString(context)}`,
96
+ { options }
97
+ );
98
+ }
99
+ listUserAdjustablePolicies(userId, options) {
100
+ return this.request("GET", `${basePath}/users/${(0, import_validation.pathSegment)("userId", userId)}/user-parameters`, { options });
101
+ }
102
+ getUserPolicyParameters(userId, policyId, options) {
103
+ return this.request(
104
+ "GET",
105
+ `${basePath}/users/${(0, import_validation.pathSegment)("userId", userId)}/user-parameters/${(0, import_validation.pathSegment)("policyId", policyId)}`,
106
+ { options }
107
+ );
108
+ }
109
+ listUserPolicyParameterHistory(userId, policyId, query, options) {
110
+ return this.request(
111
+ "GET",
112
+ `${basePath}/users/${(0, import_validation.pathSegment)("userId", userId)}/user-parameters/${(0, import_validation.pathSegment)(
113
+ "policyId",
114
+ policyId
115
+ )}/history${queryString(query)}`,
116
+ { options }
117
+ );
118
+ }
119
+ listConfigurableApprovalRequirements(authorizationScopeId, options) {
120
+ return this.request(
121
+ "GET",
122
+ `${basePath}/authorization-scopes/${(0, import_validation.pathSegment)("authorizationScopeId", authorizationScopeId)}/requirements`,
123
+ { options }
124
+ );
125
+ }
126
+ getConfigurableApprovalRequirement(reference, options) {
127
+ return this.request("GET", requirementPath(reference), { options });
128
+ }
129
+ getApprovalConfiguration(reference, options) {
130
+ return this.request("GET", `${requirementPath(reference)}/configuration`, { options });
131
+ }
132
+ getEffectiveApprovalConfiguration(reference, options) {
133
+ return this.request("GET", `${requirementPath(reference)}/configuration/effective`, { options });
134
+ }
135
+ updateApprovalConfiguration(reference, body, options) {
136
+ return this.request("PUT", `${requirementPath(reference)}/configuration`, { body, options });
137
+ }
138
+ resetApprovalConfiguration(reference, expectedRevision, options) {
139
+ return this.updateApprovalConfiguration(reference, { expectedRevision, values: {} }, options);
140
+ }
141
+ listApprovalConfigurationHistory(reference, options) {
142
+ return this.request("GET", `${requirementPath(reference)}/configuration/history`, { options });
143
+ }
144
+ getUserApprovalAssignments(authorizationScopeId, userId, options) {
145
+ return this.request(
146
+ "GET",
147
+ `${basePath}/authorization-scopes/${(0, import_validation.pathSegment)("authorizationScopeId", authorizationScopeId)}/users/${(0, import_validation.pathSegment)(
148
+ "userId",
149
+ userId
150
+ )}/assignments`,
151
+ { options }
152
+ );
153
+ }
154
+ listAuthorizationScopeMembers(authorizationScopeId, query, options) {
155
+ return this.request(
156
+ "GET",
157
+ `${basePath}/authorization-scopes/${(0, import_validation.pathSegment)("authorizationScopeId", authorizationScopeId)}/members${queryString(
158
+ query
159
+ )}`,
160
+ { options }
161
+ );
162
+ }
163
+ replaceUserApprovalAssignments(authorizationScopeId, userId, body, options) {
164
+ return this.request(
165
+ "PUT",
166
+ `${basePath}/authorization-scopes/${(0, import_validation.pathSegment)("authorizationScopeId", authorizationScopeId)}/users/${(0, import_validation.pathSegment)(
167
+ "userId",
168
+ userId
169
+ )}/assignments`,
170
+ { body, options }
171
+ );
172
+ }
173
+ listUserApprovalAssignmentHistory(authorizationScopeId, userId, options) {
174
+ return this.request(
175
+ "GET",
176
+ `${basePath}/authorization-scopes/${(0, import_validation.pathSegment)("authorizationScopeId", authorizationScopeId)}/users/${(0, import_validation.pathSegment)(
177
+ "userId",
178
+ userId
179
+ )}/assignments/history`,
180
+ { options }
181
+ );
182
+ }
183
+ getWalletAuthorizationScope(walletId, options) {
184
+ return this.request("GET", `${basePath}/wallets/${(0, import_validation.pathSegment)("walletId", walletId)}/authorization-scope`, { options });
185
+ }
186
+ setWalletAuthorizationScope(walletId, body, options) {
187
+ return this.request("PUT", `${basePath}/wallets/${(0, import_validation.pathSegment)("walletId", walletId)}/authorization-scope`, {
188
+ body,
189
+ options
190
+ });
191
+ }
192
+ listWalletAuthorizationScopeHistory(walletId, query, options) {
193
+ return this.request(
194
+ "GET",
195
+ `${basePath}/wallets/${(0, import_validation.pathSegment)("walletId", walletId)}/authorization-scope/history${queryString(query)}`,
196
+ { options }
197
+ );
198
+ }
199
+ listPartnerApprovalCases(query, options) {
200
+ return this.request("GET", `${basePath}/approval-cases${queryString(query)}`, { options });
201
+ }
202
+ getPartnerApprovalCase(caseId, options) {
203
+ return this.request("GET", `${basePath}/approval-cases/${(0, import_validation.pathSegment)("caseId", caseId)}`, { options });
204
+ }
205
+ getPartnerPolicyUsage(policyId, context, options) {
206
+ const _a = context, { userId, walletId } = _a, query = __objRest(_a, ["userId", "walletId"]);
207
+ const subjectPath = userId ? `users/${(0, import_validation.pathSegment)("userId", userId)}` : `wallets/${(0, import_validation.pathSegment)("walletId", walletId)}`;
208
+ const usageQuery = userId ? __spreadValues({ walletId }, query) : query;
209
+ return this.request(
210
+ "GET",
211
+ `${basePath}/${subjectPath}/policies/${(0, import_validation.pathSegment)("policyId", policyId)}/usage${queryString(usageQuery)}`,
212
+ { options }
213
+ );
214
+ }
215
+ }
216
+ // Annotate the CommonJS export names for ESM import in node:
217
+ 0 && (module.exports = {
218
+ RestPermissionsClient
219
+ });
@@ -0,0 +1,52 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var validation_exports = {};
19
+ __export(validation_exports, {
20
+ ParaRestValidationError: () => ParaRestValidationError,
21
+ pathSegment: () => pathSegment,
22
+ requireBody: () => requireBody,
23
+ requireNonEmpty: () => requireNonEmpty
24
+ });
25
+ module.exports = __toCommonJS(validation_exports);
26
+ class ParaRestValidationError extends Error {
27
+ constructor(message) {
28
+ super(message);
29
+ this.name = "ParaRestValidationError";
30
+ }
31
+ }
32
+ function requireBody(value, name) {
33
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
34
+ throw new ParaRestValidationError(`${name} is required`);
35
+ }
36
+ }
37
+ function requireNonEmpty(value, name) {
38
+ if (value == null || value === "") {
39
+ throw new ParaRestValidationError(`${name} is required`);
40
+ }
41
+ }
42
+ function pathSegment(name, value) {
43
+ requireNonEmpty(value, name);
44
+ return encodeURIComponent(value);
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ ParaRestValidationError,
49
+ pathSegment,
50
+ requireBody,
51
+ requireNonEmpty
52
+ });
@@ -0,0 +1,27 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var webhooks_exports = {};
19
+ __export(webhooks_exports, {
20
+ WebhookEventType: () => import_shared.WebhookEventType
21
+ });
22
+ module.exports = __toCommonJS(webhooks_exports);
23
+ var import_shared = require("@getpara/shared");
24
+ // Annotate the CommonJS export names for ESM import in node:
25
+ 0 && (module.exports = {
26
+ WebhookEventType
27
+ });
package/dist/esm/index.js CHANGED
@@ -18,6 +18,11 @@ var __async = (__this, __arguments, generator) => {
18
18
  step((generator = generator.apply(__this, __arguments)).next());
19
19
  });
20
20
  };
21
+ import { RestPermissionsClient } from "./permissions.js";
22
+ import { ParaRestValidationError, pathSegment, requireBody, requireNonEmpty } from "./validation.js";
23
+ export * from "./permissions.js";
24
+ export * from "./webhooks.js";
25
+ import { ParaRestValidationError as ParaRestValidationError2 } from "./validation.js";
21
26
  class ParaRestError extends Error {
22
27
  constructor({
23
28
  status,
@@ -41,12 +46,6 @@ class ParaRestSerializationError extends Error {
41
46
  this.name = "ParaRestSerializationError";
42
47
  }
43
48
  }
44
- class ParaRestValidationError extends Error {
45
- constructor(message) {
46
- super(message);
47
- this.name = "ParaRestValidationError";
48
- }
49
- }
50
49
  const BASE_URLS = {
51
50
  PROD: "https://api.getpara.com",
52
51
  BETA: "https://api.beta.getpara.com",
@@ -77,9 +76,10 @@ function toRestJson(body) {
77
76
  }
78
77
  return json;
79
78
  }
80
- class ParaRestClient {
79
+ class ParaRestClient extends RestPermissionsClient {
81
80
  constructor(options) {
82
81
  var _a, _b, _c;
82
+ super();
83
83
  if (!options.apiKey) {
84
84
  throw new ParaRestValidationError("apiKey is required");
85
85
  }
@@ -196,6 +196,17 @@ class ParaRestClient {
196
196
  }
197
197
  );
198
198
  }
199
+ /**
200
+ * Look up a fiat on-ramp purchase by id — the id the SDK reports on the `ONRAMP_LAUNCHED` event, and the
201
+ * `purchaseId` on the `onramp.completed` webhook. Use it to reconcile a delivery you missed, or to check one still in flight.
202
+ *
203
+ * Scoped to the calling partner: a purchase that doesn't exist, is malformed, or belongs to another partner all
204
+ * raise an identical `ParaRestError` with status 404, so a 404 never confirms that some other partner's purchase
205
+ * id exists.
206
+ */
207
+ getOnRampPurchase(purchaseId, options) {
208
+ return this.request("GET", `/v1/onramp/purchases/${pathSegment("purchaseId", purchaseId)}`, { options });
209
+ }
199
210
  request(_0, _1) {
200
211
  return __async(this, arguments, function* (method, path, {
201
212
  body,
@@ -262,20 +273,6 @@ function defaultRequestId() {
262
273
  function walletPath(walletId) {
263
274
  return pathSegment("walletId", walletId);
264
275
  }
265
- function pathSegment(name, value) {
266
- requireNonEmpty(value, name);
267
- return encodeURIComponent(value);
268
- }
269
- function requireBody(value, name) {
270
- if (!isRecord(value)) {
271
- throw new ParaRestValidationError(`${name} is required`);
272
- }
273
- }
274
- function requireNonEmpty(value, name) {
275
- if (value == null || value === "") {
276
- throw new ParaRestValidationError(`${name} is required`);
277
- }
278
- }
279
276
  function queryString(query) {
280
277
  if (!query) return "";
281
278
  const params = new URLSearchParams();
@@ -307,6 +304,6 @@ export {
307
304
  ParaRestClient,
308
305
  ParaRestError,
309
306
  ParaRestSerializationError,
310
- ParaRestValidationError,
307
+ ParaRestValidationError2 as ParaRestValidationError,
311
308
  toRestJson
312
309
  };
@@ -0,0 +1,198 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
29
+ import { pathSegment } from "./validation.js";
30
+ const basePath = "/v1/permissions-v2";
31
+ function queryString(query) {
32
+ if (!query) return "";
33
+ const params = new URLSearchParams();
34
+ for (const [key, value] of Object.entries(query)) {
35
+ if (value != null) params.set(key, String(value));
36
+ }
37
+ const serialized = params.toString();
38
+ return serialized ? `?${serialized}` : "";
39
+ }
40
+ function requirementPath(reference) {
41
+ return `${basePath}/authorization-scopes/${pathSegment(
42
+ "authorizationScopeId",
43
+ reference.authorizationScopeId
44
+ )}/policies/${pathSegment(
45
+ "policyId",
46
+ reference.policyId
47
+ )}/versions/${pathSegment("policyVersion", reference.policyVersion)}/requirements/${pathSegment(
48
+ "requirementId",
49
+ reference.requirementId
50
+ )}`;
51
+ }
52
+ class RestPermissionsClient {
53
+ listPartnerPolicies(options) {
54
+ return this.request("GET", `${basePath}/policies`, { options });
55
+ }
56
+ getPartnerPolicy(policyId, options) {
57
+ return this.request("GET", `${basePath}/policies/${pathSegment("policyId", policyId)}`, { options });
58
+ }
59
+ listPartnerPolicyVersions(policyId, options) {
60
+ return this.request("GET", `${basePath}/policies/${pathSegment("policyId", policyId)}/versions`, { options });
61
+ }
62
+ listUserPolicyConsents(userId, context, options) {
63
+ return this.request(
64
+ "GET",
65
+ `${basePath}/users/${pathSegment("userId", userId)}/delegation-consents${queryString(context)}`,
66
+ { options }
67
+ );
68
+ }
69
+ getUserPolicyConsent(userId, policyId, context, options) {
70
+ return this.request(
71
+ "GET",
72
+ `${basePath}/users/${pathSegment("userId", userId)}/delegation-consents/${pathSegment(
73
+ "policyId",
74
+ policyId
75
+ )}${queryString(context)}`,
76
+ { options }
77
+ );
78
+ }
79
+ listUserAdjustablePolicies(userId, options) {
80
+ return this.request("GET", `${basePath}/users/${pathSegment("userId", userId)}/user-parameters`, { options });
81
+ }
82
+ getUserPolicyParameters(userId, policyId, options) {
83
+ return this.request(
84
+ "GET",
85
+ `${basePath}/users/${pathSegment("userId", userId)}/user-parameters/${pathSegment("policyId", policyId)}`,
86
+ { options }
87
+ );
88
+ }
89
+ listUserPolicyParameterHistory(userId, policyId, query, options) {
90
+ return this.request(
91
+ "GET",
92
+ `${basePath}/users/${pathSegment("userId", userId)}/user-parameters/${pathSegment(
93
+ "policyId",
94
+ policyId
95
+ )}/history${queryString(query)}`,
96
+ { options }
97
+ );
98
+ }
99
+ listConfigurableApprovalRequirements(authorizationScopeId, options) {
100
+ return this.request(
101
+ "GET",
102
+ `${basePath}/authorization-scopes/${pathSegment("authorizationScopeId", authorizationScopeId)}/requirements`,
103
+ { options }
104
+ );
105
+ }
106
+ getConfigurableApprovalRequirement(reference, options) {
107
+ return this.request("GET", requirementPath(reference), { options });
108
+ }
109
+ getApprovalConfiguration(reference, options) {
110
+ return this.request("GET", `${requirementPath(reference)}/configuration`, { options });
111
+ }
112
+ getEffectiveApprovalConfiguration(reference, options) {
113
+ return this.request("GET", `${requirementPath(reference)}/configuration/effective`, { options });
114
+ }
115
+ updateApprovalConfiguration(reference, body, options) {
116
+ return this.request("PUT", `${requirementPath(reference)}/configuration`, { body, options });
117
+ }
118
+ resetApprovalConfiguration(reference, expectedRevision, options) {
119
+ return this.updateApprovalConfiguration(reference, { expectedRevision, values: {} }, options);
120
+ }
121
+ listApprovalConfigurationHistory(reference, options) {
122
+ return this.request("GET", `${requirementPath(reference)}/configuration/history`, { options });
123
+ }
124
+ getUserApprovalAssignments(authorizationScopeId, userId, options) {
125
+ return this.request(
126
+ "GET",
127
+ `${basePath}/authorization-scopes/${pathSegment("authorizationScopeId", authorizationScopeId)}/users/${pathSegment(
128
+ "userId",
129
+ userId
130
+ )}/assignments`,
131
+ { options }
132
+ );
133
+ }
134
+ listAuthorizationScopeMembers(authorizationScopeId, query, options) {
135
+ return this.request(
136
+ "GET",
137
+ `${basePath}/authorization-scopes/${pathSegment("authorizationScopeId", authorizationScopeId)}/members${queryString(
138
+ query
139
+ )}`,
140
+ { options }
141
+ );
142
+ }
143
+ replaceUserApprovalAssignments(authorizationScopeId, userId, body, options) {
144
+ return this.request(
145
+ "PUT",
146
+ `${basePath}/authorization-scopes/${pathSegment("authorizationScopeId", authorizationScopeId)}/users/${pathSegment(
147
+ "userId",
148
+ userId
149
+ )}/assignments`,
150
+ { body, options }
151
+ );
152
+ }
153
+ listUserApprovalAssignmentHistory(authorizationScopeId, userId, options) {
154
+ return this.request(
155
+ "GET",
156
+ `${basePath}/authorization-scopes/${pathSegment("authorizationScopeId", authorizationScopeId)}/users/${pathSegment(
157
+ "userId",
158
+ userId
159
+ )}/assignments/history`,
160
+ { options }
161
+ );
162
+ }
163
+ getWalletAuthorizationScope(walletId, options) {
164
+ return this.request("GET", `${basePath}/wallets/${pathSegment("walletId", walletId)}/authorization-scope`, { options });
165
+ }
166
+ setWalletAuthorizationScope(walletId, body, options) {
167
+ return this.request("PUT", `${basePath}/wallets/${pathSegment("walletId", walletId)}/authorization-scope`, {
168
+ body,
169
+ options
170
+ });
171
+ }
172
+ listWalletAuthorizationScopeHistory(walletId, query, options) {
173
+ return this.request(
174
+ "GET",
175
+ `${basePath}/wallets/${pathSegment("walletId", walletId)}/authorization-scope/history${queryString(query)}`,
176
+ { options }
177
+ );
178
+ }
179
+ listPartnerApprovalCases(query, options) {
180
+ return this.request("GET", `${basePath}/approval-cases${queryString(query)}`, { options });
181
+ }
182
+ getPartnerApprovalCase(caseId, options) {
183
+ return this.request("GET", `${basePath}/approval-cases/${pathSegment("caseId", caseId)}`, { options });
184
+ }
185
+ getPartnerPolicyUsage(policyId, context, options) {
186
+ const _a = context, { userId, walletId } = _a, query = __objRest(_a, ["userId", "walletId"]);
187
+ const subjectPath = userId ? `users/${pathSegment("userId", userId)}` : `wallets/${pathSegment("walletId", walletId)}`;
188
+ const usageQuery = userId ? __spreadValues({ walletId }, query) : query;
189
+ return this.request(
190
+ "GET",
191
+ `${basePath}/${subjectPath}/policies/${pathSegment("policyId", policyId)}/usage${queryString(usageQuery)}`,
192
+ { options }
193
+ );
194
+ }
195
+ }
196
+ export {
197
+ RestPermissionsClient
198
+ };
@@ -0,0 +1,26 @@
1
+ class ParaRestValidationError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = "ParaRestValidationError";
5
+ }
6
+ }
7
+ function requireBody(value, name) {
8
+ if (value == null || typeof value !== "object" || Array.isArray(value)) {
9
+ throw new ParaRestValidationError(`${name} is required`);
10
+ }
11
+ }
12
+ function requireNonEmpty(value, name) {
13
+ if (value == null || value === "") {
14
+ throw new ParaRestValidationError(`${name} is required`);
15
+ }
16
+ }
17
+ function pathSegment(name, value) {
18
+ requireNonEmpty(value, name);
19
+ return encodeURIComponent(value);
20
+ }
21
+ export {
22
+ ParaRestValidationError,
23
+ pathSegment,
24
+ requireBody,
25
+ requireNonEmpty
26
+ };
@@ -0,0 +1,4 @@
1
+ import { WebhookEventType } from "@getpara/shared";
2
+ export {
3
+ WebhookEventType
4
+ };
@@ -1,4 +1,8 @@
1
- import type { TPregenIdentifierType, TWalletScheme, TWalletType } from '@getpara/shared';
1
+ import type { OnrampCompletedPayload, TPregenIdentifierType, TWalletScheme, TWalletType } from '@getpara/shared';
2
+ import { RestPermissionsClient } from './permissions.js';
3
+ export * from './permissions.js';
4
+ export * from './webhooks.js';
5
+ export { ParaRestValidationError } from './validation.js';
2
6
  export type ParaRestEnvironment = 'PROD' | 'BETA' | 'SANDBOX' | {
3
7
  baseUrl: string;
4
8
  };
@@ -218,6 +222,24 @@ export interface RestTransaction {
218
222
  submittedAt?: string;
219
223
  resolvedAt?: string;
220
224
  }
225
+ export type RestOnRampPurchaseKnownStatus = 'INITIATED' | 'FINISHED' | 'CANCELLED';
226
+ /**
227
+ * Lifecycle state of an on-ramp purchase. Treat an unrecognized value as NON-TERMINAL — new states may be added,
228
+ * and settling your own records on one you don't know is worse than waiting for a state you do.
229
+ */
230
+ export type RestOnRampPurchaseStatus = RestOnRampPurchaseKnownStatus | (string & {});
231
+ /**
232
+ * A fiat on-ramp purchase, as returned by `getOnRampPurchase`.
233
+ *
234
+ * Extends the `onramp.completed` webhook payload — the server builds both from one definition, so the two shapes
235
+ * can't diverge — with the row's lifecycle `status`. A purchase that hasn't settled yet returns partial data:
236
+ * `transactionHash` and `completedAt` are `null` until `status` is `FINISHED`, so read `status` rather than
237
+ * inferring completion from the hash.
238
+ */
239
+ export interface RestOnRampPurchase extends Omit<OnrampCompletedPayload, 'completedAt'> {
240
+ status: RestOnRampPurchaseStatus;
241
+ completedAt: string | null;
242
+ }
221
243
  export interface ParaRestCallOptions {
222
244
  idempotencyKey?: string;
223
245
  signal?: AbortSignal;
@@ -261,11 +283,8 @@ export declare class ParaRestError extends Error {
261
283
  export declare class ParaRestSerializationError extends Error {
262
284
  constructor(message: string);
263
285
  }
264
- export declare class ParaRestValidationError extends Error {
265
- constructor(message: string);
266
- }
267
286
  export declare function toRestJson(body: unknown): string;
268
- export declare class ParaRestClient {
287
+ export declare class ParaRestClient extends RestPermissionsClient {
269
288
  private readonly apiKey;
270
289
  private readonly baseUrl;
271
290
  private readonly fetchImpl;
@@ -288,5 +307,18 @@ export declare class ParaRestClient {
288
307
  requestFaucet(body: FaucetRequest, options?: ParaRestCallOptions): Promise<FaucetResponse>;
289
308
  listRestTransactions(walletId: string, query?: ListRestTransactionsRequest, options?: ParaRestCallOptions): Promise<RestListResponse<RestTransaction>>;
290
309
  getRestTransaction(walletId: string, transactionId: string, options?: ParaRestCallOptions): Promise<RestTransaction>;
291
- private request;
310
+ /**
311
+ * Look up a fiat on-ramp purchase by id — the id the SDK reports on the `ONRAMP_LAUNCHED` event, and the
312
+ * `purchaseId` on the `onramp.completed` webhook. Use it to reconcile a delivery you missed, or to check one still in flight.
313
+ *
314
+ * Scoped to the calling partner: a purchase that doesn't exist, is malformed, or belongs to another partner all
315
+ * raise an identical `ParaRestError` with status 404, so a 404 never confirms that some other partner's purchase
316
+ * id exists.
317
+ */
318
+ getOnRampPurchase(purchaseId: string, options?: ParaRestCallOptions): Promise<RestOnRampPurchase>;
319
+ protected request<T>(method: string, path: string, { body, options, expectedStatus, }?: {
320
+ body?: unknown;
321
+ options?: ParaRestCallOptions;
322
+ expectedStatus?: number;
323
+ }): Promise<T>;
292
324
  }
@@ -0,0 +1,69 @@
1
+ import type { PermissionsV2AuthoritySetHistory, PermissionsV2AuthoritySetView, PermissionsV2AuthoritySetWrite, PermissionsV2AuthorizationConfigurationHistory, PermissionsV2AuthorizationConfigurationView, PermissionsV2AuthorizationConfigurationWrite, PermissionsV2AuthorizationScopeBindingHistory, PermissionsV2AuthorizationScopeBindingView, PermissionsV2AuthorizationScopeBindingWrite, PermissionsV2AuthorizationScopeMembers, PermissionsV2ConditionalApprovalCaseView, PermissionsV2ConditionalApprovalPartnerCaseList, PermissionsV2ConditionalRequirementList, PermissionsV2ConditionalRequirementView, PermissionsV2DelegationConsentDiscoveryResponse, PermissionsV2DelegationConsentView, PermissionsV2EffectiveAuthorizationConfiguration, PermissionsV2PolicyListResponse, PermissionsV2PolicyResponse, PermissionsV2PolicyUsage, PermissionsV2PolicyVersionsResponse, PermissionsV2PolicyView, PermissionsV2UserParameterHistory, PermissionsV2UserParameterView } from '@getpara/shared';
2
+ import type { ParaRestCallOptions } from './index.js';
3
+ export type { PermissionsV2AuthoritySetHistory, PermissionsV2AuthoritySetWrite, PermissionsV2AuthorizationConfigurationHistory, PermissionsV2AuthorizationConfigurationWrite, PermissionsV2AuthorizationScopeBindingHistory, PermissionsV2AuthorizationScopeBindingWrite, PermissionsV2AuthorizationScopeMembers, PermissionsV2ConditionalApprovalPartnerCaseList, PermissionsV2ConditionalRequirementList, PermissionsV2ConditionalRequirementView, PermissionsV2EffectiveAuthorizationConfiguration, PermissionsV2PolicyListResponse, PermissionsV2PolicyResponse, PermissionsV2PolicyUsage, PermissionsV2PolicyUsageMeter, PermissionsV2PolicyVersionsResponse, PermissionsV2PolicyView, } from '@getpara/shared';
4
+ type PermissionsRequestOptions = {
5
+ body?: unknown;
6
+ options?: ParaRestCallOptions;
7
+ expectedStatus?: number;
8
+ };
9
+ export type PermissionsV2PolicyLifecycle = PermissionsV2PolicyView['lifecycle'];
10
+ export interface PermissionsV2ApprovalRequirementReference {
11
+ authorizationScopeId: string;
12
+ policyId: string;
13
+ policyVersion: string;
14
+ requirementId: string;
15
+ }
16
+ export interface PermissionsV2WalletContext {
17
+ walletId: string;
18
+ }
19
+ export interface PermissionsV2ConsentListContext extends PermissionsV2WalletContext {
20
+ pendingTransactionId?: string;
21
+ }
22
+ export interface PermissionsV2HistoryOptions {
23
+ beforeRevision?: number;
24
+ }
25
+ export interface PermissionsV2CaseListOptions {
26
+ limit?: number;
27
+ beforeCaseId?: string;
28
+ }
29
+ export interface PermissionsV2AuthorizationScopeMemberListOptions {
30
+ limit?: number;
31
+ afterUserId?: string;
32
+ }
33
+ export interface PermissionsV2PartnerUsageContext extends PermissionsV2WalletContext {
34
+ userId?: string;
35
+ chainId?: string;
36
+ tokenAddress?: string;
37
+ }
38
+ export interface PermissionsV2UserAdjustablePolicyListResponse {
39
+ policies: PermissionsV2UserParameterView[];
40
+ }
41
+ /** Partner-secret permissions methods inherited by {@link ParaRestClient}. */
42
+ export declare abstract class RestPermissionsClient {
43
+ protected abstract request<T>(method: string, path: string, options?: PermissionsRequestOptions): Promise<T>;
44
+ listPartnerPolicies(options?: ParaRestCallOptions): Promise<PermissionsV2PolicyListResponse>;
45
+ getPartnerPolicy(policyId: string, options?: ParaRestCallOptions): Promise<PermissionsV2PolicyResponse>;
46
+ listPartnerPolicyVersions(policyId: string, options?: ParaRestCallOptions): Promise<PermissionsV2PolicyVersionsResponse>;
47
+ listUserPolicyConsents(userId: string, context: PermissionsV2ConsentListContext, options?: ParaRestCallOptions): Promise<PermissionsV2DelegationConsentDiscoveryResponse>;
48
+ getUserPolicyConsent(userId: string, policyId: string, context: PermissionsV2WalletContext, options?: ParaRestCallOptions): Promise<PermissionsV2DelegationConsentView>;
49
+ listUserAdjustablePolicies(userId: string, options?: ParaRestCallOptions): Promise<PermissionsV2UserAdjustablePolicyListResponse>;
50
+ getUserPolicyParameters(userId: string, policyId: string, options?: ParaRestCallOptions): Promise<PermissionsV2UserParameterView>;
51
+ listUserPolicyParameterHistory(userId: string, policyId: string, query?: PermissionsV2HistoryOptions, options?: ParaRestCallOptions): Promise<PermissionsV2UserParameterHistory>;
52
+ listConfigurableApprovalRequirements(authorizationScopeId: string, options?: ParaRestCallOptions): Promise<PermissionsV2ConditionalRequirementList>;
53
+ getConfigurableApprovalRequirement(reference: PermissionsV2ApprovalRequirementReference, options?: ParaRestCallOptions): Promise<PermissionsV2ConditionalRequirementView>;
54
+ getApprovalConfiguration(reference: PermissionsV2ApprovalRequirementReference, options?: ParaRestCallOptions): Promise<PermissionsV2AuthorizationConfigurationView>;
55
+ getEffectiveApprovalConfiguration(reference: PermissionsV2ApprovalRequirementReference, options?: ParaRestCallOptions): Promise<PermissionsV2EffectiveAuthorizationConfiguration>;
56
+ updateApprovalConfiguration(reference: PermissionsV2ApprovalRequirementReference, body: PermissionsV2AuthorizationConfigurationWrite, options?: ParaRestCallOptions): Promise<PermissionsV2AuthorizationConfigurationView>;
57
+ resetApprovalConfiguration(reference: PermissionsV2ApprovalRequirementReference, expectedRevision: number, options?: ParaRestCallOptions): Promise<PermissionsV2AuthorizationConfigurationView>;
58
+ listApprovalConfigurationHistory(reference: PermissionsV2ApprovalRequirementReference, options?: ParaRestCallOptions): Promise<PermissionsV2AuthorizationConfigurationHistory>;
59
+ getUserApprovalAssignments(authorizationScopeId: string, userId: string, options?: ParaRestCallOptions): Promise<PermissionsV2AuthoritySetView>;
60
+ listAuthorizationScopeMembers(authorizationScopeId: string, query?: PermissionsV2AuthorizationScopeMemberListOptions, options?: ParaRestCallOptions): Promise<PermissionsV2AuthorizationScopeMembers>;
61
+ replaceUserApprovalAssignments(authorizationScopeId: string, userId: string, body: PermissionsV2AuthoritySetWrite, options?: ParaRestCallOptions): Promise<PermissionsV2AuthoritySetView>;
62
+ listUserApprovalAssignmentHistory(authorizationScopeId: string, userId: string, options?: ParaRestCallOptions): Promise<PermissionsV2AuthoritySetHistory>;
63
+ getWalletAuthorizationScope(walletId: string, options?: ParaRestCallOptions): Promise<PermissionsV2AuthorizationScopeBindingView>;
64
+ setWalletAuthorizationScope(walletId: string, body: PermissionsV2AuthorizationScopeBindingWrite, options?: ParaRestCallOptions): Promise<PermissionsV2AuthorizationScopeBindingView>;
65
+ listWalletAuthorizationScopeHistory(walletId: string, query?: PermissionsV2HistoryOptions, options?: ParaRestCallOptions): Promise<PermissionsV2AuthorizationScopeBindingHistory>;
66
+ listPartnerApprovalCases(query?: PermissionsV2CaseListOptions, options?: ParaRestCallOptions): Promise<PermissionsV2ConditionalApprovalPartnerCaseList>;
67
+ getPartnerApprovalCase(caseId: string, options?: ParaRestCallOptions): Promise<Omit<PermissionsV2ConditionalApprovalCaseView, 'decision'>>;
68
+ getPartnerPolicyUsage(policyId: string, context: PermissionsV2PartnerUsageContext, options?: ParaRestCallOptions): Promise<PermissionsV2PolicyUsage>;
69
+ }
@@ -0,0 +1,6 @@
1
+ export declare class ParaRestValidationError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare function requireBody(value: unknown, name: string): asserts value is Record<string, unknown>;
5
+ export declare function requireNonEmpty(value: unknown, name: string): asserts value is string;
6
+ export declare function pathSegment(name: string, value: string): string;
@@ -0,0 +1,42 @@
1
+ export { WebhookEventType } from '@getpara/shared';
2
+ export type { WebhookEvent, WebhookEventPayload, WebhookEventPayloadMap, UserCreatedPayload, WalletCreatedPayload, TransactionSignedPayload, SendBroadcastedPayload, SendConfirmedPayload, SendFailedPayload, RestTransactionConfirmedPayload, RestTransactionFailedPayload, WalletPregenClaimedPayload, UserExternalWalletVerifiedPayload, OnrampCompletedPayload, TestPingPayload, } from '@getpara/shared';
3
+ import type { WebhookEventPayloadMap } from '@getpara/shared';
4
+ /**
5
+ * A received webhook, as a discriminated union over the event type.
6
+ *
7
+ * Prefer this to the generic `WebhookEvent` when handling deliveries: `WebhookEvent<T>` leaves `type` and `data`
8
+ * uncorrelated, so `data` stays the union of every payload no matter what `type` says. This maps each event type to
9
+ * its own payload, so a `switch` on `event.type` narrows `event.data` to the matching shape.
10
+ *
11
+ * Derived from `WebhookEventPayloadMap`, so it picks up new event types automatically.
12
+ *
13
+ * ```ts
14
+ * import { WebhookEventType, type ParaWebhookEvent } from '@getpara/rest-sdk';
15
+ *
16
+ * function handle(event: ParaWebhookEvent) {
17
+ * switch (event.type) {
18
+ * case WebhookEventType.ONRAMP_COMPLETED:
19
+ * // event.data is OnrampCompletedPayload
20
+ * return credit(event.data.purchaseId, event.data.transactionHash);
21
+ * case WebhookEventType.WALLET_CREATED:
22
+ * // event.data is WalletCreatedPayload
23
+ * return index(event.data.walletAddress);
24
+ * }
25
+ * }
26
+ * ```
27
+ */
28
+ export type ParaWebhookEvent = {
29
+ [K in keyof WebhookEventPayloadMap]: {
30
+ /** Unique event id, prefixed with `evt_`. */
31
+ id: string;
32
+ type: K;
33
+ /** ISO 8601 timestamp of when the event was created. */
34
+ createdAt: string;
35
+ data: WebhookEventPayloadMap[K];
36
+ };
37
+ }[keyof WebhookEventPayloadMap];
38
+ /**
39
+ * The payload for a given event type — e.g. `ParaWebhookPayload<WebhookEventType.ONRAMP_COMPLETED>`. Useful for
40
+ * typing a per-event handler without restating the payload interface's name.
41
+ */
42
+ export type ParaWebhookPayload<K extends keyof WebhookEventPayloadMap> = WebhookEventPayloadMap[K];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/rest-sdk",
3
- "version": "3.18.0",
3
+ "version": "3.20.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/v2/rest/sdk",
@@ -27,7 +27,7 @@
27
27
  "vitest": "^3.2.4"
28
28
  },
29
29
  "dependencies": {
30
- "@getpara/shared": "^1.29.0"
30
+ "@getpara/shared": "^1.33.0"
31
31
  },
32
32
  "exports": {
33
33
  ".": {
@@ -110,5 +110,5 @@
110
110
  }
111
111
  },
112
112
  "typings": "dist/types/index.d.ts",
113
- "gitHead": "735fe066642c4d1d88adfd4ef737c64a1cfe16c4"
113
+ "gitHead": "0a7224c678bc2b172bd41cce75637a8783869a93"
114
114
  }