@cemiar/auth-sdk 1.0.2 → 1.0.3

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.
@@ -1,6 +1,6 @@
1
1
  import axios from "axios";
2
2
  import { createDefaultTokenStorage } from "./Storage.js";
3
- import { normalizeBaseUrl, isBrowser, tokenToClaim } from "../shared/Utils.js";
3
+ import { normalizeBaseUrl, isBrowser, tokenToClaimBrowser } from "../shared/Utils.js";
4
4
  const LOGIN_METHOD_STORAGE_KEY = "cemiar-auth-login-method";
5
5
  function parseAuds(auds) {
6
6
  return auds.map(a => a.trim()).filter(Boolean);
@@ -62,7 +62,7 @@ export class CemiarAuthClient {
62
62
  const accessToken = extractAccessToken(data);
63
63
  this.setAccessToken(accessToken);
64
64
  this.persistLoginMethod("emailCode");
65
- const claim = tokenToClaim(accessToken);
65
+ const claim = tokenToClaimBrowser(accessToken);
66
66
  return {
67
67
  email: claim.sub,
68
68
  displayName: claim.displayName
@@ -73,7 +73,7 @@ export class CemiarAuthClient {
73
73
  if (token) {
74
74
  this.setAccessToken(token);
75
75
  this.persistLoginMethod("microsoft");
76
- const claim = tokenToClaim(token);
76
+ const claim = tokenToClaimBrowser(token);
77
77
  return {
78
78
  email: claim.sub,
79
79
  displayName: claim.displayName
@@ -1,4 +1,5 @@
1
1
  import { Claim } from "./models/Claim.js";
2
2
  export declare function normalizeBaseUrl(url: string): string;
3
3
  export declare function tokenToClaim(token: string): Claim;
4
+ export declare function tokenToClaimBrowser(token: string): Claim;
4
5
  export declare const isBrowser: boolean;
@@ -10,4 +10,10 @@ export function tokenToClaim(token) {
10
10
  const parsed = JSON.parse(decoded);
11
11
  return parsed;
12
12
  }
13
+ export function tokenToClaimBrowser(token) {
14
+ const payload = token.split(".")[1];
15
+ const decoded = atob(payload);
16
+ const parsed = JSON.parse(decoded);
17
+ return parsed;
18
+ }
13
19
  export const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cemiar/auth-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Cemiar Auth integration helpers for web apps and APIs.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",