@paypay/mini-app-js-sdk 1.20.0 → 1.21.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.
@@ -65,7 +65,7 @@ function normalizeNativeResponseData(data2) {
65
65
  }
66
66
  class JsBridge {
67
67
  constructor(global) {
68
- this.version = "1.20.0";
68
+ this.version = "1.21.0";
69
69
  this.messageHandlers = new Map();
70
70
  this.responseCallbacks = new Map();
71
71
  this.global = global;
@@ -772,6 +772,7 @@ function saveCookie(key, value2, expires) {
772
772
  }
773
773
  function removeCookie(key) {
774
774
  var _a, _b;
775
+ api.remove(key);
775
776
  api.remove(key, { domain: (_a = window.location) == null ? void 0 : _a.hostname });
776
777
  api.remove(key, { domain: parseDomain((_b = window.location) == null ? void 0 : _b.hostname) });
777
778
  }
@@ -1082,7 +1083,7 @@ const opaUrl = () => {
1082
1083
  const createHeaderMiniAppApi = (urlEndpoint, customHeaders) => {
1083
1084
  let headers = new Headers(__spreadValues({
1084
1085
  "Content-Type": "application/json",
1085
- "Client-Version": "1.20.0",
1086
+ "Client-Version": "1.21.0",
1086
1087
  "Client-OS-Type": getRuntime()
1087
1088
  }, customHeaders));
1088
1089
  if (urlEndpoint === "web-api/app/v2/payment/methods" || urlEndpoint === "web-api/app/v2/payment/consult" || urlEndpoint === "web-api/app/v1/payment/cashbackDetail" || urlEndpoint === "web-api/app/v1/confirmAgeForCashback" || urlEndpoint === "web-api/app/v1/internal/request" || urlEndpoint === "web-api/app/v1/addressbyzip" || urlEndpoint === "/web-api/app/platform/v1/balance") {
@@ -1523,11 +1524,14 @@ async function getPermissionStatus(params) {
1523
1524
  await execute$8(params);
1524
1525
  }
1525
1526
  async function execute$8(params) {
1526
- var _a, _b, _c;
1527
+ var _a, _b, _c, _d;
1527
1528
  try {
1528
1529
  const permissionList = await getUserGrantedPermission();
1530
+ if (!permissionList) {
1531
+ return (_a = params == null ? void 0 : params.fail) == null ? void 0 : _a.call(params, { errorCode: MiniAppErrorType.serverError });
1532
+ }
1529
1533
  if (!(params == null ? void 0 : params.name)) {
1530
- return (_a = params == null ? void 0 : params.success) == null ? void 0 : _a.call(params, {
1534
+ return (_b = params == null ? void 0 : params.success) == null ? void 0 : _b.call(params, {
1531
1535
  granted_permissions: permissionList
1532
1536
  });
1533
1537
  } else {
@@ -1535,10 +1539,10 @@ async function execute$8(params) {
1535
1539
  return name === (params == null ? void 0 : params.name);
1536
1540
  });
1537
1541
  const status2 = thePermission ? PermissionStatus.granted : PermissionStatus.denied;
1538
- return (_b = params == null ? void 0 : params.success) == null ? void 0 : _b.call(params, { status: status2 });
1542
+ return (_c = params == null ? void 0 : params.success) == null ? void 0 : _c.call(params, { status: status2 });
1539
1543
  }
1540
1544
  } catch (_) {
1541
- return (_c = params == null ? void 0 : params.fail) == null ? void 0 : _c.call(params, { errorCode: MiniAppErrorType.serverError });
1545
+ return (_d = params == null ? void 0 : params.fail) == null ? void 0 : _d.call(params, { errorCode: MiniAppErrorType.serverError });
1542
1546
  }
1543
1547
  }
1544
1548
  function useGetHeights() {
@@ -22542,6 +22546,15 @@ async function resendEmail() {
22542
22546
  method: "POST"
22543
22547
  });
22544
22548
  }
22549
+ function getUserLocationRequest(params) {
22550
+ return ppFetch({
22551
+ url: "web-api/app/v1/location",
22552
+ method: "GET",
22553
+ params: {
22554
+ validTimeMinutes: params.validTimeMinutes
22555
+ }
22556
+ });
22557
+ }
22545
22558
  function isValidUrl(urlChallenge) {
22546
22559
  return /^https?:\/\//.test(urlChallenge);
22547
22560
  }
@@ -28498,50 +28511,67 @@ async function setTitle(params) {
28498
28511
  (_a = params == null ? void 0 : params.success) == null ? void 0 : _a.call(params);
28499
28512
  }
28500
28513
  async function getUserLocation(params) {
28501
- var _a, _b;
28514
+ var _a, _b, _c;
28502
28515
  reconstructParams(params);
28503
28516
  try {
28504
28517
  const grantStatus = await checkPermission(PermissionName.mini_app_user_location);
28505
28518
  if (grantStatus !== PermissionStatus.granted) {
28506
28519
  (_a = params == null ? void 0 : params.fail) == null ? void 0 : _a.call(params, { errorCode: MiniAppErrorType.insufficientScope });
28507
28520
  return;
28508
- } else {
28509
- await new Promise((resolve2, _) => {
28510
- var _a2;
28511
- if (navigator.geolocation) {
28512
- navigator.geolocation.getCurrentPosition((res) => {
28513
- var _a3, _b2, _c;
28514
- (_c = params == null ? void 0 : params.success) == null ? void 0 : _c.call(params, {
28515
- result: {
28516
- lat: (_a3 = res == null ? void 0 : res.coords) == null ? void 0 : _a3.latitude,
28517
- long: (_b2 = res == null ? void 0 : res.coords) == null ? void 0 : _b2.longitude
28518
- }
28519
- });
28520
- resolve2(null);
28521
- return;
28522
- }, () => {
28523
- var _a3;
28524
- (_a3 = params == null ? void 0 : params.fail) == null ? void 0 : _a3.call(params, {
28525
- errorCode: MiniAppErrorType.hostAppLocationDenied
28526
- });
28527
- resolve2(null);
28528
- return;
28529
- }, {
28530
- enableHighAccuracy: params.accuracy === "high",
28531
- timeout: 1e4,
28532
- maximumAge: 0
28521
+ }
28522
+ let validTimeMinutes = 30;
28523
+ if (Number.isInteger(params.validTimeMinutes)) {
28524
+ validTimeMinutes = params.validTimeMinutes;
28525
+ }
28526
+ if (validTimeMinutes > 0) {
28527
+ const resp = await getUserLocationRequest({ validTimeMinutes });
28528
+ if (!("error" in resp) && resp.unsigned.data.location) {
28529
+ const lat = Number.parseFloat(resp.unsigned.data.location.lat);
28530
+ const long = Number.parseFloat(resp.unsigned.data.location.lon);
28531
+ (_b = params == null ? void 0 : params.success) == null ? void 0 : _b.call(params, {
28532
+ result: {
28533
+ lat,
28534
+ long
28535
+ }
28536
+ });
28537
+ return;
28538
+ }
28539
+ }
28540
+ await new Promise((resolve2, _) => {
28541
+ var _a2;
28542
+ if (navigator.geolocation) {
28543
+ navigator.geolocation.getCurrentPosition((res) => {
28544
+ var _a3, _b2, _c2;
28545
+ (_c2 = params == null ? void 0 : params.success) == null ? void 0 : _c2.call(params, {
28546
+ result: {
28547
+ lat: (_a3 = res == null ? void 0 : res.coords) == null ? void 0 : _a3.latitude,
28548
+ long: (_b2 = res == null ? void 0 : res.coords) == null ? void 0 : _b2.longitude
28549
+ }
28533
28550
  });
28534
- } else {
28535
- (_a2 = params == null ? void 0 : params.fail) == null ? void 0 : _a2.call(params, {
28551
+ resolve2(null);
28552
+ return;
28553
+ }, () => {
28554
+ var _a3;
28555
+ (_a3 = params == null ? void 0 : params.fail) == null ? void 0 : _a3.call(params, {
28536
28556
  errorCode: MiniAppErrorType.hostAppLocationDenied
28537
28557
  });
28538
28558
  resolve2(null);
28539
28559
  return;
28540
- }
28541
- });
28542
- }
28560
+ }, {
28561
+ enableHighAccuracy: params.accuracy === "high",
28562
+ timeout: 1e4,
28563
+ maximumAge: 0
28564
+ });
28565
+ } else {
28566
+ (_a2 = params == null ? void 0 : params.fail) == null ? void 0 : _a2.call(params, {
28567
+ errorCode: MiniAppErrorType.hostAppLocationDenied
28568
+ });
28569
+ resolve2(null);
28570
+ return;
28571
+ }
28572
+ });
28543
28573
  } catch {
28544
- (_b = params == null ? void 0 : params.fail) == null ? void 0 : _b.call(params, { errorCode: MiniAppErrorType.other });
28574
+ (_c = params == null ? void 0 : params.fail) == null ? void 0 : _c.call(params, { errorCode: MiniAppErrorType.other });
28545
28575
  }
28546
28576
  }
28547
28577
  const initGetUserAddress = async (params) => {
@@ -29188,7 +29218,7 @@ async function debug(params) {
29188
29218
  async function execute$5(params) {
29189
29219
  var _a;
29190
29220
  (_a = params == null ? void 0 : params.success) == null ? void 0 : _a.call(params, {
29191
- v: "1.20.0"
29221
+ v: "1.21.0"
29192
29222
  });
29193
29223
  }
29194
29224
  function useCallBack(props, ctx) {
package/dist/types.d.ts CHANGED
@@ -148,6 +148,7 @@ export interface GetUserLocationResult {
148
148
  };
149
149
  }
150
150
  export interface GetUserLocationParams extends NativeParams<GetUserLocationResult, MiniAppErrorResultType, void> {
151
+ validTimeMinutes?: number;
151
152
  accuracy?: string;
152
153
  }
153
154
  export declare enum TakePhotoMode {
@@ -143,5 +143,18 @@ export declare type RegisterEmailResponse = {
143
143
  };
144
144
  export declare function registerEmail(email: string): Promise<import("./fetch").ErrorResponse | RegisterEmailResponse>;
145
145
  export declare function resendEmail(): Promise<import("./fetch").ErrorResponse | RegisterEmailResponse>;
146
+ export declare type UserLocationResponse = {
147
+ unsigned: {
148
+ data: {
149
+ location?: {
150
+ lat: string;
151
+ lon: string;
152
+ };
153
+ };
154
+ };
155
+ };
156
+ export declare function getUserLocationRequest(params: {
157
+ validTimeMinutes: number;
158
+ }): Promise<import("./fetch").ErrorResponse | UserLocationResponse>;
146
159
  export declare function isValidUrl(urlChallenge: string): boolean;
147
160
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypay/mini-app-js-sdk",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "build": "vite build",