@queekai/client-sdk
v0.3.1
Published
Official Queek storefront client SDK for auth and API requests.
Readme
Queek Client SDK
Lightweight browser-friendly SDK for /api/v1/client/auth/*.
Install
npm install @queekai/client-sdkBuild
npm run lint
npm run build
npm testPublishing a new version
Bump the version in
package.jsonfollowing semver (patch= bug fix,minor= new feature,major= breaking change):npm version patch # 0.3.0 → 0.3.1 npm version minor # 0.3.0 → 0.4.0 npm version major # 0.3.0 → 1.0.0This updates
package.json, commits the bump, and tags the commit.Login to npm (one-time, stored in keychain):
npm loginPublish (runs lint + build + tests automatically via
prepublishOnly):npm publishUpdate consumers (
queek_storefront, etc.) to the new version:# in queek_storefront pnpm update @queekai/client-sdk
Note: The package is scoped to
@queekaiand published as public ("publishConfig": { "access": "public" }). The npm account must be a member of thequeekainpm org.
Usage
import { createQueekClient, QueekSdkError } from '@queekai/client-sdk';
// External self-hosted storefront (requires client key)
const client = createQueekClient({
baseUrl: 'https://api.queek.com.ng/api/v1',
clientKey: 'qck_client_public_key_here',
});
// Queek-hosted storefront (key optional)
const hostedClient = createQueekClient({
baseUrl: 'https://api.queek.com.ng/api/v1',
vendorSlug: 'jonshop',
});
await client.auth.requestOtp({ phone: '+14155552671' });
try {
await client.auth.verifyOtp({ phone: '+14155552671', otpCode: '1234' });
} catch (error) {
if (error instanceof QueekSdkError && error.code === 'account_not_found') {
await client.auth.register({
firstName: 'Client',
lastName: 'User',
email: '[email protected]',
phone: '+14155552671',
otpCode: '1234',
});
} else {
throw error;
}
}
await client.auth.me();
await client.get('/client/store/info');
await client.get('/client/store/products');
await client.get('/client/store/collections');
await client.get('/client/store/promotions');
await client.auth.logout();Public Client Methods
client.get(path, options?)client.post(path, body, options?)client.put(path, body, options?)client.delete(path, options?)client.request(config)
Automatic Headers and Token Handling
- Sends
X-Client-Keywhen configured - Sends
X-Vendor-Slugwhen configured - Sends
X-Platform: storefronton every request - Sends
Authorization: Bearer <token>when access token exists - On
401, refreshes once and retries the original request once - If refresh fails, clears tokens and throws normalized auth error (
unauthenticated)
