login-authorization-v2 2.0.0-beta.7 → 2.0.0-beta.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/dist/index.d.ts CHANGED
@@ -1,16 +1,18 @@
1
1
  export * from './src/cookie';
2
2
  export * from './src/compatible';
3
3
  export * from './src/utils';
4
- import { type ModuleName, type Tenant, type Brand } from './src/types';
4
+ import { Brand, type ModuleName, Tenant } from './src/types';
5
5
  type MakeFnParams = {
6
- brand: Brand;
7
- tenantId: Tenant;
8
6
  moduleName: ModuleName;
9
7
  moduleBaseUrl: string;
10
8
  loginPageUrl: string;
11
9
  };
10
+ type InitFnParams = {
11
+ brand?: Brand;
12
+ tenantId: Tenant;
13
+ };
12
14
  export declare const make: (config: MakeFnParams) => {
13
- init: () => Promise<{
15
+ init: (initConfig: InitFnParams) => Promise<{
14
16
  groupName: ModuleName;
15
17
  icon: string;
16
18
  id: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAO3B,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAiB,MAAM,aAAa,CAAA;AAIrF,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,QAAQ,YAAY;;;;;;;;;;CAqIxC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAO3B,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAc,MAAM,EAAiB,MAAM,aAAa,CAAA;AAGvF,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,QAAQ,YAAY;uBAUb,YAAY;;;;;;;;;CAmIvC,CAAA"}
package/dist/index.esm.js CHANGED
@@ -295,10 +295,10 @@ const make = (config) => {
295
295
  let timer = undefined;
296
296
  setModuleBaseUrl(config.moduleBaseUrl);
297
297
  setLoginPageUrl(config.loginPageUrl);
298
- setTenantId(config.tenantId);
299
- setBrand(config.brand);
300
298
  initInstance();
301
- const init = () => {
299
+ const init = (initConfig) => {
300
+ setTenantId(initConfig.tenantId);
301
+ setBrand(initConfig.brand || Brand.ZERO);
302
302
  const token = getAccessToken();
303
303
  const refreshToken = getRefreshToken();
304
304
  if (!token) {
@@ -319,18 +319,22 @@ const make = (config) => {
319
319
  }
320
320
  return fetchServerListHTTP();
321
321
  }))
322
- .catch(error => {
323
- openDialog();
324
- throw error;
325
- })
326
322
  .then(resp => {
327
323
  const menus = resp.data.content || [];
328
- if (menus.length <= 0)
329
- return Promise.reject();
330
324
  const group = menus.find(menu => menu.groupName === config.moduleName);
331
- if (group) {
332
- setSystemType(group.staffEndpoint ? SystemType.Staff : SystemType.Client);
325
+ if (menus.length <= 0) {
326
+ openDialog();
327
+ return Promise.reject();
328
+ }
329
+ if (config.moduleName === 'commonLogin') {
330
+ setupRefreshTokenTimer();
331
+ return Promise.resolve(menus);
332
+ }
333
+ if (!group) {
334
+ openDialog();
335
+ return Promise.reject();
333
336
  }
337
+ setSystemType(group.staffEndpoint ? SystemType.Staff : SystemType.Client);
334
338
  setupRefreshTokenTimer();
335
339
  return Promise.resolve(menus);
336
340
  })
package/dist/index.umd.js CHANGED
@@ -297,10 +297,10 @@
297
297
  let timer = undefined;
298
298
  setModuleBaseUrl(config.moduleBaseUrl);
299
299
  setLoginPageUrl(config.loginPageUrl);
300
- setTenantId(config.tenantId);
301
- setBrand(config.brand);
302
300
  initInstance();
303
- const init = () => {
301
+ const init = (initConfig) => {
302
+ setTenantId(initConfig.tenantId);
303
+ setBrand(initConfig.brand || Brand.ZERO);
304
304
  const token = getAccessToken();
305
305
  const refreshToken = getRefreshToken();
306
306
  if (!token) {
@@ -321,18 +321,22 @@
321
321
  }
322
322
  return fetchServerListHTTP();
323
323
  }))
324
- .catch(error => {
325
- openDialog();
326
- throw error;
327
- })
328
324
  .then(resp => {
329
325
  const menus = resp.data.content || [];
330
- if (menus.length <= 0)
331
- return Promise.reject();
332
326
  const group = menus.find(menu => menu.groupName === config.moduleName);
333
- if (group) {
334
- setSystemType(group.staffEndpoint ? SystemType.Staff : SystemType.Client);
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();
335
338
  }
339
+ setSystemType(group.staffEndpoint ? SystemType.Staff : SystemType.Client);
336
340
  setupRefreshTokenTimer();
337
341
  return Promise.resolve(menus);
338
342
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "login-authorization-v2",
4
- "version": "2.0.0-beta.7",
4
+ "version": "2.0.0-beta.9",
5
5
  "engines": {
6
6
  "node": "^20"
7
7
  },