@ichaingo/auth 1.1.0 → 1.2.0

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,6 +1,6 @@
1
1
  import { default as LoginApi } from './loginApi';
2
2
  import { default as TokenManager } from '@ichaingo/token';
3
3
  export declare function logout(): void;
4
- export declare function fetchUserProfile(refresh?: boolean): Promise<any> | null;
4
+ export declare function fetchUserProfile(): Promise<any>;
5
5
  export { TokenManager, LoginApi };
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,YAA0C,MAAM,iBAAiB,CAAA;AACxE,wBAAgB,MAAM,SAwBrB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,UAAQ,uBAc/C;AAED,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,YAA0C,MAAM,iBAAiB,CAAA;AACxE,wBAAgB,MAAM,SAwBrB;AAED,wBAAgB,gBAAgB,iBAO/B;AAED,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAA"}
package/dist/index.mjs CHANGED
@@ -1,36 +1,33 @@
1
- import r from "@ichaingo/request";
2
- import { default as m } from "./loginApi.mjs";
3
- import { getToken as a, removeAllToken as i } from "@ichaingo/token";
1
+ import n from "@ichaingo/request";
2
+ import { default as p } from "./loginApi.mjs";
3
+ import { getToken as i, removeAllToken as r } from "@ichaingo/token";
4
4
  import { default as g } from "@ichaingo/token";
5
- function u() {
6
- r.get("/connect/logout", {
5
+ function c() {
6
+ n.get("/connect/logout", {
7
7
  params: {
8
- id_token_hint: a()
8
+ id_token_hint: i()
9
9
  }
10
- }).then((o) => {
11
- var t;
12
- if (((t = o == null ? void 0 : o.status) == null ? void 0 : t.code) === 0) {
13
- i();
14
- const e = document.createElement("iframe");
15
- e.src = `${process.env.NEXT_PUBLIC_AUTH_URL}/en/logout`, window.addEventListener("message", (n) => {
16
- n.data.type === "logout" && (e.remove(), window.location.pathname.includes("/user-center") ? window.location.replace(process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL || "/") : window.location.reload());
17
- }), e.style.display = "none", document.body.appendChild(e);
10
+ }).then((e) => {
11
+ var o;
12
+ if (((o = e == null ? void 0 : e.status) == null ? void 0 : o.code) === 0) {
13
+ r();
14
+ const t = document.createElement("iframe");
15
+ t.src = `${process.env.NEXT_PUBLIC_AUTH_URL}/en/logout`, window.addEventListener("message", (a) => {
16
+ a.data.type === "logout" && (t.remove(), window.location.pathname.includes("/user-center") ? window.location.replace(process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL || "/") : window.location.reload());
17
+ }), t.style.display = "none", document.body.appendChild(t);
18
18
  }
19
19
  });
20
20
  }
21
- function c(o = !1) {
22
- if (o)
23
- return r.get("/v2/users/profile").then((e) => {
24
- var n;
25
- if (((n = e == null ? void 0 : e.status) == null ? void 0 : n.code) === 0)
26
- return e.data;
27
- });
28
- const t = localStorage.getItem("userProfile");
29
- return t ? Promise.resolve(JSON.parse(t)) : null;
21
+ function u() {
22
+ return n.get("/v2/users/profile").then((e) => {
23
+ var o;
24
+ if (((o = e == null ? void 0 : e.status) == null ? void 0 : o.code) === 0)
25
+ return e.data;
26
+ });
30
27
  }
31
28
  export {
32
- m as LoginApi,
29
+ p as LoginApi,
33
30
  g as TokenManager,
34
- c as fetchUserProfile,
35
- u as logout
31
+ u as fetchUserProfile,
32
+ c as logout
36
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ichaingo/auth",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",
@@ -24,8 +24,8 @@
24
24
  ],
25
25
  "peerDependencies": {
26
26
  "js-cookie": "3.0.5",
27
- "@ichaingo/request": "1.1.0",
28
- "@ichaingo/token": "1.1.0"
27
+ "@ichaingo/request": "1.2.0",
28
+ "@ichaingo/token": "1.2.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/js-cookie": "^3.0.6",