@paypay/mini-app-js-sdk 2.33.0 → 2.37.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.
@@ -218,6 +218,11 @@ const PPUtilFunctionName = {
218
218
  consoleDebugInfo: "consoleDebugInfo",
219
219
  clientPopState: "clientPopState"
220
220
  };
221
+ var SdkType = /* @__PURE__ */ ((SdkType2) => {
222
+ SdkType2["MiniApp"] = "MiniApp";
223
+ SdkType2["SmartPayment"] = "SmartPayment";
224
+ return SdkType2;
225
+ })(SdkType || {});
221
226
  const jsBridgeNamespace = "_PayPayJsBridge";
222
227
  const miniAppSupportedFunctions = [
223
228
  "init",
@@ -277,85 +282,70 @@ const miniAppSupportedFunctions = [
277
282
  "getTransactions",
278
283
  "getPayPayCardInfo",
279
284
  "getExternalLinkageInformation",
280
- "markAsReady"
285
+ "markAsReady",
286
+ "renderCoupons"
287
+ ];
288
+ const smartPaymentSupportedFunctions = [
289
+ "init",
290
+ "createOrder",
291
+ "makePayment",
292
+ "render",
293
+ "logout",
294
+ "getAuthStatus",
295
+ "getUserProfile",
296
+ "getBalance",
297
+ "getUserAddress",
298
+ "getUAID",
299
+ "getCashbackInformation",
300
+ "renderCoupons",
301
+ "getLoginUrl"
281
302
  ];
282
303
  function url(path) {
283
304
  return "https://image.paypay.ne.jp/miniapps/mini-app-sdk/" + path;
284
305
  }
285
306
  const img_paypayRec = url("icon-paypay-rec.svg");
286
307
  const img_paypayRecWhite = url("icon-paypay-rec-white.svg");
287
- var MiniAppErrorType = /* @__PURE__ */ ((MiniAppErrorType2) => {
288
- MiniAppErrorType2["success"] = "SUCCESS";
289
- MiniAppErrorType2["invalidUrl"] = "INVALID_URL";
290
- MiniAppErrorType2["invalidData"] = "INVALID_DATA";
291
- MiniAppErrorType2["invalidHeader"] = "INVALID_HEADER";
292
- MiniAppErrorType2["invalidMethod"] = "INVALID_METHOD";
293
- MiniAppErrorType2["invalidPath"] = "INVALID_PATH";
294
- MiniAppErrorType2["notReachable"] = "NOT_REACHABLE";
295
- MiniAppErrorType2["notAvailable"] = "NOT_AVAILABLE";
296
- MiniAppErrorType2["timeOut"] = "TIME_OUT";
297
- MiniAppErrorType2["whiteListError"] = "NONE_WHITELIST_DOMAIN";
298
- MiniAppErrorType2["statusCodeError"] = "STATUS_CODE_ERROR";
299
- MiniAppErrorType2["invalidResponse"] = "INVALID_RESPONSE";
300
- MiniAppErrorType2["noLocationPermission"] = "NO_USER_LOCATION_PERMISSION";
301
- MiniAppErrorType2["noPermissionListAvailable"] = "NO_PERMISSION_LIST_AVAILABLE";
302
- MiniAppErrorType2["other"] = "other";
303
- MiniAppErrorType2["serverError"] = "SERVER_ERROR";
304
- MiniAppErrorType2["noCameraPermission"] = "HOST_APP_CAMERA_DENIED";
305
- MiniAppErrorType2["noAlbumPermission"] = "HOST_APP_ALBUM_DENIED";
306
- MiniAppErrorType2["insufficientScope"] = "INSUFFICIENT_SCOPE";
307
- MiniAppErrorType2["userCanceled"] = "USER_CANCELED";
308
- MiniAppErrorType2["invalidJSAPIParams"] = "INVALID_JS_API_PARAMS";
309
- MiniAppErrorType2["hostAppLocationDenied"] = "HOST_APP_LOCATION_DENIED";
310
- MiniAppErrorType2["hostAppContactsDenied"] = "HOST_APP_READING_CONTACT_DENIED";
311
- MiniAppErrorType2["badRequestInsufficientParameter"] = "BAD_REQUEST_INSUFFICIENT_PARAMETER";
312
- MiniAppErrorType2["badRequest"] = "BAD_REQUEST";
313
- MiniAppErrorType2["paymentFail"] = "PAYMENT_FAIL";
314
- MiniAppErrorType2["topupFail"] = "TOPUP_FAIL";
315
- MiniAppErrorType2["topupSuccessButNotAddToBalance"] = "TOPUP_SUCCESS_BUT_NOT_ADD_TO_BALANCE";
316
- MiniAppErrorType2["userCanceledSimilarTxn"] = "USER_CANCELED_SIMILAR_TRANSACTION";
317
- MiniAppErrorType2["mapAppNotFound"] = "MAP_APP_NOT_FOUND";
318
- MiniAppErrorType2["invalidAppSchemeURL"] = "INVALID_APP_SCHEME_URL";
319
- MiniAppErrorType2["noValueFound"] = "NO_VALUE_FOUND";
320
- MiniAppErrorType2["securityNotSetup"] = "SECURITY_NOT_SETUP";
321
- MiniAppErrorType2["userDenied"] = "USER_DENIED";
322
- MiniAppErrorType2["securityTemporaryLocked"] = "SECURITY_TEMPORARY_LOCKED";
323
- MiniAppErrorType2["couldNotGenerateBarcode"] = "COULD_NOT_GENERATE_BARCODE";
324
- MiniAppErrorType2["cannotDetectAvailability"] = "CAN_NOT_DETECT_AVAILABILITY";
325
- MiniAppErrorType2["suspectedDuplicatePayment"] = "SUSPECTED_DUPLICATE_PAYMENT";
326
- MiniAppErrorType2["noSufficientFund"] = "NO_SUFFICIENT_FUND";
327
- MiniAppErrorType2["unknown"] = "UNKNOWN";
328
- MiniAppErrorType2["sdkNotInitialized"] = "SDK_NOT_INITIALIZED";
329
- MiniAppErrorType2["tokenNotFound"] = "TOKEN_NOT_FOUND";
330
- MiniAppErrorType2["tokenExpired"] = "TOKEN_EXPIRED";
331
- MiniAppErrorType2["activeRequestExists"] = "ACTIVE_REQUEST_EXISTS";
332
- MiniAppErrorType2["invalidType"] = "INVALID_TYPE";
333
- MiniAppErrorType2["sessionNotFound"] = "SESSION_NOT_FOUND";
334
- MiniAppErrorType2["cookieError"] = "COOKIE_ERROR";
335
- MiniAppErrorType2["notAuthorized"] = "NOT_AUTHORIZED";
336
- MiniAppErrorType2["permissionRequired"] = "PERMISSION_REQUIRED";
337
- MiniAppErrorType2["deeplinkUnavailable"] = "DEEPLINK_UNAVAILABLE";
338
- MiniAppErrorType2["kycIncompleted"] = "KYC_INCOMPLETED";
339
- MiniAppErrorType2["noBankAccount"] = "NO_BANK_ACCOUNT";
340
- MiniAppErrorType2["invalidPaymentIdentifier"] = "INVALID_PAYMENT_IDENTIFIER";
341
- MiniAppErrorType2["otpSendTooShort"] = "OTP_SEND_TOO_SHORT";
342
- MiniAppErrorType2["otpSendOverLimit"] = "OTP_SEND_OVER_LIMIT";
343
- MiniAppErrorType2["userVerificationFailure"] = "USER_VERIFICATION_FAILURE";
344
- MiniAppErrorType2["unacceptableOp"] = "UNACCEPTABLE_OP";
345
- MiniAppErrorType2["kycUpdateRequired"] = "KYC_UPDATE_REQUIRED";
346
- MiniAppErrorType2["notCompleted"] = "NOT_COMPLETED";
347
- MiniAppErrorType2["kycValidationInProcess"] = "KYC_VALIDATION_IN_PROCESS";
348
- MiniAppErrorType2["noLocationData"] = "NO_LOCATION_DATA";
349
- MiniAppErrorType2["functionNotFound"] = "FUNCTION_NOT_FOUND";
350
- MiniAppErrorType2["originNotAllowed"] = "ORIGIN_NOT_ALLOWED";
351
- MiniAppErrorType2["messageSendingFailed"] = "MESSAGE_SENDING_FAILED";
352
- MiniAppErrorType2["transactionNotFound"] = "TRANSACTION_NOT_FOUND";
353
- MiniAppErrorType2["unexpectedOperation"] = "UNEXPECTED_OP";
354
- MiniAppErrorType2["merchantTimeout"] = "MERCHANT_TIMEOUT";
355
- MiniAppErrorType2["rateLimitExceeded"] = "RATE_LIMIT_EXCEEDED";
356
- MiniAppErrorType2["sdkUpgradeRequired"] = "SDK_UPGRADE_REQUIRED";
357
- return MiniAppErrorType2;
358
- })(MiniAppErrorType || {});
308
+ var getRandomValues;
309
+ var rnds8 = new Uint8Array(16);
310
+ function rng() {
311
+ if (!getRandomValues) {
312
+ getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== "undefined" && typeof msCrypto.getRandomValues === "function" && msCrypto.getRandomValues.bind(msCrypto);
313
+ if (!getRandomValues) {
314
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
315
+ }
316
+ }
317
+ return getRandomValues(rnds8);
318
+ }
319
+ const REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
320
+ function validate(uuid) {
321
+ return typeof uuid === "string" && REGEX.test(uuid);
322
+ }
323
+ var byteToHex = [];
324
+ for (var i = 0; i < 256; ++i) {
325
+ byteToHex.push((i + 256).toString(16).substr(1));
326
+ }
327
+ function stringify(arr) {
328
+ var offset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
329
+ var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
330
+ if (!validate(uuid)) {
331
+ throw TypeError("Stringified UUID is invalid");
332
+ }
333
+ return uuid;
334
+ }
335
+ function v4(options, buf, offset) {
336
+ options = options || {};
337
+ var rnds = options.random || (options.rng || rng)();
338
+ rnds[6] = rnds[6] & 15 | 64;
339
+ rnds[8] = rnds[8] & 63 | 128;
340
+ if (buf) {
341
+ offset = offset || 0;
342
+ for (var i = 0; i < 16; ++i) {
343
+ buf[offset + i] = rnds[i];
344
+ }
345
+ return buf;
346
+ }
347
+ return stringify(rnds);
348
+ }
359
349
  function isIP(hostName) {
360
350
  return isIPv4(hostName) || isIPv6(hostName);
361
351
  }
@@ -707,8 +697,8 @@ function parseDomain(domain) {
707
697
  function getDomain(subdomainCookieSharing, hostname) {
708
698
  return subdomainCookieSharing ? parseDomain(hostname) : hostname;
709
699
  }
710
- const JS_SDK_VERSION = "2.33.0";
711
- const REVISION = "5833fe0";
700
+ const JS_SDK_VERSION = "2.37.0";
701
+ const REVISION = "1b5c920";
712
702
  const coreBaseUrl = new URL("https://mini-app-sdk-core.paypay.ne.jp/");
713
703
  const CORE_IFRAME_ORIGIN = coreBaseUrl.origin;
714
704
  const CORE_IFRAME_URL = new URL(
@@ -720,6 +710,80 @@ const COUPON_IFRAME_URL = new URL(
720
710
  coreBaseUrl
721
711
  ).href;
722
712
  const SENTRY_DSN = "https://377b45f154b1fb17d8e98a6ffb67030a@o4505819519320064.ingest.sentry.io/4506579323453440";
713
+ const GA_API_SECRET = "fgPKRkdQQvq7XbV4qw3MOQ";
714
+ const GA_MEASUREMENT_ID = "G-M64Q2828RR";
715
+ var MiniAppErrorType = /* @__PURE__ */ ((MiniAppErrorType2) => {
716
+ MiniAppErrorType2["success"] = "SUCCESS";
717
+ MiniAppErrorType2["invalidUrl"] = "INVALID_URL";
718
+ MiniAppErrorType2["invalidData"] = "INVALID_DATA";
719
+ MiniAppErrorType2["invalidHeader"] = "INVALID_HEADER";
720
+ MiniAppErrorType2["invalidMethod"] = "INVALID_METHOD";
721
+ MiniAppErrorType2["invalidPath"] = "INVALID_PATH";
722
+ MiniAppErrorType2["notReachable"] = "NOT_REACHABLE";
723
+ MiniAppErrorType2["notAvailable"] = "NOT_AVAILABLE";
724
+ MiniAppErrorType2["timeOut"] = "TIME_OUT";
725
+ MiniAppErrorType2["whiteListError"] = "NONE_WHITELIST_DOMAIN";
726
+ MiniAppErrorType2["statusCodeError"] = "STATUS_CODE_ERROR";
727
+ MiniAppErrorType2["invalidResponse"] = "INVALID_RESPONSE";
728
+ MiniAppErrorType2["noLocationPermission"] = "NO_USER_LOCATION_PERMISSION";
729
+ MiniAppErrorType2["noPermissionListAvailable"] = "NO_PERMISSION_LIST_AVAILABLE";
730
+ MiniAppErrorType2["other"] = "other";
731
+ MiniAppErrorType2["serverError"] = "SERVER_ERROR";
732
+ MiniAppErrorType2["noCameraPermission"] = "HOST_APP_CAMERA_DENIED";
733
+ MiniAppErrorType2["noAlbumPermission"] = "HOST_APP_ALBUM_DENIED";
734
+ MiniAppErrorType2["insufficientScope"] = "INSUFFICIENT_SCOPE";
735
+ MiniAppErrorType2["userCanceled"] = "USER_CANCELED";
736
+ MiniAppErrorType2["invalidJSAPIParams"] = "INVALID_JS_API_PARAMS";
737
+ MiniAppErrorType2["hostAppLocationDenied"] = "HOST_APP_LOCATION_DENIED";
738
+ MiniAppErrorType2["hostAppContactsDenied"] = "HOST_APP_READING_CONTACT_DENIED";
739
+ MiniAppErrorType2["badRequestInsufficientParameter"] = "BAD_REQUEST_INSUFFICIENT_PARAMETER";
740
+ MiniAppErrorType2["badRequest"] = "BAD_REQUEST";
741
+ MiniAppErrorType2["paymentFail"] = "PAYMENT_FAIL";
742
+ MiniAppErrorType2["topupFail"] = "TOPUP_FAIL";
743
+ MiniAppErrorType2["topupSuccessButNotAddToBalance"] = "TOPUP_SUCCESS_BUT_NOT_ADD_TO_BALANCE";
744
+ MiniAppErrorType2["userCanceledSimilarTxn"] = "USER_CANCELED_SIMILAR_TRANSACTION";
745
+ MiniAppErrorType2["mapAppNotFound"] = "MAP_APP_NOT_FOUND";
746
+ MiniAppErrorType2["invalidAppSchemeURL"] = "INVALID_APP_SCHEME_URL";
747
+ MiniAppErrorType2["noValueFound"] = "NO_VALUE_FOUND";
748
+ MiniAppErrorType2["securityNotSetup"] = "SECURITY_NOT_SETUP";
749
+ MiniAppErrorType2["userDenied"] = "USER_DENIED";
750
+ MiniAppErrorType2["securityTemporaryLocked"] = "SECURITY_TEMPORARY_LOCKED";
751
+ MiniAppErrorType2["couldNotGenerateBarcode"] = "COULD_NOT_GENERATE_BARCODE";
752
+ MiniAppErrorType2["cannotDetectAvailability"] = "CAN_NOT_DETECT_AVAILABILITY";
753
+ MiniAppErrorType2["suspectedDuplicatePayment"] = "SUSPECTED_DUPLICATE_PAYMENT";
754
+ MiniAppErrorType2["noSufficientFund"] = "NO_SUFFICIENT_FUND";
755
+ MiniAppErrorType2["unknown"] = "UNKNOWN";
756
+ MiniAppErrorType2["sdkNotInitialized"] = "SDK_NOT_INITIALIZED";
757
+ MiniAppErrorType2["tokenNotFound"] = "TOKEN_NOT_FOUND";
758
+ MiniAppErrorType2["tokenExpired"] = "TOKEN_EXPIRED";
759
+ MiniAppErrorType2["activeRequestExists"] = "ACTIVE_REQUEST_EXISTS";
760
+ MiniAppErrorType2["invalidType"] = "INVALID_TYPE";
761
+ MiniAppErrorType2["sessionNotFound"] = "SESSION_NOT_FOUND";
762
+ MiniAppErrorType2["cookieError"] = "COOKIE_ERROR";
763
+ MiniAppErrorType2["notAuthorized"] = "NOT_AUTHORIZED";
764
+ MiniAppErrorType2["permissionRequired"] = "PERMISSION_REQUIRED";
765
+ MiniAppErrorType2["deeplinkUnavailable"] = "DEEPLINK_UNAVAILABLE";
766
+ MiniAppErrorType2["kycIncompleted"] = "KYC_INCOMPLETED";
767
+ MiniAppErrorType2["noBankAccount"] = "NO_BANK_ACCOUNT";
768
+ MiniAppErrorType2["invalidPaymentIdentifier"] = "INVALID_PAYMENT_IDENTIFIER";
769
+ MiniAppErrorType2["otpSendTooShort"] = "OTP_SEND_TOO_SHORT";
770
+ MiniAppErrorType2["otpSendOverLimit"] = "OTP_SEND_OVER_LIMIT";
771
+ MiniAppErrorType2["userVerificationFailure"] = "USER_VERIFICATION_FAILURE";
772
+ MiniAppErrorType2["unacceptableOp"] = "UNACCEPTABLE_OP";
773
+ MiniAppErrorType2["kycUpdateRequired"] = "KYC_UPDATE_REQUIRED";
774
+ MiniAppErrorType2["notCompleted"] = "NOT_COMPLETED";
775
+ MiniAppErrorType2["kycValidationInProcess"] = "KYC_VALIDATION_IN_PROCESS";
776
+ MiniAppErrorType2["noLocationData"] = "NO_LOCATION_DATA";
777
+ MiniAppErrorType2["functionNotFound"] = "FUNCTION_NOT_FOUND";
778
+ MiniAppErrorType2["originNotAllowed"] = "ORIGIN_NOT_ALLOWED";
779
+ MiniAppErrorType2["messageSendingFailed"] = "MESSAGE_SENDING_FAILED";
780
+ MiniAppErrorType2["transactionNotFound"] = "TRANSACTION_NOT_FOUND";
781
+ MiniAppErrorType2["unexpectedOperation"] = "UNEXPECTED_OP";
782
+ MiniAppErrorType2["merchantTimeout"] = "MERCHANT_TIMEOUT";
783
+ MiniAppErrorType2["rateLimitExceeded"] = "RATE_LIMIT_EXCEEDED";
784
+ MiniAppErrorType2["sdkUpgradeRequired"] = "SDK_UPGRADE_REQUIRED";
785
+ return MiniAppErrorType2;
786
+ })(MiniAppErrorType || {});
723
787
  const objectToString = Object.prototype.toString;
724
788
  function isBuiltin(wat, className) {
725
789
  return objectToString.call(wat) === `[object ${className}]`;
@@ -833,14 +897,14 @@ function _dropUndefinedKeys(inputValue, memoizationMap) {
833
897
  }
834
898
  function uuid4() {
835
899
  const gbl = GLOBAL_OBJ;
836
- const crypto = gbl.crypto || gbl.msCrypto;
900
+ const crypto2 = gbl.crypto || gbl.msCrypto;
837
901
  let getRandomByte = () => Math.random() * 16;
838
902
  try {
839
- if (crypto && crypto.randomUUID) {
840
- return crypto.randomUUID().replace(/-/g, "");
903
+ if (crypto2 && crypto2.randomUUID) {
904
+ return crypto2.randomUUID().replace(/-/g, "");
841
905
  }
842
- if (crypto && crypto.getRandomValues) {
843
- getRandomByte = () => crypto.getRandomValues(new Uint8Array(1))[0];
906
+ if (crypto2 && crypto2.getRandomValues) {
907
+ getRandomByte = () => crypto2.getRandomValues(new Uint8Array(1))[0];
844
908
  }
845
909
  } catch (_) {
846
910
  }
@@ -2041,13 +2105,6 @@ function addBreadcrumbToSentry(breadcrumb) {
2041
2105
  addBreadcrumb(breadcrumb);
2042
2106
  }
2043
2107
  }
2044
- ({
2045
- UNAUTHORIZED: MiniAppErrorType.notAuthorized,
2046
- BAD_REQUEST: MiniAppErrorType.badRequest,
2047
- MISSING_REQUEST_PARAMS: MiniAppErrorType.badRequestInsufficientParameter,
2048
- OP_OUT_OF_SCOPE: MiniAppErrorType.insufficientScope,
2049
- MINI_APP_SCOPE_NOT_FOUND: MiniAppErrorType.insufficientScope
2050
- });
2051
2108
  let clientId = "";
2052
2109
  function getCurrentClientId() {
2053
2110
  return clientId;
@@ -2110,10 +2167,74 @@ class LocalStorageProxy {
2110
2167
  this.memoryStorage = {};
2111
2168
  }
2112
2169
  }
2113
- new LocalStorageProxy();
2114
- function isPayPayMiniApp() {
2115
- return navigator.userAgent.includes("PayPayMiniApp/");
2170
+ const storage = new LocalStorageProxy();
2171
+ function getKeyWithClientId(baseKey, clientId2) {
2172
+ return `${baseKey}.${clientId2 != null ? clientId2 : getCurrentClientId()}`;
2173
+ }
2174
+ function saveLocalStorage(key, value) {
2175
+ removeLocalStorage(key);
2176
+ if (value) {
2177
+ return storage.setItem(key, value);
2178
+ }
2179
+ }
2180
+ function removeLocalStorage(key) {
2181
+ storage.removeItem(key);
2182
+ }
2183
+ function saveClientUUID(uuid) {
2184
+ saveLocalStorage(getKeyWithClientId(PpLocalStorageKey.clientUUID), uuid);
2185
+ }
2186
+ function getClientUUID() {
2187
+ let uuid = storage.getItem(getKeyWithClientId(PpLocalStorageKey.clientUUID)) || "";
2188
+ if (!validate(uuid)) {
2189
+ uuid = v4();
2190
+ saveClientUUID(uuid);
2191
+ }
2192
+ return uuid;
2193
+ }
2194
+ function getAppDetail(clientId2) {
2195
+ const val = storage.getItem(
2196
+ getKeyWithClientId(PpLocalStorageKey.appDetail, clientId2)
2197
+ );
2198
+ if (val == null) {
2199
+ return null;
2200
+ }
2201
+ return JSON.parse(val);
2202
+ }
2203
+ let timeoutId = null;
2204
+ let eventsQueue = [];
2205
+ function sendEvents() {
2206
+ var _a;
2207
+ const events = eventsQueue;
2208
+ eventsQueue = [];
2209
+ timeoutId = null;
2210
+ navigator.sendBeacon(
2211
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
2212
+ `https://www.google-analytics.com/mp/collect?api_secret=${GA_API_SECRET}&measurement_id=${GA_MEASUREMENT_ID}`,
2213
+ JSON.stringify({
2214
+ client_id: getClientUUID(),
2215
+ events,
2216
+ user_id: (_a = getAppDetail()) == null ? void 0 : _a.externalUserId
2217
+ })
2218
+ );
2116
2219
  }
2220
+ getRandomString();
2221
+ document.addEventListener("visibilitychange", () => {
2222
+ if (document.visibilityState === "hidden") {
2223
+ if (eventsQueue.length > 0) {
2224
+ if (timeoutId) {
2225
+ clearTimeout(timeoutId);
2226
+ }
2227
+ sendEvents();
2228
+ }
2229
+ }
2230
+ });
2231
+ ({
2232
+ UNAUTHORIZED: MiniAppErrorType.notAuthorized,
2233
+ BAD_REQUEST: MiniAppErrorType.badRequest,
2234
+ MISSING_REQUEST_PARAMS: MiniAppErrorType.badRequestInsufficientParameter,
2235
+ OP_OUT_OF_SCOPE: MiniAppErrorType.insufficientScope,
2236
+ MINI_APP_SCOPE_NOT_FOUND: MiniAppErrorType.insufficientScope
2237
+ });
2117
2238
  function getAppVersion() {
2118
2239
  var _a, _b, _c, _d;
2119
2240
  let appVersion = null;
@@ -2149,13 +2270,6 @@ function checkVersion(minVersion) {
2149
2270
  function getRandomString() {
2150
2271
  return Math.random().toString(36).substring(7);
2151
2272
  }
2152
- function getEventCategory(params) {
2153
- var _a;
2154
- const clientId2 = (_a = params == null ? void 0 : params.clientId) != null ? _a : getCurrentClientId();
2155
- const featureName = (params == null ? void 0 : params.featureName) ? `_${params == null ? void 0 : params.featureName}` : "";
2156
- const sdkType = (params == null ? void 0 : params.sdkType) ? params.sdkType : isPayPayMiniApp() ? "miniapp" : "smartpayment";
2157
- return `${sdkType}_${clientId2}${featureName}`;
2158
- }
2159
2273
  function checkIFrameOrigin(origin) {
2160
2274
  return origin === CORE_IFRAME_ORIGIN;
2161
2275
  }
@@ -2192,15 +2306,10 @@ function getCodeVerifier() {
2192
2306
  return api.get(PpLocalStorageKey.codeVerifier) || "";
2193
2307
  }
2194
2308
  function exposeClientJsBridge(jsBridge) {
2195
- const global2 = window;
2196
- if (
2197
- // eslint-disable-next-line no-prototype-builtins, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
2198
- global2.hasOwnProperty(jsBridgeNamespace) && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2199
- global2[jsBridgeNamespace] === jsBridge
2200
- ) {
2309
+ if (window.hasOwnProperty(jsBridgeNamespace) && window[jsBridgeNamespace] === jsBridge) {
2201
2310
  return false;
2202
2311
  }
2203
- global2[jsBridgeNamespace] = jsBridge;
2312
+ window[jsBridgeNamespace] = jsBridge;
2204
2313
  return true;
2205
2314
  }
2206
2315
  function consoleDebugInfo(params) {
@@ -2209,6 +2318,11 @@ function consoleDebugInfo(params) {
2209
2318
  function isSupportedMiniapp(functionName) {
2210
2319
  return miniAppSupportedFunctions.includes(functionName);
2211
2320
  }
2321
+ function isSupportedSmartpayment(functionName) {
2322
+ return smartPaymentSupportedFunctions.includes(
2323
+ functionName
2324
+ );
2325
+ }
2212
2326
  let runningFunctions = [];
2213
2327
  function isFunctionRunning() {
2214
2328
  return runningFunctions.length > 0;
@@ -2229,13 +2343,13 @@ function promiseToCallback(functionName, target, getCore2, getLoggingParams) {
2229
2343
  const loggingParams = getLoggingParams == null ? void 0 : getLoggingParams(params);
2230
2344
  void core2.logEvent(__spreadValues({
2231
2345
  event_action: `pp_${functionName}_called`,
2232
- event_category: getEventCategory({ featureName: functionName })
2346
+ event_category_suffix: functionName
2233
2347
  }, loggingParams));
2234
2348
  target(params).then((result) => {
2235
2349
  var _a;
2236
2350
  void core2.logEvent(__spreadValues({
2237
2351
  event_action: `pp_${functionName}_success`,
2238
- event_category: getEventCategory({ featureName: functionName })
2352
+ event_category_suffix: functionName
2239
2353
  }, loggingParams));
2240
2354
  (_a = params.success) == null ? void 0 : _a.call(params, result);
2241
2355
  }).catch((error) => {
@@ -2243,7 +2357,7 @@ function promiseToCallback(functionName, target, getCore2, getLoggingParams) {
2243
2357
  console.error(error.message);
2244
2358
  void core2.logEvent(__spreadValues({
2245
2359
  event_action: `pp_${functionName}_fail`,
2246
- event_category: getEventCategory({ featureName: functionName }),
2360
+ event_category_suffix: functionName,
2247
2361
  error_value: error.errorCode
2248
2362
  }, loggingParams));
2249
2363
  (_a = params.fail) == null ? void 0 : _a.call(params, { errorCode: error.errorCode });
@@ -2575,6 +2689,7 @@ function createIframe() {
2575
2689
  });
2576
2690
  }
2577
2691
  let useAllFunctions = false;
2692
+ let clientSdkType;
2578
2693
  let initDonePromise;
2579
2694
  WindowBridge.init({});
2580
2695
  void getCoreIframe();
@@ -2641,7 +2756,7 @@ function init(params) {
2641
2756
  const ott = url2.searchParams.get("one_time_token");
2642
2757
  const refreshToken = getRefreshToken();
2643
2758
  const codeVerifier = getCodeVerifier();
2644
- const clientVersion = "2.33.0";
2759
+ const clientVersion = "2.37.0";
2645
2760
  useAllFunctions = !!params.useAllFunctions;
2646
2761
  if (token || ott) {
2647
2762
  removeTokenFromUrl(url2);
@@ -2655,7 +2770,8 @@ function init(params) {
2655
2770
  ott,
2656
2771
  refreshToken,
2657
2772
  clientVersion,
2658
- codeVerifier
2773
+ codeVerifier,
2774
+ clientSdkType
2659
2775
  };
2660
2776
  let initDonePromiseResolve;
2661
2777
  const nextInitDonePromise = new Promise(
@@ -3102,52 +3218,66 @@ const initExemptedFunctions = [
3102
3218
  "getLoginUrl"
3103
3219
  ];
3104
3220
  const autoInitFunctions = ["renderCoupons"];
3105
- const proxy = new Proxy(clientFunctions, {
3106
- get(target, prop) {
3107
- const functionName = prop;
3108
- if (!useAllFunctions) {
3109
- if (!isSupportedMiniapp(functionName)) {
3110
- throw new Error(`${functionName} is not supported by Mini Apps JS SDK`);
3111
- }
3112
- }
3113
- return (params) => __async(this, null, function* () {
3114
- var _a, _b;
3115
- if (!initExemptedFunctions.includes(functionName) && !(yield initDonePromise)) {
3116
- if (autoInitFunctions.includes(functionName) && params.clientId) {
3117
- init({ clientId: params.clientId, env: params.env });
3118
- yield initDonePromise;
3119
- } else {
3120
- (_a = params.fail) == null ? void 0 : _a.call(params, { errorCode: MiniAppErrorType.sdkNotInitialized });
3121
- (_b = params.complete) == null ? void 0 : _b.call(params);
3122
- return;
3123
- }
3124
- }
3125
- if (Object.prototype.hasOwnProperty.call(target, functionName)) {
3126
- return target[functionName](params);
3127
- }
3128
- triggerPostMessageToCore(
3129
- prop,
3130
- false,
3131
- params,
3132
- params
3133
- );
3134
- });
3135
- }
3136
- });
3137
- function executePendingFunctionCalls() {
3221
+ function executePendingFunctionCalls(client2) {
3138
3222
  const pendingFunctionCalls = window._ppcs;
3139
3223
  if (!pendingFunctionCalls) {
3140
3224
  return;
3141
3225
  }
3142
3226
  window._ppcs = void 0;
3143
3227
  for (const [functionName, params] of pendingFunctionCalls) {
3144
- proxy[functionName](params);
3228
+ client2[functionName](params);
3145
3229
  }
3146
3230
  }
3147
- executePendingFunctionCalls();
3148
- proxy.revision = "5833fe0";
3149
- const client = proxy;
3150
- window._pp = client;
3231
+ const clientProperties = {
3232
+ version: "2.37.0",
3233
+ revision: "1b5c920"
3234
+ };
3235
+ function getClient({ sdkType }) {
3236
+ clientSdkType = sdkType;
3237
+ const isSupportedFunction = sdkType === SdkType.MiniApp ? isSupportedMiniapp : isSupportedSmartpayment;
3238
+ const proxy = new Proxy(clientFunctions, {
3239
+ get(target, prop) {
3240
+ if (prop in clientProperties) {
3241
+ return clientProperties[prop];
3242
+ }
3243
+ const functionName = prop;
3244
+ if (!useAllFunctions) {
3245
+ if (!isSupportedFunction(functionName)) {
3246
+ throw new Error(
3247
+ `${functionName} is not supported by ${sdkType} JS SDK`
3248
+ );
3249
+ }
3250
+ }
3251
+ return (params) => __async(this, null, function* () {
3252
+ var _a, _b;
3253
+ if (!initExemptedFunctions.includes(functionName) && !(yield initDonePromise)) {
3254
+ if (autoInitFunctions.includes(functionName) && params.clientId) {
3255
+ init({ clientId: params.clientId, env: params.env });
3256
+ yield initDonePromise;
3257
+ } else {
3258
+ (_a = params.fail) == null ? void 0 : _a.call(params, { errorCode: MiniAppErrorType.sdkNotInitialized });
3259
+ (_b = params.complete) == null ? void 0 : _b.call(params);
3260
+ return;
3261
+ }
3262
+ }
3263
+ if (Object.prototype.hasOwnProperty.call(target, functionName)) {
3264
+ return target[functionName](params);
3265
+ }
3266
+ triggerPostMessageToCore(
3267
+ prop,
3268
+ false,
3269
+ params,
3270
+ params
3271
+ );
3272
+ });
3273
+ }
3274
+ });
3275
+ const client2 = proxy;
3276
+ window._pp = client2;
3277
+ executePendingFunctionCalls(client2);
3278
+ return client2;
3279
+ }
3280
+ const client = getClient({ sdkType: SdkType.MiniApp });
3151
3281
  const miniAppSdk = client;
3152
3282
  export {
3153
3283
  miniAppSdk as default
@@ -1,4 +1,5 @@
1
1
  import { NativeParams } from '../jsbridge-core/jsbridge';
2
+ import { SdkType } from '../types';
2
3
  export interface InitClientParams extends NativeParams<InitResult> {
3
4
  clientId: string;
4
5
  env?: PPEnvType;
@@ -17,6 +18,7 @@ export interface InitParams extends NativeParams<InitResult> {
17
18
  clientVersion?: string;
18
19
  debugMode?: boolean;
19
20
  useAllFunctions?: boolean;
21
+ clientSdkType?: SdkType;
20
22
  }
21
23
  export declare const PPEnv: {
22
24
  readonly staging: "staging";
package/dist/types.d.ts CHANGED
@@ -246,6 +246,7 @@ export declare type AppDetail = {
246
246
  version: string;
247
247
  statusDescription: string;
248
248
  userAuthorizationId: string;
249
+ externalUserId: string;
249
250
  permissions: Permission[];
250
251
  isInternal: boolean;
251
252
  terms: Array<{
@@ -407,9 +408,6 @@ export declare type CashbackResponse = {
407
408
  };
408
409
  };
409
410
  };
410
- export interface ShowStorageAccessPermissionAlertParams extends NativeParams<void> {
411
- clientUrl: string;
412
- }
413
411
  export declare type LinkOption = {
414
412
  url: string;
415
413
  target?: string;
@@ -492,6 +490,10 @@ export declare type ClientJsBridge = {
492
490
  export declare type ConsoleDebugInfoParams = {
493
491
  params: unknown[];
494
492
  };
493
+ export declare enum SdkType {
494
+ MiniApp = "MiniApp",
495
+ SmartPayment = "SmartPayment"
496
+ }
495
497
  export interface PayPayCallStackParamsType {
496
498
  complete?: () => void;
497
499
  [index: string]: unknown;
@@ -501,6 +503,7 @@ declare global {
501
503
  interface Window {
502
504
  _ppcs?: PayPayCallStackType;
503
505
  _ppsl?: boolean;
506
+ _PayPayJsBridge?: ClientJsBridge;
504
507
  }
505
508
  }
506
509
  export {};
@@ -1,4 +1,4 @@
1
- import { PPFunctionNameType } from '../types';
1
+ import { PPFunctionNameType, SdkType } from '../types';
2
2
  import { PPEnvType } from '../types/init';
3
3
  interface EventParams {
4
4
  env: PPEnvType;
@@ -10,6 +10,7 @@ interface EventParams {
10
10
  event_label2?: unknown;
11
11
  merchant_id?: string;
12
12
  order_type?: string;
13
+ user_agent?: string;
13
14
  }
14
15
  interface Options {
15
16
  env?: PPEnvType;
@@ -25,5 +26,6 @@ export declare function handleLogSDKEvent(name: PPFunctionNameType, eventActionS
25
26
  export declare function test_initClientState(params: {
26
27
  clientId: string;
27
28
  clientOrigin: string;
29
+ clientSdkType?: SdkType;
28
30
  }): void;
29
31
  export {};
@@ -17,6 +17,7 @@ declare type PPFetchOptions = {
17
17
  skipResultCodeCheck?: boolean;
18
18
  skipStatusCodeCheck?: boolean;
19
19
  authorizationRequired?: boolean;
20
+ priority?: 'high' | 'low' | 'auto';
20
21
  };
21
22
  declare type APIBaseResponse = {
22
23
  signed: {
@@ -0,0 +1,6 @@
1
+ import { SerializedAppDetail } from '../utils/storage';
2
+ import { Ref } from 'vue';
3
+ export declare function fetchAppDetail(accessToken?: string, options?: {
4
+ priority?: 'high' | 'low';
5
+ }): Promise<SerializedAppDetail>;
6
+ export declare function useAppDetail(): Ref<SerializedAppDetail | null>;
@@ -72,6 +72,7 @@ export declare function getRandomString(): string;
72
72
  export declare function isAlphabet(value: string): boolean;
73
73
  export declare function reconstructKycPassportCallbackUrl(url: string, type: string): string;
74
74
  export declare function getValueFromUA(paramName: string): string | undefined;
75
+ export declare function isBffSitEnvironment(): boolean;
75
76
  export declare function replaceStringPlaceholders(str: string, values: Record<string, string>): string;
76
77
  export declare function validateUrl(url: string): boolean;
77
78
  export declare function constructUrl(baseUrl: string, params: Record<string, string | string[] | number | number[] | boolean | undefined>): string;