mosquito-transport-js 0.3.7 → 0.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mosquito-transport-js",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Javascript web sdk for mosquito-transport (https://github.com/brainbehindx/mosquito-transport)",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.d.ts CHANGED
@@ -389,12 +389,12 @@ interface MTAuth {
389
389
  twitterSignin: () => Promise<SignupResult>;
390
390
  githubSignin: () => Promise<SignupResult>;
391
391
  listenVerifiedStatus: (callback?: (verified?: boolean) => void, onError?: (error?: ErrorResponse) => void) => () => void;
392
- listenAuthToken: (callback: (token: string) => void) => () => void;
393
- getAuthToken: () => Promise<string>;
394
- getRefreshToken: () => Promise<string>;
395
- getRefreshTokenData: () => Promise<RefreshTokenData>;
392
+ listenAuthToken: (callback: (token: string | null) => void) => () => void;
393
+ getAuthToken: () => Promise<string | null>;
394
+ getRefreshToken: () => Promise<string | undefined>;
395
+ getRefreshTokenData: () => Promise<RefreshTokenData | undefined>;
396
396
  parseToken: (token: string) => AuthData | RefreshTokenData;
397
- listenAuth: (callback: (auth: TokenEventData) => void) => () => void;
397
+ listenAuth: (callback: (auth: TokenEventData | null) => void) => () => void;
398
398
  getAuth: () => Promise<TokenEventData>;
399
399
  signOut: () => Promise<void>;
400
400
  forceRefreshToken: () => Promise<string>;
@@ -437,10 +437,14 @@ interface RefreshTokenData {
437
437
  uid: string;
438
438
  tokenID: string;
439
439
  isRefreshToken: true;
440
+ exp: number;
441
+ aud: string;
442
+ iss: string;
443
+ sub: string;
440
444
  }
441
445
 
442
446
  interface TokenEventData extends AuthData {
443
- tokenManager: TokenManager | null;
447
+ tokenManager: TokenManager;
444
448
  }
445
449
 
446
450
  interface TokenManager {
@@ -119,6 +119,12 @@ export default class MTAuth {
119
119
  return CacheStore.AuthStore[this.builder.projectUrl]?.refreshToken;
120
120
  }
121
121
 
122
+ getRefreshTokenData = async () => {
123
+ await awaitStore();
124
+ const { refreshToken } = CacheStore.AuthStore[this.builder.projectUrl] || {};
125
+ return refreshToken && parseToken(refreshToken);
126
+ }
127
+
122
128
  parseToken = (token) => parseToken(token);
123
129
 
124
130
  getAuthToken = () => new Promise(resolve => {
@@ -61,8 +61,8 @@ export const mfetch = async (input = '', init, config) => {
61
61
  if ('uglified' in rawHeader)
62
62
  throw '"uglified" in header is a reserved prop';
63
63
 
64
- if (isBaseUrl && !rawApproach)
65
- throw `please set { rawApproach: true } if you're trying to access different endpoint at "${input}"`;
64
+ // if (isBaseUrl && !rawApproach)
65
+ // throw `please set { rawApproach: true } if you're trying to access different endpoint at "${input}"`;
66
66
 
67
67
  if (body !== undefined) {
68
68
  if (