@hautechai/sdk 0.0.9 → 0.0.11

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/dist/sdk/api.js CHANGED
@@ -38,7 +38,7 @@ export const createWebsocket = async (props) => {
38
38
  const pusherSettings = (await api.call({ run: (api) => api.websocketControllerGetSettingsV1() }));
39
39
  const pusher = new Pusher(pusherSettings.key, {
40
40
  channelAuthorization: {
41
- endpoint: `${baseUrl}/websocket/auth`,
41
+ endpoint: `${baseUrl}/v1/websocket/auth`,
42
42
  headers: {
43
43
  'Access-Control-Allow-Origin': '*',
44
44
  Authorization: `Bearer ${await props.options.authToken()}`,
package/dist/sdk/index.js CHANGED
@@ -3,7 +3,7 @@ import balances from './balances';
3
3
  import collections from './collections';
4
4
  import groups from './groups';
5
5
  import images from './images';
6
- import jwt from 'jsonwebtoken';
6
+ import { jwtDecode } from 'jwt-decode';
7
7
  import operations from './operations';
8
8
  import stacks from './stacks';
9
9
  import storage from './storage';
@@ -12,7 +12,7 @@ export const createSDK = (options) => {
12
12
  let token = undefined;
13
13
  const authToken = async () => {
14
14
  if (token) {
15
- const decoded = jwt.decode(token);
15
+ const decoded = jwtDecode(token);
16
16
  const currentTime = Math.floor(Date.now() / 1000);
17
17
  if (decoded.exp && decoded.exp > currentTime)
18
18
  return token;
@@ -8,8 +8,8 @@ export declare const createTokenSigner: (options: {
8
8
  accountId: string;
9
9
  expiresInSeconds: number;
10
10
  permissions?: Partial<MethodsPermissions>;
11
- }) => string;
11
+ }) => any;
12
12
  createRootToken: (props: {
13
13
  expiresInSeconds: number;
14
- }) => string;
14
+ }) => any;
15
15
  };
@@ -1,5 +1,4 @@
1
1
  import { defaultPermissions, defaultRootPermissions } from './permissions';
2
- import jwt from 'jsonwebtoken';
3
2
  const createPrivateKey = (key) => {
4
3
  const header = `-----BEGIN PRIVATE KEY-----\n`;
5
4
  const footer = `\n-----END PRIVATE KEY-----`;
@@ -7,7 +6,9 @@ const createPrivateKey = (key) => {
7
6
  const keyBody = key.match(/.{1,64}/g).join('\n');
8
7
  return header + keyBody + footer;
9
8
  };
9
+ // This function will not work in the browser
10
10
  const createToken = (props) => {
11
+ const jwt = require('jsonwebtoken');
11
12
  const privateKey = createPrivateKey(props.appKeySecret);
12
13
  return jwt.sign(props.payload, privateKey, {
13
14
  algorithm: 'RS256',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hautechai/sdk",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "license": "MIT",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -19,6 +19,7 @@
19
19
  "dependencies": {
20
20
  "axios": "1.6.1",
21
21
  "jsonwebtoken": "8.5.1",
22
+ "jwt-decode": "4.0.0",
22
23
  "pusher-js": "8.4.0-rc2"
23
24
  },
24
25
  "devDependencies": {