@easyflow/javascript-sdk 2.1.8 → 2.1.9

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 +71 -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/libs/errors.mjs DELETED
@@ -1,62 +0,0 @@
1
- /**
2
- * Custom error class for Easyflow SDK
3
- */
4
- export class EasyflowError extends Error {
5
- /**
6
- * @param {string} message - Error message
7
- * @param {number} status - HTTP status code
8
- * @param {string} code - Error code for programmatic handling
9
- */
10
- constructor(message, status, code) {
11
- super(message)
12
- this.name = 'EasyflowError'
13
- this.status = status
14
- this.code = code
15
- }
16
- }
17
-
18
- /**
19
- * Erros de Segurança
20
- */
21
- export class SecurityError extends Error {
22
- constructor(message) {
23
- super(message)
24
- this.name = 'SecurityError'
25
- this.code = 'SECURITY_VIOLATION'
26
- }
27
- }
28
-
29
- export class ValidationError extends Error {
30
- constructor(message) {
31
- super(message)
32
- this.name = 'ValidationError'
33
- this.code = 'VALIDATION_ERROR'
34
- }
35
- }
36
-
37
- export class NetworkError extends Error {
38
- constructor(message) {
39
- super(message)
40
- this.name = 'NetworkError'
41
- this.code = 'NETWORK_ERROR'
42
- }
43
- }
44
-
45
- /**
46
- * Error codes for Easyflow SDK
47
- */
48
- export const ERROR_CODES = {
49
- VALIDATION_ERROR: 'VALIDATION_ERROR',
50
- MISSING_BUSINESS_ID: 'MISSING_BUSINESS_ID',
51
- OFFER_NOT_FOUND: 'OFFER_NOT_FOUND',
52
- ORDER_NOT_FOUND: 'ORDER_NOT_FOUND',
53
- INVALID_PAYMENT_METHOD: 'INVALID_PAYMENT_METHOD',
54
- MISSING_CREDIT_CARD_DATA: 'MISSING_CREDIT_CARD_DATA',
55
- PLACE_ORDER_FAILED: 'PLACE_ORDER_FAILED',
56
- CHARGE_FAILED: 'CHARGE_FAILED',
57
- ENCRYPTION_FAILED: 'ENCRYPTION_FAILED',
58
- NETWORK_ERROR: 'NETWORK_ERROR',
59
- INVALID_RESPONSE: 'INVALID_RESPONSE',
60
- GET_OFFER_FAILED: 'GET_OFFER_FAILED',
61
- GET_ORDER_FAILED: 'GET_ORDER_FAILED',
62
- }
@@ -1,178 +0,0 @@
1
- import { jest } from '@jest/globals'
2
- import {
3
- EasyflowError,
4
- SecurityError,
5
- ValidationError,
6
- NetworkError,
7
- ERROR_CODES,
8
- } from './errors.mjs'
9
-
10
- describe('Error Classes', () => {
11
- describe('EasyflowError', () => {
12
- test('should create EasyflowError with message, status, and code', () => {
13
- const error = new EasyflowError('Test error', 400, 'TEST_ERROR')
14
-
15
- expect(error.message).toBe('Test error')
16
- expect(error.status).toBe(400)
17
- expect(error.code).toBe('TEST_ERROR')
18
- expect(error.name).toBe('EasyflowError')
19
- expect(error).toBeInstanceOf(Error)
20
- })
21
-
22
- test('should create EasyflowError with only message', () => {
23
- const error = new EasyflowError('Test error')
24
-
25
- expect(error.message).toBe('Test error')
26
- expect(error.status).toBeUndefined()
27
- expect(error.code).toBeUndefined()
28
- expect(error.name).toBe('EasyflowError')
29
- })
30
-
31
- test('should be throwable', () => {
32
- expect(() => {
33
- throw new EasyflowError('Test error', 400, 'TEST_ERROR')
34
- }).toThrow(EasyflowError)
35
- })
36
- })
37
-
38
- describe('SecurityError', () => {
39
- test('should create SecurityError with message', () => {
40
- const error = new SecurityError('Security violation')
41
-
42
- expect(error.message).toBe('Security violation')
43
- expect(error.name).toBe('SecurityError')
44
- expect(error.code).toBe('SECURITY_VIOLATION')
45
- expect(error).toBeInstanceOf(Error)
46
- })
47
-
48
- test('should be throwable', () => {
49
- expect(() => {
50
- throw new SecurityError('Security violation')
51
- }).toThrow(SecurityError)
52
- })
53
-
54
- test('should have correct error code', () => {
55
- const error = new SecurityError('Test')
56
- expect(error.code).toBe('SECURITY_VIOLATION')
57
- })
58
- })
59
-
60
- describe('ValidationError', () => {
61
- test('should create ValidationError with message', () => {
62
- const error = new ValidationError('Validation failed')
63
-
64
- expect(error.message).toBe('Validation failed')
65
- expect(error.name).toBe('ValidationError')
66
- expect(error.code).toBe('VALIDATION_ERROR')
67
- expect(error).toBeInstanceOf(Error)
68
- })
69
-
70
- test('should be throwable', () => {
71
- expect(() => {
72
- throw new ValidationError('Validation failed')
73
- }).toThrow(ValidationError)
74
- })
75
-
76
- test('should have correct error code', () => {
77
- const error = new ValidationError('Test')
78
- expect(error.code).toBe('VALIDATION_ERROR')
79
- })
80
- })
81
-
82
- describe('NetworkError', () => {
83
- test('should create NetworkError with message', () => {
84
- const error = new NetworkError('Network timeout')
85
-
86
- expect(error.message).toBe('Network timeout')
87
- expect(error.name).toBe('NetworkError')
88
- expect(error.code).toBe('NETWORK_ERROR')
89
- expect(error).toBeInstanceOf(Error)
90
- })
91
-
92
- test('should be throwable', () => {
93
- expect(() => {
94
- throw new NetworkError('Network timeout')
95
- }).toThrow(NetworkError)
96
- })
97
-
98
- test('should have correct error code', () => {
99
- const error = new NetworkError('Test')
100
- expect(error.code).toBe('NETWORK_ERROR')
101
- })
102
- })
103
-
104
- describe('ERROR_CODES', () => {
105
- test('should contain all expected error codes', () => {
106
- expect(ERROR_CODES).toEqual({
107
- VALIDATION_ERROR: 'VALIDATION_ERROR',
108
- MISSING_BUSINESS_ID: 'MISSING_BUSINESS_ID',
109
- OFFER_NOT_FOUND: 'OFFER_NOT_FOUND',
110
- ORDER_NOT_FOUND: 'ORDER_NOT_FOUND',
111
- INVALID_PAYMENT_METHOD: 'INVALID_PAYMENT_METHOD',
112
- MISSING_CREDIT_CARD_DATA: 'MISSING_CREDIT_CARD_DATA',
113
- PLACE_ORDER_FAILED: 'PLACE_ORDER_FAILED',
114
- CHARGE_FAILED: 'CHARGE_FAILED',
115
- ENCRYPTION_FAILED: 'ENCRYPTION_FAILED',
116
- NETWORK_ERROR: 'NETWORK_ERROR',
117
- INVALID_RESPONSE: 'INVALID_RESPONSE',
118
- GET_OFFER_FAILED: 'GET_OFFER_FAILED',
119
- GET_ORDER_FAILED: 'GET_ORDER_FAILED',
120
- })
121
- })
122
-
123
- test('should have correct error code values', () => {
124
- expect(ERROR_CODES.VALIDATION_ERROR).toBe('VALIDATION_ERROR')
125
- expect(ERROR_CODES.NETWORK_ERROR).toBe('NETWORK_ERROR')
126
- expect(ERROR_CODES.MISSING_BUSINESS_ID).toBe('MISSING_BUSINESS_ID')
127
- expect(ERROR_CODES.OFFER_NOT_FOUND).toBe('OFFER_NOT_FOUND')
128
- expect(ERROR_CODES.ORDER_NOT_FOUND).toBe('ORDER_NOT_FOUND')
129
- expect(ERROR_CODES.INVALID_PAYMENT_METHOD).toBe(
130
- 'INVALID_PAYMENT_METHOD'
131
- )
132
- expect(ERROR_CODES.MISSING_CREDIT_CARD_DATA).toBe(
133
- 'MISSING_CREDIT_CARD_DATA'
134
- )
135
- expect(ERROR_CODES.PLACE_ORDER_FAILED).toBe('PLACE_ORDER_FAILED')
136
- expect(ERROR_CODES.CHARGE_FAILED).toBe('CHARGE_FAILED')
137
- expect(ERROR_CODES.ENCRYPTION_FAILED).toBe('ENCRYPTION_FAILED')
138
- expect(ERROR_CODES.INVALID_RESPONSE).toBe('INVALID_RESPONSE')
139
- expect(ERROR_CODES.GET_OFFER_FAILED).toBe('GET_OFFER_FAILED')
140
- expect(ERROR_CODES.GET_ORDER_FAILED).toBe('GET_ORDER_FAILED')
141
- })
142
- })
143
-
144
- describe('Error Inheritance', () => {
145
- test('all custom errors should inherit from Error', () => {
146
- expect(new EasyflowError()).toBeInstanceOf(Error)
147
- expect(new SecurityError()).toBeInstanceOf(Error)
148
- expect(new ValidationError()).toBeInstanceOf(Error)
149
- expect(new NetworkError()).toBeInstanceOf(Error)
150
- })
151
-
152
- test('SecurityError should not be instance of EasyflowError', () => {
153
- expect(new SecurityError()).not.toBeInstanceOf(EasyflowError)
154
- })
155
-
156
- test('ValidationError should not be instance of EasyflowError', () => {
157
- expect(new ValidationError()).not.toBeInstanceOf(EasyflowError)
158
- })
159
-
160
- test('NetworkError should not be instance of EasyflowError', () => {
161
- expect(new NetworkError()).not.toBeInstanceOf(EasyflowError)
162
- })
163
- })
164
-
165
- describe('Error Stack Traces', () => {
166
- test('should have stack traces', () => {
167
- const error = new EasyflowError('Test error')
168
- expect(error.stack).toBeDefined()
169
- expect(typeof error.stack).toBe('string')
170
- })
171
-
172
- test('should have stack traces for all error types', () => {
173
- expect(new SecurityError('Test').stack).toBeDefined()
174
- expect(new ValidationError('Test').stack).toBeDefined()
175
- expect(new NetworkError('Test').stack).toBeDefined()
176
- })
177
- })
178
- })
@@ -1,21 +0,0 @@
1
- /**
2
- * Exception handler utility for Easyflow SDK
3
- *
4
- * This module provides a centralized way to handle and throw errors
5
- * throughout the SDK.
6
- */
7
-
8
- /**
9
- * Throws an error - used for centralized error handling
10
- *
11
- * @param {Error} error - Error object to throw
12
- * @throws {Error} The provided error
13
- *
14
- * @example
15
- * ```javascript
16
- * throwsError(new ValidationError('Invalid input'));
17
- * ```
18
- */
19
- export const throwsError = (error) => {
20
- throw error
21
- }
@@ -1,237 +0,0 @@
1
- import { jest } from '@jest/globals'
2
- import { throwsError } from './exception-handler.mjs'
3
-
4
- describe('Exception Handler', () => {
5
- describe('throwsError', () => {
6
- test('should throw the provided error', () => {
7
- const testError = new Error('Test error message')
8
-
9
- expect(() => {
10
- throwsError(testError)
11
- }).toThrow(testError)
12
- })
13
-
14
- test('should throw custom error types', () => {
15
- const customError = {
16
- name: 'CustomError',
17
- message: 'Custom error message',
18
- code: 'CUSTOM_ERROR',
19
- }
20
-
21
- expect(() => {
22
- throwsError(customError)
23
- }).toThrow(customError)
24
- })
25
-
26
- test('should throw error with message', () => {
27
- const errorMessage = 'Network timeout error'
28
- const testError = new Error(errorMessage)
29
-
30
- expect(() => {
31
- throwsError(testError)
32
- }).toThrow(errorMessage)
33
- })
34
-
35
- test('should throw error with stack trace', () => {
36
- const testError = new Error('Test error')
37
-
38
- expect(() => {
39
- throwsError(testError)
40
- }).toThrow(testError)
41
-
42
- expect(testError.stack).toBeDefined()
43
- })
44
-
45
- test('should throw error with additional properties', () => {
46
- const testError = new Error('Test error')
47
- testError.statusCode = 500
48
- testError.customProperty = 'custom value'
49
-
50
- expect(() => {
51
- throwsError(testError)
52
- }).toThrow(testError)
53
-
54
- expect(testError.statusCode).toBe(500)
55
- expect(testError.customProperty).toBe('custom value')
56
- })
57
-
58
- test('should throw null error', () => {
59
- expect(() => {
60
- throwsError(null)
61
- }).toThrow()
62
- })
63
-
64
- test('should throw undefined error', () => {
65
- expect(() => {
66
- throwsError(undefined)
67
- }).toThrow()
68
- })
69
-
70
- test('should throw string as error', () => {
71
- const errorString = 'String error message'
72
-
73
- expect(() => {
74
- throwsError(errorString)
75
- }).toThrow(errorString)
76
- })
77
-
78
- test('should throw number as error', () => {
79
- const errorNumber = 404
80
-
81
- expect(() => {
82
- throwsError(errorNumber)
83
- }).toThrow()
84
- })
85
-
86
- test('should throw object as error', () => {
87
- const errorObject = {
88
- message: 'Object error message',
89
- code: 'OBJECT_ERROR',
90
- }
91
-
92
- expect(() => {
93
- throwsError(errorObject)
94
- }).toThrow()
95
- })
96
-
97
- test('should preserve error name', () => {
98
- const testError = new TypeError('Type error message')
99
-
100
- expect(() => {
101
- throwsError(testError)
102
- }).toThrow(TypeError)
103
- })
104
-
105
- test('should preserve error constructor', () => {
106
- const testError = new RangeError('Range error message')
107
-
108
- expect(() => {
109
- throwsError(testError)
110
- }).toThrow(RangeError)
111
- })
112
-
113
- test('should handle multiple consecutive throws', () => {
114
- const error1 = new Error('First error')
115
- const error2 = new Error('Second error')
116
-
117
- expect(() => {
118
- throwsError(error1)
119
- }).toThrow('First error')
120
-
121
- expect(() => {
122
- throwsError(error2)
123
- }).toThrow('Second error')
124
- })
125
-
126
- test('should handle async context', async () => {
127
- const testError = new Error('Async error')
128
-
129
- await expect(async () => {
130
- throwsError(testError)
131
- }).rejects.toThrow('Async error')
132
- })
133
-
134
- test('should handle promise rejection context', () => {
135
- const testError = new Error('Promise error')
136
-
137
- const promise = Promise.resolve().then(() => {
138
- throwsError(testError)
139
- })
140
-
141
- return expect(promise).rejects.toThrow('Promise error')
142
- })
143
-
144
- test('should handle error with circular references', () => {
145
- const testError = new Error('Circular error')
146
- testError.self = testError
147
-
148
- expect(() => {
149
- throwsError(testError)
150
- }).toThrow(testError)
151
- })
152
-
153
- test('should handle error with functions', () => {
154
- const testError = new Error('Function error')
155
- testError.handler = () => 'handler function'
156
-
157
- expect(() => {
158
- throwsError(testError)
159
- }).toThrow(testError)
160
-
161
- expect(typeof testError.handler).toBe('function')
162
- })
163
-
164
- test('should handle error with arrays', () => {
165
- const testError = new Error('Array error')
166
- testError.items = [1, 2, 3, 'test']
167
-
168
- expect(() => {
169
- throwsError(testError)
170
- }).toThrow(testError)
171
-
172
- expect(Array.isArray(testError.items)).toBe(true)
173
- })
174
-
175
- test('should handle error with nested objects', () => {
176
- const testError = new Error('Nested error')
177
- testError.details = {
178
- level1: {
179
- level2: {
180
- level3: 'deep value',
181
- },
182
- },
183
- }
184
-
185
- expect(() => {
186
- throwsError(testError)
187
- }).toThrow(testError)
188
-
189
- expect(testError.details.level1.level2.level3).toBe('deep value')
190
- })
191
-
192
- test('should handle error with symbols', () => {
193
- const testError = new Error('Symbol error')
194
- const symbol = Symbol('test')
195
- testError[symbol] = 'symbol value'
196
-
197
- expect(() => {
198
- throwsError(testError)
199
- }).toThrow(testError)
200
-
201
- expect(testError[symbol]).toBe('symbol value')
202
- })
203
-
204
- test('should handle error with getters and setters', () => {
205
- const testError = new Error('Getter/Setter error')
206
- Object.defineProperty(testError, 'computed', {
207
- get() {
208
- return 'computed value'
209
- },
210
- set(value) {
211
- this._computed = value
212
- },
213
- enumerable: true,
214
- })
215
-
216
- expect(() => {
217
- throwsError(testError)
218
- }).toThrow(testError)
219
-
220
- expect(testError.computed).toBe('computed value')
221
- })
222
-
223
- test('should handle error with non-enumerable properties', () => {
224
- const testError = new Error('Non-enumerable error')
225
- Object.defineProperty(testError, 'hidden', {
226
- value: 'hidden value',
227
- enumerable: false,
228
- })
229
-
230
- expect(() => {
231
- throwsError(testError)
232
- }).toThrow(testError)
233
-
234
- expect(testError.hidden).toBe('hidden value')
235
- })
236
- })
237
- })