@avaprotocol/sdk-js 3.0.0 → 3.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @avaprotocol/sdk-js
2
2
 
3
+ ## 3.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8ea2a5b: Extend the catalog re-export surface and bump `@avaprotocol/protocols` to `^0.6.0`.
8
+
9
+ ## 3.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 3b4e2df: fix: `buildAuthMessage`, `signAuthMessage`, and `AuthResource.exchangeWithKey` now require a `uri` parameter (the origin URL the user is authenticating against). This replaces the previously hardcoded `https://app.avaprotocol.org` value so wallet popups display the correct site. The `uri` value is validated as a non-empty, syntactically valid URL at runtime; whitespace-only strings and non-URL values throw immediately.
14
+
3
15
  ## 3.0.0
4
16
 
5
17
  ### Major Changes — REST cutover
package/dist/index.js CHANGED
@@ -34,12 +34,14 @@ __export(index_exports, {
34
34
  OperatorsResource: () => OperatorsResource,
35
35
  Protocols: () => import_protocols2.Protocols,
36
36
  SecretsResource: () => SecretsResource,
37
+ Tokens: () => import_protocols2.Tokens,
37
38
  TokensResource: () => TokensResource,
38
39
  Triggers: () => Triggers,
39
40
  TriggersResource: () => TriggersResource,
40
41
  WalletsResource: () => WalletsResource,
41
42
  WorkflowsResource: () => WorkflowsResource,
42
43
  buildAuthMessage: () => buildAuthMessage,
44
+ lookupToken: () => import_protocols2.lookupToken,
43
45
  signAuthMessage: () => signAuthMessage
44
46
  });
45
47
  module.exports = __toCommonJS(index_exports);
