@pay-com/js 1.1.3 → 1.1.4

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/lib/index.d.ts CHANGED
@@ -1,395 +1,21 @@
1
- import EventEmitter from 'events';
2
- import * as CSS from 'csstype';
1
+ import * as types from 'types';
2
+ export * from 'types';
3
3
 
4
4
  interface PayComScriptQueryParameters {
5
- identifier: string;
6
- sandbox?: boolean;
7
- debug?: boolean;
8
- }
9
-
10
- interface PayComScriptOptions extends PayComScriptQueryParameters {
11
- sdkBaseURL?: string;
12
- }
13
-
14
- type PayCustomPseudos = ':error'
15
-
16
- type PayCssConfig = Partial<
17
- Record<CSS.SimplePseudos | PayCustomPseudos, CSS.Properties>
18
- > &
19
- CSS.Properties
20
- interface CheckoutStyles {
21
- base?: PayCssConfig
22
- number?: PayCssConfig
23
- cvv?: PayCssConfig
24
- expiry?: PayCssConfig
25
- name?: PayCssConfig
26
- checkboxes?: {
27
- buttonBackground?: string
28
- labelColor?: string
29
- }
30
- submit?: PayCssConfig
31
- }
32
-
33
- interface CheckoutFieldConfig {
34
- label?: string
35
- labelStyle?: PayCssConfig
36
- errorMessageStyle?: PayCssConfig
37
- inputSize?: 'small' | 'medium' | 'large'
38
- placeholder?: string
39
- style?: PayCssConfig
40
- }
41
-
42
- interface CheckoutFormConfig {
43
- base?: {
44
- inputSpacing?: string
45
- formTitle?: string
46
- titleStyles?: PayCssConfig
47
- style?: PayCssConfig
48
- }
49
- number?: CheckoutFieldConfig
50
- cvv?: CheckoutFieldConfig
51
- expiry?: CheckoutFieldConfig
52
- name?: CheckoutFieldConfig
53
- }
54
-
55
- interface CheckoutToggles {
56
- /**
57
- * If false, the form will render without a submission button.
58
- * @default true
59
- */
60
- submitButton?: boolean
61
- /**
62
- * If false, the form will render without a title.
63
- * @default true
64
- */
65
- withTitle?: boolean
66
- /**
67
- * If false, the form will render without a card holder name.
68
- * @default true
69
- */
70
- withCardHolderName?: boolean
71
- /**
72
- * If false, the wrapping element of the form will be a div instead of a form.
73
- * Good for when the form is embedded inside a larger form.
74
- * @default true
75
- */
76
- formWrapper?: boolean
77
- /**
78
- * If true, will display save for future use checkbox under the form.
79
- * @default false
80
- */
81
- saveSourceForFutureUseCheckbox?: boolean
82
- /**
83
- * If true, will display our accept T&A checkbox under the form.
84
- * @default false
85
- */
86
- acceptTermsAndConditionsCheckbox?: boolean
87
- /**
88
- * If true, will render native browser checkboxes instead of ours.
89
- * @default false
90
- */
91
- nativeCheckboxes?: boolean
92
- }
93
-
94
- interface PaypalOpts {
95
- container: string
96
- onClickValidation: () => Promise<boolean>
97
- }
98
-
99
- interface RenderOpts {
100
- container: string
101
- button?: boolean
102
- toggles?: CheckoutToggles
103
- formConfig?: CheckoutFormConfig
104
- localizations?: {
105
- [language: string]: LanguageLocalizationOverride
106
- }
107
- style?: CheckoutStyles
108
- }
109
-
110
- interface UniversalToggles {
111
- /**
112
- * If false, the form will render without a submission button.
113
- * @default true
114
- */
115
- submitButton?: boolean
116
-
117
- /**
118
- * If true, displays the card bin as well as last 4.
119
- * @default false
120
- */
121
- savedCardsBins?: boolean | 2 | 3 | 4 | 5 | 6
122
-
123
- /**
124
- * If true, the CVV in saved payment method will be inline
125
- * @default false
126
- */
127
- savedPaymentMethodInlineCvv?: boolean
128
-
129
- /**
130
- * A title to display above the Universal form.
131
- */
132
- title?: string
133
- }
134
-
135
- type LanguageLocalizationOverride = {
136
- cardForm?: {
137
- nameOnCard?: string
138
- cardNumber?: string
139
- cvv?: string
140
- expiryDate?: string
141
- title?: string
142
- checkboxes?: {
143
- saveCardForFutureUse?: string
144
- agreeToTermsAndConditions?: string
145
- }
146
- submit?: {
147
- pay?: string
148
- save_card?: string
149
- DEPOSIT?: string
150
- }
151
- }
152
- existingSource?: {
153
- delete?: string
154
- }
155
- dividers?: {
156
- myPaymentMethods?: string
157
- otherPaymentMethods?: string
158
- showOtherWaysToPay?: string
159
- payWithCard?: string
160
- payWith?: string
161
- savedPaymentMethods?: string
162
- }
163
- }
164
-
165
- interface DividerStyle {
166
- text: PayCssConfig
167
- divider: {
168
- color: PayCssConfig['color']
169
- height: PayCssConfig['height']
170
- }
171
- }
172
-
173
- interface UniversalOpts {
174
- container: string
175
- cardForm?: Omit<RenderOpts, 'container' | 'style'>
176
- toggles?: UniversalToggles
177
- apmsOnClickValidation?: () => Promise<boolean>
178
- localizations?: {
179
- [language: string]: LanguageLocalizationOverride
180
- }
181
- style?: {
182
- cardForm?: CheckoutStyles
183
- base?: PayCssConfig
184
- submit?: PayCssConfig
185
- savedPaymentMethods?: PayCssConfig
186
- expressCheckout?: PayCssConfig
187
- apmButtons?: PayCssConfig
188
- dividers?: {
189
- showOtherWaysToPay?: DividerStyle
190
- payWith?: DividerStyle
191
- savedPaymentMethods?: DividerStyle
192
- }
193
- existingSource?: {
194
- deleteText?: PayCssConfig
195
- cvv?: {
196
- style?: PayCssConfig
197
- labelStyle?: PayCssConfig
198
- errorMessageStyle?: PayCssConfig
199
- }
200
- icons?: {
201
- delete?: PayCssConfig
202
- confirmDeletion?: PayCssConfig
203
- cancelDeletion?: PayCssConfig
204
- }
205
- base?: PayCssConfig & { ':selected'?: PayCssConfig }
206
- radioButton?: {
207
- color?: PayCssConfig['color']
208
- ':selected'?: {
209
- color?: PayCssConfig['color']
210
- }
211
- }
212
- }
213
- }
214
- paymentMethods?: Array<string>
215
- }
216
-
217
- interface SubmitOpts {
218
- token?: string
219
- }
220
-
221
- type FailureError = {
222
- message: string
223
- data?: Record<string, unknown>
224
- }
225
-
226
- interface CheckoutOpts {
227
- /**
228
- * @deprecated Got replaced by clientSecret
229
- */
230
- token?: string | (() => Promise<string>)
231
- clientSecret?: string | (() => Promise<string>)
232
- currency?: string
233
- onSuccess?: (payment: Record<string, unknown>) => void
234
- onFailure?: (error: FailureError) => void
235
- mode?: modeOpts
236
- throwOnSubmitFailure?: boolean
237
- paymentFailurePopupConfig?: {
238
- sessionExpiredPopupText?: string
239
- maxAttemptsReachedPopupText?: string
240
- style?: PayCssConfig
241
- }
242
- toggles?: {
243
- displayFailureMessages: boolean
244
- displayEndOfSessionFailureMessages?: boolean
245
- disableAdditionalFields?: boolean
246
- }
247
- }
248
-
249
- interface PayComOpts {
250
- identifier?: string
251
- riskIdentifier?: string
5
+ identifier: string
252
6
  sandbox?: boolean
253
7
  debug?: boolean
254
8
  }
