@justifi/webcomponents 0.0.10 → 0.0.12

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 (44) hide show
  1. package/dist/cjs/{index-68222998.js → index-4f753ffd.js} +32 -1
  2. package/dist/cjs/index.cjs.js +0 -10
  3. package/dist/cjs/justifi-bank-account-form_4.cjs.entry.js +4352 -42
  4. package/dist/cjs/loader.cjs.js +4 -3
  5. package/dist/cjs/webcomponents.cjs.js +7 -3
  6. package/dist/collection/collection-manifest.json +4 -4
  7. package/dist/collection/components/bank-account-form/bank-account-form.js +43 -45
  8. package/dist/collection/components/card-form/card-form.js +66 -39
  9. package/dist/collection/components/payment-method-form/message-event-types.js +12 -0
  10. package/dist/collection/components/payment-method-form/payment-method-form.js +68 -73
  11. package/dist/collection/index.js +1 -3
  12. package/dist/components/index.d.ts +9 -0
  13. package/dist/components/index.js +4 -4
  14. package/dist/components/justifi-bank-account-form.js +17 -14
  15. package/dist/components/justifi-card-form.js +23 -11
  16. package/dist/components/justifi-payments-list.js +1 -1
  17. package/dist/components/payment-method-form.js +48 -39
  18. package/dist/esm/{index-e279d85e.js → index-3d88d85c.js} +32 -2
  19. package/dist/esm/index.js +1 -2
  20. package/dist/esm/justifi-bank-account-form_4.entry.js +4350 -40
  21. package/dist/esm/loader.js +4 -3
  22. package/dist/esm/polyfills/css-shim.js +1 -1
  23. package/dist/esm/webcomponents.js +4 -3
  24. package/dist/types/api/Api.d.ts +1 -1
  25. package/dist/types/api/Payment.d.ts +1 -1
  26. package/dist/types/components/bank-account-form/bank-account-form.d.ts +10 -5
  27. package/dist/types/components/card-form/card-form.d.ts +14 -3
  28. package/dist/types/components/payment-method-form/message-event-types.d.ts +12 -0
  29. package/dist/types/components/payment-method-form/payment-method-form.d.ts +5 -4
  30. package/dist/types/components.d.ts +13 -12
  31. package/dist/types/index.d.ts +1 -4
  32. package/dist/types/stencil-public-runtime.d.ts +48 -3
  33. package/dist/webcomponents/index.esm.js +0 -1
  34. package/dist/webcomponents/p-8ad58e9a.entry.js +1 -0
  35. package/dist/webcomponents/p-de108437.js +2 -0
  36. package/dist/webcomponents/webcomponents.esm.js +1 -1
  37. package/loader/index.d.ts +9 -0
  38. package/package.json +2 -3
  39. package/dist/cjs/payments-list-d2dfcef1.js +0 -4298
  40. package/dist/collection/components/card-form/card-form.css +0 -3
  41. package/dist/esm/payments-list-91eba70b.js +0 -4294
  42. package/dist/webcomponents/p-146348d6.js +0 -2
  43. package/dist/webcomponents/p-a688f9d3.entry.js +0 -1
  44. package/dist/webcomponents/p-c94a0f7f.js +0 -1
@@ -6,40 +6,43 @@ const BankAccountForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
6
6
  super();
7
7
  this.__registerHost();
8
8
  this.bankAccountFormReady = createEvent(this, "bankAccountFormReady", 7);
9
- this.bankAccountFormChange = createEvent(this, "bankAccountFormChange", 7);
10
- this.bankAccountFormBlur = createEvent(this, "bankAccountFormBlur", 7);
11
9
  this.bankAccountFormTokenize = createEvent(this, "bankAccountFormTokenize", 7);
12
- this.iframeOrigin = undefined;
10
+ this.bankAccountFormValidate = createEvent(this, "bankAccountFormValidate", 7);
11
+ this.validationStrategy = undefined;
13
12
  }
