JavaScript/TypeScript SDK for CrydenSync's HTTP API. Works in browsers and Node — thin fetch wrapper, no dependencies.
npm install @crydensync/sdkimport { Cryden, CrydenError } from "@crydensync/sdk";
const cryden = new Cryden({ baseUrl: "https://auth.yourapp.com" });
await cryden.signUp("devray@example.com", "SecurePass123!");
await cryden.login("devray@example.com", "SecurePass123!");
// Auto-refreshes on an expired access token and retries once —
// you never manually manage token refresh.
const sessions = await cryden.listSessions();
try {
await cryden.login(email, password);
} catch (err) {
if (err instanceof CrydenError) {
switch (err.code) {
case "invalid_credentials": /* ... */ break;
case "account_locked": /* ... */ break;
case "rate_limited": /* ... */ break;
}
}
}Defaults to localStorage in a browser, an in-memory Map elsewhere (Node, SSR). Pass your own adapter for anything else (React Native, sessionStorage, encrypted storage):
const cryden = new Cryden({
baseUrl: "...",
storage: myCustomAdapter, // implements StorageAdapter: get/set/remove
});changePasswordclears locally stored tokens after success — the engine just revoked every session including the current one, so this matches real behavior, not an SDK choice.confirmEmailChangerequires no authentication — matches the API, since the user may click the link from an email client with no active session.- A failed silent refresh (expired or reused refresh token) clears stored tokens automatically. Catch the resulting error and redirect to login — the SDK doesn't retry beyond one refresh attempt.
npm install
npm run build # tsup for ESM/CJS bundles + tsc for type declarations
node smoketest/main.mjs http://localhost:8080 # run against a live api instanceMIT