@easyflow/javascript-sdk 2.1.8 → 2.1.10

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 (94) hide show
  1. package/README.md +87 -7
  2. package/dist/index.d.ts +421 -0
  3. package/package.json +19 -6
  4. package/.babelrc +0 -5
  5. package/.github/workflows/deploy-sdk-cf.yml +0 -49
  6. package/.github/workflows/release-sdk-cdn.yml +0 -144
  7. package/.github/workflows/release-sdk.yml +0 -112
  8. package/.prettierrc +0 -6
  9. package/CDN-DEPLOYMENT.md +0 -175
  10. package/DEMO.md +0 -258
  11. package/DEPLOYMENT.md +0 -224
  12. package/INTEGRATION-GUIDE.md +0 -521
  13. package/coverage/base.css +0 -224
  14. package/coverage/block-navigation.js +0 -87
  15. package/coverage/easyflow-javascript-sdk/index.html +0 -116
  16. package/coverage/easyflow-javascript-sdk/libs/constants.mjs.html +0 -268
  17. package/coverage/easyflow-javascript-sdk/libs/errors.mjs.html +0 -271
  18. package/coverage/easyflow-javascript-sdk/libs/exception-handler.mjs.html +0 -148
  19. package/coverage/easyflow-javascript-sdk/libs/fingerprint.mjs.html +0 -895
  20. package/coverage/easyflow-javascript-sdk/libs/http.mjs.html +0 -502
  21. package/coverage/easyflow-javascript-sdk/libs/index.html +0 -266
  22. package/coverage/easyflow-javascript-sdk/libs/logger.mjs.html +0 -568
  23. package/coverage/easyflow-javascript-sdk/libs/sanitizer.mjs.html +0 -1099
  24. package/coverage/easyflow-javascript-sdk/libs/security.mjs.html +0 -733
  25. package/coverage/easyflow-javascript-sdk/libs/types.mjs.html +0 -508
  26. package/coverage/easyflow-javascript-sdk/libs/utils.mjs.html +0 -379
  27. package/coverage/easyflow-javascript-sdk/libs/validator.mjs.html +0 -2623
  28. package/coverage/easyflow-javascript-sdk/sdk.mjs.html +0 -2434
  29. package/coverage/favicon.png +0 -0
  30. package/coverage/index.html +0 -131
  31. package/coverage/lcov-report/base.css +0 -224
  32. package/coverage/lcov-report/block-navigation.js +0 -87
  33. package/coverage/lcov-report/easyflow-javascript-sdk/index.html +0 -116
  34. package/coverage/lcov-report/easyflow-javascript-sdk/libs/constants.mjs.html +0 -268
  35. package/coverage/lcov-report/easyflow-javascript-sdk/libs/errors.mjs.html +0 -271
  36. package/coverage/lcov-report/easyflow-javascript-sdk/libs/exception-handler.mjs.html +0 -148
  37. package/coverage/lcov-report/easyflow-javascript-sdk/libs/fingerprint.mjs.html +0 -895
  38. package/coverage/lcov-report/easyflow-javascript-sdk/libs/http.mjs.html +0 -502
  39. package/coverage/lcov-report/easyflow-javascript-sdk/libs/index.html +0 -266
  40. package/coverage/lcov-report/easyflow-javascript-sdk/libs/logger.mjs.html +0 -568
  41. package/coverage/lcov-report/easyflow-javascript-sdk/libs/sanitizer.mjs.html +0 -1099
  42. package/coverage/lcov-report/easyflow-javascript-sdk/libs/security.mjs.html +0 -733
  43. package/coverage/lcov-report/easyflow-javascript-sdk/libs/types.mjs.html +0 -508
  44. package/coverage/lcov-report/easyflow-javascript-sdk/libs/utils.mjs.html +0 -379
  45. package/coverage/lcov-report/easyflow-javascript-sdk/libs/validator.mjs.html +0 -2623
  46. package/coverage/lcov-report/easyflow-javascript-sdk/sdk.mjs.html +0 -2434
  47. package/coverage/lcov-report/favicon.png +0 -0
  48. package/coverage/lcov-report/index.html +0 -131
  49. package/coverage/lcov-report/prettify.css +0 -1
  50. package/coverage/lcov-report/prettify.js +0 -2
  51. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  52. package/coverage/lcov-report/sorter.js +0 -196
  53. package/coverage/lcov.info +0 -1429
  54. package/coverage/prettify.css +0 -1
  55. package/coverage/prettify.js +0 -2
  56. package/coverage/sort-arrow-sprite.png +0 -0
  57. package/coverage/sorter.js +0 -196
  58. package/dist/435.easyflow-sdk.min.js +0 -1
  59. package/dist/easyflow-sdk.min.js +0 -1
  60. package/dist/easyflow-sdk.min.js.LICENSE.txt +0 -1
  61. package/dist/index.html +0 -756
  62. package/docs/index.html +0 -775
  63. package/examples/lovable-integration.html +0 -410
  64. package/index.html +0 -981
  65. package/jest.config.js +0 -37
  66. package/jsdoc.json +0 -42
  67. package/libs/auto-integration.mjs +0 -333
  68. package/libs/constants.mjs +0 -61
  69. package/libs/constants.spec.js +0 -198
  70. package/libs/errors.mjs +0 -62
  71. package/libs/errors.spec.js +0 -178
  72. package/libs/exception-handler.mjs +0 -21
  73. package/libs/exception-handler.spec.js +0 -237
  74. package/libs/fingerprint.mjs +0 -270
  75. package/libs/http.mjs +0 -163
  76. package/libs/http.spec.js +0 -427
  77. package/libs/integration-wrapper.mjs +0 -285
  78. package/libs/logger.mjs +0 -161
  79. package/libs/logger.spec.js +0 -389
  80. package/libs/sanitizer.mjs +0 -340
  81. package/libs/sanitizer.spec.js +0 -583
  82. package/libs/security.mjs +0 -217
  83. package/libs/types.mjs +0 -141
  84. package/libs/utils.mjs +0 -368
  85. package/libs/utils.spec.js +0 -231
  86. package/libs/validator.mjs +0 -952
  87. package/libs/validator.spec.js +0 -615
  88. package/mocks/offer.mock.js +0 -77
  89. package/scripts/publish-npm.sh +0 -82
  90. package/sdk.mjs +0 -945
  91. package/sdk.spec.js +0 -796
  92. package/test-setup.cjs +0 -211
  93. package/test.html +0 -154
  94. package/webpack.config.cjs +0 -41
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Easyflow JavaScript SDK
2
2
 
