login-authorization-v2 1.1.5 → 2.0.0-beta.10

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.
@@ -0,0 +1,424 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('js-cookie'), require('js-base64'), require('axios')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'js-cookie', 'js-base64', 'axios'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LoginAuthorizationV2 = {}, global.Cookies, global.Base64, global.axios));
5
+ })(this, (function (exports, Cookie, jsBase64, axios) { 'use strict';
6
+
7
+ /******************************************************************************
8
+ Copyright (c) Microsoft Corporation.
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
+ PERFORMANCE OF THIS SOFTWARE.
20
+ ***************************************************************************** */
21
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
22
+
23
+
24
+ function __awaiter(thisArg, _arguments, P, generator) {
25
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
26
+ return new (P || (P = Promise))(function (resolve, reject) {
27
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
28
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
29
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
30
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
31
+ });
32
+ }
33
+
34
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
35
+ var e = new Error(message);
36
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
37
+ };
38
+
39
+ const NO_ACCESS_TOKEN = 'Access token not found';
40
+ const INVALID_ACCESS_TOKEN = 'Invalid access token';
41
+ const INVALID_REFRESH_TOKEN = 'Invalid refresh token';
42
+ const NO_REFRESH_TOKEN = 'Refresh token not found';
43
+ const NO_MODULE_BASE_URL = 'Module base URL is required';
44
+ const INVALID_TENANT_ID = 'Invalid tenant ID';
45
+ const INVALID_BRAND = 'Invalid brand';
46
+
47
+ const makeSetCookieFn = (key, options) => {
48
+ const index = window.location.hostname.indexOf('.');
49
+ const domain = index === -1
50
+ ? window.location.hostname
51
+ : window.location.hostname.slice(index);
52
+ return (value) => {
53
+ if (value === null) {
54
+ return Cookie.remove(key, Object.assign({ domain }, options));
55
+ }
56
+ Cookie.set(key, value, Object.assign({ domain, expires: 30 }, options));
57
+ };
58
+ };
59
+ const setIdTokenFront = makeSetCookieFn('idTokenFront');
60
+ const setIdTokenBack = makeSetCookieFn('idTokenBack');
61
+ const setRefreshTokenFront = makeSetCookieFn('refreshTokenFront');
62
+ const setRefreshTokenBack = makeSetCookieFn('refreshTokenBack');
63
+ const setRefreshToken = (token) => {
64
+ if (!token) {
65
+ setIdTokenBack(null);
66
+ setIdTokenFront(null);
67
+ makeSetCookieFn('refresh_token')(null);
68
+ return;
69
+ }
70
+ const splits = token.split('.');
71
+ if (splits.length < 5)
72
+ throw new Error(INVALID_REFRESH_TOKEN);
73
+ const refreshTokenFront = splits[0] + '.' + splits[1];
74
+ const refreshTokenBack = splits[2] + '.' + splits[3] + '.' + splits[4];
75
+ setRefreshTokenFront(refreshTokenFront);
76
+ setRefreshTokenBack(refreshTokenBack);
77
+ makeSetCookieFn('refresh_token')(token);
78
+ };
79
+ const setAccessToken = (token) => {
80
+ if (!token) {
81
+ setIdTokenBack(null);
82
+ setIdTokenFront(null);
83
+ makeSetCookieFn('access_token')(null);
84
+ return;
85
+ }
86
+ const splits = token.split('.');
87
+ if (splits.length < 3)
88
+ throw new Error(INVALID_ACCESS_TOKEN);
89
+ const idTokenFront = splits[0] + '.' + splits[1];
90
+ const idTokenBack = splits[2] || '';
91
+ setIdTokenFront(idTokenFront);
92
+ setIdTokenBack(idTokenBack);
93
+ makeSetCookieFn('access_token')(token);
94
+ };
95
+ const getAccessToken = () => Cookie.get('access_token');
96
+ const getRefreshToken = () => Cookie.get('refresh_token');
97
+ const setSystemType = makeSetCookieFn('currentSystemType');
98
+ const getSystemType = () => Cookie.get('currentSystemType');
99
+
100
+ /**
101
+ * 这个文件是写一些兼容的方法,避免各个项目做出大量调整
102
+ */
103
+ const setIdToken = setAccessToken;
104
+ const getIdToken = getAccessToken;
105
+ const setCookie = (name, value, domain, path = '/', time = 30 * 24 * 60 * 60 * 1000) => {
106
+ if (value === null || value === undefined) {
107
+ return Cookie.remove(name);
108
+ }
109
+ Cookie.set(name, value, {
110
+ domain,
111
+ path,
112
+ expires: time / (24 * 60 * 60 * 1000)
113
+ });
114
+ };
115
+ const clearLoginCookie = () => {
116
+ setAccessToken(null);
117
+ setRefreshToken(null);
118
+ };
119
+ const getCookie = (c_name) => {
120
+ if (!c_name)
121
+ return null;
122
+ const reg = new RegExp('(?:^|; )' + encodeURIComponent(c_name) + '=([^;]*)');
123
+ const result = reg.exec(document.cookie);
124
+ return result ? decodeURIComponent(result[1] || '') : null;
125
+ };
126
+ const getUrlParam = (key, href) => {
127
+ const search = '?' + ((href || window.location.href).split('?')[1] || '');
128
+ const searchParams = new URLSearchParams(search);
129
+ return searchParams.get(key);
130
+ };
131
+
132
+ const isMobile = () => {
133
+ const ua = navigator.userAgent;
134
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua);
135
+ };
136
+ const getUserInfo = () => {
137
+ return new Promise((resolve, reject) => {
138
+ const token = getAccessToken();
139
+ if (!token)
140
+ return reject(new Error(NO_ACCESS_TOKEN));
141
+ const splits = token.split('.');
142
+ if (splits.length < 3)
143
+ return reject(new Error(NO_ACCESS_TOKEN));
144
+ resolve(JSON.parse(jsBase64.Base64.decode(splits[1])));
145
+ });
146
+ };
147
+
148
+ var Brand;
149
+ (function (Brand) {
150
+ Brand[Brand["ZERO"] = 1] = "ZERO";
151
+ Brand[Brand["HEDGEHOOD"] = 2] = "HEDGEHOOD";
152
+ Brand[Brand["NISE"] = 3] = "NISE";
153
+ })(Brand || (Brand = {}));
154
+ var Tenant;
155
+ (function (Tenant) {
156
+ Tenant[Tenant["ZERO_INT"] = 1] = "ZERO_INT";
157
+ Tenant[Tenant["HEDGEHOOD"] = 2] = "HEDGEHOOD";
158
+ Tenant[Tenant["ZERO_NZ"] = 3] = "ZERO_NZ";
159
+ Tenant[Tenant["ZERO_LA"] = 4] = "ZERO_LA";
160
+ Tenant[Tenant["ZERO_BR"] = 4] = "ZERO_BR";
161
+ Tenant[Tenant["NISE_EU"] = 5] = "NISE_EU";
162
+ })(Tenant || (Tenant = {}));
163
+ var SystemType;
164
+ (function (SystemType) {
165
+ SystemType["Staff"] = "staff";
166
+ SystemType["Client"] = "client";
167
+ })(SystemType || (SystemType = {}));
168
+
169
+ let tenantId;
170
+ let brand;
171
+ let moduleBaseUrl = '';
172
+ let loginPageUrl = '';
173
+ const setTenantId = (id) => {
174
+ if (!Object.values(Tenant).includes(id)) {
175
+ throw new Error(INVALID_TENANT_ID);
176
+ }
177
+ tenantId = id;
178
+ };
179
+ const setBrand = (id) => {
180
+ if (!Object.values(Brand).includes(id)) {
181
+ throw new Error(INVALID_BRAND);
182
+ }
183
+ brand = id;
184
+ };
185
+ const setModuleBaseUrl = (url) => {
186
+ moduleBaseUrl = url;
187
+ };
188
+ const setLoginPageUrl = (url) => {
189
+ loginPageUrl = url;
190
+ };
191
+
192
+ const createPcDialog = () => {
193
+ return `<div id="confirm-container" style="box-sizing:border-box;position:fixed;width:615px;height:145px;box-shadow: 0 0 2px 2px #eeeeee;border-radius: 5px;z-index: 10000000;display: block;left: 35%;padding:20px 20px;top:10px;font-size: 16px;">
194
+ <div id="href" style="color: rgb(32,33,36);"></div>
195
+ <div style="margin: 10px 0 20px 0;color: rgb(32,33,36);font-size: 14px;">You do not have access to the system.</div>
196
+ <div style="display: flex;justify-content: flex-end;">
197
+ <button id="cancel" style="padding: 8px 15px;background: #ffffff;color:rgb(26,115,232);border:1px solid #ccc;border-radius:5px;cursor: pointer;font-size:14px;">Cancel</button>
198
+ <button id="confirm" style="padding: 8px 15px;background: rgb(26,115,232);color:#ffffff;border:none;border-radius:5px;margin-left: 10px;cursor: pointer;font-size:14px;">Sign in to another ZERO account</button>
199
+ </div>
200
+ </div>`;
201
+ };
202
+ const createMobileDialog = () => {
203
+ return `<div id="confirm-container" style="box-sizing:border-box;position:fixed;width:97.6vw;height:145px;box-shadow: 0 0 2px 2px #eeeeee;border-radius: 5px;z-index: 10000000;display: block;left:0px;padding:20px 20px;top:4px;margin:0 4px;font-size: 16px;">
204
+ <div id="href" style="color: rgb(32,33,36);"></div>
205
+ <div style="margin: 10px 0 20px 0;color: rgb(32,33,36);font-size: 14px;">You do not have access to the system.</div>
206
+ <div style="display: flex;justify-content: flex-end;">
207
+ <div style="display: flex;justify-content: flex-end;">
208
+ <button id="cancel" style="padding: 8px 15px;background: #ffffff;color:rgb(26,115,232);border:1px solid #ccc;border-radius:5px;cursor: pointer;font-size:14px;">Cancel</button>
209
+ <button id="confirm" style="padding: 8px 15px;background: rgb(26,115,232);color:#ffffff;border:none;border-radius:5px;margin-left: 10px;cursor: pointer;font-size:14px;">Sign in to another ZERO account</button>
210
+ </div>
211
+ </div>
212
+ </div>`;
213
+ };
214
+ const onConfirmHandler = (evt) => {
215
+ closeDialog();
216
+ window.location.href = loginPageUrl;
217
+ };
218
+ const onCancelHandler = () => {
219
+ closeDialog();
220
+ window.location.href = 'about:blank';
221
+ };
222
+ const closeDialog = () => {
223
+ const container = document.getElementById('confirm-container');
224
+ if (!container || !container.parentNode)
225
+ return;
226
+ document.body.removeChild(container.parentNode);
227
+ };
228
+ const openDialog = () => {
229
+ const container = document.createElement('div');
230
+ isMobile()
231
+ ? container.innerHTML = createMobileDialog()
232
+ : container.innerHTML = createPcDialog();
233
+ const confirmButton = container.querySelector('#confirm');
234
+ const cancelButton = container.querySelector('#cancel');
235
+ confirmButton === null || confirmButton === void 0 ? void 0 : confirmButton.addEventListener('click', onConfirmHandler);
236
+ cancelButton === null || cancelButton === void 0 ? void 0 : cancelButton.addEventListener('click', onCancelHandler);
237
+ document.body.appendChild(container);
238
+ };
239
+
240
+ let instance;
241
+ /**
242
+ * 没找到更好的方式,只能这样做了
243
+ */
244
+ const initInstance = () => __awaiter(void 0, void 0, void 0, function* () {
245
+ let userInfo = null;
246
+ try {
247
+ userInfo = yield getUserInfo();
248
+ }
249
+ catch (error) {
250
+ console.warn('initInstance getUserInfo error:', error);
251
+ }
252
+ instance = axios.create({
253
+ baseURL: moduleBaseUrl,
254
+ timeout: 1.5e4,
255
+ });
256
+ instance.interceptors.request.use((config) => {
257
+ config.headers = Object.assign(Object.assign({}, config.headers), { 'X-tenant-id': userInfo ? userInfo['custom:tenant_id'].toString() : tenantId.toString(), 'X-brand': brand.toString(), 'Authorization': `Bearer ${getAccessToken()}` });
258
+ return config;
259
+ }, (error) => {
260
+ return Promise.reject(error);
261
+ });
262
+ instance.interceptors.response.use((response) => {
263
+ if (response.data.code !== 200) {
264
+ return Promise.reject(response.data.msg);
265
+ }
266
+ return response;
267
+ }, (error) => {
268
+ return Promise.reject(error);
269
+ });
270
+ });
271
+ const fetchRefreshTokenHTTP = (refreshToken) => {
272
+ return instance({
273
+ method: 'post',
274
+ url: '/user-profile/refresh-token/refresh',
275
+ data: {
276
+ refreshToken
277
+ }
278
+ });
279
+ };
280
+ const fetchLogoutHTTP = () => {
281
+ return instance({
282
+ method: 'get',
283
+ url: '/user-profile/logout'
284
+ });
285
+ };
286
+ const fetchServerListHTTP = () => {
287
+ return instance({
288
+ method: 'get',
289
+ url: '/session/current/servers'
290
+ });
291
+ };
292
+
293
+ const make = (config) => {
294
+ if (!config.moduleBaseUrl) {
295
+ throw new Error(NO_MODULE_BASE_URL);
296
+ }
297
+ let timer = undefined;
298
+ setModuleBaseUrl(config.moduleBaseUrl);
299
+ setLoginPageUrl(config.loginPageUrl);
300
+ initInstance();
301
+ const init = (initConfig) => {
302
+ setTenantId(initConfig.tenantId);
303
+ setBrand(initConfig.brand || Brand.ZERO);
304
+ const token = getAccessToken();
305
+ const refreshToken = getRefreshToken();
306
+ if (!token) {
307
+ setAccessToken(null);
308
+ setRefreshToken(null);
309
+ return Promise.reject(new Error(NO_ACCESS_TOKEN));
310
+ }
311
+ if (!refreshToken) {
312
+ setAccessToken(null);
313
+ setRefreshToken(null);
314
+ return Promise.reject(new Error(NO_REFRESH_TOKEN));
315
+ }
316
+ return getUserInfo()
317
+ .then((userInfo) => __awaiter(void 0, void 0, void 0, function* () {
318
+ const valid = detectUserInfoGroupAuth(userInfo);
319
+ if (!valid) {
320
+ return Promise.reject();
321
+ }
322
+ return fetchServerListHTTP();
323
+ }))
324
+ .then(resp => {
325
+ const menus = resp.data.content || [];
326
+ const group = menus.find(menu => menu.groupName === config.moduleName);
327
+ if (menus.length <= 0) {
328
+ openDialog();
329
+ return Promise.reject();
330
+ }
331
+ if (config.moduleName === 'commonLogin') {
332
+ setupRefreshTokenTimer();
333
+ return Promise.resolve(menus);
334
+ }
335
+ if (!group) {
336
+ openDialog();
337
+ return Promise.reject();
338
+ }
339
+ setSystemType(group.staffEndpoint ? SystemType.Staff : SystemType.Client);
340
+ setupRefreshTokenTimer();
341
+ return Promise.resolve(menus);
342
+ })
343
+ .catch((error) => __awaiter(void 0, void 0, void 0, function* () {
344
+ clearRefreshTokenTimer();
345
+ setAccessToken(null);
346
+ setRefreshToken(null);
347
+ yield logout();
348
+ throw error;
349
+ }));
350
+ };
351
+ const detectUserInfoGroupAuth = (userInfo) => {
352
+ const groups = userInfo['cognito:groups'] || [];
353
+ if (!groups.includes(config.moduleName)
354
+ && config.moduleName !== 'commonLogin'
355
+ && config.moduleName !== 'App') {
356
+ return false;
357
+ }
358
+ return true;
359
+ };
360
+ const setupRefreshTokenTimer = () => {
361
+ const refreshToken = getRefreshToken();
362
+ if (!refreshToken)
363
+ return;
364
+ if (timer) {
365
+ clearInterval(timer);
366
+ }
367
+ timer = setInterval(() => {
368
+ fetchRefreshTokenHTTP(refreshToken)
369
+ .then(resp => {
370
+ const { content: { idToken } } = resp.data;
371
+ setAccessToken(idToken);
372
+ return getUserInfo();
373
+ })
374
+ .then(userInfo => {
375
+ const valid = detectUserInfoGroupAuth(userInfo);
376
+ if (!valid) {
377
+ clearRefreshTokenTimer();
378
+ openDialog();
379
+ return logout();
380
+ }
381
+ })
382
+ .catch(error => {
383
+ clearRefreshTokenTimer();
384
+ throw error;
385
+ });
386
+ }, 1e3 * 60 * 3); // 3 minutes
387
+ };
388
+ const logout = () => {
389
+ return fetchLogoutHTTP()
390
+ .finally(() => {
391
+ clearRefreshTokenTimer();
392
+ setAccessToken(null);
393
+ setRefreshToken(null);
394
+ });
395
+ };
396
+ const clearRefreshTokenTimer = () => {
397
+ if (!timer)
398
+ return;
399
+ clearInterval(timer);
400
+ timer = null;
401
+ };
402
+ return {
403
+ init,
404
+ logout
405
+ };
406
+ };
407
+
408
+ exports.clearLoginCookie = clearLoginCookie;
409
+ exports.getAccessToken = getAccessToken;
410
+ exports.getCookie = getCookie;
411
+ exports.getIdToken = getIdToken;
412
+ exports.getRefreshToken = getRefreshToken;
413
+ exports.getSystemType = getSystemType;
414
+ exports.getUrlParam = getUrlParam;
415
+ exports.getUserInfo = getUserInfo;
416
+ exports.isMobile = isMobile;
417
+ exports.make = make;
418
+ exports.setAccessToken = setAccessToken;
419
+ exports.setCookie = setCookie;
420
+ exports.setIdToken = setIdToken;
421
+ exports.setRefreshToken = setRefreshToken;
422
+ exports.setSystemType = setSystemType;
423
+
424
+ }));
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 这个文件是写一些兼容的方法,避免各个项目做出大量调整
3
+ */
4
+ export declare const setIdToken: (token: string | null) => void;
5
+ export declare const getIdToken: () => string | undefined;
6
+ export declare const setCookie: (name: string, value: string | undefined | null, domain: string, path?: string, time?: number) => void;
7
+ export declare const clearLoginCookie: () => void;
8
+ export declare const getCookie: (c_name: string) => string | null;
9
+ export declare const getUrlParam: (key: string, href?: string) => string | null;
10
+ //# sourceMappingURL=compatible.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compatible.d.ts","sourceRoot":"","sources":["../../src/compatible.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,eAAO,MAAM,UAAU,gCAAiB,CAAA;AACxC,eAAO,MAAM,UAAU,0BAAiB,CAAA;AAExC,eAAO,MAAM,SAAS,GACpB,MAAM,MAAM,EACZ,OAAO,MAAM,GAAG,SAAS,GAAG,IAAI,EAChC,QAAQ,MAAM,EACd,OAAM,MAAY,EAClB,aAA+B,SAUhC,CAAA;AACD,eAAO,MAAM,gBAAgB,YAG5B,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,kBAKvC,CAAA;AAGD,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,kBAMrD,CAAA"}
@@ -0,0 +1,8 @@
1
+ export declare const NO_ACCESS_TOKEN = "Access token not found";
2
+ export declare const INVALID_ACCESS_TOKEN = "Invalid access token";
3
+ export declare const INVALID_REFRESH_TOKEN = "Invalid refresh token";
4
+ export declare const NO_REFRESH_TOKEN = "Refresh token not found";
5
+ export declare const NO_MODULE_BASE_URL = "Module base URL is required";
6
+ export declare const INVALID_TENANT_ID = "Invalid tenant ID";
7
+ export declare const INVALID_BRAND = "Invalid brand";
8
+ //# sourceMappingURL=constance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constance.d.ts","sourceRoot":"","sources":["../../src/constance.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,2BAA2B,CAAA;AACvD,eAAO,MAAM,oBAAoB,yBAAyB,CAAA;AAC1D,eAAO,MAAM,qBAAqB,0BAA0B,CAAA;AAC5D,eAAO,MAAM,gBAAgB,4BAA4B,CAAA;AACzD,eAAO,MAAM,kBAAkB,gCAAgC,CAAA;AAC/D,eAAO,MAAM,iBAAiB,sBAAsB,CAAA;AACpD,eAAO,MAAM,aAAa,kBAAkB,CAAA"}
@@ -0,0 +1,8 @@
1
+ export type CookieKeys = 'access_token' | 'refresh_token' | 'idTokenFront' | 'idTokenBack' | 'refreshTokenFront' | 'refreshTokenBack' | 'currentSystemType';
2
+ export declare const setRefreshToken: (token: string | null) => void;
3
+ export declare const setAccessToken: (token: string | null) => void;
4
+ export declare const getAccessToken: () => string | undefined;
5
+ export declare const getRefreshToken: () => string | undefined;
6
+ export declare const setSystemType: (value: string | null) => void;
7
+ export declare const getSystemType: () => string | undefined;
8
+ //# sourceMappingURL=cookie.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../src/cookie.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GACpB,cAAc,GACZ,eAAe,GACf,cAAc,GACd,aAAa,GACb,mBAAmB,GACnB,kBAAkB,GAClB,mBAAmB,CAAA;AAyBvB,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,GAAG,IAAI,SAenD,CAAA;AACD,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,GAAG,IAAI,SAgBlD,CAAA;AAED,eAAO,MAAM,cAAc,0BAAmC,CAAA;AAC9D,eAAO,MAAM,eAAe,0BAAoC,CAAA;AAEhE,eAAO,MAAM,aAAa,UArDT,MAAM,GAAG,IAAI,SAqDmC,CAAA;AACjE,eAAO,MAAM,aAAa,0BAAwC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const closeDialog: () => void;
2
+ export declare const openDialog: () => void;
3
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/dom.ts"],"names":[],"mappings":"AAqCA,eAAO,MAAM,WAAW,YAKvB,CAAA;AAED,eAAO,MAAM,UAAU,YActB,CAAA"}
@@ -0,0 +1,36 @@
1
+ import type { ModuleName } from './types';
2
+ import type { AxiosPromise } from 'axios';
3
+ /**
4
+ * 没找到更好的方式,只能这样做了
5
+ */
6
+ export declare const initInstance: () => Promise<void>;
7
+ type RefreshTokenResponse = {
8
+ code: string;
9
+ msg: string;
10
+ content: {
11
+ accessToken: string;
12
+ expiresIn: number;
13
+ idToken: string;
14
+ newDeviceMetadata: null;
15
+ refreshToken: string;
16
+ tokenType: 'Bearer';
17
+ };
18
+ };
19
+ export declare const fetchRefreshTokenHTTP: (refreshToken: string) => AxiosPromise<RefreshTokenResponse>;
20
+ export declare const fetchLogoutHTTP: () => AxiosPromise<any>;
21
+ type Content = {
22
+ groupName: ModuleName;
23
+ icon: string;
24
+ id: number;
25
+ label: string;
26
+ staffEndpoint: boolean;
27
+ url: string;
28
+ };
29
+ type ServerListResponse = {
30
+ content: Array<Content>;
31
+ code: number;
32
+ totalElements: number;
33
+ };
34
+ export declare const fetchServerListHTTP: () => AxiosPromise<ServerListResponse>;
35
+ export {};
36
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAY,MAAM,SAAS,CAAA;AAEnD,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAA;AAKxD;;GAEG;AACH,eAAO,MAAM,YAAY,qBAuCxB,CAAA;AAED,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE;QACP,WAAW,EAAE,MAAM,CAAA;QACnB,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;QACf,iBAAiB,EAAE,IAAI,CAAA;QACvB,YAAY,EAAE,MAAM,CAAA;QACpB,SAAS,EAAE,QAAQ,CAAA;KACpB,CAAA;CACF,CAAA;AACD,eAAO,MAAM,qBAAqB,GAAI,cAAc,MAAM,KAOlD,YAAY,CAAC,oBAAoB,CACxC,CAAA;AAED,eAAO,MAAM,eAAe,yBAK3B,CAAA;AAED,KAAK,OAAO,GAAG;IACb,SAAS,EAAE,UAAU,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,OAAO,CAAA;IACtB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AACD,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AACD,eAAO,MAAM,mBAAmB,QAIxB,YAAY,CAAC,kBAAkB,CACtC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { Tenant, Brand } from './types';
2
+ export declare let tenantId: Tenant;
3
+ export declare let brand: Brand;
4
+ export declare let moduleBaseUrl: string;
5
+ export declare let loginPageUrl: string;
6
+ export declare const setTenantId: (id: Tenant) => void;
7
+ export declare const setBrand: (id: Brand) => void;
8
+ export declare const setModuleBaseUrl: (url: string) => void;
9
+ export declare const setLoginPageUrl: (url: string) => void;
10
+ //# sourceMappingURL=shares.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shares.d.ts","sourceRoot":"","sources":["../../src/shares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAGvC,eAAO,IAAI,QAAQ,EAAG,MAAM,CAAA;AAC5B,eAAO,IAAI,KAAK,EAAG,KAAK,CAAA;AACxB,eAAO,IAAI,aAAa,EAAE,MAAW,CAAA;AACrC,eAAO,IAAI,YAAY,EAAE,MAAW,CAAA;AAEpC,eAAO,MAAM,WAAW,GAAI,IAAI,MAAM,SAKrC,CAAA;AACD,eAAO,MAAM,QAAQ,GAAI,IAAI,KAAK,SAKjC,CAAA;AACD,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,SAE3C,CAAA;AACD,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,SAE1C,CAAA"}
@@ -0,0 +1,89 @@
1
+ declare const modules: readonly [{
2
+ readonly href: "";
3
+ readonly name: "commonLogin";
4
+ }, {
5
+ readonly href: "";
6
+ readonly name: "App";
7
+ }, {
8
+ readonly href: "";
9
+ readonly name: "Portal";
10
+ }, {
11
+ readonly href: "";
12
+ readonly name: "AgentPortal";
13
+ }, {
14
+ readonly href: "";
15
+ readonly name: "AdminPortal";
16
+ }, {
17
+ readonly href: "";
18
+ readonly name: "CRM";
19
+ }, {
20
+ readonly href: "";
21
+ readonly name: "Finance";
22
+ }, {
23
+ readonly href: "";
24
+ readonly name: "FundingAdmin";
25
+ }, {
26
+ readonly href: "";
27
+ readonly name: "MessageTemplate";
28
+ }, {
29
+ readonly href: "";
30
+ readonly name: "Translate";
31
+ }, {
32
+ readonly href: "";
33
+ readonly name: "TradeConfig";
34
+ }, {
35
+ readonly href: "";
36
+ readonly name: "Ticket";
37
+ }, {
38
+ readonly href: "";
39
+ readonly name: "IBPortalAdmin";
40
+ }, {
41
+ readonly href: "";
42
+ readonly name: "OPPortal";
43
+ }, {
44
+ readonly href: "";
45
+ readonly name: "ClientInfoHub";
46
+ }, {
47
+ readonly href: "";
48
+ readonly name: "Promotion";
49
+ }];
50
+ export type ModuleName = typeof modules[number]['name'];
51
+ export type UserInfo = {
52
+ 'aud': string;
53
+ 'aud_time': number;
54
+ 'cognito:groups': ModuleName[];
55
+ 'cognito:username': string;
56
+ 'custom:encrypt_email_var': string;
57
+ 'custom:tenant_id': Tenant;
58
+ 'custom:user_id': string;
59
+ 'email': string;
60
+ 'email_verified': boolean;
61
+ 'exp': number;
62
+ 'event_id': string;
63
+ 'iat': number;
64
+ 'iss': string;
65
+ 'jti': string;
66
+ 'origin_jti': string;
67
+ 'preferred_username': string;
68
+ 'sub': string;
69
+ 'token_use': string;
70
+ };
71
+ export declare enum Brand {
72
+ ZERO = 1,
73
+ HEDGEHOOD = 2,
74
+ NISE = 3
75
+ }
76
+ export declare enum Tenant {
77
+ ZERO_INT = 1,
78
+ HEDGEHOOD = 2,
79
+ ZERO_NZ = 3,
80
+ ZERO_LA = 4,
81
+ ZERO_BR = 4,
82
+ NISE_EU = 5
83
+ }
84
+ export declare enum SystemType {
85
+ Staff = "staff",
86
+ Client = "client"
87
+ }
88
+ export {};
89
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiEH,CAAA;AAEV,MAAM,MAAM,UAAU,GAAG,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvD,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,UAAU,EAAE,CAAA;IAC9B,kBAAkB,EAAE,MAAM,CAAA;IAC1B,0BAA0B,EAAE,MAAM,CAAA;IAClC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,gBAAgB,EAAE,MAAM,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,OAAO,CAAA;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,oBAAY,KAAK;IACf,IAAI,IAAI;IACR,SAAS,IAAI;IACb,IAAI,IAAI;CACT;AAED,oBAAY,MAAM;IAChB,QAAQ,IAAI;IACZ,SAAS,IAAI;IACb,OAAO,IAAI;IACX,OAAO,IAAI;IACX,OAAO,IAAI;IACX,OAAO,IAAI;CACZ;AAED,oBAAY,UAAU;IACpB,KAAK,UAAU;IACf,MAAM,WAAW;CAClB"}
@@ -0,0 +1,4 @@
1
+ import type { UserInfo } from './types';
2
+ export declare const isMobile: () => boolean;
3
+ export declare const getUserInfo: () => Promise<UserInfo>;
4
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAKvC,eAAO,MAAM,QAAQ,QAAM,OAG1B,CAAA;AAED,eAAO,MAAM,WAAW,QAAO,OAAO,CAAC,QAAQ,CAS9C,CAAA"}