@paypay/mini-app-js-sdk 2.3.0 → 2.5.0

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.
@@ -0,0 +1,6 @@
1
+ export declare const IFRAME_NAME = "ppmna-iframe";
2
+ export declare const IFRAME_CONTAINER_NAME = "ppsdk-container";
3
+ export declare function initCoreIframe(env?: string, coreVersion?: string): void;
4
+ export declare function showCoreIframe(visible: boolean): void;
5
+ export declare function getCoreIframe(): Promise<HTMLIFrameElement | undefined>;
6
+ export declare function removeCoreIframe(): void;
@@ -1,5 +1,5 @@
1
1
  import proxy from '../client/index';
2
2
  import { miniAppSupportedFunctions } from '../client/supportedFunctionsList';
3
- declare type MiniAppSdkType = Pick<typeof proxy, typeof miniAppSupportedFunctions[number]>;
3
+ declare type MiniAppSdkType = Pick<typeof proxy, (typeof miniAppSupportedFunctions)[number]>;
4
4
  declare const _default: MiniAppSdkType;
5
5
  export default _default;
@@ -1,2 +1,2 @@
1
1
  (function(){"use strict";try{if(typeof document!="undefined"){var p=document.createElement("style");p.appendChild(document.createTextNode(".ppmna-reset-css{all:initial}.ppmna-reset-css *{text-align:unset;color:unset;background:initial;background-color:transparent;margin:revert;padding:revert;font-weight:revert;font-style:unset;font-size:unset;user-select:none;border:unset;border-radius:revert;vertical-align:unset;word-break:unset;outline:none;box-sizing:content-box}.ppmna-reset-css * img{display:inline-block}.ppmna-reset-css * input,.ppmna-reset-css * select{user-select:auto}.ppmna-reset-css * li{list-style:none}.ppmna-reset-css * :where(*:not(svg,svg *)){all:revert}.pp-smartButtonWrapper .pp-smartBtn{display:flex;align-items:center;border-radius:8px;border:none;font-size:14px;font-weight:600;line-height:22px;color:#fff;padding:0;width:100%;height:44px;margin:auto;-webkit-tap-highlight-color:transparent;text-decoration:none;box-sizing:border-box}.pp-smartButtonWrapper .pp-smartBtn.pp-sm .pp-leftSection .pp-btnContent{flex-direction:column}.pp-smartButtonWrapper .pp-smartBtn.pp-light{background:#fff;color:#242323}.pp-smartButtonWrapper .pp-smartBtn.pp-dark{background:#000}.pp-smartButtonWrapper .pp-smartBtn.pp-red{background:#ff0033}.pp-smartButtonWrapper .pp-smartBtn.pp-login{min-width:180px}.pp-smartButtonWrapper .pp-smartBtn.pp-login.pp-sm{width:180px!important}.pp-smartButtonWrapper .pp-smartBtn.pp-login.pp-light{border:1px solid #e4e4e8}.pp-smartButtonWrapper .pp-smartBtn.pp-login.pp-light .pp-userProfile{margin-right:4px}.pp-smartButtonWrapper .pp-smartBtn.pp-login .pp-leftSection .pp-btnContent{display:grid}.pp-smartButtonWrapper .pp-smartBtn.pp-pay{min-width:160px}.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-light{border:1px solid #dddddd}.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-light .pp-cashbackInfo{color:#ff954c;background:#fff0e5}.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-red .pp-cashbackInfo{color:#f03}.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-ja .pp-cashbackInfo{padding:2px 16px}.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-sm{width:160px!important}.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-sm.pp-cashback{height:66px;flex-direction:column;justify-content:center}.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-sm .pp-cashbackInfo{margin:8px 0 0}.pp-smartButtonWrapper .pp-smartBtn.pp-pay .pp-leftSection .pp-img{width:24px;height:24px}.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-shortText{font-size:16px}.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-sm .pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-cashback .pp-leftSection .pp-btnContent,.pp-smartButtonWrapper .pp-smartBtn.pp-pay.pp-shortText .pp-leftSection .pp-btnContent{margin-left:4px}.pp-smartButtonWrapper .pp-smartBtn .pp-leftSection{display:flex;justify-content:center;align-items:center;width:100%;box-sizing:border-box;padding:0 8px}.pp-smartButtonWrapper .pp-smartBtn .pp-leftSection .pp-img{width:20px;height:20px;display:inline-block}.pp-smartButtonWrapper .pp-smartBtn .pp-leftSection .pp-btnContent{margin-left:8px}.pp-smartButtonWrapper .pp-smartBtn .pp-leftSection .pp-btnContent .pp-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pp-smartButtonWrapper .pp-smartBtn .pp-cashbackInfo{font-size:12px;color:#242323;background:#fff;line-height:14px;padding:2px 8px;border-radius:9px;margin-left:8px}.pp-smartButtonWrapper .pp-smartBtn .pp-userProfile{width:34px;height:34px;border-radius:50%;margin-right:5px}.pp-smartButtonWrapper.pp-button{padding:0;margin:0;background:none;border:none;width:100%;border-radius:8px;-webkit-tap-highlight-color:transparent;font-family:revert!important}.pp-smartButtonWrapper.pp-button *{font-family:revert!important}")),document.head.appendChild(p)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- var pp=function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)e[a]=n[a]}return e}var t=function t(n,a){function o(t,o,l){if("undefined"!=typeof document){"number"==typeof(l=e({},a,l)).expires&&(l.expires=new Date(Date.now()+864e5*l.expires)),l.expires&&(l.expires=l.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var i="";for(var r in l)l[r]&&(i+="; "+r,!0!==l[r]&&(i+="="+l[r].split(";")[0]));return document.cookie=t+"="+n.write(o,t)+i}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],a={},o=0;o<t.length;o++){var l=t[o].split("="),i=l.slice(1).join("=");try{var r=decodeURIComponent(l[0]);if(a[r]=n.read(i,r),e===r)break}catch(s){}}return e?a[e]:a}},remove:function(t,n){o(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(a)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),n=(e=>(e.accessToken="ppjssdk.accessToken",e.refreshToken="ppjssdk.refreshToken",e.env="ppjssdk.env",e.deviceUUID="ppjssdk.deviceUUID",e.clientUUID="ppjssdk.clientUUID",e.lastPayment="ppjssdk.lastPayment",e.lastTopup="ppjssdk.lastTopup",e.appDetail="ppjssdk.appDetail",e.appConfig="ppjssdk.appConfig",e.userInfo="ppjssdk.userInfo",e.lastPaymentMethod="ppjssdk.lastPaymentMethod",e.lastTopupPayMethod="ppjssdk.lastTopupPayMethod",e.codeVerifier="ppjssdk.codeVerifier",e.clientOrigin="ppjssdk.clientOrigin",e.clientVersion="ppjssdk.clientVersion",e.debugMode="ppjssdk.debugMode",e.merchant="ppjssdk.merchant",e))(n||{});const a="success",o="fail",l="complete",i="init",r="render",s="makePayment",c="verifyMultiFactorAuthResult",d="share",u="scanCode",p="getAuthStatus",m="handleMessageFromNative",v="getKycPassportInfo",f="reload",I="link",E="saveRefreshToken",g="saveCodeVerifier",A="makeVisible",_="consoleDebugInfo",h="_PayPayJsBridge",T=["init","openWebview","openMap","closeApp","makePayment","topup","setSessionData","getSessionData","setStorageData","getStorageData","removeStorageData","getPermissionStatus","scanCode","showAlert","showErrorSheet","getTopBarHeight","setTitle","showUpdateWarning","getPlatformInformation","openApp","share","getKycInformation","getUserLocation","checkPaymentMethod","registerKyc","startMultiFactorAuth","verifyMultiFactorAuthResult","getBankInfo","logout","getUserProfile","getBalance","getUserAddress","getUAID","copyToClipboard","registerUserInfo","setEnablePullDownRefresh","registerEmail","checkAccessToken","debug","inputAddress","getDeviceInformation","openMiniApp","request","requestInternal","registerPaymentFeatures","initKycPassport","getKycPassportInfo","shortcutExists","addShortcut","logAppsFlyerEvent","getAllUserAddresses"];function N(e){return"https://image.paypay.ne.jp/miniapps/mini-app-sdk/"+e}const S=N("icon-paypay-rec.svg"),y=N("icon-paypay-rec-white.svg");function D(e,t,n){return e===O(t,n)}function O(e,t){return new URL(P(e,t)).origin}function P(e,t){return`${function(){switch(e){case"staging":case"sandbox":case"canary":case"qa":return"staging"===t?"https://mini-app-sdk-core.paypay.ne.jp/dev/stg/iframe.html":"https://mini-app-sdk-core.paypay.ne.jp/iframe.html";default:return"https://mini-app-sdk-core.paypay.ne.jp/iframe.html"}}()}?v=2.3.0`}function C(e){return e?String(e):""}function k(e,n){t.remove(e),t.remove(e,{domain:n})}let R=[];function U(e){R=R.filter((t=>t!==e))}function L(){const e=Math.random().toString(36).substring(7);return R.push(e),e}var b=(e=>(e.success="SUCCESS",e.invalidUrl="INVALID_URL",e.invalidData="INVALID_DATA",e.invalidHeader="INVALID_HEADER",e.invalidMethod="INVALID_METHOD",e.invalidPath="INVALID_PATH",e.notReachable="NOT_REACHABLE",e.notAvailable="NOT_AVAILABLE",e.timeOut="TIME_OUT",e.whiteListError="NONE_WHITELIST_DOMAIN",e.statusCodeError="STATUS_CODE_ERROR",e.invalidResponse="INVALID_RESPONSE",e.noLocationPermission="NO_USER_LOCATION_PERMISSION",e.noPermissionListAvailable="NO_PERMISSION_LIST_AVAILABLE",e.other="other",e.serverError="SERVER_ERROR",e.noCameraPermission="HOST_APP_CAMERA_DENIED",e.noAlbumPermission="HOST_APP_ALBUM_DENIED",e.insufficientScope="INSUFFICIENT_SCOPE",e.userCanceled="USER_CANCELED",e.invalidJSAPIParams="INVALID_JS_API_PARAMS",e.hostAppLocationDenied="HOST_APP_LOCATION_DENIED",e.hostAppContactsDenied="HOST_APP_READING_CONTACT_DENIED",e.badRequestInsufficientParameter="BAD_REQUEST_INSUFFICIENT_PARAMETER",e.badRequest="BAD_REQUEST",e.paymentFail="PAYMENT_FAIL",e.topupFail="TOPUP_FAIL",e.topupSuccessButNotAddToBalance="TOPUP_SUCCESS_BUT_NOT_ADD_TO_BALANCE",e.userCanceledSimilarTxn="USER_CANCELED_SIMILAR_TRANSACTION",e.mapAppNotFound="MAP_APP_NOT_FOUND",e.invalidAppSchemeURL="INVALID_APP_SCHEME_URL",e.noValueFound="NO_VALUE_FOUND",e.securityNotSetup="SECURITY_NOT_SETUP",e.userDenied="USER_DENIED",e.securityTemporaryLocked="SECURITY_TEMPORARY_LOCKED",e.couldNotGenerateBarcode="COULD_NOT_GENERATE_BARCODE",e.cannotDetectAvailability="CAN_NOT_DETECT_AVAILABILITY",e.suspectedDuplicatePayment="SUSPECTED_DUPLICATE_PAYMENT",e.noSufficientFund="NO_SUFFICIENT_FUND",e.unknown="UNKNOWN",e.sdkNotInitialized="SDK_NOT_INITIALIZED",e.tokenNotFound="TOKEN_NOT_FOUND",e.tokenExpired="TOKEN_EXPIRED",e.activeRequestExists="ACTIVE_REQUEST_EXISTS",e.invalidType="INVALID_TYPE",e.sessionNotFound="SESSION_NOT_FOUND",e.cookieError="COOKIE_ERROR",e.notAuthorized="NOT_AUTHORIZED",e.permissionRequired="PERMISSION_REQUIRED",e.deeplinkUnavailable="DEEPLINK_UNAVAILABLE",e.kycIncompleted="KYC_INCOMPLETED",e.noBankAccount="NO_BANK_ACCOUNT",e.invalidPaymentIdentifier="INVALID_PAYMENT_IDENTIFIER",e.otpSendTooShort="OTP_SEND_TOO_SHORT",e.otpSendOverLimit="OTP_SEND_OVER_LIMIT",e.userVerificationFailure="USER_VERIFICATION_FAILURE",e.unacceptableOp="UNACCEPTABLE_OP",e.kycUpdateRequired="KYC_UPDATE_REQUIRED",e.notCompleted="NOT_COMPLETED",e.kycValidationInProcess="KYC_VALIDATION_IN_PROCESS",e.noLocationData="NO_LOCATION_DATA",e))(b||{});const w="ppmna-iframe",M="ppsdk-container";let F,V=!1,B="";function j(){return document.getElementById(M)}function x(){var e;return null==(e=j())?void 0:e.getElementsByTagName("iframe")[0]}function K(e){const t=j();t&&(t.style.display=e?"initial":"none")}function H(e,t,n){var i,r,s;e.result===o&&(null==(i=null==t?void 0:t.fail)||i.call(t,e.data)),e.result===a&&(null==(r=null==t?void 0:t.success)||r.call(t,null==e?void 0:e.data)),e.result===l&&(null==(s=null==t?void 0:t.complete)||s.call(t),removeEventListener("message",n),U(e.messageId),R.length>0||K(!1))}function J(e,t,n){null==e||e.postMessage(JSON.parse(JSON.stringify(n)),O(t))}function Y(e,t,n,a){(async()=>{let o=null;var l;o=e===i?await(l=F,new Promise(((e,t)=>{if(x())return void e(x());const n=document.createElement("div");document.createElement("div"),n.setAttribute("id",M),n.setAttribute("class",M),document.body.appendChild(n);const a=document.createElement("iframe");a.setAttribute("src",P(l,B)),a.setAttribute("name",w),a.setAttribute("id",w),a.setAttribute("allow","geolocation"),a.onload=()=>e(a),a.onerror=()=>t(),n.appendChild(a),a.style.all="initial",a.style.width="100%",a.style.height="100%",a.style.border="none",n.style.all="initial",n.style.display="none",n.style.position="fixed",n.style.width="100%",n.style.height="100%",n.style.top="0",n.style.left="0"}))):x();const r=L();K(t);const s=t=>{D(t.origin,F,B)&&t.data.name===e&&t.data.messageId===r&&H(t.data,n,s)};addEventListener("message",s),J(null==o?void 0:o.contentWindow,F,{name:e,params:a,messageId:r})})().catch((()=>{}))}addEventListener("message",(e=>{if(D(e.origin,F,B))if(e.data.name===f&&window.location.reload(),e.data.name!==A){if(e.data.name===I){const t=e.data.data;"_blank"===t.target?window.open(t.url,"_blank"):window.location.href=t.url}if(e.data.name===E){const{refreshToken:a,domain:o,isSecure:l}=e.data.data;!function(e,a,o){k(n.refreshToken,a),t.set(n.refreshToken,e,{domain:a,expires:90,secure:o})}(a,o,l)}if(e.data.name===g){const{codeVerifier:a,domain:o,isSecure:l}=e.data.data;!function(e,a,o){k(n.codeVerifier,a),t.set(n.codeVerifier,e,{domain:a,secure:o})}(a,o,l)}if(e.data.name===_){const{params:t}=e.data.data;!function(e){console.debug(...e)}(t)}}else K(!0)}));!function(e){const t=window;(!t.hasOwnProperty(h)||t._PayPayJsBridge!==e)&&(t._PayPayJsBridge=e)}({_handleMessageFromNative:e=>{var t;const n=x();null==(t=null==n?void 0:n.contentWindow)||t.postMessage(JSON.parse(JSON.stringify({name:m,params:{json:e}})),O(F))}});return new Proxy({init:function(e){B=e.coreVersion;const a=new URL(window.location.href),o=a.searchParams.get("token"),l=a.searchParams.get("one_time_token"),r=t.get(n.refreshToken)||"",s=t.get(n.codeVerifier)||"";V=!!e.useAllFunctions,(o||l)&&function(e){e.searchParams.delete("token"),e.searchParams.delete("one_time_token"),e.search=e.searchParams.toString(),history.replaceState(null,"",e)}(a),F=e.env;const c={env:e.env,mode:e.mode,debugMode:e.debugMode,clientId:e.clientId,token:o,ott:l,refreshToken:r,clientVersion:"2.3.0",codeVerifier:s};Y(i,!1,e,c)},verifyMultiFactorAuthResult:function(e){const t=new URL(window.location.href);Y(c,!1,e,{...e,sessionId:t.searchParams.get("ppSessionId")})},share:function(e){if(!(null==navigator?void 0:navigator.share))return void Y(d,!1,e,e);const t={text:null==e?void 0:e.text};navigator.share(t).then((()=>{var t,n;null==(t=null==e?void 0:e.success)||t.call(e),null==(n=null==e?void 0:e.complete)||n.call(e)})).catch((()=>{var t,n;null==(t=null==e?void 0:e.fail)||t.call(e,{errorCode:b.unknown}),null==(n=null==e?void 0:e.complete)||n.call(e)}))},setTitle:function(e){var t,n;document.title=(null==e?void 0:e.title)||"",null==(t=null==e?void 0:e.success)||t.call(e),null==(n=null==e?void 0:e.complete)||n.call(e)},render:function(e){var t;const n=x();if(!(null==e?void 0:e.containerId)||!document.getElementById(null==e?void 0:e.containerId))return null==(t=null==e?void 0:e.fail)||t.call(e,{errorCode:b.badRequestInsufficientParameter}),console.error("Invalid container Id");let o=L();const i=t=>{var n,c;if(!D(t.origin,F,B)||t.data.name!==r||t.data.messageId!==o)return;const d=null==(n=t.data)?void 0:n.data,u=null==(c=t.data)?void 0:c.data;t.data.result===a&&(!function(e,t){var n,a,o,l,i,r,c;const d=document.getElementById(t.containerId),u=document.createElement("button");u.className="ppmna-reset-css pp-smartButtonWrapper pp-button";const p=function(e){return"red"===e?y:S}(null==t?void 0:t.theme),m=(null==(a=null==(n=null==e?void 0:e.data)?void 0:n.cashbackInfo)?void 0:a.length)?"pp-cashback":"",v=t.isShortText?"pp-shortText":"",f=null!=(o=null==t?void 0:t.buttonSize)?o:"lg",I=null!=(l=null==t?void 0:t.theme)?l:"light",E=document.createElement("a");E.className=`pp-smartBtn pp-${I} pp-${f} pp-${C(t.type)} pp-${e.preferredLanguage} ${m} ${v}`,E.href=C(t.url);const g=document.createElement("span");g.className="pp-leftSection";const A=document.createElement("img");A.className="pp-img",A.src=p,A.alt="",g.appendChild(A);const _=document.createElement("span");_.className="pp-btnContent";const h=document.createElement("span");h.className="pp-title",h.innerText=null==(i=null==e?void 0:e.data)?void 0:i.title,_.appendChild(h),g.appendChild(_),E.append(g);const T=document.createElement("span");(null==(r=null==e?void 0:e.data)?void 0:r.cashbackInfo)&&(T.className="pp-cashbackInfo",T.innerText=null==(c=null==e?void 0:e.data)?void 0:c.cashbackInfo,_.append(T));if(e.data.avatarUrl){const t=document.createElement("img");t.className="pp-userProfile",t.src=e.data.avatarUrl,t.addEventListener("error",(function(e){var t;const n=e.target;null==(t=null==n?void 0:n.parentNode)||t.removeChild(n)})),E.append(t)}u.append(E),d&&(d.innerHTML="",d.appendChild(u),"pay"===t.type&&(null==e?void 0:e.isLoggedIn)&&u.addEventListener("click",(e=>{var n;e.preventDefault(),(null==t?void 0:t.callback)?null==(n=null==t?void 0:t.callback)||n.call(t):t.orderInfo&&Y(s,!0,t,{...t.orderInfo})})))}(u,e),"pay"===d.type&&(null==u?void 0:u.isJustLoggedIn)&&e.autoInvoke&&(null==u?void 0:u.isLoggedIn)&&Y(s,!0,e,{...e.orderInfo})),t.data.result===l&&(U(t.data.messageId),removeEventListener("message",i))};addEventListener("message",i),J(null==n?void 0:n.contentWindow,F,{name:r,params:e,messageId:o})},scanCode:function(e){var t;const n={...e,redirectUrlOnCancel:null!=(t=null==e?void 0:e.redirectUrlOnCancel)?t:window.location.href};Y(u,!1,e,n)},copyToClipboard:function(e){var t,n,a;const o=document.createElement("textarea");o.setAttribute("readonly","true"),o.setAttribute("contenteditable","true"),o.value=e.value,document.body.appendChild(o),o.select(),o.setSelectionRange(0,o.value.length);const l=document.execCommand("copy");document.body.removeChild(o),l?null==(t=null==e?void 0:e.success)||t.call(e):null==(n=null==e?void 0:e.fail)||n.call(e,{errorCode:b.other}),null==(a=e.complete)||a.call(e)},getSessionData:function(e){var t,n;const a=sessionStorage.getItem(null==e?void 0:e.key);null==(t=null==e?void 0:e.success)||t.call(e,{[null==e?void 0:e.key]:null!=a?a:""}),null==(n=null==e?void 0:e.complete)||n.call(e)},setSessionData:function(e){var t,n,a;sessionStorage.setItem(null==e?void 0:e.key,null!=(t=null==e?void 0:e.value)?t:""),null==(n=null==e?void 0:e.success)||n.call(e),null==(a=null==e?void 0:e.complete)||a.call(e)},getStorageData:function(e){var t,n;const a=localStorage.getItem(null==e?void 0:e.key);null==(t=null==e?void 0:e.success)||t.call(e,{[null==e?void 0:e.key]:null!=a?a:""}),null==(n=null==e?void 0:e.complete)||n.call(e)},setStorageData:function(e){var t,n,a;localStorage.setItem(null==e?void 0:e.key,null!=(t=null==e?void 0:e.value)?t:""),null==(n=null==e?void 0:e.success)||n.call(e),null==(a=null==e?void 0:e.complete)||a.call(e)},removeStorageData:function(e){var t,n;localStorage.removeItem(null==e?void 0:e.key),null==(t=null==e?void 0:e.success)||t.call(e),null==(n=null==e?void 0:e.complete)||n.call(e)},getKycPassportInfo:function(e){const t=new URL(window.location.href);Y(v,!1,e,{...e,url:t})},getAuthStatus:function(e){const t=window.location.href;Y(p,!1,e,{...e,url:t})}},{get(e,t){const n=t;if(!V&&!function(e){return T.includes(e)}(n))throw new Error(`${n} is not supported by Mini Apps JS SDK`);return Object.prototype.hasOwnProperty.call(e,t)?e[t]:e=>{Y(t,!1,e,e)}}})}();
