@customyai/provisioning
v0.1.1
Published
Customy Provisioning: create, find and clean up TEST users (identity provisioning) with an Access API key, over @customyai/core. Includes withEphemeralUsers for CI.
Maintainers
Readme
@customyai/provisioning
Identity provisioning for TEST users in Customy Access, with an Access API key of one environment. Sobre @customyai/core.
npm install @customyai/provisioning @customyai/coreimport { createProvisioning } from "@customyai/provisioning";
const provisioning = createProvisioning({
environment: "staging", // required, no default: the key belongs to ONE environment
baseUrl: process.env.CUSTOMY_ACCESS_URL!,
clientId: process.env.CUSTOMY_CLIENT_ID!,
clientSecret: process.env.CUSTOMY_CLIENT_SECRET!,
});
const { users } = await provisioning.testUsers.batch({ count: 3, emailDomain: "qa.example.com", reason: "e2e checkout run" });
await provisioning.users.upsert("qa-ana", { email: "[email protected]", password: "generate", reason: "manual QA account" });
await provisioning.testUsers.cleanup({ mine: true }, { reason: "end of QA session" });- Auth: client-credentials JWT (audience
customy-provisioning), cached in memory and renewed about 60 s before it expires.Customy-Environmenttravels on every request; a mismatch isCustomyEnvironmentMismatchError. - Writes: each logical call gets an
Idempotency-Key(override withidempotencyKey), reused on every retry. Retries happen only on 429 (honoursRetry-After), 5xx, network failures andIDEMPOTENCY_IN_PROGRESS, with exponential backoff and full jitter (retry: { maxAttempts }, default 3). Never on other 4xx. - Errors:
CustomyProvisioningError(code,status,requestId,details) and subclassesCustomyScopeError(.scope),CustomyEnvironmentMismatchError,CustomyAuthError,CustomyConflictError(.currentVersion),CustomyRateLimitError(.retryAfter),CustomyCapabilityDisabledError,CustomyValidationError. - Secrets: the client secret, bearer tokens,
credentials.passwordand signinlinkare scrubbed from error messages,toJSON,util.inspectand theonRequest/onResponsehooks. Generated passwords and links are returned once; an idempotent replay returnsnullwithredacted: true. - Edge-ready: global
fetchonly, no Node imports.
Tests: withEphemeralUsers
import { withEphemeralUsers } from "@customyai/provisioning/testing"; // also @customyai/sdk/testing
await withEphemeralUsers({ count: 2, client: provisioning, emailDomain: "qa.example.com" }, async ([buyer]) => {
await signIn(buyer.email, buyer.password);
}); // the batch is deleted in `finally`, even if the callback throwsephemeralUsersFixture(options) gives setup() / teardown() for any runner's beforeAll / afterAll.
