Skip to content

Commit dca7dc5

Browse files
Merge pull request #11 from talkjs/feat/jwt-auth
(Feat) Add JWT auth properties to session component
2 parents e76e4ad + 81e5bbd commit dca7dc5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Session.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ type SessionProps = UserProps &
1515
sessionRef?: React.MutableRefObject<Talk.Session | undefined>;
1616
desktopNotificationEnabled?: boolean;
1717
children?: ReactNode;
18+
token?: string;
19+
tokenFetcher?: () => Promise<string>;
1820
signature?: string;
1921
};
2022

@@ -26,6 +28,8 @@ export function Session(props: SessionProps) {
2628
userId,
2729
syncUser,
2830
appId,
31+
token,
32+
tokenFetcher,
2933
signature,
3034
sessionRef,
3135
desktopNotificationEnabled,
@@ -42,7 +46,7 @@ export function Session(props: SessionProps) {
4246
? syncUser()
4347
: syncUser ?? new Talk.User(userId);
4448

45-
const session = new Talk.Session({ appId, me, signature });
49+
const session = new Talk.Session({ appId, me, token, tokenFetcher, signature });
4650
setSession(session);
4751
if (sessionRef) {
4852
sessionRef.current = session;
@@ -52,7 +56,7 @@ export function Session(props: SessionProps) {
5256
// if appId or me changed, destroy (and then recreate) the entire
5357
// session.
5458
//
55-
// once the JSSDK supports proper progammatic user mutation, we can
59+
// once the JSSDK supports proper programmatic user mutation, we can
5660
// avoid recreating the session when `syncUser` changes.
5761
session.destroy();
5862
setSession(undefined);

0 commit comments

Comments
 (0)