2
+ var pp=function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)e[a]=n[a]}return e}var t=function t(n,a){function o(t,o,i){if("undefined"!=typeof document){"number"==typeof(i=e({},a,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var l="";for(var r in i)i[r]&&(l+="; "+r,!0!==i[r]&&(l+="="+i[r].split(";")[0]));return document.cookie=t+"="+n.write(o,t)+l}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],a={},o=0;o<t.length;o++){var i=t[o].split("="),l=i.slice(1).join("=");try{var r=decodeURIComponent(i[0]);if(a[r]=n.read(l,r),e===r)break}catch(s){}}return e?a[e]:a}},remove:function(t,n){o(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(a)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),n=(e=>(e.accessToken="ppjssdk.accessToken",e.refreshToken="ppjssdk.refreshToken",e.env="ppjssdk.env",e.deviceUUID="ppjssdk.deviceUUID",e.clientUUID="ppjssdk.clientUUID",e.lastPayment="ppjssdk.lastPayment",e.lastTopup="ppjssdk.lastTopup",e.appDetail="ppjssdk.appDetail",e.appConfig="ppjssdk.appConfig",e.userInfo="ppjssdk.userInfo",e.lastPaymentMethod="ppjssdk.lastPaymentMethod",e.lastTopupPayMethod="ppjssdk.lastTopupPayMethod",e.codeVerifier="ppjssdk.codeVerifier",e.clientOrigin="ppjssdk.clientOrigin",e.clientVersion="ppjssdk.clientVersion",e.debugMode="ppjssdk.debugMode",e.merchant="ppjssdk.merchant",e))(n||{});const a="success",o="fail",i="complete",l="init",r="render",s="makePayment",c="verifyMultiFactorAuthResult",d="share",u="scanCode",p="getAuthStatus",m="handleMessageFromNative",v="getKycPassportInfo",f="reload",I="link",E="saveRefreshToken",g="saveCodeVerifier",A="makeVisible",_="consoleDebugInfo",h="_PayPayJsBridge",T=["init","openWebview","openMap","closeApp","makePayment","topup","setSessionData","getSessionData","setStorageData","getStorageData","removeStorageData","getPermissionStatus","scanCode","showAlert","showErrorSheet","getTopBarHeight","setTitle","showUpdateWarning","getPlatformInformation","openApp","share","getKycInformation","getUserLocation","checkPaymentMethod","registerKyc","startMultiFactorAuth","verifyMultiFactorAuthResult","getBankInfo","logout","getUserProfile","getBalance","getUserAddress","getUAID","copyToClipboard","registerUserInfo","setEnablePullDownRefresh","registerEmail","checkAccessToken","debug","inputAddress","getDeviceInformation","openMiniApp","request","requestInternal","registerPaymentFeatures","initKycPassport","getKycPassportInfo","shortcutExists","addShortcut","logAppsFlyerEvent","getAllUserAddresses"];function N(e){return"https://image.paypay.ne.jp/miniapps/mini-app-sdk/"+e}const S=N("icon-paypay-rec.svg"),y=N("icon-paypay-rec-white.svg");function D(e,t,n){return e===O(t,n)}function O(e,t){return new URL(P(e,t)).origin}function P(e,t){return`${function(){switch(e){case"staging":case"sandbox":case"canary":case"qa":return"staging"===t?"https://mini-app-sdk-core.paypay.ne.jp/dev/stg/iframe.html":"https://mini-app-sdk-core.paypay.ne.jp/iframe.html";default:return"https://mini-app-sdk-core.paypay.ne.jp/iframe.html"}}()}?v=2.5.0`}function C(e){return e?String(e):""}function k(e,n){t.remove(e),t.remove(e,{domain:n})}let R=[];function U(e){R=R.filter((t=>t!==e))}function L(){const e=Math.random().toString(36).substring(7);return R.push(e),e}var b=(e=>(e.success="SUCCESS",e.invalidUrl="INVALID_URL",e.invalidData="INVALID_DATA",e.invalidHeader="INVALID_HEADER",e.invalidMethod="INVALID_METHOD",e.invalidPath="INVALID_PATH",e.notReachable="NOT_REACHABLE",e.notAvailable="NOT_AVAILABLE",e.timeOut="TIME_OUT",e.whiteListError="NONE_WHITELIST_DOMAIN",e.statusCodeError="STATUS_CODE_ERROR",e.invalidResponse="INVALID_RESPONSE",e.noLocationPermission="NO_USER_LOCATION_PERMISSION",e.noPermissionListAvailable="NO_PERMISSION_LIST_AVAILABLE",e.other="other",e.serverError="SERVER_ERROR",e.noCameraPermission="HOST_APP_CAMERA_DENIED",e.noAlbumPermission="HOST_APP_ALBUM_DENIED",e.insufficientScope="INSUFFICIENT_SCOPE",e.userCanceled="USER_CANCELED",e.invalidJSAPIParams="INVALID_JS_API_PARAMS",e.hostAppLocationDenied="HOST_APP_LOCATION_DENIED",e.hostAppContactsDenied="HOST_APP_READING_CONTACT_DENIED",e.badRequestInsufficientParameter="BAD_REQUEST_INSUFFICIENT_PARAMETER",e.badRequest="BAD_REQUEST",e.paymentFail="PAYMENT_FAIL",e.topupFail="TOPUP_FAIL",e.topupSuccessButNotAddToBalance="TOPUP_SUCCESS_BUT_NOT_ADD_TO_BALANCE",e.userCanceledSimilarTxn="USER_CANCELED_SIMILAR_TRANSACTION",e.mapAppNotFound="MAP_APP_NOT_FOUND",e.invalidAppSchemeURL="INVALID_APP_SCHEME_URL",e.noValueFound="NO_VALUE_FOUND",e.securityNotSetup="SECURITY_NOT_SETUP",e.userDenied="USER_DENIED",e.securityTemporaryLocked="SECURITY_TEMPORARY_LOCKED",e.couldNotGenerateBarcode="COULD_NOT_GENERATE_BARCODE",e.cannotDetectAvailability="CAN_NOT_DETECT_AVAILABILITY",e.suspectedDuplicatePayment="SUSPECTED_DUPLICATE_PAYMENT",e.noSufficientFund="NO_SUFFICIENT_FUND",e.unknown="UNKNOWN",e.sdkNotInitialized="SDK_NOT_INITIALIZED",e.tokenNotFound="TOKEN_NOT_FOUND",e.tokenExpired="TOKEN_EXPIRED",e.activeRequestExists="ACTIVE_REQUEST_EXISTS",e.invalidType="INVALID_TYPE",e.sessionNotFound="SESSION_NOT_FOUND",e.cookieError="COOKIE_ERROR",e.notAuthorized="NOT_AUTHORIZED",e.permissionRequired="PERMISSION_REQUIRED",e.deeplinkUnavailable="DEEPLINK_UNAVAILABLE",e.kycIncompleted="KYC_INCOMPLETED",e.noBankAccount="NO_BANK_ACCOUNT",e.invalidPaymentIdentifier="INVALID_PAYMENT_IDENTIFIER",e.otpSendTooShort="OTP_SEND_TOO_SHORT",e.otpSendOverLimit="OTP_SEND_OVER_LIMIT",e.userVerificationFailure="USER_VERIFICATION_FAILURE",e.unacceptableOp="UNACCEPTABLE_OP",e.kycUpdateRequired="KYC_UPDATE_REQUIRED",e.notCompleted="NOT_COMPLETED",e.kycValidationInProcess="KYC_VALIDATION_IN_PROCESS",e.noLocationData="NO_LOCATION_DATA",e))(b||{});const w="ppmna-iframe",M="ppsdk-container";let F,V,B,j,x;function K(){return B||(B=function(){const e=document.createElement("div");return document.createElement("div"),e.setAttribute("id",M),e.setAttribute("class",M),e.style.all="initial",e.style.display="none",e.style.position="fixed",e.style.width="100%",e.style.height="100%",e.style.top="0",e.style.left="0",document.body.appendChild(e),e}()),B}function H(e){K().style.display=e?"initial":"none"}function J(){return j||(j=new Promise(((e,t)=>{const n=document.createElement("iframe");n.setAttribute("src",P(F,V)),n.setAttribute("name",w),n.setAttribute("id",w),n.setAttribute("class",w),n.setAttribute("allow","geolocation"),n.onload=()=>{e(n)},n.onerror=t,n.style.all="initial",n.style.width="100%",n.style.height="100%",n.style.border="none",K().replaceChildren(n)}))),j}let Y=!1,q="";function $(e,t,n){var l,r,s;e.result===o&&(null==(l=null==t?void 0:t.fail)||l.call(t,e.data)),e.result===a&&(null==(r=null==t?void 0:t.success)||r.call(t,null==e?void 0:e.data)),e.result===i&&(null==(s=null==t?void 0:t.complete)||s.call(t),removeEventListener("message",n),U(e.messageId),R.length>0||H(!1))}async function W(e){var t;const n=await J().catch((()=>{}));null==(t=null==n?void 0:n.contentWindow)||t.postMessage(JSON.parse(JSON.stringify(e)),O(x))}function z(e,t,n,a){const o=L();H(t);const i=t=>{D(t.origin,x,q)&&t.data.name===e&&t.data.messageId===o&&$(t.data,n,i)};addEventListener("message",i),W({name:e,params:a,messageId:o})}addEventListener("message",(e=>{if(D(e.origin,x,q))if(e.data.name===f&&window.location.reload(),e.data.name!==A){if(e.data.name===I){const t=e.data.data;"_blank"===t.target?window.open(t.url,"_blank"):window.location.href=t.url}if(e.data.name===E){const{refreshToken:a,domain:o,isSecure:i}=e.data.data;!function(e,a,o){k(n.refreshToken,a),t.set(n.refreshToken,e,{domain:a,expires:90,secure:o})}(a,o,i)}if(e.data.name===g){const{codeVerifier:a,domain:o,isSecure:i}=e.data.data;!function(e,a,o){k(n.codeVerifier,a),t.set(n.codeVerifier,e,{domain:a,secure:o})}(a,o,i)}if(e.data.name===_){const{params:t}=e.data.data;!function(e){console.debug(...e)}(t)}}else H(!0)}));!function(e){const t=window;(!t.hasOwnProperty(h)||t._PayPayJsBridge!==e)&&(t._PayPayJsBridge=e)}({_handleMessageFromNative:async e=>{var t;const n=await J();null==(t=null==n?void 0:n.contentWindow)||t.postMessage(JSON.parse(JSON.stringify({name:m,params:{json:e}})),O(x))}});return new Proxy({init:function(e){q=e.coreVersion;const a=new URL(window.location.href),o=a.searchParams.get("token"),i=a.searchParams.get("one_time_token"),r=t.get(n.refreshToken)||"",s=t.get(n.codeVerifier)||"";Y=!!e.useAllFunctions,(o||i)&&function(e){e.searchParams.delete("token"),e.searchParams.delete("one_time_token"),e.search=e.searchParams.toString(),history.replaceState(null,"",e)}(a),x=e.env;const c={env:e.env,mode:e.mode,debugMode:e.debugMode,clientId:e.clientId,token:o,ott:i,refreshToken:r,clientVersion:"2.5.0",codeVerifier:s};F=x,V=q,J(),z(l,!1,e,c)},verifyMultiFactorAuthResult:function(e){const t=new URL(window.location.href);z(c,!1,e,{...e,sessionId:t.searchParams.get("ppSessionId")})},share:function(e){if(!(null==navigator?void 0:navigator.share))return void z(d,!1,e,e);const t={text:null==e?void 0:e.text};navigator.share(t).then((()=>{var t,n;null==(t=null==e?void 0:e.success)||t.call(e),null==(n=null==e?void 0:e.complete)||n.call(e)})).catch((()=>{var t,n;null==(t=null==e?void 0:e.fail)||t.call(e,{errorCode:b.unknown}),null==(n=null==e?void 0:e.complete)||n.call(e)}))},setTitle:function(e){var t,n;document.title=(null==e?void 0:e.title)||"",null==(t=null==e?void 0:e.success)||t.call(e),null==(n=null==e?void 0:e.complete)||n.call(e)},render:function(e){var t;if(!(null==e?void 0:e.containerId)||!document.getElementById(null==e?void 0:e.containerId))return null==(t=null==e?void 0:e.fail)||t.call(e,{errorCode:b.badRequestInsufficientParameter}),console.error("Invalid container Id");const n=L(),o=t=>{var l,c;if(!D(t.origin,x,q)||t.data.name!==r||t.data.messageId!==n)return;const d=null==(l=t.data)?void 0:l.data,u=null==(c=t.data)?void 0:c.data;t.data.result===a&&(!function(e,t){var n,a,o,i,l,r,c;const d=document.getElementById(t.containerId),u=document.createElement("button");u.className="ppmna-reset-css pp-smartButtonWrapper pp-button";const p=function(e){return"red"===e?y:S}(null==t?void 0:t.theme),m=(null==(a=null==(n=null==e?void 0:e.data)?void 0:n.cashbackInfo)?void 0:a.length)?"pp-cashback":"",v=t.isShortText?"pp-shortText":"",f=null!=(o=null==t?void 0:t.buttonSize)?o:"lg",I=null!=(i=null==t?void 0:t.theme)?i:"light",E=document.createElement("a");E.className=`pp-smartBtn pp-${I} pp-${f} pp-${C(t.type)} pp-${e.preferredLanguage} ${m} ${v}`,E.href=C(t.url);const g=document.createElement("span");g.className="pp-leftSection";const A=document.createElement("img");A.className="pp-img",A.src=p,A.alt="",g.appendChild(A);const _=document.createElement("span");_.className="pp-btnContent";const h=document.createElement("span");h.className="pp-title",h.innerText=null==(l=null==e?void 0:e.data)?void 0:l.title,_.appendChild(h),g.appendChild(_),E.append(g);const T=document.createElement("span");(null==(r=null==e?void 0:e.data)?void 0:r.cashbackInfo)&&(T.className="pp-cashbackInfo",T.innerText=null==(c=null==e?void 0:e.data)?void 0:c.cashbackInfo,_.append(T));if(e.data.avatarUrl){const t=document.createElement("img");t.className="pp-userProfile",t.src=e.data.avatarUrl,t.addEventListener("error",(function(e){var t;const n=e.target;null==(t=null==n?void 0:n.parentNode)||t.removeChild(n)})),E.append(t)}u.append(E),d&&(d.innerHTML="",d.appendChild(u),"pay"===t.type&&(null==e?void 0:e.isLoggedIn)&&u.addEventListener("click",(e=>{var n;e.preventDefault(),(null==t?void 0:t.callback)?null==(n=null==t?void 0:t.callback)||n.call(t):t.orderInfo&&z(s,!0,t,{...t.orderInfo})})))}(u,e),"pay"===d.type&&(null==u?void 0:u.isJustLoggedIn)&&e.autoInvoke&&(null==u?void 0:u.isLoggedIn)&&z(s,!0,e,{...e.orderInfo})),t.data.result===i&&(U(t.data.messageId),removeEventListener("message",o))};addEventListener("message",o),W({name:r,params:e,messageId:n})},scanCode:function(e){var t;const n={...e,redirectUrlOnCancel:null!=(t=null==e?void 0:e.redirectUrlOnCancel)?t:window.location.href};z(u,!1,e,n)},copyToClipboard:function(e){var t,n,a;const o=document.createElement("textarea");o.setAttribute("readonly","true"),o.setAttribute("contenteditable","true"),o.value=e.value,document.body.appendChild(o),o.select(),o.setSelectionRange(0,o.value.length);const i=document.execCommand("copy");document.body.removeChild(o),i?null==(t=null==e?void 0:e.success)||t.call(e):null==(n=null==e?void 0:e.fail)||n.call(e,{errorCode:b.other}),null==(a=e.complete)||a.call(e)},getSessionData:function(e){var t,n;const a=sessionStorage.getItem(null==e?void 0:e.key);null==(t=null==e?void 0:e.success)||t.call(e,{[null==e?void 0:e.key]:null!=a?a:""}),null==(n=null==e?void 0:e.complete)||n.call(e)},setSessionData:function(e){var t,n,a;sessionStorage.setItem(null==e?void 0:e.key,null!=(t=null==e?void 0:e.value)?t:""),null==(n=null==e?void 0:e.success)||n.call(e),null==(a=null==e?void 0:e.complete)||a.call(e)},getStorageData:function(e){var t,n;const a=localStorage.getItem(null==e?void 0:e.key);null==(t=null==e?void 0:e.success)||t.call(e,{[null==e?void 0:e.key]:null!=a?a:""}),null==(n=null==e?void 0:e.complete)||n.call(e)},setStorageData:function(e){var t,n,a;localStorage.setItem(null==e?void 0:e.key,null!=(t=null==e?void 0:e.value)?t:""),null==(n=null==e?void 0:e.success)||n.call(e),null==(a=null==e?void 0:e.complete)||a.call(e)},removeStorageData:function(e){var t,n;localStorage.removeItem(null==e?void 0:e.key),null==(t=null==e?void 0:e.success)||t.call(e),null==(n=null==e?void 0:e.complete)||n.call(e)},getKycPassportInfo:function(e){const t=new URL(window.location.href);z(v,!1,e,{...e,url:t})},getAuthStatus:function(e){const t=window.location.href;z(p,!1,e,{...e,url:t})}},{get(e,t){const n=t;if(!Y&&!function(e){return T.includes(e)}(n))throw new Error(`${n} is not supported by Mini Apps JS SDK`);return Object.prototype.hasOwnProperty.call(e,t)?e[t]:e=>{z(t,!1,e,e)}}})}();
@@ -245,7 +245,7 @@ function getIframeOrigin(env2, coreVersion2) {
245
245
  return iframeUrl.origin;
246
246
  }
