Skip to content

Commit 6d2eef3

Browse files
authored
Merge pull request #86 from anam-org/alpha
Release 2.1.1
2 parents 881ec72 + aa8143a commit 6d2eef3

File tree

5 files changed

+83
-4
lines changed

5 files changed

+83
-4
lines changed

package-lock.json

Lines changed: 65 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,8 @@
6262
"typescript-eslint": "^7.9.0",
6363
"webpack": "^5.91.0",
6464
"webpack-cli": "^5.1.4"
65+
},
66+
"dependencies": {
67+
"buffer": "^6.0.3"
6568
}
6669
}

src/AnamClient.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
StartSessionResponse,
1717
} from './types';
1818
import { TalkMessageStream } from './types/TalkMessageStream';
19-
19+
import { Buffer } from 'buffer';
2020
export default class AnamClient {
2121
private publicEventEmitter: PublicEventEmitter;
2222
private internalEventEmitter: InternalEventEmitter;
@@ -68,7 +68,10 @@ export default class AnamClient {
6868
private decodeJwt(token: string): any {
6969
try {
7070
const base64Payload = token.split('.')[1];
71-
const payload = JSON.parse(atob(base64Payload));
71+
const payloadString = Buffer.from(base64Payload, 'base64').toString(
72+
'utf8',
73+
);
74+
const payload = JSON.parse(payloadString);
7275
return payload;
7376
} catch (error) {
7477
throw new Error('Invalid session token format');

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ const unsafe_createClientWithApiKey = (
3636
};
3737

3838
export { createClient, unsafe_createClientWithApiKey };
39-
export type { AnamClient, PersonaConfig, AnamPublicClientOptions };
39+
export type { AnamClient };
40+
export * from './types';

webpack.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,13 @@ module.exports = {
2424
},
2525
resolve: {
2626
extensions: ['.ts', '.js', '.json'],
27+
fallback: {
28+
buffer: require.resolve('buffer/'),
29+
},
2730
},
31+
plugins: [
32+
new webpack.ProvidePlugin({
33+
Buffer: ['buffer', 'Buffer'],
34+
}),
35+
],
2836
};

0 commit comments

Comments
 (0)