255
9
 
256
- enum EVENT_TYPES {
257
- THREE_DS_INIT = 'three_ds_init',
258
- THREE_DS_CHALLENGE = 'three_ds_challenge',
259
- THREE_DS_DONE = 'three_ds_done',
260
- CONTENT_READY = 'content_ready',
261
- PAYMENT_SUCCESS = 'payment_success',
262
- SETUP_SUCCESS = 'setup_success',
263
- PAYMENT_FAILURE = 'payment_failure',
264
- SETUP_FAILURE = 'setup_failure',
265
- PAYMENT_PROCESSING = 'payment_processing',
266
- SETUP_PROCESSING = 'setup_processing',
267
- SESSION_EXPIRED = 'session_expired',
268
- MAX_ATTEMPTS_REACHED = 'max_attempts_reached'
269
- }
270
-
271
- type ListenerFn = (
272
- eventName: EVENT_TYPES,
273
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
274
- callback: (...params: any[]) => void
275
- ) => EventEmitter
276
-
277
- enum ELEMENT_TYPES {
278
- CHECKOUT = 'checkout',
279
- UNIVERSAL = 'universal',
280
- PAYPAL = 'paypal'
281
- }
282
-
283
- type FormattedErrors = {
284
- valid: boolean
285
- invalidFields: string[]
286
- }
287
- type RenderFn = (renderOpts: RenderOpts) => Promise<void>
288
- type PaypalFn = (paypalOpts: PaypalOpts) => Promise<void>
289
- type UniversalFn = (universalOpts: UniversalOpts) => Promise<void>
290
- type SubmitFn = (
291
- opts?: SubmitOpts,
292
- frameType?: ELEMENT_TYPES
293
- ) => Promise<void | Record<string, unknown>>
294
-
295
- interface UpdateOpts {
296
- amount: number
297
- currency?: string
298
- }
299
- type UpdateFn = (updateOpts: UpdateOpts) => Promise<void>
300
-
301
- type ValidateFn = (frameType?: ELEMENT_TYPES) => Promise<FormattedErrors | void>
302
- type ResetFn = (frameType?: ELEMENT_TYPES) => Promise<void>
303
-
304
- type UpdateTransactionDetailsOpts = {
305
- successUrl?: string
306
- failureUrl?: string
307
- consumer?: {
308
- firstName?: string
309
- lastName?: string
310
- email?: string
311
- phone?: string
312
- }
313
- billing?: {
314
- addressLine: string
315
- addressLine2?: string
316
- zip: string
317
- city: string
318
- state?: string
319
- countryAlpha2: string
320
- }
321
- shipping?: {
322
- addressLine: string
323
- addressLine2?: string
324
- zip: string
325
- city: string
326
- state?: string
327
- countryAlpha2: string
328
- }
329
- }
330
-
331
- type PayOpts = {
332
- source: string
333
- }
334
-
335
- type PayFn = (Opts: PayOpts) => Promise<unknown>
336
-
337
- type UpdateTransactionDetailsFn = (
338
- config: UpdateTransactionDetailsOpts
339
- ) => Promise<unknown>
340
-
341
- type CheckoutObject = {
342
- on: ListenerFn
343
- once: ListenerFn
344
- removeListener: ListenerFn
345
- EVENT_TYPES: typeof EVENT_TYPES
346
- render: RenderFn
347
- paypal: PaypalFn
348
- universal: UniversalFn
349
- update: UpdateFn
350
- updateTransactionDetails: UpdateTransactionDetailsFn
351
- submit: SubmitFn
352
- validate: ValidateFn
353
- reset: ResetFn
354
- pay: PayFn
355
- }
356
-
357
- type CheckoutFunction = (opts: CheckoutOpts) => CheckoutObject
358
-
359
- type PayComFunction = (opts: PayComOpts) => Promise<{
360
- checkout: CheckoutFunction
361
- }>
362
-
363
- interface PayComNamespace {
364
- com: PayComFunction
365
- riskIdentifier: string
366
- }
367
-
368
- declare module '@pay-com/js' {
369
- export function loadScript(
370
- options: PayComScriptOptions,
371
- PromisePonyfill?: PromiseConstructor
372
- ): Promise<PayComNamespace | null>
373
-
374
- export function loadCustomScript(options: {
375
- url: string
376
- attributes?: Record<string, string>
377
- PromisePonyfill?: PromiseConstructor
378
- }): Promise<void>
379
-
380
- export const version: string
381
- }
382
-
383
- declare global {
384
- interface Window {
385
- Pay?: PayComNamespace
386
- }
10
+ interface PayComScriptOptions extends PayComScriptQueryParameters {
11
+ sdkUrlOverride?: string
12
+ live?: boolean
387
13
  }
388
14
 
389
15
  declare const _default: {
390
16
  com: (options: PayComScriptOptions, PromisePonyfill?: PromiseConstructor) => Promise<{
391
- checkout: CheckoutFunction;
17
+ checkout: types.CheckoutFunction;
392
18
  }>;
393
19
  };
394
20
 
395
- export { CheckoutFunction, CheckoutObject, CheckoutToggles, EVENT_TYPES, ListenerFn, PayComFunction, PayComNamespace, PaypalOpts, RenderOpts, SubmitOpts, UniversalOpts, UpdateTransactionDetailsOpts, _default as default };
21
+ export { _default as default };
package/lib/index.esm.js CHANGED
@@ -1 +1 @@
1
- function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}a((r=r.apply(e,t||[])).next())}))}function t(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function n(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function r(e,t){if(i(e,t),"undefined"==typeof window)return t.resolve(null);var r=e.sdkBaseURL,u="",c=window.location.hostname;u=r||(["localhost","dev","staging"].some((function(e){return window.location.hostname.includes(e)}))?"https://js.dev.pay.com/v1.js":c.includes(".sandbox.")?"https://js.sandbox.pay.com/v1.js":"https://js.pay.com/v1.js");var a="Pay",s=o(a);return function(e,t){var r=document.querySelector('script[src="'.concat(e,'"]'));if(null===r)return null;var o=n(e,t),i=Object.assign({},r.dataset);if(delete i.uidAuto,Object.keys(i).length!==Object.keys(o.dataset).length)return null;var u=!0;return Object.keys(i).forEach((function(e){i[e]!==o.dataset[e]&&(u=!1)})),u?r:null}(u)&&s?t.resolve(s):function(e,t){i(e,t);var r=e.url,o=e.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new t((function(e,t){return"undefined"==typeof window?e():function(e){var t=e.url,r=e.attributes,o=e.onSuccess,i=e.onError,u=n(t,r);u.onerror=i,u.onload=o,document.head.insertBefore(u,document.head.firstElementChild)}({url:r,attributes:o,onSuccess:function(){return e()},onError:function(){return t(new Error('The script "'.concat(r,'" failed to load.')))}})}))}({url:u},t).then((function(){var e=o(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function o(e){return window[e]}function i(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}"function"==typeof SuppressedError&&SuppressedError;var u={com:function(n,o){return void 0===o&&(o=function(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}()),e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,r(n,o)];case 1:if(!(e=t.sent()))throw new Error("Wrong script URL provided");return[2,e.com(n)]}}))}))}};export{u as default};
1
+ export*from"types";var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t,r,n){return new(r||(r=Promise))((function(o,i){function u(e){try{a(n.next(e))}catch(e){i(e)}}function c(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(u,c)}a((n=n.apply(e,t||[])).next())}))}function r(e,t){var r,n,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,n=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function n(e,t){void 0===t&&(t={});var r=document.createElement("script");return r.src=e,Object.keys(t).forEach((function(e){r.setAttribute(e,t[e]),"data-csp-nonce"===e&&r.setAttribute("nonce",t["data-csp-nonce"])})),r}function o(t,r){if(u(t,r),"undefined"==typeof window)return r.resolve(null);var o=t.live,c=t.sdkUrlOverride,a=o?"https://js.pay.com/v1.js":"https://js.staging.pay.com/v1.js";c&&(a=c);var l="Pay",s=i(l);return function(t,r){var o=document.querySelector('script[src="'.concat(t,'"]'));if(null===o)return null;var i=n(t,r),u=e({},o.dataset);if(delete u.uidAuto,Object.keys(u).length!==Object.keys(i.dataset).length)return null;var c=!0;return Object.keys(u).forEach((function(e){u[e]!==i.dataset[e]&&(c=!1)})),c?o:null}(a)&&s?r.resolve(s):function(e,t){u(e,t);var r=e.url,o=e.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new t((function(e,t){return"undefined"==typeof window?e():function(e){var t=e.url,r=e.attributes,o=e.onSuccess,i=e.onError,u=n(t,r);u.onerror=i,u.onload=o,document.head.insertBefore(u,document.head.firstElementChild)}({url:r,attributes:o,onSuccess:function(){return e()},onError:function(){return t(new Error('The script "'.concat(r,'" failed to load.')))}})}))}({url:a},r).then((function(){var e=i(l);if(e)return e;throw new Error("The window.".concat(l," global variable is not available."))}))}function i(e){return window[e]}function u(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}"function"==typeof SuppressedError&&SuppressedError;var c={com:function(e,n){return void 0===n&&(n=function(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}()),t(void 0,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,o(e,n)];case 1:if(!(t=r.sent()))throw new Error("Wrong script URL provided");return[2,t.com(e)]}}))}))}};export{c as default};
package/lib/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Pay=t()}(this,(function(){"use strict";function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}a((r=r.apply(e,t||[])).next())}))}function t(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function n(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function r(e,t){if(i(e,t),"undefined"==typeof window)return t.resolve(null);var r=e.sdkBaseURL,u="",c=window.location.hostname;u=r||(["localhost","dev","staging"].some((function(e){return window.location.hostname.includes(e)}))?"https://js.dev.pay.com/v1.js":c.includes(".sandbox.")?"https://js.sandbox.pay.com/v1.js":"https://js.pay.com/v1.js");var a="Pay",s=o(a);return function(e,t){var r=document.querySelector('script[src="'.concat(e,'"]'));if(null===r)return null;var o=n(e,t),i=Object.assign({},r.dataset);if(delete i.uidAuto,Object.keys(i).length!==Object.keys(o.dataset).length)return null;var u=!0;return Object.keys(i).forEach((function(e){i[e]!==o.dataset[e]&&(u=!1)})),u?r:null}(u)&&s?t.resolve(s):function(e,t){i(e,t);var r=e.url,o=e.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new t((function(e,t){return"undefined"==typeof window?e():function(e){var t=e.url,r=e.attributes,o=e.onSuccess,i=e.onError,u=n(t,r);u.onerror=i,u.onload=o,document.head.insertBefore(u,document.head.firstElementChild)}({url:r,attributes:o,onSuccess:function(){return e()},onError:function(){return t(new Error('The script "'.concat(r,'" failed to load.')))}})}))}({url:u},t).then((function(){var e=o(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function o(e){return window[e]}function i(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}"function"==typeof SuppressedError&&SuppressedError;return{com:function(n,o){return void 0===o&&(o=function(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}()),e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,r(n,o)];case 1:if(!(e=t.sent()))throw new Error("Wrong script URL provided");return[2,e.com(n)]}}))}))}}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("types")):"function"==typeof define&&define.amd?define(["exports","types"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Pay={},e.types)}(this,(function(e,t){"use strict";var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};function r(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function c(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}a((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function i(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function u(e,t){if(a(e,t),"undefined"==typeof window)return t.resolve(null);var r=e.live,o=e.sdkUrlOverride,u=r?"https://js.pay.com/v1.js":"https://js.staging.pay.com/v1.js";o&&(u=o);var f="Pay",s=c(f);return function(e,t){var r=document.querySelector('script[src="'.concat(e,'"]'));if(null===r)return null;var o=i(e,t),u=n({},r.dataset);if(delete u.uidAuto,Object.keys(u).length!==Object.keys(o.dataset).length)return null;var c=!0;return Object.keys(u).forEach((function(e){u[e]!==o.dataset[e]&&(c=!1)})),c?r:null}(u)&&s?t.resolve(s):function(e,t){a(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t((function(e,t){return"undefined"==typeof window?e():function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,u=i(t,n);u.onerror=o,u.onload=r,document.head.insertBefore(u,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){return t(new Error('The script "'.concat(n,'" failed to load.')))}})}))}({url:u},t).then((function(){var e=c(f);if(e)return e;throw new Error("The window.".concat(f," global variable is not available."))}))}function c(e){return window[e]}function a(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}"function"==typeof SuppressedError&&SuppressedError;var f={com:function(e,t){return void 0===t&&(t=function(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}()),r(void 0,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return[4,u(e,t)];case 1:if(!(n=r.sent()))throw new Error("Wrong script URL provided");return[2,n.com(e)]}}))}))}};e.default=f,Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pay-com/js",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "payments"
@@ -11,6 +11,7 @@
11
11
  "module": "lib/index.esm.js",
