@authme/core 2.2.0 → 2.2.1-rc.3
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/README.md +2 -2
- package/index.cjs +238 -0
- package/index.js +220 -0
- package/package.json +9 -9
- package/src/index.d.ts +6 -4
- package/src/lib/authme-log.d.ts +1 -0
- package/src/lib/core.d.ts +1 -2
- package/src/lib/data-access/http-client.d.ts +16 -16
- package/src/lib/data-access/index.d.ts +1 -1
- package/src/lib/enum/language.enum.d.ts +4 -4
- package/src/lib/model/authme-error.d.ts +1 -26
- package/src/lib/model/index.d.ts +1 -1
- package/src/lib/translate/index.d.ts +1 -1
- package/src/lib/translate/translate.d.ts +16 -15
- package/src/lib/version.d.ts +1 -0
- package/CHANGELOG.md +0 -151
- package/src/index.js +0 -8
- package/src/index.js.map +0 -1
- package/src/lib/core.js +0 -14
- package/src/lib/core.js.map +0 -1
- package/src/lib/data-access/http-client.js +0 -115
- package/src/lib/data-access/http-client.js.map +0 -1
- package/src/lib/data-access/index.js +0 -5
- package/src/lib/data-access/index.js.map +0 -1
- package/src/lib/enum/language.enum.js +0 -9
- package/src/lib/enum/language.enum.js.map +0 -1
- package/src/lib/model/authme-error.js +0 -48
- package/src/lib/model/authme-error.js.map +0 -1
- package/src/lib/model/index.js +0 -5
- package/src/lib/model/index.js.map +0 -1
- package/src/lib/model/init-config.interface.d.ts +0 -0
- package/src/lib/model/init-config.interface.js +0 -1
- package/src/lib/model/init-config.interface.js.map +0 -1
- package/src/lib/translate/index.js +0 -5
- package/src/lib/translate/index.js.map +0 -1
- package/src/lib/translate/translate.js +0 -55
- package/src/lib/translate/translate.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# shared-util
|
|
2
2
|
|
|
3
3
|
This library was generated with [Nx](https://nx.dev).
|
|
4
4
|
|
|
5
5
|
## Running unit tests
|
|
6
6
|
|
|
7
|
-
Run `nx test
|
|
7
|
+
Run `nx test shared-util` to execute the unit tests via [Jest](https://jestjs.io).
|
package/index.cjs
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var util = require('@authme/util');
|
|
6
|
+
require('core-js/modules/es.object.assign.js');
|
|
7
|
+
require('core-js/modules/es.regexp.to-string.js');
|
|
8
|
+
require('core-js/modules/es.array.iterator.js');
|
|
9
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
10
|
+
require('core-js/modules/web.url.js');
|
|
11
|
+
require('core-js/modules/web.url-search-params.js');
|
|
12
|
+
require('core-js/modules/es.promise.js');
|
|
13
|
+
require('core-js/modules/es.symbol.description.js');
|
|
14
|
+
require('core-js/modules/es.regexp.exec.js');
|
|
15
|
+
require('core-js/modules/es.string.replace.js');
|
|
16
|
+
require('core-js/modules/es.regexp.constructor.js');
|
|
17
|
+
|
|
18
|
+
function core() {
|
|
19
|
+
return 'core';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/******************************************************************************
|
|
23
|
+
Copyright (c) Microsoft Corporation.
|
|
24
|
+
|
|
25
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
26
|
+
purpose with or without fee is hereby granted.
|
|
27
|
+
|
|
28
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
29
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
30
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
31
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
32
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
33
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
34
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
35
|
+
***************************************************************************** */
|
|
36
|
+
|
|
37
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
38
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
39
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
40
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
41
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
42
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
43
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var name = "@authme/core";
|
|
48
|
+
var version$1 = "2.2.1-rc.3";
|
|
49
|
+
var peerDependencies = {
|
|
50
|
+
"core-js": "^3.6.0"
|
|
51
|
+
};
|
|
52
|
+
var packageInfo = {
|
|
53
|
+
name: name,
|
|
54
|
+
version: version$1,
|
|
55
|
+
peerDependencies: peerDependencies
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
var _a;
|
|
59
|
+
var _b, _c;
|
|
60
|
+
const version = packageInfo.version;
|
|
61
|
+
(_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
|
|
62
|
+
window[Symbol.for('authme-sdk')][packageInfo.name] = version;
|
|
63
|
+
|
|
64
|
+
function tryLoadAndParseJsonAsync(response) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
try {
|
|
67
|
+
return [undefined, yield response.json()];
|
|
68
|
+
} catch (error) {
|
|
69
|
+
return [error, undefined];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function tryLoadAndParseTextAsync(response) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
try {
|
|
76
|
+
return [undefined, yield response.text()];
|
|
77
|
+
} catch (error) {
|
|
78
|
+
return [error, undefined];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function tryLoadArrayBufferAsync(response) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
try {
|
|
85
|
+
return [undefined, yield response.arrayBuffer()];
|
|
86
|
+
} catch (error) {
|
|
87
|
+
return [error, undefined];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function sendRequest(url, method = 'GET', {
|
|
92
|
+
body = undefined,
|
|
93
|
+
contentType = 'application/json',
|
|
94
|
+
expectedResponseContentTypes = null,
|
|
95
|
+
// 可以透過代入 null 的方式來取消預設值。
|
|
96
|
+
accessToken = util.Storage.getItem('token'),
|
|
97
|
+
baseUrl = util.Storage.getItem('apiBaseUrl'),
|
|
98
|
+
sdkInfo = [`sdk-version: ${version}`, util.getUserAgent()].join(';')
|
|
99
|
+
} = {}) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const options = Object.assign(Object.assign({
|
|
102
|
+
method
|
|
103
|
+
}, typeof body !== undefined ? {
|
|
104
|
+
body: body
|
|
105
|
+
} : {}), {
|
|
106
|
+
headers: Object.assign(Object.assign(Object.assign({}, accessToken ? {
|
|
107
|
+
Authorization: 'Bearer ' + accessToken
|
|
108
|
+
} : {}), typeof body !== 'undefined' && contentType !== 'multipart/form-data' ? {
|
|
109
|
+
'Content-Type': contentType
|
|
110
|
+
} : {}), sdkInfo ? {
|
|
111
|
+
'sdk-info': sdkInfo
|
|
112
|
+
} : {})
|
|
113
|
+
});
|
|
114
|
+
let resp;
|
|
115
|
+
try {
|
|
116
|
+
const normalizedUrl = baseUrl ? new URL(url, baseUrl).toString() : url;
|
|
117
|
+
resp = yield fetch(normalizedUrl.toString(), options);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
throw new util.AuthmeError(util.ErrorCode.NETWORK_ERROR, error);
|
|
120
|
+
}
|
|
121
|
+
const responseContentType = resp.headers.has('content-type') ? resp.headers.get('content-type') : undefined;
|
|
122
|
+
const errorMessages = [];
|
|
123
|
+
let parsedError;
|
|
124
|
+
let responseContent;
|
|
125
|
+
if (!responseContentType) {
|
|
126
|
+
[parsedError, responseContent] = [undefined, undefined];
|
|
127
|
+
} else if (responseContentType.indexOf('application/json') >= 0) {
|
|
128
|
+
[parsedError, responseContent] = yield tryLoadAndParseJsonAsync(resp);
|
|
129
|
+
} else if (responseContentType.indexOf('text/json') >= 0) {
|
|
130
|
+
[parsedError, responseContent] = yield tryLoadAndParseJsonAsync(resp);
|
|
131
|
+
} else if (responseContentType.indexOf('text/') >= 0) {
|
|
132
|
+
[parsedError, responseContent] = yield tryLoadAndParseTextAsync(resp);
|
|
133
|
+
} else if (responseContentType.indexOf('application/javascript') >= 0) {
|
|
134
|
+
[parsedError, responseContent] = yield tryLoadAndParseTextAsync(resp);
|
|
135
|
+
} else {
|
|
136
|
+
[parsedError, responseContent] = yield tryLoadArrayBufferAsync(resp);
|
|
137
|
+
}
|
|
138
|
+
if (!resp.ok) {
|
|
139
|
+
errorMessages.push('status code not in the range 200-299');
|
|
140
|
+
}
|
|
141
|
+
if (parsedError) {
|
|
142
|
+
errorMessages.push('parsedError when load/parse response');
|
|
143
|
+
}
|
|
144
|
+
if (expectedResponseContentTypes) {
|
|
145
|
+
if (!responseContentType || expectedResponseContentTypes.every(v => responseContentType.indexOf(v) < 0)) {
|
|
146
|
+
errorMessages.push(`responseContentType: expected value = ${expectedResponseContentTypes}` + `, but actual value = ${responseContentType}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (errorMessages.length !== 0) {
|
|
150
|
+
throw new util.AuthmeError(util.ErrorCode.HTTP_ERROR_RESPONSE, {
|
|
151
|
+
errorMessages,
|
|
152
|
+
meta: {
|
|
153
|
+
status: resp.status,
|
|
154
|
+
ok: resp.ok,
|
|
155
|
+
url,
|
|
156
|
+
responseContentType,
|
|
157
|
+
responseContent,
|
|
158
|
+
parsedError
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
return responseContent;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var AuthmeLanguage;
|
|
167
|
+
(function (AuthmeLanguage) {
|
|
168
|
+
AuthmeLanguage["zh-TW"] = "zh_Hant_TW";
|
|
169
|
+
AuthmeLanguage["en-US"] = "en_US";
|
|
170
|
+
})(AuthmeLanguage || (AuthmeLanguage = {}));
|
|
171
|
+
|
|
172
|
+
class TranslateService {
|
|
173
|
+
constructor() {
|
|
174
|
+
this.originalDict = {};
|
|
175
|
+
this.customDict = {};
|
|
176
|
+
this.languageOptions = [AuthmeLanguage['zh-TW'], AuthmeLanguage['en-US']];
|
|
177
|
+
this.currentLang = AuthmeLanguage['zh-TW'];
|
|
178
|
+
}
|
|
179
|
+
fetchSource(path) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
for (let i = 0; i < this.languageOptions.length; i++) {
|
|
182
|
+
const resp = yield fetch(`${path}/${this.languageOptions[i]}.json`);
|
|
183
|
+
if (resp.ok) {
|
|
184
|
+
this.originalDict[this.languageOptions[i]] = yield resp.json();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
extendSource(path, lang) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
const resp = yield fetch(`${path}`);
|
|
193
|
+
if (resp.ok) {
|
|
194
|
+
this.customDict[lang] = yield resp.json();
|
|
195
|
+
}
|
|
196
|
+
return true;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
setLang(lang) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
this.currentLang = lang;
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
translate(key, args = {}) {
|
|
205
|
+
var _a, _b, _c, _d;
|
|
206
|
+
let str = (_d = (_b = (_a = this.customDict[this.currentLang]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : (_c = this.originalDict[this.currentLang]) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : key;
|
|
207
|
+
if (Object.keys(args).length > 0) {
|
|
208
|
+
Object.keys(args).forEach(key => {
|
|
209
|
+
str = str.replace(new RegExp(`{{${key}}}`, 'g'), args[key].toString());
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return str;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
TranslateService.instance = null;
|
|
216
|
+
function getTranslateInstance() {
|
|
217
|
+
if (!TranslateService.instance) {
|
|
218
|
+
TranslateService.instance = new TranslateService();
|
|
219
|
+
}
|
|
220
|
+
return TranslateService.instance;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
Object.defineProperty(exports, 'AuthmeError', {
|
|
224
|
+
enumerable: true,
|
|
225
|
+
get: function () { return util.AuthmeError; }
|
|
226
|
+
});
|
|
227
|
+
Object.defineProperty(exports, 'ErrorCode', {
|
|
228
|
+
enumerable: true,
|
|
229
|
+
get: function () { return util.ErrorCode; }
|
|
230
|
+
});
|
|
231
|
+
Object.defineProperty(exports, 'debugLog', {
|
|
232
|
+
enumerable: true,
|
|
233
|
+
get: function () { return util.debugLog; }
|
|
234
|
+
});
|
|
235
|
+
exports.core = core;
|
|
236
|
+
exports.getTranslateInstance = getTranslateInstance;
|
|
237
|
+
exports.sendRequest = sendRequest;
|
|
238
|
+
exports.version = version;
|
package/index.js
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { Storage, getUserAgent, AuthmeError, ErrorCode } from '@authme/util';
|
|
2
|
+
export { AuthmeError, ErrorCode, debugLog } from '@authme/util';
|
|
3
|
+
import 'core-js/modules/es.object.assign.js';
|
|
4
|
+
import 'core-js/modules/es.regexp.to-string.js';
|
|
5
|
+
import 'core-js/modules/es.array.iterator.js';
|
|
6
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
7
|
+
import 'core-js/modules/web.url.js';
|
|
8
|
+
import 'core-js/modules/web.url-search-params.js';
|
|
9
|
+
import 'core-js/modules/es.promise.js';
|
|
10
|
+
import 'core-js/modules/es.symbol.description.js';
|
|
11
|
+
import 'core-js/modules/es.regexp.exec.js';
|
|
12
|
+
import 'core-js/modules/es.string.replace.js';
|
|
13
|
+
import 'core-js/modules/es.regexp.constructor.js';
|
|
14
|
+
|
|
15
|
+
function core() {
|
|
16
|
+
return 'core';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/******************************************************************************
|
|
20
|
+
Copyright (c) Microsoft Corporation.
|
|
21
|
+
|
|
22
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
23
|
+
purpose with or without fee is hereby granted.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
26
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
27
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
28
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
29
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
30
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
31
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
32
|
+
***************************************************************************** */
|
|
33
|
+
|
|
34
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
35
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
36
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
37
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
38
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
39
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
40
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var name = "@authme/core";
|
|
45
|
+
var version$1 = "2.2.1-rc.3";
|
|
46
|
+
var peerDependencies = {
|
|
47
|
+
"core-js": "^3.6.0"
|
|
48
|
+
};
|
|
49
|
+
var packageInfo = {
|
|
50
|
+
name: name,
|
|
51
|
+
version: version$1,
|
|
52
|
+
peerDependencies: peerDependencies
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var _a;
|
|
56
|
+
var _b, _c;
|
|
57
|
+
const version = packageInfo.version;
|
|
58
|
+
(_a = (_b = window)[_c = Symbol.for('authme-sdk')]) !== null && _a !== void 0 ? _a : _b[_c] = {};
|
|
59
|
+
window[Symbol.for('authme-sdk')][packageInfo.name] = version;
|
|
60
|
+
|
|
61
|
+
function tryLoadAndParseJsonAsync(response) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
try {
|
|
64
|
+
return [undefined, yield response.json()];
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return [error, undefined];
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function tryLoadAndParseTextAsync(response) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
try {
|
|
73
|
+
return [undefined, yield response.text()];
|
|
74
|
+
} catch (error) {
|
|
75
|
+
return [error, undefined];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function tryLoadArrayBufferAsync(response) {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
try {
|
|
82
|
+
return [undefined, yield response.arrayBuffer()];
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return [error, undefined];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function sendRequest(url, method = 'GET', {
|
|
89
|
+
body = undefined,
|
|
90
|
+
contentType = 'application/json',
|
|
91
|
+
expectedResponseContentTypes = null,
|
|
92
|
+
// 可以透過代入 null 的方式來取消預設值。
|
|
93
|
+
accessToken = Storage.getItem('token'),
|
|
94
|
+
baseUrl = Storage.getItem('apiBaseUrl'),
|
|
95
|
+
sdkInfo = [`sdk-version: ${version}`, getUserAgent()].join(';')
|
|
96
|
+
} = {}) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const options = Object.assign(Object.assign({
|
|
99
|
+
method
|
|
100
|
+
}, typeof body !== undefined ? {
|
|
101
|
+
body: body
|
|
102
|
+
} : {}), {
|
|
103
|
+
headers: Object.assign(Object.assign(Object.assign({}, accessToken ? {
|
|
104
|
+
Authorization: 'Bearer ' + accessToken
|
|
105
|
+
} : {}), typeof body !== 'undefined' && contentType !== 'multipart/form-data' ? {
|
|
106
|
+
'Content-Type': contentType
|
|
107
|
+
} : {}), sdkInfo ? {
|
|
108
|
+
'sdk-info': sdkInfo
|
|
109
|
+
} : {})
|
|
110
|
+
});
|
|
111
|
+
let resp;
|
|
112
|
+
try {
|
|
113
|
+
const normalizedUrl = baseUrl ? new URL(url, baseUrl).toString() : url;
|
|
114
|
+
resp = yield fetch(normalizedUrl.toString(), options);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
throw new AuthmeError(ErrorCode.NETWORK_ERROR, error);
|
|
117
|
+
}
|
|
118
|
+
const responseContentType = resp.headers.has('content-type') ? resp.headers.get('content-type') : undefined;
|
|
119
|
+
const errorMessages = [];
|
|
120
|
+
let parsedError;
|
|
121
|
+
let responseContent;
|
|
122
|
+
if (!responseContentType) {
|
|
123
|
+
[parsedError, responseContent] = [undefined, undefined];
|
|
124
|
+
} else if (responseContentType.indexOf('application/json') >= 0) {
|
|
125
|
+
[parsedError, responseContent] = yield tryLoadAndParseJsonAsync(resp);
|
|
126
|
+
} else if (responseContentType.indexOf('text/json') >= 0) {
|
|
127
|
+
[parsedError, responseContent] = yield tryLoadAndParseJsonAsync(resp);
|
|
128
|
+
} else if (responseContentType.indexOf('text/') >= 0) {
|
|
129
|
+
[parsedError, responseContent] = yield tryLoadAndParseTextAsync(resp);
|
|
130
|
+
} else if (responseContentType.indexOf('application/javascript') >= 0) {
|
|
131
|
+
[parsedError, responseContent] = yield tryLoadAndParseTextAsync(resp);
|
|
132
|
+
} else {
|
|
133
|
+
[parsedError, responseContent] = yield tryLoadArrayBufferAsync(resp);
|
|
134
|
+
}
|
|
135
|
+
if (!resp.ok) {
|
|
136
|
+
errorMessages.push('status code not in the range 200-299');
|
|
137
|
+
}
|
|
138
|
+
if (parsedError) {
|
|
139
|
+
errorMessages.push('parsedError when load/parse response');
|
|
140
|
+
}
|
|
141
|
+
if (expectedResponseContentTypes) {
|
|
142
|
+
if (!responseContentType || expectedResponseContentTypes.every(v => responseContentType.indexOf(v) < 0)) {
|
|
143
|
+
errorMessages.push(`responseContentType: expected value = ${expectedResponseContentTypes}` + `, but actual value = ${responseContentType}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (errorMessages.length !== 0) {
|
|
147
|
+
throw new AuthmeError(ErrorCode.HTTP_ERROR_RESPONSE, {
|
|
148
|
+
errorMessages,
|
|
149
|
+
meta: {
|
|
150
|
+
status: resp.status,
|
|
151
|
+
ok: resp.ok,
|
|
152
|
+
url,
|
|
153
|
+
responseContentType,
|
|
154
|
+
responseContent,
|
|
155
|
+
parsedError
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return responseContent;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var AuthmeLanguage;
|
|
164
|
+
(function (AuthmeLanguage) {
|
|
165
|
+
AuthmeLanguage["zh-TW"] = "zh_Hant_TW";
|
|
166
|
+
AuthmeLanguage["en-US"] = "en_US";
|
|
167
|
+
})(AuthmeLanguage || (AuthmeLanguage = {}));
|
|
168
|
+
|
|
169
|
+
class TranslateService {
|
|
170
|
+
constructor() {
|
|
171
|
+
this.originalDict = {};
|
|
172
|
+
this.customDict = {};
|
|
173
|
+
this.languageOptions = [AuthmeLanguage['zh-TW'], AuthmeLanguage['en-US']];
|
|
174
|
+
this.currentLang = AuthmeLanguage['zh-TW'];
|
|
175
|
+
}
|
|
176
|
+
fetchSource(path) {
|
|
177
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
+
for (let i = 0; i < this.languageOptions.length; i++) {
|
|
179
|
+
const resp = yield fetch(`${path}/${this.languageOptions[i]}.json`);
|
|
180
|
+
if (resp.ok) {
|
|
181
|
+
this.originalDict[this.languageOptions[i]] = yield resp.json();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
extendSource(path, lang) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
const resp = yield fetch(`${path}`);
|
|
190
|
+
if (resp.ok) {
|
|
191
|
+
this.customDict[lang] = yield resp.json();
|
|
192
|
+
}
|
|
193
|
+
return true;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
setLang(lang) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
this.currentLang = lang;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
translate(key, args = {}) {
|
|
202
|
+
var _a, _b, _c, _d;
|
|
203
|
+
let str = (_d = (_b = (_a = this.customDict[this.currentLang]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : (_c = this.originalDict[this.currentLang]) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : key;
|
|
204
|
+
if (Object.keys(args).length > 0) {
|
|
205
|
+
Object.keys(args).forEach(key => {
|
|
206
|
+
str = str.replace(new RegExp(`{{${key}}}`, 'g'), args[key].toString());
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return str;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
TranslateService.instance = null;
|
|
213
|
+
function getTranslateInstance() {
|
|
214
|
+
if (!TranslateService.instance) {
|
|
215
|
+
TranslateService.instance = new TranslateService();
|
|
216
|
+
}
|
|
217
|
+
return TranslateService.instance;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export { core, getTranslateInstance, sendRequest, version };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authme/core",
|
|
3
|
-
"version": "2.2.
|
|
4
|
-
"main": "./src/index.js",
|
|
5
|
-
"typings": "./src/index.d.ts",
|
|
6
|
-
"dependencies": {},
|
|
3
|
+
"version": "2.2.1-rc.3",
|
|
7
4
|
"peerDependencies": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
"core-js": "^3.6.0",
|
|
6
|
+
"@authme/util": "2.2.1-rc.3"
|
|
7
|
+
},
|
|
8
|
+
"module": "./index.js",
|
|
9
|
+
"main": "./index.cjs",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"types": "./src/index.d.ts",
|
|
12
|
+
"dependencies": {}
|
|
13
13
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export * from './lib/core';
|
|
2
|
-
export * from './lib/model';
|
|
3
|
-
export * from './lib/data-access';
|
|
4
|
-
export * from './lib/translate';
|
|
1
|
+
export * from './lib/core';
|
|
2
|
+
export * from './lib/model';
|
|
3
|
+
export * from './lib/data-access';
|
|
4
|
+
export * from './lib/translate';
|
|
5
|
+
export * from './lib/authme-log';
|
|
6
|
+
export { version } from './lib/version';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { debugLog } from '@authme/util';
|
package/src/lib/core.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function core(): string;
|
|
2
|
-
export declare function debugLog(message?: any, ...others: any[]): void;
|
|
1
|
+
export declare function core(): string;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export interface RequestOptions {
|
|
2
|
-
header: {
|
|
3
|
-
[header: string]: string;
|
|
4
|
-
};
|
|
5
|
-
params: {
|
|
6
|
-
[param: string]: string;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
export declare function sendRequest<TResp = any>(url: string, method?: string, { body, contentType, expectedResponseContentTypes, accessToken, baseUrl, sdkInfo, }?: {
|
|
10
|
-
body?: unknown;
|
|
11
|
-
contentType?: string;
|
|
12
|
-
expectedResponseContentTypes?: string[];
|
|
13
|
-
accessToken?: string;
|
|
14
|
-
baseUrl?: string;
|
|
15
|
-
sdkInfo?: string;
|
|
16
|
-
}): Promise<TResp>;
|
|
1
|
+
export interface RequestOptions {
|
|
2
|
+
header: {
|
|
3
|
+
[header: string]: string;
|
|
4
|
+
};
|
|
5
|
+
params: {
|
|
6
|
+
[param: string]: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function sendRequest<TResp = any>(url: string, method?: string, { body, contentType, expectedResponseContentTypes, accessToken, baseUrl, sdkInfo, }?: {
|
|
10
|
+
body?: unknown;
|
|
11
|
+
contentType?: string;
|
|
12
|
+
expectedResponseContentTypes?: string[];
|
|
13
|
+
accessToken?: string;
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
sdkInfo?: string;
|
|
16
|
+
}): Promise<TResp>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './http-client';
|
|
1
|
+
export * from './http-client';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare enum AuthmeLanguage {
|
|
2
|
-
'zh-TW' = "zh_Hant_TW",
|
|
3
|
-
'en-US' = "en_US"
|
|
4
|
-
}
|
|
1
|
+
export declare enum AuthmeLanguage {
|
|
2
|
+
'zh-TW' = "zh_Hant_TW",
|
|
3
|
+
'en-US' = "en_US"
|
|
4
|
+
}
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
private _cause;
|
|
3
|
-
private _code;
|
|
4
|
-
constructor(code: ErrorCode, cause?: any);
|
|
5
|
-
get message(): string;
|
|
6
|
-
setCode(code: ErrorCode): void;
|
|
7
|
-
get code(): ErrorCode;
|
|
8
|
-
get cause(): any;
|
|
9
|
-
}
|
|
10
|
-
export declare enum ErrorCode {
|
|
11
|
-
BROWSER_NOT_SUPPORT = 100,
|
|
12
|
-
ENGINE_INIT_ERROR = 101,
|
|
13
|
-
ENGINE_MODULE_IS_INITIALIZING = 102,
|
|
14
|
-
ENGINE_MODULE_INIT_ERROR = 103,
|
|
15
|
-
RECOGNITION_NOT_AVAILABLE = 104,
|
|
16
|
-
RECOGNITION_ERROR = 105,
|
|
17
|
-
INVALID_AUTH_ERROR = 106,
|
|
18
|
-
LIVENESS_NOT_PASSED = 201,
|
|
19
|
-
ID_RECOGNITION_CONFIRM_INFO_ERROR = 301,
|
|
20
|
-
ANTI_FRAUD_TIMEOUT_ERROR = 401,
|
|
21
|
-
SDK_INTERNAL_ERROR = 900,
|
|
22
|
-
NETWORK_ERROR = 901,
|
|
23
|
-
HTTP_ERROR_RESPONSE = 902,
|
|
24
|
-
USER_CANCEL = 903,
|
|
25
|
-
CAMERA_NOT_SUPPORT = 904
|
|
26
|
-
}
|
|
1
|
+
export { AuthmeError, ErrorCode } from '@authme/util';
|
package/src/lib/model/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './authme-error';
|
|
1
|
+
export * from './authme-error';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './translate';
|
|
1
|
+
export * from './translate';
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { AuthmeLanguage } from '../enum/language.enum';
|
|
2
|
-
declare class TranslateService {
|
|
3
|
-
private
|
|
4
|
-
private
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { AuthmeLanguage } from '../enum/language.enum';
|
|
2
|
+
declare class TranslateService {
|
|
3
|
+
private originalDict;
|
|
4
|
+
private customDict;
|
|
5
|
+
private languageOptions;
|
|
6
|
+
private currentLang;
|
|
7
|
+
fetchSource(path: string): Promise<boolean>;
|
|
8
|
+
extendSource(path: string, lang: AuthmeLanguage): Promise<boolean>;
|
|
9
|
+
setLang(lang: AuthmeLanguage): Promise<void>;
|
|
10
|
+
translate(key: string, args?: {
|
|
11
|
+
[key: string]: string | number;
|
|
12
|
+
}): string;
|
|
13
|
+
static instance: TranslateService | null;
|
|
14
|
+
}
|
|
15
|
+
declare function getTranslateInstance(): TranslateService;
|
|
16
|
+
export { getTranslateInstance };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version: string;
|
package/CHANGELOG.md
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
|
-
|
|
5
|
-
## [2.2.0](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.13...v2.2.0) (2022-12-19)
|
|
6
|
-
|
|
7
|
-
## [2.2.0-rc.13](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.12...v2.2.0-rc.13) (2022-12-19)
|
|
8
|
-
|
|
9
|
-
## [2.2.0-rc.12](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.11...v2.2.0-rc.12) (2022-12-16)
|
|
10
|
-
|
|
11
|
-
## [2.2.0-rc.11](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.10...v2.2.0-rc.11) (2022-12-16)
|
|
12
|
-
|
|
13
|
-
## [2.2.0-rc.10](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.9...v2.2.0-rc.10) (2022-12-15)
|
|
14
|
-
|
|
15
|
-
## [2.2.0-rc.9](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.8...v2.2.0-rc.9) (2022-12-09)
|
|
16
|
-
|
|
17
|
-
### Bug Fixes
|
|
18
|
-
|
|
19
|
-
- http-client error message ([6be02fc](https://github.com/AuthMe01/web-client-sdk/commit/6be02fc6e6b9ae461e5c73b289bce58cfba5759b))
|
|
20
|
-
|
|
21
|
-
## [2.2.0-rc.8](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.7...v2.2.0-rc.8) (2022-12-07)
|
|
22
|
-
|
|
23
|
-
## [2.2.0-rc.7](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.6...v2.2.0-rc.7) (2022-12-07)
|
|
24
|
-
|
|
25
|
-
## [2.2.0-rc.6](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.5...v2.2.0-rc.6) (2022-12-05)
|
|
26
|
-
|
|
27
|
-
## [2.2.0-rc.5](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.4...v2.2.0-rc.5) (2022-12-03)
|
|
28
|
-
|
|
29
|
-
### Features
|
|
30
|
-
|
|
31
|
-
- strict error code & error handler ([b6267d5](https://github.com/AuthMe01/web-client-sdk/commit/b6267d57d0a6bf80ef9eddd12243da969b1ebb79))
|
|
32
|
-
|
|
33
|
-
## [2.2.0-rc.4](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.3...v2.2.0-rc.4) (2022-12-01)
|
|
34
|
-
|
|
35
|
-
## [2.2.0-rc.3](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.2...v2.2.0-rc.3) (2022-11-30)
|
|
36
|
-
|
|
37
|
-
## [2.2.0-rc.2](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.1...v2.2.0-rc.2) (2022-11-28)
|
|
38
|
-
|
|
39
|
-
## [2.2.0-rc.1](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.0...v2.2.0-rc.1) (2022-11-18)
|
|
40
|
-
|
|
41
|
-
## [2.2.0-rc.0](https://github.com/AuthMe01/web-client-sdk/compare/v2.1.1...v2.2.0-rc.0) (2022-11-11)
|
|
42
|
-
|
|
43
|
-
### Features
|
|
44
|
-
|
|
45
|
-
- PROD-1647 remove unused code ([2ae2a11](https://github.com/AuthMe01/web-client-sdk/commit/2ae2a11846fa2c733ae4c07d5e00c971270e648c))
|
|
46
|
-
- PROD-1660 Add i18n extend support ([15c8fd7](https://github.com/AuthMe01/web-client-sdk/commit/15c8fd77af1a645b77de93a891f7740edf4bdf6d))
|
|
47
|
-
|
|
48
|
-
## [2.1.2-rc.0](https://github.com/AuthMe01/web-client-sdk/compare/prod-2.1.1...prod-2.1.2-rc.0) (2022-09-15)
|
|
49
|
-
|
|
50
|
-
### Features
|
|
51
|
-
|
|
52
|
-
- PROD-1647 remove unused code ([2ae2a11](https://github.com/AuthMe01/web-client-sdk/commit/2ae2a11846fa2c733ae4c07d5e00c971270e648c))
|
|
53
|
-
- PROD-1660 Add i18n extend support ([15c8fd7](https://github.com/AuthMe01/web-client-sdk/commit/15c8fd77af1a645b77de93a891f7740edf4bdf6d))
|
|
54
|
-
|
|
55
|
-
## [2.1.1](https://github.com/AuthMe01/web-client-sdk/compare/prod-2.1.0...prod-2.1.1) (2022-09-08)
|
|
56
|
-
|
|
57
|
-
## 1.2.2 (2022-07-28)
|
|
58
|
-
|
|
59
|
-
### Bug Fixes
|
|
60
|
-
|
|
61
|
-
- PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
|
|
62
|
-
- PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
|
|
63
|
-
- PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
|
|
64
|
-
|
|
65
|
-
### Features
|
|
66
|
-
|
|
67
|
-
- PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
|
|
68
|
-
- PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
|
|
69
|
-
- PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
|
|
70
|
-
- PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
|
|
71
|
-
- show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
|
|
72
|
-
|
|
73
|
-
## 1.2.1 (2022-07-28)
|
|
74
|
-
|
|
75
|
-
### Bug Fixes
|
|
76
|
-
|
|
77
|
-
- PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
|
|
78
|
-
- PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
|
|
79
|
-
- PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
|
|
80
|
-
|
|
81
|
-
### Features
|
|
82
|
-
|
|
83
|
-
- PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
|
|
84
|
-
- PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
|
|
85
|
-
- PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
|
|
86
|
-
- PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
|
|
87
|
-
- show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
|
|
88
|
-
|
|
89
|
-
# 1.2.0 (2022-07-25)
|
|
90
|
-
|
|
91
|
-
### Bug Fixes
|
|
92
|
-
|
|
93
|
-
- PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
|
|
94
|
-
- PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
|
|
95
|
-
- PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
|
|
96
|
-
|
|
97
|
-
### Features
|
|
98
|
-
|
|
99
|
-
- PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
|
|
100
|
-
- PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
|
|
101
|
-
- PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
|
|
102
|
-
- PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
|
|
103
|
-
- show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
|
|
104
|
-
|
|
105
|
-
## 1.1.1 (2022-07-07)
|
|
106
|
-
|
|
107
|
-
### Bug Fixes
|
|
108
|
-
|
|
109
|
-
- PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
|
|
110
|
-
- PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
|
|
111
|
-
- PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
|
|
112
|
-
|
|
113
|
-
### Features
|
|
114
|
-
|
|
115
|
-
- PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
|
|
116
|
-
- PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
|
|
117
|
-
- PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
|
|
118
|
-
- PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
|
|
119
|
-
- show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
|
|
120
|
-
|
|
121
|
-
# 1.1.0 (2022-07-06)
|
|
122
|
-
|
|
123
|
-
### Bug Fixes
|
|
124
|
-
|
|
125
|
-
- PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
|
|
126
|
-
- PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
|
|
127
|
-
- PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
|
|
128
|
-
|
|
129
|
-
### Features
|
|
130
|
-
|
|
131
|
-
- PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
|
|
132
|
-
- PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
|
|
133
|
-
- PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
|
|
134
|
-
- PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
|
|
135
|
-
- show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
|
|
136
|
-
|
|
137
|
-
# 1.0.0 (2022-05-30)
|
|
138
|
-
|
|
139
|
-
### Bug Fixes
|
|
140
|
-
|
|
141
|
-
- PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
|
|
142
|
-
- PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
|
|
143
|
-
- PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
|
|
144
|
-
|
|
145
|
-
### Features
|
|
146
|
-
|
|
147
|
-
- PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
|
|
148
|
-
- PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
|
|
149
|
-
- PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
|
|
150
|
-
- PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
|
|
151
|
-
- show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
|
package/src/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./lib/core"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./lib/model"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./lib/data-access"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./lib/translate"), exports);
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/core/src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,sDAA4B;AAC5B,4DAAkC;AAClC,0DAAgC"}
|
package/src/lib/core.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debugLog = exports.core = void 0;
|
|
4
|
-
function core() {
|
|
5
|
-
return 'core';
|
|
6
|
-
}
|
|
7
|
-
exports.core = core;
|
|
8
|
-
function debugLog(message, ...others) {
|
|
9
|
-
if (new URLSearchParams(location.search).get('authme-debug') === 'true') {
|
|
10
|
-
console.log(message, ...others);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.debugLog = debugLog;
|
|
14
|
-
//# sourceMappingURL=core.js.map
|
package/src/lib/core.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/core.ts"],"names":[],"mappings":";;;AAAA,SAAgB,IAAI;IAClB,OAAO,MAAM,CAAC;AAChB,CAAC;AAFD,oBAEC;AAED,SAAgB,QAAQ,CAAC,OAAa,EAAE,GAAG,MAAa;IACtD,IAAI,IAAI,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,MAAM,EAAE;QACvE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;KACjC;AACH,CAAC;AAJD,4BAIC"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendRequest = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const util_1 = require("@authme/util");
|
|
6
|
-
const model_1 = require("../model");
|
|
7
|
-
function tryLoadAndParseJsonAsync(response) {
|
|
8
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
try {
|
|
10
|
-
return [undefined, yield response.json()];
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
return [error, undefined];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
function tryLoadAndParseTextAsync(response) {
|
|
18
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
try {
|
|
20
|
-
return [undefined, yield response.text()];
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
return [error, undefined];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
function tryLoadArrayBufferAsync(response) {
|
|
28
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
try {
|
|
30
|
-
return [undefined, yield response.arrayBuffer()];
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
return [error, undefined];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function sendRequest(url, method = 'GET', { body = undefined, contentType = 'application/json', expectedResponseContentTypes = null,
|
|
38
|
-
// 可以透過代入 null 的方式來取消預設值。
|
|
39
|
-
accessToken = util_1.Storage.getItem('token'), baseUrl = util_1.Storage.getItem('apiBaseUrl'), sdkInfo = [
|
|
40
|
-
`sdk-version: ${util_1.Storage.getItem('SDKVersion')}`,
|
|
41
|
-
(0, util_1.getUserAgent)(),
|
|
42
|
-
].join(';'), } = {}) {
|
|
43
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const options = Object.assign(Object.assign({ method }, (typeof body !== undefined ? { body: body } : {})), { headers: Object.assign(Object.assign(Object.assign({}, (accessToken
|
|
45
|
-
? {
|
|
46
|
-
Authorization: 'Bearer ' + accessToken,
|
|
47
|
-
}
|
|
48
|
-
: {})), (typeof body !== 'undefined' && contentType !== 'multipart/form-data'
|
|
49
|
-
? {
|
|
50
|
-
'Content-Type': contentType,
|
|
51
|
-
}
|
|
52
|
-
: {})), (sdkInfo ? { 'sdk-info': sdkInfo } : {})) });
|
|
53
|
-
let resp;
|
|
54
|
-
try {
|
|
55
|
-
const normalizedUrl = baseUrl ? new URL(url, baseUrl).toString() : url;
|
|
56
|
-
resp = yield fetch(normalizedUrl.toString(), options);
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
throw new model_1.AuthmeError(model_1.ErrorCode.NETWORK_ERROR, error);
|
|
60
|
-
}
|
|
61
|
-
const responseContentType = resp.headers.has('content-type')
|
|
62
|
-
? resp.headers.get('content-type')
|
|
63
|
-
: undefined;
|
|
64
|
-
const errorMessages = [];
|
|
65
|
-
let parsedError;
|
|
66
|
-
let responseContent;
|
|
67
|
-
if (!responseContentType) {
|
|
68
|
-
[parsedError, responseContent] = [undefined, undefined];
|
|
69
|
-
}
|
|
70
|
-
else if (responseContentType.indexOf('application/json') >= 0) {
|
|
71
|
-
[parsedError, responseContent] = yield tryLoadAndParseJsonAsync(resp);
|
|
72
|
-
}
|
|
73
|
-
else if (responseContentType.indexOf('text/json') >= 0) {
|
|
74
|
-
[parsedError, responseContent] = yield tryLoadAndParseJsonAsync(resp);
|
|
75
|
-
}
|
|
76
|
-
else if (responseContentType.indexOf('text/') >= 0) {
|
|
77
|
-
[parsedError, responseContent] = yield tryLoadAndParseTextAsync(resp);
|
|
78
|
-
}
|
|
79
|
-
else if (responseContentType.indexOf('application/javascript') >= 0) {
|
|
80
|
-
[parsedError, responseContent] = yield tryLoadAndParseTextAsync(resp);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
[parsedError, responseContent] = yield tryLoadArrayBufferAsync(resp);
|
|
84
|
-
}
|
|
85
|
-
if (!resp.ok) {
|
|
86
|
-
errorMessages.push('status code not in the range 200-299');
|
|
87
|
-
}
|
|
88
|
-
if (parsedError) {
|
|
89
|
-
errorMessages.push('parsedError when load/parse response');
|
|
90
|
-
}
|
|
91
|
-
if (expectedResponseContentTypes) {
|
|
92
|
-
if (!responseContentType ||
|
|
93
|
-
expectedResponseContentTypes.every((v) => responseContentType.indexOf(v) < 0)) {
|
|
94
|
-
errorMessages.push(`responseContentType: expected value = ${expectedResponseContentTypes}` +
|
|
95
|
-
`, but actual value = ${responseContentType}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (errorMessages.length !== 0) {
|
|
99
|
-
throw new model_1.AuthmeError(model_1.ErrorCode.HTTP_ERROR_RESPONSE, {
|
|
100
|
-
errorMessages,
|
|
101
|
-
meta: {
|
|
102
|
-
status: resp.status,
|
|
103
|
-
ok: resp.ok,
|
|
104
|
-
url,
|
|
105
|
-
responseContentType,
|
|
106
|
-
responseContent,
|
|
107
|
-
parsedError,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
return responseContent;
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
exports.sendRequest = sendRequest;
|
|
115
|
-
//# sourceMappingURL=http-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/data-access/http-client.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/data-access/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthmeLanguage = void 0;
|
|
4
|
-
var AuthmeLanguage;
|
|
5
|
-
(function (AuthmeLanguage) {
|
|
6
|
-
AuthmeLanguage["zh-TW"] = "zh_Hant_TW";
|
|
7
|
-
AuthmeLanguage["en-US"] = "en_US";
|
|
8
|
-
})(AuthmeLanguage = exports.AuthmeLanguage || (exports.AuthmeLanguage = {}));
|
|
9
|
-
//# sourceMappingURL=language.enum.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"language.enum.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/enum/language.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,sCAAsB,CAAA;IACtB,iCAAiB,CAAA;AACnB,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorCode = exports.AuthmeError = void 0;
|
|
4
|
-
class AuthmeError {
|
|
5
|
-
constructor(code, cause = null) {
|
|
6
|
-
this._cause = null;
|
|
7
|
-
this._code = null;
|
|
8
|
-
this._code = code;
|
|
9
|
-
this._cause = cause;
|
|
10
|
-
}
|
|
11
|
-
get message() {
|
|
12
|
-
return '[Authme SDK Error] Code: ' + this.code;
|
|
13
|
-
}
|
|
14
|
-
setCode(code) {
|
|
15
|
-
this._code = code;
|
|
16
|
-
}
|
|
17
|
-
get code() {
|
|
18
|
-
return this._code;
|
|
19
|
-
}
|
|
20
|
-
get cause() {
|
|
21
|
-
return this._cause;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.AuthmeError = AuthmeError;
|
|
25
|
-
var ErrorCode;
|
|
26
|
-
(function (ErrorCode) {
|
|
27
|
-
// 1XX for engine
|
|
28
|
-
ErrorCode[ErrorCode["BROWSER_NOT_SUPPORT"] = 100] = "BROWSER_NOT_SUPPORT";
|
|
29
|
-
ErrorCode[ErrorCode["ENGINE_INIT_ERROR"] = 101] = "ENGINE_INIT_ERROR";
|
|
30
|
-
ErrorCode[ErrorCode["ENGINE_MODULE_IS_INITIALIZING"] = 102] = "ENGINE_MODULE_IS_INITIALIZING";
|
|
31
|
-
ErrorCode[ErrorCode["ENGINE_MODULE_INIT_ERROR"] = 103] = "ENGINE_MODULE_INIT_ERROR";
|
|
32
|
-
ErrorCode[ErrorCode["RECOGNITION_NOT_AVAILABLE"] = 104] = "RECOGNITION_NOT_AVAILABLE";
|
|
33
|
-
ErrorCode[ErrorCode["RECOGNITION_ERROR"] = 105] = "RECOGNITION_ERROR";
|
|
34
|
-
ErrorCode[ErrorCode["INVALID_AUTH_ERROR"] = 106] = "INVALID_AUTH_ERROR";
|
|
35
|
-
// 2 for LIVENESS
|
|
36
|
-
ErrorCode[ErrorCode["LIVENESS_NOT_PASSED"] = 201] = "LIVENESS_NOT_PASSED";
|
|
37
|
-
// 3 for ID-Recognition
|
|
38
|
-
ErrorCode[ErrorCode["ID_RECOGNITION_CONFIRM_INFO_ERROR"] = 301] = "ID_RECOGNITION_CONFIRM_INFO_ERROR";
|
|
39
|
-
// 4 for Anti-fraud
|
|
40
|
-
ErrorCode[ErrorCode["ANTI_FRAUD_TIMEOUT_ERROR"] = 401] = "ANTI_FRAUD_TIMEOUT_ERROR";
|
|
41
|
-
// 9 for common
|
|
42
|
-
ErrorCode[ErrorCode["SDK_INTERNAL_ERROR"] = 900] = "SDK_INTERNAL_ERROR";
|
|
43
|
-
ErrorCode[ErrorCode["NETWORK_ERROR"] = 901] = "NETWORK_ERROR";
|
|
44
|
-
ErrorCode[ErrorCode["HTTP_ERROR_RESPONSE"] = 902] = "HTTP_ERROR_RESPONSE";
|
|
45
|
-
ErrorCode[ErrorCode["USER_CANCEL"] = 903] = "USER_CANCEL";
|
|
46
|
-
ErrorCode[ErrorCode["CAMERA_NOT_SUPPORT"] = 904] = "CAMERA_NOT_SUPPORT";
|
|
47
|
-
})(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
|
|
48
|
-
//# sourceMappingURL=authme-error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authme-error.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/model/authme-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IAItB,YAAY,IAAe,EAAE,QAAa,IAAI;QAHtC,WAAM,GAAQ,IAAI,CAAC;QACnB,UAAK,GAAqB,IAAI,CAAC;QAGrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,2BAA2B,GAAG,IAAI,CAAC,IAAI,CAAC;IACjD,CAAC;IAEM,OAAO,CAAC,IAAe;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IACD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAvBD,kCAuBC;AAED,IAAY,SAyBX;AAzBD,WAAY,SAAS;IACnB,iBAAiB;IACjB,yEAAyB,CAAA;IACzB,qEAAuB,CAAA;IACvB,6FAAmC,CAAA;IACnC,mFAA8B,CAAA;IAC9B,qFAA+B,CAAA;IAC/B,qEAAuB,CAAA;IACvB,uEAAwB,CAAA;IAExB,iBAAiB;IACjB,yEAAyB,CAAA;IAEzB,uBAAuB;IACvB,qGAAuC,CAAA;IAEvC,mBAAmB;IACnB,mFAA8B,CAAA;IAE9B,eAAe;IACf,uEAAwB,CAAA;IACxB,6DAAmB,CAAA;IACnB,yEAAyB,CAAA;IACzB,yDAAiB,CAAA;IACjB,uEAAwB,CAAA;AAC1B,CAAC,EAzBW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAyBpB"}
|
package/src/lib/model/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/model/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B"}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=init-config.interface.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init-config.interface.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/model/init-config.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/translate/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTranslateInstance = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const language_enum_1 = require("../enum/language.enum");
|
|
6
|
-
class TranslateService {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.dict = {};
|
|
9
|
-
this.languageOptions = [language_enum_1.AuthmeLanguage['zh-TW'], language_enum_1.AuthmeLanguage['en-US']];
|
|
10
|
-
this.currentLang = language_enum_1.AuthmeLanguage['zh-TW'];
|
|
11
|
-
}
|
|
12
|
-
fetchSource(path) {
|
|
13
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
for (let i = 0; i < this.languageOptions.length; i++) {
|
|
15
|
-
const resp = yield fetch(`${path}/${this.languageOptions[i]}.json`);
|
|
16
|
-
if (resp.ok) {
|
|
17
|
-
this.dict[this.languageOptions[i]] = yield resp.json();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
extendSource(path, lang) {
|
|
24
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const resp = yield fetch(`${path}`);
|
|
26
|
-
if (resp.ok) {
|
|
27
|
-
this.dict[lang] = Object.assign(Object.assign({}, this.dict[lang]), (yield resp.json()));
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
setLang(lang) {
|
|
33
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
this.currentLang = lang;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
translate(key, args = {}) {
|
|
38
|
-
let str = this.dict[this.currentLang][key] || key;
|
|
39
|
-
if (Object.keys(args).length > 0) {
|
|
40
|
-
Object.keys(args).forEach((key) => {
|
|
41
|
-
str = str.replace(new RegExp(`{{${key}}}`, 'g'), args[key].toString());
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return str;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
TranslateService.instance = null;
|
|
48
|
-
function getTranslateInstance() {
|
|
49
|
-
if (!TranslateService.instance) {
|
|
50
|
-
TranslateService.instance = new TranslateService();
|
|
51
|
-
}
|
|
52
|
-
return TranslateService.instance;
|
|
53
|
-
}
|
|
54
|
-
exports.getTranslateInstance = getTranslateInstance;
|
|
55
|
-
//# sourceMappingURL=translate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translate.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/translate/translate.ts"],"names":[],"mappings":";;;;AAAA,yDAAuD;AAEvD,MAAM,gBAAgB;IAAtB;QACU,SAAI,GAAiD,EAAE,CAAC;QAExD,oBAAe,GAAG,CAAC,8BAAc,CAAC,OAAO,CAAC,EAAE,8BAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QACrE,gBAAW,GAAG,8BAAc,CAAC,OAAO,CAAC,CAAC;IAqChD,CAAC;IAnCO,WAAW,CAAC,IAAY;;YAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACpE,IAAI,IAAI,CAAC,EAAE,EAAE;oBACX,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;iBACxD;aACF;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAEK,YAAY,CAAC,IAAY,EAAE,IAAoB;;YACnD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;YACpC,IAAI,IAAI,CAAC,EAAE,EAAE;gBACX,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAQ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAK,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAE,CAAC;aAClE;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAEK,OAAO,CAAC,IAAoB;;YAChC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC1B,CAAC;KAAA;IAED,SAAS,CAAC,GAAW,EAAE,OAA2C,EAAE;QAClE,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;QAElD,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAChC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAChC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YACzE,CAAC,CAAC,CAAC;SACJ;QAED,OAAO,GAAG,CAAC;IACb,CAAC;;AAEM,yBAAQ,GAA4B,IAAI,CAAC;AAGlD,SAAS,oBAAoB;IAC3B,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE;QAC9B,gBAAgB,CAAC,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;KACpD;IACD,OAAO,gBAAgB,CAAC,QAAQ,CAAC;AACnC,CAAC;AAEQ,oDAAoB"}
|