@authme/core 2.2.1-rc.1 → 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.
Files changed (39) hide show
  1. package/README.md +2 -2
  2. package/index.cjs +238 -0
  3. package/index.js +220 -0
  4. package/package.json +9 -9
  5. package/src/index.d.ts +6 -5
  6. package/src/lib/authme-log.d.ts +1 -1
  7. package/src/lib/core.d.ts +1 -1
  8. package/src/lib/data-access/http-client.d.ts +16 -16
  9. package/src/lib/data-access/index.d.ts +1 -1
  10. package/src/lib/enum/language.enum.d.ts +4 -4
  11. package/src/lib/model/authme-error.d.ts +1 -1
  12. package/src/lib/model/index.d.ts +1 -1
  13. package/src/lib/translate/index.d.ts +1 -1
  14. package/src/lib/translate/translate.d.ts +16 -16
  15. package/src/lib/version.d.ts +1 -0
  16. package/CHANGELOG.md +0 -163
  17. package/src/index.js +0 -9
  18. package/src/index.js.map +0 -1
  19. package/src/lib/authme-log.js +0 -6
  20. package/src/lib/authme-log.js.map +0 -1
  21. package/src/lib/core.js +0 -8
  22. package/src/lib/core.js.map +0 -1
  23. package/src/lib/data-access/http-client.js +0 -115
  24. package/src/lib/data-access/http-client.js.map +0 -1
  25. package/src/lib/data-access/index.js +0 -5
  26. package/src/lib/data-access/index.js.map +0 -1
  27. package/src/lib/enum/language.enum.js +0 -9
  28. package/src/lib/enum/language.enum.js.map +0 -1
  29. package/src/lib/model/authme-error.js +0 -7
  30. package/src/lib/model/authme-error.js.map +0 -1
  31. package/src/lib/model/index.js +0 -5
  32. package/src/lib/model/index.js.map +0 -1
  33. package/src/lib/model/init-config.interface.d.ts +0 -0
  34. package/src/lib/model/init-config.interface.js +0 -1
  35. package/src/lib/model/init-config.interface.js.map +0 -1
  36. package/src/lib/translate/index.js +0 -5
  37. package/src/lib/translate/index.js.map +0 -1
  38. package/src/lib/translate/translate.js +0 -57
  39. package/src/lib/translate/translate.js.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # core
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 core` to execute the unit tests via [Jest](https://jestjs.io).
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.1-rc.1",
4
- "main": "./src/index.js",
5
- "typings": "./src/index.d.ts",
6
- "dependencies": {},
3
+ "version": "2.2.1-rc.3",
7
4
  "peerDependencies": {
8
- "@authme/util": "2.2.1-rc.1",
9
- "three": "^0.136.0",
10
- "lottie-web": "^5.9.2",
11
- "tslib": "^2.3.0"
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,5 +1,6 @@
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';
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';
@@ -1 +1 @@
1
- export { debugLog } from '@authme/util';
1
+ export { debugLog } from '@authme/util';
package/src/lib/core.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function core(): string;
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 +1 @@
1
- export { AuthmeError, ErrorCode } from '@authme/util';
1
+ export { AuthmeError, ErrorCode } from '@authme/util';
@@ -1 +1 @@
1
- export * from './authme-error';
1
+ export * from './authme-error';
@@ -1 +1 @@
1
- export * from './translate';
1
+ export * from './translate';
@@ -1,16 +1,16 @@
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 };
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,163 +0,0 @@
1
- # Changelog
2
-
3
- This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
-
5
- ## [2.2.1-rc.1](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.1-rc.0...v2.2.1-rc.1) (2022-12-28)
6
-
7
- ## [2.2.1-rc.0](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0...v2.2.1-rc.0) (2022-12-22)
8
-
9
- ### Features
10
-
11
- - implement block fraud config ([6da235f](https://github.com/AuthMe01/web-client-sdk/commit/6da235fdefea62acdf7f0ef1e0c73583a11378f8))
12
-
13
- ### Bug Fixes
14
-
15
- - 1. fix lang packge initSDK loading error. 2. modify translate service extent method. 3. implement sdk-demo custom lang simple. ([db5f8b9](https://github.com/AuthMe01/web-client-sdk/commit/db5f8b99d50f0ddfd7a2645c9de9dacab7591458))
16
-
17
- ## [2.2.0](https://github.com/AuthMe01/web-client-sdk/compare/v2.2.0-rc.13...v2.2.0) (2022-12-19)
18
-
19
- ## [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)
20
-
21
- ## [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)
22
-
23
- ## [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)
24
-
25
- ## [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)
26
-
27
- ## [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)
28
-
29
- ### Bug Fixes
30
-
31
- - http-client error message ([6be02fc](https://github.com/AuthMe01/web-client-sdk/commit/6be02fc6e6b9ae461e5c73b289bce58cfba5759b))
32
-
33
- ## [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)
34
-
35
- ## [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)
36
-
37
- ## [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)
38
-
39
- ## [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)
40
-
41
- ### Features
42
-
43
- - strict error code & error handler ([b6267d5](https://github.com/AuthMe01/web-client-sdk/commit/b6267d57d0a6bf80ef9eddd12243da969b1ebb79))
44
-
45
- ## [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)
46
-
47
- ## [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)
48
-
49
- ## [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)
50
-
51
- ## [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)
52
-
53
- ## [2.2.0-rc.0](https://github.com/AuthMe01/web-client-sdk/compare/v2.1.1...v2.2.0-rc.0) (2022-11-11)
54
-
55
- ### Features
56
-
57
- - PROD-1647 remove unused code ([2ae2a11](https://github.com/AuthMe01/web-client-sdk/commit/2ae2a11846fa2c733ae4c07d5e00c971270e648c))
58
- - PROD-1660 Add i18n extend support ([15c8fd7](https://github.com/AuthMe01/web-client-sdk/commit/15c8fd77af1a645b77de93a891f7740edf4bdf6d))
59
-
60
- ## [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)
61
-
62
- ### Features
63
-
64
- - PROD-1647 remove unused code ([2ae2a11](https://github.com/AuthMe01/web-client-sdk/commit/2ae2a11846fa2c733ae4c07d5e00c971270e648c))
65
- - PROD-1660 Add i18n extend support ([15c8fd7](https://github.com/AuthMe01/web-client-sdk/commit/15c8fd77af1a645b77de93a891f7740edf4bdf6d))
66
-
67
- ## [2.1.1](https://github.com/AuthMe01/web-client-sdk/compare/prod-2.1.0...prod-2.1.1) (2022-09-08)
68
-
69
- ## 1.2.2 (2022-07-28)
70
-
71
- ### Bug Fixes
72
-
73
- - PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
74
- - PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
75
- - PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
76
-
77
- ### Features
78
-
79
- - PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
80
- - PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
81
- - PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
82
- - PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
83
- - show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
84
-
85
- ## 1.2.1 (2022-07-28)
86
-
87
- ### Bug Fixes
88
-
89
- - PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
90
- - PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
91
- - PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
92
-
93
- ### Features
94
-
95
- - PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
96
- - PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
97
- - PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
98
- - PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
99
- - show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
100
-
101
- # 1.2.0 (2022-07-25)
102
-
103
- ### Bug Fixes
104
-
105
- - PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
106
- - PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
107
- - PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
108
-
109
- ### Features
110
-
111
- - PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
112
- - PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
113
- - PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
114
- - PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
115
- - show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
116
-
117
- ## 1.1.1 (2022-07-07)
118
-
119
- ### Bug Fixes
120
-
121
- - PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
122
- - PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
123
- - PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
124
-
125
- ### Features
126
-
127
- - PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
128
- - PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
129
- - PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
130
- - PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
131
- - show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
132
-
133
- # 1.1.0 (2022-07-06)
134
-
135
- ### Bug Fixes
136
-
137
- - PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
138
- - PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
139
- - PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
140
-
141
- ### Features
142
-
143
- - PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
144
- - PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
145
- - PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
146
- - PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
147
- - show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
148
-
149
- # 1.0.0 (2022-05-30)
150
-
151
- ### Bug Fixes
152
-
153
- - PROD-405 Handle ocr backend recognition error ([1084e8d](https://github.com/AuthMe01/web-client-sdk/commit/1084e8d70f00ab8200f00f334272e1d594585387))
154
- - PROD-463 handle anti-fraud timeout error ([13d1533](https://github.com/AuthMe01/web-client-sdk/commit/13d1533a4baecefadd9a47e0f81ac5ed4dbba0fa))
155
- - PROD-583 fix anti-fraud process ([aee07de](https://github.com/AuthMe01/web-client-sdk/commit/aee07de111240304584a1b08dc9b9c6bc816f615))
156
-
157
- ### Features
158
-
159
- - PROD-135 v3 fas api ([8e1e9cc](https://github.com/AuthMe01/web-client-sdk/commit/8e1e9cc9b8e5acbdbc4d49564bad8d42146a3c61))
160
- - PROD-279 add sdk info in request header ([ca871cf](https://github.com/AuthMe01/web-client-sdk/commit/ca871cf9182aab3499c1918a8b946dc6d2cfed9a))
161
- - PROD-334 Add Network Error Retry ([1dafbfd](https://github.com/AuthMe01/web-client-sdk/commit/1dafbfd2d51024abed9611cda4b7bd04401ed7f1))
162
- - PROD-595 Add eKYC impl ([6b5cf51](https://github.com/AuthMe01/web-client-sdk/commit/6b5cf5198a8f3039a52a1f114ff2089cb45b17b2))
163
- - show current version on view ([1957ca6](https://github.com/AuthMe01/web-client-sdk/commit/1957ca6f863e1421ed3705937a7e8601cda70916))
package/src/index.js DELETED
@@ -1,9 +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
- tslib_1.__exportStar(require("./lib/authme-log"), exports);
9
- //# 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;AAChC,2DAAiC"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.debugLog = void 0;
4
- var util_1 = require("@authme/util");
5
- Object.defineProperty(exports, "debugLog", { enumerable: true, get: function () { return util_1.debugLog; } });
6
- //# sourceMappingURL=authme-log.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"authme-log.js","sourceRoot":"","sources":["../../../../../libs/core/src/lib/authme-log.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AAA/B,gGAAA,QAAQ,OAAA"}
package/src/lib/core.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.core = void 0;
4
- function core() {
5
- return 'core';
6
- }
7
- exports.core = core;
8
- //# sourceMappingURL=core.js.map
@@ -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"}
@@ -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":";;;;AAAA,uCAAqD;A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AC,MAAM;oBACnB,EAAE,EAAE,IAAI,CAAC,EAAE;oBACX,GAAG;oBACH,mBAAmB;oBACnB,eAAe;oBACf,WAAW;iBACZ;aACF,CAAC,CAAC;SACJ;QAED,OAAO,eAAwB,CAAC;IAClC,CAAC;CAAA;AAnGD,kCAmGC"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./http-client"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -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,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorCode = exports.AuthmeError = void 0;
4
- var util_1 = require("@authme/util");
5
- Object.defineProperty(exports, "AuthmeError", { enumerable: true, get: function () { return util_1.AuthmeError; } });
6
- Object.defineProperty(exports, "ErrorCode", { enumerable: true, get: function () { return util_1.ErrorCode; } });
7
- //# 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,qCAAsD;AAA7C,mGAAA,WAAW,OAAA;AAAE,iGAAA,SAAS,OAAA"}
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./authme-error"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -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,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./translate"), exports);
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/core/src/lib/translate/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B"}
@@ -1,57 +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.originalDict = {};
9
- this.customDict = {};
10
- this.languageOptions = [language_enum_1.AuthmeLanguage['zh-TW'], language_enum_1.AuthmeLanguage['en-US']];
11
- this.currentLang = language_enum_1.AuthmeLanguage['zh-TW'];
12
- }
13
- fetchSource(path) {
14
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
- for (let i = 0; i < this.languageOptions.length; i++) {
16
- const resp = yield fetch(`${path}/${this.languageOptions[i]}.json`);
17
- if (resp.ok) {
18
- this.originalDict[this.languageOptions[i]] = yield resp.json();
19
- }
20
- }
21
- return true;
22
- });
23
- }
24
- extendSource(path, lang) {
25
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
26
- const resp = yield fetch(`${path}`);
27
- if (resp.ok) {
28
- this.customDict[lang] = yield resp.json();
29
- }
30
- return true;
31
- });
32
- }
33
- setLang(lang) {
34
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
- this.currentLang = lang;
36
- });
37
- }
38
- translate(key, args = {}) {
39
- var _a, _b, _c, _d;
40
- 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;
41
- if (Object.keys(args).length > 0) {
42
- Object.keys(args).forEach((key) => {
43
- str = str.replace(new RegExp(`{{${key}}}`, 'g'), args[key].toString());
44
- });
45
- }
46
- return str;
47
- }
48
- }
49
- TranslateService.instance = null;
50
- function getTranslateInstance() {
51
- if (!TranslateService.instance) {
52
- TranslateService.instance = new TranslateService();
53
- }
54
- return TranslateService.instance;
55
- }
56
- exports.getTranslateInstance = getTranslateInstance;
57
- //# 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;AAGvD,MAAM,gBAAgB;IAAtB;QACU,iBAAY,GAAkB,EAAE,CAAC;QACjC,eAAU,GAAkB,EAAE,CAAC;QAE/B,oBAAe,GAAG,CAAC,8BAAc,CAAC,OAAO,CAAC,EAAE,8BAAc,CAAC,OAAO,CAAC,CAAC,CAAC;QACrE,gBAAW,GAAG,8BAAc,CAAC,OAAO,CAAC,CAAC;IAyChD,CAAC;I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