@W-21207882: Adding support for SCAPI CORS preferences#231
Draft
amit-kumar8-sf wants to merge 1 commit intomainfrom
Draft
@W-21207882: Adding support for SCAPI CORS preferences#231amit-kumar8-sf wants to merge 1 commit intomainfrom
amit-kumar8-sf wants to merge 1 commit intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
scapi corscommands (get,set,delete) for managing Cross-Origin Resource Sharing (CORS) preferences via the SCAPI CORS Preferences API.SDK (
@salesforce/b2c-tooling-sdk)scapi-cors-v1.yamlOpenAPI spec and generated types (scapi-cors.generated.ts)createScapiCorsClientfactory withSCAPI_CORS_READ_SCOPES/SCAPI_CORS_RW_SCOPESscope constantsscapi-corsinmiddleware-registry.tsCLI (
@salesforce/b2c-cli)b2c scapi cors get— fetches CORS preferences for a site with table outputb2c scapi cors set— creates/replaces CORS preferences; validates--client-idagainst^[-a-zA-Z0-9]+$and each origin against<scheme>://<domain>.<tld>(no port, no path);--client-idserves as both OAuth credential and CORS body target per API specb2c scapi cors delete— deletes all CORS preferences for a site--site-idflag with 1–32 character length validation; consistentINFO/ERRORlog format for all parse-time and runtime errorscorssubtopic underscapiinpackage.jsonoclif config and i18n keysTests
packages/b2c-tooling-sdk/test/clients/scapi-cors.test.ts— 8 SDK client tests (GET/PUT/DELETE responses, auth header, error handling, scope constants)packages/b2c-cli/test/commands/scapi/cors/get.test.ts— 5 tests (missing config, empty/non-empty response, API error)packages/b2c-cli/test/commands/scapi/cors/set.test.ts— 10 tests (client-id pattern validation, origins port/path/no-scheme rejection, multi-invalid error, empty origins, request body shape, API error)packages/b2c-cli/test/commands/scapi/cors/delete.test.ts— 4 tests (success, siteId query param, missing site-id, API error)Documentation
docs/cli/scapi-cors.md— full CLI reference with flag tables, origin format rules, and output examplesdocs/.vitepress/config.mts— sidebar entry addedskills/b2c-cli/skills/b2c-scapi-cors/SKILL.md— agent skill with usage examplesTesting
pnpm --filter @salesforce/b2c-cli run test:agent,pnpm --filter @salesforce/b2c-tooling-sdk run test:agent)get,set, anddeleteagainst a live SCAPI CORS endpointclient-idpattern, invalid origins (port, path, bare hostname), andsite-idlength violationsDependencies
pnpm test)pnpm run format)