@authme/core 2.4.11 → 2.7.1

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 CHANGED
@@ -48,15 +48,13 @@ function __awaiter(thisArg, _arguments, P, generator) {
48
48
  });
49
49
  }
50
50
 
51
- var name = "@authme/core";
52
- var version$1 = "2.4.11";
53
- var peerDependencies = {
54
- "core-js": "^3.6.0"
55
- };
51
+ var name = "authme/sdk";
52
+ var version$1 = "2.7.1";
53
+ var date = "2024-09-06T02:00:28+0000";
56
54
  var packageInfo = {
57
55
  name: name,
58
56
  version: version$1,
59
- peerDependencies: peerDependencies
57
+ date: date
60
58
  };
61
59
 
62
60
  var _a;
@@ -112,7 +110,7 @@ function sendRequest(url, method = 'GET', {
112
110
  // 可以透過代入 null 的方式來取消預設值。
113
111
  accessToken = util.Storage.getItem('token'),
114
112
  baseUrl = util.Storage.getItem('apiBaseUrl'),
115
- sdkInfo = [`sdk-version: ${version}`, util.getUserAgent()].join(';')
113
+ sdkInfo = [`sdk-version: ${version}`, `platform: ${navigator.platform}`].join(';')
116
114
  } = {}) {
117
115
  return __awaiter(this, void 0, void 0, function* () {
118
116
  const requestLoggingFunction = getRequestLoggingFunc();
@@ -133,7 +131,7 @@ function sendRequest(url, method = 'GET', {
133
131
  try {
134
132
  const normalizedUrl = baseUrl ? new URL(url, baseUrl).toString() : url;
135
133
  resp = requestLoggingFunction ? yield requestLoggingFunction(() => fetch(normalizedUrl.toString(), options), {
136
- runFunction: 'api.sendRequest',
134
+ runFunction: util.RUN_FUNCTION_NAME.API_REQUEST,
137
135
  message: {
138
136
  url: normalizedUrl.toString(),
139
137
  options
@@ -218,9 +216,12 @@ class TranslateService {
218
216
  fetchSource(path) {
219
217
  return __awaiter(this, void 0, void 0, function* () {
220
218
  for (let i = 0; i < this.languageOptions.length; i++) {
221
- const resp = yield fetch(`${path}/${this.languageOptions[i]}.json`);
219
+ const [resp, oldKeyResp] = yield Promise.all([fetch(`${path}/${this.languageOptions[i]}.json`), fetch(`${path}/old/${this.languageOptions[i]}.json`)]);
220
+ if (oldKeyResp.ok && !localStorage.getItem('local')) {
221
+ this.originalDict[this.languageOptions[i]] = yield oldKeyResp.json();
222
+ }
222
223
  if (resp.ok) {
223
- this.originalDict[this.languageOptions[i]] = yield resp.json();
224
+ this.originalDict[this.languageOptions[i]] = Object.assign(Object.assign({}, this.originalDict[this.languageOptions[i]]), yield resp.json());
224
225
  }
225
226
  }
226
227
  return true;
@@ -251,7 +252,7 @@ class TranslateService {
251
252
  str = str.replace(new RegExp(`{{${key}}}`, 'g'), args[key].toString());
252
253
  });
253
254
  }
254
- return str.replace(/\\n/g, ' \n');
255
+ return str.replace(/\n$/, '').replace(/\n/g, '<br>');
255
256
  }
256
257
  getCurrentLang() {
257
258
  return this.currentLang;
@@ -396,6 +397,7 @@ exports.StatusEvent = void 0;
396
397
  StatusEvent["Done"] = "Done";
397
398
  StatusEvent["Passive"] = "Passive";
398
399
  StatusEvent["SelectCardTypeAndCountry"] = "SelectCardTypeAndCountry";
400
+ StatusEvent["CardThicknessFailed"] = "CardThicknessFailed";
399
401
  })(exports.StatusEvent || (exports.StatusEvent = {}));
400
402
  exports.StatusView = void 0;
401
403
  (function (StatusView) {
@@ -450,6 +452,7 @@ exports.StatusDescription = void 0;
450
452
  StatusDescription["UploadingStart"] = "UploadingStart";
451
453
  StatusDescription["UploadingEnd"] = "UploadingEnd";
452
454
  StatusDescription["Complete"] = "Complete";
455
+ StatusDescription["CardThicknessFailed"] = "CardThicknessFailed";
453
456
  })(exports.StatusDescription || (exports.StatusDescription = {}));
454
457
 
455
458
  class TrackingEvent {
@@ -586,10 +589,6 @@ Object.defineProperty(exports, 'ErrorCode', {
586
589
  enumerable: true,
587
590
  get: function () { return util.ErrorCode; }
588
591
  });
589
- Object.defineProperty(exports, 'debugLog', {
590
- enumerable: true,
591
- get: function () { return util.debugLog; }
592
- });
593
592
  exports.EventListenerService = EventListenerService;
594
593
  exports.TrackingEvent = TrackingEvent;
595
594
  exports.core = core;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Storage, getUserAgent, AuthmeError, ErrorCode, STORAGE_KEY, decodeToken, useState, getDeviceInfo, getSystemInfo } from '@authme/util';
2
- export { AuthmeError, ErrorCode, debugLog } from '@authme/util';
1
+ import { Storage, RUN_FUNCTION_NAME, AuthmeError, ErrorCode, STORAGE_KEY, decodeToken, useState, getDeviceInfo, getSystemInfo } from '@authme/util';
2
+ export { AuthmeError, ErrorCode } from '@authme/util';
3
3
  import 'core-js/modules/es.object.assign.js';
4
4
  import 'core-js/modules/es.regexp.to-string.js';
5
5
  import 'core-js/modules/es.array.iterator.js';
@@ -45,15 +45,13 @@ function __awaiter(thisArg, _arguments, P, generator) {
45
45
  });
46
46
  }
47
47
 
48
- var name = "@authme/core";
49
- var version$1 = "2.4.11";
50
- var peerDependencies = {
51
- "core-js": "^3.6.0"
52
- };
48
+ var name = "authme/sdk";
49
+ var version$1 = "2.7.1";
50
+ var date = "2024-09-06T02:00:28+0000";
53
51
  var packageInfo = {
54
52
  name: name,
55
53
  version: version$1,
56
- peerDependencies: peerDependencies
54
+ date: date
57
55
  };
58
56
 
59
57
  var _a;
@@ -109,7 +107,7 @@ function sendRequest(url, method = 'GET', {
109
107
  // 可以透過代入 null 的方式來取消預設值。
110
108
  accessToken = Storage.getItem('token'),
111
109
  baseUrl = Storage.getItem('apiBaseUrl'),
112
- sdkInfo = [`sdk-version: ${version}`, getUserAgent()].join(';')
110
+ sdkInfo = [`sdk-version: ${version}`, `platform: ${navigator.platform}`].join(';')
113
111
  } = {}) {
114
112
  return __awaiter(this, void 0, void 0, function* () {
115
113
  const requestLoggingFunction = getRequestLoggingFunc();
@@ -130,7 +128,7 @@ function sendRequest(url, method = 'GET', {
130
128
  try {
131
129
  const normalizedUrl = baseUrl ? new URL(url, baseUrl).toString() : url;
132
130
  resp = requestLoggingFunction ? yield requestLoggingFunction(() => fetch(normalizedUrl.toString(), options), {
133
- runFunction: 'api.sendRequest',
131
+ runFunction: RUN_FUNCTION_NAME.API_REQUEST,
134
132
  message: {
135
133
  url: normalizedUrl.toString(),
136
134
  options
@@ -215,9 +213,12 @@ class TranslateService {
215
213
  fetchSource(path) {
216
214
  return __awaiter(this, void 0, void 0, function* () {
217
215
  for (let i = 0; i < this.languageOptions.length; i++) {
218
- const resp = yield fetch(`${path}/${this.languageOptions[i]}.json`);
216
+ const [resp, oldKeyResp] = yield Promise.all([fetch(`${path}/${this.languageOptions[i]}.json`), fetch(`${path}/old/${this.languageOptions[i]}.json`)]);
217
+ if (oldKeyResp.ok && !localStorage.getItem('local')) {
218
+ this.originalDict[this.languageOptions[i]] = yield oldKeyResp.json();
219
+ }
219
220
  if (resp.ok) {
220
- this.originalDict[this.languageOptions[i]] = yield resp.json();
221
+ this.originalDict[this.languageOptions[i]] = Object.assign(Object.assign({}, this.originalDict[this.languageOptions[i]]), yield resp.json());
221
222
  }
222
223
  }
223
224
  return true;
@@ -248,7 +249,7 @@ class TranslateService {
248
249
  str = str.replace(new RegExp(`{{${key}}}`, 'g'), args[key].toString());
249
250
  });
250
251
  }
251
- return str.replace(/\\n/g, ' \n');
252
+ return str.replace(/\n$/, '').replace(/\n/g, '<br>');
252
253
  }
253
254
  getCurrentLang() {
254
255
  return this.currentLang;
@@ -393,6 +394,7 @@ var StatusEvent;
393
394
  StatusEvent["Done"] = "Done";
394
395
  StatusEvent["Passive"] = "Passive";
395
396
  StatusEvent["SelectCardTypeAndCountry"] = "SelectCardTypeAndCountry";
397
+ StatusEvent["CardThicknessFailed"] = "CardThicknessFailed";
396
398
  })(StatusEvent || (StatusEvent = {}));
397
399
  var StatusView;
398
400
  (function (StatusView) {
@@ -447,6 +449,7 @@ var StatusDescription;
447
449
  StatusDescription["UploadingStart"] = "UploadingStart";
448
450
  StatusDescription["UploadingEnd"] = "UploadingEnd";
449
451
  StatusDescription["Complete"] = "Complete";
452
+ StatusDescription["CardThicknessFailed"] = "CardThicknessFailed";
450
453
  })(StatusDescription || (StatusDescription = {}));
451
454
 
452
455
  class TrackingEvent {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@authme/core",
3
- "version": "2.4.11",
3
+ "version": "2.7.1",
4
4
  "peerDependencies": {
5
5
  "core-js": "^3.6.0",
6
- "@authme/util": "2.4.11",
6
+ "@authme/util": "2.7.1",
7
7
  "rxjs": "7.5.7",
8
8
  "uuid": "8.3.2"
9
9
  },
package/src/index.d.ts CHANGED
@@ -2,7 +2,6 @@ export * from './lib/core';
2
2
  export * from './lib/model';
3
3
  export * from './lib/data-access';
4
4
  export * from './lib/translate';
5
- export * from './lib/authme-log';
6
5
  export * from './lib/enum/language.enum';
7
6
  export * from './lib/features';
8
7
  export { version } from './lib/version';
@@ -26,7 +26,8 @@ export declare enum StatusEvent {
26
26
  Scale = "Scale",
27
27
  Done = "Done",
28
28
  Passive = "Passive",
29
- SelectCardTypeAndCountry = "SelectCardTypeAndCountry"
29
+ SelectCardTypeAndCountry = "SelectCardTypeAndCountry",
30
+ CardThicknessFailed = "CardThicknessFailed"
30
31
  }
31
32
  export declare enum StatusView {
32
33
  Info = "Info",
@@ -77,5 +78,6 @@ export declare enum StatusDescription {
77
78
  NeedOpenEyes = "NeedOpenEyes",
78
79
  UploadingStart = "UploadingStart",
79
80
  UploadingEnd = "UploadingEnd",
80
- Complete = "Complete"
81
+ Complete = "Complete",
82
+ CardThicknessFailed = "CardThicknessFailed"
81
83
  }
@@ -1 +0,0 @@
1
- export { debugLog } from '@authme/util';