14
13
  readyHandler(event) {
15
14
  this.bankAccountFormReady.emit(event);
16
15
  }
17
- changeHandler(event) {
18
- this.bankAccountFormChange.emit(event);
19
- }
20
- blurHandler(event) {
21
- this.bankAccountFormBlur.emit(event);
22
- }
23
16
  tokenizeHandler(event) {
24
17
  this.bankAccountFormTokenize.emit(event);
25
18
  }
19
+ validateHandler(event) {
20
+ this.bankAccountFormValidate.emit(event);
21
+ }
26
22
  async tokenize(...args) {
27
23
  if (!this.childRef) {
28
24
  throw new Error('Cannot call tokenize');
29
25
  }
30
26
  return this.childRef.tokenize(...args);
31
27
  }
28
+ async validate() {
29
+ if (!this.childRef) {
30
+ throw new Error('Cannot call validate');
31
+ }
32
+ return this.childRef.validate();
33
+ }
32
34
  render() {
33
35
  return (h("justifi-payment-method-form", { ref: el => {
34
36
  if (el) {
35
37
  this.childRef = el;
36
38
  }
37
- }, "iframe-origin": this.iframeOrigin || 'https://js.justifi.ai/bank-account', "payment-method-form-ready": this.bankAccountFormReady, "payment-method-form-change": this.bankAccountFormChange, "payment-method-form-blur": this.bankAccountFormBlur, "payment-method-form-tokenize": this.bankAccountFormTokenize }));
39
+ }, "payment-method-form-type": "bankAccount", "payment-method-form-ready": this.bankAccountFormReady, "payment-method-form-tokenize": this.bankAccountFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit' }));
38
40
  }
