@paypay/mini-app-js-sdk 2.56.0 → 2.58.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.
- package/dist/client/communicationWithCore.d.ts +2 -1
- package/dist/composition-api/useKycPassport.d.ts +2 -2
- package/dist/constants/clientUtilFunctionName.d.ts +1 -0
- package/dist/constants/errorCodes.d.ts +1 -0
- package/dist/constants/index.d.ts +11 -0
- package/dist/constants/localStorageKeys.d.ts +1 -0
- package/dist/constants/permissionName.d.ts +1 -0
- package/dist/constants/sdkFunctionNames.d.ts +1 -0
- package/dist/core/coreFunctions/renderButton/types.d.ts +1 -0
- package/dist/core/sentry.d.ts +2 -2
- package/dist/mini-app-js-sdk.browser.js +1 -1
- package/dist/mini-app-js-sdk.es.js +85 -1211
- package/dist/model/miniAppError.d.ts +2 -1
- package/dist/model/permission.d.ts +2 -1
- package/dist/resources/images.d.ts +1 -0
- package/dist/resources/locales/payment/index.d.ts +20 -0
- package/dist/resources/locales/payment/ja.d.ts +10 -0
- package/dist/resources/locales/topup/index.d.ts +2 -0
- package/dist/resources/locales/topup/ja.d.ts +1 -0
- package/dist/types/getPermissionStatus.d.ts +1 -43
- package/dist/types/makePayment.d.ts +23 -3
- package/dist/types.d.ts +3 -80
- package/dist/utils/analytics.d.ts +2 -1
- package/dist/utils/api.d.ts +7 -7
- package/dist/utils/errors.d.ts +3 -3
- package/dist/utils/fetch.d.ts +6 -6
- package/dist/utils/helper.d.ts +7 -8
- package/dist/utils/miniAppRequest.d.ts +2 -2
- package/dist/utils/pureHelpers.d.ts +2 -0
- package/dist/utils/storage.d.ts +1 -1
- package/dist/utils/windowBridge.d.ts +4 -1
- package/dist/views/make-payment/store/util-for-handle-error.d.ts +2 -2
- package/dist/views/make-payment/store.d.ts +8525 -603
- package/package.json +1 -1
|
@@ -74,7 +74,7 @@ var defaultConverter = {
|
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
-
function init$
|
|
77
|
+
function init$2(converter, defaultAttributes) {
|
|
78
78
|
function set(name, value, attributes) {
|
|
79
79
|
if (typeof document === "undefined") {
|
|
80
80
|
return;
|
|
@@ -134,10 +134,10 @@ function init$1(converter, defaultAttributes) {
|
|
|
134
134
|
);
|
|
135
135
|
},
|
|
136
136
|
withAttributes: function(attributes) {
|
|
137
|
-
return init$
|
|
137
|
+
return init$2(this.converter, assign({}, this.attributes, attributes));
|
|
138
138
|
},
|
|
139
139
|
withConverter: function(converter2) {
|
|
140
|
-
return init$
|
|
140
|
+
return init$2(assign({}, this.converter, converter2), this.attributes);
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
143
|
{
|
|
@@ -146,95 +146,7 @@ function init$1(converter, defaultAttributes) {
|
|
|
146
146
|
}
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
|
-
var api = init$
|
|
150
|
-
var PpLocalStorageKey = /* @__PURE__ */ ((PpLocalStorageKey2) => {
|
|
151
|
-
PpLocalStorageKey2["accessToken"] = "ppjssdk.accessToken";
|
|
152
|
-
PpLocalStorageKey2["refreshToken"] = "ppjssdk.refreshToken";
|
|
153
|
-
PpLocalStorageKey2["env"] = "ppjssdk.env";
|
|
154
|
-
PpLocalStorageKey2["deviceUUID"] = "ppjssdk.deviceUUID";
|
|
155
|
-
PpLocalStorageKey2["clientUUID"] = "ppjssdk.clientUUID";
|
|
156
|
-
PpLocalStorageKey2["lastPayment"] = "ppjssdk.lastPayment";
|
|
157
|
-
PpLocalStorageKey2["lastTopup"] = "ppjssdk.lastTopup";
|
|
158
|
-
PpLocalStorageKey2["appDetail"] = "ppjssdk.appDetail";
|
|
159
|
-
PpLocalStorageKey2["appConfig"] = "ppjssdk.appConfig";
|
|
160
|
-
PpLocalStorageKey2["userInfo"] = "ppjssdk.userInfo";
|
|
161
|
-
PpLocalStorageKey2["lastPaymentMethod"] = "ppjssdk.lastPaymentMethod";
|
|
162
|
-
PpLocalStorageKey2["lastTopupPayMethod"] = "ppjssdk.lastTopupPayMethod";
|
|
163
|
-
PpLocalStorageKey2["codeVerifier"] = "ppjssdk.codeVerifier";
|
|
164
|
-
PpLocalStorageKey2["clientOrigin"] = "ppjssdk.clientOrigin";
|
|
165
|
-
PpLocalStorageKey2["clientVersion"] = "ppjssdk.clientVersion";
|
|
166
|
-
PpLocalStorageKey2["debugMode"] = "ppjssdk.debugMode";
|
|
167
|
-
PpLocalStorageKey2["claimCouponImmediately"] = "ppjssdk.claimCouponImmediately";
|
|
168
|
-
PpLocalStorageKey2["merchant"] = "ppjssdk.merchant";
|
|
169
|
-
PpLocalStorageKey2["consumedOTT"] = "ppjssdk.consumedOTT";
|
|
170
|
-
PpLocalStorageKey2["initializedAt"] = "ppjssdk.initializedAt";
|
|
171
|
-
return PpLocalStorageKey2;
|
|
172
|
-
})(PpLocalStorageKey || {});
|
|
173
|
-
const PPFunctionResult = {
|
|
174
|
-
success: "success",
|
|
175
|
-
fail: "fail",
|
|
176
|
-
complete: "complete"
|
|
177
|
-
};
|
|
178
|
-
const PPFunctionName = {
|
|
179
|
-
init: "init",
|
|
180
|
-
getBankInfo: "getBankInfo",
|
|
181
|
-
showAlert: "showAlert",
|
|
182
|
-
render: "render",
|
|
183
|
-
makePayment: "makePayment",
|
|
184
|
-
getUAID: "getUAID",
|
|
185
|
-
logout: "logout",
|
|
186
|
-
startMultiFactorAuth: "startMultiFactorAuth",
|
|
187
|
-
verifyMultiFactorAuthResult: "verifyMultiFactorAuthResult",
|
|
188
|
-
getPermissionStatus: "getPermissionStatus",
|
|
189
|
-
registerKyc: "registerKyc",
|
|
190
|
-
getKycInformation: "getKycInformation",
|
|
191
|
-
getUserAddress: "getUserAddress",
|
|
192
|
-
getUserLocation: "getUserLocation",
|
|
193
|
-
getUserProfile: "getUserProfile",
|
|
194
|
-
registerEmail: "registerEmail",
|
|
195
|
-
showUpdateWarning: "showUpdateWarning",
|
|
196
|
-
showErrorSheet: "showErrorSheet",
|
|
197
|
-
getPlatformInformation: "getPlatformInformation",
|
|
198
|
-
share: "share",
|
|
199
|
-
getTopBarHeight: "getTopBarHeight",
|
|
200
|
-
openWebview: "openWebview",
|
|
201
|
-
openMap: "openMap",
|
|
202
|
-
closeApp: "closeApp",
|
|
203
|
-
openApp: "openApp",
|
|
204
|
-
checkPaymentMethod: "checkPaymentMethod",
|
|
205
|
-
getBalance: "getBalance",
|
|
206
|
-
topup: "topup",
|
|
207
|
-
registerPaymentFeatures: "registerPaymentFeatures",
|
|
208
|
-
registerUserInfo: "registerUserInfo",
|
|
209
|
-
requestInternal: "requestInternal",
|
|
210
|
-
scanCode: "scanCode",
|
|
211
|
-
getAuthStatus: "getAuthStatus",
|
|
212
|
-
inputAddress: "inputAddress",
|
|
213
|
-
getCashbackInformation: "getCashbackInformation",
|
|
214
|
-
request: "request",
|
|
215
|
-
getDeviceInformation: "getDeviceInformation",
|
|
216
|
-
createOrder: "createOrder",
|
|
217
|
-
handleMessageFromNative: "handleMessageFromNative",
|
|
218
|
-
initKycPassport: "initKycPassport",
|
|
219
|
-
smsAuth: "smsAuth",
|
|
220
|
-
getKycPassportInfo: "getKycPassportInfo"
|
|
221
|
-
};
|
|
222
|
-
const PPUtilFunctionName = {
|
|
223
|
-
reload: "reload",
|
|
224
|
-
link: "link",
|
|
225
|
-
saveRefreshToken: "saveRefreshToken",
|
|
226
|
-
saveCodeVerifier: "saveCodeVerifier",
|
|
227
|
-
makeVisible: "makeVisible",
|
|
228
|
-
hideIframe: "hideIframe",
|
|
229
|
-
showIframe: "showIframe",
|
|
230
|
-
consoleDebugInfo: "consoleDebugInfo",
|
|
231
|
-
clientPopState: "clientPopState"
|
|
232
|
-
};
|
|
233
|
-
var SdkType = /* @__PURE__ */ ((SdkType2) => {
|
|
234
|
-
SdkType2["MiniApp"] = "MiniApp";
|
|
235
|
-
SdkType2["SmartPayment"] = "SmartPayment";
|
|
236
|
-
return SdkType2;
|
|
237
|
-
})(SdkType || {});
|
|
149
|
+
var api = init$2(defaultConverter, { path: "/" });
|
|
238
150
|
const jsBridgeNamespace = "_PayPayJsBridge";
|
|
239
151
|
const miniAppSupportedFunctions = [
|
|
240
152
|
"init",
|
|
@@ -309,8 +221,8 @@ const smartPaymentSupportedFunctions = [
|
|
|
309
221
|
"getLoginUrl",
|
|
310
222
|
"renderButton"
|
|
311
223
|
];
|
|
312
|
-
const JS_SDK_VERSION = "2.
|
|
313
|
-
const REVISION = "
|
|
224
|
+
const JS_SDK_VERSION = "2.58.0";
|
|
225
|
+
const REVISION = "5c56199";
|
|
314
226
|
const coreBaseUrl = new URL("https://mini-app-sdk-core.paypay.ne.jp/");
|
|
315
227
|
const CORE_IFRAME_ORIGIN = coreBaseUrl.origin;
|
|
316
228
|
const CORE_IFRAME_URL = new URL(
|
|
@@ -325,88 +237,17 @@ new URL(
|
|
|
325
237
|
`./button/iframe.html?v=${JS_SDK_VERSION}`,
|
|
326
238
|
coreBaseUrl
|
|
327
239
|
).href;
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
MiniAppErrorType2["invalidData"] = "INVALID_DATA";
|
|
333
|
-
MiniAppErrorType2["invalidHeader"] = "INVALID_HEADER";
|
|
334
|
-
MiniAppErrorType2["invalidMethod"] = "INVALID_METHOD";
|
|
335
|
-
MiniAppErrorType2["invalidPath"] = "INVALID_PATH";
|
|
336
|
-
MiniAppErrorType2["notReachable"] = "NOT_REACHABLE";
|
|
337
|
-
MiniAppErrorType2["notAvailable"] = "NOT_AVAILABLE";
|
|
338
|
-
MiniAppErrorType2["timeOut"] = "TIME_OUT";
|
|
339
|
-
MiniAppErrorType2["whiteListError"] = "NONE_WHITELIST_DOMAIN";
|
|
340
|
-
MiniAppErrorType2["statusCodeError"] = "STATUS_CODE_ERROR";
|
|
341
|
-
MiniAppErrorType2["invalidResponse"] = "INVALID_RESPONSE";
|
|
342
|
-
MiniAppErrorType2["noLocationPermission"] = "NO_USER_LOCATION_PERMISSION";
|
|
343
|
-
MiniAppErrorType2["noPermissionListAvailable"] = "NO_PERMISSION_LIST_AVAILABLE";
|
|
344
|
-
MiniAppErrorType2["other"] = "other";
|
|
345
|
-
MiniAppErrorType2["serverError"] = "SERVER_ERROR";
|
|
346
|
-
MiniAppErrorType2["noCameraPermission"] = "HOST_APP_CAMERA_DENIED";
|
|
347
|
-
MiniAppErrorType2["noAlbumPermission"] = "HOST_APP_ALBUM_DENIED";
|
|
348
|
-
MiniAppErrorType2["insufficientScope"] = "INSUFFICIENT_SCOPE";
|
|
349
|
-
MiniAppErrorType2["userCanceled"] = "USER_CANCELED";
|
|
350
|
-
MiniAppErrorType2["invalidJSAPIParams"] = "INVALID_JS_API_PARAMS";
|
|
351
|
-
MiniAppErrorType2["hostAppLocationDenied"] = "HOST_APP_LOCATION_DENIED";
|
|
352
|
-
MiniAppErrorType2["hostAppContactsDenied"] = "HOST_APP_READING_CONTACT_DENIED";
|
|
353
|
-
MiniAppErrorType2["badRequestInsufficientParameter"] = "BAD_REQUEST_INSUFFICIENT_PARAMETER";
|
|
354
|
-
MiniAppErrorType2["badRequest"] = "BAD_REQUEST";
|
|
355
|
-
MiniAppErrorType2["paymentFail"] = "PAYMENT_FAIL";
|
|
356
|
-
MiniAppErrorType2["topupFail"] = "TOPUP_FAIL";
|
|
357
|
-
MiniAppErrorType2["topupSuccessButNotAddToBalance"] = "TOPUP_SUCCESS_BUT_NOT_ADD_TO_BALANCE";
|
|
358
|
-
MiniAppErrorType2["userCanceledSimilarTxn"] = "USER_CANCELED_SIMILAR_TRANSACTION";
|
|
359
|
-
MiniAppErrorType2["mapAppNotFound"] = "MAP_APP_NOT_FOUND";
|
|
360
|
-
MiniAppErrorType2["invalidAppSchemeURL"] = "INVALID_APP_SCHEME_URL";
|
|
361
|
-
MiniAppErrorType2["noValueFound"] = "NO_VALUE_FOUND";
|
|
362
|
-
MiniAppErrorType2["securityNotSetup"] = "SECURITY_NOT_SETUP";
|
|
363
|
-
MiniAppErrorType2["userDenied"] = "USER_DENIED";
|
|
364
|
-
MiniAppErrorType2["securityTemporaryLocked"] = "SECURITY_TEMPORARY_LOCKED";
|
|
365
|
-
MiniAppErrorType2["couldNotGenerateBarcode"] = "COULD_NOT_GENERATE_BARCODE";
|
|
366
|
-
MiniAppErrorType2["cannotDetectAvailability"] = "CAN_NOT_DETECT_AVAILABILITY";
|
|
367
|
-
MiniAppErrorType2["suspectedDuplicatePayment"] = "SUSPECTED_DUPLICATE_PAYMENT";
|
|
368
|
-
MiniAppErrorType2["noSufficientFund"] = "NO_SUFFICIENT_FUND";
|
|
369
|
-
MiniAppErrorType2["unknown"] = "UNKNOWN";
|
|
370
|
-
MiniAppErrorType2["sdkNotInitialized"] = "SDK_NOT_INITIALIZED";
|
|
371
|
-
MiniAppErrorType2["tokenNotFound"] = "TOKEN_NOT_FOUND";
|
|
372
|
-
MiniAppErrorType2["tokenExpired"] = "TOKEN_EXPIRED";
|
|
373
|
-
MiniAppErrorType2["activeRequestExists"] = "ACTIVE_REQUEST_EXISTS";
|
|
374
|
-
MiniAppErrorType2["invalidType"] = "INVALID_TYPE";
|
|
375
|
-
MiniAppErrorType2["sessionNotFound"] = "SESSION_NOT_FOUND";
|
|
376
|
-
MiniAppErrorType2["cookieError"] = "COOKIE_ERROR";
|
|
377
|
-
MiniAppErrorType2["notAuthorized"] = "NOT_AUTHORIZED";
|
|
378
|
-
MiniAppErrorType2["permissionRequired"] = "PERMISSION_REQUIRED";
|
|
379
|
-
MiniAppErrorType2["deeplinkUnavailable"] = "DEEPLINK_UNAVAILABLE";
|
|
380
|
-
MiniAppErrorType2["kycIncompleted"] = "KYC_INCOMPLETED";
|
|
381
|
-
MiniAppErrorType2["noBankAccount"] = "NO_BANK_ACCOUNT";
|
|
382
|
-
MiniAppErrorType2["invalidPaymentIdentifier"] = "INVALID_PAYMENT_IDENTIFIER";
|
|
383
|
-
MiniAppErrorType2["otpSendTooShort"] = "OTP_SEND_TOO_SHORT";
|
|
384
|
-
MiniAppErrorType2["otpSendOverLimit"] = "OTP_SEND_OVER_LIMIT";
|
|
385
|
-
MiniAppErrorType2["userVerificationFailure"] = "USER_VERIFICATION_FAILURE";
|
|
386
|
-
MiniAppErrorType2["unacceptableOp"] = "UNACCEPTABLE_OP";
|
|
387
|
-
MiniAppErrorType2["kycUpdateRequired"] = "KYC_UPDATE_REQUIRED";
|
|
388
|
-
MiniAppErrorType2["notCompleted"] = "NOT_COMPLETED";
|
|
389
|
-
MiniAppErrorType2["kycValidationInProcess"] = "KYC_VALIDATION_IN_PROCESS";
|
|
390
|
-
MiniAppErrorType2["noLocationData"] = "NO_LOCATION_DATA";
|
|
391
|
-
MiniAppErrorType2["functionNotFound"] = "FUNCTION_NOT_FOUND";
|
|
392
|
-
MiniAppErrorType2["originNotAllowed"] = "ORIGIN_NOT_ALLOWED";
|
|
393
|
-
MiniAppErrorType2["messageSendingFailed"] = "MESSAGE_SENDING_FAILED";
|
|
394
|
-
MiniAppErrorType2["transactionNotFound"] = "TRANSACTION_NOT_FOUND";
|
|
395
|
-
MiniAppErrorType2["unexpectedOperation"] = "UNEXPECTED_OP";
|
|
396
|
-
MiniAppErrorType2["merchantTimeout"] = "MERCHANT_TIMEOUT";
|
|
397
|
-
MiniAppErrorType2["rateLimitExceeded"] = "RATE_LIMIT_EXCEEDED";
|
|
398
|
-
MiniAppErrorType2["sdkUpgradeRequired"] = "SDK_UPGRADE_REQUIRED";
|
|
399
|
-
MiniAppErrorType2["authorizationNeeded"] = "AUTHORIZATION_NEEDED";
|
|
400
|
-
MiniAppErrorType2["invalidVirtualAccount"] = "INVALID_VIRTUAL_ACCOUNT";
|
|
401
|
-
return MiniAppErrorType2;
|
|
402
|
-
})(MiniAppErrorType || {});
|
|
240
|
+
const notReachable = "NOT_REACHABLE", other = "other", badRequestInsufficientParameter = "BAD_REQUEST_INSUFFICIENT_PARAMETER", unknown = "UNKNOWN", sdkNotInitialized = "SDK_NOT_INITIALIZED", tokenNotFound = "TOKEN_NOT_FOUND", tokenExpired = "TOKEN_EXPIRED", functionNotFound = "FUNCTION_NOT_FOUND", originNotAllowed = "ORIGIN_NOT_ALLOWED", messageSendingFailed = "MESSAGE_SENDING_FAILED", authorizationNeeded = "AUTHORIZATION_NEEDED";
|
|
241
|
+
const refreshToken = "ppjssdk.refreshToken", codeVerifier = "ppjssdk.codeVerifier";
|
|
242
|
+
const init$1 = "init", verifyMultiFactorAuthResult$1 = "verifyMultiFactorAuthResult", share$1 = "share", scanCode$1 = "scanCode", handleMessageFromNative = "handleMessageFromNative", getKycPassportInfo$1 = "getKycPassportInfo";
|
|
243
|
+
const reload = "reload", link = "link", makeVisible = "makeVisible", hideIframe = "hideIframe", showIframe = "showIframe", consoleDebugInfo$1 = "consoleDebugInfo", clientPopState = "clientPopState";
|
|
403
244
|
function setCookie({ name, value, options }) {
|
|
404
245
|
return api.set(name, value, options);
|
|
405
246
|
}
|
|
406
247
|
function getCookie({ name }) {
|
|
407
248
|
return api.get(name);
|
|
408
249
|
}
|
|
409
|
-
function removeCookie
|
|
250
|
+
function removeCookie({ name, options }) {
|
|
410
251
|
return api.remove(name, options);
|
|
411
252
|
}
|
|
412
253
|
function setLocalStorage({
|
|
@@ -459,7 +300,7 @@ function insertIframe(_a) {
|
|
|
459
300
|
reject(
|
|
460
301
|
new PPError(
|
|
461
302
|
`Container with selector "${containerQuerySelector}" not found.`,
|
|
462
|
-
|
|
303
|
+
badRequestInsufficientParameter
|
|
463
304
|
)
|
|
464
305
|
);
|
|
465
306
|
return;
|
|
@@ -469,9 +310,7 @@ function insertIframe(_a) {
|
|
|
469
310
|
resolve(true);
|
|
470
311
|
};
|
|
471
312
|
iframe.onerror = () => {
|
|
472
|
-
reject(
|
|
473
|
-
new PPError("Failed to load iframe.", MiniAppErrorType.notReachable)
|
|
474
|
-
);
|
|
313
|
+
reject(new PPError("Failed to load iframe.", notReachable));
|
|
475
314
|
};
|
|
476
315
|
Object.assign(iframe.style, styles);
|
|
477
316
|
Object.entries(attributes).forEach(([key, value]) => {
|
|
@@ -507,7 +346,7 @@ const clientWindowBridgeFunctions = /* @__PURE__ */ Object.freeze(/* @__PURE__ *
|
|
|
507
346
|
getSessionStorage,
|
|
508
347
|
getUrl,
|
|
509
348
|
insertIframe,
|
|
510
|
-
removeCookie
|
|
349
|
+
removeCookie,
|
|
511
350
|
removeElement,
|
|
512
351
|
removeLocalStorage,
|
|
513
352
|
removeQueryParametersFromUrl,
|
|
@@ -517,986 +356,16 @@ const clientWindowBridgeFunctions = /* @__PURE__ */ Object.freeze(/* @__PURE__ *
|
|
|
517
356
|
setSessionStorage,
|
|
518
357
|
updateElementStyle
|
|
519
358
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const CONSOLE_LEVELS = [
|
|
531
|
-
"debug",
|
|
532
|
-
"info",
|
|
533
|
-
"warn",
|
|
534
|
-
"error",
|
|
535
|
-
"log",
|
|
536
|
-
"assert",
|
|
537
|
-
"trace"
|
|
538
|
-
];
|
|
539
|
-
const originalConsoleMethods = {};
|
|
540
|
-
function consoleSandbox(callback) {
|
|
541
|
-
if (!("console" in GLOBAL_OBJ)) {
|
|
542
|
-
return callback();
|
|
543
|
-
}
|
|
544
|
-
const console2 = GLOBAL_OBJ.console;
|
|
545
|
-
const wrappedFuncs = {};
|
|
546
|
-
const wrappedLevels = Object.keys(originalConsoleMethods);
|
|
547
|
-
wrappedLevels.forEach((level) => {
|
|
548
|
-
const originalConsoleMethod = originalConsoleMethods[level];
|
|
549
|
-
wrappedFuncs[level] = console2[level];
|
|
550
|
-
console2[level] = originalConsoleMethod;
|
|
551
|
-
});
|
|
552
|
-
try {
|
|
553
|
-
return callback();
|
|
554
|
-
} finally {
|
|
555
|
-
wrappedLevels.forEach((level) => {
|
|
556
|
-
console2[level] = wrappedFuncs[level];
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
function makeLogger() {
|
|
561
|
-
let enabled = false;
|
|
562
|
-
const logger2 = {
|
|
563
|
-
enable: () => {
|
|
564
|
-
enabled = true;
|
|
565
|
-
},
|
|
566
|
-
disable: () => {
|
|
567
|
-
enabled = false;
|
|
568
|
-
},
|
|
569
|
-
isEnabled: () => enabled
|
|
570
|
-
};
|
|
571
|
-
if (DEBUG_BUILD) {
|
|
572
|
-
CONSOLE_LEVELS.forEach((name) => {
|
|
573
|
-
logger2[name] = (...args) => {
|
|
574
|
-
if (enabled) {
|
|
575
|
-
consoleSandbox(() => {
|
|
576
|
-
GLOBAL_OBJ.console[name](`${PREFIX}[${name}]:`, ...args);
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
});
|
|
581
|
-
} else {
|
|
582
|
-
CONSOLE_LEVELS.forEach((name) => {
|
|
583
|
-
logger2[name] = () => void 0;
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
return logger2;
|
|
587
|
-
}
|
|
588
|
-
const logger = getGlobalSingleton("logger", makeLogger);
|
|
589
|
-
function getMainCarrier() {
|
|
590
|
-
getSentryCarrier(GLOBAL_OBJ);
|
|
591
|
-
return GLOBAL_OBJ;
|
|
592
|
-
}
|
|
593
|
-
function getSentryCarrier(carrier) {
|
|
594
|
-
const __SENTRY__ = carrier.__SENTRY__ = carrier.__SENTRY__ || {};
|
|
595
|
-
__SENTRY__.version = __SENTRY__.version || SDK_VERSION;
|
|
596
|
-
return __SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {};
|
|
597
|
-
}
|
|
598
|
-
const objectToString = Object.prototype.toString;
|
|
599
|
-
function isBuiltin(wat, className) {
|
|
600
|
-
return objectToString.call(wat) === `[object ${className}]`;
|
|
601
|
-
}
|
|
602
|
-
function isPlainObject(wat) {
|
|
603
|
-
return isBuiltin(wat, "Object");
|
|
604
|
-
}
|
|
605
|
-
function isThenable(wat) {
|
|
606
|
-
return Boolean(wat && wat.then && typeof wat.then === "function");
|
|
607
|
-
}
|
|
608
|
-
function addNonEnumerableProperty(obj, name, value) {
|
|
609
|
-
try {
|
|
610
|
-
Object.defineProperty(obj, name, {
|
|
611
|
-
// enumerable: false, // the default, so we can save on bundle size by not explicitly setting it
|
|
612
|
-
value,
|
|
613
|
-
writable: true,
|
|
614
|
-
configurable: true
|
|
615
|
-
});
|
|
616
|
-
} catch (o_O) {
|
|
617
|
-
DEBUG_BUILD && logger.log(`Failed to add non-enumerable property "${name}" to object`, obj);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
const ONE_SECOND_IN_MS = 1e3;
|
|
621
|
-
function dateTimestampInSeconds() {
|
|
622
|
-
return Date.now() / ONE_SECOND_IN_MS;
|
|
623
|
-
}
|
|
624
|
-
function createUnixTimestampInSecondsFunc() {
|
|
625
|
-
const { performance } = GLOBAL_OBJ;
|
|
626
|
-
if (!performance || !performance.now) {
|
|
627
|
-
return dateTimestampInSeconds;
|
|
628
|
-
}
|
|
629
|
-
const approxStartingTimeOrigin = Date.now() - performance.now();
|
|
630
|
-
const timeOrigin = performance.timeOrigin == void 0 ? approxStartingTimeOrigin : performance.timeOrigin;
|
|
631
|
-
return () => {
|
|
632
|
-
return (timeOrigin + performance.now()) / ONE_SECOND_IN_MS;
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
const timestampInSeconds = createUnixTimestampInSecondsFunc();
|
|
636
|
-
(() => {
|
|
637
|
-
const { performance } = GLOBAL_OBJ;
|
|
638
|
-
if (!performance || !performance.now) {
|
|
639
|
-
return void 0;
|
|
640
|
-
}
|
|
641
|
-
const threshold = 3600 * 1e3;
|
|
642
|
-
const performanceNow = performance.now();
|
|
643
|
-
const dateNow = Date.now();
|
|
644
|
-
const timeOriginDelta = performance.timeOrigin ? Math.abs(performance.timeOrigin + performanceNow - dateNow) : threshold;
|
|
645
|
-
const timeOriginIsReliable = timeOriginDelta < threshold;
|
|
646
|
-
const navigationStart = performance.timing && performance.timing.navigationStart;
|
|
647
|
-
const hasNavigationStart = typeof navigationStart === "number";
|
|
648
|
-
const navigationStartDelta = hasNavigationStart ? Math.abs(navigationStart + performanceNow - dateNow) : threshold;
|
|
649
|
-
const navigationStartIsReliable = navigationStartDelta < threshold;
|
|
650
|
-
if (timeOriginIsReliable || navigationStartIsReliable) {
|
|
651
|
-
if (timeOriginDelta <= navigationStartDelta) {
|
|
652
|
-
return performance.timeOrigin;
|
|
653
|
-
} else {
|
|
654
|
-
return navigationStart;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
return dateNow;
|
|
658
|
-
})();
|
|
659
|
-
function uuid4() {
|
|
660
|
-
const gbl = GLOBAL_OBJ;
|
|
661
|
-
const crypto = gbl.crypto || gbl.msCrypto;
|
|
662
|
-
let getRandomByte = () => Math.random() * 16;
|
|
663
|
-
try {
|
|
664
|
-
if (crypto && crypto.randomUUID) {
|
|
665
|
-
return crypto.randomUUID().replace(/-/g, "");
|
|
666
|
-
}
|
|
667
|
-
if (crypto && crypto.getRandomValues) {
|
|
668
|
-
getRandomByte = () => {
|
|
669
|
-
const typedArray = new Uint8Array(1);
|
|
670
|
-
crypto.getRandomValues(typedArray);
|
|
671
|
-
return typedArray[0];
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
} catch (_) {
|
|
675
|
-
}
|
|
676
|
-
return ("10000000100040008000" + 1e11).replace(
|
|
677
|
-
/[018]/g,
|
|
678
|
-
(c) => (
|
|
679
|
-
// eslint-disable-next-line no-bitwise
|
|
680
|
-
(c ^ (getRandomByte() & 15) >> c / 4).toString(16)
|
|
681
|
-
)
|
|
682
|
-
);
|
|
683
|
-
}
|
|
684
|
-
function updateSession(session, context = {}) {
|
|
685
|
-
if (context.user) {
|
|
686
|
-
if (!session.ipAddress && context.user.ip_address) {
|
|
687
|
-
session.ipAddress = context.user.ip_address;
|
|
688
|
-
}
|
|
689
|
-
if (!session.did && !context.did) {
|
|
690
|
-
session.did = context.user.id || context.user.email || context.user.username;
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
session.timestamp = context.timestamp || timestampInSeconds();
|
|
694
|
-
if (context.abnormal_mechanism) {
|
|
695
|
-
session.abnormal_mechanism = context.abnormal_mechanism;
|
|
696
|
-
}
|
|
697
|
-
if (context.ignoreDuration) {
|
|
698
|
-
session.ignoreDuration = context.ignoreDuration;
|
|
699
|
-
}
|
|
700
|
-
if (context.sid) {
|
|
701
|
-
session.sid = context.sid.length === 32 ? context.sid : uuid4();
|
|
702
|
-
}
|
|
703
|
-
if (context.init !== void 0) {
|
|
704
|
-
session.init = context.init;
|
|
705
|
-
}
|
|
706
|
-
if (!session.did && context.did) {
|
|
707
|
-
session.did = `${context.did}`;
|
|
708
|
-
}
|
|
709
|
-
if (typeof context.started === "number") {
|
|
710
|
-
session.started = context.started;
|
|
711
|
-
}
|
|
712
|
-
if (session.ignoreDuration) {
|
|
713
|
-
session.duration = void 0;
|
|
714
|
-
} else if (typeof context.duration === "number") {
|
|
715
|
-
session.duration = context.duration;
|
|
716
|
-
} else {
|
|
717
|
-
const duration = session.timestamp - session.started;
|
|
718
|
-
session.duration = duration >= 0 ? duration : 0;
|
|
719
|
-
}
|
|
720
|
-
if (context.release) {
|
|
721
|
-
session.release = context.release;
|
|
722
|
-
}
|
|
723
|
-
if (context.environment) {
|
|
724
|
-
session.environment = context.environment;
|
|
725
|
-
}
|
|
726
|
-
if (!session.ipAddress && context.ipAddress) {
|
|
727
|
-
session.ipAddress = context.ipAddress;
|
|
728
|
-
}
|
|
729
|
-
if (!session.userAgent && context.userAgent) {
|
|
730
|
-
session.userAgent = context.userAgent;
|
|
731
|
-
}
|
|
732
|
-
if (typeof context.errors === "number") {
|
|
733
|
-
session.errors = context.errors;
|
|
734
|
-
}
|
|
735
|
-
if (context.status) {
|
|
736
|
-
session.status = context.status;
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
function generateTraceId() {
|
|
740
|
-
return uuid4();
|
|
741
|
-
}
|
|
742
|
-
function generateSpanId() {
|
|
743
|
-
return uuid4().substring(16);
|
|
744
|
-
}
|
|
745
|
-
function merge(initialObj, mergeObj, levels = 2) {
|
|
746
|
-
if (!mergeObj || typeof mergeObj !== "object" || levels <= 0) {
|
|
747
|
-
return mergeObj;
|
|
748
|
-
}
|
|
749
|
-
if (initialObj && mergeObj && Object.keys(mergeObj).length === 0) {
|
|
750
|
-
return initialObj;
|
|
751
|
-
}
|
|
752
|
-
const output = __spreadValues({}, initialObj);
|
|
753
|
-
for (const key in mergeObj) {
|
|
754
|
-
if (Object.prototype.hasOwnProperty.call(mergeObj, key)) {
|
|
755
|
-
output[key] = merge(output[key], mergeObj[key], levels - 1);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
return output;
|
|
759
|
-
}
|
|
760
|
-
const SCOPE_SPAN_FIELD = "_sentrySpan";
|
|
761
|
-
function _setSpanForScope(scope, span) {
|
|
762
|
-
if (span) {
|
|
763
|
-
addNonEnumerableProperty(scope, SCOPE_SPAN_FIELD, span);
|
|
764
|
-
} else {
|
|
765
|
-
delete scope[SCOPE_SPAN_FIELD];
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
function _getSpanForScope(scope) {
|
|
769
|
-
return scope[SCOPE_SPAN_FIELD];
|
|
770
|
-
}
|
|
771
|
-
const DEFAULT_MAX_BREADCRUMBS = 100;
|
|
772
|
-
class ScopeClass {
|
|
773
|
-
/** Flag if notifying is happening. */
|
|
774
|
-
/** Callback for client to receive scope changes. */
|
|
775
|
-
/** Callback list that will be called during event processing. */
|
|
776
|
-
/** Array of breadcrumbs. */
|
|
777
|
-
/** User */
|
|
778
|
-
/** Tags */
|
|
779
|
-
/** Extra */
|
|
780
|
-
/** Contexts */
|
|
781
|
-
/** Attachments */
|
|
782
|
-
/** Propagation Context for distributed tracing */
|
|
783
|
-
/**
|
|
784
|
-
* A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
|
|
785
|
-
* sent to Sentry
|
|
786
|
-
*/
|
|
787
|
-
/** Fingerprint */
|
|
788
|
-
/** Severity */
|
|
789
|
-
/**
|
|
790
|
-
* Transaction Name
|
|
791
|
-
*
|
|
792
|
-
* IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.
|
|
793
|
-
* It's purpose is to assign a transaction to the scope that's added to non-transaction events.
|
|
794
|
-
*/
|
|
795
|
-
/** Session */
|
|
796
|
-
/** Request Mode Session Status */
|
|
797
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
798
|
-
/** The client on this scope */
|
|
799
|
-
/** Contains the last event id of a captured event. */
|
|
800
|
-
// NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.
|
|
801
|
-
constructor() {
|
|
802
|
-
this._notifyingListeners = false;
|
|
803
|
-
this._scopeListeners = [];
|
|
804
|
-
this._eventProcessors = [];
|
|
805
|
-
this._breadcrumbs = [];
|
|
806
|
-
this._attachments = [];
|
|
807
|
-
this._user = {};
|
|
808
|
-
this._tags = {};
|
|
809
|
-
this._extra = {};
|
|
810
|
-
this._contexts = {};
|
|
811
|
-
this._sdkProcessingMetadata = {};
|
|
812
|
-
this._propagationContext = {
|
|
813
|
-
traceId: generateTraceId(),
|
|
814
|
-
spanId: generateSpanId()
|
|
815
|
-
};
|
|
816
|
-
}
|
|
817
|
-
/**
|
|
818
|
-
* @inheritDoc
|
|
819
|
-
*/
|
|
820
|
-
clone() {
|
|
821
|
-
const newScope = new ScopeClass();
|
|
822
|
-
newScope._breadcrumbs = [...this._breadcrumbs];
|
|
823
|
-
newScope._tags = __spreadValues({}, this._tags);
|
|
824
|
-
newScope._extra = __spreadValues({}, this._extra);
|
|
825
|
-
newScope._contexts = __spreadValues({}, this._contexts);
|
|
826
|
-
if (this._contexts.flags) {
|
|
827
|
-
newScope._contexts.flags = {
|
|
828
|
-
values: [...this._contexts.flags.values]
|
|
829
|
-
};
|
|
830
|
-
}
|
|
831
|
-
newScope._user = this._user;
|
|
832
|
-
newScope._level = this._level;
|
|
833
|
-
newScope._session = this._session;
|
|
834
|
-
newScope._transactionName = this._transactionName;
|
|
835
|
-
newScope._fingerprint = this._fingerprint;
|
|
836
|
-
newScope._eventProcessors = [...this._eventProcessors];
|
|
837
|
-
newScope._requestSession = this._requestSession;
|
|
838
|
-
newScope._attachments = [...this._attachments];
|
|
839
|
-
newScope._sdkProcessingMetadata = __spreadValues({}, this._sdkProcessingMetadata);
|
|
840
|
-
newScope._propagationContext = __spreadValues({}, this._propagationContext);
|
|
841
|
-
newScope._client = this._client;
|
|
842
|
-
newScope._lastEventId = this._lastEventId;
|
|
843
|
-
_setSpanForScope(newScope, _getSpanForScope(this));
|
|
844
|
-
return newScope;
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* @inheritDoc
|
|
848
|
-
*/
|
|
849
|
-
setClient(client2) {
|
|
850
|
-
this._client = client2;
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* @inheritDoc
|
|
854
|
-
*/
|
|
855
|
-
setLastEventId(lastEventId) {
|
|
856
|
-
this._lastEventId = lastEventId;
|
|
857
|
-
}
|
|
858
|
-
/**
|
|
859
|
-
* @inheritDoc
|
|
860
|
-
*/
|
|
861
|
-
getClient() {
|
|
862
|
-
return this._client;
|
|
863
|
-
}
|
|
864
|
-
/**
|
|
865
|
-
* @inheritDoc
|
|
866
|
-
*/
|
|
867
|
-
lastEventId() {
|
|
868
|
-
return this._lastEventId;
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
* @inheritDoc
|
|
872
|
-
*/
|
|
873
|
-
addScopeListener(callback) {
|
|
874
|
-
this._scopeListeners.push(callback);
|
|
875
|
-
}
|
|
876
|
-
/**
|
|
877
|
-
* @inheritDoc
|
|
878
|
-
*/
|
|
879
|
-
addEventProcessor(callback) {
|
|
880
|
-
this._eventProcessors.push(callback);
|
|
881
|
-
return this;
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* @inheritDoc
|
|
885
|
-
*/
|
|
886
|
-
setUser(user) {
|
|
887
|
-
this._user = user || {
|
|
888
|
-
email: void 0,
|
|
889
|
-
id: void 0,
|
|
890
|
-
ip_address: void 0,
|
|
891
|
-
username: void 0
|
|
892
|
-
};
|
|
893
|
-
if (this._session) {
|
|
894
|
-
updateSession(this._session, { user });
|
|
895
|
-
}
|
|
896
|
-
this._notifyScopeListeners();
|
|
897
|
-
return this;
|
|
898
|
-
}
|
|
899
|
-
/**
|
|
900
|
-
* @inheritDoc
|
|
901
|
-
*/
|
|
902
|
-
getUser() {
|
|
903
|
-
return this._user;
|
|
904
|
-
}
|
|
905
|
-
/**
|
|
906
|
-
* @inheritDoc
|
|
907
|
-
*/
|
|
908
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
909
|
-
getRequestSession() {
|
|
910
|
-
return this._requestSession;
|
|
911
|
-
}
|
|
912
|
-
/**
|
|
913
|
-
* @inheritDoc
|
|
914
|
-
*/
|
|
915
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
916
|
-
setRequestSession(requestSession) {
|
|
917
|
-
this._requestSession = requestSession;
|
|
918
|
-
return this;
|
|
919
|
-
}
|
|
920
|
-
/**
|
|
921
|
-
* @inheritDoc
|
|
922
|
-
*/
|
|
923
|
-
setTags(tags) {
|
|
924
|
-
this._tags = __spreadValues(__spreadValues({}, this._tags), tags);
|
|
925
|
-
this._notifyScopeListeners();
|
|
926
|
-
return this;
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* @inheritDoc
|
|
930
|
-
*/
|
|
931
|
-
setTag(key, value) {
|
|
932
|
-
this._tags = __spreadProps(__spreadValues({}, this._tags), { [key]: value });
|
|
933
|
-
this._notifyScopeListeners();
|
|
934
|
-
return this;
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* @inheritDoc
|
|
938
|
-
*/
|
|
939
|
-
setExtras(extras) {
|
|
940
|
-
this._extra = __spreadValues(__spreadValues({}, this._extra), extras);
|
|
941
|
-
this._notifyScopeListeners();
|
|
942
|
-
return this;
|
|
943
|
-
}
|
|
944
|
-
/**
|
|
945
|
-
* @inheritDoc
|
|
946
|
-
*/
|
|
947
|
-
setExtra(key, extra) {
|
|
948
|
-
this._extra = __spreadProps(__spreadValues({}, this._extra), { [key]: extra });
|
|
949
|
-
this._notifyScopeListeners();
|
|
950
|
-
return this;
|
|
951
|
-
}
|
|
952
|
-
/**
|
|
953
|
-
* @inheritDoc
|
|
954
|
-
*/
|
|
955
|
-
setFingerprint(fingerprint) {
|
|
956
|
-
this._fingerprint = fingerprint;
|
|
957
|
-
this._notifyScopeListeners();
|
|
958
|
-
return this;
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* @inheritDoc
|
|
962
|
-
*/
|
|
963
|
-
setLevel(level) {
|
|
964
|
-
this._level = level;
|
|
965
|
-
this._notifyScopeListeners();
|
|
966
|
-
return this;
|
|
967
|
-
}
|
|
968
|
-
/**
|
|
969
|
-
* @inheritDoc
|
|
970
|
-
*/
|
|
971
|
-
setTransactionName(name) {
|
|
972
|
-
this._transactionName = name;
|
|
973
|
-
this._notifyScopeListeners();
|
|
974
|
-
return this;
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* @inheritDoc
|
|
978
|
-
*/
|
|
979
|
-
setContext(key, context) {
|
|
980
|
-
if (context === null) {
|
|
981
|
-
delete this._contexts[key];
|
|
982
|
-
} else {
|
|
983
|
-
this._contexts[key] = context;
|
|
984
|
-
}
|
|
985
|
-
this._notifyScopeListeners();
|
|
986
|
-
return this;
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* @inheritDoc
|
|
990
|
-
*/
|
|
991
|
-
setSession(session) {
|
|
992
|
-
if (!session) {
|
|
993
|
-
delete this._session;
|
|
994
|
-
} else {
|
|
995
|
-
this._session = session;
|
|
996
|
-
}
|
|
997
|
-
this._notifyScopeListeners();
|
|
998
|
-
return this;
|
|
999
|
-
}
|
|
1000
|
-
/**
|
|
1001
|
-
* @inheritDoc
|
|
1002
|
-
*/
|
|
1003
|
-
getSession() {
|
|
1004
|
-
return this._session;
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* @inheritDoc
|
|
1008
|
-
*/
|
|
1009
|
-
update(captureContext) {
|
|
1010
|
-
if (!captureContext) {
|
|
1011
|
-
return this;
|
|
1012
|
-
}
|
|
1013
|
-
const scopeToMerge = typeof captureContext === "function" ? captureContext(this) : captureContext;
|
|
1014
|
-
const [scopeInstance, requestSession] = scopeToMerge instanceof Scope ? (
|
|
1015
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
1016
|
-
[scopeToMerge.getScopeData(), scopeToMerge.getRequestSession()]
|
|
1017
|
-
) : isPlainObject(scopeToMerge) ? [captureContext, captureContext.requestSession] : [];
|
|
1018
|
-
const { tags, extra, user, contexts, level, fingerprint = [], propagationContext } = scopeInstance || {};
|
|
1019
|
-
this._tags = __spreadValues(__spreadValues({}, this._tags), tags);
|
|
1020
|
-
this._extra = __spreadValues(__spreadValues({}, this._extra), extra);
|
|
1021
|
-
this._contexts = __spreadValues(__spreadValues({}, this._contexts), contexts);
|
|
1022
|
-
if (user && Object.keys(user).length) {
|
|
1023
|
-
this._user = user;
|
|
1024
|
-
}
|
|
1025
|
-
if (level) {
|
|
1026
|
-
this._level = level;
|
|
1027
|
-
}
|
|
1028
|
-
if (fingerprint.length) {
|
|
1029
|
-
this._fingerprint = fingerprint;
|
|
1030
|
-
}
|
|
1031
|
-
if (propagationContext) {
|
|
1032
|
-
this._propagationContext = propagationContext;
|
|
1033
|
-
}
|
|
1034
|
-
if (requestSession) {
|
|
1035
|
-
this._requestSession = requestSession;
|
|
1036
|
-
}
|
|
1037
|
-
return this;
|
|
1038
|
-
}
|
|
1039
|
-
/**
|
|
1040
|
-
* @inheritDoc
|
|
1041
|
-
*/
|
|
1042
|
-
clear() {
|
|
1043
|
-
this._breadcrumbs = [];
|
|
1044
|
-
this._tags = {};
|
|
1045
|
-
this._extra = {};
|
|
1046
|
-
this._user = {};
|
|
1047
|
-
this._contexts = {};
|
|
1048
|
-
this._level = void 0;
|
|
1049
|
-
this._transactionName = void 0;
|
|
1050
|
-
this._fingerprint = void 0;
|
|
1051
|
-
this._requestSession = void 0;
|
|
1052
|
-
this._session = void 0;
|
|
1053
|
-
_setSpanForScope(this, void 0);
|
|
1054
|
-
this._attachments = [];
|
|
1055
|
-
this.setPropagationContext({ traceId: generateTraceId() });
|
|
1056
|
-
this._notifyScopeListeners();
|
|
1057
|
-
return this;
|
|
1058
|
-
}
|
|
1059
|
-
/**
|
|
1060
|
-
* @inheritDoc
|
|
1061
|
-
*/
|
|
1062
|
-
addBreadcrumb(breadcrumb, maxBreadcrumbs) {
|
|
1063
|
-
const maxCrumbs = typeof maxBreadcrumbs === "number" ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;
|
|
1064
|
-
if (maxCrumbs <= 0) {
|
|
1065
|
-
return this;
|
|
1066
|
-
}
|
|
1067
|
-
const mergedBreadcrumb = __spreadValues({
|
|
1068
|
-
timestamp: dateTimestampInSeconds()
|
|
1069
|
-
}, breadcrumb);
|
|
1070
|
-
const breadcrumbs = this._breadcrumbs;
|
|
1071
|
-
breadcrumbs.push(mergedBreadcrumb);
|
|
1072
|
-
this._breadcrumbs = breadcrumbs.length > maxCrumbs ? breadcrumbs.slice(-maxCrumbs) : breadcrumbs;
|
|
1073
|
-
this._notifyScopeListeners();
|
|
1074
|
-
return this;
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* @inheritDoc
|
|
1078
|
-
*/
|
|
1079
|
-
getLastBreadcrumb() {
|
|
1080
|
-
return this._breadcrumbs[this._breadcrumbs.length - 1];
|
|
1081
|
-
}
|
|
1082
|
-
/**
|
|
1083
|
-
* @inheritDoc
|
|
1084
|
-
*/
|
|
1085
|
-
clearBreadcrumbs() {
|
|
1086
|
-
this._breadcrumbs = [];
|
|
1087
|
-
this._notifyScopeListeners();
|
|
1088
|
-
return this;
|
|
1089
|
-
}
|
|
1090
|
-
/**
|
|
1091
|
-
* @inheritDoc
|
|
1092
|
-
*/
|
|
1093
|
-
addAttachment(attachment) {
|
|
1094
|
-
this._attachments.push(attachment);
|
|
1095
|
-
return this;
|
|
1096
|
-
}
|
|
1097
|
-
/**
|
|
1098
|
-
* @inheritDoc
|
|
1099
|
-
*/
|
|
1100
|
-
clearAttachments() {
|
|
1101
|
-
this._attachments = [];
|
|
1102
|
-
return this;
|
|
1103
|
-
}
|
|
1104
|
-
/** @inheritDoc */
|
|
1105
|
-
getScopeData() {
|
|
1106
|
-
return {
|
|
1107
|
-
breadcrumbs: this._breadcrumbs,
|
|
1108
|
-
attachments: this._attachments,
|
|
1109
|
-
contexts: this._contexts,
|
|
1110
|
-
tags: this._tags,
|
|
1111
|
-
extra: this._extra,
|
|
1112
|
-
user: this._user,
|
|
1113
|
-
level: this._level,
|
|
1114
|
-
fingerprint: this._fingerprint || [],
|
|
1115
|
-
eventProcessors: this._eventProcessors,
|
|
1116
|
-
propagationContext: this._propagationContext,
|
|
1117
|
-
sdkProcessingMetadata: this._sdkProcessingMetadata,
|
|
1118
|
-
transactionName: this._transactionName,
|
|
1119
|
-
span: _getSpanForScope(this)
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
/**
|
|
1123
|
-
* @inheritDoc
|
|
1124
|
-
*/
|
|
1125
|
-
setSDKProcessingMetadata(newData) {
|
|
1126
|
-
this._sdkProcessingMetadata = merge(this._sdkProcessingMetadata, newData, 2);
|
|
1127
|
-
return this;
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
|
-
* @inheritDoc
|
|
1131
|
-
*/
|
|
1132
|
-
setPropagationContext(context) {
|
|
1133
|
-
this._propagationContext = __spreadValues({
|
|
1134
|
-
// eslint-disable-next-line deprecation/deprecation
|
|
1135
|
-
spanId: generateSpanId()
|
|
1136
|
-
}, context);
|
|
1137
|
-
return this;
|
|
1138
|
-
}
|
|
1139
|
-
/**
|
|
1140
|
-
* @inheritDoc
|
|
1141
|
-
*/
|
|
1142
|
-
getPropagationContext() {
|
|
1143
|
-
return this._propagationContext;
|
|
1144
|
-
}
|
|
1145
|
-
/**
|
|
1146
|
-
* @inheritDoc
|
|
1147
|
-
*/
|
|
1148
|
-
captureException(exception, hint) {
|
|
1149
|
-
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
|
|
1150
|
-
if (!this._client) {
|
|
1151
|
-
logger.warn("No client configured on scope - will not capture exception!");
|
|
1152
|
-
return eventId;
|
|
1153
|
-
}
|
|
1154
|
-
const syntheticException = new Error("Sentry syntheticException");
|
|
1155
|
-
this._client.captureException(
|
|
1156
|
-
exception,
|
|
1157
|
-
__spreadProps(__spreadValues({
|
|
1158
|
-
originalException: exception,
|
|
1159
|
-
syntheticException
|
|
1160
|
-
}, hint), {
|
|
1161
|
-
event_id: eventId
|
|
1162
|
-
}),
|
|
1163
|
-
this
|
|
1164
|
-
);
|
|
1165
|
-
return eventId;
|
|
1166
|
-
}
|
|
1167
|
-
/**
|
|
1168
|
-
* @inheritDoc
|
|
1169
|
-
*/
|
|
1170
|
-
captureMessage(message, level, hint) {
|
|
1171
|
-
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
|
|
1172
|
-
if (!this._client) {
|
|
1173
|
-
logger.warn("No client configured on scope - will not capture message!");
|
|
1174
|
-
return eventId;
|
|
1175
|
-
}
|
|
1176
|
-
const syntheticException = new Error(message);
|
|
1177
|
-
this._client.captureMessage(
|
|
1178
|
-
message,
|
|
1179
|
-
level,
|
|
1180
|
-
__spreadProps(__spreadValues({
|
|
1181
|
-
originalException: message,
|
|
1182
|
-
syntheticException
|
|
1183
|
-
}, hint), {
|
|
1184
|
-
event_id: eventId
|
|
1185
|
-
}),
|
|
1186
|
-
this
|
|
1187
|
-
);
|
|
1188
|
-
return eventId;
|
|
1189
|
-
}
|
|
1190
|
-
/**
|
|
1191
|
-
* @inheritDoc
|
|
1192
|
-
*/
|
|
1193
|
-
captureEvent(event, hint) {
|
|
1194
|
-
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
|
|
1195
|
-
if (!this._client) {
|
|
1196
|
-
logger.warn("No client configured on scope - will not capture event!");
|
|
1197
|
-
return eventId;
|
|
1198
|
-
}
|
|
1199
|
-
this._client.captureEvent(event, __spreadProps(__spreadValues({}, hint), { event_id: eventId }), this);
|
|
1200
|
-
return eventId;
|
|
1201
|
-
}
|
|
1202
|
-
/**
|
|
1203
|
-
* This will be called on every set call.
|
|
1204
|
-
*/
|
|
1205
|
-
_notifyScopeListeners() {
|
|
1206
|
-
if (!this._notifyingListeners) {
|
|
1207
|
-
this._notifyingListeners = true;
|
|
1208
|
-
this._scopeListeners.forEach((callback) => {
|
|
1209
|
-
callback(this);
|
|
1210
|
-
});
|
|
1211
|
-
this._notifyingListeners = false;
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
const Scope = ScopeClass;
|
|
1216
|
-
function getDefaultCurrentScope() {
|
|
1217
|
-
return getGlobalSingleton("defaultCurrentScope", () => new Scope());
|
|
1218
|
-
}
|
|
1219
|
-
function getDefaultIsolationScope() {
|
|
1220
|
-
return getGlobalSingleton("defaultIsolationScope", () => new Scope());
|
|
1221
|
-
}
|
|
1222
|
-
class AsyncContextStack {
|
|
1223
|
-
constructor(scope, isolationScope) {
|
|
1224
|
-
let assignedScope;
|
|
1225
|
-
if (!scope) {
|
|
1226
|
-
assignedScope = new Scope();
|
|
1227
|
-
} else {
|
|
1228
|
-
assignedScope = scope;
|
|
1229
|
-
}
|
|
1230
|
-
let assignedIsolationScope;
|
|
1231
|
-
if (!isolationScope) {
|
|
1232
|
-
assignedIsolationScope = new Scope();
|
|
1233
|
-
} else {
|
|
1234
|
-
assignedIsolationScope = isolationScope;
|
|
1235
|
-
}
|
|
1236
|
-
this._stack = [{ scope: assignedScope }];
|
|
1237
|
-
this._isolationScope = assignedIsolationScope;
|
|
1238
|
-
}
|
|
1239
|
-
/**
|
|
1240
|
-
* Fork a scope for the stack.
|
|
1241
|
-
*/
|
|
1242
|
-
withScope(callback) {
|
|
1243
|
-
const scope = this._pushScope();
|
|
1244
|
-
let maybePromiseResult;
|
|
1245
|
-
try {
|
|
1246
|
-
maybePromiseResult = callback(scope);
|
|
1247
|
-
} catch (e) {
|
|
1248
|
-
this._popScope();
|
|
1249
|
-
throw e;
|
|
1250
|
-
}
|
|
1251
|
-
if (isThenable(maybePromiseResult)) {
|
|
1252
|
-
return maybePromiseResult.then(
|
|
1253
|
-
(res) => {
|
|
1254
|
-
this._popScope();
|
|
1255
|
-
return res;
|
|
1256
|
-
},
|
|
1257
|
-
(e) => {
|
|
1258
|
-
this._popScope();
|
|
1259
|
-
throw e;
|
|
1260
|
-
}
|
|
1261
|
-
);
|
|
1262
|
-
}
|
|
1263
|
-
this._popScope();
|
|
1264
|
-
return maybePromiseResult;
|
|
1265
|
-
}
|
|
1266
|
-
/**
|
|
1267
|
-
* Get the client of the stack.
|
|
1268
|
-
*/
|
|
1269
|
-
getClient() {
|
|
1270
|
-
return this.getStackTop().client;
|
|
1271
|
-
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Returns the scope of the top stack.
|
|
1274
|
-
*/
|
|
1275
|
-
getScope() {
|
|
1276
|
-
return this.getStackTop().scope;
|
|
1277
|
-
}
|
|
1278
|
-
/**
|
|
1279
|
-
* Get the isolation scope for the stack.
|
|
1280
|
-
*/
|
|
1281
|
-
getIsolationScope() {
|
|
1282
|
-
return this._isolationScope;
|
|
1283
|
-
}
|
|
1284
|
-
/**
|
|
1285
|
-
* Returns the topmost scope layer in the order domain > local > process.
|
|
1286
|
-
*/
|
|
1287
|
-
getStackTop() {
|
|
1288
|
-
return this._stack[this._stack.length - 1];
|
|
1289
|
-
}
|
|
1290
|
-
/**
|
|
1291
|
-
* Push a scope to the stack.
|
|
1292
|
-
*/
|
|
1293
|
-
_pushScope() {
|
|
1294
|
-
const scope = this.getScope().clone();
|
|
1295
|
-
this._stack.push({
|
|
1296
|
-
client: this.getClient(),
|
|
1297
|
-
scope
|
|
1298
|
-
});
|
|
1299
|
-
return scope;
|
|
1300
|
-
}
|
|
1301
|
-
/**
|
|
1302
|
-
* Pop a scope from the stack.
|
|
1303
|
-
*/
|
|
1304
|
-
_popScope() {
|
|
1305
|
-
if (this._stack.length <= 1) return false;
|
|
1306
|
-
return !!this._stack.pop();
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
function getAsyncContextStack() {
|
|
1310
|
-
const registry = getMainCarrier();
|
|
1311
|
-
const sentry = getSentryCarrier(registry);
|
|
1312
|
-
return sentry.stack = sentry.stack || new AsyncContextStack(getDefaultCurrentScope(), getDefaultIsolationScope());
|
|
1313
|
-
}
|
|
1314
|
-
function withScope(callback) {
|
|
1315
|
-
return getAsyncContextStack().withScope(callback);
|
|
1316
|
-
}
|
|
1317
|
-
function withSetScope(scope, callback) {
|
|
1318
|
-
const stack = getAsyncContextStack();
|
|
1319
|
-
return stack.withScope(() => {
|
|
1320
|
-
stack.getStackTop().scope = scope;
|
|
1321
|
-
return callback(scope);
|
|
1322
|
-
});
|
|
1323
|
-
}
|
|
1324
|
-
function withIsolationScope(callback) {
|
|
1325
|
-
return getAsyncContextStack().withScope(() => {
|
|
1326
|
-
return callback(getAsyncContextStack().getIsolationScope());
|
|
1327
|
-
});
|
|
1328
|
-
}
|
|
1329
|
-
function getStackAsyncContextStrategy() {
|
|
1330
|
-
return {
|
|
1331
|
-
withIsolationScope,
|
|
1332
|
-
withScope,
|
|
1333
|
-
withSetScope,
|
|
1334
|
-
withSetIsolationScope: (_isolationScope, callback) => {
|
|
1335
|
-
return withIsolationScope(callback);
|
|
1336
|
-
},
|
|
1337
|
-
getCurrentScope: () => getAsyncContextStack().getScope(),
|
|
1338
|
-
getIsolationScope: () => getAsyncContextStack().getIsolationScope()
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
|
-
function getAsyncContextStrategy(carrier) {
|
|
1342
|
-
const sentry = getSentryCarrier(carrier);
|
|
1343
|
-
if (sentry.acs) {
|
|
1344
|
-
return sentry.acs;
|
|
1345
|
-
}
|
|
1346
|
-
return getStackAsyncContextStrategy();
|
|
1347
|
-
}
|
|
1348
|
-
function getCurrentScope() {
|
|
1349
|
-
const carrier = getMainCarrier();
|
|
1350
|
-
const acs = getAsyncContextStrategy(carrier);
|
|
1351
|
-
return acs.getCurrentScope();
|
|
1352
|
-
}
|
|
1353
|
-
function getIsolationScope() {
|
|
1354
|
-
const carrier = getMainCarrier();
|
|
1355
|
-
const acs = getAsyncContextStrategy(carrier);
|
|
1356
|
-
return acs.getIsolationScope();
|
|
1357
|
-
}
|
|
1358
|
-
function getClient$1() {
|
|
1359
|
-
return getCurrentScope().getClient();
|
|
1360
|
-
}
|
|
1361
|
-
function captureMessage(message, captureContext) {
|
|
1362
|
-
const level = captureContext;
|
|
1363
|
-
const context = void 0;
|
|
1364
|
-
return getCurrentScope().captureMessage(message, level, context);
|
|
1365
|
-
}
|
|
1366
|
-
const DEFAULT_BREADCRUMBS = 100;
|
|
1367
|
-
function addBreadcrumb(breadcrumb, hint) {
|
|
1368
|
-
const client2 = getClient$1();
|
|
1369
|
-
const isolationScope = getIsolationScope();
|
|
1370
|
-
if (!client2) return;
|
|
1371
|
-
const { beforeBreadcrumb = null, maxBreadcrumbs = DEFAULT_BREADCRUMBS } = client2.getOptions();
|
|
1372
|
-
if (maxBreadcrumbs <= 0) return;
|
|
1373
|
-
const timestamp = dateTimestampInSeconds();
|
|
1374
|
-
const mergedBreadcrumb = __spreadValues({ timestamp }, breadcrumb);
|
|
1375
|
-
const finalBreadcrumb = beforeBreadcrumb ? consoleSandbox(() => beforeBreadcrumb(mergedBreadcrumb, hint)) : mergedBreadcrumb;
|
|
1376
|
-
if (finalBreadcrumb === null) return;
|
|
1377
|
-
if (client2.emit) {
|
|
1378
|
-
client2.emit("beforeAddBreadcrumb", finalBreadcrumb, hint);
|
|
1379
|
-
}
|
|
1380
|
-
isolationScope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
|
|
1381
|
-
}
|
|
1382
|
-
const errorsToIgnore = [
|
|
1383
|
-
MiniAppErrorType.sdkNotInitialized,
|
|
1384
|
-
MiniAppErrorType.notAuthorized,
|
|
1385
|
-
MiniAppErrorType.userCanceled,
|
|
1386
|
-
MiniAppErrorType.userCanceledSimilarTxn,
|
|
1387
|
-
MiniAppErrorType.suspectedDuplicatePayment,
|
|
1388
|
-
MiniAppErrorType.noSufficientFund
|
|
1389
|
-
];
|
|
1390
|
-
function sendWindowBridgeErrorToSentry(functionName, message, error) {
|
|
1391
|
-
if (!errorsToIgnore.includes(error) && SENTRY_DSN) {
|
|
1392
|
-
captureMessage(
|
|
1393
|
-
`windowBridge.${functionName} failed. error: ${error}, message: ${message}`,
|
|
1394
|
-
"log"
|
|
1395
|
-
);
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
function addBreadcrumbToSentry(breadcrumb) {
|
|
1399
|
-
{
|
|
1400
|
-
addBreadcrumb(breadcrumb);
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
class LocalStorageProxy {
|
|
1404
|
-
constructor() {
|
|
1405
|
-
var _a;
|
|
1406
|
-
this.useLocalStorage = true;
|
|
1407
|
-
this.memoryStorage = {};
|
|
1408
|
-
try {
|
|
1409
|
-
localStorage.setItem(
|
|
1410
|
-
PpLocalStorageKey.initializedAt,
|
|
1411
|
-
Date.now().toString()
|
|
1412
|
-
);
|
|
1413
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
1414
|
-
const key = localStorage.key(i);
|
|
1415
|
-
if (key != null) {
|
|
1416
|
-
this.memoryStorage[key] = (_a = localStorage.getItem(key)) != null ? _a : "";
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
} catch (e) {
|
|
1420
|
-
this.useLocalStorage = false;
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
getItem(key) {
|
|
1424
|
-
var _a, _b;
|
|
1425
|
-
if (this.useLocalStorage) {
|
|
1426
|
-
try {
|
|
1427
|
-
if (localStorage.getItem(PpLocalStorageKey.initializedAt) != null) {
|
|
1428
|
-
const val = localStorage.getItem(key);
|
|
1429
|
-
if (val != null) {
|
|
1430
|
-
return val;
|
|
1431
|
-
}
|
|
1432
|
-
return (_a = api.get(key)) != null ? _a : null;
|
|
1433
|
-
} else {
|
|
1434
|
-
console.debug("local storage value has lost unexpectedly.");
|
|
1435
|
-
addBreadcrumbToSentry({
|
|
1436
|
-
message: "local storage value has lost unexpectedly.",
|
|
1437
|
-
category: "storage"
|
|
1438
|
-
});
|
|
1439
|
-
}
|
|
1440
|
-
} catch (e) {
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
this.useLocalStorage = false;
|
|
1444
|
-
return (_b = this.memoryStorage[key]) != null ? _b : null;
|
|
1445
|
-
}
|
|
1446
|
-
setItem(key, value) {
|
|
1447
|
-
this.memoryStorage[key] = value;
|
|
1448
|
-
if (this.useLocalStorage) {
|
|
1449
|
-
try {
|
|
1450
|
-
localStorage.setItem(key, value);
|
|
1451
|
-
removeCookie(key);
|
|
1452
|
-
} catch (e) {
|
|
1453
|
-
this.useLocalStorage = false;
|
|
1454
|
-
console.warn("localStorage has become unavailable.");
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
removeItem(key) {
|
|
1459
|
-
delete this.memoryStorage[key];
|
|
1460
|
-
try {
|
|
1461
|
-
localStorage.removeItem(key);
|
|
1462
|
-
removeCookie(key);
|
|
1463
|
-
} catch (e) {
|
|
1464
|
-
this.useLocalStorage = false;
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
clear() {
|
|
1468
|
-
try {
|
|
1469
|
-
localStorage.clear();
|
|
1470
|
-
localStorage.setItem(
|
|
1471
|
-
PpLocalStorageKey.initializedAt,
|
|
1472
|
-
Date.now().toString()
|
|
1473
|
-
);
|
|
1474
|
-
clearAllCookies();
|
|
1475
|
-
} catch (e) {
|
|
1476
|
-
}
|
|
1477
|
-
this.memoryStorage = {};
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
const cookieAttributes = Object.freeze(__spreadValues({
|
|
1481
|
-
expires: 365,
|
|
1482
|
-
sameSite: "None"
|
|
1483
|
-
}, { secure: true, Partitioned: true }));
|
|
1484
|
-
function writeCookie(key, value) {
|
|
1485
|
-
api.set(key, value, cookieAttributes);
|
|
1486
|
-
}
|
|
1487
|
-
function removeCookie(key) {
|
|
1488
|
-
api.remove(key, cookieAttributes);
|
|
1489
|
-
}
|
|
1490
|
-
(() => {
|
|
1491
|
-
return new LocalStorageProxy();
|
|
1492
|
-
})();
|
|
1493
|
-
function clearAllCookies() {
|
|
1494
|
-
const cookies = api.get();
|
|
1495
|
-
for (const key in cookies) {
|
|
1496
|
-
removeCookie(key);
|
|
1497
|
-
}
|
|
1498
|
-
writeCookie(PpLocalStorageKey.initializedAt, Date.now().toString());
|
|
1499
|
-
}
|
|
359
|
+
const PPFunctionResult = {
|
|
360
|
+
success: "success",
|
|
361
|
+
fail: "fail",
|
|
362
|
+
complete: "complete"
|
|
363
|
+
};
|
|
364
|
+
var SdkType = /* @__PURE__ */ ((SdkType2) => {
|
|
365
|
+
SdkType2["MiniApp"] = "MiniApp";
|
|
366
|
+
SdkType2["SmartPayment"] = "SmartPayment";
|
|
367
|
+
return SdkType2;
|
|
368
|
+
})(SdkType || {});
|
|
1500
369
|
function isFunction(val) {
|
|
1501
370
|
return typeof val === "function";
|
|
1502
371
|
}
|
|
@@ -1536,13 +405,14 @@ const getCallbacksPlaceholder = (callbacks) => {
|
|
|
1536
405
|
);
|
|
1537
406
|
};
|
|
1538
407
|
class WindowBridge {
|
|
1539
|
-
constructor(functions, allowedOrigins, middlewares = []) {
|
|
408
|
+
constructor(functions, allowedOrigins, middlewares = [], errorLogger) {
|
|
1540
409
|
this.deferredPromises = {};
|
|
1541
410
|
this.functions = functions;
|
|
1542
411
|
this.allowedOrigins = allowedOrigins;
|
|
1543
412
|
this.middlewares = middlewares;
|
|
1544
413
|
this.registeredCallbacks = {};
|
|
1545
414
|
this.messageEventHandler = this.messageEventHandler.bind(this);
|
|
415
|
+
this.errorLogger = errorLogger;
|
|
1546
416
|
this.subscribeToMessageEvent();
|
|
1547
417
|
}
|
|
1548
418
|
/**
|
|
@@ -1569,7 +439,7 @@ class WindowBridge {
|
|
|
1569
439
|
return this.sendErrorResponse(
|
|
1570
440
|
receivedMessageEvent,
|
|
1571
441
|
`${receivedMessageEvent.origin} is not allowed to make requests`,
|
|
1572
|
-
|
|
442
|
+
originNotAllowed
|
|
1573
443
|
);
|
|
1574
444
|
}
|
|
1575
445
|
if (receivedMessageEvent.data.type === "request") {
|
|
@@ -1595,7 +465,7 @@ class WindowBridge {
|
|
|
1595
465
|
this.sendErrorResponse(
|
|
1596
466
|
receivedMessageEvent,
|
|
1597
467
|
`Function '${functionName}' does not exists on the target window`,
|
|
1598
|
-
|
|
468
|
+
functionNotFound
|
|
1599
469
|
);
|
|
1600
470
|
}
|
|
1601
471
|
const params = deepClone(receivedMessageEvent.data.params);
|
|
@@ -1622,7 +492,7 @@ class WindowBridge {
|
|
|
1622
492
|
);
|
|
1623
493
|
} catch (error) {
|
|
1624
494
|
let message = "Some error occurred while processing the request";
|
|
1625
|
-
let errorCode =
|
|
495
|
+
let errorCode = unknown;
|
|
1626
496
|
if (error instanceof PPError) {
|
|
1627
497
|
message = error.message;
|
|
1628
498
|
errorCode = error.errorCode;
|
|
@@ -1667,11 +537,13 @@ class WindowBridge {
|
|
|
1667
537
|
callback(...args);
|
|
1668
538
|
}
|
|
1669
539
|
sendErrorResponse(receivedMessageEvent, message, errorCode) {
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
540
|
+
if (this.errorLogger) {
|
|
541
|
+
this.errorLogger(
|
|
542
|
+
receivedMessageEvent.data.functionName,
|
|
543
|
+
message,
|
|
544
|
+
errorCode
|
|
545
|
+
);
|
|
546
|
+
}
|
|
1675
547
|
this.sendResponse(receivedMessageEvent, {
|
|
1676
548
|
status: "failure",
|
|
1677
549
|
message,
|
|
@@ -1744,10 +616,7 @@ class WindowBridge {
|
|
|
1744
616
|
delete this.deferredPromises[key];
|
|
1745
617
|
delete this.registeredCallbacks[key];
|
|
1746
618
|
reject(
|
|
1747
|
-
new PPError(
|
|
1748
|
-
error.message,
|
|
1749
|
-
MiniAppErrorType.messageSendingFailed
|
|
1750
|
-
)
|
|
619
|
+
new PPError(error.message, messageSendingFailed)
|
|
1751
620
|
);
|
|
1752
621
|
}
|
|
1753
622
|
}));
|
|
@@ -1766,13 +635,18 @@ class WindowBridge {
|
|
|
1766
635
|
* @param allowedOrigins a list of allowed origins from where request can be accepted
|
|
1767
636
|
* @returns `WindowBridge` instance
|
|
1768
637
|
*/
|
|
1769
|
-
static init(functions, allowedOrigins, middlewares = []) {
|
|
638
|
+
static init(functions, allowedOrigins, middlewares = [], errorLogger) {
|
|
1770
639
|
if (this._instance) {
|
|
1771
640
|
throw new Error(
|
|
1772
641
|
"WindowBridge already initialized, you can't call WindowBridge.init more than once"
|
|
1773
642
|
);
|
|
1774
643
|
}
|
|
1775
|
-
this._instance = new this(
|
|
644
|
+
this._instance = new this(
|
|
645
|
+
functions,
|
|
646
|
+
allowedOrigins,
|
|
647
|
+
middlewares,
|
|
648
|
+
errorLogger
|
|
649
|
+
);
|
|
1776
650
|
return this._instance;
|
|
1777
651
|
}
|
|
1778
652
|
/**
|
|
@@ -1959,28 +833,28 @@ function checkIFrameOrigin(origin) {
|
|
|
1959
833
|
}
|
|
1960
834
|
function getRefreshToken(clientId, useLocalStorage) {
|
|
1961
835
|
if (useLocalStorage) {
|
|
1962
|
-
const refreshToken = localStorage.getItem(
|
|
1963
|
-
`${
|
|
836
|
+
const refreshToken$1 = localStorage.getItem(
|
|
837
|
+
`${refreshToken}.${clientId}`
|
|
1964
838
|
);
|
|
1965
|
-
if (refreshToken) {
|
|
1966
|
-
return refreshToken;
|
|
839
|
+
if (refreshToken$1) {
|
|
840
|
+
return refreshToken$1;
|
|
1967
841
|
}
|
|
1968
842
|
}
|
|
1969
843
|
const refreshTokenWithClientId = api.get(
|
|
1970
|
-
`${
|
|
844
|
+
`${refreshToken}.${clientId}`
|
|
1971
845
|
);
|
|
1972
|
-
return refreshTokenWithClientId || api.get(
|
|
846
|
+
return refreshTokenWithClientId || api.get(refreshToken) || "";
|
|
1973
847
|
}
|
|
1974
848
|
function getCodeVerifier(clientId, useLocalStorage) {
|
|
1975
849
|
if (useLocalStorage) {
|
|
1976
|
-
const codeVerifier = localStorage.getItem(
|
|
1977
|
-
`${
|
|
850
|
+
const codeVerifier$1 = localStorage.getItem(
|
|
851
|
+
`${codeVerifier}.${clientId}`
|
|
1978
852
|
);
|
|
1979
|
-
if (codeVerifier) {
|
|
1980
|
-
return codeVerifier;
|
|
853
|
+
if (codeVerifier$1) {
|
|
854
|
+
return codeVerifier$1;
|
|
1981
855
|
}
|
|
1982
856
|
}
|
|
1983
|
-
return api.get(`${
|
|
857
|
+
return api.get(`${codeVerifier}.${clientId}`) || api.get(codeVerifier) || "";
|
|
1984
858
|
}
|
|
1985
859
|
function exposeClientJsBridge(jsBridge) {
|
|
1986
860
|
if (window.hasOwnProperty(jsBridgeNamespace) && window[jsBridgeNamespace] === jsBridge) {
|
|
@@ -2032,9 +906,9 @@ function promiseToCallback(functionName, target, getLoggingParams) {
|
|
|
2032
906
|
};
|
|
2033
907
|
}
|
|
2034
908
|
const INIT_STATUS_CODE_REMAP = {
|
|
2035
|
-
[
|
|
2036
|
-
[
|
|
2037
|
-
[
|
|
909
|
+
[sdkNotInitialized]: authorizationNeeded,
|
|
910
|
+
[tokenNotFound]: authorizationNeeded,
|
|
911
|
+
[tokenExpired]: tokenExpired
|
|
2038
912
|
};
|
|
2039
913
|
function callbackToPromise(target, functionName) {
|
|
2040
914
|
return (params = {}) => {
|
|
@@ -2086,22 +960,22 @@ const commonMessageHandler = (e) => {
|
|
|
2086
960
|
if (!checkIFrameOrigin(e.origin)) {
|
|
2087
961
|
return;
|
|
2088
962
|
}
|
|
2089
|
-
if (e.data.name ===
|
|
963
|
+
if (e.data.name === reload) {
|
|
2090
964
|
window.location.reload();
|
|
2091
965
|
}
|
|
2092
|
-
if (e.data.name ===
|
|
966
|
+
if (e.data.name === makeVisible) {
|
|
2093
967
|
showCoreIframe(true);
|
|
2094
968
|
return;
|
|
2095
969
|
}
|
|
2096
|
-
if (e.data.name ===
|
|
970
|
+
if (e.data.name === showIframe) {
|
|
2097
971
|
showCoreIframe(true);
|
|
2098
972
|
return;
|
|
2099
973
|
}
|
|
2100
|
-
if (e.data.name ===
|
|
974
|
+
if (e.data.name === hideIframe) {
|
|
2101
975
|
showCoreIframe(false);
|
|
2102
976
|
return;
|
|
2103
977
|
}
|
|
2104
|
-
if (e.data.name ===
|
|
978
|
+
if (e.data.name === link) {
|
|
2105
979
|
const linkOption = e.data.data;
|
|
2106
980
|
if (linkOption.target === "_blank") {
|
|
2107
981
|
window.open(linkOption.url, "_blank");
|
|
@@ -2109,7 +983,7 @@ const commonMessageHandler = (e) => {
|
|
|
2109
983
|
window.location.href = linkOption.url;
|
|
2110
984
|
}
|
|
2111
985
|
}
|
|
2112
|
-
if (e.data.name ===
|
|
986
|
+
if (e.data.name === consoleDebugInfo$1) {
|
|
2113
987
|
const { params } = e.data.data;
|
|
2114
988
|
consoleDebugInfo(params);
|
|
2115
989
|
}
|
|
@@ -2119,19 +993,19 @@ addEventListener("popstate", () => {
|
|
|
2119
993
|
getCoreIframe().then((iframe) => {
|
|
2120
994
|
var _a;
|
|
2121
995
|
const data = {
|
|
2122
|
-
name:
|
|
996
|
+
name: clientPopState
|
|
2123
997
|
};
|
|
2124
998
|
(_a = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _a.postMessage(data, CORE_IFRAME_ORIGIN);
|
|
2125
999
|
}).catch((error) => console.warn(error));
|
|
2126
1000
|
});
|
|
2127
1001
|
function init(params) {
|
|
2128
|
-
const
|
|
2129
|
-
const
|
|
2130
|
-
const clientVersion = "2.
|
|
1002
|
+
const refreshToken2 = getRefreshToken(params.clientId, params.useLocalStorage);
|
|
1003
|
+
const codeVerifier2 = getCodeVerifier(params.clientId, params.useLocalStorage);
|
|
1004
|
+
const clientVersion = "2.58.0";
|
|
2131
1005
|
const initParams = __spreadProps(__spreadValues({}, params), {
|
|
2132
|
-
refreshToken,
|
|
1006
|
+
refreshToken: refreshToken2,
|
|
2133
1007
|
clientVersion,
|
|
2134
|
-
codeVerifier,
|
|
1008
|
+
codeVerifier: codeVerifier2,
|
|
2135
1009
|
clientSdkType,
|
|
2136
1010
|
clientUrl: window.location.href
|
|
2137
1011
|
});
|
|
@@ -2146,13 +1020,13 @@ function init(params) {
|
|
|
2146
1020
|
};
|
|
2147
1021
|
initDonePromise.then(() => getCoreIframe()).then(() => {
|
|
2148
1022
|
triggerPostMessageToCore(
|
|
2149
|
-
|
|
1023
|
+
init$1,
|
|
2150
1024
|
__spreadProps(__spreadValues({}, params), { complete }),
|
|
2151
1025
|
initParams
|
|
2152
1026
|
);
|
|
2153
1027
|
}).catch(() => {
|
|
2154
1028
|
var _a;
|
|
2155
|
-
(_a = params.fail) == null ? void 0 : _a.call(params, { errorCode:
|
|
1029
|
+
(_a = params.fail) == null ? void 0 : _a.call(params, { errorCode: sdkNotInitialized });
|
|
2156
1030
|
complete();
|
|
2157
1031
|
});
|
|
2158
1032
|
initDonePromise = nextInitDonePromise;
|
|
@@ -2164,7 +1038,7 @@ const clientJsBridge = {
|
|
|
2164
1038
|
(_a = iframe == null ? void 0 : iframe.contentWindow) == null ? void 0 : _a.postMessage(
|
|
2165
1039
|
JSON.parse(
|
|
2166
1040
|
JSON.stringify({
|
|
2167
|
-
name:
|
|
1041
|
+
name: handleMessageFromNative,
|
|
2168
1042
|
params: {
|
|
2169
1043
|
json
|
|
2170
1044
|
}
|
|
@@ -2202,8 +1076,8 @@ function executePendingFunctionCalls(client2) {
|
|
|
2202
1076
|
}
|
|
2203
1077
|
}
|
|
2204
1078
|
const clientProperties = {
|
|
2205
|
-
version: "2.
|
|
2206
|
-
revision: "
|
|
1079
|
+
version: "2.58.0",
|
|
1080
|
+
revision: "5c56199"
|
|
2207
1081
|
};
|
|
2208
1082
|
function isInitClientParams(params) {
|
|
2209
1083
|
return params.clientId !== void 0;
|
|
@@ -2239,7 +1113,7 @@ function getClient({
|
|
|
2239
1113
|
yield initDonePromise;
|
|
2240
1114
|
} else {
|
|
2241
1115
|
(_a = params.fail) == null ? void 0 : _a.call(params, {
|
|
2242
|
-
errorCode:
|
|
1116
|
+
errorCode: sdkNotInitialized
|
|
2243
1117
|
});
|
|
2244
1118
|
(_b = params.complete) == null ? void 0 : _b.call(params);
|
|
2245
1119
|
return;
|
|
@@ -2278,7 +1152,7 @@ function copyToClipboard(params) {
|
|
|
2278
1152
|
if (result) {
|
|
2279
1153
|
(_a = params == null ? void 0 : params.success) == null ? void 0 : _a.call(params);
|
|
2280
1154
|
} else {
|
|
2281
|
-
(_b = params == null ? void 0 : params.fail) == null ? void 0 : _b.call(params, { errorCode:
|
|
1155
|
+
(_b = params == null ? void 0 : params.fail) == null ? void 0 : _b.call(params, { errorCode: other });
|
|
2282
1156
|
}
|
|
2283
1157
|
(_c = params.complete) == null ? void 0 : _c.call(params);
|
|
2284
1158
|
}
|
|
@@ -2300,7 +1174,7 @@ promiseToCallback(
|
|
|
2300
1174
|
);
|
|
2301
1175
|
function getKycPassportInfo(params) {
|
|
2302
1176
|
const url = window.location.href;
|
|
2303
|
-
triggerPostMessageToCore(
|
|
1177
|
+
triggerPostMessageToCore(getKycPassportInfo$1, params, __spreadProps(__spreadValues({}, params), {
|
|
2304
1178
|
url
|
|
2305
1179
|
}));
|
|
2306
1180
|
}
|
|
@@ -2321,7 +1195,7 @@ const logout = promiseToCallback("logout", () => __async(void 0, null, function*
|
|
|
2321
1195
|
} catch (error) {
|
|
2322
1196
|
throw new PPError(
|
|
2323
1197
|
`An error occurred while trying to logout the user, error=${error}`,
|
|
2324
|
-
|
|
1198
|
+
unknown
|
|
2325
1199
|
);
|
|
2326
1200
|
}
|
|
2327
1201
|
}));
|
|
@@ -2340,7 +1214,7 @@ const renderCoupons = promiseToCallback(
|
|
|
2340
1214
|
if (!containerElement) {
|
|
2341
1215
|
throw new PPError(
|
|
2342
1216
|
"Invalid coupon container Id",
|
|
2343
|
-
|
|
1217
|
+
badRequestInsufficientParameter
|
|
2344
1218
|
);
|
|
2345
1219
|
}
|
|
2346
1220
|
const coupons = yield coreFunctions.fetchCoupons({
|
|
@@ -2383,7 +1257,7 @@ const renderCoupons = promiseToCallback(
|
|
|
2383
1257
|
} catch (error) {
|
|
2384
1258
|
throw new PPError(
|
|
2385
1259
|
`An error occurred while displaying coupons, merchantId=${merchantId}, couponId=${couponId}, error=${error}`,
|
|
2386
|
-
|
|
1260
|
+
unknown
|
|
2387
1261
|
);
|
|
2388
1262
|
}
|
|
2389
1263
|
}),
|
|
@@ -2397,7 +1271,7 @@ function scanCode(params) {
|
|
|
2397
1271
|
const scanCodeParams = __spreadProps(__spreadValues({}, params), {
|
|
2398
1272
|
redirectUrlOnCancel: (_a = params == null ? void 0 : params.redirectUrlOnCancel) != null ? _a : window.location.href
|
|
2399
1273
|
});
|
|
2400
|
-
triggerPostMessageToCore(
|
|
1274
|
+
triggerPostMessageToCore(scanCode$1, params, scanCodeParams);
|
|
2401
1275
|
}
|
|
2402
1276
|
function setTitle(params) {
|
|
2403
1277
|
var _a, _b, _c;
|
|
@@ -2407,7 +1281,7 @@ function setTitle(params) {
|
|
|
2407
1281
|
}
|
|
2408
1282
|
function share(params) {
|
|
2409
1283
|
if (!(navigator == null ? void 0 : navigator.share)) {
|
|
2410
|
-
triggerPostMessageToCore(
|
|
1284
|
+
triggerPostMessageToCore(share$1, params, params);
|
|
2411
1285
|
return;
|
|
2412
1286
|
}
|
|
2413
1287
|
const data = {
|
|
@@ -2421,7 +1295,7 @@ function share(params) {
|
|
|
2421
1295
|
(_b = params == null ? void 0 : params.complete) == null ? void 0 : _b.call(params);
|
|
2422
1296
|
}).catch(() => {
|
|
2423
1297
|
var _a, _b;
|
|
2424
|
-
(_a = params == null ? void 0 : params.fail) == null ? void 0 : _a.call(params, { errorCode:
|
|
1298
|
+
(_a = params == null ? void 0 : params.fail) == null ? void 0 : _a.call(params, { errorCode: unknown });
|
|
2425
1299
|
(_b = params == null ? void 0 : params.complete) == null ? void 0 : _b.call(params);
|
|
2426
1300
|
});
|
|
2427
1301
|
}
|
|
@@ -2457,7 +1331,7 @@ function removeStorageData(params) {
|
|
|
2457
1331
|
}
|
|
2458
1332
|
function verifyMultiFactorAuthResult(params) {
|
|
2459
1333
|
const url = new URL(window.location.href);
|
|
2460
|
-
triggerPostMessageToCore(
|
|
1334
|
+
triggerPostMessageToCore(verifyMultiFactorAuthResult$1, params, __spreadProps(__spreadValues({}, params), {
|
|
2461
1335
|
sessionId: url.searchParams.get("ppSessionId")
|
|
2462
1336
|
}));
|
|
2463
1337
|
}
|