@plyaz/api 1.3.0 → 1.4.1
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/dist/api/client/createApiClient.d.ts.map +1 -1
- package/dist/api/endpoints/cdn.d.ts +122 -0
- package/dist/api/endpoints/cdn.d.ts.map +1 -0
- package/dist/api/endpoints/index.d.ts +34 -4
- package/dist/api/endpoints/index.d.ts.map +1 -1
- package/dist/api/endpoints/virustotal.d.ts +91 -0
- package/dist/api/endpoints/virustotal.d.ts.map +1 -0
- package/dist/api/services/cdn/cloudflare/POST/cloudflarePurgeCache.d.ts +35 -0
- package/dist/api/services/cdn/cloudflare/POST/cloudflarePurgeCache.d.ts.map +1 -0
- package/dist/api/services/cdn/cloudflare/POST/index.d.ts +5 -0
- package/dist/api/services/cdn/cloudflare/POST/index.d.ts.map +1 -0
- package/dist/api/services/cdn/cloudflare/index.d.ts +5 -0
- package/dist/api/services/cdn/cloudflare/index.d.ts.map +1 -0
- package/dist/api/services/cdn/cloudfront/POST/cloudFrontCreateInvalidation.d.ts +38 -0
- package/dist/api/services/cdn/cloudfront/POST/cloudFrontCreateInvalidation.d.ts.map +1 -0
- package/dist/api/services/cdn/cloudfront/POST/index.d.ts +5 -0
- package/dist/api/services/cdn/cloudfront/POST/index.d.ts.map +1 -0
- package/dist/api/services/cdn/cloudfront/index.d.ts +5 -0
- package/dist/api/services/cdn/cloudfront/index.d.ts.map +1 -0
- package/dist/api/services/cdn/fastly/POST/fastlyPurgeUrl.d.ts +35 -0
- package/dist/api/services/cdn/fastly/POST/fastlyPurgeUrl.d.ts.map +1 -0
- package/dist/api/services/cdn/fastly/POST/index.d.ts +5 -0
- package/dist/api/services/cdn/fastly/POST/index.d.ts.map +1 -0
- package/dist/api/services/cdn/fastly/index.d.ts +5 -0
- package/dist/api/services/cdn/fastly/index.d.ts.map +1 -0
- package/dist/api/services/cdn/index.d.ts +8 -0
- package/dist/api/services/cdn/index.d.ts.map +1 -0
- package/dist/api/services/index.d.ts +2 -0
- package/dist/api/services/index.d.ts.map +1 -1
- package/dist/api/services/virustotal/analyses/GET/getAnalysisResult.d.ts +35 -0
- package/dist/api/services/virustotal/analyses/GET/getAnalysisResult.d.ts.map +1 -0
- package/dist/api/services/virustotal/analyses/GET/index.d.ts +6 -0
- package/dist/api/services/virustotal/analyses/GET/index.d.ts.map +1 -0
- package/dist/api/services/virustotal/analyses/index.d.ts +6 -0
- package/dist/api/services/virustotal/analyses/index.d.ts.map +1 -0
- package/dist/api/services/virustotal/files/POST/index.d.ts +6 -0
- package/dist/api/services/virustotal/files/POST/index.d.ts.map +1 -0
- package/dist/api/services/virustotal/files/POST/uploadFileForScanning.d.ts +36 -0
- package/dist/api/services/virustotal/files/POST/uploadFileForScanning.d.ts.map +1 -0
- package/dist/api/services/virustotal/files/index.d.ts +6 -0
- package/dist/api/services/virustotal/files/index.d.ts.map +1 -0
- package/dist/api/services/virustotal/index.d.ts +8 -0
- package/dist/api/services/virustotal/index.d.ts.map +1 -0
- package/dist/api/utils/aws/index.d.ts +7 -0
- package/dist/api/utils/aws/index.d.ts.map +1 -0
- package/dist/api/utils/aws/signature-v4.d.ts +41 -0
- package/dist/api/utils/aws/signature-v4.d.ts.map +1 -0
- package/dist/api/utils/aws/xml/cloudfront.d.ts +37 -0
- package/dist/api/utils/aws/xml/cloudfront.d.ts.map +1 -0
- package/dist/api/utils/aws/xml/index.d.ts +6 -0
- package/dist/api/utils/aws/xml/index.d.ts.map +1 -0
- package/dist/index.cjs +496 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +467 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
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
|
|
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
|
|
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 (
|
|
634
|
-
return
|
|
653
|
+
if (crypto3 && typeof crypto3.randomUUID === "function") {
|
|
654
|
+
return crypto3.randomUUID();
|
|
635
655
|
}
|
|
636
|
-
if (
|
|
656
|
+
if (crypto3?.getRandomValues) {
|
|
637
657
|
const bytes = new Uint8Array(UUID_CONSTANTS.BYTES);
|
|
638
|
-
|
|
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
|
|
21398
|
+
return crypto2.createHash("sha256").update(content).digest("hex").substring(0, FINGERPRINT_LENGTH);
|
|
21271
21399
|
}
|
|
21272
21400
|
__name(getHeaderFingerprint, "getHeaderFingerprint");
|
|
21273
21401
|
|
|
@@ -22973,6 +23101,27 @@ function enhanceClientWithMethods(params) {
|
|
|
22973
23101
|
client,
|
|
22974
23102
|
eventManager2
|
|
22975
23103
|
);
|
|
23104
|
+
clientWithEvents.get = (url, config) => {
|
|
23105
|
+
return client.request(url, { ...config, method: "GET" });
|
|
23106
|
+
};
|
|
23107
|
+
clientWithEvents.post = (url, data, config) => {
|
|
23108
|
+
return client.request(url, { ...config, method: "POST", data });
|
|
23109
|
+
};
|
|
23110
|
+
clientWithEvents.put = (url, data, config) => {
|
|
23111
|
+
return client.request(url, { ...config, method: "PUT", data });
|
|
23112
|
+
};
|
|
23113
|
+
clientWithEvents.patch = (url, data, config) => {
|
|
23114
|
+
return client.request(url, { ...config, method: "PATCH", data });
|
|
23115
|
+
};
|
|
23116
|
+
clientWithEvents.delete = (url, config) => {
|
|
23117
|
+
return client.request(url, { ...config, method: "DELETE" });
|
|
23118
|
+
};
|
|
23119
|
+
clientWithEvents.head = (url, config) => {
|
|
23120
|
+
return client.request(url, { ...config, method: "HEAD" });
|
|
23121
|
+
};
|
|
23122
|
+
clientWithEvents.options = (url, config) => {
|
|
23123
|
+
return client.request(url, { ...config, method: "OPTIONS" });
|
|
23124
|
+
};
|
|
22976
23125
|
}
|
|
22977
23126
|
__name(enhanceClientWithMethods, "enhanceClientWithMethods");
|
|
22978
23127
|
function initializeClientSystems(options) {
|
|
@@ -25412,6 +25561,335 @@ async function updateInfobipScheduledEmailStatuses(params, payload, options) {
|
|
|
25412
25561
|
});
|
|
25413
25562
|
}
|
|
25414
25563
|
__name(updateInfobipScheduledEmailStatuses, "updateInfobipScheduledEmailStatuses");
|
|
25564
|
+
async function uploadFileForScanning(payload, options) {
|
|
25565
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25566
|
+
if (!payload.file) {
|
|
25567
|
+
throw new ApiPackageError(
|
|
25568
|
+
"Missing required field: file",
|
|
25569
|
+
void 0,
|
|
25570
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25571
|
+
);
|
|
25572
|
+
}
|
|
25573
|
+
if (!payload.filename) {
|
|
25574
|
+
throw new ApiPackageError(
|
|
25575
|
+
"Missing required field: filename",
|
|
25576
|
+
void 0,
|
|
25577
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25578
|
+
);
|
|
25579
|
+
}
|
|
25580
|
+
if (payload.file.length === 0) {
|
|
25581
|
+
throw new ApiPackageError(
|
|
25582
|
+
"File buffer cannot be empty",
|
|
25583
|
+
void 0,
|
|
25584
|
+
api.API_ERROR_CODES.INVALID_INPUT
|
|
25585
|
+
);
|
|
25586
|
+
}
|
|
25587
|
+
const serviceDefaults = {
|
|
25588
|
+
retry: { attempts: 2 },
|
|
25589
|
+
// Allow retries for network issues
|
|
25590
|
+
timeout: 6e4
|
|
25591
|
+
// 60 second timeout for file uploads
|
|
25592
|
+
};
|
|
25593
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25594
|
+
const updateOptions = {
|
|
25595
|
+
strategy: "temporary",
|
|
25596
|
+
...options?.updateConfigOptions
|
|
25597
|
+
};
|
|
25598
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25599
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25600
|
+
}
|
|
25601
|
+
const formData = new FormData();
|
|
25602
|
+
const blob = new Blob([new Uint8Array(payload.file)]);
|
|
25603
|
+
formData.append("file", blob, payload.filename);
|
|
25604
|
+
return client.uploadFileForScanning({
|
|
25605
|
+
body: formData
|
|
25606
|
+
});
|
|
25607
|
+
}
|
|
25608
|
+
__name(uploadFileForScanning, "uploadFileForScanning");
|
|
25609
|
+
async function getAnalysisResult(payload, options) {
|
|
25610
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25611
|
+
if (!payload.analysisId) {
|
|
25612
|
+
throw new ApiPackageError(
|
|
25613
|
+
"Missing required field: analysisId",
|
|
25614
|
+
void 0,
|
|
25615
|
+
api.API_ERROR_CODES.REQUIRED_FIELD_MISSING
|
|
25616
|
+
);
|
|
25617
|
+
}
|
|
25618
|
+
const serviceDefaults = {
|
|
25619
|
+
retry: { attempts: 3 },
|
|
25620
|
+
// Allow retries for polling
|
|
25621
|
+
timeout: 3e4,
|
|
25622
|
+
// 30 second timeout
|
|
25623
|
+
cacheTime: 0
|
|
25624
|
+
// Don't cache (results change as scan progresses)
|
|
25625
|
+
};
|
|
25626
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25627
|
+
const updateOptions = {
|
|
25628
|
+
strategy: "temporary",
|
|
25629
|
+
...options?.updateConfigOptions
|
|
25630
|
+
};
|
|
25631
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25632
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25633
|
+
}
|
|
25634
|
+
return client.getAnalysisResult({
|
|
25635
|
+
params: { id: payload.analysisId }
|
|
25636
|
+
});
|
|
25637
|
+
}
|
|
25638
|
+
__name(getAnalysisResult, "getAnalysisResult");
|
|
25639
|
+
async function cloudflarePurgeCache(payload, options) {
|
|
25640
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25641
|
+
if (!payload.zoneId) {
|
|
25642
|
+
throw new ApiPackageError(
|
|
25643
|
+
"Missing required field: zoneId",
|
|
25644
|
+
config.HTTP_STATUS.BAD_REQUEST,
|
|
25645
|
+
api.API_ERROR_CODES.CLOUDFLARE_ZONE_NOT_FOUND
|
|
25646
|
+
);
|
|
25647
|
+
}
|
|
25648
|
+
if (!payload.apiToken) {
|
|
25649
|
+
throw new ApiPackageError(
|
|
25650
|
+
"Missing required field: apiToken",
|
|
25651
|
+
config.HTTP_STATUS.UNAUTHORIZED,
|
|
25652
|
+
api.API_ERROR_CODES.CLOUDFLARE_AUTHENTICATION_FAILED
|
|
25653
|
+
);
|
|
25654
|
+
}
|
|
25655
|
+
if (!payload.files || payload.files.length === 0) {
|
|
25656
|
+
throw new ApiPackageError(
|
|
25657
|
+
"Missing required field: files (must be non-empty array)",
|
|
25658
|
+
config.HTTP_STATUS.BAD_REQUEST,
|
|
25659
|
+
api.API_ERROR_CODES.CLOUDFLARE_INVALID_URL
|
|
25660
|
+
);
|
|
25661
|
+
}
|
|
25662
|
+
const serviceDefaults = {
|
|
25663
|
+
retry: { attempts: 2 },
|
|
25664
|
+
timeout: 3e4
|
|
25665
|
+
// 30 seconds
|
|
25666
|
+
};
|
|
25667
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25668
|
+
const updateOptions = {
|
|
25669
|
+
strategy: "temporary",
|
|
25670
|
+
...options?.updateConfigOptions
|
|
25671
|
+
};
|
|
25672
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25673
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25674
|
+
}
|
|
25675
|
+
return client.cloudflarePurgeCache({
|
|
25676
|
+
params: { zoneId: payload.zoneId },
|
|
25677
|
+
headers: {
|
|
25678
|
+
Authorization: `Bearer ${payload.apiToken}`
|
|
25679
|
+
},
|
|
25680
|
+
body: {
|
|
25681
|
+
files: payload.files,
|
|
25682
|
+
zoneId: payload.zoneId,
|
|
25683
|
+
apiToken: payload.apiToken
|
|
25684
|
+
}
|
|
25685
|
+
});
|
|
25686
|
+
}
|
|
25687
|
+
__name(cloudflarePurgeCache, "cloudflarePurgeCache");
|
|
25688
|
+
function generateAWSSignatureV4(options) {
|
|
25689
|
+
const {
|
|
25690
|
+
accessKeyId,
|
|
25691
|
+
secretAccessKey,
|
|
25692
|
+
sessionToken,
|
|
25693
|
+
region,
|
|
25694
|
+
service,
|
|
25695
|
+
method,
|
|
25696
|
+
path,
|
|
25697
|
+
queryString = "",
|
|
25698
|
+
headers: headers2,
|
|
25699
|
+
payload,
|
|
25700
|
+
host
|
|
25701
|
+
} = options;
|
|
25702
|
+
const timestamp = options.timestamp ?? (/* @__PURE__ */ new Date()).toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
25703
|
+
const dateStamp = timestamp.split("T")[0];
|
|
25704
|
+
const baseHeaders = { ...headers2 };
|
|
25705
|
+
if (!Object.keys(baseHeaders).some((h) => h.toLowerCase() === "host")) {
|
|
25706
|
+
baseHeaders["Host"] = host;
|
|
25707
|
+
}
|
|
25708
|
+
if (sessionToken) {
|
|
25709
|
+
baseHeaders["X-Amz-Security-Token"] = sessionToken;
|
|
25710
|
+
}
|
|
25711
|
+
baseHeaders["X-Amz-Date"] = timestamp;
|
|
25712
|
+
const canonicalHeaders = Object.keys(baseHeaders).sort().map((key) => `${key.toLowerCase()}:${baseHeaders[key].trim()}`).join("\n");
|
|
25713
|
+
const signedHeaders = Object.keys(baseHeaders).sort().map((key) => key.toLowerCase()).join(";");
|
|
25714
|
+
const payloadHash = crypto2__namespace.createHash("sha256").update(payload).digest("hex");
|
|
25715
|
+
const canonicalRequest = [
|
|
25716
|
+
method,
|
|
25717
|
+
path,
|
|
25718
|
+
queryString,
|
|
25719
|
+
canonicalHeaders + "\n",
|
|
25720
|
+
signedHeaders,
|
|
25721
|
+
payloadHash
|
|
25722
|
+
].join("\n");
|
|
25723
|
+
const algorithm = "AWS4-HMAC-SHA256";
|
|
25724
|
+
const credentialScope = `${dateStamp}/${region}/${service}/aws4_request`;
|
|
25725
|
+
const canonicalRequestHash = crypto2__namespace.createHash("sha256").update(canonicalRequest).digest("hex");
|
|
25726
|
+
const stringToSign = [algorithm, timestamp, credentialScope, canonicalRequestHash].join("\n");
|
|
25727
|
+
const kDate = crypto2__namespace.createHmac("sha256", `AWS4${secretAccessKey}`).update(dateStamp).digest();
|
|
25728
|
+
const kRegion = crypto2__namespace.createHmac("sha256", kDate).update(region).digest();
|
|
25729
|
+
const kService = crypto2__namespace.createHmac("sha256", kRegion).update(service).digest();
|
|
25730
|
+
const kSigning = crypto2__namespace.createHmac("sha256", kService).update("aws4_request").digest();
|
|
25731
|
+
const signature = crypto2__namespace.createHmac("sha256", kSigning).update(stringToSign).digest("hex");
|
|
25732
|
+
const authorization = `${algorithm} Credential=${accessKeyId}/${credentialScope}, SignedHeaders=${signedHeaders}, Signature=${signature}`;
|
|
25733
|
+
return {
|
|
25734
|
+
headers: baseHeaders,
|
|
25735
|
+
authorization
|
|
25736
|
+
};
|
|
25737
|
+
}
|
|
25738
|
+
__name(generateAWSSignatureV4, "generateAWSSignatureV4");
|
|
25739
|
+
|
|
25740
|
+
// src/api/utils/aws/xml/cloudfront.ts
|
|
25741
|
+
function generateCloudFrontInvalidationXML(paths, callerReference) {
|
|
25742
|
+
const items = paths.map((path) => `<Path>${escapeXml(path)}</Path>`).join("\n ");
|
|
25743
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
25744
|
+
<InvalidationBatch xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
|
|
25745
|
+
<Paths>
|
|
25746
|
+
<Quantity>${paths.length}</Quantity>
|
|
25747
|
+
<Items>
|
|
25748
|
+
${items}
|
|
25749
|
+
</Items>
|
|
25750
|
+
</Paths>
|
|
25751
|
+
<CallerReference>${escapeXml(callerReference)}</CallerReference>
|
|
25752
|
+
</InvalidationBatch>`;
|
|
25753
|
+
}
|
|
25754
|
+
__name(generateCloudFrontInvalidationXML, "generateCloudFrontInvalidationXML");
|
|
25755
|
+
function escapeXml(str) {
|
|
25756
|
+
const xmlEscapes = {
|
|
25757
|
+
"&": "&",
|
|
25758
|
+
"<": "<",
|
|
25759
|
+
">": ">",
|
|
25760
|
+
'"': """,
|
|
25761
|
+
"'": "'"
|
|
25762
|
+
};
|
|
25763
|
+
return str.replace(/[&<>"']/g, (ch) => xmlEscapes[ch]);
|
|
25764
|
+
}
|
|
25765
|
+
__name(escapeXml, "escapeXml");
|
|
25766
|
+
function generateCloudFrontCallerReference(prefix = "api") {
|
|
25767
|
+
return `${prefix}-${Date.now()}`;
|
|
25768
|
+
}
|
|
25769
|
+
__name(generateCloudFrontCallerReference, "generateCloudFrontCallerReference");
|
|
25770
|
+
|
|
25771
|
+
// src/api/services/cdn/cloudfront/POST/cloudFrontCreateInvalidation.ts
|
|
25772
|
+
async function cloudFrontCreateInvalidation(payload, options) {
|
|
25773
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25774
|
+
if (!payload.distributionId) {
|
|
25775
|
+
throw new ApiPackageError(
|
|
25776
|
+
"Missing required field: distributionId",
|
|
25777
|
+
config.HTTP_STATUS.BAD_REQUEST,
|
|
25778
|
+
api.API_ERROR_CODES.CLOUDFRONT_DISTRIBUTION_NOT_FOUND
|
|
25779
|
+
);
|
|
25780
|
+
}
|
|
25781
|
+
if (!payload.accessKeyId) {
|
|
25782
|
+
throw new ApiPackageError(
|
|
25783
|
+
"Missing required field: accessKeyId",
|
|
25784
|
+
config.HTTP_STATUS.UNAUTHORIZED,
|
|
25785
|
+
api.API_ERROR_CODES.CLOUDFRONT_AUTHENTICATION_FAILED
|
|
25786
|
+
);
|
|
25787
|
+
}
|
|
25788
|
+
if (!payload.secretAccessKey) {
|
|
25789
|
+
throw new ApiPackageError(
|
|
25790
|
+
"Missing required field: secretAccessKey",
|
|
25791
|
+
config.HTTP_STATUS.UNAUTHORIZED,
|
|
25792
|
+
api.API_ERROR_CODES.CLOUDFRONT_AUTHENTICATION_FAILED
|
|
25793
|
+
);
|
|
25794
|
+
}
|
|
25795
|
+
if (!payload.paths || payload.paths.length === 0) {
|
|
25796
|
+
throw new ApiPackageError(
|
|
25797
|
+
"Missing required field: paths (must be non-empty array)",
|
|
25798
|
+
config.HTTP_STATUS.BAD_REQUEST,
|
|
25799
|
+
api.API_ERROR_CODES.CLOUDFRONT_INVALID_PATH
|
|
25800
|
+
);
|
|
25801
|
+
}
|
|
25802
|
+
const region = payload.region ?? config.AWS_CLOUDFRONT_CONFIG.DEFAULT_REGION;
|
|
25803
|
+
const service = config.AWS_CLOUDFRONT_CONFIG.SERVICE_NAME;
|
|
25804
|
+
const host = config.AWS_CLOUDFRONT_CONFIG.HOST;
|
|
25805
|
+
const method = "POST";
|
|
25806
|
+
const path = `/${config.AWS_CLOUDFRONT_CONFIG.API_VERSION}/distribution/${payload.distributionId}/invalidation`;
|
|
25807
|
+
const callerReference = generateCloudFrontCallerReference("api");
|
|
25808
|
+
const body = generateCloudFrontInvalidationXML(payload.paths, callerReference);
|
|
25809
|
+
const { headers: signedHeaders, authorization } = generateAWSSignatureV4({
|
|
25810
|
+
accessKeyId: payload.accessKeyId,
|
|
25811
|
+
secretAccessKey: payload.secretAccessKey,
|
|
25812
|
+
sessionToken: payload.sessionToken,
|
|
25813
|
+
region,
|
|
25814
|
+
service,
|
|
25815
|
+
method,
|
|
25816
|
+
path,
|
|
25817
|
+
host,
|
|
25818
|
+
headers: {
|
|
25819
|
+
"Content-Type": "application/xml"
|
|
25820
|
+
},
|
|
25821
|
+
payload: body
|
|
25822
|
+
});
|
|
25823
|
+
const serviceDefaults = {
|
|
25824
|
+
retry: { attempts: 2 },
|
|
25825
|
+
timeout: 3e4
|
|
25826
|
+
// 30 seconds
|
|
25827
|
+
};
|
|
25828
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25829
|
+
const updateOptions = {
|
|
25830
|
+
strategy: "temporary",
|
|
25831
|
+
...options?.updateConfigOptions
|
|
25832
|
+
};
|
|
25833
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25834
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25835
|
+
}
|
|
25836
|
+
return client.cloudFrontCreateInvalidation({
|
|
25837
|
+
params: { distributionId: payload.distributionId },
|
|
25838
|
+
headers: {
|
|
25839
|
+
...signedHeaders,
|
|
25840
|
+
Authorization: authorization
|
|
25841
|
+
},
|
|
25842
|
+
body
|
|
25843
|
+
});
|
|
25844
|
+
}
|
|
25845
|
+
__name(cloudFrontCreateInvalidation, "cloudFrontCreateInvalidation");
|
|
25846
|
+
async function fastlyPurgeUrl(payload, options) {
|
|
25847
|
+
const client = options?.apiClient ?? getDefaultApiClient();
|
|
25848
|
+
if (!payload.serviceId) {
|
|
25849
|
+
throw new ApiPackageError(
|
|
25850
|
+
"Missing required field: serviceId",
|
|
25851
|
+
config.HTTP_STATUS.BAD_REQUEST,
|
|
25852
|
+
api.API_ERROR_CODES.FASTLY_SERVICE_NOT_FOUND
|
|
25853
|
+
);
|
|
25854
|
+
}
|
|
25855
|
+
if (!payload.apiToken) {
|
|
25856
|
+
throw new ApiPackageError(
|
|
25857
|
+
"Missing required field: apiToken",
|
|
25858
|
+
config.HTTP_STATUS.UNAUTHORIZED,
|
|
25859
|
+
api.API_ERROR_CODES.FASTLY_AUTHENTICATION_FAILED
|
|
25860
|
+
);
|
|
25861
|
+
}
|
|
25862
|
+
if (!payload.url) {
|
|
25863
|
+
throw new ApiPackageError(
|
|
25864
|
+
"Missing required field: url",
|
|
25865
|
+
config.HTTP_STATUS.BAD_REQUEST,
|
|
25866
|
+
api.API_ERROR_CODES.FASTLY_INVALID_URL
|
|
25867
|
+
);
|
|
25868
|
+
}
|
|
25869
|
+
const serviceDefaults = {
|
|
25870
|
+
retry: { attempts: 2 },
|
|
25871
|
+
timeout: 15e3
|
|
25872
|
+
// 15 seconds
|
|
25873
|
+
};
|
|
25874
|
+
const mergedConfig = mergeConfigs(serviceDefaults, options?.apiConfig ?? {});
|
|
25875
|
+
const updateOptions = {
|
|
25876
|
+
strategy: "temporary",
|
|
25877
|
+
...options?.updateConfigOptions
|
|
25878
|
+
};
|
|
25879
|
+
if (shouldApplyConfig(mergedConfig, updateOptions)) {
|
|
25880
|
+
client.updateConfig(mergedConfig, updateOptions);
|
|
25881
|
+
}
|
|
25882
|
+
return client.fastlyPurgeUrl({
|
|
25883
|
+
params: {
|
|
25884
|
+
serviceId: payload.serviceId,
|
|
25885
|
+
url: encodeURIComponent(payload.url)
|
|
25886
|
+
},
|
|
25887
|
+
headers: {
|
|
25888
|
+
"Fastly-Key": payload.apiToken
|
|
25889
|
+
}
|
|
25890
|
+
});
|
|
25891
|
+
}
|
|
25892
|
+
__name(fastlyPurgeUrl, "fastlyPurgeUrl");
|
|
25415
25893
|
function getSSRSafeConfig(config) {
|
|
25416
25894
|
if (!isBrowser()) {
|
|
25417
25895
|
return {
|
|
@@ -25757,6 +26235,7 @@ exports.calculatePollingDuration = calculatePollingDuration;
|
|
|
25757
26235
|
exports.calculateRequestMetrics = calculateRequestMetrics;
|
|
25758
26236
|
exports.campaignEndpoints = campaignEndpoints;
|
|
25759
26237
|
exports.canPerformHeavyOperation = canPerformHeavyOperation;
|
|
26238
|
+
exports.cdnEndpoints = cdnEndpoints;
|
|
25760
26239
|
exports.checkOverrideTriggers = checkOverrideTriggers;
|
|
25761
26240
|
exports.clamp = clamp;
|
|
25762
26241
|
exports.clampedPercentage = clampedPercentage;
|
|
@@ -25764,6 +26243,10 @@ exports.clearErrorHandlers = clearErrorHandlers;
|
|
|
25764
26243
|
exports.clearNetworkDebugData = clearNetworkDebugData;
|
|
25765
26244
|
exports.clearTemporaryOverrides = clearTemporaryOverrides;
|
|
25766
26245
|
exports.cloneConfig = cloneConfig;
|
|
26246
|
+
exports.cloudFrontCreateInvalidation = cloudFrontCreateInvalidation;
|
|
26247
|
+
exports.cloudFrontEndpoints = cloudFrontEndpoints;
|
|
26248
|
+
exports.cloudflareEndpoints = cloudflareEndpoints;
|
|
26249
|
+
exports.cloudflarePurgeCache = cloudflarePurgeCache;
|
|
25767
26250
|
exports.compactHistory = compactHistory;
|
|
25768
26251
|
exports.configConflictDetector = configConflictDetector;
|
|
25769
26252
|
exports.configureForEnvironment = configureForEnvironment;
|
|
@@ -25836,6 +26319,8 @@ exports.exportKeyToBase64 = exportKeyToBase64;
|
|
|
25836
26319
|
exports.extendRevalidationPresets = extendPresets;
|
|
25837
26320
|
exports.extractFields = extractFields;
|
|
25838
26321
|
exports.extractUrlParams = extractUrlParams;
|
|
26322
|
+
exports.fastlyEndpoints = fastlyEndpoints;
|
|
26323
|
+
exports.fastlyPurgeUrl = fastlyPurgeUrl;
|
|
25839
26324
|
exports.fetchCampaign = fetchCampaign;
|
|
25840
26325
|
exports.fetchCampaignParticipants = fetchCampaignParticipants;
|
|
25841
26326
|
exports.fetchCampaignStats = fetchCampaignStats;
|
|
@@ -25872,6 +26357,7 @@ exports.getAdaptiveTimeout = getAdaptiveTimeout;
|
|
|
25872
26357
|
exports.getAllEndpointUrls = getAllEndpointUrls;
|
|
25873
26358
|
exports.getAllFieldPaths = getAllFieldPaths;
|
|
25874
26359
|
exports.getAllMediaExtensions = getAllMediaExtensions;
|
|
26360
|
+
exports.getAnalysisResult = getAnalysisResult;
|
|
25875
26361
|
exports.getAppVersion = getAppVersion;
|
|
25876
26362
|
exports.getAuthenticationType = getAuthenticationType;
|
|
25877
26363
|
exports.getCache = getCache;
|
|
@@ -26195,6 +26681,7 @@ exports.unregisterErrorHandlers = unregisterErrorHandlers;
|
|
|
26195
26681
|
exports.updateCampaign = updateCampaign;
|
|
26196
26682
|
exports.updateGlobalConfig = updateGlobalConfig;
|
|
26197
26683
|
exports.updateInfobipScheduledEmailStatuses = updateInfobipScheduledEmailStatuses;
|
|
26684
|
+
exports.uploadFileForScanning = uploadFileForScanning;
|
|
26198
26685
|
exports.useAbortableRequest = useAbortableRequest;
|
|
26199
26686
|
exports.useApiConfigConflicts = useApiConfigConflicts;
|
|
26200
26687
|
exports.useApiDebugInfo = useApiDebugInfo;
|
|
@@ -26225,6 +26712,7 @@ exports.validateHeaders = validateHeaders2;
|
|
|
26225
26712
|
exports.validateInfobipEmail = validateInfobipEmail;
|
|
26226
26713
|
exports.validatePathParams = validatePathParams;
|
|
26227
26714
|
exports.validatePreset = validatePreset;
|
|
26715
|
+
exports.virusTotalEndpoints = virusTotalEndpoints;
|
|
26228
26716
|
exports.waitForOnline = waitForOnline;
|
|
26229
26717
|
exports.withNetworkDetection = withNetworkDetection;
|
|
26230
26718
|
exports.withNetworkInfo = withNetworkInfo;
|