@plyaz/api 1.3.0 → 1.4.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.
Files changed (55) hide show
  1. package/dist/api/endpoints/cdn.d.ts +122 -0
  2. package/dist/api/endpoints/cdn.d.ts.map +1 -0
  3. package/dist/api/endpoints/index.d.ts +34 -4
  4. package/dist/api/endpoints/index.d.ts.map +1 -1
  5. package/dist/api/endpoints/virustotal.d.ts +91 -0
  6. package/dist/api/endpoints/virustotal.d.ts.map +1 -0
  7. package/dist/api/services/cdn/cloudflare/POST/cloudflarePurgeCache.d.ts +35 -0
  8. package/dist/api/services/cdn/cloudflare/POST/cloudflarePurgeCache.d.ts.map +1 -0
  9. package/dist/api/services/cdn/cloudflare/POST/index.d.ts +5 -0
  10. package/dist/api/services/cdn/cloudflare/POST/index.d.ts.map +1 -0
  11. package/dist/api/services/cdn/cloudflare/index.d.ts +5 -0
  12. package/dist/api/services/cdn/cloudflare/index.d.ts.map +1 -0
  13. package/dist/api/services/cdn/cloudfront/POST/cloudFrontCreateInvalidation.d.ts +38 -0
  14. package/dist/api/services/cdn/cloudfront/POST/cloudFrontCreateInvalidation.d.ts.map +1 -0
  15. package/dist/api/services/cdn/cloudfront/POST/index.d.ts +5 -0
  16. package/dist/api/services/cdn/cloudfront/POST/index.d.ts.map +1 -0
  17. package/dist/api/services/cdn/cloudfront/index.d.ts +5 -0
  18. package/dist/api/services/cdn/cloudfront/index.d.ts.map +1 -0
  19. package/dist/api/services/cdn/fastly/POST/fastlyPurgeUrl.d.ts +35 -0
  20. package/dist/api/services/cdn/fastly/POST/fastlyPurgeUrl.d.ts.map +1 -0
  21. package/dist/api/services/cdn/fastly/POST/index.d.ts +5 -0
  22. package/dist/api/services/cdn/fastly/POST/index.d.ts.map +1 -0
  23. package/dist/api/services/cdn/fastly/index.d.ts +5 -0
  24. package/dist/api/services/cdn/fastly/index.d.ts.map +1 -0
  25. package/dist/api/services/cdn/index.d.ts +8 -0
  26. package/dist/api/services/cdn/index.d.ts.map +1 -0
  27. package/dist/api/services/index.d.ts +2 -0
  28. package/dist/api/services/index.d.ts.map +1 -1
  29. package/dist/api/services/virustotal/analyses/GET/getAnalysisResult.d.ts +35 -0
  30. package/dist/api/services/virustotal/analyses/GET/getAnalysisResult.d.ts.map +1 -0
  31. package/dist/api/services/virustotal/analyses/GET/index.d.ts +6 -0
  32. package/dist/api/services/virustotal/analyses/GET/index.d.ts.map +1 -0
  33. package/dist/api/services/virustotal/analyses/index.d.ts +6 -0
  34. package/dist/api/services/virustotal/analyses/index.d.ts.map +1 -0
  35. package/dist/api/services/virustotal/files/POST/index.d.ts +6 -0
  36. package/dist/api/services/virustotal/files/POST/index.d.ts.map +1 -0
  37. package/dist/api/services/virustotal/files/POST/uploadFileForScanning.d.ts +36 -0
  38. package/dist/api/services/virustotal/files/POST/uploadFileForScanning.d.ts.map +1 -0
  39. package/dist/api/services/virustotal/files/index.d.ts +6 -0
  40. package/dist/api/services/virustotal/files/index.d.ts.map +1 -0
  41. package/dist/api/services/virustotal/index.d.ts +8 -0
  42. package/dist/api/services/virustotal/index.d.ts.map +1 -0
  43. package/dist/api/utils/aws/index.d.ts +7 -0
  44. package/dist/api/utils/aws/index.d.ts.map +1 -0
  45. package/dist/api/utils/aws/signature-v4.d.ts +41 -0
  46. package/dist/api/utils/aws/signature-v4.d.ts.map +1 -0
  47. package/dist/api/utils/aws/xml/cloudfront.d.ts +37 -0
  48. package/dist/api/utils/aws/xml/cloudfront.d.ts.map +1 -0
  49. package/dist/api/utils/aws/xml/index.d.ts +6 -0
  50. package/dist/api/utils/aws/xml/index.d.ts.map +1 -0
  51. package/dist/index.cjs +475 -8
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.mjs +446 -8
  54. package/dist/index.mjs.map +1 -1
  55. package/package.json +5 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/services/virustotal/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * AWS Utilities
