@medipha/feed 0.2.9 → 0.3.1

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,5 +1,11 @@
1
1
  export interface NewsfeedModuleProps {
2
2
  accessToken: string;
3
+ /**
4
+ * When the access token expires, in epoch seconds (the JWT `exp` claim). Before every request the
5
+ * feed calls onRefreshToken if the token expires within 10 minutes, so the host must pass the new
6
+ * expireTime together with the new accessToken after refreshing.
7
+ */
8
+ expireTime?: number;
3
9
  apiUrl: string;
4
10
  chatApiUrl: string;
5
11
  basePath: string;
@@ -1,6 +1,6 @@
1
1
  import { FeedApi } from '../../core';
2
2
  import { NewsfeedModuleProps } from '../newsfeed-module.types';
3
- type SessionProps = Pick<NewsfeedModuleProps, 'accessToken' | 'onRefreshToken' | 'onUnauthorized'>;
3
+ type SessionProps = Pick<NewsfeedModuleProps, 'accessToken' | 'expireTime' | 'onRefreshToken' | 'onUnauthorized'>;
4
4
  export declare class FeedSession {
5
5
  readonly api: FeedApi;
6
6
  private props;
@@ -2,6 +2,8 @@ import { QueryParams } from './query-string';
2
2
  export interface FeedApiConfig {
3
3
  apiBaseUrl: string;
4
4
  getAccessToken: () => string | null;
5
+ /** Epoch seconds the host reports for the access token; unknown skips the early refresh. */
6
+ getExpireTime?: () => number | undefined;
5
7
  onRefreshToken?: () => Promise<string>;
6
8
  onUnauthorized?: () => void;
7
9
  fetchImpl?: typeof fetch;
@@ -0,0 +1,2 @@
1
+ /** True when the token expires within `bufferSeconds`. `expireTime` is epoch seconds (the JWT `exp`). */
2
+ export declare function isTokenExpired(expireTime: number, bufferSeconds?: number): boolean;