diff --git a/examples/secure-component-styles/index.html b/examples/secure-component-styles/index.html
new file mode 100644
index 0000000..9e0cefc
--- /dev/null
+++ b/examples/secure-component-styles/index.html
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+ Secure component styles
+
+
+
+
+
+
+
+
+
+ Secure component styles
+
+
+
+
+
+
+
+
+
+
diff --git a/src/core/event-name.enum.ts b/src/core/event-name.enum.ts
index 8ff9ee1..1d19bfa 100644
--- a/src/core/event-name.enum.ts
+++ b/src/core/event-name.enum.ts
@@ -14,4 +14,5 @@ export const enum EventName {
financeDetails = 'financeDetails',
nextAction = 'nextAction',
warning = 'warning',
+ setSecureComponentStyles = 'setSecureComponentStyles',
}
diff --git a/src/features/headless-checkout/headless-checkout.spec.ts b/src/features/headless-checkout/headless-checkout.spec.ts
index 6ef246e..c7606ac 100644
--- a/src/features/headless-checkout/headless-checkout.spec.ts
+++ b/src/features/headless-checkout/headless-checkout.spec.ts
@@ -72,7 +72,7 @@ describe('HeadlessCheckout', () => {
const spy = spyOn(postMessagesClient, 'init');
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
- () => new MockIframeElement() as unknown as HTMLIFrameElement
+ () => new MockIframeElement() as unknown as HTMLIFrameElement,
);
await headlessCheckout.init({ isWebview: false });
@@ -82,7 +82,7 @@ describe('HeadlessCheckout', () => {
it('Should init localization', () => {
const localizeSpy = spyOn(
localizeService,
- 'initDictionaries'
+ 'initDictionaries',
).and.resolveTo();
void headlessCheckout.init({ isWebview: false });
@@ -101,7 +101,7 @@ describe('HeadlessCheckout', () => {
headlessCheckout.events.onCoreEvent(
EventName.initPayment,
mockHandler,
- stub
+ stub,
);
expect(spy).toHaveBeenCalled();
});
@@ -110,7 +110,7 @@ describe('HeadlessCheckout', () => {
const spy = spyOn(postMessagesClient, 'listen');
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
- () => new MockIframeElement() as unknown as HTMLIFrameElement
+ () => new MockIframeElement() as unknown as HTMLIFrameElement,
);
await headlessCheckout.init({ isWebview: false });
@@ -123,6 +123,12 @@ describe('HeadlessCheckout', () => {
expect(spy).toHaveBeenCalled();
});
+ it('Should set secure component styles', async () => {
+ const spy = spyOn(postMessagesClient, 'send');
+ await headlessCheckout.setSecureComponentStyles('styles');
+ expect(spy).toHaveBeenCalled();
+ });
+
it('Should throw exception if empty token', async () => {
try {
await headlessCheckout.setToken('');
@@ -136,7 +142,7 @@ describe('HeadlessCheckout', () => {
await headlessCheckout.getFinanceDetails();
expect(spy).toHaveBeenCalledWith(
{ name: EventName.financeDetails },
- getFinanceDetailsHandler
+ getFinanceDetailsHandler,
);
});
@@ -157,7 +163,7 @@ describe('HeadlessCheckout', () => {
spyOn(windowService.customElements, 'get').and.returnValue(undefined);
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
- () => new MockIframeElement() as unknown as HTMLIFrameElement
+ () => new MockIframeElement() as unknown as HTMLIFrameElement,
);
await headlessCheckout.init({ isWebview: false });
@@ -166,11 +172,11 @@ describe('HeadlessCheckout', () => {
it('Should web components not be redefined', async () => {
spyOn(windowService.customElements, 'get').and.returnValue(
- CustomElementMock
+ CustomElementMock,
);
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
- () => new MockIframeElement() as unknown as HTMLIFrameElement
+ () => new MockIframeElement() as unknown as HTMLIFrameElement,
);
const spy = spyOn(window.customElements, 'define');
diff --git a/src/features/headless-checkout/headless-checkout.ts b/src/features/headless-checkout/headless-checkout.ts
index fffc60e..a9d69e2 100644
--- a/src/features/headless-checkout/headless-checkout.ts
+++ b/src/features/headless-checkout/headless-checkout.ts
@@ -28,6 +28,7 @@ import { headlessCheckoutAppUrl } from './environment';
import { FinanceDetails } from '../../core/finance-details/finance-details.interface';
import { getFinanceDetailsHandler } from './post-messages-handlers/get-finance-details.handler';
import { FormStatus } from '../../core/status/form-status.enum';
+import { setSecureComponentStylesHandler } from './post-messages-handlers/set-secure-component-styles.handler';
@singleton()
export class HeadlessCheckout {
@@ -52,7 +53,7 @@ export class HeadlessCheckout {
onCoreEvent: (
eventName: EventName,
handler: Handler,
- callback: (value?: T) => void
+ callback: (value?: T) => void,
): (() => void) => {
return this.postMessagesClient.listen(eventName, handler, callback);
},
@@ -81,7 +82,7 @@ export class HeadlessCheckout {
}
this.formSpy.formWasInit = true;
this.formStatus = FormStatus.active;
- })
+ }),
) as Promise