3
+ * Helpers for AWS API integration
4
+ */
5
+ export * from './signature-v4';
6
+ export * from './xml';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/utils/aws/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * AWS Signature Version 4 Utilities
3
+ * Implements AWS Signature V4 signing for API requests
4
+ *
5
+ * @see https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
6
+ */
7
+ import type { AWSSignatureV4Options, AWSSignatureV4Result } from '@plyaz/types/api';
8
+ /**
9
+ * Generate AWS Signature Version 4 for request authentication
10
+ *
11
+ * @param options - Signature generation options
12
+ * @param options.accessKeyId - AWS access key ID
13
+ * @param options.secretAccessKey - AWS secret access key
14
+ * @param options.sessionToken - AWS session token (optional, for temporary credentials)
15
+ * @param options.region - AWS region (e.g., 'us-east-1')
16
+ * @param options.service - AWS service name (e.g., 'cloudfront', 's3')
17
+ * @param options.method - HTTP method (e.g., 'GET', 'POST')
18
+ * @param options.path - Request path
19
+ * @param options.queryString - Query string parameters (optional)
20
+ * @param options.headers - HTTP headers
21
+ * @param options.payload - Request payload/body
22
+ * @param options.host - Host header value
23
+ * @param options.timestamp - ISO 8601 timestamp in YYYYMMDDTHHmmssZ format (optional, auto-generated if not provided)
24
+ * @returns Signed headers and authorization header
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const { headers, authorization } = generateAWSSignatureV4({
29
+ * accessKeyId: 'AKIAIOSFODNN7EXAMPLE',
30
+ * secretAccessKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
31
+ * region: 'us-east-1',
32
+ * service: 'cloudfront',
33
+ * method: 'POST',
34
+ * path: '/2020-05-31/distribution/E1234/invalidation',
35
+ * headers: { 'Host': 'cloudfront.amazonaws.com', 'Content-Type': 'application/xml' },
36
+ * payload: '<xml>...</xml>',
37
+ * });
38
+ * ```
39
+ */
40
+ export declare function generateAWSSignatureV4(options: AWSSignatureV4Options): AWSSignatureV4Result;
41
+ //# sourceMappingURL=signature-v4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature-v4.d.ts","sourceRoot":"","sources":["../../../../src/api/utils/aws/signature-v4.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,CAgF3F"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * AWS CloudFront XML Utilities
3
+ * Generates XML bodies for CloudFront API requests
4
+ *
5
+ * @see https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateInvalidation.html
6
+ */
7
+ /**
8
+ * Generate XML body for CloudFront invalidation request
9
+ *
10
+ * @param paths - List of paths to invalidate (e.g., ['/images/*', '/styles/main.css'])
11
+ * @param callerReference - Unique identifier for this invalidation request
12
+ * @returns XML string formatted for CloudFront API
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const xml = generateCloudFrontInvalidationXML(
17
+ * ['/images/*', '/styles/main.css'],
18
+ * 'api-1234567890'
19
+ * );
20
+ * ```
21
+ */
22
+ export declare function generateCloudFrontInvalidationXML(paths: string[], callerReference: string): string;
23
+ /**
24
+ * Generate unique caller reference for CloudFront invalidation
25
+ * Uses timestamp-based unique identifier
26
+ *
27
+ * @param prefix - Optional prefix for the caller reference (default: 'api')
28
+ * @returns Unique caller reference string
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const ref = generateCloudFrontCallerReference(); // 'api-1234567890123'
33
+ * const customRef = generateCloudFrontCallerReference('storage'); // 'storage-1234567890123'
34
+ * ```
35
+ */
36
+ export declare function generateCloudFrontCallerReference(prefix?: string): string;
37
+ //# sourceMappingURL=cloudfront.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudfront.d.ts","sourceRoot":"","sources":["../../../../../src/api/utils/aws/xml/cloudfront.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,MAAM,EAAE,EACf,eAAe,EAAE,MAAM,GACtB,MAAM,CAaR;AAiBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,iCAAiC,CAAC,MAAM,SAAQ,GAAG,MAAM,CAExE"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * AWS XML Utilities
3
+ * XML generation for various AWS services
4
+ */
5
+ export * from './cloudfront';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/api/utils/aws/xml/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,cAAc,CAAC"}
package/dist/index.cjs CHANGED
@@ -10,10 +10,30 @@ var errors = require('@plyaz/types/errors');
10
10
  var async_hooks = require('async_hooks');
11
11
  var common = require('@nestjs/common');
12
12
  var rxjs = require('rxjs');
13
- var crypto$1 = require('crypto');
13
+ var crypto2 = require('crypto');
14
14
  var reactQuery = require('@tanstack/react-query');
15
15
  var react = require('react');
16
16
 
