@pixelpay/sdk-core 2.4.2-beta.1 → 2.4.2-beta.3

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
@@ -5,6 +5,10 @@ El formato se basa en [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  y este proyecto se adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
  Tipos de cambios: `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`.
7
7
 
8
+ ## [v2.4.1] - 2025-05-20
9
+ ### Added
10
+ - Se agregó soporte para autenticación de 3D Secure con Cardinal API
11
+
8
12
  ## [v2.4.0] - 2025-03-13
9
13
  ### Added
10
14
  - Se agregó autenticación de 3D Secure con Cybersource
package/deploy.js ADDED
@@ -0,0 +1,92 @@
1
+ const { S3Client, PutObjectCommand } = require('@aws-sdk/client-s3');
2
+ const { CloudFrontClient, CreateInvalidationCommand } = require('@aws-sdk/client-cloudfront');
3
+ const { version } = require('./package.json');
4
+ const dotenv = require('dotenv');
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ dotenv.config();
9
+
10
+ const filePath = path.join('lib', 'browser', 'index.js');
11
+ const isBeta = version.includes('beta');
12
+
13
+ const bucketName = process.env.S3_BUCKET_NAME;
14
+ const cloudfrontDistributionId = process.env.CLOUDFRONT_DISTRIBUTION_ID;
15
+ const domain = process.env.DOMAIN_NAME;
16
+
17
+ const s3Path = 'sdk/';
18
+ const versionedFile = `${s3Path}sdk-core@${version}.js`;
19
+ const latestFile = `${s3Path}sdk-core.js`;
20
+
21
+ const awsCredentials = {
22
+ region: process.env.AWS_REGION,
23
+ credentials: {
24
+ accessKeyId: process.env.S3_ACCESS_KEY_ID,
25
+ secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
26
+ },
27
+ };
28
+
29
+ const s3 = new S3Client(awsCredentials);
30
+ const cloudfront = new CloudFrontClient(awsCredentials);
31
+
32
+ /**
33
+ * Uploads a file to an Amazon S3 bucket.
34
+ * @param {string} fileName - The name of the file to be uploaded to the S3 bucket.
35
+ * @returns {Promise<void>} A promise that resolves when the file is successfully uploaded.
36
+ */
37
+ async function uploadToS3(fileName) {
38
+ try {
39
+ const fileContent = fs.readFileSync(filePath);
40
+
41
+ const params = {
42
+ Bucket: bucketName,
43
+ Key: fileName,
44
+ Body: fileContent,
45
+ ContentType: 'application/javascript',
46
+ };
47
+
48
+ await s3.send(new PutObjectCommand(params));
49
+ console.log(`Archivo subido con éxito: https://${bucketName}.s3.amazonaws.com/${fileName}`);
50
+ } catch (error) {
51
+ console.error(`Error al subir el archivo (${fileName}):`, error);
52
+ process.exit(1);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Invalidates the CloudFront cache for a specific file.
58
+ * @param {string} fileName - The name of the file (including its path) to invalidate in the CloudFront cache.
59
+ * @returns {Promise<void>} A promise that resolves when the cache invalidation is successfully completed.
60
+ */
61
+ async function invalidateCloudFrontCache(fileName) {
62
+ try {
63
+ const params = {
64
+ DistributionId: cloudfrontDistributionId,
65
+ InvalidationBatch: {
66
+ Paths: {
67
+ Quantity: 1,
68
+ Items: [`/${fileName}`],
69
+ },
70
+ CallerReference: `${Date.now()}`,
71
+ },
72
+ };
73
+
74
+ await cloudfront.send(new CreateInvalidationCommand(params));
75
+ console.log(`Caché invalidado en CloudFront para /${fileName}`);
76
+ } catch (error) {
77
+ console.error('Error al invalidar caché:', error);
78
+ }
79
+ }
80
+
81
+ (async () => {
82
+ await uploadToS3(versionedFile);
83
+ console.log(`Archivo disponible en: ${domain}/${versionedFile}`);
84
+
85
+ if (!isBeta) {
86
+ await uploadToS3(latestFile);
87
+ await invalidateCloudFrontCache(latestFile);
88
+ console.log(`Archivo disponible en: ${domain}/${latestFile}`);
89
+ }
90
+
91
+ console.log('Publicación completada');
92
+ })();