@metamask-previews/snap-networks-utils 3.0.0-preview-20251b05 → 3.0.0-preview-3fffa79

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.
@@ -45,6 +45,6 @@ export declare class SecurityAlertsApiClient {
45
45
  * @throws HttpError if the request fails, the API responds
46
46
  * with a non-2xx status, or the response body cannot be parsed as JSON.
47
47
  */
48
- scanTransaction(body: unknown): Promise<unknown>;
48
+ scanTransaction(body: unknown): Promise<any>;
49
49
  }
50
50
  //# sourceMappingURL=SecurityAlertsApiClient.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SecurityAlertsApiClient.d.mts","sourceRoot":"","sources":["../../../src/clients/security-alerts-api/SecurityAlertsApiClient.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGlE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAuB;;IAKlC;;;;;;;;OAQG;gBACS,EACV,OAAO,EACP,KAAK,EAAE,OAA0B,GAClC,EAAE,8BAA8B;IAOjC;;;;;;;OAOG;IACG,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAuBvD"}
1
+ {"version":3,"file":"SecurityAlertsApiClient.d.mts","sourceRoot":"","sources":["../../../src/clients/security-alerts-api/SecurityAlertsApiClient.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGlE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAuB;;IAKlC;;;;;;;;OAQG;gBACS,EACV,OAAO,EACP,KAAK,EAAE,OAA0B,GAClC,EAAE,8BAA8B;IAOjC;;;;;;;OAOG;IAEG,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;CAuBnD"}
@@ -45,6 +45,7 @@ export class SecurityAlertsApiClient {
45
45
  * @throws HttpError if the request fails, the API responds
46
46
  * with a non-2xx status, or the response body cannot be parsed as JSON.
47
47
  */
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
49
  async scanTransaction(body) {
49
50
  try {
50
51
  const response = await this.#fetch(this.#scanUrl, {
@@ -1 +1 @@
1
- {"version":3,"file":"SecurityAlertsApiClient.mjs","sourceRoot":"","sources":["../../../src/clients/security-alerts-api/SecurityAlertsApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAE/C,OAAO,EAAE,SAAS,EAAE,qCAA2B;AAC/C,OAAO,EAAE,SAAS,EAAE,4CAAwC;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAA2B;IACrE,cAAc,EAAE,kBAAkB;IAClC,MAAM,EAAE,kBAAkB;CAC3B,CAAC;AAcF;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,uBAAuB;IACzB,MAAM,CAA0B;IAEhC,QAAQ,CAAS;IAE1B;;;;;;;;OAQG;IACH,YAAY,EACV,OAAO,EACP,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC,KAAK,GACF;QAC/B,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAE3B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,eAAe,CAAC,IAAa;QACjC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChD,OAAO,EAAE,EAAE,GAAG,+BAA+B,EAAE;gBAC/C,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;aAC3B,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,SAAS,CAAC,uBAAuB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAChE,CAAC;YAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;gBAC/B,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,IAAI,SAAS,CAAC,2BAA2B,EAAE;gBAC/C,KAAK,EAAE,KAAK;aACb,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import { assert } from '@metamask/superstruct';\n\nimport { HttpError } from '../../utils/errors';\nimport { UrlStruct } from '../../utils/urlStruct/urlStruct';\n\n/**\n * Headers sent with every Security Alerts API request.\n */\nexport const SECURITY_ALERTS_REQUEST_HEADERS: Record<string, string> = {\n 'Content-Type': 'application/json',\n accept: 'application/json',\n};\n\n/**\n * Options for a `SecurityAlertsApiClient` constructor.\n */\nexport type SecurityAlertsApiClientOptions = {\n /**\n * The full scan endpoint URL, e.g. `https://security-alerts.api.cx.metamask.io/tron/transaction/scan`.\n */\n scanUrl: string;\n /** The fetch implementation to use. Defaults to `globalThis.fetch`. */\n fetch?: typeof globalThis.fetch;\n};\n\n/**\n * HTTP client for a Security Alerts API scan endpoint.\n *\n * Owns the request envelope shared by every chain — POSTing the JSON body,\n * wrapping request failures, non-2xx responses, and malformed JSON bodies as\n * {@link HttpError}, and parsing the JSON response — and nothing\n * else.\n *\n * The request body is a chain-specific Blockaid contract: the caller\n * supplies a typed body (e.g. checked with `satisfies` against a per-snap\n * body type) and is responsible for validating the parsed response payload.\n */\nexport class SecurityAlertsApiClient {\n readonly #fetch: typeof globalThis.fetch;\n\n readonly #scanUrl: string;\n\n /**\n * Creates a new SecurityAlertsApiClient.\n *\n * @param options - The client options.\n * @param options.scanUrl - The full scan endpoint URL. Validated once, so\n * an invalid URL fails fast at construction.\n * @param options.fetch - Optional fetch implementation; defaults to\n * `globalThis.fetch`.\n */\n constructor({\n scanUrl,\n fetch: fetchFn = globalThis.fetch,\n }: SecurityAlertsApiClientOptions) {\n assert(scanUrl, UrlStruct);\n\n this.#fetch = fetchFn;\n this.#scanUrl = scanUrl;\n }\n\n /**\n * Scans a transaction by posting the request body to the scan endpoint.\n *\n * @param body - The chain-specific scan request body.\n * @returns The parsed scan response.\n * @throws HttpError if the request fails, the API responds\n * with a non-2xx status, or the response body cannot be parsed as JSON.\n */\n async scanTransaction(body: unknown): Promise<unknown> {\n try {\n const response = await this.#fetch(this.#scanUrl, {\n headers: { ...SECURITY_ALERTS_REQUEST_HEADERS },\n method: 'POST',\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n throw new HttpError(`HTTP error! status: ${response.status}`);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof HttpError) {\n throw error;\n }\n\n throw new HttpError('Security Alerts API error', {\n cause: error,\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"SecurityAlertsApiClient.mjs","sourceRoot":"","sources":["../../../src/clients/security-alerts-api/SecurityAlertsApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAE/C,OAAO,EAAE,SAAS,EAAE,qCAA2B;AAC/C,OAAO,EAAE,SAAS,EAAE,4CAAwC;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAA2B;IACrE,cAAc,EAAE,kBAAkB;IAClC,MAAM,EAAE,kBAAkB;CAC3B,CAAC;AAcF;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,uBAAuB;IACzB,MAAM,CAA0B;IAEhC,QAAQ,CAAS;IAE1B;;;;;;;;OAQG;IACH,YAAY,EACV,OAAO,EACP,KAAK,EAAE,OAAO,GAAG,UAAU,CAAC,KAAK,GACF;QAC/B,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAE3B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,8DAA8D;IAC9D,KAAK,CAAC,eAAe,CAAC,IAAa;QACjC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChD,OAAO,EAAE,EAAE,GAAG,+BAA+B,EAAE;gBAC/C,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;aAC3B,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,SAAS,CAAC,uBAAuB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAChE,CAAC;YAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;gBAC/B,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,IAAI,SAAS,CAAC,2BAA2B,EAAE;gBAC/C,KAAK,EAAE,KAAK;aACb,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import { assert } from '@metamask/superstruct';\n\nimport { HttpError } from '../../utils/errors';\nimport { UrlStruct } from '../../utils/urlStruct/urlStruct';\n\n/**\n * Headers sent with every Security Alerts API request.\n */\nexport const SECURITY_ALERTS_REQUEST_HEADERS: Record<string, string> = {\n 'Content-Type': 'application/json',\n accept: 'application/json',\n};\n\n/**\n * Options for a `SecurityAlertsApiClient` constructor.\n */\nexport type SecurityAlertsApiClientOptions = {\n /**\n * The full scan endpoint URL, e.g. `https://security-alerts.api.cx.metamask.io/tron/transaction/scan`.\n */\n scanUrl: string;\n /** The fetch implementation to use. Defaults to `globalThis.fetch`. */\n fetch?: typeof globalThis.fetch;\n};\n\n/**\n * HTTP client for a Security Alerts API scan endpoint.\n *\n * Owns the request envelope shared by every chain — POSTing the JSON body,\n * wrapping request failures, non-2xx responses, and malformed JSON bodies as\n * {@link HttpError}, and parsing the JSON response — and nothing\n * else.\n *\n * The request body is a chain-specific Blockaid contract: the caller\n * supplies a typed body (e.g. checked with `satisfies` against a per-snap\n * body type) and is responsible for validating the parsed response payload.\n */\nexport class SecurityAlertsApiClient {\n readonly #fetch: typeof globalThis.fetch;\n\n readonly #scanUrl: string;\n\n /**\n * Creates a new SecurityAlertsApiClient.\n *\n * @param options - The client options.\n * @param options.scanUrl - The full scan endpoint URL. Validated once, so\n * an invalid URL fails fast at construction.\n * @param options.fetch - Optional fetch implementation; defaults to\n * `globalThis.fetch`.\n */\n constructor({\n scanUrl,\n fetch: fetchFn = globalThis.fetch,\n }: SecurityAlertsApiClientOptions) {\n assert(scanUrl, UrlStruct);\n\n this.#fetch = fetchFn;\n this.#scanUrl = scanUrl;\n }\n\n /**\n * Scans a transaction by posting the request body to the scan endpoint.\n *\n * @param body - The chain-specific scan request body.\n * @returns The parsed scan response.\n * @throws HttpError if the request fails, the API responds\n * with a non-2xx status, or the response body cannot be parsed as JSON.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async scanTransaction(body: unknown): Promise<any> {\n try {\n const response = await this.#fetch(this.#scanUrl, {\n headers: { ...SECURITY_ALERTS_REQUEST_HEADERS },\n method: 'POST',\n body: JSON.stringify(body),\n });\n\n if (!response.ok) {\n throw new HttpError(`HTTP error! status: ${response.status}`);\n }\n\n return await response.json();\n } catch (error) {\n if (error instanceof HttpError) {\n throw error;\n }\n\n throw new HttpError('Security Alerts API error', {\n cause: error,\n });\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/snap-networks-utils",
3
- "version": "3.0.0-preview-20251b05",
3
+ "version": "3.0.0-preview-3fffa79",
4
4
  "description": "Shared utilities for MetaMask network snaps",
5
5
  "keywords": [
6
6
  "Ethereum",