17
+ function _interopNamespace(e) {
18
+ if (e && e.__esModule) return e;
19
+ var n = Object.create(null);
20
+ if (e) {
21
+ Object.keys(e).forEach(function (k) {
22
+ if (k !== 'default') {
23
+ var d = Object.getOwnPropertyDescriptor(e, k);
24
+ Object.defineProperty(n, k, d.get ? d : {
25
+ enumerable: true,
26
+ get: function () { return e[k]; }
27
+ });
28
+ }
29
+ });
30
+ }
31
+ n.default = e;
32
+ return Object.freeze(n);
33
+ }
34
+
35
+ var crypto2__namespace = /*#__PURE__*/_interopNamespace(crypto2);
36
+
17
37
  // @plyaz package - Built with tsup
18
38
  var __defProp = Object.defineProperty;
19
39
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -613,7 +633,7 @@ function getCrypto() {
613
633
  }
614
634
  __name(getCrypto, "getCrypto");
615
635
  function generateUUID() {
616
- const crypto2 = getCrypto();
636
+ const crypto3 = getCrypto();
617
637
  const UUID_CONSTANTS = {
618
638
  BYTES: 16,
619
639
  VERSION_POSITION: 6,
@@ -630,12 +650,12 @@ function generateUUID() {
630
650
  // eslint-disable-next-line no-magic-numbers
631
651
  POSITIONS: [8, 12, 16, 20, 32]
632
652
  };
633
- if (crypto2 && typeof crypto2.randomUUID === "function") {
634
- return crypto2.randomUUID();
653
+ if (crypto3 && typeof crypto3.randomUUID === "function") {
654
+ return crypto3.randomUUID();
635
655
  }
636
- if (crypto2?.getRandomValues) {
656
+ if (crypto3?.getRandomValues) {
637
657
  const bytes = new Uint8Array(UUID_CONSTANTS.BYTES);
638
- crypto2.getRandomValues(bytes);
658
+ crypto3.getRandomValues(bytes);
639
659
  bytes[UUID_CONSTANTS.VERSION_POSITION] = bytes[UUID_CONSTANTS.VERSION_POSITION] & UUID_CONSTANTS.VERSION_MASK | UUID_CONSTANTS.VERSION_VALUE;
640
660
  bytes[UUID_CONSTANTS.VARIANT_POSITION] = bytes[UUID_CONSTANTS.VARIANT_POSITION] & UUID_CONSTANTS.VARIANT_MASK | UUID_CONSTANTS.VARIANT_VALUE;
641
661
  const hex = Array.from(
@@ -14018,6 +14038,108 @@ var infobipEndpoints = {
14018
14038
  ...infobipEmailEndpoints
14019
14039
  };
14020
14040
 
14041
+ // src/api/endpoints/virustotal.ts
14042
+ var virusTotalEndpoints = {
14043
+ // ========== File Scanning ==========
14044
+ /**
14045
+ * POST /files - Upload file for scanning
14046
+ * Multipart/form-data with file attachment
14047
+ * See official documentation for current free tier limits:
14048
+ * https://developers.virustotal.com/reference/overview#public-vs-premium-api
14049
+ *
14050
+ * @returns {object} response - Upload response with analysis ID
14051
+ * @returns {string} response.data.id - Analysis ID for polling results
14052
+ */
14053
+ uploadFileForScanning: {
14054
+ url: "/files",
14055
+ method: "POST"
14056
+ },
14057
+ /**
14058
+ * GET /analyses/{id} - Get analysis result
14059
+ * Retrieve scan results for previously uploaded file
14060
+ *
14061
+ * @param {string} id - Analysis ID from upload response
14062
+ * @returns {object} response - Analysis result with threat details
14063
+ */
14064
+ getAnalysisResult: {
14065
+ url: "/analyses/:id",
14066
+ method: "GET",
14067
+ cacheTime: 0
14068
+ // Don't cache scan results (they update)
14069
+ },
14070
+ // ========== Health & Info ==========
14071
+ /**
14072
+ * GET /version - Get API version info (health check)
14073
+ * Simple endpoint to verify API availability
14074
+ */
14075
+ getApiVersion: {
14076
+ url: "/version",
14077
+ method: "GET",
14078
+ cacheTime: 300,
14079
+ // Cache for 5 minutes
14080
+ staleTime: 600
14081
+ }
14082
+ };
14083
+ ({
14084
+ ...virusTotalEndpoints
14085
+ });
14086
+ var cloudflareEndpoints = {
14087
+ /**
14088
+ * POST /zones/{zoneId}/purge_cache - Purge files from cache
14089
+ * Purge specific files or all files in a zone
14090
+ * Rate limits may change; see official documentation for current limits:
14091
+ * https://developers.cloudflare.com/api/operations/zone-purge#rate-limits
14092
+ *
14093
+ * @param {string} zoneId - Cloudflare Zone ID
14094
+ * @returns {object} response - Purge result with success status
14095
+ */
14096
+ cloudflarePurgeCache: {
14097
+ url: "/zones/:zoneId/purge_cache",
14098
+ method: "POST",
14099
+ cacheTime: 0
14100
+ // Don't cache purge operations
14101
+ }
14102
+ };
14103
+ var cloudFrontEndpoints = {
14104
+ /**
14105
+ * POST /{apiVersion}/distribution/{distributionId}/invalidation - Create invalidation
14106
+ * Creates an invalidation batch for specified paths
14107
+ * Rate limits may change; see the official AWS documentation for current limits:
14108
+ * https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
14109
+ * Requires AWS Signature Version 4 authentication
14110
+ *
14111
+ * @param {string} distributionId - CloudFront Distribution ID
14112
+ * @returns {object} response - Invalidation result with ID and status
14113
+ */
14114
+ cloudFrontCreateInvalidation: {
14115
+ url: `/${config.AWS_CLOUDFRONT_CONFIG.API_VERSION}/distribution/:distributionId/invalidation`,
14116
+ method: "POST",
14117
+ cacheTime: 0
14118
+ }
14119
+ };
14120
+ var fastlyEndpoints = {
14121
+ /**
14122
+ * POST /service/{serviceId}/purge/{url} - Purge single URL
14123
+ * Instant soft-purge of specific URL
14124
+ * Rate limit: Unlimited soft-purges. Hard-purges are limited to 1000 requests per hour per service (as of 2024-06). See Fastly documentation for updates:
14125
+ * @see https://developer.fastly.com/reference/api/purging/#rate-limits
14126
+ *
14127
+ * @param {string} serviceId - Fastly Service ID
14128
+ * @param {string} url - URL to purge (URL-encoded)
14129
+ * @returns {object} response - Purge result with status
14130
+ */
14131
+ fastlyPurgeUrl: {
14132
+ url: "/service/:serviceId/purge/:url",
14133
+ method: "POST",
14134
+ cacheTime: 0
14135
+ }
14136
+ };
14137
+ var cdnEndpoints = {
14138
+ ...cloudflareEndpoints,
14139
+ ...cloudFrontEndpoints,
14140
+ ...fastlyEndpoints
14141
+ };
14142
+
14021
14143
  // src/api/endpoints/utils.ts
14022
14144
  function getEndpointUrl(name) {
14023
14145
  return endpoints[name].url;
@@ -14192,7 +14314,13 @@ var endpoints = {
14192
14314
  // These are only examples for the polling, none of these endpoints doesnt exist yet
14193
14315
  ...pollingEndpoints,
14194
14316
  // Infobip third-party provider endpoints (Email, SMS, WhatsApp)
14195
- ...infobipEndpoints
14317
+ ...infobipEndpoints,
14318
+ // VirusTotal third-party provider endpoints (Virus/Malware scanning)
14319
+ ...virusTotalEndpoints,
14320
+ // CDN provider endpoints (Cloudflare, CloudFront, Fastly)
14321
+ ...cloudflareEndpoints,
14322
+ ...cloudFrontEndpoints,
14323
+ ...fastlyEndpoints
14196
14324
  };
14197
14325
  var isSlowConnection = fetchff.isSlowConnection;
14198
14326
  function isNetworkAPISupported() {
@@ -21267,7 +21395,7 @@ function getHeaderFingerprint(headers2) {
21267
21395
  return "no-cache-affecting-headers";
21268
21396
  }
21269
21397
  const content = parts.join("|");
21270
- return crypto$1.createHash("sha256").update(content).digest("hex").substring(0, FINGERPRINT_LENGTH);
21398
+ return crypto2.createHash("sha256").update(content).digest("hex").substring(0, FINGERPRINT_LENGTH);
21271
21399
  }
21272
21400
  __name(getHeaderFingerprint, "getHeaderFingerprint");
21273
21401
 
@@ -25412,6 +25540,335 @@ async function updateInfobipScheduledEmailStatuses(params, payload, options) {
25412
25540
  });
25413
25541
  }
25414
25542
  __name(updateInfobipScheduledEmailStatuses, "updateInfobipScheduledEmailStatuses");
25543
+ async function uploadFileForScanning(payload, options) {
25544
+ const client = options?.apiClient ?? getDefaultApiClient();
25545
+ if (!payload.file) {
25546
+ throw new ApiPackageError(
25547
+ "Missing required field: file",
25548
+ void 0,
25549
+ api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
25550
+ );
25551
+ }
25552
+ if (!payload.filename) {
25553
+ throw new ApiPackageError(
25554
+ "Missing required field: filename",
25555
+ void 0,
25556
+ api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
25557
+ );
25558
+ }
25559
+ if (payload.file.length === 0) {
25560
+ throw new ApiPackageError(
25561
+ "File buffer cannot be empty",
25562
+ void 0,
25563
+ api.API_ERROR_CODES.INVALID_INPUT
25564
+ );
25565
+ }
25566
+ const serviceDefaults = {
25567
+ retry: { attempts: 2 },
25568
+ // Allow retries for network issues
25569
+ timeout: 6e4
25570
+ // 60 second timeout for file uploads
25571
+ };
25572
+ const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
25573
+ const updateOptions = {
25574
+ strategy: "temporary",
25575
+ ...options?.updateConfigOptions
25576
+ };
25577
+ if (shouldApplyConfig(mergedConfig, updateOptions)) {
25578
+ client.updateConfig(mergedConfig, updateOptions);
25579
+ }
25580
+ const formData = new FormData();
25581
+ const blob = new Blob([new Uint8Array(payload.file)]);
25582
+ formData.append("file", blob, payload.filename);
25583
+ return client.uploadFileForScanning({
25584
+ body: formData
25585
+ });
25586
+ }
25587
+ __name(uploadFileForScanning, "uploadFileForScanning");
25588
+ async function getAnalysisResult(payload, options) {
25589
+ const client = options?.apiClient ?? getDefaultApiClient();
25590
+ if (!payload.analysisId) {
25591
+ throw new ApiPackageError(
25592
+ "Missing required field: analysisId",
25593
+ void 0,
25594
+ api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
25595
+ );
25596
+ }
25597
+ const serviceDefaults = {
25598
+ retry: { attempts: 3 },
25599
+ // Allow retries for polling
25600
+ timeout: 3e4,
25601
+ // 30 second timeout
25602
+ cacheTime: 0
25603
+ // Don't cache (results change as scan progresses)
25604
+ };
25605
+ const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
25606
+ const updateOptions = {
25607
+ strategy: "temporary",
25608
+ ...options?.updateConfigOptions
25609
+ };
25610
+ if (shouldApplyConfig(mergedConfig, updateOptions)) {
25611
+ client.updateConfig(mergedConfig, updateOptions);
25612
+ }
25613
+ return client.getAnalysisResult({
25614
+ params: { id: payload.analysisId }
25615
+ });
25616
+ }
25617
+ __name(getAnalysisResult, "getAnalysisResult");
25618
+ async function cloudflarePurgeCache(payload, options) {
25619
+ const client = options?.apiClient ?? getDefaultApiClient();
25620
+ if (!payload.zoneId) {
25621
+ throw new ApiPackageError(
25622
+ "Missing required field: zoneId",
25623
+ config.HTTP_STATUS.BAD_REQUEST,
25624
+ api.API_ERROR_CODES.CLOUDFLARE_ZONE_NOT_FOUND
25625
+ );
25626
+ }
25627
+ if (!payload.apiToken) {
25628
+ throw new ApiPackageError(
25629
+ "Missing required field: apiToken",
25630
+ config.HTTP_STATUS.UNAUTHORIZED,
25631
+ api.API_ERROR_CODES.CLOUDFLARE_AUTHENTICATION_FAILED
25632
+ );
25633
+ }
25634
+ if (!payload.files || payload.files.length === 0) {
25635
+ throw new ApiPackageError(
25636
+ "Missing required field: files (must be non-empty array)",
25637
+ config.HTTP_STATUS.BAD_REQUEST,
25638
+ api.API_ERROR_CODES.CLOUDFLARE_INVALID_URL
25639
+ );
25640
+ }
25641
+ const serviceDefaults = {
25642
+ retry: { attempts: 2 },
25643
+ timeout: 3e4
25644
+ // 30 seconds
25645
+ };
25646
+ const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
25647
+ const updateOptions = {
25648
+ strategy: "temporary",
25649
+ ...options?.updateConfigOptions
25650
+ };
25651
+ if (shouldApplyConfig(mergedConfig, updateOptions)) {
25652
+ client.updateConfig(mergedConfig, updateOptions);
25653
+ }
25654
+ return client.cloudflarePurgeCache({
25655
+ params: { zoneId: payload.zoneId },
25656
+ headers: {
25657
+ Authorization: `Bearer ${payload.apiToken}`
25658
+ },
25659
+ body: {
25660
+ files: payload.files,
25661
+ zoneId: payload.zoneId,
25662
+ apiToken: payload.apiToken
25663
+ }
25664
+ });
25665
+ }
25666
+ __name(cloudflarePurgeCache, "cloudflarePurgeCache");
25667
+ function generateAWSSignatureV4(options) {
25668
+ const {
25669
+ accessKeyId,
25670
+ secretAccessKey,
25671
+ sessionToken,
25672
+ region,
25673
+ service,
25674
+ method,
25675
+ path,
25676
+ queryString = "",
25677
+ headers: headers2,
25678
+ payload,
25679
+ host
25680
+ } = options;
25681
+ const timestamp = options.timestamp ?? (/* @__PURE__ */ new Date()).toISOString().replace(/[:-]|\.\d{3}/g, "");
25682
+ const dateStamp = timestamp.split("T")[0];
25683
+ const baseHeaders = { ...headers2 };
25684
+ if (!Object.keys(baseHeaders).some((h) => h.toLowerCase() === "host")) {
25685
+ baseHeaders["Host"] = host;
25686
+ }
25687
+ if (sessionToken) {
25688
+ baseHeaders["X-Amz-Security-Token"] = sessionToken;
25689
+ }
25690
+ baseHeaders["X-Amz-Date"] = timestamp;
25691
+ const canonicalHeaders = Object.keys(baseHeaders).sort().map((key) => `${key.toLowerCase()}:${baseHeaders[key].trim()}`).join("\n");
25692
+ const signedHeaders = Object.keys(baseHeaders).sort().map((key) => key.toLowerCase()).join(";");
25693
+ const payloadHash = crypto2__namespace.createHash("sha256").update(payload).digest("hex");
25694
+ const canonicalRequest = [
25695
+ method,
25696
+ path,
25697
+ queryString,
25698
+ canonicalHeaders + "\n",
25699
+ signedHeaders,
25700
+ payloadHash
25701
+ ].join("\n");
25702
+ const algorithm = "AWS4-HMAC-SHA256";
25703
+ const credentialScope = `${dateStamp}/${region}/${service}/aws4_request`;
25704
+ const canonicalRequestHash = crypto2__namespace.createHash("sha256").update(canonicalRequest).digest("hex");
25705
+ const stringToSign = [algorithm, timestamp, credentialScope, canonicalRequestHash].join("\n");
25706
+ const kDate = crypto2__namespace.createHmac("sha256", `AWS4${secretAccessKey}`).update(dateStamp).digest();
25707
+ const kRegion = crypto2__namespace.createHmac("sha256", kDate).update(region).digest();
25708
+ const kService = crypto2__namespace.createHmac("sha256", kRegion).update(service).digest();
25709
+ const kSigning = crypto2__namespace.createHmac("sha256", kService).update("aws4_request").digest();
25710
+ const signature = crypto2__namespace.createHmac("sha256", kSigning).update(stringToSign).digest("hex");
25711
+ const authorization = `${algorithm} Credential=${accessKeyId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`;
25712
+ return {
25713
+ headers: baseHeaders,
25714
+ authorization
25715
+ };
25716
+ }
25717
+ __name(generateAWSSignatureV4, "generateAWSSignatureV4");
25718
+
25719
+ // src/api/utils/aws/xml/cloudfront.ts
25720
+ function generateCloudFrontInvalidationXML(paths, callerReference) {
25721
+ const items = paths.map((path) => `<Path>${escapeXml(path)}</Path>`).join("\n ");
25722
+ return `<?xml version="1.0" encoding="UTF-8"?>
25723
+ <InvalidationBatch xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
25724
+ <Paths>
25725
+ <Quantity>${paths.length}</Quantity>
25726
+ <Items>
25727
+ ${items}
25728
+ </Items>
25729
+ </Paths>
25730
+ <CallerReference>${escapeXml(callerReference)}</CallerReference>
25731
+ </InvalidationBatch>`;
25732
+ }
25733
+ __name(generateCloudFrontInvalidationXML, "generateCloudFrontInvalidationXML");
25734
+ function escapeXml(str) {
25735
+ const xmlEscapes = {
25736
+ "&": "&amp;",
25737
+ "<": "&lt;",
25738
+ ">": "&gt;",
25739
+ '"': "&quot;",
25740
+ "'": "&apos;"
25741
+ };
25742
+ return str.replace(/[&<>"']/g, (ch) => xmlEscapes[ch]);
25743
+ }
25744
+ __name(escapeXml, "escapeXml");
25745
+ function generateCloudFrontCallerReference(prefix = "api") {
25746
+ return `${prefix}-${Date.now()}`;
25747
+ }
25748
+ __name(generateCloudFrontCallerReference, "generateCloudFrontCallerReference");
25749
+
25750
+ // src/api/services/cdn/cloudfront/POST/cloudFrontCreateInvalidation.ts
25751
+ async function cloudFrontCreateInvalidation(payload, options) {
25752
+ const client = options?.apiClient ?? getDefaultApiClient();
25753
+ if (!payload.distributionId) {
25754
+ throw new ApiPackageError(
25755
+ "Missing required field: distributionId",
25756
+ config.HTTP_STATUS.BAD_REQUEST,
25757
+ api.API_ERROR_CODES.CLOUDFRONT_DISTRIBUTION_NOT_FOUND
25758
+ );
25759
+ }
25760
+ if (!payload.accessKeyId) {
25761
+ throw new ApiPackageError(
25762
+ "Missing required field: accessKeyId",
25763
+ config.HTTP_STATUS.UNAUTHORIZED,
25764
+ api.API_ERROR_CODES.CLOUDFRONT_AUTHENTICATION_FAILED
25765
+ );
25766
+ }
25767
+ if (!payload.secretAccessKey) {
25768
+ throw new ApiPackageError(
25769
+ "Missing required field: secretAccessKey",
25770
+ config.HTTP_STATUS.UNAUTHORIZED,
25771
+ api.API_ERROR_CODES.CLOUDFRONT_AUTHENTICATION_FAILED
25772
+ );
25773
+ }
25774
+ if (!payload.paths || payload.paths.length === 0) {
25775
+ throw new ApiPackageError(
25776
+ "Missing required field: paths (must be non-empty array)",
25777
+ config.HTTP_STATUS.BAD_REQUEST,
25778
+ api.API_ERROR_CODES.CLOUDFRONT_INVALID_PATH
25779
+ );
25780
+ }
25781
+ const region = payload.region ?? config.AWS_CLOUDFRONT_CONFIG.DEFAULT_REGION;
25782
+ const service = config.AWS_CLOUDFRONT_CONFIG.SERVICE_NAME;
25783
+ const host = config.AWS_CLOUDFRONT_CONFIG.HOST;
25784
+ const method = "POST";
25785
+ const path = `/${config.AWS_CLOUDFRONT_CONFIG.API_VERSION}/distribution/${payload.distributionId}/invalidation`;
25786
+ const callerReference = generateCloudFrontCallerReference("api");
25787
+ const body = generateCloudFrontInvalidationXML(payload.paths, callerReference);
25788
+ const { headers: signedHeaders, authorization } = generateAWSSignatureV4({
25789
+ accessKeyId: payload.accessKeyId,
25790
+ secretAccessKey: payload.secretAccessKey,
25791
+ sessionToken: payload.sessionToken,
25792
+ region,
25793
+ service,
25794
+ method,
25795
+ path,
25796
+ host,
25797
+ headers: {
25798
+ "Content-Type": "application/xml"
25799
+ },
25800
+ payload: body
25801
+ });
25802
+ const serviceDefaults = {
25803
+ retry: { attempts: 2 },
25804
+ timeout: 3e4
25805
+ // 30 seconds
25806
+ };
25807
+ const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
25808
+ const updateOptions = {
25809
+ strategy: "temporary",
25810
+ ...options?.updateConfigOptions
25811
+ };
25812
+ if (shouldApplyConfig(mergedConfig, updateOptions)) {
25813
+ client.updateConfig(mergedConfig, updateOptions);
25814
+ }
25815
+ return client.cloudFrontCreateInvalidation({
25816
+ params: { distributionId: payload.distributionId },
25817
+ headers: {
25818
+ ...signedHeaders,
25819
+ Authorization: authorization
25820
+ },
25821
+ body
25822
+ });
25823
+ }
25824
+ __name(cloudFrontCreateInvalidation, "cloudFrontCreateInvalidation");
25825
+ async function fastlyPurgeUrl(payload, options) {
25826
+ const client = options?.apiClient ?? getDefaultApiClient();
25827
+ if (!payload.serviceId) {
25828
+ throw new ApiPackageError(
25829
+ "Missing required field: serviceId",
25830
+ config.HTTP_STATUS.BAD_REQUEST,
25831
+ api.API_ERROR_CODES.FASTLY_SERVICE_NOT_FOUND
25832
+ );
25833
+ }
25834
+ if (!payload.apiToken) {
25835
+ throw new ApiPackageError(
25836
+ "Missing required field: apiToken",
25837
+ config.HTTP_STATUS.UNAUTHORIZED,
25838
+ api.API_ERROR_CODES.FASTLY_AUTHENTICATION_FAILED
25839
+ );
25840
+ }
25841
+ if (!payload.url) {
25842
+ throw new ApiPackageError(
25843
+ "Missing required field: url",
25844
+ config.HTTP_STATUS.BAD_REQUEST,
25845
+ api.API_ERROR_CODES.FASTLY_INVALID_URL
25846
+ );
25847
+ }
25848
+ const serviceDefaults = {
25849
+ retry: { attempts: 2 },
25850
+ timeout: 15e3
25851
+ // 15 seconds
25852
+ };
25853
+ const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
25854
+ const updateOptions = {
25855
+ strategy: "temporary",
25856
+ ...options?.updateConfigOptions
25857
+ };
25858
+ if (shouldApplyConfig(mergedConfig, updateOptions)) {
25859
+ client.updateConfig(mergedConfig, updateOptions);
25860
+ }
25861
+ return client.fastlyPurgeUrl({
25862
+ params: {
25863
+ serviceId: payload.serviceId,
25864
+ url: encodeURIComponent(payload.url)
25865
+ },
25866
+ headers: {
25867
+ "Fastly-Key": payload.apiToken
25868
+ }
25869
+ });
25870
+ }
25871
+ __name(fastlyPurgeUrl, "fastlyPurgeUrl");
25415
25872
  function getSSRSafeConfig(config) {
25416
25873
  if (!isBrowser()) {
25417
25874
  return {
@@ -25757,6 +26214,7 @@ exports.calculatePollingDuration = calculatePollingDuration;
25757
26214
  exports.calculateRequestMetrics = calculateRequestMetrics;
25758
26215
  exports.campaignEndpoints = campaignEndpoints;
25759
26216
  exports.canPerformHeavyOperation = canPerformHeavyOperation;
26217
+ exports.cdnEndpoints = cdnEndpoints;
25760
26218
  exports.checkOverrideTriggers = checkOverrideTriggers;
25761
26219
  exports.clamp = clamp;
25762
26220
  exports.clampedPercentage = clampedPercentage;
@@ -25764,6 +26222,10 @@ exports.clearErrorHandlers = clearErrorHandlers;
25764
26222
  exports.clearNetworkDebugData = clearNetworkDebugData;
25765
26223
  exports.clearTemporaryOverrides = clearTemporaryOverrides;
25766
26224
  exports.cloneConfig = cloneConfig;
26225
+ exports.cloudFrontCreateInvalidation = cloudFrontCreateInvalidation;
26226
+ exports.cloudFrontEndpoints = cloudFrontEndpoints;
26227
+ exports.cloudflareEndpoints = cloudflareEndpoints;
26228
+ exports.cloudflarePurgeCache = cloudflarePurgeCache;
25767
26229
  exports.compactHistory = compactHistory;
25768
26230
  exports.configConflictDetector = configConflictDetector;
25769
26231
  exports.configureForEnvironment = configureForEnvironment;
@@ -25836,6 +26298,8 @@ exports.exportKeyToBase64 = exportKeyToBase64;
25836
26298
  exports.extendRevalidationPresets = extendPresets;
25837
26299
  exports.extractFields = extractFields;
25838
26300
  exports.extractUrlParams = extractUrlParams;
26301
+ exports.fastlyEndpoints = fastlyEndpoints;
26302
+ exports.fastlyPurgeUrl = fastlyPurgeUrl;
25839
26303
  exports.fetchCampaign = fetchCampaign;
25840
26304
  exports.fetchCampaignParticipants = fetchCampaignParticipants;
25841
26305
  exports.fetchCampaignStats = fetchCampaignStats;
@@ -25872,6 +26336,7 @@ exports.getAdaptiveTimeout = getAdaptiveTimeout;
25872
26336
  exports.getAllEndpointUrls = getAllEndpointUrls;
25873
26337
  exports.getAllFieldPaths = getAllFieldPaths;
25874
26338
  exports.getAllMediaExtensions = getAllMediaExtensions;
26339
+ exports.getAnalysisResult = getAnalysisResult;
25875
26340
  exports.getAppVersion = getAppVersion;
25876
26341
  exports.getAuthenticationType = getAuthenticationType;
25877
26342
  exports.getCache = getCache;
@@ -26195,6 +26660,7 @@ exports.unregisterErrorHandlers = unregisterErrorHandlers;
26195
26660
  exports.updateCampaign = updateCampaign;
26196
26661
  exports.updateGlobalConfig = updateGlobalConfig;
26197
26662
  exports.updateInfobipScheduledEmailStatuses = updateInfobipScheduledEmailStatuses;
26663
+ exports.uploadFileForScanning = uploadFileForScanning;
26198
26664
  exports.useAbortableRequest = useAbortableRequest;
26199
26665
  exports.useApiConfigConflicts = useApiConfigConflicts;
26200
26666
  exports.useApiDebugInfo = useApiDebugInfo;
@@ -26225,6 +26691,7 @@ exports.validateHeaders = validateHeaders2;
26225
26691
  exports.validateInfobipEmail = validateInfobipEmail;
26226
26692
  exports.validatePathParams = validatePathParams;
26227
26693
  exports.validatePreset = validatePreset;
26694
+ exports.virusTotalEndpoints = virusTotalEndpoints;
26228
26695
  exports.waitForOnline = waitForOnline;
26229
26696
  exports.withNetworkDetection = withNetworkDetection;
26230
26697
  exports.withNetworkInfo = withNetworkInfo;