@dimo-network/data-sdk 1.2.3 → 1.2.5

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.
@@ -0,0 +1 @@
1
+ export declare const decodeJwt: (token: string) => any;
@@ -0,0 +1,11 @@
1
+ import { jwtDecode } from "jwt-decode";
2
+ export const decodeJwt = (token) => {
3
+ try {
4
+ const decoded = jwtDecode(token);
5
+ return decoded;
6
+ }
7
+ catch (error) {
8
+ console.error('Failed to decode JWT', error);
9
+ return null;
10
+ }
11
+ };
@@ -0,0 +1 @@
1
+ export declare const decodePermissions: (permissionHex: string) => number[];
@@ -0,0 +1,12 @@
1
+ export const decodePermissions = (permissionHex) => {
2
+ const cleanHex = permissionHex.toLowerCase().replace("0x", "");
3
+ const permissionBits = BigInt("0x" + cleanHex);
4
+ const grantedPermissions = [];
5
+ for (let i = 0; i < 128; i++) {
6
+ const bitPair = (permissionBits >> BigInt(i * 2)) & BigInt(0b11);
7
+ if (bitPair === BigInt(0b11)) {
8
+ grantedPermissions.push(i);
9
+ }
10
+ }
11
+ return grantedPermissions;
12
+ };
@@ -0,0 +1,8 @@
1
+ import { decodeJwt } from './decodeJwt';
2
+ import { decodePermissions } from './decodePermissions';
3
+ export { decodeJwt, decodePermissions };
4
+ declare const _default: {
5
+ decodeJwt: (token: string) => any;
6
+ decodePermissions: (permissionHex: string) => number[];
7
+ };
8
+ export default _default;
@@ -0,0 +1,7 @@
1
+ import { decodeJwt } from './decodeJwt';
2
+ import { decodePermissions } from './decodePermissions';
3
+ export { decodeJwt, decodePermissions };
4
+ export default {
5
+ decodeJwt,
6
+ decodePermissions
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimo-network/data-sdk",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "DIMO Data SDK for JavaScript",
5
5
  "main": "dist/index.js",
6
6
  "author": "James Li",
@@ -31,6 +31,7 @@
31
31
  "dependencies": {
32
32
  "axios": "^1.6.7",
33
33
  "fs": "^0.0.1-security",
34
+ "jwt-decode": "^4.0.0",
34
35
  "rxjs": "^7.8.1",
35
36
  "web3": "^4.6.0"
36
37
  },
@@ -52,5 +53,8 @@
52
53
  "ts-jest": "^29.1.4",
53
54
  "typescript": "^5.4.5"
54
55
  },
56
+ "optionalDependencies": {
57
+ "@rollup/rollup-linux-x64-gnu": "*"
58
+ },
55
59
  "types": "./dist/index.d.ts"
56
60
  }