12
12
  "types": "lib/index.d.ts",
13
13
  "publishConfig": {
14
+ "access": "public",
14
15
  "registry": "https://registry.npmjs.org/"
15
16
  },
16
17
  "repository": {
@@ -25,13 +26,23 @@
25
26
  "build:watch": "rollup -c --watch",
26
27
  "build": "rollup -c",
27
28
  "prepublishOnly": "npm run build",
28
- "prepublish": "npm run build"
29
+ "prepare": "husky install"
30
+ },
31
+ "lint-staged": {
32
+ "**/*.{js,ts}": "eslint . --cache --fix --ignore-path '.eslintignore' --max-warnings 0",
33
+ "**/*.{js,ts,md}": "prettier --write"
29
34
  },
30
35
  "devDependencies": {
36
+ "@pay-com/eslint-config-react": "^2.0.3",
31
37
  "@rollup/plugin-commonjs": "^21.0.0",
32
38
  "@rollup/plugin-node-resolve": "^13.0.5",
33
39
  "csstype": "^3.0.9",
40
+ "eslint": "^8.46.0",
41
+ "eslint-plugin-prettier": "^5.0.0",
34
42
  "events": "^3.3.0",
43
+ "husky": "^8.0.0",
44
+ "lint-staged": "^13.2.3",
45
+ "prettier": "^3.0.0",
35
46
  "rollup": "^2.70.1",
36
47
  "rollup-plugin-copy": "^3.4.0",
37
48
  "rollup-plugin-dts": "^4.0.0",