247
247
  function getIframeUrl(env2, coreVersion2) {
248
- const version = "2.3.0";
248
+ const version = "2.5.0";
249
249
  return `${getUrl()}?v=${version}`;
250
250
  function getUrl() {
251
251
  switch (env2) {
@@ -392,8 +392,68 @@ var MiniAppErrorType = /* @__PURE__ */ ((MiniAppErrorType2) => {
392
392
  return MiniAppErrorType2;
393
393
  })(MiniAppErrorType || {});
394
394
  var style = "";
395
- const frameName = "ppmna-iframe";
396
- const containerName = "ppsdk-container";
395
+ const IFRAME_NAME = "ppmna-iframe";
396
+ const IFRAME_CONTAINER_NAME = "ppsdk-container";
397
+ let _env;
398
+ let _coreVersion;
399
+ function initCoreIframe(env2, coreVersion2) {
400
+ _env = env2;
401
+ _coreVersion = coreVersion2;
402
+ getCoreIframe();
403
+ }
404
+ let iframeContainer;
405
+ function getCoreIframeContainer() {
406
+ if (!iframeContainer) {
407
+ iframeContainer = createIframeContainer();
408
+ }
409
+ return iframeContainer;
410
+ }
411
+ function createIframeContainer() {
412
+ const container = document.createElement("div");
413
+ document.createElement("div");
414
+ container.setAttribute("id", IFRAME_CONTAINER_NAME);
415
+ container.setAttribute("class", IFRAME_CONTAINER_NAME);
416
+ container.style.all = "initial";
417
+ container.style.display = "none";
418
+ container.style.position = "fixed";
419
+ container.style.width = "100%";
420
+ container.style.height = "100%";
421
+ container.style.top = "0";
422
+ container.style.left = "0";
423
+ document.body.appendChild(container);
424
+ return container;
425
+ }
426
+ function showCoreIframe(visible) {
427
+ const container = getCoreIframeContainer();
428
+ container.style.display = visible ? "initial" : "none";
429
+ }
430
+ let coreIframeLoadingPromise;
431
+ function getCoreIframe() {
432
+ if (!coreIframeLoadingPromise) {
433
+ coreIframeLoadingPromise = createIframe();
434
+ }
435
+ return coreIframeLoadingPromise;
436
+ }
437
+ function createIframe() {
438
+ return new Promise((resolve, reject) => {
439
+ const iframe = document.createElement("iframe");
440
+ iframe.setAttribute("src", getIframeUrl(_env, _coreVersion));
441
+ iframe.setAttribute("name", IFRAME_NAME);
442
+ iframe.setAttribute("id", IFRAME_NAME);
443
+ iframe.setAttribute("class", IFRAME_NAME);
444
+ iframe.setAttribute("allow", "geolocation");
445
+ iframe.onload = () => {
446
+ resolve(iframe);
447
+ };
448
+ iframe.onerror = reject;
449
+ iframe.style.all = "initial";
450
+ iframe.style.width = "100%";
451
+ iframe.style.height = "100%";
452
+ iframe.style.border = "none";
453
+ const container = getCoreIframeContainer();
454
+ container.replaceChildren(iframe);
455
+ });
456
+ }
397
457
  let env;
398
458
  let useAllFunctions = false;
399
459
  let coreVersion = "";
@@ -405,7 +465,7 @@ const commonMessageHandler = (e) => {
405
465
  window.location.reload();
406
466
  }
407
467
  if (e.data.name === PPUtilFunctionName.makeVisible) {
408
- showIframe(true);
468
+ showCoreIframe(true);
409
469
  return;
410
470
  }
411
471
  if (e.data.name === PPUtilFunctionName.link) {
@@ -437,7 +497,7 @@ function init(params) {
437
497
  const ott = url2.searchParams.get("one_time_token");
438
498
  const refreshToken = getRefreshToken();
439
499
  const codeVerifier = getCodeVerifier();
440
- const clientVersion = "2.3.0";
500
+ const clientVersion = "2.5.0";
441
501
  useAllFunctions = !!params.useAllFunctions;
442
502
  if (token || ott) {
443
503
  removeTokenFromUrl(url2);
@@ -454,6 +514,7 @@ function init(params) {
454
514
  clientVersion,
455
515
  codeVerifier
456
516
  };
517
+ initCoreIframe(env, coreVersion);
457
518
  triggerPostMessageToCore(PPFunctionName.init, false, params, initParams);
458
519
  }
459
520
  function getAuthStatus(params) {
@@ -510,14 +571,13 @@ function setTitle(params) {
510
571
  }
511
572
  function render(params) {
512
573
  var _a;
513
- const iframe = getIframe();
514
574
  if (!(params == null ? void 0 : params.containerId) || !document.getElementById(params == null ? void 0 : params.containerId)) {
515
575
  (_a = params == null ? void 0 : params.fail) == null ? void 0 : _a.call(params, {
516
576
  errorCode: MiniAppErrorType.badRequestInsufficientParameter
517
577
  });
518
578
  return console.error("Invalid container Id");
519
579
  }
520
- let messageId = functionStart();
580
+ const messageId = functionStart();
521
581
  const getRenderMessageHandler = (e) => {
522
582
  var _a2, _b;
523
583
  if (!checkIFrameOrigin(e.origin, env, coreVersion) || e.data.name !== PPFunctionName.render || e.data.messageId !== messageId) {
@@ -539,7 +599,7 @@ function render(params) {
539
599
  }
540
600
  };
541
601
  addEventListener("message", getRenderMessageHandler);
542
- postMessageToCore(iframe == null ? void 0 : iframe.contentWindow, env, {
602
+ postMessageToCore({
543
603
  name: PPFunctionName.render,
544
604
  params,
545
605
  messageId
@@ -602,51 +662,6 @@ function copyToClipboard(params) {
602
662
  result ? (_a = params == null ? void 0 : params.success) == null ? void 0 : _a.call(params) : (_b = params == null ? void 0 : params.fail) == null ? void 0 : _b.call(params, { errorCode: MiniAppErrorType.other });
603
663
  (_c = params.complete) == null ? void 0 : _c.call(params);
604
664
  }
605
- function getContainer() {
606
- return document.getElementById(containerName);
607
- }
608
- function getIframe() {
609
- var _a;
610
- return (_a = getContainer()) == null ? void 0 : _a.getElementsByTagName("iframe")[0];
611
- }
612
- function showIframe(visible) {
613
- const container = getContainer();
614
- if (container) {
615
- container.style.display = visible ? "initial" : "none";
616
- }
617
- }
618
- function createIframe(env2) {
619
- return new Promise((resolve, reject) => {
620
- if (getIframe()) {
621
- resolve(getIframe());
622
- return;
623
- }
624
- const container = document.createElement("div");
625
- document.createElement("div");
626
- container.setAttribute("id", containerName);
627
- container.setAttribute("class", containerName);
628
- document.body.appendChild(container);
629
- const iframe = document.createElement("iframe");
630
- iframe.setAttribute("src", getIframeUrl(env2, coreVersion));
631
- iframe.setAttribute("name", frameName);
632
- iframe.setAttribute("id", frameName);
633
- iframe.setAttribute("allow", "geolocation");
634
- iframe.onload = () => resolve(iframe);
635
- iframe.onerror = () => reject();
636
- container.appendChild(iframe);
637
- iframe.style.all = "initial";
638
- iframe.style.width = "100%";
639
- iframe.style.height = "100%";
640
- iframe.style.border = "none";
641
- container.style.all = "initial";
642
- container.style.display = "none";
643
- container.style.position = "fixed";
644
- container.style.width = "100%";
645
- container.style.height = "100%";
646
- container.style.top = "0";
647
- container.style.left = "0";
648
- });
649
- }
650
665
  function receiveMessageFromIframe(messageData, params, eventHandler) {
651
666
  var _a, _b, _c;
652
667
  if (messageData.result === PPFunctionResult.fail) {
@@ -660,14 +675,16 @@ function receiveMessageFromIframe(messageData, params, eventHandler) {
660
675
  removeEventListener("message", eventHandler);
661
676
  functionEnd(messageData.messageId);
662
677
  if (!isFunctionRunning()) {
663
- showIframe(false);
678
+ showCoreIframe(false);
664
679
  }
665
680
  }
666
681
  }
667
- function postMessageToCore(target, env2, messageData) {
668
- target == null ? void 0 : target.postMessage(
682
+ async function postMessageToCore(messageData) {
683
+ var _a;
684
+ const iframe = await getCoreIframe().catch(() => void 0);
685
+ (_a = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _a.postMessage(
669
686
  JSON.parse(JSON.stringify(messageData)),
670
- getIframeOrigin(env2)
687
+ getIframeOrigin(env)
671
688
  );
672
689
  }
673
690
  function removeTokenFromUrl(url2) {
@@ -677,32 +694,23 @@ function removeTokenFromUrl(url2) {
677
694
  history.replaceState(null, "", url2);
678
695
  }
679
696
  function triggerPostMessageToCore(type, showIframeFlag, params, postMessageParams) {
680
- (async () => {
681
- let iframe = null;
682
- if (type === PPFunctionName.init) {
683
- iframe = await createIframe(env);
684
- } else {
685
- iframe = getIframe();
697
+ const messageId = functionStart();
698
+ showCoreIframe(showIframeFlag);
699
+ const fnMessageHandler = (e) => {
700
+ if (!checkIFrameOrigin(e.origin, env, coreVersion)) {
701
+ return;
686
702
  }
687
- const messageId = functionStart();
688
- showIframe(showIframeFlag);
689
- const fnMessageHandler = (e) => {
690
- if (!checkIFrameOrigin(e.origin, env, coreVersion)) {
691
- return;
692
- }
693
- if (e.data.name === type) {
694
- if (e.data.messageId === messageId) {
695
- receiveMessageFromIframe(e.data, params, fnMessageHandler);
696
- }
703
+ if (e.data.name === type) {
704
+ if (e.data.messageId === messageId) {
705
+ receiveMessageFromIframe(e.data, params, fnMessageHandler);
697
706
  }
698
- };
699
- addEventListener("message", fnMessageHandler);
700
- postMessageToCore(iframe == null ? void 0 : iframe.contentWindow, env, {
701
- name: type,
702
- params: postMessageParams,
703
- messageId
704
- });
705
- })().catch(() => {
707
+ }
708
+ };
709
+ addEventListener("message", fnMessageHandler);
710
+ postMessageToCore({
711
+ name: type,
712
+ params: postMessageParams,
713
+ messageId
706
714
  });
707
715
  }
708
716
  function renderButton(data, params) {
@@ -772,9 +780,9 @@ function renderButton(data, params) {
772
780
  }
773
781
  }
774
782
  const clientJsBridge = {
775
- _handleMessageFromNative: (json) => {
783
+ _handleMessageFromNative: async (json) => {
776
784
  var _a;
777
- const iframe = getIframe();
785
+ const iframe = await getCoreIframe();
778
786
  (_a = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _a.postMessage(
779
787
  JSON.parse(
780
788
  JSON.stringify({
package/dist/types.d.ts CHANGED
@@ -442,13 +442,13 @@ export declare const PaymentFeatureTypes: {
442
442
  readonly FALLBACK_PAYMENT_METHOD: "FALLBACK_PAYMENT_METHOD";
443
443
  readonly RECOMMEND: "RECOMMEND";
444
444
  };
445
- export declare type PaymentFeatureType = typeof PaymentFeatureTypes[keyof typeof PaymentFeatureTypes];
445
+ export declare type PaymentFeatureType = (typeof PaymentFeatureTypes)[keyof typeof PaymentFeatureTypes];
446
446
  export declare const ConsultPaymentFeatureTypes: {
447
447
  readonly PRE_TRANSACTION_AUTO_CHARGE: "PRE_TRANSACTION_AUTO_CHARGE";
448
448
  readonly FALLBACK_PAYMENT_METHOD: "FALLBACK_PAYMENT_METHOD";
449
449
  readonly NONE: "NONE";
450
450
  };
451
- export declare type ConsultPaymentFeatureType = typeof ConsultPaymentFeatureTypes[keyof typeof ConsultPaymentFeatureTypes];
451
+ export declare type ConsultPaymentFeatureType = (typeof ConsultPaymentFeatureTypes)[keyof typeof ConsultPaymentFeatureTypes];
452
452
  export interface RegisterPaymentFeaturesParams extends NativeParams<void> {
453
453
  paymentFeatureType: PaymentFeatureType;
454
454
  redirectUrl?: string;
@@ -519,14 +519,14 @@ export declare const AddShortcutTypes: {
519
519
  readonly FAVORITE: "FAVORITE";
520
520
  readonly OS_HOME_SCREEN_ICON: "OS_HOME_SCREEN_ICON";
521
521
  };
522
- export declare type AddShortcutType = typeof AddShortcutTypes[keyof typeof AddShortcutTypes];
522
+ export declare type AddShortcutType = (typeof AddShortcutTypes)[keyof typeof AddShortcutTypes];
523
523
  export interface AddShortcutParams extends NativeParams<void> {
524
524
  type: AddShortcutType;
525
525
  }
526
526
  export declare const ShortcutExistsTypes: {
527
527
  readonly FAVORITE: "FAVORITE";
528
528
  };
529
- export declare type ShortcutExistsType = typeof ShortcutExistsTypes[keyof typeof ShortcutExistsTypes];
529
+ export declare type ShortcutExistsType = (typeof ShortcutExistsTypes)[keyof typeof ShortcutExistsTypes];
530
530
  export interface ShortcutExistsParams extends NativeParams<MiniAppResult> {
531
531
  type: ShortcutExistsType;
532
532
  }
@@ -540,7 +540,7 @@ export declare const PPFunctionResult: {
540
540
  readonly fail: "fail";
541
541
  readonly complete: "complete";
542
542
  };
543
- export declare type PPFunctionResultType = typeof PPFunctionResult[keyof typeof PPFunctionResult];
543
+ export declare type PPFunctionResultType = (typeof PPFunctionResult)[keyof typeof PPFunctionResult];
544
544
  export declare type CoreMessageData<T> = {
545
545
  name: PPFunctionNameType;
546
546
  result: PPFunctionResultType;
@@ -639,7 +639,7 @@ export declare const PPFunctionName: {
639
639
  readonly smsAuth: "smsAuth";
640
640
  readonly getKycPassportInfo: "getKycPassportInfo";
641
641
  };
642
- export declare type PPFunctionNameType = typeof PPFunctionName[keyof typeof PPFunctionName];
642
+ export declare type PPFunctionNameType = (typeof PPFunctionName)[keyof typeof PPFunctionName];
643
643
  export declare const PPUtilFunctionName: {
644
644
  readonly reload: "reload";
645
645
  readonly link: "link";
@@ -648,7 +648,7 @@ export declare const PPUtilFunctionName: {
648
648
  readonly makeVisible: "makeVisible";
649
649
  readonly consoleDebugInfo: "consoleDebugInfo";
650
650
  };
651
- export declare type PPUtilFunctionNameType = typeof PPUtilFunctionName[keyof typeof PPUtilFunctionName];
651
+ export declare type PPUtilFunctionNameType = (typeof PPUtilFunctionName)[keyof typeof PPUtilFunctionName];
652
652
  export declare type SaveRefreshTokenOption = {
653
653
  refreshToken: string;
654
654
  domain: string;
@@ -44,6 +44,8 @@ export declare function getEventLabel(merchant?: string | null): string;
44
44
  export declare function getEventCategory(): string;
45
45
  export declare function semVerCompare(a: string, b: string): boolean;
46
46
  export declare function checkVersion(minVersion: string): boolean;
47
+ declare type FontSize = 'REGULAR' | 'LARGE' | 'EXTRA_LARGE';
48
+ export declare function getPlatformFontSize(): FontSize;
47
49
  export declare function delay(time?: number): Promise<boolean>;
48
50
  export declare const createErrorCode: (errorCode: MiniAppErrorType, jws?: string | null | undefined) => {
49
51
  errorCode: MiniAppErrorType;
@@ -3,4 +3,4 @@ export declare const GetKycPassportErrorSheet: {
3
3
  readonly VERIFY_EXPIRED: "verifyExpired";
4
4
  readonly FALLBACK_SMS: "fallbackSMS";
5
5
  };
6
- export declare type GetKycPassportErrorSheetType = typeof GetKycPassportErrorSheet[keyof typeof GetKycPassportErrorSheet];
6
+ export declare type GetKycPassportErrorSheetType = (typeof GetKycPassportErrorSheet)[keyof typeof GetKycPassportErrorSheet];
@@ -5,7 +5,7 @@ export declare const AutoTopupModeType: {
5
5
  readonly PRE_AUTO_TOPUP: "PreAutoTopup";
6
6
  readonly UNREGISTERED: "Unregistered";
7
7
  };
8
- export declare type AutoTopupMode = typeof AutoTopupModeType[keyof typeof AutoTopupModeType];
8
+ export declare type AutoTopupMode = (typeof AutoTopupModeType)[keyof typeof AutoTopupModeType];
9
9
  export declare type GetTopupConfigurationParams = {
10
10
  includePaymentMethodList: boolean;
11
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypay/mini-app-js-sdk",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "build": "yarn build:client && yarn build:core && yarn build:client:nightly",
@@ -52,8 +52,8 @@
52
52
  "@types/js-cookie": "^2.2.7",
53
53
  "@types/ua-parser-js": "^0.7.36",
54
54
  "@types/uuid": "^8.3.1",
55
- "@typescript-eslint/eslint-plugin": "^5.8.0",
56
- "@typescript-eslint/parser": "^4.31.0",
55
+ "@typescript-eslint/eslint-plugin": "^5.58.0",
56
+ "@typescript-eslint/parser": "^5.58.0",
57
57
  "@vitejs/plugin-vue": "^1.10.2",
58
58
  "@vitejs/plugin-vue-jsx": "^1.3.10",
59
59
  "@vue/babel-plugin-jsx": "^1.0.7",
@@ -61,9 +61,10 @@
61
61
  "@vue/test-utils": "^2.0.0-rc.21",
62
62
  "acorn-jsx": "^5.3.2",
63
63
  "babel-jest": "^26.6.3",
64
- "eslint": "^7.32.0",
65
- "eslint-config-prettier": "^8.3.0",
66
- "eslint-plugin-vue": "^7.17.0",
64
+ "eslint": "^8.38.0",
65
+ "eslint-config-prettier": "^8.8.0",
66
+ "eslint-plugin-prettier": "^4.2.1",
67
+ "eslint-plugin-vue": "^9.10.0",
67
68
  "husky": "^7.0.2",
68
69
  "identity-obj-proxy": "^3.0.0",
69
70
  "ip": "^1.1.8",
@@ -76,14 +77,14 @@
76
77
  "lint-staged": "^11.1.2",
77
78
  "postcss-html": "^1.4.1",
78
79
  "postcss-less": "^6.0.0",
79
- "prettier": "^2.3.2",
80
+ "prettier": "^2.8.7",
80
81
  "stylelint": "^14.9.1",
81
82
  "ts-jest": "^26.5.6",
82
83
  "typescript": "~4.4.2",
83
84
  "vite": "^2.9.15",
84
85
  "vite-plugin-css-injected-by-js": "^2.1.0",
85
86
  "vite-plugin-dts": "^0.9.10",
86
- "vue-eslint-parser": "^7.11.0",
87
+ "vue-eslint-parser": "^9.1.1",
87
88
  "vue-jest": "5.0.0-alpha.9",
88
89
  "vue-tsc": "^1.0.24"
89
90
  },