Skip to content

Commit 1cbf506

Browse files
fix(clerk-js): Stop ssoBypassAllowlist from making Organization circular (#9828)
1 parent b7408ce commit 1cbf506

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

‎packages/clerk-js/src/core/resources/SSOBypassAllowlist.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import { DeletedObject } from './DeletedObject';
1212
import { SSOBypassAllowlistUser } from './SSOBypassAllowlistUser';
1313

1414
export class SSOBypassAllowlist implements SSOBypassAllowlistResource {
15-
constructor(private readonly organization: { id: string }) {}
15+
declare private readonly organization: { id: string };
16+
17+
constructor(organization: { id: string }) {
18+
Object.defineProperty(this, 'organization', { value: organization, enumerable: false });
19+
}
1620

1721
private get path(): string {
1822
return `/organizations/${this.organization.id}/sso_bypass_allowlist_users`;

‎packages/clerk-js/src/core/resources/__tests__/Organization.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,5 +484,12 @@ describe('Organization', () => {
484484
expect(result.id).toBe('user_1');
485485
expect(result.deleted).toBe(true);
486486
});
487+
488+
it('does not create a cycle when the organization is serialized', () => {
489+
const organization = createOrganization();
490+
491+
expect(() => JSON.stringify(organization)).not.toThrow();
492+
expect(JSON.parse(JSON.stringify(organization)).ssoBypassAllowlist).toEqual({});
493+
});
487494
});
488495
});

0 commit comments

Comments
 (0)