Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clerk-js,types): Update system permission names #1865

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fresh-news-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/clerk-js': patch
'@clerk/types': patch
---

Update default organization permissions with a `sys_` prefix as part of the entitlement. This changes makes it easy to distinguish between clerk reserved permissions and custom permissions created by developers.
6 changes: 3 additions & 3 deletions packages/clerk-js/src/core/resources/Session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('Session', () => {
updated_at: new Date().getTime(),
} as SessionJSON);

const isAuthorized = await session.isAuthorized({ permission: 'org:profile:delete' });
const isAuthorized = await session.isAuthorized({ permission: 'org:sys_profile:delete' });

expect(isAuthorized).toBe(true);
});
Expand All @@ -84,7 +84,7 @@ describe('Session', () => {
id: 'session_1',
object: 'session',
user: createUser({
organization_memberships: [{ name: 'Org1', id: 'org1', permissions: ['org:memberships:read'] }],
organization_memberships: [{ name: 'Org1', id: 'org1', permissions: ['org:sys_memberships:read'] }],
}),
last_active_organization_id: 'org1',
last_active_token: { object: 'token', jwt: mockJwt },
Expand All @@ -93,7 +93,7 @@ describe('Session', () => {
updated_at: new Date().getTime(),
} as SessionJSON);

const isAuthorized = await session.isAuthorized({ permission: 'org:profile:delete' });
const isAuthorized = await session.isAuthorized({ permission: 'org:sys_profile:delete' });

expect(isAuthorized).toBe(false);
});
Expand Down
16 changes: 8 additions & 8 deletions packages/clerk-js/src/core/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export const createOrganizationMembership = (params: OrgParams): OrganizationMem
public_metadata: {},
role: role || 'admin',
permissions: permissions || [
'org:domains:delete',
'org:domains:manage',
'org:domains:read',
'org:memberships:delete',
'org:memberships:manage',
'org:memberships:read',
'org:profile:delete',
'org:profile:manage',
'org:sys_domains:delete',
'org:sys_domains:manage',
'org:sys_domains:read',
'org:sys_memberships:delete',
'org:sys_memberships:manage',
'org:sys_memberships:read',
'org:sys_profile:delete',
'org:sys_profile:manage',
],
updated_at: new Date().getTime(),
} as OrganizationMembershipJSON;
Expand Down
16 changes: 8 additions & 8 deletions packages/types/src/organizationMembership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export interface OrganizationMembershipResource extends ClerkResource {
export type MembershipRole = 'admin' | 'basic_member' | 'guest_member';

export type OrganizationPermission =
| 'org:domains:manage'
| 'org:domains:delete'
| 'org:profile:manage'
| 'org:profile:delete'
| 'org:memberships:read'
| 'org:memberships:manage'
| 'org:memberships:delete'
| 'org:domains:read';
| 'org:sys_domains:manage'
| 'org:sys_domains:delete'
| 'org:sys_profile:manage'
| 'org:sys_profile:delete'
| 'org:sys_memberships:read'
| 'org:sys_memberships:manage'
| 'org:sys_memberships:delete'
| 'org:sys_domains:read';

export type UpdateOrganizationMembershipParams = {
role: MembershipRole;
Expand Down