@lcap/nasl
Version:
NetEase Application Specific Language
81 lines • 2.71 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.HTTP_TIMEOUT_ORIGIN_MESSAGE = exports.login = exports.connect = exports.config = exports.version = void 0;
const axios_1 = __importDefault(require("axios"));
const package_json_1 = __importDefault(require("../package.json"));
/** Nasl 当前版本 */
exports.version = package_json_1.default.version;
exports.config = {
mock: undefined, // 'case1', // || process.env.ASL_MOCK,
storage: {
protocol: 'http',
/**
* 基本远程路径或 fs 路径
*/
basePath: typeof window !== 'undefined' ? '/proxy/nasl-storage' : 'http://localhost:9300',
cookie: '...',
},
baseURL: 'http://lcp.vusion.top',
staticURL: '//static-vusion.163yun.com',
scope: 'pc',
cookie: '...',
debug: true,
debugRequest: false,
reloadAlways: false,
advancedFeatures: false,
throttleWait: 5000,
allNodesAPI: {},
closeViews: false,
/**
* 前端制品client.js依赖资源
* 使用场景:导出源码
*/
frontendPackagesResource: [],
assets: [],
};
async function connect(protocol, basePath, username, password) {
exports.config.storage.protocol = protocol;
exports.config.storage.basePath = basePath;
if (password) {
exports.config.storage.cookie = await login(username, password);
}
else if (username) {
exports.config.storage.cookie = username;
}
}
exports.connect = connect;
/**
* 便捷登录,只支持普通登录
* @required 需要先配置好 config.baseURL
* @param username 用户名
* @param password 密码
*/
async function login(username, password) {
const hostname = exports.config.baseURL.split('/')[2];
const parts = hostname.split('.');
const res = await (0, axios_1.default)({
baseURL: exports.config.baseURL,
params: { Action: 'Login', Version: '2020-06-01' },
method: 'POST',
url: '/proxy/nuims/gateway/nuims/nuims',
data: {
DomainName: 'low-code',
LoginType: 'Normal',
TenantName: parts[0],
UserName: username,
Password: password,
},
headers: {
Env: 'online',
'Content-Type': 'application/json;charset=UTF-8',
},
withCredentials: false,
});
return 'authorization=' + res.headers.authorization;
}
exports.login = login;
exports.HTTP_TIMEOUT_ORIGIN_MESSAGE = 'the local timeout is greater than the system timeout';
//# sourceMappingURL=config.js.map