@passgage/sdk-react-native 1.0.13 → 1.0.15

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/index.js CHANGED
@@ -8,6 +8,7 @@ var Geolocation2 = require('react-native-geolocation-service');
8
8
  var RNPermissions = require('react-native-permissions');
9
9
  var reactNative = require('react-native');
10
10
  var NfcManager = require('react-native-nfc-manager');
11
+ var bigInt = require('big-integer');
11
12
 
12
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
14
 
@@ -35,6 +36,7 @@ var Keychain__namespace = /*#__PURE__*/_interopNamespace(Keychain);
35
36
  var Geolocation2__default = /*#__PURE__*/_interopDefault(Geolocation2);
36
37
  var RNPermissions__default = /*#__PURE__*/_interopDefault(RNPermissions);
37
38
  var NfcManager__default = /*#__PURE__*/_interopDefault(NfcManager);
39
+ var bigInt__default = /*#__PURE__*/_interopDefault(bigInt);
38
40
 
39
41
  var __defProp = Object.defineProperty;
40
42
  var __export = (target, all) => {
@@ -1171,14 +1173,14 @@ var enteranceFlow = async (data, options) => {
1171
1173
  }
1172
1174
  };
1173
1175
  }
1174
- if (!options.skipRepetitiveCheck && !checkRepetitiveRead(isQrCode ? qrCode : nfcCode)) {
1176
+ if (!options?.skipRepetitiveCheck && !checkRepetitiveRead(isQrCode ? qrCode : nfcCode)) {
1175
1177
  return {
1176
1178
  success: false,
1177
1179
  message: "QR code was recently scanned. Please wait before scanning again.",
1178
1180
  error: { code: "REPETITIVE_READ" }
1179
1181
  };
1180
1182
  }
1181
- if (!options.skipLocationCheck) {
1183
+ if (!options?.skipLocationCheck) {
1182
1184
  const locationValidation = validateLocation(device, location ?? void 0);
1183
1185
  if (!locationValidation.valid) {
1184
1186
  return {
@@ -1199,9 +1201,7 @@ var enteranceFlow = async (data, options) => {
1199
1201
  const enteranceResIot = await QRAccessService.triggerIoTDevice(device.id);
1200
1202
  if (enteranceResIot.success) {
1201
1203
  try {
1202
- const enteranceQrRes = await QRAccessService.createEntranceFromQR(
1203
- onlineRequestBody
1204
- );
1204
+ const enteranceQrRes = await QRAccessService.createEntranceFromQR(onlineRequestBody);
1205
1205
  if (enteranceQrRes.success) {
1206
1206
  addQrReadRecord(qrCode);
1207
1207
  return {
@@ -1235,9 +1235,7 @@ var enteranceFlow = async (data, options) => {
1235
1235
  }
1236
1236
  } else {
1237
1237
  try {
1238
- const enteranceQrRes = await QRAccessService.createEntranceFromQR(
1239
- onlineRequestBody
1240
- );
1238
+ const enteranceQrRes = await QRAccessService.createEntranceFromQR(onlineRequestBody);
1241
1239
  addQrReadRecord(qrCode);
1242
1240
  return {
1243
1241
  success: !!enteranceQrRes?.success,
@@ -1493,7 +1491,7 @@ var usePassgageQRScanner = (payload) => {
1493
1491
  if (!qrDevice) {
1494
1492
  qrDevice = qrDevices.find((item) => item.qr_code_id === qrCode);
1495
1493
  if (!qrDevice) {
1496
- payload.onError?.(
1494
+ payload?.onError?.(
1497
1495
  error ?? { message: "QR Device not found", success: false }
1498
1496
  );
1499
1497
  return;
@@ -1505,12 +1503,12 @@ var usePassgageQRScanner = (payload) => {
1505
1503
  qrCode,
1506
1504
  isQrCode: true
1507
1505
  },
1508
- payload.options
1506
+ payload?.options
1509
1507
  );
1510
1508
  if (!result.success) {
1511
- payload.onError?.(result);
1509
+ payload?.onError?.(result);
1512
1510
  } else {
1513
- payload.onSuccess?.(result.entrance);
1511
+ payload?.onSuccess?.(result.entrance);
1514
1512
  }
1515
1513
  } catch (err) {
1516
1514
  const errorObj = {
@@ -1519,7 +1517,7 @@ var usePassgageQRScanner = (payload) => {
1519
1517
  error: { code: "QR_SCAN_FAILED" }
1520
1518
  };
1521
1519
  setError(errorObj);
1522
- payload.onError?.(errorObj);
1520
+ payload?.onError?.(errorObj);
1523
1521
  } finally {
1524
1522
  setIsLoading(false);
1525
1523
  }
@@ -1537,7 +1535,7 @@ var reversedHexToDec = (reversedHex) => {
1537
1535
  for (let i = reversedHex.length; i > 0; i -= 2) {
1538
1536
  originalHex += reversedHex.substring(i - 2, i);
1539
1537
  }
1540
- let decimalValue = 111;
1538
+ let decimalValue = bigInt__default.default(originalHex, 16);
1541
1539
  return decimalValue.toString();
1542
1540
  } catch (error) {
1543
1541
  return reversedHex;
@@ -1588,17 +1586,17 @@ function usePassgageNFCScanner(payload) {
1588
1586
  nfcCode,
1589
1587
  isQrCode: false
1590
1588
  },
1591
- payload.options
1589
+ payload?.options
1592
1590
  );
1593
1591
  if (!result.success) {
1594
1592
  throw new Error(result.message);
1595
1593
  }
1596
- payload.onSuccess?.(result.entrance);
1594
+ payload?.onSuccess?.(result.entrance);
1597
1595
  stopScanning();
1598
1596
  } catch (err) {
1599
1597
  const error2 = err;
1600
1598
  setError(error2);
1601
- payload.onError?.(error2);
1599
+ payload?.onError?.(error2);
1602
1600
  stopScanning();
1603
1601
  }
1604
1602
  };
package/dist/index.mjs CHANGED
@@ -6,6 +6,7 @@ import Geolocation2 from 'react-native-geolocation-service';
6
6
  import RNPermissions, { PERMISSIONS, RESULTS, request } from 'react-native-permissions';
7
7
  import { Platform } from 'react-native';
8
8
  import NfcManager, { NfcTech } from 'react-native-nfc-manager';
9
+ import bigInt from 'big-integer';
9
10
 
10
11
  var __defProp = Object.defineProperty;
11
12
  var __export = (target, all) => {
@@ -1142,14 +1143,14 @@ var enteranceFlow = async (data, options) => {
1142
1143
  }
1143
1144
  };
1144
1145
  }
1145
- if (!options.skipRepetitiveCheck && !checkRepetitiveRead(isQrCode ? qrCode : nfcCode)) {
1146
+ if (!options?.skipRepetitiveCheck && !checkRepetitiveRead(isQrCode ? qrCode : nfcCode)) {
1146
1147
  return {
1147
1148
  success: false,
1148
1149
  message: "QR code was recently scanned. Please wait before scanning again.",
1149
1150
  error: { code: "REPETITIVE_READ" }
1150
1151
  };
1151
1152
  }
1152
- if (!options.skipLocationCheck) {
1153
+ if (!options?.skipLocationCheck) {
1153
1154
  const locationValidation = validateLocation(device, location ?? void 0);
1154
1155
  if (!locationValidation.valid) {
1155
1156
  return {
@@ -1170,9 +1171,7 @@ var enteranceFlow = async (data, options) => {
1170
1171
  const enteranceResIot = await QRAccessService.triggerIoTDevice(device.id);
1171
1172
  if (enteranceResIot.success) {
1172
1173
  try {
1173
- const enteranceQrRes = await QRAccessService.createEntranceFromQR(
1174
- onlineRequestBody
1175
- );
1174
+ const enteranceQrRes = await QRAccessService.createEntranceFromQR(onlineRequestBody);
1176
1175
  if (enteranceQrRes.success) {
1177
1176
  addQrReadRecord(qrCode);
1178
1177
  return {
@@ -1206,9 +1205,7 @@ var enteranceFlow = async (data, options) => {
1206
1205
  }
1207
1206
  } else {
1208
1207
  try {
1209
- const enteranceQrRes = await QRAccessService.createEntranceFromQR(
1210
- onlineRequestBody
1211
- );
1208
+ const enteranceQrRes = await QRAccessService.createEntranceFromQR(onlineRequestBody);
1212
1209
  addQrReadRecord(qrCode);
1213
1210
  return {
1214
1211
  success: !!enteranceQrRes?.success,
@@ -1464,7 +1461,7 @@ var usePassgageQRScanner = (payload) => {
1464
1461
  if (!qrDevice) {
1465
1462
  qrDevice = qrDevices.find((item) => item.qr_code_id === qrCode);
1466
1463
  if (!qrDevice) {
1467
- payload.onError?.(
1464
+ payload?.onError?.(
1468
1465
  error ?? { message: "QR Device not found", success: false }
1469
1466
  );
1470
1467
  return;
@@ -1476,12 +1473,12 @@ var usePassgageQRScanner = (payload) => {
1476
1473
  qrCode,
1477
1474
  isQrCode: true
1478
1475
  },
1479
- payload.options
1476
+ payload?.options
1480
1477
  );
1481
1478
  if (!result.success) {
1482
- payload.onError?.(result);
1479
+ payload?.onError?.(result);
1483
1480
  } else {
1484
- payload.onSuccess?.(result.entrance);
1481
+ payload?.onSuccess?.(result.entrance);
1485
1482
  }
1486
1483
  } catch (err) {
1487
1484
  const errorObj = {
@@ -1490,7 +1487,7 @@ var usePassgageQRScanner = (payload) => {
1490
1487
  error: { code: "QR_SCAN_FAILED" }
1491
1488
  };
1492
1489
  setError(errorObj);
1493
- payload.onError?.(errorObj);
1490
+ payload?.onError?.(errorObj);
1494
1491
  } finally {
1495
1492
  setIsLoading(false);
1496
1493
  }
@@ -1508,7 +1505,7 @@ var reversedHexToDec = (reversedHex) => {
1508
1505
  for (let i = reversedHex.length; i > 0; i -= 2) {
1509
1506
  originalHex += reversedHex.substring(i - 2, i);
1510
1507
  }
1511
- let decimalValue = 111;
1508
+ let decimalValue = bigInt(originalHex, 16);
1512
1509
  return decimalValue.toString();
1513
1510
  } catch (error) {
1514
1511
  return reversedHex;
@@ -1559,17 +1556,17 @@ function usePassgageNFCScanner(payload) {
1559
1556
  nfcCode,
1560
1557
  isQrCode: false
1561
1558
  },
1562
- payload.options
1559
+ payload?.options
1563
1560
  );
1564
1561
  if (!result.success) {
1565
1562
  throw new Error(result.message);
1566
1563
  }
1567
- payload.onSuccess?.(result.entrance);
1564
+ payload?.onSuccess?.(result.entrance);
1568
1565
  stopScanning();
1569
1566
  } catch (err) {
1570
1567
  const error2 = err;
1571
1568
  setError(error2);
1572
- payload.onError?.(error2);
1569
+ payload?.onError?.(error2);
1573
1570
  stopScanning();
1574
1571
  }
1575
1572
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@passgage/sdk-react-native",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Passgage Access SDK - React Native wrapper with components and hooks",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -55,6 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "axios": "^1.6.0",
58
+ "big-integer": "^1.6.52",
58
59
  "zustand": "^5.0.9"
59
60
  },
60
61
  "peerDependencies": {