Skip to content
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
8 changes: 7 additions & 1 deletion packages/void/src/cli/platform-app-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ export async function prepareInstallationAppAccess(input: {
try {
return (await access.get('organizations')) as Record<string, unknown>;
} catch (error) {
if (error instanceof PlatformCloudflareApiError && error.status === 404) {
if (
error instanceof PlatformCloudflareApiError &&
(error.status === 404 ||
(choice === 'public' &&
error.status === 403 &&
error.message.startsWith('Cloudflare API error: access.api.error.not_enabled:')))
) {
return null;
}
throw error;
Expand Down
29 changes: 29 additions & 0 deletions packages/void/test/unit/platform-app-access.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,35 @@ describe('guided installation app access', () => {
expect(prompts.confirm).not.toHaveBeenCalled();
expect(prompts.password).not.toHaveBeenCalled();
});
it('allows unmanaged public apps when Cloudflare explicitly reports Access disabled', async () => {
const { input, fetcher } = fixture('public');
fetcher.mockResolvedValueOnce(
Response.json(
{
success: false,
errors: [{ code: 9999, message: 'access.api.error.not_enabled: Access is not enabled.' }],
},
{ status: 403 },
),
);
expect(JSON.parse(await prepareInstallationAppAccess(input))).toMatchObject({
mode: 'public',
managed: false,
});
expect(fetcher).toHaveBeenCalledOnce();
});
it('requires an explicit credential when Cloudflare denies the public Access check', async () => {
const { input, fetcher } = fixture('public');
fetcher.mockResolvedValueOnce(
Response.json(
{ success: false, errors: [{ code: 10000, message: 'Authentication error' }] },
{ status: 403 },
),
);
await expect(prepareInstallationAppAccess(input)).rejects.toThrow(
'VOID_PLATFORM_APP_ACCESS_TOKEN',
);
});
it('prepares managed public rules under Default-Deny without asking for company policies', async () => {
tty(true);
const { input } = fixture('public');
Expand Down