39
41
  }, [0, "justifi-bank-account-form", {
40
- "iframeOrigin": [1, "iframe-origin"],
41
- "tokenize": [64]
42
- }, [[0, "paymentMethodFormReady", "readyHandler"], [0, "paymentMethodFormChange", "changeHandler"], [0, "paymentMethodFormBlur", "blurHandler"], [0, "paymentMethodFormTokenize", "tokenizeHandler"]]]);
42
+ "validationStrategy": [1, "validation-strategy"],
43
+ "tokenize": [64],
44
+ "validate": [64]
45
+ }, [[0, "paymentMethodFormReady", "readyHandler"], [0, "paymentMethodFormTokenize", "tokenizeHandler"], [0, "paymentMethodFormValidate", "validateHandler"]]]);
43
46
  function defineCustomElement$1() {
44
47
  if (typeof customElements === "undefined") {
45
48
  return;
@@ -62,4 +65,4 @@ function defineCustomElement$1() {
62
65
  const JustifiBankAccountForm = BankAccountForm;
63
66
  const defineCustomElement = defineCustomElement$1;
64
67
 
65
- export { BankAccountForm as B, JustifiBankAccountForm, defineCustomElement };
68
+ export { JustifiBankAccountForm, defineCustomElement };
@@ -1,17 +1,23 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { d as defineCustomElement$2 } from './payment-method-form.js';
3
3
 
4
- const cardFormCss = "justifi-card-form iframe{height:55px}";
5
-
6
4
  const CardForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
5
  constructor() {
8
6
  super();
9
7
  this.__registerHost();
10
8
  this.cardFormReady = createEvent(this, "cardFormReady", 7);
11
- this.cardFormChange = createEvent(this, "cardFormChange", 7);
12
- this.cardFormBlur = createEvent(this, "cardFormBlur", 7);
13
9
  this.cardFormTokenize = createEvent(this, "cardFormTokenize", 7);
14
- this.iframeOrigin = undefined;
10
+ this.cardFormValidate = createEvent(this, "cardFormValidate", 7);
11
+ this.validationStrategy = undefined;
12
+ }
13
+ readyHandler(event) {
14
+ this.cardFormReady.emit(event);
15
+ }
16
+ tokenizeHandler(event) {
17
+ this.cardFormTokenize.emit(event);
18
+ }
19
+ validateHandler(event) {
20
+ this.cardFormValidate.emit(event);
15
21
  }
16
22
  async tokenize(...args) {
17
23
  if (!this.childRef) {
@@ -19,18 +25,24 @@ const CardForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
19
25
  }
20
26
  return this.childRef.tokenize(...args);
21
27
  }
28
+ async validate() {
29
+ if (!this.childRef) {
30
+ throw new Error('Cannot call validate');
31
+ }
32
+ return this.childRef.validate();
33
+ }
22
34
  render() {
23
35
  return (h("justifi-payment-method-form", { ref: el => {
24
36
  if (el) {
25
37
  this.childRef = el;
26
38
  }
27
- }, "iframe-origin": this.iframeOrigin || 'https://js.justifi.ai/card', "payment-method-form-ready": this.cardFormReady, "payment-method-form-change": this.cardFormChange, "payment-method-form-blur": this.cardFormBlur, "payment-method-form-tokenize": this.cardFormTokenize }));
39
+ }, "payment-method-form-type": "card", "payment-method-form-ready": this.cardFormReady, "payment-method-form-tokenize": this.cardFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit' }));
28
40
  }
29
- static get style() { return cardFormCss; }
30
41
  }, [0, "justifi-card-form", {
31
- "iframeOrigin": [1, "iframe-origin"],
32
- "tokenize": [64]
33
- }]);
42
+ "validationStrategy": [1, "validation-strategy"],
43
+ "tokenize": [64],
44
+ "validate": [64]
45
+ }, [[0, "paymentMethodFormReady", "readyHandler"], [0, "paymentMethodFormTokenize", "tokenizeHandler"], [0, "paymentMethodFormValidate", "validateHandler"]]]);
34
46
  function defineCustomElement$1() {
35
47
  if (typeof customElements === "undefined") {
36
48
  return;
@@ -53,4 +65,4 @@ function defineCustomElement$1() {
53
65
  const JustifiCardForm = CardForm;
54
66
  const defineCustomElement = defineCustomElement$1;
55
67
 
56
- export { CardForm as C, JustifiCardForm, defineCustomElement };
68
+ export { JustifiCardForm, defineCustomElement };
@@ -4250,4 +4250,4 @@ function defineCustomElement$1() {
4250
4250
  const JustifiPaymentsList = PaymentsList;
4251
4251
  const defineCustomElement = defineCustomElement$1;
4252
4252
 
4253
- export { JustifiPaymentsList, PaymentsList as P, defineCustomElement };
4253
+ export { JustifiPaymentsList, defineCustomElement };
@@ -1,23 +1,28 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
 
3
+ const MessageEventType = {
4
+ card: {
5
+ ready: 'justifi.card.ready',
6
+ tokenize: 'justifi.card.tokenize',
7
+ validate: 'justifi.card.validate',
8
+ },
9
+ bankAccount: {
10
+ ready: 'justifi.bank_account.ready',
11
+ tokenize: 'justifi.bank_account.tokenize',
12
+ validate: 'justifi.bank_account.validate',
13
+ }
14
+ };
15
+
3
16
  const paymentMethodFormCss = ":host{display:block}justifi-payment-method-form iframe{border:none;width:100%}";
4
17
 
5
- var DispatchedEventTypes;
6
- (function (DispatchedEventTypes) {
7
- DispatchedEventTypes["blur"] = "blur";
8
- DispatchedEventTypes["change"] = "change";
9
- DispatchedEventTypes["ready"] = "ready";
10
- DispatchedEventTypes["tokenize"] = "tokenize";
11
- })(DispatchedEventTypes || (DispatchedEventTypes = {}));
12
18
  const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
13
19
  constructor() {
14
20
  super();
15
21
  this.__registerHost();
16
22
  this.paymentMethodFormReady = createEvent(this, "paymentMethodFormReady", 7);
17
- this.paymentMethodFormChange = createEvent(this, "paymentMethodFormChange", 7);
18
- this.paymentMethodFormBlur = createEvent(this, "paymentMethodFormBlur", 7);
19
23
  this.paymentMethodFormTokenize = createEvent(this, "paymentMethodFormTokenize", 7);
20
- this.iframeOrigin = undefined;
24
+ this.paymentMethodFormType = undefined;
25
+ this.paymentMethodFormValidationStrategy = undefined;
21
26
  }
22
27
  connectedCallback() {
23
28
  window.addEventListener('message', this.dispatchMessageEvent.bind(this));
@@ -29,48 +34,52 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
29
34
  const messagePayload = messageEvent.data;
30
35
  const messageType = messagePayload.eventType;
31
36
  const messageData = messagePayload.data;
32
- switch (messageType) {
33
- case DispatchedEventTypes.ready:
34
- this.paymentMethodFormReady.emit(messageData);
35
- break;
36
- case DispatchedEventTypes.change:
37
- this.paymentMethodFormChange.emit(messageData);
38
- break;
39
- case DispatchedEventTypes.blur:
40
- this.paymentMethodFormBlur.emit(messageData);
41
- break;
42
- }
43
- }
44
- triggerTokenization(clientKey, paymentMethodMetadata, account) {
45
- if (this.iframeElement && this.iframeElement.contentWindow) {
46
- this.iframeElement.contentWindow.postMessage({
47
- eventType: DispatchedEventTypes.tokenize,
48
- clientKey: clientKey,
49
- paymentMethodMetadata: paymentMethodMetadata,
50
- account: account
51
- }, '*');
37
+ if (messageType === MessageEventType[this.paymentMethodFormType].ready) {
38
+ this.paymentMethodFormReady.emit(messageData);
52
39
  }
53
40
  }
54
- async tokenize(clientKey, paymentMethodMetadata, account) {
41
+ async postMessageWithResponseListener(eventType, payload) {
55
42
  return new Promise((resolve) => {
56
- const tokenizeEventListener = (event) => {
57
- if (event.data.eventType !== DispatchedEventTypes.tokenize)
43
+ const responseListener = (event) => {
44
+ if (event.data.eventType !== eventType)
58
45
  return;
59
- window.removeEventListener('message', tokenizeEventListener);
46
+ window.removeEventListener('message', responseListener);
60
47
  resolve(event.data.data);
61
48
  };
62
- window.addEventListener('message', tokenizeEventListener);
63
- this.triggerTokenization(clientKey, paymentMethodMetadata, account);
49
+ window.addEventListener('message', responseListener);
50
+ this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
64
51
  });
65
52
  }
53
+ async tokenize(clientKey, paymentMethodMetadata, account) {
54
+ const eventType = MessageEventType[this.paymentMethodFormType].tokenize;
55
+ const payload = {
56
+ clientKey: clientKey,
57
+ paymentMethodMetadata: paymentMethodMetadata,
58
+ account: account
59
+ };
60
+ return this.postMessageWithResponseListener(eventType, payload);
61
+ }
62
+ ;
63
+ async validate() {
64
+ return this.postMessageWithResponseListener(MessageEventType[this.paymentMethodFormType].validate);
65
+ }
66
66
  ;
67
+ getIframeSrc() {
68
+ let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
69
+ if (this.paymentMethodFormValidationStrategy) {
70
+ iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
71
+ }
72
+ return iframeSrc;
73
+ }
67
74
  render() {
68
- return (h(Host, null, h("iframe", { id: "justifi-payment-method-form", src: this.iframeOrigin, ref: (el) => this.iframeElement = el })));
75
+ return (h(Host, null, h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el })));
69
76
  }
70
77
  static get style() { return paymentMethodFormCss; }
71
78
  }, [0, "justifi-payment-method-form", {
72
- "iframeOrigin": [1, "iframe-origin"],
73
- "tokenize": [64]
79
+ "paymentMethodFormType": [1, "payment-method-form-type"],
80
+ "paymentMethodFormValidationStrategy": [1, "payment-method-form-validation-strategy"],
81
+ "tokenize": [64],
82
+ "validate": [64]
74
83
  }]);
75
84
  function defineCustomElement() {
76
85
  if (typeof customElements === "undefined") {
@@ -41,6 +41,18 @@ const isComplexType = (o) => {
41
41
  o = typeof o;
42
42
  return o === 'object' || o === 'function';
43
43
  };
44
+ /**
45
+ * Helper method for querying a `meta` tag that contains a nonce value
46
+ * out of a DOM's head.
47
+ *
48
+ * @param doc The DOM containing the `head` to query against
49
+ * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
50
+ * exists or the tag has no content.
51
+ */
52
+ function queryNonceMetaTagContent(doc) {
53
+ var _a, _b, _c;
54
+ return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
55
+ }
44
56
  /**
45
57
  * Production h() function based on Preact by
46
58
  * Jason Miller (@developit)
@@ -49,7 +61,6 @@ const isComplexType = (o) => {
49
61
  *
50
62
  * Modified for Stencil's compiler and vdom
51
63
  */
52
- // const stack: any[] = [];
53
64
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
54
65
  // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
55
66
  const h = (nodeName, vnodeData, ...children) => {
@@ -197,6 +208,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
197
208
  styles.set(scopeId, style);
198
209
  };
199
210
  const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
211
+ var _a;
200
212
  let scopeId = getScopeId(cmpMeta);
201
213
  const style = styles.get(scopeId);
202
214
  // if an element is NOT connected then getRootNode() will return the wrong root node
@@ -216,6 +228,11 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
216
228
  styleElm = doc.createElement('style');
217
229
  styleElm.innerHTML = style;
218
230
  }
231
+ // Apply CSP nonce to the style tag if it exists
232
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
233
+ if (nonce != null) {
234
+ styleElm.setAttribute('nonce', nonce);
235
+ }
219
236
  styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
220
237
  }
221
238
  if (appliedStyles) {
@@ -1136,6 +1153,7 @@ const disconnectedCallback = (elm) => {
1136
1153
  }
1137
1154
  };
1138
1155
  const bootstrapLazy = (lazyBundles, options = {}) => {
1156
+ var _a;
1139
1157
  const endBootstrap = createTime();
1140
1158
  const cmpTags = [];
1141
1159
  const exclude = options.exclude || [];
@@ -1215,6 +1233,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1215
1233
  {
1216
1234
  visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
1217
1235
  visibilityStyle.setAttribute('data-styles', '');
1236
+ // Apply CSP nonce to the style tag if it exists
1237
+ const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
1238
+ if (nonce != null) {
1239
+ visibilityStyle.setAttribute('nonce', nonce);
1240
+ }
1218
1241
  head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
1219
1242
  }
1220
1243
  // Process deferred connectedCallbacks now all components have been registered
@@ -1259,6 +1282,13 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
1259
1282
  };
1260
1283
  // prettier-ignore
1261
1284
  const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
1285
+ /**
1286
+ * Assigns the given value to the nonce property on the runtime platform object.
1287
+ * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
1288
+ * @param nonce The value to be assigned to the platform nonce property.
1289
+ * @returns void
1290
+ */
1291
+ const setNonce = (nonce) => (plt.$nonce$ = nonce);
1262
1292
  const hostRefs = /*@__PURE__*/ new WeakMap();
1263
1293
  const getHostRef = (ref) => hostRefs.get(ref);
1264
1294
  const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
@@ -1369,4 +1399,4 @@ const flush = () => {
1369
1399
  const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1370
1400
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1371
1401
 
1372
- export { Host as H, bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r };
1402
+ export { Host as H, bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r, setNonce as s };
package/dist/esm/index.js CHANGED
@@ -1,2 +1 @@
1
- export { B as BankAccountForm, C as CardForm, P as PaymentsList } from './payments-list-91eba70b.js';
2
- import './index-e279d85e.js';
1
+