@yuntower/yuntower-account-node-sdk 0.0.9
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 +20 -0
- package/index.js +226 -0
- package/package.json +21 -0
- package/src/index.ts +163 -0
- package/tsconfig.json +108 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# YunTowerAccount-NodeSDK
|
|
2
|
+
|
|
3
|
+
云塔开放认证平台官方Node SDK
|
|
4
|
+
|
|
5
|
+
Apache License 2.0
|
|
6
|
+
|
|
7
|
+
- 官网:[https://account.yuntower.com](https://account.yuntower.cn)
|
|
8
|
+
- 文档:[https://account.yuntower.com/docs](https://account.yuntower.cn/docs)
|
|
9
|
+
- NPM:[https://www.npmjs.com/package/@yuntower/yuntower-account-node-sdk](https://www.npmjs.com/package/yuntower-account-node-sdk)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
// For versions <= 0.0.8
|
|
14
|
+
npm i yuntower-account-node-sdk
|
|
15
|
+
|
|
16
|
+
// For versions >= 0.0.9
|
|
17
|
+
npm i yuntower/yuntower-account-node-sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Provide by YunTower
|
package/index.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
var YunTowerAccountSDK = /** @class */ (function () {
|
|
51
|
+
function YunTowerAccountSDK(_a) {
|
|
52
|
+
var appid = _a.appid, appsecret = _a.appsecret, _b = _a.state, state = _b === void 0 ? null : _b, _c = _a.scope, scope = _c === void 0 ? 'user_profile' : _c;
|
|
53
|
+
if (!appid || !appsecret || !scope) {
|
|
54
|
+
console.error('[YunTowerAccountSDK] 参数缺失');
|
|
55
|
+
}
|
|
56
|
+
if (!['user_profile'].includes(scope)) {
|
|
57
|
+
console.error('[YunTowerAccountSDK] scope参数错误,目前只支持[user_profile]');
|
|
58
|
+
}
|
|
59
|
+
this.config = {
|
|
60
|
+
auth: 'https://account.yuntower.cn',
|
|
61
|
+
api: 'https://v1.api.account.yuntower.cn/open/v1',
|
|
62
|
+
// auth:'http://localhost:3000',
|
|
63
|
+
// api:'http://127.0.0.1:8787',
|
|
64
|
+
origin_white_list: ['account.yuntower.cn', 'account.yuntower.com', 'localhost:3000'],
|
|
65
|
+
appid: appid,
|
|
66
|
+
appsecret: appsecret,
|
|
67
|
+
scope: scope,
|
|
68
|
+
state: state,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* fetch
|
|
73
|
+
* @param {string} url - 请求URL
|
|
74
|
+
* @param {string} method - 请求方法 (GET | POST)
|
|
75
|
+
* @param {Object} [data] - POST请求时的数据
|
|
76
|
+
* @param {Object} [headers] - 自定义请求头
|
|
77
|
+
* @returns {Promise<any>} - 解析后的响应体
|
|
78
|
+
*/
|
|
79
|
+
YunTowerAccountSDK.prototype.fetch = function (url_1, method_1) {
|
|
80
|
+
return __awaiter(this, arguments, void 0, function (url, method, data, headers) {
|
|
81
|
+
var defaultHeaders, options, response, responseBody, error_1;
|
|
82
|
+
if (data === void 0) { data = {}; }
|
|
83
|
+
if (headers === void 0) { headers = {}; }
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
_a.trys.push([0, 3, , 4]);
|
|
88
|
+
defaultHeaders = __assign({ 'Content-Type': 'application/json' }, headers);
|
|
89
|
+
options = {
|
|
90
|
+
method: method,
|
|
91
|
+
headers: defaultHeaders,
|
|
92
|
+
};
|
|
93
|
+
// 如果是POST请求,需要设置body
|
|
94
|
+
if (method.toUpperCase() === 'POST') {
|
|
95
|
+
options.body = JSON.stringify(data);
|
|
96
|
+
}
|
|
97
|
+
return [4 /*yield*/, fetch(url, options)];
|
|
98
|
+
case 1:
|
|
99
|
+
response = _a.sent();
|
|
100
|
+
// 检查响应状态
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
throw new Error("HTTP error! Status: ".concat(response.status));
|
|
103
|
+
}
|
|
104
|
+
return [4 /*yield*/, response.json()];
|
|
105
|
+
case 2:
|
|
106
|
+
responseBody = _a.sent();
|
|
107
|
+
console.log('[YunTowerAccountSDK]: ', responseBody);
|
|
108
|
+
return [2 /*return*/, responseBody];
|
|
109
|
+
case 3:
|
|
110
|
+
error_1 = _a.sent();
|
|
111
|
+
console.error('Fetch error:', error_1);
|
|
112
|
+
throw error_1;
|
|
113
|
+
case 4: return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* 获取用户访问凭证
|
|
120
|
+
* @param {string} token 临时Token
|
|
121
|
+
* @param {string} tuid 临时UID
|
|
122
|
+
* @param {string} appid 应用ID
|
|
123
|
+
* @param {string} appsecret 应用密钥
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
YunTowerAccountSDK.prototype.getUserToken = function (token_1, tuid_1) {
|
|
127
|
+
return __awaiter(this, arguments, void 0, function (token, tuid, appid, appsecret) {
|
|
128
|
+
var res;
|
|
129
|
+
if (appid === void 0) { appid = this.config.appid; }
|
|
130
|
+
if (appsecret === void 0) { appsecret = this.config.appsecret; }
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
switch (_a.label) {
|
|
133
|
+
case 0: return [4 /*yield*/, this.fetch("".concat(this.config.api, "/user/token/get"), "POST", {
|
|
134
|
+
token: token,
|
|
135
|
+
tuid: tuid,
|
|
136
|
+
appid: appid,
|
|
137
|
+
appsecret: appsecret
|
|
138
|
+
})];
|
|
139
|
+
case 1:
|
|
140
|
+
res = _a.sent();
|
|
141
|
+
return [2 /*return*/, res];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* 获取用户数据
|
|
148
|
+
* @param {string} access_token 用户访问凭证
|
|
149
|
+
* @param {string} appid 应用ID
|
|
150
|
+
* @param {string} appsecret 应用密钥
|
|
151
|
+
* @returns
|
|
152
|
+
*/
|
|
153
|
+
YunTowerAccountSDK.prototype.getUserInfo = function (access_token_1) {
|
|
154
|
+
return __awaiter(this, arguments, void 0, function (access_token, appid, appsecret) {
|
|
155
|
+
var res;
|
|
156
|
+
if (appid === void 0) { appid = this.config.appid; }
|
|
157
|
+
if (appsecret === void 0) { appsecret = this.config.appsecret; }
|
|
158
|
+
return __generator(this, function (_a) {
|
|
159
|
+
switch (_a.label) {
|
|
160
|
+
case 0: return [4 /*yield*/, this.fetch("".concat(this.config.api, "/user/data"), "POST", {
|
|
161
|
+
appid: appid,
|
|
162
|
+
appsecret: appsecret
|
|
163
|
+
}, {
|
|
164
|
+
Authorization: "Bearer ".concat(access_token)
|
|
165
|
+
})];
|
|
166
|
+
case 1:
|
|
167
|
+
res = _a.sent();
|
|
168
|
+
return [2 /*return*/, res];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* 刷新用户访问凭证
|
|
175
|
+
* @param {string} refresh_token 用户刷新凭证
|
|
176
|
+
* @param {string} appid 应用ID
|
|
177
|
+
* @param {string} appsecret 应用密钥
|
|
178
|
+
* @returns
|
|
179
|
+
*/
|
|
180
|
+
YunTowerAccountSDK.prototype.refreshUserToken = function (refresh_token_1) {
|
|
181
|
+
return __awaiter(this, arguments, void 0, function (refresh_token, appid, appsecret) {
|
|
182
|
+
var res;
|
|
183
|
+
if (appid === void 0) { appid = this.config.appid; }
|
|
184
|
+
if (appsecret === void 0) { appsecret = this.config.appsecret; }
|
|
185
|
+
return __generator(this, function (_a) {
|
|
186
|
+
switch (_a.label) {
|
|
187
|
+
case 0: return [4 /*yield*/, this.fetch("".concat(this.config.api, "/user/token/refresh"), "POST", {
|
|
188
|
+
appid: appid,
|
|
189
|
+
appsecret: appsecret
|
|
190
|
+
}, {
|
|
191
|
+
Authorization: "Bearer ".concat(refresh_token)
|
|
192
|
+
})];
|
|
193
|
+
case 1:
|
|
194
|
+
res = _a.sent();
|
|
195
|
+
return [2 /*return*/, res];
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* 退出登录状态
|
|
202
|
+
* @param {string} access_token 用户访问凭证
|
|
203
|
+
*/
|
|
204
|
+
YunTowerAccountSDK.prototype.logout = function (access_token_1) {
|
|
205
|
+
return __awaiter(this, arguments, void 0, function (access_token, appid, appsecret) {
|
|
206
|
+
var res;
|
|
207
|
+
if (appid === void 0) { appid = this.config.appid; }
|
|
208
|
+
if (appsecret === void 0) { appsecret = this.config.appsecret; }
|
|
209
|
+
return __generator(this, function (_a) {
|
|
210
|
+
switch (_a.label) {
|
|
211
|
+
case 0: return [4 /*yield*/, this.fetch("".concat(this.config.api, "/user/logout"), "POST", {
|
|
212
|
+
appid: appid,
|
|
213
|
+
appsecret: appsecret
|
|
214
|
+
}, {
|
|
215
|
+
Authorization: "Bearer ".concat(access_token)
|
|
216
|
+
})];
|
|
217
|
+
case 1:
|
|
218
|
+
res = _a.sent();
|
|
219
|
+
return [2 /*return*/, res];
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
return YunTowerAccountSDK;
|
|
225
|
+
}());
|
|
226
|
+
exports.default = YunTowerAccountSDK;
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yuntower/yuntower-account-node-sdk",
|
|
3
|
+
"description": "YunTower Account Node SDK",
|
|
4
|
+
"version": "0.0.9",
|
|
5
|
+
"private": false,
|
|
6
|
+
"author": "yuntower",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"@types/node": "^22.5.5"
|
|
10
|
+
},
|
|
11
|
+
"main": "index.js",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"undici-types": "^6.19.8"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
}
|
|
21
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
class YunTowerAccountSDK {
|
|
2
|
+
config: {
|
|
3
|
+
auth: string,
|
|
4
|
+
api: string,
|
|
5
|
+
origin_white_list: string[],
|
|
6
|
+
appid: string,
|
|
7
|
+
appsecret: string,
|
|
8
|
+
scope: string,
|
|
9
|
+
state: any
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
constructor({
|
|
13
|
+
appid,
|
|
14
|
+
appsecret,
|
|
15
|
+
state = null,
|
|
16
|
+
scope = 'user_profile',
|
|
17
|
+
}: {
|
|
18
|
+
appid: string;
|
|
19
|
+
appsecret: string;
|
|
20
|
+
scope: string;
|
|
21
|
+
state?: any;
|
|
22
|
+
}) {
|
|
23
|
+
if (!appid || !appsecret || !scope) {
|
|
24
|
+
console.error('[YunTowerAccountSDK] 参数缺失');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!['user_profile'].includes(scope)) {
|
|
28
|
+
console.error('[YunTowerAccountSDK] scope参数错误,目前只支持[user_profile]');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.config = {
|
|
32
|
+
auth: 'https://account.yuntower.cn',
|
|
33
|
+
api: 'https://v1.api.account.yuntower.cn/open/v1',
|
|
34
|
+
// auth:'http://localhost:3000',
|
|
35
|
+
// api:'http://127.0.0.1:8787',
|
|
36
|
+
origin_white_list: ['account.yuntower.cn', 'account.yuntower.com', 'localhost:3000'],
|
|
37
|
+
appid,
|
|
38
|
+
appsecret,
|
|
39
|
+
scope,
|
|
40
|
+
state,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* fetch
|
|
46
|
+
* @param {string} url - 请求URL
|
|
47
|
+
* @param {string} method - 请求方法 (GET | POST)
|
|
48
|
+
* @param {Object} [data] - POST请求时的数据
|
|
49
|
+
* @param {Object} [headers] - 自定义请求头
|
|
50
|
+
* @returns {Promise<any>} - 解析后的响应体
|
|
51
|
+
*/
|
|
52
|
+
async fetch(url: string, method: 'GET' | 'POST', data: object = {}, headers: object = {}): Promise<any> {
|
|
53
|
+
try {
|
|
54
|
+
// 设置默认请求头
|
|
55
|
+
const defaultHeaders = {
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
...headers,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// 构建fetch选项
|
|
61
|
+
const options: RequestInit = {
|
|
62
|
+
method,
|
|
63
|
+
headers: defaultHeaders,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// 如果是POST请求,需要设置body
|
|
67
|
+
if (method.toUpperCase() === 'POST') {
|
|
68
|
+
options.body = JSON.stringify(data);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 发起请求
|
|
72
|
+
const response = await fetch(url, options);
|
|
73
|
+
|
|
74
|
+
// 检查响应状态
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 解析响应体
|
|
80
|
+
const responseBody = await response.json();
|
|
81
|
+
console.log('[YunTowerAccountSDK]: ', responseBody)
|
|
82
|
+
return responseBody;
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error('Fetch error:', error);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 获取用户访问凭证
|
|
91
|
+
* @param {string} token 临时Token
|
|
92
|
+
* @param {string} tuid 临时UID
|
|
93
|
+
* @param {string} appid 应用ID
|
|
94
|
+
* @param {string} appsecret 应用密钥
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
async getUserToken(token: string, tuid: string, appid: string = this.config.appid, appsecret: string = this.config.appsecret): Promise<any> {
|
|
98
|
+
const res = await this.fetch(`${this.config.api}/user/token/get`, "POST", {
|
|
99
|
+
token,
|
|
100
|
+
tuid,
|
|
101
|
+
appid,
|
|
102
|
+
appsecret
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return res;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 获取用户数据
|
|
110
|
+
* @param {string} access_token 用户访问凭证
|
|
111
|
+
* @param {string} appid 应用ID
|
|
112
|
+
* @param {string} appsecret 应用密钥
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
async getUserInfo(access_token: string, appid: string = this.config.appid, appsecret: string = this.config.appsecret): Promise<any> {
|
|
116
|
+
const res = await this.fetch(`${this.config.api}/user/data`, "POST", {
|
|
117
|
+
appid,
|
|
118
|
+
appsecret
|
|
119
|
+
}, {
|
|
120
|
+
Authorization: `Bearer ${access_token}`
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return res;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 刷新用户访问凭证
|
|
128
|
+
* @param {string} refresh_token 用户刷新凭证
|
|
129
|
+
* @param {string} appid 应用ID
|
|
130
|
+
* @param {string} appsecret 应用密钥
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
async refreshUserToken(refresh_token: string, appid: string = this.config.appid, appsecret: string = this.config.appsecret): Promise<any> {
|
|
134
|
+
const res = await this.fetch(`${this.config.api}/user/token/refresh`, "POST", {
|
|
135
|
+
appid,
|
|
136
|
+
appsecret
|
|
137
|
+
}, {
|
|
138
|
+
Authorization: `Bearer ${refresh_token}`
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
return res;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 退出登录状态
|
|
146
|
+
* @param {string} access_token 用户访问凭证
|
|
147
|
+
*/
|
|
148
|
+
async logout(access_token: string, appid: string = this.config.appid, appsecret: string = this.config.appsecret): Promise<{
|
|
149
|
+
code: number,
|
|
150
|
+
msg: string,
|
|
151
|
+
data: any
|
|
152
|
+
}> {
|
|
153
|
+
const res = await this.fetch(`${this.config.api}/user/logout`, "POST", {
|
|
154
|
+
appid,
|
|
155
|
+
appsecret
|
|
156
|
+
}, {
|
|
157
|
+
Authorization: `Bearer ${access_token}`
|
|
158
|
+
});
|
|
159
|
+
return res;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export default YunTowerAccountSDK;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
+
|
|
27
|
+
/* Modules */
|
|
28
|
+
"module": "commonjs", /* Specify what module code is generated. */
|
|
29
|
+
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
+
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
+
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
+
|
|
46
|
+
/* JavaScript Support */
|
|
47
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
+
|
|
51
|
+
/* Emit */
|
|
52
|
+
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
+
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
+
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
59
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
+
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
63
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
64
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
65
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
66
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
67
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
68
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
69
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
70
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
71
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
72
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
73
|
+
|
|
74
|
+
/* Interop Constraints */
|
|
75
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
76
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
77
|
+
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
78
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
79
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
80
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
81
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
82
|
+
|
|
83
|
+
/* Type Checking */
|
|
84
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
85
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
86
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
87
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
88
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
89
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
90
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
91
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
92
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
93
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
94
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
95
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
96
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
97
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
98
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
99
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
100
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
101
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
102
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
103
|
+
|
|
104
|
+
/* Completeness */
|
|
105
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
106
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
107
|
+
}
|
|
108
|
+
}
|