Skip to content

Commit 4307e64

Browse files
authored
chore(shared): Move logic to align with other SDKs and API logic (#5629)
1 parent 00f16e4 commit 4307e64

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

.changeset/dark-dragons-shop.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/shared/src/__tests__/jwtPayloadParser.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('JWTPayloadToAuthObjectProperties', () => {
4949
org_id: 'org_xxxxxxx',
5050
org_role: 'org:admin',
5151
org_slug: 'org_test',
52-
org_permissions: ['org:impersonation:manage', 'org:impersonation:read'],
52+
org_permissions: ['org:impersonation:read', 'org:impersonation:manage'],
5353
});
5454
expect(signedInAuthObjectV1).toEqual(signedInAuthObjectV2);
5555
});

packages/shared/src/jwtPayloadParser.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ export const parsePermissions = ({ per, fpm }: { per?: string; fpm?: string }) =
1212
return { permissions: [], featurePermissionMap: [] };
1313
}
1414

15-
const permissions = per
16-
.split(',')
17-
.map(p => p.trim())
18-
.reverse();
15+
const permissions = per.split(',').map(p => p.trim());
1916

2017
// TODO: make this more efficient
2118
const featurePermissionMap = fpm
@@ -26,7 +23,8 @@ export const parsePermissions = ({ per, fpm }: { per?: string; fpm?: string }) =
2623
.toString(2)
2724
.padStart(permissions.length, '0')
2825
.split('')
29-
.map(bit => Number.parseInt(bit, 10)),
26+
.map(bit => Number.parseInt(bit, 10))
27+
.reverse(),
3028
)
3129
.filter(Boolean);
3230

0 commit comments

Comments
 (0)