MCPcopy Create free account
hub / github.com/ampproject/amphtml / validateSecureContext

Function validateSecureContext

third_party/subscriptions-project/swg.js:16038–16051  ·  view source on GitHub ↗

* Validate if is secure context. Returns null if context is secure, otherwise * return error message. * * See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts * * @return {?string} null if current context is secure, otherwise return error * message.

()

Source from the content-addressed store, hash-verified

16036 * message.
16037 */
16038function validateSecureContext() {
16039 if (window.location.hostname.endsWith(Constants.TRUSTED_DOMAIN)) {
16040 // This is for local development.
16041 return null;
16042 }
16043 if (window.isSecureContext === undefined) {
16044 // Browser not support isSecureContext, figure out a way to validate this
16045 // for the unsupported browser.
16046 return null;
16047 }
16048 return window.isSecureContext ?
16049 null :
16050 'Google Pay APIs should be called in secure context!';
16051}
16052
16053/**
16054 * Validate PaymentOptions.

Callers 3

isReadyToPayMethod · 0.85
prefetchPaymentDataMethod · 0.85
loadPaymentDataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected