@adyen/adyen-web 6.0.0-alpha.6 → 6.0.0-alpha.7
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/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +8 -0
- package/dist/es/components/Card/components/CardInput/defaultProps.js +1 -1
- package/dist/es/components/Card/components/CardInput/defaultProps.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/Services/analytics/log-event.js +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.registry.js +1 -1
- package/dist/es/core/core.registry.js.map +1 -1
- package/dist/es/external/preact/dist/preact.js +1 -1
- package/dist/es/external/preact/dist/preact.js.map +1 -1
- package/dist/es/index.d.ts +8 -0
- package/dist/es-legacy/components/Card/components/CardInput/defaultProps.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/defaultProps.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/Services/analytics/log-event.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.registry.js +1 -1
- package/dist/es-legacy/core/core.registry.js.map +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
- package/package.json +4 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CbObjOnLoad) => void;\n private handleOnConfigSuccess: (obj: CbObjOnConfigSuccess) => void;\n private handleOnFieldValid: (obj: CbObjOnFieldValid) => void;\n private handleOnAllValid: (obj: CbObjOnAllValid) => void;\n private handleOnBrand: (obj: CbObjOnBrand) => void;\n private handleFocus: (obj: CbObjOnFocus) => void;\n private handleOnError: (obj: CbObjOnError, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CbObjOnAutoComplete) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CbObjOnError): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CbObjOnError = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"+8CA6BA,MAAMA,UAA8BC,EAuEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAC,GAEjDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,SAAQC,IACXX,KAAKY,gBAAgBD,GAAS,CAAA,IAIlCX,KAAKa,cAAgBT,EAAOU,QAAOC,GAAKA,EAAEC,MAAM,YAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,WAExBF,KAAKoB,wBAEb,CAEOC,kBAAAA,GACHrB,KAAKsB,mBACT,CAEOC,oBAAAA,GACHvB,KAAKwB,IAAM,KACXC,aAAazB,KAAK0B,oBAClBD,aAAazB,KAAK2B,qBACtB,CAEQR,aAAAA,CAAcS,GAClB,IAAIC,EAAiB7B,KAAKC,MAAM4B,eA+Cd,IAAAC,EAnClB,MAAMC,EAA8B,CAChC7B,SAAU0B,EACVI,KAAMhC,KAAKC,MAAM+B,KACjBC,UAAWjC,KAAKC,MAAMgC,UACtBC,eAAgBlC,KAAKC,MAAMkC,OAC3BC,UAAWpC,KAAKC,MAAMmC,UACtBC,sBAAuBrC,KAAKC,MAAMoC,sBAClCR,iBACAS,UAAWtC,KAAKC,MAAMqC,UACtBC,aAAcvC,KAAKC,MAAMsC,aACzBC,eAAgB,CACZC,SAAUzC,KAAKC,MAAMyC,QAEzBC,KAAM3C,KAAKC,MAAM0C,KACjBC,UAAW,CACPC,OAAQ7C,KAAK8C,aACbC,gBAAiB/C,KAAKg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EACP4D,UAAWC,EACXC,iBAAkBC,EAClBrD,YAAY,EACZ/B,gBAAiBnE,EAAMmE,iBAE3BpE,KAAKmE,MAAQiF,EAEbpJ,KAAK0B,mBAAqB,KAC1B1B,KAAKkF,qBAAuB,IAE5BlF,KAAK2B,qBAAuB,KAC5B3B,KAAKkJ,uBAAyB,KAE9BlJ,KAAKY,gBAAkB,GAGvBZ,KAAK8C,aAAe2G,EAAS3G,aAAa4G,KAAK1J,MAC/CA,KAAKgD,sBAAwByG,EAASzG,sBAAsB0G,KAAK1J,MACjEA,KAAKkD,mBAAqBuG,EAASvG,mBAAmBwG,KAAK1J,MAC3DA,KAAKoD,iBAAmBqG,EAASrG,iBAAiBsG,KAAK1J,MACvDA,KAAKsD,cAAgBmG,EAASnG,cAAcoG,KAAK1J,MACjDA,KAAK0D,YAAc+F,EAAS/F,YAAYgG,KAAK1J,MAC7CA,KAAKwD,cAAgBiG,EAASjG,cAAckG,KAAK1J,MACjDA,KAAKoB,uBAAyBqI,EAASrI,uBAAuBsI,KAAK1J,MACnEA,KAAK6D,qBAAuB4F,EAAS5F,qBAAqB6F,KAAK1J,MAC/DA,KAAKiE,sBAAwBwF,EAASxF,sBAAsByF,KAAK1J,MAEjEA,KAAKqI,yBAA2BrI,KAAKqI,yBAAyBqB,KAAK1J,MAGnEA,KAAK6G,WAAa7G,KAAK6G,WAAW6C,KAAK1J,MACvCA,KAAKgH,aAAehH,KAAKgH,aAAa0C,KAAK1J,MAC3CA,KAAKsG,sBAAwBtG,KAAKsG,sBAAsBoD,KAAK1J,MAC7DA,KAAKoH,eAAiBpH,KAAKoH,eAAesC,KAAK1J,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQwI,KAAK1J,KACrC,EAEAiJ,EArEEpJ,EAqEY8J,eAAeA"}
|
|
1
|
+
{"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CbObjOnError,\n CbObjOnFocus,\n CbObjOnBrand,\n CbObjOnAllValid,\n CbObjOnFieldValid,\n CbObjOnAutoComplete,\n CbObjOnConfigSuccess,\n CbObjOnLoad\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CbObjOnLoad) => void;\n private handleOnConfigSuccess: (obj: CbObjOnConfigSuccess) => void;\n private handleOnFieldValid: (obj: CbObjOnFieldValid) => void;\n private handleOnAllValid: (obj: CbObjOnAllValid) => void;\n private handleOnBrand: (obj: CbObjOnBrand) => void;\n private handleFocus: (obj: CbObjOnFocus) => void;\n private handleOnError: (obj: CbObjOnError, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CbObjOnAutoComplete) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CbObjOnError): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CbObjOnError = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CbObjOnError = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"+8CA6BA,MAAMA,UAA8BC,EAuEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAC,GAEjDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,SAAQC,IACXX,KAAKY,gBAAgBD,GAAS,CAAA,IAIlCX,KAAKa,cAAgBT,EAAOU,QAAOC,GAAKA,EAAEC,MAAM,YAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,WAExBF,KAAKoB,wBAEb,CAEOC,kBAAAA,GACHrB,KAAKsB,mBACT,CAEOC,oBAAAA,GACHvB,KAAKwB,IAAM,KACXC,aAAazB,KAAK0B,oBAClBD,aAAazB,KAAK2B,qBACtB,CAEQR,aAAAA,CAAcS,GAClB,IAAIC,EAAiB7B,KAAKC,MAAM4B,eAgDd,IAAAC,EApClB,MAAMC,EAA8B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MAGnEA,KAAK8G,WAAa9G,KAAK8G,WAAW6C,KAAK3J,MACvCA,KAAKiH,aAAejH,KAAKiH,aAAa0C,KAAK3J,MAC3CA,KAAKuG,sBAAwBvG,KAAKuG,sBAAsBoD,KAAK3J,MAC7DA,KAAKqH,eAAiBrH,KAAKqH,eAAesC,KAAK3J,MAC/CA,KAAKkB,QAAUlB,KAAKkB,QAAQyI,KAAK3J,KACrC,EAEAkJ,EArEErJ,EAqEY+J,eAAeA"}
|
package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{select as e,getAttribute as t}from"../../utilities/dom.js";import{DATA_ENCRYPTED_FIELD_ATTR as i,CVC_POLICY_REQUIRED as s,DATE_POLICY_REQUIRED as o,ENCRYPTED_EXPIRY_YEAR as n,SF_CONFIG_TIMEOUT as r,ALL_SECURED_FIELDS as a,DATA_INFO as d,DATA_UID as l}from"../../constants.js";import{existy as c}from"../../utilities/commonUtils.js";import h from"../utils/cardType.js";import u from"../../securedField/SecuredField.js";import p from"../../../../../../core/Errors/AdyenCheckoutError.js";function f(){this.encryptedAttrName=i;const n=e(this.props.rootNode,`[${this.encryptedAttrName}]`).filter((e=>{const i=t(e,this.encryptedAttrName),s=a.includes(i);return s||console.warn(`WARNING: '${i}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`),s})),r=s,d=o;return this.config.isCreditCardType?(this.isSingleBrandedCard=!1,this.securityCode="",this.createCardSecuredFields(n,r,d),n.length):(this.createNonCardSecuredFields(n),n.length)}async function m(e){for(let t=0;t<e.length;t++){const i=e[t];await this.setupSecuredField(i).catch((e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)}))}}async function y(e,t,i){let n=this.state.type;if("card"===n&&1===this.config.cardGroupTypes.length&&(n=this.config.cardGroupTypes[0],this.state.type=n),this.isSingleBrandedCard="card"!==n,this.isSingleBrandedCard){const e=h.getCardByBrand(n);c(e)?(t=e.cvcPolicy||s,i=e.expiryDatePolicy||o,this.securityCode=e.securityCode):this.state.type="unrecognised-single-brand"}for(let s=0;s<e.length;s++){const o=e[s];window._b$dl&&console.log("\nAbout to set up securedField:",o),await this.setupSecuredField(o,t,i).catch((e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)})),window._b$dl&&console.log("Finished setting up securedField:",o)}if(window._b$dl&&console.log("Finished setting up all securedFields"),this.isSingleBrandedCard){const e={type:this.state.type,rootNode:this.props.rootNode,brand:n,cvcPolicy:t,expiryDatePolicy:i,cvcText:this.securityCode};setTimeout((()=>{this.callbacks.onBrand(e)}),0)}}function g(e,i,s){return new Promise(((o,a)=>{const c=t(e,this.encryptedAttrName);c===n&&(this.state.hasSeparateDateFields=!0);const h={fieldType:c,extraFieldData:t(e,d),uid:t(e,l),cvcPolicy:i,holderEl:e,expiryDatePolicy:s,txVariant:this.state.type,cardGroupTypes:this.config.cardGroupTypes,iframeUIConfig:this.config.iframeUIConfig,sfLogAtStart:this.config.sfLogAtStart,trimTrailingSeparator:this.config.trimTrailingSeparator,isCreditCardType:this.config.isCreditCardType,iframeSrc:this.config.iframeSrc,loadingContext:this.config.loadingContext,showWarnings:this.config.showWarnings,legacyInputMode:this.config.legacyInputMode,minimumExpiryDate:this.config.minimumExpiryDate,maskSecurityCode:this.props.maskSecurityCode,disableIOSArrowKeys:this.props.shouldDisableIOSArrowKeys,implementationType:this.props.implementationType,showContextualElement:this.props.showContextualElement,placeholders:this.props.placeholders},f=new u(h,this.props.i18n).onIframeLoaded((()=>{if(this.state.iframeCount+=1,window._b$dl&&console.log("### createSecuredFields::onIframeLoaded:: this.state.iframeCount=",this.state.iframeCount),this.state.iframeCount>this.state.numIframes)throw this.destroySecuredFields(),new p("ERROR",`One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`);if(f.loadToConfigTimeout=setTimeout((()=>{a({type:h.fieldType,failReason:"sf took too long to config"})}),r),this.state.iframeCount===this.state.originalNumIframes){const e={iframesLoaded:!0};this.callbacks.onLoad(e)}})).onConfig((e=>{this.handleIframeConfigFeedback(e),clearTimeout(f.loadToConfigTimeout),f.loadToConfigTimeout=null,o(e)})).onFocus((e=>{this.handleFocus(e)})).onBinValue((e=>{this.handleBinValue(e)})).onTouchstart((e=>{this.props.shouldDisableIOSArrowKeys&&(this.hasGenuineTouchEvents||e.hasGenuineTouchEvents)&&this.callbacks.onTouchstartIOS({fieldType:e.fieldType}),(e.hasGenuineTouchEvents||this.hasGenuineTouchEvents)&&this.postMessageToAllIframes({fieldType:e.fieldType,fieldClick:!0})})).onShiftTab((e=>{this.handleSFShiftTab(e.fieldType)})).onEncryption((e=>{this.handleEncryption(e)})).onValidation((e=>{this.handleValidation(e)})).onAutoComplete((e=>{this.processAutoComplete(e)}));this.state.securedFields[c]=f}))}export{y as createCardSecuredFields,m as createNonCardSecuredFields,f as createSecuredFields,g as setupSecuredField};
|
|
1
|
+
import{select as e,getAttribute as t}from"../../utilities/dom.js";import{DATA_ENCRYPTED_FIELD_ATTR as i,CVC_POLICY_REQUIRED as s,DATE_POLICY_REQUIRED as o,ENCRYPTED_EXPIRY_YEAR as n,SF_CONFIG_TIMEOUT as r,ALL_SECURED_FIELDS as a,DATA_INFO as d,DATA_UID as l}from"../../constants.js";import{existy as c}from"../../utilities/commonUtils.js";import h from"../utils/cardType.js";import u from"../../securedField/SecuredField.js";import p from"../../../../../../core/Errors/AdyenCheckoutError.js";function f(){this.encryptedAttrName=i;const n=e(this.props.rootNode,`[${this.encryptedAttrName}]`).filter((e=>{const i=t(e,this.encryptedAttrName),s=a.includes(i);return s||console.warn(`WARNING: '${i}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`),s})),r=s,d=o;return this.config.isCreditCardType?(this.isSingleBrandedCard=!1,this.securityCode="",this.createCardSecuredFields(n,r,d),n.length):(this.createNonCardSecuredFields(n),n.length)}async function m(e){for(let t=0;t<e.length;t++){const i=e[t];await this.setupSecuredField(i).catch((e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)}))}}async function y(e,t,i){let n=this.state.type;if("card"===n&&1===this.config.cardGroupTypes.length&&(n=this.config.cardGroupTypes[0],this.state.type=n),this.isSingleBrandedCard="card"!==n,this.isSingleBrandedCard){const e=h.getCardByBrand(n);c(e)?(t=e.cvcPolicy||s,i=e.expiryDatePolicy||o,this.securityCode=e.securityCode):this.state.type="unrecognised-single-brand"}for(let s=0;s<e.length;s++){const o=e[s];window._b$dl&&console.log("\nAbout to set up securedField:",o),await this.setupSecuredField(o,t,i).catch((e=>{window._b$dl&&console.log("Secured fields setup failure. e=",e)})),window._b$dl&&console.log("Finished setting up securedField:",o)}if(window._b$dl&&console.log("Finished setting up all securedFields"),this.isSingleBrandedCard){const e={type:this.state.type,rootNode:this.props.rootNode,brand:n,cvcPolicy:t,expiryDatePolicy:i,cvcText:this.securityCode};setTimeout((()=>{this.callbacks.onBrand(e)}),0)}}function g(e,i,s){return new Promise(((o,a)=>{const c=t(e,this.encryptedAttrName);c===n&&(this.state.hasSeparateDateFields=!0);const h={fieldType:c,extraFieldData:t(e,d),uid:t(e,l),cvcPolicy:i,holderEl:e,expiryDatePolicy:s,txVariant:this.state.type,cardGroupTypes:this.config.cardGroupTypes,iframeUIConfig:this.config.iframeUIConfig,sfLogAtStart:this.config.sfLogAtStart,trimTrailingSeparator:this.config.trimTrailingSeparator,isCreditCardType:this.config.isCreditCardType,iframeSrc:this.config.iframeSrc,loadingContext:this.config.loadingContext,showWarnings:this.config.showWarnings,legacyInputMode:this.config.legacyInputMode,minimumExpiryDate:this.config.minimumExpiryDate,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,disableIOSArrowKeys:this.props.shouldDisableIOSArrowKeys,implementationType:this.props.implementationType,showContextualElement:this.props.showContextualElement,placeholders:this.props.placeholders},f=new u(h,this.props.i18n).onIframeLoaded((()=>{if(this.state.iframeCount+=1,window._b$dl&&console.log("### createSecuredFields::onIframeLoaded:: this.state.iframeCount=",this.state.iframeCount),this.state.iframeCount>this.state.numIframes)throw this.destroySecuredFields(),new p("ERROR",`One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`);if(f.loadToConfigTimeout=setTimeout((()=>{a({type:h.fieldType,failReason:"sf took too long to config"})}),r),this.state.iframeCount===this.state.originalNumIframes){const e={iframesLoaded:!0};this.callbacks.onLoad(e)}})).onConfig((e=>{this.handleIframeConfigFeedback(e),clearTimeout(f.loadToConfigTimeout),f.loadToConfigTimeout=null,o(e)})).onFocus((e=>{this.handleFocus(e)})).onBinValue((e=>{this.handleBinValue(e)})).onTouchstart((e=>{this.props.shouldDisableIOSArrowKeys&&(this.hasGenuineTouchEvents||e.hasGenuineTouchEvents)&&this.callbacks.onTouchstartIOS({fieldType:e.fieldType}),(e.hasGenuineTouchEvents||this.hasGenuineTouchEvents)&&this.postMessageToAllIframes({fieldType:e.fieldType,fieldClick:!0})})).onShiftTab((e=>{this.handleSFShiftTab(e.fieldType)})).onEncryption((e=>{this.handleEncryption(e)})).onValidation((e=>{this.handleValidation(e)})).onAutoComplete((e=>{this.processAutoComplete(e)}));this.state.securedFields[c]=f}))}export{y as createCardSecuredFields,m as createNonCardSecuredFields,f as createSecuredFields,g as setupSecuredField};
|
|
2
2
|
//# sourceMappingURL=createSecuredFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSecuredFields.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.ts"],"sourcesContent":["import { select, getAttribute } from '../../utilities/dom';\nimport {\n ENCRYPTED_EXPIRY_YEAR,\n DATE_POLICY_REQUIRED,\n CVC_POLICY_REQUIRED,\n DATA_ENCRYPTED_FIELD_ATTR,\n DATA_INFO,\n DATA_UID,\n SF_CONFIG_TIMEOUT,\n ALL_SECURED_FIELDS,\n ENCRYPTED_EXPIRY_MONTH\n} from '../../constants';\nimport { existy } from '../../utilities/commonUtils';\nimport cardType from '../utils/cardType';\nimport { SecuredFieldSetupObject } from '../../types';\nimport SecuredField from '../../securedField/SecuredField';\nimport { CardObject, CbObjOnBrand, SFFeedbackObj, CbObjOnLoad, CVCPolicyType, DatePolicyType } from '../../types';\nimport AdyenCheckoutError from '../../../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Bound to the instance of CSF\n * Handles specific functionality related to configuring & creating SecuredFields\n */\nexport function createSecuredFields(): number {\n this.encryptedAttrName = DATA_ENCRYPTED_FIELD_ATTR;\n\n // Detect DOM elements that qualify as securedField holders & filter them for valid types\n const securedFields: HTMLElement[] = select(this.props.rootNode, `[${this.encryptedAttrName}]`).filter(field => {\n const fieldType: string = getAttribute(field, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_MONTH) {\n // TODO send analytics about separate date fields\n }\n\n const isValidType = ALL_SECURED_FIELDS.includes(fieldType);\n if (!isValidType) {\n console.warn(\n `WARNING: '${fieldType}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`\n );\n }\n return isValidType;\n });\n\n /**\n * cvcPolicy - 'required' | 'optional' | 'hidden'\n * - Always 'required' for GiftCards\n * - Usually 'required' for single branded Credit Cards but with exceptions e.g. maestro ('optional'), bcmc ('hidden').\n * - Always 'required' for generic Credit Cards at start up - in this case, subsequent, supporting information about whether cvc stops being required\n * comes from the SF in the brand information (as the shopper inputs the cc number)\n */\n const cvcPolicy: CVCPolicyType = CVC_POLICY_REQUIRED;\n\n /** Usually 'required' for single branded Credit Cards but with exceptions e.g. ticket ('hidden', *technically* a meal voucher) */\n const expiryDatePolicy: DatePolicyType = DATE_POLICY_REQUIRED;\n\n // CHECK IF THIS SECURED FIELD IS NOT OF A CREDIT CARD TYPE\n if (!this.config.isCreditCardType) {\n this.createNonCardSecuredFields(securedFields);\n return securedFields.length;\n }\n\n // CONTINUE AS CREDIT-CARD TYPE...\n this.isSingleBrandedCard = false;\n\n this.securityCode = '';\n\n this.createCardSecuredFields(securedFields, cvcPolicy, expiryDatePolicy);\n\n // Return the number of iframes we're going to create\n return securedFields.length;\n}\n\n/**\n * i.e. giftcard and ach fields\n *\n * Create a new SecuredField for each detected holding element\n */\nexport async function createNonCardSecuredFields(securedFields: HTMLElement[]): Promise<any> {\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n await this.setupSecuredField(securedField).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n }\n}\n\nexport async function createCardSecuredFields(\n securedFields: HTMLElement[],\n cvcPolicy: CVCPolicyType,\n expiryDatePolicy: DatePolicyType\n): Promise<any> {\n // Declared card type from the initialisation of CSF\n let type: string = this.state.type;\n\n // Maybe it's a single branded card defined by setting type: 'card' & a single item in cardGroupTypes\n // In which case update the type var both locally AND in State\n if (type === 'card' && this.config.cardGroupTypes.length === 1) {\n type = this.config.cardGroupTypes[0];\n this.state.type = type;\n }\n\n // So, is it a single branded card?\n this.isSingleBrandedCard = type !== 'card';\n\n // If single branded card field...\n if (this.isSingleBrandedCard) {\n // Check that type exists\n const card: CardObject = cardType.getCardByBrand(type);\n\n // It's possible we don't recognise the card type -\n // scenario: frontend initially recognises card as e.g. Visa - but then backend tokenises it as a sub-brand which we currently don't recognise\n if (!existy(card)) {\n this.state.type = 'unrecognised-single-brand'; // Will let CVC field accept 4 digits in the input\n } else {\n // Assess whether cvc field is required based on the card type & whether the cvc field should even be visible\n cvcPolicy = (card.cvcPolicy as CVCPolicyType) || CVC_POLICY_REQUIRED;\n expiryDatePolicy = (card.expiryDatePolicy as DatePolicyType) || DATE_POLICY_REQUIRED;\n\n this.securityCode = card.securityCode;\n }\n }\n\n /**\n * Create a new SecuredField for each detected holding element\n *\n * - we do this in sequence, waiting until one has configured before creating the next.\n * We do it this way to avoid the 'bug' whereby if something interrupts the loading of an iframe the listener we have for its load event\n * never fires; which means the iframe never configures.\n * (NB - you can recreate this 'bug' by creating the securedFields in a synchronous loop:\n * securedFields.forEach(this.setupSecuredField.bind(this));\n * and putting a breakpoint on the line where we declare the setupSecuredField function)\n *\n * Also note we tried the Array.map/Promise.all way of asynchronously looping through an array - but it didn't fix the issue,\n * - so we fall back to a good old for-loop\n */\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n if (window._b$dl) console.log('\\nAbout to set up securedField:', securedField);\n await this.setupSecuredField(securedField, cvcPolicy, expiryDatePolicy).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n if (window._b$dl) console.log('Finished setting up securedField:', securedField);\n }\n if (window._b$dl) console.log('Finished setting up all securedFields');\n\n /**\n * Now the securedFields have all been created and configured...\n *\n * For a single branded card we call to onBrand callback once.\n * This allows the UI to set the correct logo if they haven't already,\n * and we also pass the cvcPolicy & expiryDatePolicy so the UI can hide the iframe holders if necessary\n */\n if (this.isSingleBrandedCard) {\n const callbackObj: CbObjOnBrand = {\n type: this.state.type,\n rootNode: this.props.rootNode,\n brand: type,\n cvcPolicy,\n expiryDatePolicy,\n cvcText: this.securityCode\n };\n\n // Allow a tick for the securedField to finish rendering\n setTimeout(() => {\n this.callbacks.onBrand(callbackObj);\n }, 0);\n }\n}\n\n// Run for each detected holder of a securedField...\nexport function setupSecuredField(pItem: HTMLElement, cvcPolicy?: CVCPolicyType, expiryDatePolicy?: DatePolicyType): Promise<any> {\n return new Promise((resolve, reject) => {\n /**\n * possible values:\n * encryptedCardNumber\n * encryptedExpiryDate\n * encryptedExpiryMonth\n * encryptedExpiryYear\n * encryptedSecurityCode\n * encryptedPassword\n * encryptedPin???\n * encryptedBankAccountNumber\n * encryptedBankLocationId\n * encryptedIBAN\n */\n const fieldType: string = getAttribute(pItem, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_YEAR) {\n this.state.hasSeparateDateFields = true;\n }\n\n const extraFieldData: string = getAttribute(pItem, DATA_INFO);\n const uid = getAttribute(pItem, DATA_UID);\n\n // CREATE SecuredField passing config object\n const sfInitObj: SecuredFieldSetupObject = {\n fieldType,\n extraFieldData,\n uid,\n cvcPolicy,\n holderEl: pItem,\n expiryDatePolicy,\n txVariant: this.state.type,\n // from this.config (calculated)\n cardGroupTypes: this.config.cardGroupTypes,\n iframeUIConfig: this.config.iframeUIConfig,\n sfLogAtStart: this.config.sfLogAtStart,\n trimTrailingSeparator: this.config.trimTrailingSeparator,\n isCreditCardType: this.config.isCreditCardType,\n iframeSrc: this.config.iframeSrc,\n loadingContext: this.config.loadingContext,\n showWarnings: this.config.showWarnings,\n legacyInputMode: this.config.legacyInputMode,\n minimumExpiryDate: this.config.minimumExpiryDate,\n // from this.props (passed straight thru)\n maskSecurityCode: this.props.maskSecurityCode,\n disableIOSArrowKeys: this.props.shouldDisableIOSArrowKeys,\n implementationType: this.props.implementationType,\n showContextualElement: this.props.showContextualElement,\n placeholders: this.props.placeholders\n };\n\n const sf: SecuredField = new SecuredField(sfInitObj, this.props.i18n)\n .onIframeLoaded((): void => {\n // Count\n this.state.iframeCount += 1;\n\n if (window._b$dl) console.log('### createSecuredFields::onIframeLoaded:: this.state.iframeCount=', this.state.iframeCount);\n\n // One of our existing securedFields has just loaded new content!\n if (this.state.iframeCount > this.state.numIframes) {\n this.destroySecuredFields();\n // TODO send analytics about this error\n throw new AdyenCheckoutError(\n 'ERROR',\n `One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`\n );\n }\n\n /** Create timeout within which time we expect the securedField to configure */\n // @ts-ignore - timeout 'type' *is* a number\n sf.loadToConfigTimeout = setTimeout(() => {\n reject({ type: sfInitObj.fieldType, failReason: 'sf took too long to config' });\n }, SF_CONFIG_TIMEOUT);\n\n // If all iframes are loaded - call onLoad callback\n if (this.state.iframeCount === this.state.originalNumIframes) {\n const callbackObj: CbObjOnLoad = { iframesLoaded: true };\n this.callbacks.onLoad(callbackObj);\n }\n })\n .onConfig((pFeedbackObj: SFFeedbackObj): void => {\n this.handleIframeConfigFeedback(pFeedbackObj);\n\n // Clear timeout since the securedField has configured\n clearTimeout(sf.loadToConfigTimeout);\n sf.loadToConfigTimeout = null;\n\n resolve(pFeedbackObj);\n })\n .onFocus((pFeedbackObj: SFFeedbackObj): void => {\n this.handleFocus(pFeedbackObj);\n })\n .onBinValue((pFeedbackObj: SFFeedbackObj): void => {\n this.handleBinValue(pFeedbackObj);\n })\n .onTouchstart((pFeedbackObj: SFFeedbackObj): void => {\n // re. Disabling arrow keys in iOS - need to disable all other fields in the form\n if (this.props.shouldDisableIOSArrowKeys) {\n /**\n * re. this.hasGenuineTouchEvents...\n * There seems to be an issue with Responsive Design mode in Safari that means it allows setting focus on cross-origin iframes,\n * without enabling the touch events that allow the \"disableIOSArrowKeys\" workaround to fully function.\n * This results in a click on an securedFields *label* leading to, for example, the holderName field being disabled, but w/o access\n * to the touch events that would let it re-enable itself.\n *\n * So we prevent the \"disableIOSArrowKeys\" workaround unless we genuinely have touch events available.\n */\n if (this.hasGenuineTouchEvents || pFeedbackObj.hasGenuineTouchEvents) {\n this.callbacks.onTouchstartIOS({ fieldType: pFeedbackObj.fieldType });\n }\n }\n\n // Only perform this step if we genuinely have touch events available\n if (pFeedbackObj.hasGenuineTouchEvents || this.hasGenuineTouchEvents) {\n // iOS ONLY - RE. iOS BUGS AROUND BLUR AND FOCUS EVENTS\n // - pass information about which field has just been clicked (gained focus) to the other iframes\n this.postMessageToAllIframes({ fieldType: pFeedbackObj.fieldType, fieldClick: true });\n }\n })\n .onShiftTab((pFeedbackObj: SFFeedbackObj): void => {\n // Only happens for Firefox & IE <= 11\n this.handleSFShiftTab(pFeedbackObj.fieldType);\n })\n .onEncryption((pFeedbackObj: SFFeedbackObj): void => {\n this.handleEncryption(pFeedbackObj);\n })\n .onValidation((pFeedbackObj: SFFeedbackObj): void => {\n this.handleValidation(pFeedbackObj);\n })\n .onAutoComplete((pFeedbackObj: SFFeedbackObj): void => {\n this.processAutoComplete(pFeedbackObj);\n });\n\n // Store reference to securedField in this.state (under fieldType)\n this.state.securedFields[fieldType] = sf;\n });\n}\n"],"names":["createSecuredFields","this","encryptedAttrName","DATA_ENCRYPTED_FIELD_ATTR","securedFields","select","props","rootNode","filter","field","fieldType","getAttribute","isValidType","ALL_SECURED_FIELDS","includes","console","warn","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","config","isCreditCardType","isSingleBrandedCard","securityCode","createCardSecuredFields","length","createNonCardSecuredFields","async","i","securedField","setupSecuredField","catch","e","window","_b$dl","log","type","state","cardGroupTypes","card","cardType","getCardByBrand","existy","callbackObj","brand","cvcText","setTimeout","callbacks","onBrand","pItem","Promise","resolve","reject","ENCRYPTED_EXPIRY_YEAR","hasSeparateDateFields","sfInitObj","extraFieldData","DATA_INFO","uid","DATA_UID","holderEl","txVariant","iframeUIConfig","sfLogAtStart","trimTrailingSeparator","iframeSrc","loadingContext","showWarnings","legacyInputMode","minimumExpiryDate","maskSecurityCode","disableIOSArrowKeys","shouldDisableIOSArrowKeys","implementationType","showContextualElement","placeholders","sf","SecuredField","i18n","onIframeLoaded","iframeCount","numIframes","destroySecuredFields","AdyenCheckoutError","loadToConfigTimeout","failReason","SF_CONFIG_TIMEOUT","originalNumIframes","iframesLoaded","onLoad","onConfig","pFeedbackObj","handleIframeConfigFeedback","clearTimeout","onFocus","handleFocus","onBinValue","handleBinValue","onTouchstart","hasGenuineTouchEvents","onTouchstartIOS","postMessageToAllIframes","fieldClick","onShiftTab","handleSFShiftTab","onEncryption","handleEncryption","onValidation","handleValidation","onAutoComplete","processAutoComplete"],"mappings":"4eAuBO,SAASA,IACZC,KAAKC,kBAAoBC,EAGzB,MAAMC,EAA+BC,EAAOJ,KAAKK,MAAMC,SAAU,IAAIN,KAAKC,sBAAsBM,QAAOC,IACnG,MAAMC,EAAoBC,EAAaF,EAAOR,KAAKC,mBAM7CU,EAAcC,EAAmBC,SAASJ,GAMhD,OALKE,GACDG,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9C"}
|
|
1
|
+
{"version":3,"file":"createSecuredFields.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.ts"],"sourcesContent":["import { select, getAttribute } from '../../utilities/dom';\nimport {\n ENCRYPTED_EXPIRY_YEAR,\n DATE_POLICY_REQUIRED,\n CVC_POLICY_REQUIRED,\n DATA_ENCRYPTED_FIELD_ATTR,\n DATA_INFO,\n DATA_UID,\n SF_CONFIG_TIMEOUT,\n ALL_SECURED_FIELDS,\n ENCRYPTED_EXPIRY_MONTH\n} from '../../constants';\nimport { existy } from '../../utilities/commonUtils';\nimport cardType from '../utils/cardType';\nimport { SecuredFieldSetupObject } from '../../types';\nimport SecuredField from '../../securedField/SecuredField';\nimport { CardObject, CbObjOnBrand, SFFeedbackObj, CbObjOnLoad, CVCPolicyType, DatePolicyType } from '../../types';\nimport AdyenCheckoutError from '../../../../../../core/Errors/AdyenCheckoutError';\n\n/**\n * Bound to the instance of CSF\n * Handles specific functionality related to configuring & creating SecuredFields\n */\nexport function createSecuredFields(): number {\n this.encryptedAttrName = DATA_ENCRYPTED_FIELD_ATTR;\n\n // Detect DOM elements that qualify as securedField holders & filter them for valid types\n const securedFields: HTMLElement[] = select(this.props.rootNode, `[${this.encryptedAttrName}]`).filter(field => {\n const fieldType: string = getAttribute(field, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_MONTH) {\n // TODO send analytics about separate date fields\n }\n\n const isValidType = ALL_SECURED_FIELDS.includes(fieldType);\n if (!isValidType) {\n console.warn(\n `WARNING: '${fieldType}' is not a valid type for the '${this.encryptedAttrName}' attribute. A SecuredField will not be created for this element.`\n );\n }\n return isValidType;\n });\n\n /**\n * cvcPolicy - 'required' | 'optional' | 'hidden'\n * - Always 'required' for GiftCards\n * - Usually 'required' for single branded Credit Cards but with exceptions e.g. maestro ('optional'), bcmc ('hidden').\n * - Always 'required' for generic Credit Cards at start up - in this case, subsequent, supporting information about whether cvc stops being required\n * comes from the SF in the brand information (as the shopper inputs the cc number)\n */\n const cvcPolicy: CVCPolicyType = CVC_POLICY_REQUIRED;\n\n /** Usually 'required' for single branded Credit Cards but with exceptions e.g. ticket ('hidden', *technically* a meal voucher) */\n const expiryDatePolicy: DatePolicyType = DATE_POLICY_REQUIRED;\n\n // CHECK IF THIS SECURED FIELD IS NOT OF A CREDIT CARD TYPE\n if (!this.config.isCreditCardType) {\n this.createNonCardSecuredFields(securedFields);\n return securedFields.length;\n }\n\n // CONTINUE AS CREDIT-CARD TYPE...\n this.isSingleBrandedCard = false;\n\n this.securityCode = '';\n\n this.createCardSecuredFields(securedFields, cvcPolicy, expiryDatePolicy);\n\n // Return the number of iframes we're going to create\n return securedFields.length;\n}\n\n/**\n * i.e. giftcard and ach fields\n *\n * Create a new SecuredField for each detected holding element\n */\nexport async function createNonCardSecuredFields(securedFields: HTMLElement[]): Promise<any> {\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n await this.setupSecuredField(securedField).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n }\n}\n\nexport async function createCardSecuredFields(\n securedFields: HTMLElement[],\n cvcPolicy: CVCPolicyType,\n expiryDatePolicy: DatePolicyType\n): Promise<any> {\n // Declared card type from the initialisation of CSF\n let type: string = this.state.type;\n\n // Maybe it's a single branded card defined by setting type: 'card' & a single item in cardGroupTypes\n // In which case update the type var both locally AND in State\n if (type === 'card' && this.config.cardGroupTypes.length === 1) {\n type = this.config.cardGroupTypes[0];\n this.state.type = type;\n }\n\n // So, is it a single branded card?\n this.isSingleBrandedCard = type !== 'card';\n\n // If single branded card field...\n if (this.isSingleBrandedCard) {\n // Check that type exists\n const card: CardObject = cardType.getCardByBrand(type);\n\n // It's possible we don't recognise the card type -\n // scenario: frontend initially recognises card as e.g. Visa - but then backend tokenises it as a sub-brand which we currently don't recognise\n if (!existy(card)) {\n this.state.type = 'unrecognised-single-brand'; // Will let CVC field accept 4 digits in the input\n } else {\n // Assess whether cvc field is required based on the card type & whether the cvc field should even be visible\n cvcPolicy = (card.cvcPolicy as CVCPolicyType) || CVC_POLICY_REQUIRED;\n expiryDatePolicy = (card.expiryDatePolicy as DatePolicyType) || DATE_POLICY_REQUIRED;\n\n this.securityCode = card.securityCode;\n }\n }\n\n /**\n * Create a new SecuredField for each detected holding element\n *\n * - we do this in sequence, waiting until one has configured before creating the next.\n * We do it this way to avoid the 'bug' whereby if something interrupts the loading of an iframe the listener we have for its load event\n * never fires; which means the iframe never configures.\n * (NB - you can recreate this 'bug' by creating the securedFields in a synchronous loop:\n * securedFields.forEach(this.setupSecuredField.bind(this));\n * and putting a breakpoint on the line where we declare the setupSecuredField function)\n *\n * Also note we tried the Array.map/Promise.all way of asynchronously looping through an array - but it didn't fix the issue,\n * - so we fall back to a good old for-loop\n */\n for (let i = 0; i < securedFields.length; i++) {\n const securedField = securedFields[i];\n if (window._b$dl) console.log('\\nAbout to set up securedField:', securedField);\n await this.setupSecuredField(securedField, cvcPolicy, expiryDatePolicy).catch(e => {\n if (window._b$dl) console.log('Secured fields setup failure. e=', e);\n });\n if (window._b$dl) console.log('Finished setting up securedField:', securedField);\n }\n if (window._b$dl) console.log('Finished setting up all securedFields');\n\n /**\n * Now the securedFields have all been created and configured...\n *\n * For a single branded card we call to onBrand callback once.\n * This allows the UI to set the correct logo if they haven't already,\n * and we also pass the cvcPolicy & expiryDatePolicy so the UI can hide the iframe holders if necessary\n */\n if (this.isSingleBrandedCard) {\n const callbackObj: CbObjOnBrand = {\n type: this.state.type,\n rootNode: this.props.rootNode,\n brand: type,\n cvcPolicy,\n expiryDatePolicy,\n cvcText: this.securityCode\n };\n\n // Allow a tick for the securedField to finish rendering\n setTimeout(() => {\n this.callbacks.onBrand(callbackObj);\n }, 0);\n }\n}\n\n// Run for each detected holder of a securedField...\nexport function setupSecuredField(pItem: HTMLElement, cvcPolicy?: CVCPolicyType, expiryDatePolicy?: DatePolicyType): Promise<any> {\n return new Promise((resolve, reject) => {\n /**\n * possible values:\n * encryptedCardNumber\n * encryptedExpiryDate\n * encryptedExpiryMonth\n * encryptedExpiryYear\n * encryptedSecurityCode\n * encryptedPassword\n * encryptedPin???\n * encryptedBankAccountNumber\n * encryptedBankLocationId\n * encryptedIBAN\n */\n const fieldType: string = getAttribute(pItem, this.encryptedAttrName);\n\n if (fieldType === ENCRYPTED_EXPIRY_YEAR) {\n this.state.hasSeparateDateFields = true;\n }\n\n const extraFieldData: string = getAttribute(pItem, DATA_INFO);\n const uid = getAttribute(pItem, DATA_UID);\n\n // CREATE SecuredField passing config object\n const sfInitObj: SecuredFieldSetupObject = {\n fieldType,\n extraFieldData,\n uid,\n cvcPolicy,\n holderEl: pItem,\n expiryDatePolicy,\n txVariant: this.state.type,\n // from this.config (calculated)\n cardGroupTypes: this.config.cardGroupTypes,\n iframeUIConfig: this.config.iframeUIConfig,\n sfLogAtStart: this.config.sfLogAtStart,\n trimTrailingSeparator: this.config.trimTrailingSeparator,\n isCreditCardType: this.config.isCreditCardType,\n iframeSrc: this.config.iframeSrc,\n loadingContext: this.config.loadingContext,\n showWarnings: this.config.showWarnings,\n legacyInputMode: this.config.legacyInputMode,\n minimumExpiryDate: this.config.minimumExpiryDate,\n // from this.props (passed straight thru)\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n disableIOSArrowKeys: this.props.shouldDisableIOSArrowKeys,\n implementationType: this.props.implementationType,\n showContextualElement: this.props.showContextualElement,\n placeholders: this.props.placeholders\n };\n\n const sf: SecuredField = new SecuredField(sfInitObj, this.props.i18n)\n .onIframeLoaded((): void => {\n // Count\n this.state.iframeCount += 1;\n\n if (window._b$dl) console.log('### createSecuredFields::onIframeLoaded:: this.state.iframeCount=', this.state.iframeCount);\n\n // One of our existing securedFields has just loaded new content!\n if (this.state.iframeCount > this.state.numIframes) {\n this.destroySecuredFields();\n // TODO send analytics about this error\n throw new AdyenCheckoutError(\n 'ERROR',\n `One or more securedFields has just loaded new content. This should never happen. securedFields have been removed.\n iframe load count=${this.state.iframeCount}. Expected count:${this.state.numIframes}`\n );\n }\n\n /** Create timeout within which time we expect the securedField to configure */\n // @ts-ignore - timeout 'type' *is* a number\n sf.loadToConfigTimeout = setTimeout(() => {\n reject({ type: sfInitObj.fieldType, failReason: 'sf took too long to config' });\n }, SF_CONFIG_TIMEOUT);\n\n // If all iframes are loaded - call onLoad callback\n if (this.state.iframeCount === this.state.originalNumIframes) {\n const callbackObj: CbObjOnLoad = { iframesLoaded: true };\n this.callbacks.onLoad(callbackObj);\n }\n })\n .onConfig((pFeedbackObj: SFFeedbackObj): void => {\n this.handleIframeConfigFeedback(pFeedbackObj);\n\n // Clear timeout since the securedField has configured\n clearTimeout(sf.loadToConfigTimeout);\n sf.loadToConfigTimeout = null;\n\n resolve(pFeedbackObj);\n })\n .onFocus((pFeedbackObj: SFFeedbackObj): void => {\n this.handleFocus(pFeedbackObj);\n })\n .onBinValue((pFeedbackObj: SFFeedbackObj): void => {\n this.handleBinValue(pFeedbackObj);\n })\n .onTouchstart((pFeedbackObj: SFFeedbackObj): void => {\n // re. Disabling arrow keys in iOS - need to disable all other fields in the form\n if (this.props.shouldDisableIOSArrowKeys) {\n /**\n * re. this.hasGenuineTouchEvents...\n * There seems to be an issue with Responsive Design mode in Safari that means it allows setting focus on cross-origin iframes,\n * without enabling the touch events that allow the \"disableIOSArrowKeys\" workaround to fully function.\n * This results in a click on an securedFields *label* leading to, for example, the holderName field being disabled, but w/o access\n * to the touch events that would let it re-enable itself.\n *\n * So we prevent the \"disableIOSArrowKeys\" workaround unless we genuinely have touch events available.\n */\n if (this.hasGenuineTouchEvents || pFeedbackObj.hasGenuineTouchEvents) {\n this.callbacks.onTouchstartIOS({ fieldType: pFeedbackObj.fieldType });\n }\n }\n\n // Only perform this step if we genuinely have touch events available\n if (pFeedbackObj.hasGenuineTouchEvents || this.hasGenuineTouchEvents) {\n // iOS ONLY - RE. iOS BUGS AROUND BLUR AND FOCUS EVENTS\n // - pass information about which field has just been clicked (gained focus) to the other iframes\n this.postMessageToAllIframes({ fieldType: pFeedbackObj.fieldType, fieldClick: true });\n }\n })\n .onShiftTab((pFeedbackObj: SFFeedbackObj): void => {\n // Only happens for Firefox & IE <= 11\n this.handleSFShiftTab(pFeedbackObj.fieldType);\n })\n .onEncryption((pFeedbackObj: SFFeedbackObj): void => {\n this.handleEncryption(pFeedbackObj);\n })\n .onValidation((pFeedbackObj: SFFeedbackObj): void => {\n this.handleValidation(pFeedbackObj);\n })\n .onAutoComplete((pFeedbackObj: SFFeedbackObj): void => {\n this.processAutoComplete(pFeedbackObj);\n });\n\n // Store reference to securedField in this.state (under fieldType)\n this.state.securedFields[fieldType] = sf;\n });\n}\n"],"names":["createSecuredFields","this","encryptedAttrName","DATA_ENCRYPTED_FIELD_ATTR","securedFields","select","props","rootNode","filter","field","fieldType","getAttribute","isValidType","ALL_SECURED_FIELDS","includes","console","warn","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","config","isCreditCardType","isSingleBrandedCard","securityCode","createCardSecuredFields","length","createNonCardSecuredFields","async","i","securedField","setupSecuredField","catch","e","window","_b$dl","log","type","state","cardGroupTypes","card","cardType","getCardByBrand","existy","callbackObj","brand","cvcText","setTimeout","callbacks","onBrand","pItem","Promise","resolve","reject","ENCRYPTED_EXPIRY_YEAR","hasSeparateDateFields","sfInitObj","extraFieldData","DATA_INFO","uid","DATA_UID","holderEl","txVariant","iframeUIConfig","sfLogAtStart","trimTrailingSeparator","iframeSrc","loadingContext","showWarnings","legacyInputMode","minimumExpiryDate","maskSecurityCode","exposeExpiryDate","disableIOSArrowKeys","shouldDisableIOSArrowKeys","implementationType","showContextualElement","placeholders","sf","SecuredField","i18n","onIframeLoaded","iframeCount","numIframes","destroySecuredFields","AdyenCheckoutError","loadToConfigTimeout","failReason","SF_CONFIG_TIMEOUT","originalNumIframes","iframesLoaded","onLoad","onConfig","pFeedbackObj","handleIframeConfigFeedback","clearTimeout","onFocus","handleFocus","onBinValue","handleBinValue","onTouchstart","hasGenuineTouchEvents","onTouchstartIOS","postMessageToAllIframes","fieldClick","onShiftTab","handleSFShiftTab","onEncryption","handleEncryption","onValidation","handleValidation","onAutoComplete","processAutoComplete"],"mappings":"4eAuBO,SAASA,IACZC,KAAKC,kBAAoBC,EAGzB,MAAMC,EAA+BC,EAAOJ,KAAKK,MAAMC,SAAU,IAAIN,KAAKC,sBAAsBM,QAAOC,IACnG,MAAMC,EAAoBC,EAAaF,EAAOR,KAAKC,mBAM7CU,EAAcC,EAAmBC,SAASJ,GAMhD,OALKE,GACDG,QAAQC,KACJ,aAAaN,mCAA2CT,KAAKC,sFAG9DU,CAAAA,IAULK,EAA2BC,EAG3BC,EAAmCC,EAGzC,OAAKnB,KAAKoB,OAAOC,kBAMjBrB,KAAKsB,qBAAsB,EAE3BtB,KAAKuB,aAAe,GAEpBvB,KAAKwB,wBAAwBrB,EAAea,EAAWE,GAGhDf,EAAcsB,SAZjBzB,KAAK0B,2BAA2BvB,GACzBA,EAAcsB,OAY7B,CAOOE,eAAeD,EAA2BvB,GAC7C,IAAK,IAAIyB,EAAI,EAAGA,EAAIzB,EAAcsB,OAAQG,IAAK,CAC3C,MAAMC,EAAe1B,EAAcyB,SAC7B5B,KAAK8B,kBAAkBD,GAAcE,OAAMC,IACzCC,OAAOC,OAAOpB,QAAQqB,IAAI,mCAAoCH,EAAAA,GAE1E,CACJ,CAEOL,eAAeH,EAClBrB,EACAa,EACAE,GAGA,IAAIkB,EAAepC,KAAKqC,MAAMD,KAa9B,GATa,SAATA,GAAyD,IAAtCpC,KAAKoB,OAAOkB,eAAeb,SAC9CW,EAAOpC,KAAKoB,OAAOkB,eAAe,GAClCtC,KAAKqC,MAAMD,KAAOA,GAItBpC,KAAKsB,oBAA+B,SAATc,EAGvBpC,KAAKsB,oBAAqB,CAE1B,MAAMiB,EAAmBC,EAASC,eAAeL,GAI5CM,EAAOH,IAIRvB,EAAauB,EAAKvB,WAA+BC,EACjDC,EAAoBq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BAAgB,CAAE5F,UAAWmF,EAAanF,aAK7DmF,EAAaQ,uBAAyBpG,KAAKoG,wBAG3CpG,KAAKsG,wBAAwB,CAAE7F,UAAWmF,EAAanF,UAAW8F,YAAY,GAClF,IAEHC,YAAYZ,IAET5F,KAAKyG,iBAAiBb,EAAanF,UAAS,IAE/CiG,cAAcd,IACX5F,KAAK2G,iBAAiBf,EAAAA,IAEzBgB,cAAchB,IACX5F,KAAK6G,iBAAiBjB,EAAAA,IAEzBkB,gBAAgBlB,IACb5F,KAAK+G,oBAAoBnB,EAAAA,IAIjC5F,KAAKqC,MAAMlC,cAAcM,GAAaoE,CAAAA,GAE9C"}
|
package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{makeCallbackObjectsEncryption as t}from"../utils/callbackUtils.js";import{ENCRYPTED_EXPIRY_YEAR as s,ENCRYPTED_SECURITY_CODE as e,ENCRYPTED_EXPIRY_MONTH as i,ENCRYPTED_CARD_NUMBER as o}from"../../constants.js";import{processErrors as
|
|
1
|
+
import{makeCallbackObjectsEncryption as t}from"../utils/callbackUtils.js";import{ENCRYPTED_EXPIRY_YEAR as s,ENCRYPTED_SECURITY_CODE as e,ENCRYPTED_EXPIRY_MONTH as i,ENCRYPTED_CARD_NUMBER as o,ENCRYPTED_EXPIRY_DATE as r}from"../../constants.js";import{processErrors as a}from"../utils/processErrors.js";import{truthy as n}from"../../utilities/commonUtils.js";import l from"../utils/iframes/postMessageToIframe.js";import{hasOwnProperty as p}from"../../../../../../utils/hasOwnProperty.js";import c from"../utils/iframes/getIframeContentWin.js";function d(d){const m=d.fieldType;let f,u;this.config.autoFocus&&("year"!==d.type&&m!==s||this.setFocusOnFrame(e),m===i&&this.setFocusOnFrame(s));const h=d[m];this.state.securedFields[m].isEncrypted=!0,a({error:"",fieldType:m},this.state.securedFields[m],this.state.type,this.props.rootNode,this.callbacks.onError);const y=t({fieldType:m,txVariant:this.state.type,rootNode:this.props.rootNode,encryptedObjArr:h});if(m===i&&p(this.state.securedFields,s)){const t={txVariant:this.state.type,code:d.code,blob:h[0].blob,fieldType:s,numKey:this.state.securedFields[s].numKey};l(t,c(this.state,s),this.config.loadingContext)}for(m===o&&n(d.endDigits)&&(y[0].endDigits=d.endDigits),m===o&&n(d.issuerBin)&&(y[0].issuerBin=+d.issuerBin),m===r&&n(d.expiryDate)&&(y[1].expiryDate=d.expiryDate),f=0,u=y.length;f<u;f+=1)this.callbacks.onFieldValid(y[f]);this.validateForm()}export{d as handleEncryption};
|
|
2
2
|
//# sourceMappingURL=handleEncryption.js.map
|
package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleEncryption.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.ts"],"sourcesContent":["import { makeCallbackObjectsEncryption } from '../utils/callbackUtils';\nimport {
|
|
1
|
+
{"version":3,"file":"handleEncryption.js","sources":["../../../../../../../../src/components/internal/SecuredFields/lib/CSF/extensions/handleEncryption.ts"],"sourcesContent":["import { makeCallbackObjectsEncryption } from '../utils/callbackUtils';\nimport {\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE\n} from '../../constants';\nimport { processErrors } from '../utils/processErrors';\nimport { truthy } from '../../utilities/commonUtils';\nimport { SFFeedbackObj, CbObjOnFieldValid, EncryptionObj } from '../../types';\nimport postMessageToIframe from '../utils/iframes/postMessageToIframe';\nimport { hasOwnProperty } from '../../../../../../utils/hasOwnProperty';\nimport getIframeContentWin from '../utils/iframes/getIframeContentWin';\n\nexport function handleEncryption(pFeedbackObj: SFFeedbackObj): void {\n // EXTRACT VARS\n const fieldType: string = pFeedbackObj.fieldType;\n\n // SET FOCUS ON OTHER INPUT - If user has just typed a correct expiryDate - set focus on the cvc field OR typed a correct expiryMonth - focus on year field\n if (this.config.autoFocus) {\n // pFeedbackObj.type === 'year' when the encryption is happening on an expiryDate field c.f. a separate year field (when it equals ENCRYPTED_EXPIRY_YEAR)\n if (pFeedbackObj.type === 'year' || fieldType === ENCRYPTED_EXPIRY_YEAR) {\n this.setFocusOnFrame(ENCRYPTED_SECURITY_CODE);\n }\n if (fieldType === ENCRYPTED_EXPIRY_MONTH) {\n this.setFocusOnFrame(ENCRYPTED_EXPIRY_YEAR);\n }\n }\n //--\n\n let i: number;\n let len: number;\n\n const encryptedObjArr: EncryptionObj[] = pFeedbackObj[fieldType];\n\n // Set boolean saying this securedField is in an encryptedState\n this.state.securedFields[fieldType].isEncrypted = true;\n\n // REMOVE ANY ERRORS ON FIELD e.g. was a full number that failed the luhnCheck, then we corrected the number and now it passes\n processErrors(\n { error: '', fieldType } as any as SFFeedbackObj,\n this.state.securedFields[fieldType],\n this.state.type,\n this.props.rootNode,\n this.callbacks.onError\n );\n\n // MAKE ENCRYPTION OBJECTS FOR EACH OF THE INDIVIDUAL INPUTS\n // N.B. when considering \"individual inputs\" we are concerned with the 4 fields that the checkoutAPI expects to receive for a credit card payment:\n // encryptedCardNumber, encryptedSecurityCode, encryptedExpiryMonth, encryptedExpiryYear\n const callbackObjectsArr: CbObjOnFieldValid[] = makeCallbackObjectsEncryption({\n fieldType,\n txVariant: this.state.type,\n rootNode: this.props.rootNode,\n encryptedObjArr\n });\n\n // For standalone month field\n if (fieldType === ENCRYPTED_EXPIRY_MONTH) {\n if (hasOwnProperty(this.state.securedFields, ENCRYPTED_EXPIRY_YEAR)) {\n const dataObj: object = {\n txVariant: this.state.type,\n code: pFeedbackObj.code,\n blob: encryptedObjArr[0].blob,\n fieldType: ENCRYPTED_EXPIRY_YEAR,\n numKey: this.state.securedFields[ENCRYPTED_EXPIRY_YEAR].numKey\n };\n postMessageToIframe(dataObj, getIframeContentWin(this.state, ENCRYPTED_EXPIRY_YEAR), this.config.loadingContext);\n }\n }\n\n // For number field - add the endDigits to the encryption object\n if (fieldType === ENCRYPTED_CARD_NUMBER && truthy(pFeedbackObj.endDigits)) {\n callbackObjectsArr[0].endDigits = pFeedbackObj.endDigits;\n }\n\n // For number field - add the 8 digit issuerBin to the encryption object\n if (fieldType === ENCRYPTED_CARD_NUMBER && truthy(pFeedbackObj.issuerBin)) {\n callbackObjectsArr[0].issuerBin = +pFeedbackObj.issuerBin;\n }\n\n // Add expiryDate to \"encryptedExpiryYear\" field. It will only be present if the correct config has been sent to SF\n if (fieldType === ENCRYPTED_EXPIRY_DATE && truthy(pFeedbackObj.expiryDate)) {\n callbackObjectsArr[1].expiryDate = pFeedbackObj.expiryDate;\n }\n\n // BROADCAST VALID STATE OF INDIVIDUAL INPUTS - passing the encryption objects\n for (i = 0, len = callbackObjectsArr.length; i < len; i += 1) {\n this.callbacks.onFieldValid(callbackObjectsArr[i]);\n }\n //--------------------------------------------\n\n // STORE & BROADCAST VALID STATE OF THE FORM AS A WHOLE ///////\n this.validateForm();\n}\n"],"names":["handleEncryption","pFeedbackObj","fieldType","i","len","this","config","autoFocus","type","ENCRYPTED_EXPIRY_YEAR","setFocusOnFrame","ENCRYPTED_SECURITY_CODE","ENCRYPTED_EXPIRY_MONTH","encryptedObjArr","state","securedFields","isEncrypted","processErrors","error","props","rootNode","callbacks","onError","callbackObjectsArr","makeCallbackObjectsEncryption","txVariant","hasOwnProperty","dataObj","code","blob","numKey","postMessageToIframe","getIframeContentWin","loadingContext","ENCRYPTED_CARD_NUMBER","truthy","endDigits","issuerBin","ENCRYPTED_EXPIRY_DATE","expiryDate","length","onFieldValid","validateForm"],"mappings":"+hBAeO,SAASA,EAAiBC,GAE7B,MAAMC,EAAoBD,EAAaC,UAcvC,IAAIC,EACAC,EAZAC,KAAKC,OAAOC,YAEc,SAAtBN,EAAaO,MAAmBN,IAAcO,GAC9CJ,KAAKK,gBAAgBC,GAErBT,IAAcU,GACdP,KAAKK,gBAAgBD,IAQ7B,MAAMI,EAAmCZ,EAAaC,GAGtDG,KAAKS,MAAMC,cAAcb,GAAWc,aAAc,EAGlDC,EACI,CAAEC,MAAO,GAAIhB,aACbG,KAAKS,MAAMC,cAAcb,GACzBG,KAAKS,MAAMN,KACXH,KAAKc,MAAMC,SACXf,KAAKgB,UAAUC,SAMnB,MAAMC,EAA0CC,EAA8B,CAC1EtB,YACAuB,UAAWpB,KAAKS,MAAMN,KACtBY,SAAUf,KAAKc,MAAMC,SACrBP,oBAIJ,GAAIX,IAAcU,GACVc,EAAerB,KAAKS,MAAMC,cAAeN,GAAwB,CACjE,MAAMkB,EAAkB,CACpBF,UAAWpB,KAAKS,MAAMN,KACtBoB,KAAM3B,EAAa2B,KACnBC,KAAMhB,EAAgB,GAAGgB,KACzB3B,UAAWO,EACXqB,OAAQzB,KAAKS,MAAMC,cAAcN,GAAuBqB,QAE5DC,EAAoBJ,EAASK,EAAoB3B,KAAKS,MAAOL,GAAwBJ,KAAKC,OAAO2B,eACrG,CAmBJ,IAfI/B,IAAcgC,GAAyBC,EAAOlC,EAAamC,aAC3Db,EAAmB,GAAGa,UAAYnC,EAAamC,WAI/ClC,IAAcgC,GAAyBC,EAAOlC,EAAaoC,aAC3Dd,EAAmB,GAAGc,WAAapC,EAAaoC,WAIhDnC,IAAcoC,GAAyBH,EAAOlC,EAAasC,cAC3DhB,EAAmB,GAAGgB,WAAatC,EAAasC,YAI/CpC,EAAI,EAAGC,EAAMmB,EAAmBiB,OAAQrC,EAAIC,EAAKD,GAAK,EACvDE,KAAKgB,UAAUoB,aAAalB,EAAmBpB,IAKnDE,KAAKqC,cACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e="encrypted",r="encryptedCardNumber",c="encryptedExpiryDate",t="encryptedExpiryMonth",a="encryptedExpiryYear",d="encryptedSecurityCode",i="encryptedPassword",n="encryptedBankAccountNumber",o="encryptedBankLocationId",s="encryptedSecurityCode3digits",y="encryptedSecurityCode4digits",p="giftcard",u="5.0
|
|
1
|
+
const e="encrypted",r="encryptedCardNumber",c="encryptedExpiryDate",t="encryptedExpiryMonth",a="encryptedExpiryYear",d="encryptedSecurityCode",i="encryptedPassword",n="encryptedBankAccountNumber",o="encryptedBankLocationId",s="encryptedSecurityCode3digits",y="encryptedSecurityCode4digits",p="giftcard",u="5.1.0",m=["amex","mc","visa"],C=["ach",p],b=[r,c,t,a,d,i],x=[n,o],h=b.concat(x),D=["bcmc"],g="required",k="optional",B="hidden",l=g,v=k,A=B,E=g,M=k,N=B,S="data-cse",f="data-info",j="data-uid",I=["accel","pulse","star","nyce"],w={visa:"VISA",mc:"MasterCard",amex:"American Express",discover:"Discover",cup:"China Union Pay",jcb:"JCB",diners:"Diners Club",maestro:"Maestro",bcmc:"Bancontact card",bijcard:"de Bijenkorf Card"},L={[r]:"cardNumber",[c]:"expiryDate",[d]:"securityCode",[t]:"expiryMonth",[a]:"expiryYear",[i]:"password",[n]:"bankAccountNumber",[o]:"bankLocationId",[s]:"securityCodeThreeDigits",[y]:"securityCodeFourDigits"},P=6e3;export{h as ALL_SECURED_FIELDS,I as BRAND_ICON_UI_EXCLUSION_LIST,w as BRAND_READABLE_NAME_MAP,b as CREDIT_CARD_SF_FIELDS,A as CVC_POLICY_HIDDEN,v as CVC_POLICY_OPTIONAL,l as CVC_POLICY_REQUIRED,S as DATA_ENCRYPTED_FIELD_ATTR,f as DATA_INFO,j as DATA_UID,N as DATE_POLICY_HIDDEN,M as DATE_POLICY_OPTIONAL,E as DATE_POLICY_REQUIRED,D as DEDICATED_CARD_COMPONENTS,m as DEFAULT_CARD_GROUP_TYPES,e as ENCRYPTED,n as ENCRYPTED_BANK_ACCNT_NUMBER_FIELD,o as ENCRYPTED_BANK_LOCATION_FIELD,r as ENCRYPTED_CARD_NUMBER,c as ENCRYPTED_EXPIRY_DATE,t as ENCRYPTED_EXPIRY_MONTH,a as ENCRYPTED_EXPIRY_YEAR,i as ENCRYPTED_PWD_FIELD,d as ENCRYPTED_SECURITY_CODE,s as ENCRYPTED_SECURITY_CODE_3_DIGITS,y as ENCRYPTED_SECURITY_CODE_4_DIGITS,p as GIFT_CARD,B as HIDDEN,C as NON_CREDIT_CARD_TYPE_SECURED_FIELDS,k as OPTIONAL,x as OTHER_SF_FIELDS,g as REQUIRED,P as SF_CONFIG_TIMEOUT,L as SF_FIELDS_MAP,u as SF_VERSION};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../../../src/components/internal/SecuredFields/lib/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from './types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\nexport const ENCRYPTED_BANK_ACCNT_NUMBER_FIELD = 'encryptedBankAccountNumber';\nexport const ENCRYPTED_BANK_LOCATION_FIELD = 'encryptedBankLocationId';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '5.0
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../../../src/components/internal/SecuredFields/lib/constants.ts"],"sourcesContent":["import { CVCPolicyType, DatePolicyType } from './types';\n\nexport const ENCRYPTED = 'encrypted';\n\nexport const ENCRYPTED_CARD_NUMBER = 'encryptedCardNumber';\nexport const ENCRYPTED_EXPIRY_DATE = 'encryptedExpiryDate';\nexport const ENCRYPTED_EXPIRY_MONTH = 'encryptedExpiryMonth';\nexport const ENCRYPTED_EXPIRY_YEAR = 'encryptedExpiryYear';\nexport const ENCRYPTED_SECURITY_CODE = 'encryptedSecurityCode';\nexport const ENCRYPTED_PWD_FIELD = 'encryptedPassword';\nexport const ENCRYPTED_PIN_FIELD = 'encryptedPin';\nexport const ENCRYPTED_BANK_ACCNT_NUMBER_FIELD = 'encryptedBankAccountNumber';\nexport const ENCRYPTED_BANK_LOCATION_FIELD = 'encryptedBankLocationId';\n\nexport const ENCRYPTED_SECURITY_CODE_3_DIGITS = 'encryptedSecurityCode3digits';\nexport const ENCRYPTED_SECURITY_CODE_4_DIGITS = 'encryptedSecurityCode4digits';\n\nexport const GIFT_CARD = 'giftcard';\n\nexport const SF_VERSION = '5.1.0';\n\nexport const DEFAULT_CARD_GROUP_TYPES = ['amex', 'mc', 'visa'];\n\nexport const NON_CREDIT_CARD_TYPE_SECURED_FIELDS = ['ach', GIFT_CARD]; // Maybe, sometime in the future will include 'sepa' & 'sepadirectdebit'\n\n// Credit card (CardInput) related securedFields (based on the data-cse attribute)\nexport const CREDIT_CARD_SF_FIELDS = [\n ENCRYPTED_CARD_NUMBER,\n ENCRYPTED_EXPIRY_DATE,\n ENCRYPTED_EXPIRY_MONTH,\n ENCRYPTED_EXPIRY_YEAR,\n ENCRYPTED_SECURITY_CODE,\n ENCRYPTED_PWD_FIELD\n // ENCRYPTED_PIN_FIELD,// probably redundant - it was an alt. name for KCP's encryptedPassword. But maybe has a role to play if we ever encrypt ibans.\n];\n\nexport const OTHER_SF_FIELDS = [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD, ENCRYPTED_BANK_LOCATION_FIELD]; // ACH fields\n\n/** A list of all the data-cse attributes that relate to securedFields (as found in card, giftcard or ach) */\nexport const ALL_SECURED_FIELDS = CREDIT_CARD_SF_FIELDS.concat(OTHER_SF_FIELDS);\n\n// Card components created as: checkout.create({BRAND}) e.g. checkout.create('bcmc')\n// - which are dedicated to a single, core, brand e.g. 'bcmc' BUT which can in effect handle multiple brands e.g. \"bcmc\", \"maestro\", \"visa\"\nexport const DEDICATED_CARD_COMPONENTS = ['bcmc'];\n\nexport const REQUIRED = 'required';\nexport const OPTIONAL = 'optional';\nexport const HIDDEN = 'hidden';\n\nexport const CVC_POLICY_REQUIRED: CVCPolicyType = REQUIRED;\nexport const CVC_POLICY_OPTIONAL: CVCPolicyType = OPTIONAL;\nexport const CVC_POLICY_HIDDEN: CVCPolicyType = HIDDEN;\n\nexport const DATE_POLICY_REQUIRED: DatePolicyType = REQUIRED;\nexport const DATE_POLICY_OPTIONAL: DatePolicyType = OPTIONAL;\nexport const DATE_POLICY_HIDDEN: DatePolicyType = HIDDEN;\n\nexport const DATA_ENCRYPTED_FIELD_ATTR = 'data-cse';\nexport const DATA_INFO = 'data-info';\nexport const DATA_UID = 'data-uid';\n\nexport const BRAND_ICON_UI_EXCLUSION_LIST = ['accel', 'pulse', 'star', 'nyce'];\n\nexport const BRAND_READABLE_NAME_MAP = {\n visa: 'VISA',\n mc: 'MasterCard',\n amex: 'American Express',\n discover: 'Discover',\n cup: 'China Union Pay',\n jcb: 'JCB',\n diners: 'Diners Club',\n maestro: 'Maestro',\n bcmc: 'Bancontact card',\n bijcard: 'de Bijenkorf Card'\n};\n\nexport const SF_FIELDS_MAP = {\n [ENCRYPTED_CARD_NUMBER]: 'cardNumber', // ph\n [ENCRYPTED_EXPIRY_DATE]: 'expiryDate', // ph\n [ENCRYPTED_SECURITY_CODE]: 'securityCode',\n [ENCRYPTED_EXPIRY_MONTH]: 'expiryMonth', // ph\n [ENCRYPTED_EXPIRY_YEAR]: 'expiryYear', // ph\n //\n [ENCRYPTED_PWD_FIELD]: 'password',\n [ENCRYPTED_BANK_ACCNT_NUMBER_FIELD]: 'bankAccountNumber',\n [ENCRYPTED_BANK_LOCATION_FIELD]: 'bankLocationId',\n //\n [ENCRYPTED_SECURITY_CODE_3_DIGITS]: 'securityCodeThreeDigits', // ph\n [ENCRYPTED_SECURITY_CODE_4_DIGITS]: 'securityCodeFourDigits' // ph\n};\n\n/** time within which we expect to receive a \"configured\" message from a securedField iframe, once it has registered as having loaded */\nexport const SF_CONFIG_TIMEOUT = 6000;\n"],"names":["ENCRYPTED","ENCRYPTED_CARD_NUMBER","ENCRYPTED_EXPIRY_DATE","ENCRYPTED_EXPIRY_MONTH","ENCRYPTED_EXPIRY_YEAR","ENCRYPTED_SECURITY_CODE","ENCRYPTED_PWD_FIELD","ENCRYPTED_BANK_ACCNT_NUMBER_FIELD","ENCRYPTED_BANK_LOCATION_FIELD","ENCRYPTED_SECURITY_CODE_3_DIGITS","ENCRYPTED_SECURITY_CODE_4_DIGITS","GIFT_CARD","SF_VERSION","DEFAULT_CARD_GROUP_TYPES","NON_CREDIT_CARD_TYPE_SECURED_FIELDS","CREDIT_CARD_SF_FIELDS","OTHER_SF_FIELDS","ALL_SECURED_FIELDS","concat","DEDICATED_CARD_COMPONENTS","REQUIRED","OPTIONAL","HIDDEN","CVC_POLICY_REQUIRED","CVC_POLICY_OPTIONAL","CVC_POLICY_HIDDEN","DATE_POLICY_REQUIRED","DATE_POLICY_OPTIONAL","DATE_POLICY_HIDDEN","DATA_ENCRYPTED_FIELD_ATTR","DATA_INFO","DATA_UID","BRAND_ICON_UI_EXCLUSION_LIST","BRAND_READABLE_NAME_MAP","visa","mc","amex","discover","cup","jcb","diners","maestro","bcmc","bijcard","SF_FIELDS_MAP","SF_CONFIG_TIMEOUT"],"mappings":"AAEO,MAAMA,EAAY,YAEZC,EAAwB,sBACxBC,EAAwB,sBACxBC,EAAyB,uBACzBC,EAAwB,sBACxBC,EAA0B,wBAC1BC,EAAsB,oBAEtBC,EAAoC,6BACpCC,EAAgC,0BAEhCC,EAAmC,+BACnCC,EAAmC,+BAEnCC,EAAY,WAEZC,EAAa,QAEbC,EAA2B,CAAC,OAAQ,KAAM,QAE1CC,EAAsC,CAAC,MAAOH,GAG9CI,EAAwB,CACjCd,EACAC,EACAC,EACAC,EACAC,EACAC,GAISU,EAAkB,CAACT,EAAmCC,GAGtDS,EAAqBF,EAAsBG,OAAOF,GAIlDG,EAA4B,CAAC,QAE7BC,EAAW,WACXC,EAAW,WACXC,EAAS,SAETC,EAAqCH,EACrCI,EAAqCH,EACrCI,EAAmCH,EAEnCI,EAAuCN,EACvCO,EAAuCN,EACvCO,EAAqCN,EAErCO,EAA4B,WAC5BC,EAAY,YACZC,EAAW,WAEXC,EAA+B,CAAC,QAAS,QAAS,OAAQ,QAE1DC,EAA0B,CACnCC,KAAM,OACNC,GAAI,aACJC,KAAM,mBACNC,SAAU,WACVC,IAAK,kBACLC,IAAK,MACLC,OAAQ,cACRC,QAAS,UACTC,KAAM,kBACNC,QAAS,qBAGAC,EAAgB,CACzB3C,CAACA,GAAwB,aACzBC,CAACA,GAAwB,aACzBG,CAACA,GAA0B,eAC3BF,CAACA,GAAyB,cAC1BC,CAACA,GAAwB,aAEzBE,CAACA,GAAsB,WACvBC,CAACA,GAAoC,oBACrCC,CAACA,GAAgC,iBAEjCC,CAACA,GAAmC,0BACpCC,CAACA,GAAmC,0BAI3BmC,EAAoB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const o=({analyticsContext:o,clientKey:i,locale:c,analyticsPath:l,bundleType:a})=>{let s;const u={errorLevel:"fatal",loadingContext:o,path:`${l}?clientKey=${i}`};return o=>{const l=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){n(e,t,r[t])}))}return e}({version:"6.0.0-alpha.
|
|
1
|
+
import{httpPost as e}from"../http.js";import t from"../../../utils/Storage.js";function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r='WARNING: Failed to retrieve "checkoutAttemptId". Consequently, analytics will not be available for this payment. The payment process, however, will not be affected.';const o=({analyticsContext:o,clientKey:i,locale:c,analyticsPath:l,bundleType:a})=>{let s;const u={errorLevel:"fatal",loadingContext:o,path:`${l}?clientKey=${i}`};return o=>{const l=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),o.forEach((function(t){n(e,t,r[t])}))}return e}({version:"6.0.0-alpha.7",channel:"Web",platform:"Web",buildType:a,locale:c,referrer:window.location.href,screenWidth:window.screen.width},o);if(s)return s;if(!i)return Promise.reject("no-client-key");const f=new t("checkout-attempt-id","sessionStorage"),p=f.get();return function(e){if(!(null==e?void 0:e.id))return!1;const t=Date.now()-9e5;return e.timestamp>t}(p)?Promise.resolve(p.id):(s=e(u,l).then((e=>{if(null==e?void 0:e.checkoutAttemptId)return f.set({id:e.checkoutAttemptId,timestamp:Date.now()}),e.checkoutAttemptId})).catch((()=>Promise.reject(r))),s)}};export{r as FAILURE_MSG,o as default};
|
|
2
2
|
//# sourceMappingURL=collect-id.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}const n=n=>t=>{const o=function(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),r.forEach((function(t){e(n,t,o[t])}))}return n}({version:"6.0.0-alpha.
|
|
1
|
+
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}const n=n=>t=>{const o=function(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter((function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable})))),r.forEach((function(t){e(n,t,o[t])}))}return n}({version:"6.0.0-alpha.7",payload_version:1,platform:"web",locale:n.locale},t),r=Object.keys(o).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(o[e])}`)).join("&");(new Image).src=`${n.loadingContext}images/analytics.png?${r}`};export{n as default};
|
|
2
2
|
//# sourceMappingURL=log-event.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import n from"./Analytics/Analytics.js";import{processGlobalOptions as i,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as h}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as v}from"./Analytics/constants.js";import{THREEDS2_FULL as g}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as b}from"../language/constants.js";import C from"./Services/get-translations.js";import{defaultProps as j}from"./core.defaultProps.js";import{formatLocale as w,formatCustomTranslations as O}from"../language/utils.js";import{resolveEnvironments as P}from"./Environment/Environment.js";function E(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function A(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},s=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),s.forEach((function(o){E(t,o,e[o])}))}return t}function M(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t,o){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}function x(t,o){if(null==t)return{};var e,s,n=function(t,o){if(null==t)return{};var e,s,n={},i=Object.keys(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||(n[e]=t[e]);return n}(t,o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}class R{static setBundleType(t){R.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:e,countryCode:s,paymentMethods:n}=t,i=x(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(M(A({},i),{amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s})),this.createPaymentMethodsList(n),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await C(this.cdnTranslationsUrl,R.metadata.version,this.options.locale,this.options.translations)}catch(n){var t,o,e,s;n instanceof y?null===(t=(o=this.options).onError)||void 0===t||t.call(o,n):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("ERROR","Failed to fetch translation",{cause:n}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:b}),this.options.locale=w(this.options.locale),this.options.translations=O(this.options.translations)}submitDetails(t){let o=null;var e,s;(this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>{var o,e;return null===(o=(e=this.options).onError)||void 0===o||o.call(e,t),Promise.reject(t)}))),o)?o.then(d).then(m).then((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentCompleted)||void 0===o||o.call(e,t)})).catch((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentFailed)||void 0===o||o.call(e,t)})):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const e=t.type===g?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:v,subtype:t.type,message:`${e} action was handled by the SDK`});const n=A({},this.getCorePropsForComponent(),o);return s(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return M(A({},i(this.options)),{core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction})}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){var o;const e=null!==(o=null==t?void 0:t.name)&&void 0!==o?o:"The passed payment method",s=t?`${e} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(s)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const e=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,M(A({},this.options),{loadingContext:this.loadingContext})),analytics:n({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:R.metadata.bundleType}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:e,customTranslations:this.options.translations}),srPanel:new h(this,A({},this.options.srConfig))})}constructor(t){var o;E(this,"session",void 0),E(this,"paymentMethodsResponse",void 0),E(this,"modules",void 0),E(this,"options",void 0),E(this,"analyticsContext",void 0),E(this,"loadingContext",void 0),E(this,"cdnImagesUrl",void 0),E(this,"cdnTranslationsUrl",void 0),E(this,"components",[]),E(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>o.update(t))),this)))))),E(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),E(this,"setOptions",(t=>{var o;this.options=M(A({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(o=this.options)||void 0===o?void 0:o.locale)})})),r(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions(A({},j,t));const{apiUrl:e,analyticsUrl:s,cdnImagesUrl:n,cdnTranslationsUrl:i}=P(this.options.environment,this.options._environmentUrls);this.loadingContext=e,this.analyticsContext=s,this.cdnImagesUrl=n,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(o=this.options.clientKey)||void 0===o?void 0:o.substr(0,4);var c;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=R.metadata)}}E(R,"metadata",{version:"6.0.0-alpha.
|
|
1
|
+
import{Language as t}from"../language/Language.js";import o from"./RiskModule/RiskModule.js";import e from"./ProcessResponse/PaymentMethods/PaymentMethods.js";import{getComponentForAction as s}from"./ProcessResponse/PaymentAction/PaymentAction.js";import n from"./Analytics/Analytics.js";import{processGlobalOptions as i,assertConfigurationPropertiesAreValid as r}from"./utils.js";import a from"./CheckoutSession/CheckoutSession.js";import{hasOwnProperty as l}from"../utils/hasOwnProperty.js";import{Resources as c}from"./Context/Resources.js";import{SRPanel as h}from"./Errors/SRPanel.js";import p from"./core.registry.js";import{sanitizeResponse as d,verifyPaymentDidNotFail as m,cleanupFinalResult as u}from"../components/internal/UIElement/utils.js";import y,{IMPLEMENTATION_ERROR as f}from"./Errors/AdyenCheckoutError.js";import{ANALYTICS_ACTION_STR as v}from"./Analytics/constants.js";import{THREEDS2_FULL as g}from"../components/ThreeDS2/constants.js";import{DEFAULT_LOCALE as b}from"../language/constants.js";import C from"./Services/get-translations.js";import{defaultProps as j}from"./core.defaultProps.js";import{formatLocale as w,formatCustomTranslations as O}from"../language/utils.js";import{resolveEnvironments as P}from"./Environment/Environment.js";function E(t,o,e){return o in t?Object.defineProperty(t,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[o]=e,t}function A(t){for(var o=1;o<arguments.length;o++){var e=null!=arguments[o]?arguments[o]:{},s=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(s=s.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),s.forEach((function(o){E(t,o,e[o])}))}return t}function M(t,o){return o=null!=o?o:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):function(t,o){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);e.push.apply(e,s)}return e}(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))})),t}function x(t,o){if(null==t)return{};var e,s,n=function(t,o){if(null==t)return{};var e,s,n={},i=Object.keys(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||(n[e]=t[e]);return n}(t,o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)e=i[s],o.indexOf(e)>=0||Object.prototype.propertyIsEnumerable.call(t,e)&&(n[e]=t[e])}return n}class R{static setBundleType(t){R.metadata.bundleType=t}static register(...t){p.add(...t)}register(...t){p.add(...t)}getComponent(t){return p.getComponent(t)}async initialize(){return await this.initializeCore(),this.validateCoreConfiguration(),await this.createCoreModules(),this}async initializeCore(){return this.session?this.session.setupSession(this.options).then((t=>{const{amount:o,shopperLocale:e,countryCode:s,paymentMethods:n}=t,i=x(t,["amount","shopperLocale","countryCode","paymentMethods"]);return this.setOptions(M(A({},i),{amount:this.options.order?this.options.order.remainingAmount:o,locale:this.options.locale||e,countryCode:this.options.countryCode||s})),this.createPaymentMethodsList(n),this})).catch((t=>(this.options.onError&&this.options.onError(t),Promise.reject(t)))):(this.createPaymentMethodsList(),Promise.resolve(this))}async fetchLocaleTranslations(){try{return await C(this.cdnTranslationsUrl,R.metadata.version,this.options.locale,this.options.translations)}catch(n){var t,o,e,s;n instanceof y?null===(t=(o=this.options).onError)||void 0===t||t.call(o,n):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("ERROR","Failed to fetch translation",{cause:n}))}}validateCoreConfiguration(){if(this.options.paymentMethodsConfiguration&&console.warn('WARNING: "paymentMethodsConfiguration" is supported only by Drop-in.'),!this.options.countryCode)throw new y(f,"You must specify a countryCode when initializing checkout.");this.options.locale||this.setOptions({locale:b}),this.options.locale=w(this.options.locale),this.options.translations=O(this.options.translations)}submitDetails(t){let o=null;var e,s;(this.options.onAdditionalDetails&&(o=new Promise(((o,e)=>{this.options.onAdditionalDetails({data:t},void 0,{resolve:o,reject:e})}))),this.session&&(o=this.session.submitDetails(t).catch((t=>{var o,e;return null===(o=(e=this.options).onError)||void 0===o||o.call(e,t),Promise.reject(t)}))),o)?o.then(d).then(m).then((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentCompleted)||void 0===o||o.call(e,t)})).catch((t=>{var o,e;u(t),null===(o=(e=this.options).onPaymentFailed)||void 0===o||o.call(e,t)})):null===(e=(s=this.options).onError)||void 0===e||e.call(s,new y("IMPLEMENTATION_ERROR",'It can not submit the details. The callback "onAdditionalDetails" or the Session is not setup correctly.'))}createFromAction(t,o={}){if(!t||!t.type){if(l(t,"action")&&l(t,"resultCode"))throw new Error('createFromAction::Invalid Action - the passed action object itself has an "action" property and a "resultCode": have you passed in the whole response object by mistake?');throw new Error('createFromAction::Invalid Action - the passed action object does not have a "type" property')}if(t.type){const e=t.type===g?`${t.type}${t.subtype}`:t.paymentMethodType;this.modules.analytics.sendAnalytics(e,{type:v,subtype:t.type,message:`${e} action was handled by the SDK`});const n=A({},this.getCorePropsForComponent(),o);return s(this,p,t,n)}return this.handleCreateError()}getCorePropsForComponent(){return M(A({},i(this.options)),{core:this,i18n:this.modules.i18n,modules:this.modules,session:this.session,loadingContext:this.loadingContext,cdnContext:this.cdnImagesUrl,createFromAction:this.createFromAction})}storeElementReference(t){t&&this.components.push(t)}handleCreateError(t){var o;const e=null!==(o=null==t?void 0:t.name)&&void 0!==o?o:"The passed payment method",s=t?`${e} is not a valid Checkout Component. What was passed as a txVariant was: ${JSON.stringify(t)}. Check if this payment method is configured in the Backoffice or if the txVariant is a valid one`:"No Payment Method component was passed";throw new Error(s)}createPaymentMethodsList(t){this.paymentMethodsResponse=new e(this.options.paymentMethodsResponse||t,this.options)}async createCoreModules(){if(this.modules)return;const e=await this.fetchLocaleTranslations();this.modules=Object.freeze({risk:new o(this,M(A({},this.options),{loadingContext:this.loadingContext})),analytics:n({loadingContext:this.loadingContext,analyticsContext:this.analyticsContext,clientKey:this.options.clientKey,locale:this.options.locale,analytics:this.options.analytics,amount:this.options.amount,bundleType:R.metadata.bundleType}),resources:new c(this.cdnImagesUrl),i18n:new t({locale:this.options.locale,translations:e,customTranslations:this.options.translations}),srPanel:new h(this,A({},this.options.srConfig))})}constructor(t){var o;E(this,"session",void 0),E(this,"paymentMethodsResponse",void 0),E(this,"modules",void 0),E(this,"options",void 0),E(this,"analyticsContext",void 0),E(this,"loadingContext",void 0),E(this,"cdnImagesUrl",void 0),E(this,"cdnTranslationsUrl",void 0),E(this,"components",[]),E(this,"update",((t={})=>(this.setOptions(t),this.initialize().then((()=>(this.components.forEach((o=>o.update(t))),this)))))),E(this,"remove",(t=>(this.components=this.components.filter((o=>o._id!==t._id)),t.unmount(),this))),E(this,"setOptions",(t=>{var o;this.options=M(A({},this.options,t),{locale:(null==t?void 0:t.locale)||(null===(o=this.options)||void 0===o?void 0:o.locale)})})),r(t),this.createFromAction=this.createFromAction.bind(this),this.setOptions(A({},j,t));const{apiUrl:e,analyticsUrl:s,cdnImagesUrl:n,cdnTranslationsUrl:i}=P(this.options.environment,this.options._environmentUrls);this.loadingContext=e,this.analyticsContext=s,this.cdnImagesUrl=n,this.cdnTranslationsUrl=i,this.session=this.options.session&&new a(this.options.session,this.options.clientKey,this.loadingContext);const l=null===(o=this.options.clientKey)||void 0===o?void 0:o.substr(0,4);var c;if(("test"===l||"live"===l)&&!this.loadingContext.includes(l))throw new y("IMPLEMENTATION_ERROR",`Error: you are using a ${l} clientKey against the ${(null===(c=this.options._environmentUrls)||void 0===c?void 0:c.api)||this.options.environment} environment`);this.options.exposeLibraryMetadata&&(window.AdyenWebMetadata=R.metadata)}}E(R,"metadata",{version:"6.0.0-alpha.7",bundleType:"eslegacy"}),E(R,"registry",p);export{R as default};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"../components/ThreeDS2/ThreeDS2Challenge.js";import t from"../components/ThreeDS2/ThreeDS2DeviceFingerprint.js";import r from"../components/Redirect/Redirect.js";import{TxVariants as n}from"../components/tx-variants.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){o(e,t,r[t])}))}return e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const i={[n.redirect]:r,[n.threeDS2Challenge]:e,[n.threeDS2DeviceFingerprint]:t};
|
|
1
|
+
import e from"../components/ThreeDS2/ThreeDS2Challenge.js";import t from"../components/ThreeDS2/ThreeDS2DeviceFingerprint.js";import r from"../components/Redirect/Redirect.js";import{TxVariants as n}from"../components/tx-variants.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})))),n.forEach((function(t){o(e,t,r[t])}))}return e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r.push.apply(r,n)}return r}(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})),e}const i={[n.redirect]:r,[n.threeDS2Challenge]:e,[n.threeDS2DeviceFingerprint]:t};var p=new class{add(...e){this.componentsMap=s({},this.componentsMap,this.createComponentsMap(e))}getComponent(e){const t=this.componentsMap[e];return t||(this.supportedTxVariants.has(e)?void 0:r)}createComponentsMap(e){return e.reduce(((e,t)=>{var r;if(!("string"==typeof(r=t).type&&!!r.type))return console.error("CoreRegistry: Attempt to register Class failed. The Class is not a valid UIElement"),e;return[t.type,...t.txVariants].filter((e=>e)).forEach((r=>{e=c(s({},e),{[r]:t})})),e}),{})}constructor(){o(this,"componentsMap",i),o(this,"supportedTxVariants",new Set(Object.values(n)))}};export{p as default};
|
|
2
2
|
//# sourceMappingURL=core.registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.registry.js","sources":["../../../src/core/core.registry.ts"],"sourcesContent":["import UIElement from '../components/internal/UIElement/UIElement';\nimport ThreeDS2Challenge from '../components/ThreeDS2/ThreeDS2Challenge';\nimport ThreeDS2DeviceFingerprint from '../components/ThreeDS2/ThreeDS2DeviceFingerprint';\nimport Redirect from '../components/Redirect';\nimport { TxVariants } from '../components/tx-variants';\nimport type { ICore } from './types';\nimport type { IUIElement } from '../components/internal/UIElement/types';\n\nfunction assertClassHasType(Class: any): Class is typeof UIElement {\n const hasValidType = typeof Class.type === 'string' && !!Class.type;\n return hasValidType;\n}\n\nexport type NewableComponent = new (checkout: ICore, props?) => IUIElement;\n\nexport interface IRegistry {\n add(...items: NewableComponent[]): void;\n getComponent(type: string): NewableComponent | undefined;\n}\n\nconst defaultComponents = {\n [TxVariants.redirect]: Redirect,\n [TxVariants.threeDS2Challenge]: ThreeDS2Challenge,\n [TxVariants.threeDS2DeviceFingerprint]: ThreeDS2DeviceFingerprint\n};\n\nclass Registry implements IRegistry {\n public componentsMap: Record<string, NewableComponent> = defaultComponents;\n\n public supportedTxVariants: Set<string> = new Set(Object.values(TxVariants));\n\n public add(...items: NewableComponent[]) {\n this.componentsMap = {\n ...this.componentsMap,\n ...this.createComponentsMap(items)\n };\n }\n\n public getComponent(type: string): NewableComponent | undefined {\n const Component = this.componentsMap[type];\n if (Component) {\n return Component;\n }\n\n if (this.supportedTxVariants.has(type)) {\n return;\n }\n\n return Redirect;\n }\n\n public createComponentsMap(components: NewableComponent[]) {\n const componentsMap = components.reduce((memo, component) => {\n const isValid = assertClassHasType(component);\n\n if (!isValid) {\n console.error('CoreRegistry: Attempt to register Class failed. The Class is not a valid UIElement');\n return memo;\n }\n\n const supportedTxVariants = [component.type, ...component.txVariants].filter(txVariant => txVariant);\n\n supportedTxVariants.forEach(txVariant => {\n memo = {\n ...memo,\n [txVariant]: component\n };\n });\n\n return memo;\n }, {});\n\n return componentsMap;\n }\n}\n\
|
|
1
|
+
{"version":3,"file":"core.registry.js","sources":["../../../src/core/core.registry.ts"],"sourcesContent":["import UIElement from '../components/internal/UIElement/UIElement';\nimport ThreeDS2Challenge from '../components/ThreeDS2/ThreeDS2Challenge';\nimport ThreeDS2DeviceFingerprint from '../components/ThreeDS2/ThreeDS2DeviceFingerprint';\nimport Redirect from '../components/Redirect';\nimport { TxVariants } from '../components/tx-variants';\nimport type { ICore } from './types';\nimport type { IUIElement } from '../components/internal/UIElement/types';\n\nfunction assertClassHasType(Class: any): Class is typeof UIElement {\n const hasValidType = typeof Class.type === 'string' && !!Class.type;\n return hasValidType;\n}\n\nexport type NewableComponent = new (checkout: ICore, props?) => IUIElement;\n\nexport interface IRegistry {\n add(...items: NewableComponent[]): void;\n getComponent(type: string): NewableComponent | undefined;\n}\n\nconst defaultComponents = {\n [TxVariants.redirect]: Redirect,\n [TxVariants.threeDS2Challenge]: ThreeDS2Challenge,\n [TxVariants.threeDS2DeviceFingerprint]: ThreeDS2DeviceFingerprint\n};\n\nclass Registry implements IRegistry {\n public componentsMap: Record<string, NewableComponent> = defaultComponents;\n\n public supportedTxVariants: Set<string> = new Set(Object.values(TxVariants));\n\n public add(...items: NewableComponent[]) {\n this.componentsMap = {\n ...this.componentsMap,\n ...this.createComponentsMap(items)\n };\n }\n\n public getComponent(type: string): NewableComponent | undefined {\n const Component = this.componentsMap[type];\n if (Component) {\n return Component;\n }\n\n if (this.supportedTxVariants.has(type)) {\n return;\n }\n\n return Redirect;\n }\n\n public createComponentsMap(components: NewableComponent[]) {\n const componentsMap = components.reduce((memo, component) => {\n const isValid = assertClassHasType(component);\n\n if (!isValid) {\n console.error('CoreRegistry: Attempt to register Class failed. The Class is not a valid UIElement');\n return memo;\n }\n\n const supportedTxVariants = [component.type, ...component.txVariants].filter(txVariant => txVariant);\n\n supportedTxVariants.forEach(txVariant => {\n memo = {\n ...memo,\n [txVariant]: component\n };\n });\n\n return memo;\n }, {});\n\n return componentsMap;\n }\n}\n\nexport default new Registry();\n"],"names":["defaultComponents","TxVariants","redirect","Redirect","threeDS2Challenge","ThreeDS2Challenge","threeDS2DeviceFingerprint","ThreeDS2DeviceFingerprint","registry","add","items","this","componentsMap","_object_spread","createComponentsMap","getComponent","type","Component","supportedTxVariants","has","components","reduce","memo","component","Class","console","error","txVariants","filter","txVariant","forEach","_object_spread_props","_define_property","Set","Object","values"],"mappings":"2hCAoBA,MAAMA,EAAoB,CACtB,CAACC,EAAWC,UAAWC,EACvB,CAACF,EAAWG,mBAAoBC,EAChC,CAACJ,EAAWK,2BAA4BC,GAqD5C,IAAeC,EAAA,IAlDf,MAKWC,GAAAA,IAAOC,GACVC,KAAKC,cAAgBC,EACd,GAAAF,KAAKC,cACLD,KAAKG,oBAAoBJ,GAEpC,CAEOK,YAAAA,CAAaC,GAChB,MAAMC,EAAYN,KAAKC,cAAcI,GACrC,OAAIC,IAIAN,KAAKO,oBAAoBC,IAAIH,QAAjC,EAIOb,EACX,CAEOW,mBAAAA,CAAoBM,GAqBvB,OApBsBA,EAAWC,QAAO,CAACC,EAAMC,KA5CvD,IAA4BC,EA+ChB,KA9CmC,iBADnBA,EA6CmBD,GA5CTP,QAAuBQ,EAAMR,MAgDnD,OADAS,QAAQC,MAAM,sFACPJ,EAYX,MAT4B,CAACC,EAAUP,QAASO,EAAUI,YAAYC,QAAOC,GAAaA,IAEtEC,SAAQD,IACxBP,EAAOS,EACAT,EAAAA,CAAAA,EAAAA,GAAAA,CACHO,CAACA,GAAYN,OAIdD,CAAAA,GACR,CAAC,EAGR,eA9CAU,EAAArB,KAAOC,gBAAkDZ,GAEzDgC,EAAArB,KAAOO,sBAAmC,IAAIe,IAAIC,OAAOC,OAAOlC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e,n,_,t,o,l,r,u,i,s,c,f={},p=[],a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,d=Array.isArray;function h(e,n){for(var _ in n)e[_]=n[_];return e}function v(e){var n=e.parentNode;n&&n.removeChild(e)}function y(n,_,t){var o,l,r,u={};for(r in _)"key"==r?o=_[r]:"ref"==r?l=_[r]:u[r]=_[r];if(arguments.length>2&&(u.children=arguments.length>3?e.call(arguments,2):t),"function"==typeof n&&null!=n.defaultProps)for(r in n.defaultProps)void 0===u[r]&&(u[r]=n.defaultProps[r]);return m(n,u,o,l,null)}function m(e,t,o,l,r){var u={type:e,props:t,key:o,ref:l,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++_:r,__i:-1,__u:0};return null==r&&null!=n.vnode&&n.vnode(u),u}function g(e){return e.children}function k(e,n){this.props=e,this.context=n}function b(e,n){if(null==n)return e.__?b(e.__,e.__i+1):null;for(var _;n<e.__k.length;n++)if(null!=(_=e.__k[n])&&null!=_.__e)return _.__e;return"function"==typeof e.type?b(e):null}function C(e){var n,_;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,n=0;n<e.__k.length;n++)if(null!=(_=e.__k[n])&&null!=_.__e){e.__e=e.__c.base=_.__e;break}return C(e)}}function x(e){(!e.__d&&(e.__d=!0)&&t.push(e)&&!P.__r++||o!==n.debounceRendering)&&((o=n.debounceRendering)||l)(P)}function P(){var e,_,o,l,u,i,s,c;for(t.sort(r);e=t.shift();)e.__d&&(_=t.length,l=void 0,i=(u=(o=e).__v).__e,s=[],c=[],o.__P&&((l=h({},u)).__v=u.__v+1,n.vnode&&n.vnode(l),L(o.__P,l,u,o.__n,void 0!==o.__P.ownerSVGElement,32&u.__u?[i]:null,s,null==i?b(u):i,!!(32&u.__u),c),l.__v=u.__v,l.__.__k[l.__i]=l,M(s,l,c),l.__e!=i&&C(l)),t.length>_&&t.sort(r));P.__r=0}function S(e,n,_,t,o,l,r,u,i,s,c){var a,d,h,v,y,m=t&&t.__k||p,g=n.length;for(_.__d=i,w(_,n,m),i=_.__d,a=0;a<g;a++)null!=(h=_.__k[a])&&"boolean"!=typeof h&&"function"!=typeof h&&(d=-1===h.__i?f:m[h.__i]||f,h.__i=a,L(e,h,d,o,l,r,u,i,s,c),v=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&A(d.ref,null,h),c.push(h.ref,h.__c||v,h)),null==y&&null!=v&&(y=v),65536&h.__u||d.__k===h.__k?(i&&!i.isConnected&&(i=b(d)),i=E(h,i,e)):"function"==typeof h.type&&void 0!==h.__d?i=h.__d:v&&(i=v.nextSibling),h.__d=void 0,h.__u&=-196609);_.__d=i,_.__e=y}function w(e,n,_){var t,o,l,r,u,i=n.length,s=_.length,c=s,f=0;for(e.__k=[],t=0;t<i;t++)r=t+f,null!=(o=e.__k[t]=null==(o=n[t])||"boolean"==typeof o||"function"==typeof o?null:"string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?m(null,o,null,null,null):d(o)?m(g,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?m(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o)?(o.__=e,o.__b=e.__b+1,u=T(o,_,r,c),o.__i=u,l=null,-1!==u&&(c--,(l=_[u])&&(l.__u|=131072)),null==l||null===l.__v?(-1==u&&f--,"function"!=typeof o.type&&(o.__u|=65536)):u!==r&&(u===r+1?f++:u>r?c>i-r?f+=u-r:f--:u<r?u==r-1&&(f=u-r):f=0,u!==t+f&&(o.__u|=65536))):(l=_[r])&&null==l.key&&l.__e&&!(131072&l.__u)&&(l.__e==e.__d&&(e.__d=b(l)),H(l,l,!1),_[r]=null,c--);if(c)for(t=0;t<s;t++)null!=(l=_[t])&&!(131072&l.__u)&&(l.__e==e.__d&&(e.__d=b(l)),H(l,l))}function E(e,n,_){var t,o;if("function"==typeof e.type){for(t=e.__k,o=0;t&&o<t.length;o++)t[o]&&(t[o].__=e,n=E(t[o],n,_));return n}e.__e!=n&&(_.insertBefore(e.__e,n||null),n=e.__e);do{n=n&&n.nextSibling}while(null!=n&&8===n.nodeType);return n}function U(e,n){return n=n||[],null==e||"boolean"==typeof e||(d(e)?e.some((function(e){U(e,n)})):n.push(e)),n}function T(e,n,_,t){var o=e.key,l=e.type,r=_-1,u=_+1,i=n[_];if(null===i||i&&o==i.key&&l===i.type&&!(131072&i.__u))return _;if(t>(null==i||131072&i.__u?0:1))for(;r>=0||u<n.length;){if(r>=0){if((i=n[r])&&!(131072&i.__u)&&o==i.key&&l===i.type)return r;r--}if(u<n.length){if((i=n[u])&&!(131072&i.__u)&&o==i.key&&l===i.type)return u;u++}}return-1}function D(e,n,_){"-"===n[0]?e.setProperty(n,null==_?"":_):e[n]=null==_?"":"number"!=typeof _||a.test(n)?_:_+"px"}function W(e,n,_,t,o){var l;e:if("style"===n)if("string"==typeof _)e.style.cssText=_;else{if("string"==typeof t&&(e.style.cssText=t=""),t)for(n in t)_&&n in _||D(e.style,n,"");if(_)for(n in _)t&&_[n]===t[n]||D(e.style,n,_[n])}else if("o"===n[0]&&"n"===n[1])l=n!==(n=n.replace(/(PointerCapture)$|Capture$/i,"$1")),n=n.toLowerCase()in e||"onFocusOut"===n||"onFocusIn"===n?n.toLowerCase().slice(2):n.slice(2),e.l||(e.l={}),e.l[n+l]=_,_?t?_.u=t.u:(_.u=u,e.addEventListener(n,l?s:i,l)):e.removeEventListener(n,l?s:i,l);else{if(o)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&n in e)try{e[n]=null==_?"":_;break e}catch(e){}"function"==typeof _||(null==_||!1===_&&"-"!==n[4]?e.removeAttribute(n):e.setAttribute(n,_))}}function F(e){return function(_){if(this.l){var t=this.l[_.type+e];if(null==_.t)_.t=u++;else if(_.t<t.u)return;return t(n.event?n.event(_):_)}}}function L(e,_,t,o,l,r,u,i,s,c){var f,p,a,v,y,m,b,C,x,P,w,E,U,T,D,W=_.type;if(void 0!==_.constructor)return null;128&t.__u&&(s=!!(32&t.__u),r=[i=_.__e=t.__e]),(f=n.__b)&&f(_);e:if("function"==typeof W)try{if(C=_.props,x=(f=W.contextType)&&o[f.__c],P=f?x?x.props.value:f.__:o,t.__c?b=(p=_.__c=t.__c).__=p.__E:("prototype"in W&&W.prototype.render?_.__c=p=new W(C,P):(_.__c=p=new k(C,P),p.constructor=W,p.render=$),x&&x.sub(p),p.props=C,p.state||(p.state={}),p.context=P,p.__n=o,a=p.__d=!0,p.__h=[],p._sb=[]),null==p.__s&&(p.__s=p.state),null!=W.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=h({},p.__s)),h(p.__s,W.getDerivedStateFromProps(C,p.__s))),v=p.props,y=p.state,p.__v=_,a)null==W.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==W.getDerivedStateFromProps&&C!==v&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(C,P),!p.__e&&(null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(C,p.__s,P)||_.__v===t.__v)){for(_.__v!==t.__v&&(p.props=C,p.state=p.__s,p.__d=!1),_.__e=t.__e,_.__k=t.__k,_.__k.forEach((function(e){e&&(e.__=_)})),w=0;w<p._sb.length;w++)p.__h.push(p._sb[w]);p._sb=[],p.__h.length&&u.push(p);break e}null!=p.componentWillUpdate&&p.componentWillUpdate(C,p.__s,P),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(v,y,m)}))}if(p.context=P,p.props=C,p.__P=e,p.__e=!1,E=n.__r,U=0,"prototype"in W&&W.prototype.render){for(p.state=p.__s,p.__d=!1,E&&E(_),f=p.render(p.props,p.state,p.context),T=0;T<p._sb.length;T++)p.__h.push(p._sb[T]);p._sb=[]}else do{p.__d=!1,E&&E(_),f=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++U<25);p.state=p.__s,null!=p.getChildContext&&(o=h(h({},o),p.getChildContext())),a||null==p.getSnapshotBeforeUpdate||(m=p.getSnapshotBeforeUpdate(v,y)),S(e,d(D=null!=f&&f.type===g&&null==f.key?f.props.children:f)?D:[D],_,t,o,l,r,u,i,s,c),p.base=_.__e,_.__u&=-161,p.__h.length&&u.push(p),b&&(p.__E=p.__=null)}catch(e){_.__v=null,s||null!=r?(_.__e=i,_.__u|=s?160:32,r[r.indexOf(i)]=null):(_.__e=t.__e,_.__k=t.__k),n.__e(e,_,t)}else null==r&&_.__v===t.__v?(_.__k=t.__k,_.__e=t.__e):_.__e=N(t.__e,_,t,o,l,r,u,s,c);(f=n.diffed)&&f(_)}function M(e,_,t){_.__d=void 0;for(var o=0;o<t.length;o++)A(t[o],t[++o],t[++o]);n.__c&&n.__c(_,e),e.some((function(_){try{e=_.__h,_.__h=[],e.some((function(e){e.call(_)}))}catch(e){n.__e(e,_.__v)}}))}function N(n,_,t,o,l,r,u,i,s){var c,p,a,h,y,m,g,k=t.props,C=_.props,x=_.type;if("svg"===x&&(l=!0),null!=r)for(c=0;c<r.length;c++)if((y=r[c])&&"setAttribute"in y==!!x&&(x?y.localName===x:3===y.nodeType)){n=y,r[c]=null;break}if(null==n){if(null===x)return document.createTextNode(C);n=l?document.createElementNS("http://www.w3.org/2000/svg",x):document.createElement(x,C.is&&C),r=null,i=!1}if(null===x)k===C||i&&n.data===C||(n.data=C);else{if(r=r&&e.call(n.childNodes),k=t.props||f,!i&&null!=r)for(k={},c=0;c<n.attributes.length;c++)k[(y=n.attributes[c]).name]=y.value;for(c in k)y=k[c],"children"==c||("dangerouslySetInnerHTML"==c?a=y:"key"===c||c in C||W(n,c,null,y,l));for(c in C)y=C[c],"children"==c?h=y:"dangerouslySetInnerHTML"==c?p=y:"value"==c?m=y:"checked"==c?g=y:"key"===c||i&&"function"!=typeof y||k[c]===y||W(n,c,y,k[c],l);if(p)i||a&&(p.__html===a.__html||p.__html===n.innerHTML)||(n.innerHTML=p.__html),_.__k=[];else if(a&&(n.innerHTML=""),S(n,d(h)?h:[h],_,t,o,l&&"foreignObject"!==x,r,u,r?r[0]:t.__k&&b(t,0),i,s),null!=r)for(c=r.length;c--;)null!=r[c]&&v(r[c]);i||(c="value",void 0!==m&&(m!==n[c]||"progress"===x&&!m||"option"===x&&m!==k[c])&&W(n,c,m,k[c],!1),c="checked",void 0!==g&&g!==n[c]&&W(n,c,g,k[c],!1))}return n}function A(e,_,t){try{"function"==typeof e?e(_):e.current=_}catch(e){n.__e(e,t)}}function H(e,_,t){var o,l;if(n.unmount&&n.unmount(e),(o=e.ref)&&(o.current&&o.current!==e.__e||A(o,null,_)),null!=(o=e.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(e){n.__e(e,_)}o.base=o.__P=null}if(o=e.__k)for(l=0;l<o.length;l++)o[l]&&H(o[l],_,t||"function"!=typeof e.type);t||null==e.__e||v(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function $(e,n,_){return this.constructor(e,_)}function I(_,t,o){var l,r,u,i;n.__&&n.__(_,t),r=(l="function"==typeof o)?null:t.__k,u=[],i=[],L(t,_=(!l&&o||t).__k=y(g,null,[_]),r||f,f,void 0!==t.ownerSVGElement,!l&&o?[o]:r?null:t.firstChild?e.call(t.childNodes):null,u,!l&&o?o:r?r.__e:t.firstChild,l,i),M(u,_,i)}function O(n,_,t){var o,l,r,u,i=h({},n.props);for(r in n.type&&n.type.defaultProps&&(u=n.type.defaultProps),_)"key"==r?o=_[r]:"ref"==r?l=_[r]:i[r]=void 0===_[r]&&void 0!==u?u[r]:_[r];return arguments.length>2&&(i.children=arguments.length>3?e.call(arguments,2):t),m(n.type,i,o||n.key,l||n.ref,null)}function R(e,n){var _={__c:n="__cC"+c++,__:e,Consumer:function(e,n){return e.children(n)},Provider:function(e){var _,t;return this.getChildContext||(_=[],(t={})[n]=this,this.getChildContext=function(){return t},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&_.some((function(e){e.__e=!0,x(e)}))},this.sub=function(e){_.push(e);var n=e.componentWillUnmount;e.componentWillUnmount=function(){_.splice(_.indexOf(e),1),n&&n.call(e)}}),e.children}};return _.Provider.__=_.Consumer.contextType=_}e=p.slice,n={__e:function(e,n,_,t){for(var o,l,r;n=n.__;)if((o=n.__c)&&!o.__)try{if((l=o.constructor)&&null!=l.getDerivedStateFromError&&(o.setState(l.getDerivedStateFromError(e)),r=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,t||{}),r=o.__d),r)return o.__E=o}catch(n){e=n}throw e}},_=0,k.prototype.setState=function(e,n){var _;_=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof e&&(e=e(h({},_),this.props)),e&&h(_,e),null!=e&&this.__v&&(n&&this._sb.push(n),x(this))},k.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),x(this))},k.prototype.render=g,t=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,r=function(e,n){return e.__v.__b-n.__v.__b},P.__r=0,u=0,i=F(!1),s=F(!0),c=0;export{k as Component,g as Fragment,O as cloneElement,R as createContext,y as createElement,y as h,n as options,I as render,U as toChildArray};
|
|
1
|
+
var e,n,_,t,o,l,r,u,i,s,c,f={},p=[],a=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,d=Array.isArray;function h(e,n){for(var _ in n)e[_]=n[_];return e}function v(e){var n=e.parentNode;n&&n.removeChild(e)}function y(n,_,t){var o,l,r,u={};for(r in _)"key"==r?o=_[r]:"ref"==r?l=_[r]:u[r]=_[r];if(arguments.length>2&&(u.children=arguments.length>3?e.call(arguments,2):t),"function"==typeof n&&null!=n.defaultProps)for(r in n.defaultProps)void 0===u[r]&&(u[r]=n.defaultProps[r]);return m(n,u,o,l,null)}function m(e,t,o,l,r){var u={type:e,props:t,key:o,ref:l,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++_:r,__i:-1,__u:0};return null==r&&null!=n.vnode&&n.vnode(u),u}function g(e){return e.children}function k(e,n){this.props=e,this.context=n}function b(e,n){if(null==n)return e.__?b(e.__,e.__i+1):null;for(var _;n<e.__k.length;n++)if(null!=(_=e.__k[n])&&null!=_.__e)return _.__e;return"function"==typeof e.type?b(e):null}function C(e){var n,_;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,n=0;n<e.__k.length;n++)if(null!=(_=e.__k[n])&&null!=_.__e){e.__e=e.__c.base=_.__e;break}return C(e)}}function x(e){(!e.__d&&(e.__d=!0)&&t.push(e)&&!P.__r++||o!==n.debounceRendering)&&((o=n.debounceRendering)||l)(P)}function P(){var e,_,o,l,u,i,s,c;for(t.sort(r);e=t.shift();)e.__d&&(_=t.length,l=void 0,i=(u=(o=e).__v).__e,s=[],c=[],o.__P&&((l=h({},u)).__v=u.__v+1,n.vnode&&n.vnode(l),L(o.__P,l,u,o.__n,void 0!==o.__P.ownerSVGElement,32&u.__u?[i]:null,s,null==i?b(u):i,!!(32&u.__u),c),l.__v=u.__v,l.__.__k[l.__i]=l,M(s,l,c),l.__e!=i&&C(l)),t.length>_&&t.sort(r));P.__r=0}function S(e,n,_,t,o,l,r,u,i,s,c){var a,d,h,v,y,m=t&&t.__k||p,g=n.length;for(_.__d=i,w(_,n,m),i=_.__d,a=0;a<g;a++)null!=(h=_.__k[a])&&"boolean"!=typeof h&&"function"!=typeof h&&(d=-1===h.__i?f:m[h.__i]||f,h.__i=a,L(e,h,d,o,l,r,u,i,s,c),v=h.__e,h.ref&&d.ref!=h.ref&&(d.ref&&A(d.ref,null,h),c.push(h.ref,h.__c||v,h)),null==y&&null!=v&&(y=v),65536&h.__u||d.__k===h.__k?(i&&!i.isConnected&&(i=b(d)),i=E(h,i,e)):"function"==typeof h.type&&void 0!==h.__d?i=h.__d:v&&(i=v.nextSibling),h.__d=void 0,h.__u&=-196609);_.__d=i,_.__e=y}function w(e,n,_){var t,o,l,r,u,i=n.length,s=_.length,c=s,f=0;for(e.__k=[],t=0;t<i;t++)r=t+f,null!=(o=e.__k[t]=null==(o=n[t])||"boolean"==typeof o||"function"==typeof o?null:"string"==typeof o||"number"==typeof o||"bigint"==typeof o||o.constructor==String?m(null,o,null,null,null):d(o)?m(g,{children:o},null,null,null):void 0===o.constructor&&o.__b>0?m(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o)?(o.__=e,o.__b=e.__b+1,u=T(o,_,r,c),o.__i=u,l=null,-1!==u&&(c--,(l=_[u])&&(l.__u|=131072)),null==l||null===l.__v?(-1==u&&f--,"function"!=typeof o.type&&(o.__u|=65536)):u!==r&&(u===r+1?f++:u>r?c>i-r?f+=u-r:f--:u<r?u==r-1&&(f=u-r):f=0,u!==t+f&&(o.__u|=65536))):(l=_[r])&&null==l.key&&l.__e&&!(131072&l.__u)&&(l.__e==e.__d&&(e.__d=b(l)),H(l,l,!1),_[r]=null,c--);if(c)for(t=0;t<s;t++)null!=(l=_[t])&&!(131072&l.__u)&&(l.__e==e.__d&&(e.__d=b(l)),H(l,l))}function E(e,n,_){var t,o;if("function"==typeof e.type){for(t=e.__k,o=0;t&&o<t.length;o++)t[o]&&(t[o].__=e,n=E(t[o],n,_));return n}e.__e!=n&&(_.insertBefore(e.__e,n||null),n=e.__e);do{n=n&&n.nextSibling}while(null!=n&&8===n.nodeType);return n}function U(e,n){return n=n||[],null==e||"boolean"==typeof e||(d(e)?e.some((function(e){U(e,n)})):n.push(e)),n}function T(e,n,_,t){var o=e.key,l=e.type,r=_-1,u=_+1,i=n[_];if(null===i||i&&o==i.key&&l===i.type&&!(131072&i.__u))return _;if(t>(null==i||131072&i.__u?0:1))for(;r>=0||u<n.length;){if(r>=0){if((i=n[r])&&!(131072&i.__u)&&o==i.key&&l===i.type)return r;r--}if(u<n.length){if((i=n[u])&&!(131072&i.__u)&&o==i.key&&l===i.type)return u;u++}}return-1}function D(e,n,_){"-"===n[0]?e.setProperty(n,null==_?"":_):e[n]=null==_?"":"number"!=typeof _||a.test(n)?_:_+"px"}function W(e,n,_,t,o){var l;e:if("style"===n)if("string"==typeof _)e.style.cssText=_;else{if("string"==typeof t&&(e.style.cssText=t=""),t)for(n in t)_&&n in _||D(e.style,n,"");if(_)for(n in _)t&&_[n]===t[n]||D(e.style,n,_[n])}else if("o"===n[0]&&"n"===n[1])l=n!==(n=n.replace(/(PointerCapture)$|Capture$/i,"$1")),n=n.toLowerCase()in e||"onFocusOut"===n||"onFocusIn"===n?n.toLowerCase().slice(2):n.slice(2),e.l||(e.l={}),e.l[n+l]=_,_?t?_.u=t.u:(_.u=u,e.addEventListener(n,l?s:i,l)):e.removeEventListener(n,l?s:i,l);else{if(o)n=n.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=n&&"height"!=n&&"href"!=n&&"list"!=n&&"form"!=n&&"tabIndex"!=n&&"download"!=n&&"rowSpan"!=n&&"colSpan"!=n&&"role"!=n&&n in e)try{e[n]=null==_?"":_;break e}catch(e){}"function"==typeof _||(null==_||!1===_&&"-"!==n[4]?e.removeAttribute(n):e.setAttribute(n,_))}}function F(e){return function(_){if(this.l){var t=this.l[_.type+e];if(null==_.t)_.t=u++;else if(_.t<t.u)return;return t(n.event?n.event(_):_)}}}function L(e,_,t,o,l,r,u,i,s,c){var f,p,a,v,y,m,b,C,x,P,w,E,U,T,D,W=_.type;if(void 0!==_.constructor)return null;128&t.__u&&(s=!!(32&t.__u),r=[i=_.__e=t.__e]),(f=n.__b)&&f(_);e:if("function"==typeof W)try{if(C=_.props,x=(f=W.contextType)&&o[f.__c],P=f?x?x.props.value:f.__:o,t.__c?b=(p=_.__c=t.__c).__=p.__E:("prototype"in W&&W.prototype.render?_.__c=p=new W(C,P):(_.__c=p=new k(C,P),p.constructor=W,p.render=$),x&&x.sub(p),p.props=C,p.state||(p.state={}),p.context=P,p.__n=o,a=p.__d=!0,p.__h=[],p._sb=[]),null==p.__s&&(p.__s=p.state),null!=W.getDerivedStateFromProps&&(p.__s==p.state&&(p.__s=h({},p.__s)),h(p.__s,W.getDerivedStateFromProps(C,p.__s))),v=p.props,y=p.state,p.__v=_,a)null==W.getDerivedStateFromProps&&null!=p.componentWillMount&&p.componentWillMount(),null!=p.componentDidMount&&p.__h.push(p.componentDidMount);else{if(null==W.getDerivedStateFromProps&&C!==v&&null!=p.componentWillReceiveProps&&p.componentWillReceiveProps(C,P),!p.__e&&(null!=p.shouldComponentUpdate&&!1===p.shouldComponentUpdate(C,p.__s,P)||_.__v===t.__v)){for(_.__v!==t.__v&&(p.props=C,p.state=p.__s,p.__d=!1),_.__e=t.__e,_.__k=t.__k,_.__k.forEach((function(e){e&&(e.__=_)})),w=0;w<p._sb.length;w++)p.__h.push(p._sb[w]);p._sb=[],p.__h.length&&u.push(p);break e}null!=p.componentWillUpdate&&p.componentWillUpdate(C,p.__s,P),null!=p.componentDidUpdate&&p.__h.push((function(){p.componentDidUpdate(v,y,m)}))}if(p.context=P,p.props=C,p.__P=e,p.__e=!1,E=n.__r,U=0,"prototype"in W&&W.prototype.render){for(p.state=p.__s,p.__d=!1,E&&E(_),f=p.render(p.props,p.state,p.context),T=0;T<p._sb.length;T++)p.__h.push(p._sb[T]);p._sb=[]}else do{p.__d=!1,E&&E(_),f=p.render(p.props,p.state,p.context),p.state=p.__s}while(p.__d&&++U<25);p.state=p.__s,null!=p.getChildContext&&(o=h(h({},o),p.getChildContext())),a||null==p.getSnapshotBeforeUpdate||(m=p.getSnapshotBeforeUpdate(v,y)),S(e,d(D=null!=f&&f.type===g&&null==f.key?f.props.children:f)?D:[D],_,t,o,l,r,u,i,s,c),p.base=_.__e,_.__u&=-161,p.__h.length&&u.push(p),b&&(p.__E=p.__=null)}catch(e){_.__v=null,s||null!=r?(_.__e=i,_.__u|=s?160:32,r[r.indexOf(i)]=null):(_.__e=t.__e,_.__k=t.__k),n.__e(e,_,t)}else null==r&&_.__v===t.__v?(_.__k=t.__k,_.__e=t.__e):_.__e=N(t.__e,_,t,o,l,r,u,s,c);(f=n.diffed)&&f(_)}function M(e,_,t){_.__d=void 0;for(var o=0;o<t.length;o++)A(t[o],t[++o],t[++o]);n.__c&&n.__c(_,e),e.some((function(_){try{e=_.__h,_.__h=[],e.some((function(e){e.call(_)}))}catch(e){n.__e(e,_.__v)}}))}function N(n,_,t,o,l,r,u,i,s){var c,p,a,h,y,m,g,k=t.props,C=_.props,x=_.type;if("svg"===x&&(l=!0),null!=r)for(c=0;c<r.length;c++)if((y=r[c])&&"setAttribute"in y==!!x&&(x?y.localName===x:3===y.nodeType)){n=y,r[c]=null;break}if(null==n){if(null===x)return document.createTextNode(C);n=l?document.createElementNS("http://www.w3.org/2000/svg",x):document.createElement(x,C.is&&C),r=null,i=!1}if(null===x)k===C||i&&n.data===C||(n.data=C);else{if(r=r&&e.call(n.childNodes),k=t.props||f,!i&&null!=r)for(k={},c=0;c<n.attributes.length;c++)k[(y=n.attributes[c]).name]=y.value;for(c in k)if(y=k[c],"children"==c);else if("dangerouslySetInnerHTML"==c)a=y;else if("key"!==c&&!(c in C)){if("value"==c&&"defaultValue"in C||"checked"==c&&"defaultChecked"in C)continue;W(n,c,null,y,l)}for(c in C)y=C[c],"children"==c?h=y:"dangerouslySetInnerHTML"==c?p=y:"value"==c?m=y:"checked"==c?g=y:"key"===c||i&&"function"!=typeof y||k[c]===y||W(n,c,y,k[c],l);if(p)i||a&&(p.__html===a.__html||p.__html===n.innerHTML)||(n.innerHTML=p.__html),_.__k=[];else if(a&&(n.innerHTML=""),S(n,d(h)?h:[h],_,t,o,l&&"foreignObject"!==x,r,u,r?r[0]:t.__k&&b(t,0),i,s),null!=r)for(c=r.length;c--;)null!=r[c]&&v(r[c]);i||(c="value",void 0!==m&&(m!==n[c]||"progress"===x&&!m||"option"===x&&m!==k[c])&&W(n,c,m,k[c],!1),c="checked",void 0!==g&&g!==n[c]&&W(n,c,g,k[c],!1))}return n}function A(e,_,t){try{"function"==typeof e?e(_):e.current=_}catch(e){n.__e(e,t)}}function H(e,_,t){var o,l;if(n.unmount&&n.unmount(e),(o=e.ref)&&(o.current&&o.current!==e.__e||A(o,null,_)),null!=(o=e.__c)){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(e){n.__e(e,_)}o.base=o.__P=null}if(o=e.__k)for(l=0;l<o.length;l++)o[l]&&H(o[l],_,t||"function"!=typeof e.type);t||null==e.__e||v(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function $(e,n,_){return this.constructor(e,_)}function I(_,t,o){var l,r,u,i;n.__&&n.__(_,t),r=(l="function"==typeof o)?null:t.__k,u=[],i=[],L(t,_=(!l&&o||t).__k=y(g,null,[_]),r||f,f,void 0!==t.ownerSVGElement,!l&&o?[o]:r?null:t.firstChild?e.call(t.childNodes):null,u,!l&&o?o:r?r.__e:t.firstChild,l,i),M(u,_,i)}function O(n,_,t){var o,l,r,u,i=h({},n.props);for(r in n.type&&n.type.defaultProps&&(u=n.type.defaultProps),_)"key"==r?o=_[r]:"ref"==r?l=_[r]:i[r]=void 0===_[r]&&void 0!==u?u[r]:_[r];return arguments.length>2&&(i.children=arguments.length>3?e.call(arguments,2):t),m(n.type,i,o||n.key,l||n.ref,null)}function R(e,n){var _={__c:n="__cC"+c++,__:e,Consumer:function(e,n){return e.children(n)},Provider:function(e){var _,t;return this.getChildContext||(_=[],(t={})[n]=this,this.getChildContext=function(){return t},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&_.some((function(e){e.__e=!0,x(e)}))},this.sub=function(e){_.push(e);var n=e.componentWillUnmount;e.componentWillUnmount=function(){_.splice(_.indexOf(e),1),n&&n.call(e)}}),e.children}};return _.Provider.__=_.Consumer.contextType=_}e=p.slice,n={__e:function(e,n,_,t){for(var o,l,r;n=n.__;)if((o=n.__c)&&!o.__)try{if((l=o.constructor)&&null!=l.getDerivedStateFromError&&(o.setState(l.getDerivedStateFromError(e)),r=o.__d),null!=o.componentDidCatch&&(o.componentDidCatch(e,t||{}),r=o.__d),r)return o.__E=o}catch(n){e=n}throw e}},_=0,k.prototype.setState=function(e,n){var _;_=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=h({},this.state),"function"==typeof e&&(e=e(h({},_),this.props)),e&&h(_,e),null!=e&&this.__v&&(n&&this._sb.push(n),x(this))},k.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),x(this))},k.prototype.render=g,t=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,r=function(e,n){return e.__v.__b-n.__v.__b},P.__r=0,u=0,i=F(!1),s=F(!0),c=0;export{k as Component,g as Fragment,O as cloneElement,R as createContext,y as createElement,y as h,n as options,I as render,U as toChildArray};
|
|
2
2
|
//# sourceMappingURL=preact.js.map
|