3
3
  [![Build Status](https://github.com/easyflow-cash/easyflow-javascript-sdk/workflows/Build%20&%20Deploy%20Easyflow%20SDK/badge.svg)](https://github.com/easyflow-cash/easyflow-javascript-sdk/actions)
4
- [![Version](https://img.shields.io/badge/version-2.1.8-blue.svg)](https://easyflow-sdk.pages.dev)
4
+ [![Version](https://img.shields.io/badge/version-2.1.10-blue.svg)](https://easyflow-sdk.pages.dev)
5
5
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
6
6
  [![Tests](https://img.shields.io/badge/tests-250%20passing-brightgreen.svg)](https://github.com/easyflow-cash/easyflow-javascript-sdk)
7
7
  [![Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen.svg)](https://github.com/easyflow-cash/easyflow-javascript-sdk)
@@ -84,7 +84,30 @@ The **Easyflow JavaScript SDK** is the official tool for developers to integrate
84
84
  - **High Performance**: Optimized for production
85
85
  - **Complete Documentation**: Practical examples for all use cases
86
86
 
87
- ## What's New in v2.1.8
87
+ ## What's New in v2.1.10
88
+
89
+ ### Workflow Corrections
90
+
91
+ - **GitHub Actions Fixed**: Resolved release workflow permissions and SRI hash generation
92
+ - **CDN Deployment**: Automated deployment to Cloudflare Pages working correctly
93
+ - **Release Automation**: GitHub releases created automatically with proper SRI hashes
94
+ - **Build Process**: Streamlined build and deployment pipeline
95
+
96
+ ### Hybrid Distribution Strategy
97
+
98
+ ### Hybrid Distribution Strategy
99
+
100
+ - **NPM Package**: Contains only documentation and TypeScript definitions
101
+ - **CDN Scripts**: Production-ready obfuscated builds via Cloudflare Pages
102
+ - **Enhanced Security**: Code source protected while maintaining accessibility
103
+ - **Better UX**: Easy discovery via NPM, secure usage via CDN
104
+
105
+ ### Security & Privacy Improvements
106
+
107
+ - **README Anonymization**: Removed all personal information and sensitive data
108
+ - **Privacy Protection**: No personal emails, URLs, or contact information exposed
109
+ - **Professional Documentation**: Clean, business-focused documentation
110
+ - **NPM Safety**: Safe for public NPM publication
88
111
 
89
112
  ### Security & Privacy Improvements
90
113
 
@@ -135,10 +158,30 @@ The **Easyflow JavaScript SDK** is the official tool for developers to integrate
135
158
 
136
159
  ### Installation
137
160
 
161
+ #### Option 1: CDN Script (Recommended)
162
+
163
+ Add this script tag to your HTML:
164
+
165
+ ```html
166
+ <!-- Latest version -->
167
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
168
+
169
+ <!-- Specific version -->
170
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.10.min.js"></script>
171
+ ```
172
+
173
+ #### Option 2: NPM Package (Documentation Only)
174
+
138
175
  ```bash
139
176
  npm install @easyflow/javascript-sdk
140
177
  ```
141
178
 
179
+ **Note**: The NPM package contains only documentation. For production use, use the CDN script above.
180
+
181
+ #### Option 3: Direct Download
182
+
183
+ Download the latest obfuscated build from [GitHub Releases](https://github.com/easyflow-cash/easyflow-javascript-sdk/releases).
184
+
142
185
  ### Basic Usage
143
186
 
144
187
  ```javascript
@@ -191,6 +234,8 @@ console.log('Order created:', orderId)
191
234
  - **Fingerprinting**: Advanced fraud detection
192
235
  - **Rate Limiting**: Protection against abuse
193
236
  - **Input Validation**: Comprehensive data validation
237
+ - **Obfuscated Builds**: Production builds are obfuscated for enhanced security
238
+ - **Controlled Distribution**: Secure distribution via CDN and GitHub Releases
194
239
 
195
240
  ## API Reference
196
241
 
@@ -469,12 +514,33 @@ const bankBillet = await sdk.getBankBillet(orderId)
469
514
  console.log('Bank Billet Link:', bankBillet.link)
470
515
  ```
471
516
 
472
- ## Browser Support
517
+ ## Distribution & Security
518
+
519
+ ### Why CDN Scripts?
520
+
521
+ - **Obfuscated Builds**: Production code is obfuscated for security
522
+ - **Controlled Access**: Secure distribution via Cloudflare Pages
523
+ - **Version Control**: Specific versions available for stability
524
+ - **Performance**: Global CDN for fast loading
525
+
526
+ ### Available CDN URLs
527
+
528
+ ```html
529
+ <!-- Latest version -->
530
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.min.js"></script>
473
531
 
474
- - **Chrome**: 88+
475
- - **Firefox**: 85+
476
- - **Safari**: 14+
477
- - **Edge**: 88+
532
+ <!-- Versioned (recommended for production) -->
533
+ <script src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.8.min.js"></script>
534
+
535
+ <!-- With SRI (Subresource Integrity) -->
536
+ <script
537
+ src="https://easyflow-sdk.pages.dev/easyflow-sdk.v2.1.10.min.js"
538
+ integrity="sha384-[hash]"
539
+ crossorigin="anonymous"
540
+ ></script>
541
+ ```
542
+
543
+ ## Browser Support
478
544
 
479
545
  ## Node.js Support
480
546
 
@@ -498,6 +564,20 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
498
564
 
499
565
  ## Changelog
500
566
 
567
+ ### v2.1.10
568
+
569
+ - **Workflow Fixed**: Resolved GitHub Actions permissions and SRI hash generation
570
+ - **CDN Automation**: Automated deployment to Cloudflare Pages working correctly
571
+ - **Release Process**: GitHub releases created automatically with proper SRI hashes
572
+ - **Build Pipeline**: Streamlined build and deployment process
573
+
574
+ ### v2.1.9
575
+
576
+ - **Hybrid Distribution**: NPM for docs, CDN for secure obfuscated code
577
+ - **Enhanced Security**: Code source protected while maintaining accessibility
578
+ - **Better UX**: Easy discovery via NPM, secure usage via CDN
579
+ - **Documentation**: Complete setup and usage instructions
580
+
501
581
  ### v2.1.8
502
582
 
503
583
  - **Security & Privacy**: Anonymized README.md for safe NPM publication
@@ -0,0 +1,421 @@
1
+ declare module '@easyflow/javascript-sdk' {
2
+ export interface EasyflowSDKConfig {
3
+ businessId: string
4
+ environment?: 'production' | 'sandbox'
5
+ debug?: boolean
6
+ timeout?: number
7
+ }
8
+
9
+ export interface CustomerData {
10
+ name: string
11
+ email: string
12
+ document: {
13
+ type: 'CPF' | 'CNPJ'
14
+ number: string
15
+ }
16
+ phone?: {
17
+ areaCode: string
18
+ ddd: string
19
+ number: string
20
+ isMobile: boolean
21
+ }
22
+ address?: {
23
+ zipCode: string
24
+ street: string
25
+ number: string
26
+ complement?: string
27
+ neighborhood: string
28
+ city: string
29
+ state: string
30
+ }
31
+ deliveryAddress?: {
32
+ zipCode: string
33
+ street: string
34
+ number: string
35
+ complement?: string
36
+ neighborhood: string
37
+ city: string
38
+ state: string
39
+ }
40
+ }
41
+
42
+ export interface PaymentMethod {
43
+ method: 'credit-card' | 'pix' | 'bank-billet'
44
+ numberInstallments: number
45
+ creditCard?: {
46
+ number: string
47
+ holderName: string
48
+ month: string
49
+ year: string
50
+ cvv: string
51
+ }
52
+ creditCardId?: string
53
+ }
54
+
55
+ export interface OrderData {
56
+ customer: CustomerData
57
+ payments: PaymentMethod[]
58
+ items?: Array<{
59
+ name: string
60
+ price: number
61
+ quantity?: number
62
+ }>
63
+ metadata?: Record<string, any>
64
+ }
65
+
66
+ export interface CreditCardData {
67
+ number: string
68
+ holderName: string
69
+ month: string
70
+ year: string
71
+ cvv: string
72
+ }
73
+
74
+ export interface Customer {
75
+ id: string
76
+ name: string
77
+ email: string
78
+ document: {
79
+ type: 'CPF' | 'CNPJ'
80
+ number: string
81
+ }
82
+ phone?: {
83
+ areaCode: string
84
+ ddd: string
85
+ number: string
86
+ isMobile: boolean
87
+ }
88
+ address?: {
89
+ zipCode: string
90
+ street: string
91
+ number: string
92
+ complement?: string
93
+ neighborhood: string
94
+ city: string
95
+ state: string
96
+ }
97
+ deliveryAddress?: {
98
+ zipCode: string
99
+ street: string
100
+ number: string
101
+ complement?: string
102
+ neighborhood: string
103
+ city: string
104
+ state: string
105
+ }
106
+ createdAt?: string
107
+ updatedAt?: string
108
+ }
109
+
110
+ export interface CreditCard {
111
+ creditCardId: string
112
+ brand?: string
113
+ last4Numbers?: string
114
+ expiresAtMonth?: string
115
+ expiresAtYear?: string
116
+ holderName?: string
117
+ }
118
+
119
+ export interface Order {
120
+ id: string
121
+ status: string
122
+ total: number
123
+ customer: Customer
124
+ payments: PaymentMethod[]
125
+ items?: Array<{
126
+ name: string
127
+ price: number
128
+ quantity: number
129
+ }>
130
+ createdAt?: string
131
+ updatedAt?: string
132
+ }
133
+
134
+ export interface Offer {
135
+ id: string
136
+ name: string
137
+ price: number
138
+ description?: string
139
+ items: Array<{
140
+ name: string
141
+ price: number
142
+ quantity: number
143
+ }>
144
+ }
145
+
146
+ export interface PixData {
147
+ qrCode: string
148
+ copyAndPasteCode: string
149
+ expirationDate: string
150
+ }
151
+
152
+ export interface BankBilletData {
153
+ link: string
154
+ line: string
155
+ barCode: string
156
+ expirationDate: string
157
+ }
158
+
159
+ export interface ValidationResult {
160
+ isValid: boolean
161
+ errors?: string[]
162
+ }
163
+
164
+ export class EasyflowSDK {
165
+ static readonly version: string
166
+
167
+ constructor(config: EasyflowSDKConfig | string)
168
+
169
+ // Core Methods
170
+ placeOrder(
171
+ offerId: string,
172
+ data: OrderData,
173
+ headers?: Record<string, string>
174
+ ): Promise<string>
175
+ charge(
176
+ data: OrderData,
177
+ headers?: Record<string, string>
178
+ ): Promise<string>
179
+ encrypt(
180
+ creditCardData: CreditCardData,
181
+ headers?: Record<string, string>
182
+ ): Promise<string>
183
+
184
+ // Offer & Order Management
185
+ getOffer(
186
+ offerId: string,
187
+ headers?: Record<string, string>
188
+ ): Promise<Offer>
189
+ getOrder(
190
+ orderId: string,
191
+ headers?: Record<string, string>
192
+ ): Promise<Order>
193
+
194
+ // Payment Methods
195
+ getPix(
196
+ orderId: string,
197
+ headers?: Record<string, string>
198
+ ): Promise<PixData | null>
199
+ getBankBillet(
200
+ orderId: string,
201
+ headers?: Record<string, string>
202
+ ): Promise<BankBilletData | null>
203
+
204
+ // Customer Management
205
+ createCustomer(
206
+ customerData: CustomerData,
207
+ headers?: Record<string, string>
208
+ ): Promise<Customer>
209
+ getCustomer(
210
+ customerId: string,
211
+ headers?: Record<string, string>
212
+ ): Promise<Customer>
213
+ updateCustomer(
214
+ customerId: string,
215
+ updateData: Partial<CustomerData>,
216
+ headers?: Record<string, string>
217
+ ): Promise<ValidationResult>
218
+
219
+ // Credit Card Management
220
+ addCreditCard(
221
+ customerId: string,
222
+ creditCardToken: string,
223
+ headers?: Record<string, string>
224
+ ): Promise<CreditCard>
225
+ getCreditCard(
226
+ customerId: string,
227
+ creditCardId: string,
228
+ headers?: Record<string, string>
229
+ ): Promise<CreditCard>
230
+ removeCreditCard(
231
+ customerId: string,
232
+ creditCardId: string,
233
+ headers?: Record<string, string>
234
+ ): Promise<ValidationResult>
235
+
236
+ // Event System
237
+ on(
238
+ event: 'customerCreated' | 'orderPlaced' | 'paymentProcessed',
239
+ callback: (data: any) => void
240
+ ): void
241
+ off(
242
+ event: 'customerCreated' | 'orderPlaced' | 'paymentProcessed',
243
+ callback: (data: any) => void
244
+ ): void
245
+ }
246
+
247
+ // Validator Class
248
+ export class Validator {
249
+ static validateEmail(email: string): boolean
250
+ static validateCPF(cpf: string): boolean
251
+ static validateCNPJ(cnpj: string): boolean
252
+ static validateLegalDocument(document: {
253
+ type: 'CPF' | 'CNPJ'
254
+ number: string
255
+ }): boolean
256
+ static validatePhone(phone: {
257
+ areaCode: string
258
+ ddd: string
259
+ number: string
260
+ isMobile: boolean
261
+ }): boolean
262
+ static validateAddress(address: {
263
+ zipCode: string
264
+ street: string
265
+ number: string
266
+ complement?: string
267
+ neighborhood: string
268
+ city: string
269
+ state: string
270
+ }): boolean
271
+ static validateCustomer(customer: CustomerData): boolean
272
+ static validatePagination(page: number, limit: number): boolean
273
+ static validateBusinessId(businessId: string): boolean
274
+ static validateCreditCardToken(token: string): boolean
275
+ static validateOrderId(orderId: string): boolean
276
+ static validateOfferId(offerId: string): boolean
277
+ static validateCustomerId(customerId: string): boolean
278
+ static validateCreditCardId(creditCardId: string): boolean
279
+ static validateOrderData(orderData: OrderData): boolean
280
+ }
281
+
282
+ // Constants
283
+ export const PAYMENT_METHODS: {
284
+ readonly CREDIT_CARD: 'credit-card'
285
+ readonly PIX: 'pix'
286
+ readonly BANK_BILLET: 'bank-billet'
287
+ }
288
+
289
+ export const TARGETS: {
290
+ readonly CHARGE: 'charge'
291
+ readonly PLACE_ORDER: 'place-order'
292
+ readonly ENCRYPT: 'encrypt'
293
+ readonly GET_OFFER: 'get-offer'
294
+ readonly GET_ORDER: 'get-order'
295
+ }
296
+
297
+ export const HTTP_STATUS_CODES: {
298
+ readonly OK: 200
299
+ readonly CREATED: 201
300
+ readonly BAD_REQUEST: 400
301
+ readonly UNAUTHORIZED: 401
302
+ readonly FORBIDDEN: 403
303
+ readonly NOT_FOUND: 404
304
+ readonly INTERNAL_SERVER_ERROR: 500
305
+ }
306
+
307
+ export const HTTP_REQUEST_METHODS: {
308
+ readonly GET: 'GET'
309
+ readonly POST: 'POST'
310
+ readonly PUT: 'PUT'
311
+ readonly DELETE: 'DELETE'
312
+ }
313
+
314
+ // Error Classes
315
+ export class EasyflowError extends Error {
316
+ constructor(message: string, status?: number, code?: string)
317
+ status: number
318
+ code: string
319
+ }
320
+
321
+ export class SecurityError extends EasyflowError {
322
+ constructor(message: string)
323
+ }
324
+
325
+ export class ValidationError extends EasyflowError {
326
+ constructor(message: string)
327
+ }
328
+
329
+ export class NetworkError extends EasyflowError {
330
+ constructor(message: string)
331
+ }
332
+
333
+ export const ERROR_CODES: {
334
+ readonly VALIDATION_ERROR: 'VALIDATION_ERROR'
335
+ readonly SECURITY_ERROR: 'SECURITY_ERROR'
336
+ readonly NETWORK_ERROR: 'NETWORK_ERROR'
337
+ readonly UNKNOWN_ERROR: 'UNKNOWN_ERROR'
338
+ }
339
+
340
+ // Default export
341
+ export default EasyflowSDK
342
+ }
343
+
344
+ // Global instance for browser environments
345
+ declare global {
346
+ interface Window {
347
+ easyflowSDK: {
348
+ on(event: string, callback: (data: any) => void): void
349
+ off(event: string, callback: (data: any) => void): void
350
+ placeOrder(
351
+ offerId: string,
352
+ data: any,
353
+ headers?: Record<string, string>
354
+ ): Promise<string>
355
+ charge(data: any, headers?: Record<string, string>): Promise<string>
356
+ encrypt(
357
+ creditCardData: any,
358
+ headers?: Record<string, string>
359
+ ): Promise<string>
360
+ getOffer(
361
+ offerId: string,
362
+ headers?: Record<string, string>
363
+ ): Promise<any>
364
+ getOrder(
365
+ orderId: string,
366
+ headers?: Record<string, string>
367
+ ): Promise<any>
368
+ getPix(
369
+ orderId: string,
370
+ headers?: Record<string, string>
371
+ ): Promise<any>
372
+ getBankBillet(
373
+ orderId: string,
374
+ headers?: Record<string, string>
375
+ ): Promise<any>
376
+ createCustomer(
377
+ customerData: any,
378
+ headers?: Record<string, string>
379
+ ): Promise<any>
380
+ getCustomer(
381
+ customerId: string,
382
+ headers?: Record<string, string>
383
+ ): Promise<any>
384
+ updateCustomer(
385
+ customerId: string,
386
+ updateData: any,
387
+ headers?: Record<string, string>
388
+ ): Promise<any>
389
+ addCreditCard(
390
+ customerId: string,
391
+ creditCardToken: string,
392
+ headers?: Record<string, string>
393
+ ): Promise<any>
394
+ getCreditCard(
395
+ customerId: string,
396
+ creditCardId: string,
397
+ headers?: Record<string, string>
398
+ ): Promise<any>
399
+ removeCreditCard(
400
+ customerId: string,
401
+ creditCardId: string,
402
+ headers?: Record<string, string>
403
+ ): Promise<any>
404
+ validate: {
405
+ email(email: string): boolean
406
+ cpf(cpf: string): boolean
407
+ cnpj(cnpj: string): boolean
408
+ phone(phone: any): boolean
409
+ address(address: any): boolean
410
+ customer(customer: any): boolean
411
+ orderId(orderId: string): boolean
412
+ offerId(offerId: string): boolean
413
+ customerId(customerId: string): boolean
414
+ creditCardId(creditCardId: string): boolean
415
+ }
416
+ version: string
417
+ PAYMENT_METHODS: any
418
+ }
419
+ EasyflowSDK: typeof import('@easyflow/javascript-sdk').EasyflowSDK
420
+ }
421
+ }
package/package.json CHANGED
@@ -1,16 +1,27 @@
1
1
  {
2
2
  "name": "@easyflow/javascript-sdk",
3
- "version": "2.1.8",
4
- "description": "Easyflow javascript SDK to be used on client side applications",
5
- "main": "dist/easyflow-sdk.min.js",
3
+ "version": "2.1.10",
4
+ "description": "Easyflow JavaScript SDK - Documentation and TypeScript definitions. For production use, use the CDN script: https://easyflow-sdk.pages.dev/easyflow-sdk.min.js",
5
+ "main": "README.md",
6
+ "module": "README.md",
6
7
  "type": "module",
7
8
  "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "README.md",
11
+ "LICENSE",
12
+ "dist/index.d.ts"
13
+ ],
8
14
  "exports": {
9
- "import": "./dist/index.mjs",
10
- "require": "./dist/index.cjs"
15
+ ".": {
16
+ "import": "./dist/easyflow-sdk.min.js",
17
+ "require": "./dist/easyflow-sdk.min.js",
18
+ "types": "./dist/index.d.ts"
19
+ },
20
+ "./package.json": "./package.json"
11
21
  },
12
22
  "scripts": {
13
- "build": "npm run generate-version && npx webpack --config webpack.config.cjs",
23
+ "build": "npm run generate-version && npm run build:types && npx webpack --config webpack.config.cjs",
24
+ "build:types": "npx tsc --project tsconfig.json",
14
25
  "generate-version": "node -e \"const pkg=require('./package.json'); const fs=require('fs'); const content='export const SDK_VERSION = \\'' + pkg.version + '\\';'; fs.writeFileSync('./version.mjs', content);\"",
15
26
  "server:up": "rm -rf ./dist && npm run build && npx http-server . -p 8080 -o",
16
27
  "dev": "npm run build && npx http-server . -p 8080 -o --cors",
@@ -38,12 +49,14 @@
38
49
  "@babel/cli": "^7.26.4",
39
50
  "@babel/core": "^7.26.8",
40
51
  "@babel/preset-env": "^7.26.8",
52
+ "@types/node": "^20.19.11",
41
53
  "babel-loader": "^9.2.1",
42
54
  "http-server": "^14.1.1",
43
55
  "javascript-obfuscator": "^4.1.1",
44
56
  "jest": "^29.7.0",
45
57
  "prettier": "^3.4.2",
46
58
  "terser-webpack-plugin": "^5.3.11",
59
+ "typescript": "^5.9.2",
47
60
  "webpack": "^5.97.1",
48
61
  "webpack-cli": "^6.0.1",
49
62
  "webpack-obfuscator": "^3.5.1"
package/.babelrc DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "presets": [
3
- "@babel/preset-env"
4
- ]
5
- }
@@ -1,49 +0,0 @@
1
- name: Deploy Easyflow SDK to Cloudflare Pages
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- workflow_dispatch:
7
-
8
- jobs:
9
- build-and-deploy:
10
- runs-on: ubuntu-latest
11
-
12
- steps:
13
- - name: Checkout code
14
- uses: actions/checkout@v4
15
-
16
- - name: Setup Node.js
17
- uses: actions/setup-node@v4
18
- with:
19
- node-version: '18'
20
- cache: 'npm'
21
-
22
- - name: Install dependencies
23
- run: npm ci
24
-
25
- - name: Build SDK
26
- run: npm run build
27
-
28
- - name: Copy Documentation to Build
29
- run: |
30
- # Copiar apenas o index.html da documentação
31
- cp docs/index.html dist/
32
- echo "📚 Documentação copiada para build (apenas index.html)"
33
-
34
- - name: Deploy to Cloudflare Pages
35
- uses: cloudflare/pages-action@v1
36
- with:
37
- apiToken: ${{ secrets.CF_API_TOKEN }}
38
- accountId: ${{ secrets.CF_ACCOUNT_ID }}
39
- projectName: easyflow-sdk
40
- directory: dist
41
-
42
- - name: Success Message
43
- run: |
44
- echo "🚀 SDK e Documentação Deployados com sucesso!"
45
- echo "📦 SDK + Docs: https://easyflow-sdk.pages.dev"
46
- echo "🌐 jsDelivr: https://cdn.jsdelivr.net/npm/@easyflow/javascript-sdk@latest/dist/easyflow-sdk.min.js"
47
- echo ""
48
- echo "✅ Documentação agora está disponível em:"
49
- echo " https://easyflow-sdk.pages.dev"