Implements a wrapper class TokenRefreshingTopicClient that automatically refreshes disposable tokens and active topics subscriptions before tokens expire.
A standalone example exists in a single file under examples/web/cache/refresh-disposable-tokens.ts and can be run completely locally by using a localTokenVendingMachine() method, or can be run against a deployed TVM by passing the endpoint to the example code.
Sample output:
Callback A: User code processing message 77
Callback B: User code processing message 77
Callback A: User code processing message 78
Callback B: User code processing message 78
Disposable token expiring soon, refreshing topic client with new token
Callback A: User code processing message 79
Generated a disposable token that will expire at 2024-09-12T23:21:27.000Z
Refreshing in 19586 ms
Callback B: User code processing message 79
Callback A: User code processing message 80
Callback B: User code processing message 80
The existing Vite chat app was also updated to use the TokenRefreshingTopicClient. Also fixed some bugs with the TVM and web app setup while testing and updated the CSS to be more Momento-themed.
Closes https://github.com/momentohq/dev-eco-issue-tracker/issues/1013
Implements a wrapper class
TokenRefreshingTopicClient
that automatically refreshes disposable tokens and active topics subscriptions before tokens expire.A standalone example exists in a single file under
examples/web/cache/refresh-disposable-tokens.ts
and can be run completely locally by using alocalTokenVendingMachine()
method, or can be run against a deployed TVM by passing the endpoint to the example code.Sample output:
The existing Vite chat app was also updated to use the TokenRefreshingTopicClient. Also fixed some bugs with the TVM and web app setup while testing and updated the CSS to be more Momento-themed.