@@ -195,13 +197,26 @@ var Transport = class {
195
197
  var import_ethers = require("ethers");
196
198
  var AUTH_TEMPLATE = `Please sign the below text for ownership verification.
197
199
 
198
- URI: https://app.avaprotocol.org
200
+ URI: {uri}
199
201
  Chain ID: {chainId}
200
202
  Version: {version}
201
203
  Issued At: {issuedAt}
202
204
  Expire At: {expireAt}
203
205
  Wallet: {wallet}`;
204
206
  function buildAuthMessage(input) {
207
+ const trimmedUri = typeof input.uri === "string" ? input.uri.trim() : "";
208
+ if (!trimmedUri) {
209
+ throw new Error(
210
+ "buildAuthMessage: uri must be a non-empty string (the origin the user is signing into, e.g. window.location.origin)."
211
+ );
212
+ }
213
+ try {
214
+ new URL(trimmedUri);
215
+ } catch {
216
+ throw new Error(
217
+ "buildAuthMessage: uri must be a valid URL (e.g. window.location.origin)."
218
+ );
219
+ }
205
220
  if (!Number.isInteger(input.chainId) || input.chainId <= 0) {
206
221
  throw new Error(
207
222
  "buildAuthMessage: chainId must be a positive integer (the wallet's currently-connected chain)."
@@ -215,18 +230,30 @@ function buildAuthMessage(input) {
215
230
  const issuedAt = input.issuedAt ?? /* @__PURE__ */ new Date();
216
231
  const expireAt = input.expireAt ?? new Date(issuedAt.getTime() + 24 * 60 * 60 * 1e3);
217
232
  const ownerAddress = (0, import_ethers.getAddress)(input.ownerAddress);
218
- const message = AUTH_TEMPLATE.replace("{chainId}", String(input.chainId)).replace("{version}", input.version).replace("{issuedAt}", toRFC3339Millis(issuedAt)).replace("{expireAt}", toRFC3339Millis(expireAt)).replace("{wallet}", ownerAddress);
233
+ const replacements = {
234
+ "{uri}": trimmedUri,
235
+ "{chainId}": String(input.chainId),
236
+ "{version}": input.version,
237
+ "{issuedAt}": toRFC3339Millis(issuedAt),
238
+ "{expireAt}": toRFC3339Millis(expireAt),
239
+ "{wallet}": ownerAddress
240
+ };
241
+ const message = AUTH_TEMPLATE.replace(
242
+ /\{uri\}|\{chainId\}|\{version\}|\{issuedAt\}|\{expireAt\}|\{wallet\}/g,
243
+ (m) => replacements[m]
244
+ );
219
245
  return { message, chainId: input.chainId, ownerAddress, expireAt };
220
246
  }
221
247
  async function signAuthMessage(privateKey, input) {
222
248
  if (input == null || typeof input !== "object") {
223
249
  throw new Error(
224
- "signAuthMessage: input is required \u2014 pass { chainId, version } (chainId from the wallet's connected chain, version from client.health.check())."
250
+ "signAuthMessage: input is required \u2014 pass { uri, chainId, version } (uri from the calling origin, chainId from the wallet's connected chain, version from client.health.check())."
225
251
  );
226
252
  }
227
253
  const signer = new import_ethers.Wallet(privateKey);
228
254
  const built = buildAuthMessage({
229
255
  ownerAddress: input.ownerAddress ?? signer.address,
256
+ uri: input.uri,
230
257
  chainId: input.chainId,
231
258
  version: input.version,
232
259
  issuedAt: input.issuedAt,
@@ -273,11 +300,13 @@ var AuthResource = class {
273
300
  * callers should use `buildAuthMessage` + a wallet's
274
301
  * `personal_sign` and then call `exchange()` directly.
275
302
  *
276
- * `chainId` and `version` are required for the same reasons as
277
- * `buildAuthMessage` — silently defaulting either field would
278
- * mis-route every wallet RPC the resulting JWT is used for.
279
- * `version` is the gateway binary version; the simplest source
280
- * is the `version` field returned by `client.health.check()`.
303
+ * `uri`, `chainId`, and `version` are required for the same reasons
304
+ * as `buildAuthMessage` — silent defaults would lie about the origin
305
+ * the user is signing for, mis-route wallet RPCs, or hide which
306
+ * gateway minted the JWT. `version` is the gateway binary version;
307
+ * the simplest source is the `version` field returned by
308
+ * `client.health.check()`. `uri` is the calling origin (the studio
309
+ * URL the user is on right now).
281
310
  */
282
311
  async exchangeWithKey(privateKey, opts) {
283
312
  const signed = await signAuthMessage(privateKey, opts);
@@ -980,11 +1009,13 @@ var import_protocols2 = require("@avaprotocol/protocols");
980
1009
  OperatorsResource,
981
1010
  Protocols,
982
1011
  SecretsResource,
1012
+ Tokens,
983
1013
  TokensResource,
984
1014
  Triggers,
985
1015
  TriggersResource,
986
1016
  WalletsResource,
987
1017
  WorkflowsResource,
988
1018
  buildAuthMessage,
1019
+ lookupToken,
989
1020
  signAuthMessage
990
1021
  });
package/dist/index.mjs CHANGED
@@ -149,13 +149,26 @@ var Transport = class {
149
149
  import { Wallet, getAddress } from "ethers";
150
150
  var AUTH_TEMPLATE = `Please sign the below text for ownership verification.
151
151
 
152
- URI: https://app.avaprotocol.org
152
+ URI: {uri}
153
153
  Chain ID: {chainId}
154
154
  Version: {version}
155
155
  Issued At: {issuedAt}
156
156
  Expire At: {expireAt}
157
157
  Wallet: {wallet}`;
158
158
  function buildAuthMessage(input) {
159
+ const trimmedUri = typeof input.uri === "string" ? input.uri.trim() : "";
160
+ if (!trimmedUri) {
161
+ throw new Error(
162
+ "buildAuthMessage: uri must be a non-empty string (the origin the user is signing into, e.g. window.location.origin)."
163
+ );
164
+ }
165
+ try {
166
+ new URL(trimmedUri);
167
+ } catch {
168
+ throw new Error(
169
+ "buildAuthMessage: uri must be a valid URL (e.g. window.location.origin)."
170
+ );
171
+ }
159
172
  if (!Number.isInteger(input.chainId) || input.chainId <= 0) {
160
173
  throw new Error(
161
174
  "buildAuthMessage: chainId must be a positive integer (the wallet's currently-connected chain)."
@@ -169,18 +182,30 @@ function buildAuthMessage(input) {
169
182
  const issuedAt = input.issuedAt ?? /* @__PURE__ */ new Date();
170
183
  const expireAt = input.expireAt ?? new Date(issuedAt.getTime() + 24 * 60 * 60 * 1e3);
171
184
  const ownerAddress = getAddress(input.ownerAddress);
172
- const message = AUTH_TEMPLATE.replace("{chainId}", String(input.chainId)).replace("{version}", input.version).replace("{issuedAt}", toRFC3339Millis(issuedAt)).replace("{expireAt}", toRFC3339Millis(expireAt)).replace("{wallet}", ownerAddress);
185
+ const replacements = {
186
+ "{uri}": trimmedUri,
187
+ "{chainId}": String(input.chainId),
188
+ "{version}": input.version,
189
+ "{issuedAt}": toRFC3339Millis(issuedAt),
190
+ "{expireAt}": toRFC3339Millis(expireAt),
191
+ "{wallet}": ownerAddress
192
+ };
193
+ const message = AUTH_TEMPLATE.replace(
194
+ /\{uri\}|\{chainId\}|\{version\}|\{issuedAt\}|\{expireAt\}|\{wallet\}/g,
195
+ (m) => replacements[m]
196
+ );
173
197
  return { message, chainId: input.chainId, ownerAddress, expireAt };
174
198
  }
175
199
  async function signAuthMessage(privateKey, input) {
176
200
  if (input == null || typeof input !== "object") {
177
201
  throw new Error(
178
- "signAuthMessage: input is required \u2014 pass { chainId, version } (chainId from the wallet's connected chain, version from client.health.check())."
202
+ "signAuthMessage: input is required \u2014 pass { uri, chainId, version } (uri from the calling origin, chainId from the wallet's connected chain, version from client.health.check())."
179
203
  );
180
204
  }
181
205
  const signer = new Wallet(privateKey);
182
206
  const built = buildAuthMessage({
183
207
  ownerAddress: input.ownerAddress ?? signer.address,
208
+ uri: input.uri,
184
209
  chainId: input.chainId,
185
210
  version: input.version,
186
211
  issuedAt: input.issuedAt,
@@ -227,11 +252,13 @@ var AuthResource = class {
227
252
  * callers should use `buildAuthMessage` + a wallet's
228
253
  * `personal_sign` and then call `exchange()` directly.
229
254
  *
230
- * `chainId` and `version` are required for the same reasons as
231
- * `buildAuthMessage` — silently defaulting either field would
232
- * mis-route every wallet RPC the resulting JWT is used for.
233
- * `version` is the gateway binary version; the simplest source
234
- * is the `version` field returned by `client.health.check()`.
255
+ * `uri`, `chainId`, and `version` are required for the same reasons
256
+ * as `buildAuthMessage` — silent defaults would lie about the origin
257
+ * the user is signing for, mis-route wallet RPCs, or hide which
258
+ * gateway minted the JWT. `version` is the gateway binary version;
259
+ * the simplest source is the `version` field returned by
260
+ * `client.health.check()`. `uri` is the calling origin (the studio
261
+ * URL the user is on right now).
235
262
  */
236
263
  async exchangeWithKey(privateKey, opts) {
237
264
  const signed = await signAuthMessage(privateKey, opts);
@@ -917,7 +944,11 @@ var Nodes = Object.freeze({
917
944
  });
918
945
 
919
946
  // src/v4/protocols/index.ts
920
- import { Protocols } from "@avaprotocol/protocols";
947
+ import {
948
+ Protocols,
949
+ Tokens,
950
+ lookupToken
951
+ } from "@avaprotocol/protocols";
921
952
  export {
922
953
  APIError,
923
954
  AUTH_TEMPLATE,
@@ -933,11 +964,13 @@ export {
933
964
  OperatorsResource,
934
965
  Protocols,
935
966
  SecretsResource,
967
+ Tokens,
936
968
  TokensResource,
937
969
  Triggers,
938
970
  TriggersResource,
939
971
  WalletsResource,
940
972
  WorkflowsResource,
941
973
  buildAuthMessage,
974
+ lookupToken,
942
975
  signAuthMessage
943
976
  };
package/dist/v4/auth.d.ts CHANGED
@@ -6,10 +6,21 @@
6
6
  * (build + sign) so non-SDK callers (web wallets, smart-account
7
7
  * signers) can produce a message that exchanges cleanly.
8
8
  */
9
- export declare const AUTH_TEMPLATE = "Please sign the below text for ownership verification.\n\nURI: https://app.avaprotocol.org\nChain ID: {chainId}\nVersion: {version}\nIssued At: {issuedAt}\nExpire At: {expireAt}\nWallet: {wallet}";
9
+ export declare const AUTH_TEMPLATE = "Please sign the below text for ownership verification.\n\nURI: {uri}\nChain ID: {chainId}\nVersion: {version}\nIssued At: {issuedAt}\nExpire At: {expireAt}\nWallet: {wallet}";
10
10
  export interface BuildAuthMessageInput {
11
11
  /** EOA the JWT will be bound to. Lowercased / checksummed both work. */
12
12
  ownerAddress: string;
13
+ /**
14
+ * Origin URL the user is authenticating against. Required — callers
15
+ * MUST pass the actual studio/app origin the user is on right now
16
+ * (e.g. `https://app.avaprotocol.org` in production, `http://localhost:3000`
17
+ * in local dev). Shows up in the wallet popup as the "site" the user
18
+ * is granting access to, so a dishonest value reads as a phishing
19
+ * attempt or a config bug. The aggregator currently does not validate
20
+ * this field, but it's a candidate for cross-origin replay protection
21
+ * if it's ever turned on server-side.
22
+ */
23
+ uri: string;
13
24
  /**
14
25
  * Chain ID to embed in the canonical message. Required — callers
15
26
  * MUST pass the user's currently-connected wallet chain (e.g.
@@ -52,7 +63,8 @@ export interface BuiltAuthMessage {
52
63
  * @example
53
64
  * const { version } = await client.health.check();
54
65
  * const chainId = await wallet.getChainId();
55
- * const { message } = buildAuthMessage({ ownerAddress, chainId, version });
66
+ * const uri = window.location.origin; // or the studio's getSiteUrlOrDefault()
67
+ * const { message } = buildAuthMessage({ ownerAddress, uri, chainId, version });
56
68
  * const signature = await wallet.signMessage(message);
57
69
  * const { token } = await client.auth.exchange({ ownerAddress, message, signature });
58
70
  */
@@ -64,9 +76,10 @@ export declare function buildAuthMessage(input: BuildAuthMessageInput): BuiltAut
64
76
  * where the private key is in hand; browser flows use
65
77
  * `buildAuthMessage` + a wallet's `personal_sign`.
66
78
  *
67
- * `chainId` and `version` are required for the same reasons as
68
- * `buildAuthMessage` — silent defaults would lie about the chain
69
- * the JWT is bound to and the gateway it was signed against.
79
+ * `uri`, `chainId`, and `version` are required for the same reasons as
80
+ * `buildAuthMessage` — silent defaults would lie about the origin the
81
+ * user is signing for, the chain the JWT is bound to, or the gateway
82
+ * it was signed against.
70
83
  */
71
84
  export declare function signAuthMessage(privateKey: string, input: Omit<BuildAuthMessageInput, "ownerAddress"> & {
72
85
  ownerAddress?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/v4/auth.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,wMAOT,CAAC;AAElB,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;;;OAaG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,gBAAgB,CAuB/E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,cAAc,CAAC,GAAG;IAAE,YAAY,CAAC,EAAE,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AAQ,EAAE,IAAI,CAAA;CAAE,CAAC,CA4BvF"}
package/dist/v4/auth.js CHANGED
@@ -9,7 +9,7 @@ import { Wallet, getAddress } from "ethers";
9
9
  */
10
10
  export const AUTH_TEMPLATE = `Please sign the below text for ownership verification.
11
11
 
12
- URI: https://app.avaprotocol.org
12
+ URI: {uri}
13
13
  Chain ID: {chainId}
14
14
  Version: {version}
15
15
  Issued At: {issuedAt}
@@ -23,11 +23,22 @@ Wallet: {wallet}`;
23
23
  * @example
24
24
  * const { version } = await client.health.check();
25
25
  * const chainId = await wallet.getChainId();
26
- * const { message } = buildAuthMessage({ ownerAddress, chainId, version });
26
+ * const uri = window.location.origin; // or the studio's getSiteUrlOrDefault()
27
+ * const { message } = buildAuthMessage({ ownerAddress, uri, chainId, version });
27
28
  * const signature = await wallet.signMessage(message);
28
29
  * const { token } = await client.auth.exchange({ ownerAddress, message, signature });
29
30
  */
30
31
  export function buildAuthMessage(input) {
32
+ const trimmedUri = typeof input.uri === "string" ? input.uri.trim() : "";
33
+ if (!trimmedUri) {
34
+ throw new Error("buildAuthMessage: uri must be a non-empty string (the origin the user is signing into, e.g. window.location.origin).");
35
+ }
36
+ try {
37
+ new URL(trimmedUri);
38
+ }
39
+ catch {
40
+ throw new Error("buildAuthMessage: uri must be a valid URL (e.g. window.location.origin).");
41
+ }
31
42
  if (!Number.isInteger(input.chainId) || input.chainId <= 0) {
32
43
  throw new Error("buildAuthMessage: chainId must be a positive integer (the wallet's currently-connected chain).");
33
44
  }
@@ -39,12 +50,15 @@ export function buildAuthMessage(input) {
39
50
  // Canonicalize the address so the wire form matches what the
40
51
  // aggregator extracts via crypto.PubkeyToAddress.
41
52
  const ownerAddress = getAddress(input.ownerAddress);
42
- const message = AUTH_TEMPLATE
43
- .replace("{chainId}", String(input.chainId))
44
- .replace("{version}", input.version)
45
- .replace("{issuedAt}", toRFC3339Millis(issuedAt))
46
- .replace("{expireAt}", toRFC3339Millis(expireAt))
47
- .replace("{wallet}", ownerAddress);
53
+ const replacements = {
54
+ "{uri}": trimmedUri,
55
+ "{chainId}": String(input.chainId),
56
+ "{version}": input.version,
57
+ "{issuedAt}": toRFC3339Millis(issuedAt),
58
+ "{expireAt}": toRFC3339Millis(expireAt),
59
+ "{wallet}": ownerAddress,
60
+ };
61
+ const message = AUTH_TEMPLATE.replace(/\{uri\}|\{chainId\}|\{version\}|\{issuedAt\}|\{expireAt\}|\{wallet\}/g, (m) => replacements[m]);
48
62
  return { message, chainId: input.chainId, ownerAddress, expireAt };
49
63
  }
50
64
  /**
@@ -54,9 +68,10 @@ export function buildAuthMessage(input) {
54
68
  * where the private key is in hand; browser flows use
55
69
  * `buildAuthMessage` + a wallet's `personal_sign`.
56
70
  *
57
- * `chainId` and `version` are required for the same reasons as
58
- * `buildAuthMessage` — silent defaults would lie about the chain
59
- * the JWT is bound to and the gateway it was signed against.
71
+ * `uri`, `chainId`, and `version` are required for the same reasons as
72
+ * `buildAuthMessage` — silent defaults would lie about the origin the
73
+ * user is signing for, the chain the JWT is bound to, or the gateway
74
+ * it was signed against.
60
75
  */
61
76
  export async function signAuthMessage(privateKey, input) {
62
77
  // Defensive runtime guard for JS callers / TS callers casting through
@@ -64,11 +79,12 @@ export async function signAuthMessage(privateKey, input) {
64
79
  // undefined" inside buildAuthMessage. The type-level requirement
65
80
  // stands; this just makes the breaking-change error legible.
66
81
  if (input == null || typeof input !== "object") {
67
- throw new Error("signAuthMessage: input is required — pass { chainId, version } (chainId from the wallet's connected chain, version from client.health.check()).");
82
+ throw new Error("signAuthMessage: input is required — pass { uri, chainId, version } (uri from the calling origin, chainId from the wallet's connected chain, version from client.health.check()).");
68
83
  }
69
84
  const signer = new Wallet(privateKey);
70
85
  const built = buildAuthMessage({
71
86
  ownerAddress: input.ownerAddress ?? signer.address,
87
+ uri: input.uri,
72
88
  chainId: input.chainId,
73
89
  version: input.version,
74
90
  issuedAt: input.issuedAt,
@@ -2,7 +2,7 @@ export { Client, type ClientOptions } from "./client";
2
2
  export { Chains, type ChainId } from "./chains";
3
3
  export { Triggers } from "./builders/triggers";
4
4
  export { Nodes } from "./builders/nodes";
5
- export { Protocols, type AbiFragment, type AddressByChain } from "./protocols";
5
+ export { Protocols, Tokens, lookupToken, type AbiFragment, type AddressByChain, type TokenByChain, type TokenChainEntry, type TokenLinks, } from "./protocols";
6
6
  export { buildAuthMessage, signAuthMessage, AUTH_TEMPLATE, type BuildAuthMessageInput, type BuiltAuthMessage, } from "./auth";
7
7
  export { APIError, NetworkError, AuthRequiredError } from "./internal/errors";
8
8
  export { AuthResource } from "./resources/auth";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v4/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,GACtB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAK9E,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE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Ae,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI1D,YAAY,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/v4/index.js CHANGED
@@ -6,7 +6,7 @@ export { Client } from "./client";
6
6
  export { Chains } from "./chains";
7
7
  export { Triggers } from "./builders/triggers";
8
8
  export { Nodes } from "./builders/nodes";
9
- export { Protocols } from "./protocols";
9
+ export { Protocols, Tokens, lookupToken, } from "./protocols";
10
10
  export { buildAuthMessage, signAuthMessage, AUTH_TEMPLATE, } from "./auth";
11
11
  export { APIError, NetworkError, AuthRequiredError } from "./internal/errors";
12
12
  // Resource classes are exported in case advanced consumers want to
@@ -1,2 +1,2 @@
1
- export { Protocols, type AbiFragment, type AddressByChain } from "@avaprotocol/protocols";
1
+ export { Protocols, Tokens, lookupToken, type AbiFragment, type AddressByChain, type TokenByChain, type TokenChainEntry, type TokenLinks, } from "@avaprotocol/protocols";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v4/protocols/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v4/protocols/index.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,SAAS,EACT,MAAM,EACN,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,UAAU,GAChB,MAAM,wBAAwB,CAAC"}
@@ -10,4 +10,4 @@
10
10
  // when a new protocol address lands or a new chain comes online;
11
11
  // bumping `@avaprotocol/protocols` minor version + republishing this
12
12
  // SDK package picks it up automatically.
13
- export { Protocols } from "@avaprotocol/protocols";
13
+ export { Protocols, Tokens, lookupToken, } from "@avaprotocol/protocols";
@@ -25,14 +25,17 @@ export declare class AuthResource {
25
25
  * callers should use `buildAuthMessage` + a wallet's
26
26
  * `personal_sign` and then call `exchange()` directly.
27
27
  *
28
- * `chainId` and `version` are required for the same reasons as
29
- * `buildAuthMessage` — silently defaulting either field would
30
- * mis-route every wallet RPC the resulting JWT is used for.
31
- * `version` is the gateway binary version; the simplest source
32
- * is the `version` field returned by `client.health.check()`.
28
+ * `uri`, `chainId`, and `version` are required for the same reasons
29
+ * as `buildAuthMessage` — silent defaults would lie about the origin
30
+ * the user is signing for, mis-route wallet RPCs, or hide which
31
+ * gateway minted the JWT. `version` is the gateway binary version;
32
+ * the simplest source is the `version` field returned by
33
+ * `client.health.check()`. `uri` is the calling origin (the studio
34
+ * URL the user is on right now).
33
35
  */
34
36
  exchangeWithKey(privateKey: string, opts: {
35
37
  ownerAddress?: string;
38
+ uri: string;
36
39
  chainId: number;
37
40
  version: string;
38
41
  }): Promise<v4.AuthExchangeResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/v4/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;GAOG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEjD;;;;;OAKG;IACG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAmB,GAAG,OAAO,CAAC,EAAE,CAAC,oBAAoB,CAAC;IAY7E;;;;;;;;;;;;OAYG;IACG,eAAe,CACnB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAChE,OAAO,CAAC,EAAE,CAAC,oBAAoB,CAAC;IASnC;;;OAGG;IACH,KAAK,IAAI,IAAI;CAGd"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/v4/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;GAOG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAEjD;;;;;OAKG;IACG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAmB,GAAG,OAAO,CAAC,EAAE,CAAC,oBAAoB,CAAC;IAY7E;;;;;;;;;;;;;;OAcG;IACG,eAAe,CACnB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAC7E,OAAO,CAAC,EAAE,CAAC,oBAAoB,CAAC;IASnC;;;OAGG;IACH,KAAK,IAAI,IAAI;CAGd"}
@@ -35,11 +35,13 @@ export class AuthResource {
35
35
  * callers should use `buildAuthMessage` + a wallet's
36
36
  * `personal_sign` and then call `exchange()` directly.
37
37
  *
38
- * `chainId` and `version` are required for the same reasons as
39
- * `buildAuthMessage` — silently defaulting either field would
40
- * mis-route every wallet RPC the resulting JWT is used for.
41
- * `version` is the gateway binary version; the simplest source
42
- * is the `version` field returned by `client.health.check()`.
38
+ * `uri`, `chainId`, and `version` are required for the same reasons
39
+ * as `buildAuthMessage` — silent defaults would lie about the origin
40
+ * the user is signing for, mis-route wallet RPCs, or hide which
41
+ * gateway minted the JWT. `version` is the gateway binary version;
42
+ * the simplest source is the `version` field returned by
43
+ * `client.health.check()`. `uri` is the calling origin (the studio
44
+ * URL the user is on right now).
43
45
  */
44
46
  async exchangeWithKey(privateKey, opts) {
45
47
  const signed = await signAuthMessage(privateKey, opts);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avaprotocol/sdk-js",
3
- "version": "3.0.0",
3
+ "version": "3.2.0",
4
4
  "description": "TypeScript SDK for Ava Protocol's AVS REST API. Resource-grouped sub-clients, fetch transport, EIP-191 auth.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "prepare": "node ../../scripts/prepare-package.js"
33
33
  },
34
34
  "dependencies": {
35
- "@avaprotocol/protocols": "^0.2.0",
35
+ "@avaprotocol/protocols": "^0.6.0",
36
36
  "@avaprotocol/types": "^3.0.0",
37
37
  "dotenv": "^16.4.5",
38
38
  "ethers": "^6.13.2"