@authme/util 2.4.7 → 2.7.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/index.cjs +51 -32
- package/index.js +51 -32
- package/package.json +1 -1
- package/src/lib/common/state.service.d.ts +1 -1
- package/src/ui/camera.d.ts +1 -1
- package/src/ui/error-message.d.ts +2 -2
package/index.cjs
CHANGED
|
@@ -302,6 +302,7 @@ function getOsVersion(userAgent) {
|
|
|
302
302
|
|
|
303
303
|
class State {
|
|
304
304
|
constructor(initialValue = null) {
|
|
305
|
+
this._effects = [];
|
|
305
306
|
this._value = initialValue;
|
|
306
307
|
}
|
|
307
308
|
getValue() {
|
|
@@ -309,10 +310,22 @@ class State {
|
|
|
309
310
|
}
|
|
310
311
|
setValue(newValue) {
|
|
311
312
|
this._value = newValue;
|
|
313
|
+
this._runEffects(newValue);
|
|
314
|
+
}
|
|
315
|
+
addEffect(effect) {
|
|
316
|
+
this._effects.push(effect);
|
|
317
|
+
}
|
|
318
|
+
_runEffects(value) {
|
|
319
|
+
for (const effect of this._effects) {
|
|
320
|
+
effect(value);
|
|
321
|
+
}
|
|
312
322
|
}
|
|
313
323
|
}
|
|
314
|
-
function useState(initialValue = null, subscription) {
|
|
324
|
+
function useState(initialValue = null, subscription, effects = []) {
|
|
315
325
|
const state = new State(initialValue);
|
|
326
|
+
for (const effect of effects) {
|
|
327
|
+
state.addEffect(effect);
|
|
328
|
+
}
|
|
316
329
|
function getValue() {
|
|
317
330
|
return state.getValue();
|
|
318
331
|
}
|
|
@@ -1081,7 +1094,7 @@ function asyncShowErrorMessage(text, showRetryBtn, options) {
|
|
|
1081
1094
|
});
|
|
1082
1095
|
});
|
|
1083
1096
|
}
|
|
1084
|
-
function asyncOnLineShowErrorMessage(text, showRetryBtn) {
|
|
1097
|
+
function asyncOnLineShowErrorMessage(text, buttonText, showRetryBtn) {
|
|
1085
1098
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1086
1099
|
return new Promise((res, rej) => {
|
|
1087
1100
|
showErrorMessage(text, showRetryBtn, (_, tools) => {
|
|
@@ -1089,14 +1102,14 @@ function asyncOnLineShowErrorMessage(text, showRetryBtn) {
|
|
|
1089
1102
|
res(true);
|
|
1090
1103
|
tools === null || tools === void 0 ? void 0 : tools.hideErrorMessage();
|
|
1091
1104
|
}
|
|
1092
|
-
});
|
|
1105
|
+
}, buttonText);
|
|
1093
1106
|
});
|
|
1094
1107
|
});
|
|
1095
1108
|
}
|
|
1096
|
-
function checkOnlineStatus(msg) {
|
|
1109
|
+
function checkOnlineStatus(msg, buttonText) {
|
|
1097
1110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1098
1111
|
if (!window.navigator.onLine) {
|
|
1099
|
-
yield asyncOnLineShowErrorMessage(msg, true);
|
|
1112
|
+
yield asyncOnLineShowErrorMessage(msg, buttonText, true);
|
|
1100
1113
|
}
|
|
1101
1114
|
});
|
|
1102
1115
|
}
|
|
@@ -1249,22 +1262,27 @@ function switchCamera(deviceId, video) {
|
|
|
1249
1262
|
}
|
|
1250
1263
|
const constraints = {
|
|
1251
1264
|
video: {
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
width: {
|
|
1255
|
-
min: 1280,
|
|
1256
|
-
ideal: 1920,
|
|
1257
|
-
max: 1920
|
|
1258
|
-
},
|
|
1259
|
-
height: {
|
|
1260
|
-
min: 720,
|
|
1261
|
-
ideal: 1080,
|
|
1262
|
-
max: 1080
|
|
1263
|
-
},
|
|
1265
|
+
width: {},
|
|
1266
|
+
height: {},
|
|
1264
1267
|
focusMode: 'auto',
|
|
1265
1268
|
deviceId: deviceId
|
|
1266
1269
|
}
|
|
1267
1270
|
};
|
|
1271
|
+
const constraint = localStorage.getItem('camera_constraint');
|
|
1272
|
+
if (!constraint) {
|
|
1273
|
+
// 推測依然需要使用 width & height 的限制條件,
|
|
1274
|
+
// 否則即使是高解析度相機,也有可能拿到低解析度的圖片。(待驗證)
|
|
1275
|
+
constraints.video.width = {
|
|
1276
|
+
min: 1280,
|
|
1277
|
+
ideal: 1920,
|
|
1278
|
+
max: 1920
|
|
1279
|
+
};
|
|
1280
|
+
constraints.video.height = {
|
|
1281
|
+
min: 720,
|
|
1282
|
+
ideal: 1080,
|
|
1283
|
+
max: 1080
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1268
1286
|
stream = yield navigator.mediaDevices.getUserMedia(constraints);
|
|
1269
1287
|
video.srcObject = stream;
|
|
1270
1288
|
yield video.play();
|
|
@@ -1279,7 +1297,6 @@ function switchCamera(deviceId, video) {
|
|
|
1279
1297
|
});
|
|
1280
1298
|
}
|
|
1281
1299
|
function _requestCamera(video, facingMode) {
|
|
1282
|
-
var _a;
|
|
1283
1300
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1284
1301
|
if (!('mediaDevices' in navigator)) {
|
|
1285
1302
|
throw BROWSER_CAMERA_ERRORS.NOT_SUPPORT;
|
|
@@ -1298,7 +1315,7 @@ function _requestCamera(video, facingMode) {
|
|
|
1298
1315
|
// 輪詢取得攝影機 解析度等資訊
|
|
1299
1316
|
const videoDevices = (yield navigator.mediaDevices.enumerateDevices()).filter(device => device.kind === 'videoinput');
|
|
1300
1317
|
const deviceMetas = yield arrayFromAsync(asyncMap(device => __awaiter(this, void 0, void 0, function* () {
|
|
1301
|
-
var _b, _c, _d
|
|
1318
|
+
var _a, _b, _c, _d;
|
|
1302
1319
|
const stream = yield navigator.mediaDevices.getUserMedia({
|
|
1303
1320
|
video: {
|
|
1304
1321
|
deviceId: {
|
|
@@ -1306,10 +1323,10 @@ function _requestCamera(video, facingMode) {
|
|
|
1306
1323
|
}
|
|
1307
1324
|
}
|
|
1308
1325
|
});
|
|
1309
|
-
const track = (
|
|
1310
|
-
const capabilities = ((
|
|
1311
|
-
const widthMax = (
|
|
1312
|
-
const heightMax = (
|
|
1326
|
+
const track = (_a = stream.getVideoTracks()) === null || _a === void 0 ? void 0 : _a[0];
|
|
1327
|
+
const capabilities = ((_b = track === null || track === void 0 ? void 0 : track.getCapabilities) !== null && _b !== void 0 ? _b : () => undefined).bind(track)(); // firefox 沒有 getCapabilities 可以用。
|
|
1328
|
+
const widthMax = (_c = capabilities === null || capabilities === void 0 ? void 0 : capabilities.width) === null || _c === void 0 ? void 0 : _c.max;
|
|
1329
|
+
const heightMax = (_d = capabilities === null || capabilities === void 0 ? void 0 : capabilities.height) === null || _d === void 0 ? void 0 : _d.max;
|
|
1313
1330
|
const resolution = widthMax && heightMax ? widthMax * heightMax : 0;
|
|
1314
1331
|
const facingModeFromLabel = inferFacingModeFromLabel(device === null || device === void 0 ? void 0 : device.label);
|
|
1315
1332
|
const facingModeFromapabilities = inferFacingModeFromCapabilities(capabilities);
|
|
@@ -1328,7 +1345,7 @@ function _requestCamera(video, facingMode) {
|
|
|
1328
1345
|
capabilities
|
|
1329
1346
|
};
|
|
1330
1347
|
}), videoDevices));
|
|
1331
|
-
const
|
|
1348
|
+
const devices = deviceMetas.sort((a, b) => {
|
|
1332
1349
|
// 若是 Samsung 手機且模式為後鏡頭,則優先使用Label為 camera2 0 的鏡頭
|
|
1333
1350
|
let samsungCondition = 0;
|
|
1334
1351
|
if (isSamsung && facingMode === 'back') {
|
|
@@ -1347,7 +1364,9 @@ function _requestCamera(video, facingMode) {
|
|
|
1347
1364
|
}
|
|
1348
1365
|
const resolutionCondition = b.meta.resolution - a.meta.resolution;
|
|
1349
1366
|
return samsungCondition || cameraFacingCondition || resolutionCondition;
|
|
1350
|
-
})
|
|
1367
|
+
});
|
|
1368
|
+
const cameraIndex = window.localStorage.getItem('camera') || '0';
|
|
1369
|
+
const firstDevice = devices[parseInt(cameraIndex, 10)];
|
|
1351
1370
|
const deviceId = firstDevice.device.deviceId;
|
|
1352
1371
|
if (!deviceId) {
|
|
1353
1372
|
throw BROWSER_CAMERA_ERRORS.NO_CAMERA;
|
|
@@ -1382,19 +1401,19 @@ function requestCamera({
|
|
|
1382
1401
|
return yield _requestCamera(video, facingMode);
|
|
1383
1402
|
} catch (error) {
|
|
1384
1403
|
if (error === BROWSER_CAMERA_ERRORS.NOT_SUPPORT) {
|
|
1385
|
-
showMessage(translate('
|
|
1404
|
+
showMessage(translate('sdk.general.error.cameraNotFound.title'));
|
|
1386
1405
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, 'Browser not support WebRTC, or https required.');
|
|
1387
1406
|
}
|
|
1388
1407
|
if (error === BROWSER_CAMERA_ERRORS.NO_CAMERA) {
|
|
1389
|
-
showMessage(translate('
|
|
1408
|
+
showMessage(translate('sdk.general.error.cameraNotFound.content'));
|
|
1390
1409
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, 'camera not found');
|
|
1391
1410
|
}
|
|
1392
1411
|
if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_ALLOWED_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_FOUND_ERROR) {
|
|
1393
|
-
showMessage(translate('
|
|
1412
|
+
showMessage(translate('sdk.general.error.cameraNotFound.content'));
|
|
1394
1413
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1395
1414
|
}
|
|
1396
1415
|
if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_READABLE_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.ABORT_ERROR) {
|
|
1397
|
-
showMessage(translate('
|
|
1416
|
+
showMessage(translate('sdk.general.error.cameraNotFound.content'));
|
|
1398
1417
|
/* NOT_READABLE_ERROR,ABORT_ERROR 這兩個錯誤是用戶授權了,但在呼叫裝置時出現錯誤,
|
|
1399
1418
|
* 常發生在APP webview ,例如: 手機開啟 web 使用 sdk,儘管在 webview 層級上授權了,但手機在設定層級沒有授權 app 使用相機,會導致此問題。
|
|
1400
1419
|
* 但每個 android 手機的在這方面的實作不一致,不是每個手機在這種情況下都會拋出錯誤。
|
|
@@ -1403,7 +1422,7 @@ function requestCamera({
|
|
|
1403
1422
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1404
1423
|
}
|
|
1405
1424
|
if (isOverconstrainedError(error)) {
|
|
1406
|
-
showMessage(translate('
|
|
1425
|
+
showMessage(translate('sdk.general.error.cameraLowResolution'));
|
|
1407
1426
|
throw new AuthmeError(exports.ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1408
1427
|
}
|
|
1409
1428
|
throw error;
|
|
@@ -2425,8 +2444,8 @@ window.ononline = () => {
|
|
|
2425
2444
|
};
|
|
2426
2445
|
|
|
2427
2446
|
var name = "authme/sdk";
|
|
2428
|
-
var version$1 = "2.
|
|
2429
|
-
var date = "
|
|
2447
|
+
var version$1 = "2.7.0";
|
|
2448
|
+
var date = "2024-05-30T14:54:23+0000";
|
|
2430
2449
|
var packageInfo = {
|
|
2431
2450
|
name: name,
|
|
2432
2451
|
version: version$1,
|
package/index.js
CHANGED
|
@@ -292,6 +292,7 @@ function getOsVersion(userAgent) {
|
|
|
292
292
|
|
|
293
293
|
class State {
|
|
294
294
|
constructor(initialValue = null) {
|
|
295
|
+
this._effects = [];
|
|
295
296
|
this._value = initialValue;
|
|
296
297
|
}
|
|
297
298
|
getValue() {
|
|
@@ -299,10 +300,22 @@ class State {
|
|
|
299
300
|
}
|
|
300
301
|
setValue(newValue) {
|
|
301
302
|
this._value = newValue;
|
|
303
|
+
this._runEffects(newValue);
|
|
304
|
+
}
|
|
305
|
+
addEffect(effect) {
|
|
306
|
+
this._effects.push(effect);
|
|
307
|
+
}
|
|
308
|
+
_runEffects(value) {
|
|
309
|
+
for (const effect of this._effects) {
|
|
310
|
+
effect(value);
|
|
311
|
+
}
|
|
302
312
|
}
|
|
303
313
|
}
|
|
304
|
-
function useState(initialValue = null, subscription) {
|
|
314
|
+
function useState(initialValue = null, subscription, effects = []) {
|
|
305
315
|
const state = new State(initialValue);
|
|
316
|
+
for (const effect of effects) {
|
|
317
|
+
state.addEffect(effect);
|
|
318
|
+
}
|
|
306
319
|
function getValue() {
|
|
307
320
|
return state.getValue();
|
|
308
321
|
}
|
|
@@ -1071,7 +1084,7 @@ function asyncShowErrorMessage(text, showRetryBtn, options) {
|
|
|
1071
1084
|
});
|
|
1072
1085
|
});
|
|
1073
1086
|
}
|
|
1074
|
-
function asyncOnLineShowErrorMessage(text, showRetryBtn) {
|
|
1087
|
+
function asyncOnLineShowErrorMessage(text, buttonText, showRetryBtn) {
|
|
1075
1088
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1076
1089
|
return new Promise((res, rej) => {
|
|
1077
1090
|
showErrorMessage(text, showRetryBtn, (_, tools) => {
|
|
@@ -1079,14 +1092,14 @@ function asyncOnLineShowErrorMessage(text, showRetryBtn) {
|
|
|
1079
1092
|
res(true);
|
|
1080
1093
|
tools === null || tools === void 0 ? void 0 : tools.hideErrorMessage();
|
|
1081
1094
|
}
|
|
1082
|
-
});
|
|
1095
|
+
}, buttonText);
|
|
1083
1096
|
});
|
|
1084
1097
|
});
|
|
1085
1098
|
}
|
|
1086
|
-
function checkOnlineStatus(msg) {
|
|
1099
|
+
function checkOnlineStatus(msg, buttonText) {
|
|
1087
1100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1088
1101
|
if (!window.navigator.onLine) {
|
|
1089
|
-
yield asyncOnLineShowErrorMessage(msg, true);
|
|
1102
|
+
yield asyncOnLineShowErrorMessage(msg, buttonText, true);
|
|
1090
1103
|
}
|
|
1091
1104
|
});
|
|
1092
1105
|
}
|
|
@@ -1239,22 +1252,27 @@ function switchCamera(deviceId, video) {
|
|
|
1239
1252
|
}
|
|
1240
1253
|
const constraints = {
|
|
1241
1254
|
video: {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
width: {
|
|
1245
|
-
min: 1280,
|
|
1246
|
-
ideal: 1920,
|
|
1247
|
-
max: 1920
|
|
1248
|
-
},
|
|
1249
|
-
height: {
|
|
1250
|
-
min: 720,
|
|
1251
|
-
ideal: 1080,
|
|
1252
|
-
max: 1080
|
|
1253
|
-
},
|
|
1255
|
+
width: {},
|
|
1256
|
+
height: {},
|
|
1254
1257
|
focusMode: 'auto',
|
|
1255
1258
|
deviceId: deviceId
|
|
1256
1259
|
}
|
|
1257
1260
|
};
|
|
1261
|
+
const constraint = localStorage.getItem('camera_constraint');
|
|
1262
|
+
if (!constraint) {
|
|
1263
|
+
// 推測依然需要使用 width & height 的限制條件,
|
|
1264
|
+
// 否則即使是高解析度相機,也有可能拿到低解析度的圖片。(待驗證)
|
|
1265
|
+
constraints.video.width = {
|
|
1266
|
+
min: 1280,
|
|
1267
|
+
ideal: 1920,
|
|
1268
|
+
max: 1920
|
|
1269
|
+
};
|
|
1270
|
+
constraints.video.height = {
|
|
1271
|
+
min: 720,
|
|
1272
|
+
ideal: 1080,
|
|
1273
|
+
max: 1080
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1258
1276
|
stream = yield navigator.mediaDevices.getUserMedia(constraints);
|
|
1259
1277
|
video.srcObject = stream;
|
|
1260
1278
|
yield video.play();
|
|
@@ -1269,7 +1287,6 @@ function switchCamera(deviceId, video) {
|
|
|
1269
1287
|
});
|
|
1270
1288
|
}
|
|
1271
1289
|
function _requestCamera(video, facingMode) {
|
|
1272
|
-
var _a;
|
|
1273
1290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1274
1291
|
if (!('mediaDevices' in navigator)) {
|
|
1275
1292
|
throw BROWSER_CAMERA_ERRORS.NOT_SUPPORT;
|
|
@@ -1288,7 +1305,7 @@ function _requestCamera(video, facingMode) {
|
|
|
1288
1305
|
// 輪詢取得攝影機 解析度等資訊
|
|
1289
1306
|
const videoDevices = (yield navigator.mediaDevices.enumerateDevices()).filter(device => device.kind === 'videoinput');
|
|
1290
1307
|
const deviceMetas = yield arrayFromAsync(asyncMap(device => __awaiter(this, void 0, void 0, function* () {
|
|
1291
|
-
var _b, _c, _d
|
|
1308
|
+
var _a, _b, _c, _d;
|
|
1292
1309
|
const stream = yield navigator.mediaDevices.getUserMedia({
|
|
1293
1310
|
video: {
|
|
1294
1311
|
deviceId: {
|
|
@@ -1296,10 +1313,10 @@ function _requestCamera(video, facingMode) {
|
|
|
1296
1313
|
}
|
|
1297
1314
|
}
|
|
1298
1315
|
});
|
|
1299
|
-
const track = (
|
|
1300
|
-
const capabilities = ((
|
|
1301
|
-
const widthMax = (
|
|
1302
|
-
const heightMax = (
|
|
1316
|
+
const track = (_a = stream.getVideoTracks()) === null || _a === void 0 ? void 0 : _a[0];
|
|
1317
|
+
const capabilities = ((_b = track === null || track === void 0 ? void 0 : track.getCapabilities) !== null && _b !== void 0 ? _b : () => undefined).bind(track)(); // firefox 沒有 getCapabilities 可以用。
|
|
1318
|
+
const widthMax = (_c = capabilities === null || capabilities === void 0 ? void 0 : capabilities.width) === null || _c === void 0 ? void 0 : _c.max;
|
|
1319
|
+
const heightMax = (_d = capabilities === null || capabilities === void 0 ? void 0 : capabilities.height) === null || _d === void 0 ? void 0 : _d.max;
|
|
1303
1320
|
const resolution = widthMax && heightMax ? widthMax * heightMax : 0;
|
|
1304
1321
|
const facingModeFromLabel = inferFacingModeFromLabel(device === null || device === void 0 ? void 0 : device.label);
|
|
1305
1322
|
const facingModeFromapabilities = inferFacingModeFromCapabilities(capabilities);
|
|
@@ -1318,7 +1335,7 @@ function _requestCamera(video, facingMode) {
|
|
|
1318
1335
|
capabilities
|
|
1319
1336
|
};
|
|
1320
1337
|
}), videoDevices));
|
|
1321
|
-
const
|
|
1338
|
+
const devices = deviceMetas.sort((a, b) => {
|
|
1322
1339
|
// 若是 Samsung 手機且模式為後鏡頭,則優先使用Label為 camera2 0 的鏡頭
|
|
1323
1340
|
let samsungCondition = 0;
|
|
1324
1341
|
if (isSamsung && facingMode === 'back') {
|
|
@@ -1337,7 +1354,9 @@ function _requestCamera(video, facingMode) {
|
|
|
1337
1354
|
}
|
|
1338
1355
|
const resolutionCondition = b.meta.resolution - a.meta.resolution;
|
|
1339
1356
|
return samsungCondition || cameraFacingCondition || resolutionCondition;
|
|
1340
|
-
})
|
|
1357
|
+
});
|
|
1358
|
+
const cameraIndex = window.localStorage.getItem('camera') || '0';
|
|
1359
|
+
const firstDevice = devices[parseInt(cameraIndex, 10)];
|
|
1341
1360
|
const deviceId = firstDevice.device.deviceId;
|
|
1342
1361
|
if (!deviceId) {
|
|
1343
1362
|
throw BROWSER_CAMERA_ERRORS.NO_CAMERA;
|
|
@@ -1372,19 +1391,19 @@ function requestCamera({
|
|
|
1372
1391
|
return yield _requestCamera(video, facingMode);
|
|
1373
1392
|
} catch (error) {
|
|
1374
1393
|
if (error === BROWSER_CAMERA_ERRORS.NOT_SUPPORT) {
|
|
1375
|
-
showMessage(translate('
|
|
1394
|
+
showMessage(translate('sdk.general.error.cameraNotFound.title'));
|
|
1376
1395
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, 'Browser not support WebRTC, or https required.');
|
|
1377
1396
|
}
|
|
1378
1397
|
if (error === BROWSER_CAMERA_ERRORS.NO_CAMERA) {
|
|
1379
|
-
showMessage(translate('
|
|
1398
|
+
showMessage(translate('sdk.general.error.cameraNotFound.content'));
|
|
1380
1399
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, 'camera not found');
|
|
1381
1400
|
}
|
|
1382
1401
|
if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_ALLOWED_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_FOUND_ERROR) {
|
|
1383
|
-
showMessage(translate('
|
|
1402
|
+
showMessage(translate('sdk.general.error.cameraNotFound.content'));
|
|
1384
1403
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1385
1404
|
}
|
|
1386
1405
|
if ((error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.NOT_READABLE_ERROR || (error === null || error === void 0 ? void 0 : error.name) === BROWSER_CAMERA_ERRORS.ABORT_ERROR) {
|
|
1387
|
-
showMessage(translate('
|
|
1406
|
+
showMessage(translate('sdk.general.error.cameraNotFound.content'));
|
|
1388
1407
|
/* NOT_READABLE_ERROR,ABORT_ERROR 這兩個錯誤是用戶授權了,但在呼叫裝置時出現錯誤,
|
|
1389
1408
|
* 常發生在APP webview ,例如: 手機開啟 web 使用 sdk,儘管在 webview 層級上授權了,但手機在設定層級沒有授權 app 使用相機,會導致此問題。
|
|
1390
1409
|
* 但每個 android 手機的在這方面的實作不一致,不是每個手機在這種情況下都會拋出錯誤。
|
|
@@ -1393,7 +1412,7 @@ function requestCamera({
|
|
|
1393
1412
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1394
1413
|
}
|
|
1395
1414
|
if (isOverconstrainedError(error)) {
|
|
1396
|
-
showMessage(translate('
|
|
1415
|
+
showMessage(translate('sdk.general.error.cameraLowResolution'));
|
|
1397
1416
|
throw new AuthmeError(ErrorCode.CAMERA_NOT_SUPPORT, error);
|
|
1398
1417
|
}
|
|
1399
1418
|
throw error;
|
|
@@ -2415,8 +2434,8 @@ window.ononline = () => {
|
|
|
2415
2434
|
};
|
|
2416
2435
|
|
|
2417
2436
|
var name = "authme/sdk";
|
|
2418
|
-
var version$1 = "2.
|
|
2419
|
-
var date = "
|
|
2437
|
+
var version$1 = "2.7.0";
|
|
2438
|
+
var date = "2024-05-30T14:54:23+0000";
|
|
2420
2439
|
var packageInfo = {
|
|
2421
2440
|
name: name,
|
|
2422
2441
|
version: version$1,
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BehaviorSubject } from 'rxjs';
|
|
2
2
|
declare type StatePair<T> = [() => T, (value: T) => void];
|
|
3
|
-
export declare function useState<T = any>(initialValue?: T, subscription?: BehaviorSubject<T>): StatePair<T>;
|
|
3
|
+
export declare function useState<T = any>(initialValue?: T, subscription?: BehaviorSubject<T>, effects?: Array<(v: T) => void>): StatePair<T>;
|
|
4
4
|
export {};
|
package/src/ui/camera.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface DeviceMeta {
|
|
|
9
9
|
};
|
|
10
10
|
capabilities: MediaTrackCapabilities;
|
|
11
11
|
}
|
|
12
|
-
declare type FacingMode = 'front' | 'back';
|
|
12
|
+
export declare type FacingMode = 'front' | 'back';
|
|
13
13
|
interface RequestCamersResult {
|
|
14
14
|
facingMode: FacingMode;
|
|
15
15
|
deviceMetas: DeviceMeta[];
|
|
@@ -11,5 +11,5 @@ export declare function asyncShowErrorMessage(text: string, showRetryBtn?: boole
|
|
|
11
11
|
titleText?: string;
|
|
12
12
|
showErrorMessageHandler?: ShowErrorMessageHandler;
|
|
13
13
|
}): Promise<boolean>;
|
|
14
|
-
export declare function asyncOnLineShowErrorMessage(text: string, showRetryBtn?: boolean): Promise<boolean>;
|
|
15
|
-
export declare function checkOnlineStatus(msg: string): Promise<void>;
|
|
14
|
+
export declare function asyncOnLineShowErrorMessage(text: string, buttonText: string, showRetryBtn?: boolean): Promise<boolean>;
|
|
15
|
+
export declare function checkOnlineStatus(msg: string, buttonText: string): Promise<void>;
|