diff --git a/.changeset/sso-bypass-allowlist-circular-ref.md b/.changeset/sso-bypass-allowlist-circular-ref.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/sso-bypass-allowlist-circular-ref.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/clerk-js/src/core/resources/SSOBypassAllowlist.ts b/packages/clerk-js/src/core/resources/SSOBypassAllowlist.ts index 924f48c39c5..4addb975e7a 100644 --- a/packages/clerk-js/src/core/resources/SSOBypassAllowlist.ts +++ b/packages/clerk-js/src/core/resources/SSOBypassAllowlist.ts @@ -12,7 +12,11 @@ import { DeletedObject } from './DeletedObject'; import { SSOBypassAllowlistUser } from './SSOBypassAllowlistUser'; export class SSOBypassAllowlist implements SSOBypassAllowlistResource { - constructor(private readonly organization: { id: string }) {} + declare private readonly organization: { id: string }; + + constructor(organization: { id: string }) { + Object.defineProperty(this, 'organization', { value: organization, enumerable: false }); + } private get path(): string { return `/organizations/${this.organization.id}/sso_bypass_allowlist_users`; diff --git a/packages/clerk-js/src/core/resources/__tests__/Organization.test.ts b/packages/clerk-js/src/core/resources/__tests__/Organization.test.ts index bc0f0ef7665..674fba28e18 100644 --- a/packages/clerk-js/src/core/resources/__tests__/Organization.test.ts +++ b/packages/clerk-js/src/core/resources/__tests__/Organization.test.ts @@ -484,5 +484,12 @@ describe('Organization', () => { expect(result.id).toBe('user_1'); expect(result.deleted).toBe(true); }); + + it('does not create a cycle when the organization is serialized', () => { + const organization = createOrganization(); + + expect(() => JSON.stringify(organization)).not.toThrow(); + expect(JSON.parse(JSON.stringify(organization)).ssoBypassAllowlist).toEqual({}); + }); }); });