openvibers/openvibe.sdk Commits
Add universal wallet, store and items SDK clients (#151)
Changes
@@@ -1,5 +1,9 @@# Changelog++## 0.119.0 (2026-11-09)++++- openvibe-sdk/wallet: the wallet, Vibes, the store and items, through Billing and Inventory with the person's bearer and idempotency keys++## 0.118.0 (2026-11-09)- openvibe-sdk/design: `components()` and `component(name)` read OpenVibe.Design's public design.component@1 registry@@@ -10,7 +10,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags> Supported browser and server clients for the OpenVibe platform.--**Status:** alpha, v0.118.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.++**Status:** alpha, v0.119.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.@@@ -19,7 +19,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tagsAfter v0.97.1 is tagged:```bash--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.118.0++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.119.0```It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from the temporary Contracts sharing branch, a devDependency the tests check them against).@@@ -3,7 +3,7 @@"stage": "alpha","code": true,"wave": "W2",-- "version": "0.118.0",++ "version": "0.119.0","plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30","deployed": false,"deployment": "none: a package released as git tags; services and apps pin a tag",@@@ -6,6 +6,7 @@const core = require('./src/core');module.exports = {++ createWalletClient: require('./src/wallet').createWalletClient,...core,auth: require('./src/auth/browser'),locker: require('./src/locker'),@@@ -1,4 +1,4 @@--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.118.0, MIT). Do not edit.++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.119.0, MIT). Do not edit.// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces// (auth, locker, registry, trust, modules, realtime, media, cam, community, homeFeed, bot, search, bench, meme, vision, themes, design, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity./* eslint-disable */@@@ -13,32 +13,33 @@ function (module, exports) {const core = __load(1);module.exports = {++ createWalletClient: __load(8).createWalletClient,...core,-- auth: __load(8),-- locker: __load(9),-- registry: __load(20),-- trust: __load(21),-- modules: __load(22),-- realtime: __load(23),-- media: __load(24),-- cam: __load(26),-- community: __load(27),-- homeFeed: __load(28),-- bot: __load(29),-- search: __load(30),-- bench: __load(31),-- meme: __load(32),-- vision: __load(33),-- themes: __load(34),-- design: __load(35),-- redact: __load(36),-- chat: __load(37),-- ai: __load(38),-- credentials: __load(39),-- jobs: __load(40),-- tools: __load(42),-- projects: __load(43),-- geo: __load(44),++ auth: __load(9),++ locker: __load(10),++ registry: __load(21),++ trust: __load(22),++ modules: __load(23),++ realtime: __load(24),++ media: __load(25),++ cam: __load(27),++ community: __load(28),++ homeFeed: __load(29),++ bot: __load(30),++ search: __load(31),++ bench: __load(32),++ meme: __load(33),++ vision: __load(34),++ themes: __load(35),++ design: __load(36),++ redact: __load(37),++ chat: __load(38),++ ai: __load(39),++ credentials: __load(40),++ jobs: __load(41),++ tools: __load(43),++ projects: __load(44),++ geo: __load(45),};},// ── 1: src/core/index.js ───────────────────────────────────────────@@@ -53,7 +54,7 @@ const { paginate, offsetPager } = __load(7);const semver = __load(6);/** The package version (test/version.test.js keeps it equal to package.json). */--const SDK_VERSION = '0.118.0';++const SDK_VERSION = '0.119.0';module.exports = {createClient,@@@ -701,7 +702,56 @@ function offsetPager(load, { limit = 50 } = {}) {module.exports = { paginate, offsetPager };},--// ── 8: src/auth/browser.js ─────────────────────────────────────────++// ── 8: src/wallet.js ───────────────────────────────────────────────++function (module, exports) {++'use strict';++++/** Personal bearer wallet/store facade. Amounts and ownership are enforced by Billing and Inventory. */++function createWalletClient(client, { billingUrl, inventoryUrl } = {}) {++ if (!client || typeof client.json !== 'function') throw new TypeError('createWalletClient requires an SDK core client');++ const call = (service, path, opts = {}) => client.json({ service, baseUrl: service === 'billing' ? billingUrl : inventoryUrl,++ audience: `openvibe.${service}`, path, credentials: 'omit', ...opts });++ const key = (v) => {++ if (typeof v !== 'string' || !/^[A-Za-z0-9._:-]{8,128}$/.test(v)) throw new TypeError('An idempotency_key of 8–128 letters, digits, dot, colon, underscore or dash is required');++ return v;++ };++ const whole = (v) => { if (!Number.isSafeInteger(v) || v < 1) throw new TypeError('Choose a positive whole amount'); return v; };++ const itemId = (v) => { if (!/^itd_[0-9A-HJKMNP-TV-Z]{26}$/.test(v || '')) throw new TypeError('An item id is an itd_ id'); return encodeURIComponent(v); };++ // The BODY key is durable in both services. Retries keep it; the SDK must not add an unrelated header key.++ const write = (service, path, json, { signal } = {}) => call(service, path, { method: 'POST', json,++ idempotencyKey: false, idempotent: true, signal });++ return {++ wallet: {++ get: ({ signal } = {}) => call('billing', '/api/v1/me/wallet', { signal }),++ topUp: ({ provider, amount_cents, idempotency_key }, options) => write('billing', '/api/v1/me/wallet/topups',++ { provider, amount_cents: whole(amount_cents), idempotency_key: key(idempotency_key) }, options),++ },++ vibes: {++ buy: ({ provider, vibes, idempotency_key }, options) => write('billing', '/api/v1/me/vibes/buy',++ { provider, vibes: whole(vibes), idempotency_key: key(idempotency_key) }, options),++ },++ store: {++ list: ({ signal } = {}) => call('inventory', '/api/v1/store', { signal }),++ buy: (id, { currency, idempotency_key }, options) => {++ if (!['coins', 'vibes'].includes(currency)) throw new TypeError('currency is coins or vibes');++ return write('inventory', `/api/v1/store/${itemId(id)}/buy`, { currency, idempotency_key: key(idempotency_key) }, options);++ },++ submit: (id, prices, { signal } = {}) => call('inventory', `/api/v1/store/${itemId(id)}/list`,++ { method: 'POST', json: { prices }, idempotencyKey: false, retries: 0, signal }),++ },++ items: {++ list: ({ cursor, limit, kind, signal } = {}) => call('inventory', '/api/v1/me/items', { query: { cursor, limit, kind }, signal }),++ equip: ({ kind, slot, instance_id }, { signal } = {}) => {++ if (instance_id !== null && !/^inv_[0-9A-HJKMNP-TV-Z]{26}$/.test(instance_id || '')) throw new TypeError('instance_id is an inv_ id, or null to unequip');++ return call('inventory', '/api/v1/me/equipped', { method: 'PUT', json: { kind, slot, instance_id }, signal });++ },++ },++ };++}++++module.exports = { createWalletClient };++},++// ── 9: src/auth/browser.js ─────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -844,16 +894,16 @@ function unverifiedClaims(token) {module.exports = { createPkcePair, createState, buildAuthorizeUrl, startAuthorization, readCallback, base64url, decodeUnverified, unverifiedClaims };},--// ── 9: src/locker.js ───────────────────────────────────────────────++// ── 10: src/locker.js ───────────────────────────────────────────────function (module, exports) {'use strict';/*** openvibe-sdk/locker: the subpath entry. The format, the three locks, the streams and the* keys. WebCrypto only, in Node and in the browser.*/--module.exports = __load(10);++module.exports = __load(11);},--// ── 10: src/locker/index.js ─────────────────────────────────────────++// ── 11: src/locker/index.js ─────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -867,14 +917,14 @@ function (module, exports) {* const sealed = await seal('a note', { lock: 'people', keys: [{ subject, publicKey: person.ecdhPublic }] });* const note = await open(sealed, { privateKey: person.ecdh.privateKey, subject });*/--const format = __load(11);--const keys = __load(15);--const seal = __load(17);--const { padme } = __load(14);--const { inspect } = __load(18);--const { recoveryWords, isRecoveryPhrase, RECOVERY_WORDS } = __load(19);--const { WORDS } = __load(16);--const { LockerError } = __load(13);++const format = __load(12);++const keys = __load(16);++const seal = __load(18);++const { padme } = __load(15);++const { inspect } = __load(19);++const { recoveryWords, isRecoveryPhrase, RECOVERY_WORDS } = __load(20);++const { WORDS } = __load(17);++const { LockerError } = __load(14);module.exports = {// The format.@@@ -925,7 +975,7 @@ module.exports = {LockerError,};},--// ── 11: src/locker/format.js ────────────────────────────────────────++// ── 12: src/locker/format.js ────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -944,9 +994,9 @@ function (module, exports) {* | len | flags| nonce (12 bytes) | ciphertext + 16-byte tag |* +------+------+--------------------------+--------------------------+*/--const { utf8, fromUtf8, concat, base64, fromBase64, u32be, readU32be, canonicalJson } = __load(12);--const { fail } = __load(13);--const { padme } = __load(14);++const { utf8, fromUtf8, concat, base64, fromBase64, u32be, readU32be, canonicalJson } = __load(13);++const { fail } = __load(14);++const { padme } = __load(15);/** The four bytes that say "this is a Locker envelope". */const MAGIC = 'OVLK';@@@ -1074,7 +1124,7 @@ module.exports = {chunkCount, lastChunkSize, paddedSize, chunkNonce, encodeChunk, nonceBaseBytes,};},--// ── 12: src/locker/bytes.js ─────────────────────────────────────────++// ── 13: src/locker/bytes.js ─────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -1163,7 +1213,7 @@ module.exports = {u32be, readU32be, u64be, readU64be, canonicalJson,};},--// ── 13: src/locker/errors.js ────────────────────────────────────────++// ── 14: src/locker/errors.js ────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -1189,7 +1239,7 @@ function fail(code, message) { throw new LockerError(code, message); }module.exports = { LockerError, fail };},--// ── 14: src/locker/padme.js ─────────────────────────────────────────++// ── 15: src/locker/padme.js ─────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -1240,7 +1290,7 @@ function padme(size) {module.exports = { padme, exponentOf };},--// ── 15: src/locker/keys.js ──────────────────────────────────────────++// ── 16: src/locker/keys.js ──────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -1250,9 +1300,9 @@ function (module, exports) {* WebCrypto only: globalThis.crypto.subtle. No other crypto library, nothing hand-rolled: the* ECDH, the ECDSA, the HKDF, the PBKDF2 and the AES-GCM are all the browser's own.*/--const { utf8, concat, base64, base64url, fromBase64, canonicalJson } = __load(12);--const { fail } = __load(13);--const { WORDS } = __load(16);++const { utf8, concat, base64, base64url, fromBase64, canonicalJson } = __load(13);++const { fail } = __load(14);++const { WORDS } = __load(17);/** The suite of the key pairs: P-256, which every browser's WebCrypto has. */const CURVE = 'P-256';@@@ -1608,7 +1658,7 @@ module.exports = {peopleSlotAad, passwordSlotAad, wrapFor, unwrapPeopleSlot, wrapForPassword, unwrapPasswordSlot,};},--// ── 16: src/locker/words.js ─────────────────────────────────────────++// ── 17: src/locker/words.js ─────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -1658,7 +1708,7 @@ const WORDS = [module.exports = { WORDS };},--// ── 17: src/locker/seal.js ──────────────────────────────────────────++// ── 18: src/locker/seal.js ──────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -1670,17 +1720,17 @@ function (module, exports) {*/const {utf8, fromUtf8, concat, base64, base64url, fromBase64url, u32be, readU32be, u64be, readU64be,--} = __load(12);--const { fail } = __load(13);++} = __load(13);++const { fail } = __load(14);const {MAGIC, VERSION, SUITE, CHUNK_SIZE, TAG_SIZE, NONCE_BASE_SIZE, LENGTH_PREFIX, MIN_PADDED_SIZE,FINAL_FLAG, coreOf, chunkAad, encodeHeader, encodeEnvelope, readHeader, chunkCount,lastChunkSize, paddedSize, chunkNonce, encodeChunk, nonceBaseBytes,--} = __load(11);++} = __load(12);const {KEY_BYTES, PASSWORD_ITERATIONS, subtle, platformRandom, importContentKey, publicJwk,jwkThumbprint, wrapFor, unwrapPeopleSlot, wrapForPassword, unwrapPasswordSlot, resolveEphemeral,--} = __load(15);++} = __load(16);/** The content as bytes: a string is UTF-8, anything else is taken as it is. */function toBytes(content) {@@@ -2268,7 +2318,7 @@ module.exports = {publicKeyOf, privateKeyOf, slotForPerson,};},--// ── 18: src/locker/inspect.js ───────────────────────────────────────++// ── 19: src/locker/inspect.js ───────────────────────────────────────function (module, exports) {'use strict';/**@@@ -2281,8 +2331,8 @@ function (module, exports) {* The header holds no content, only wrapped keys, so this says nothing the server does not* already see.*/--const { envelopeBytes, readCore } = __load(17);--const { readHeader } = __load(11);++const { envelopeBytes, readCore } = __load(18);++const { readHeader } = __load(12);/*** What an envelope says about itself.@@@ -2314,7 +2364,7 @@ function inspect(bytes) {module.exports = { inspect };},--// ── 19: src/locker/recovery.js ──────────────────────────────────────++// ── 20: src/locker/recovery.js ──────────────────────────────────────function (module, exports) {'use strict';/**@@@ -2328,9 +2378,9 @@ function (module, exports) {* wrong simply does not open anything. isRecoveryPhrase only says whether every word is one of* the 256, so a UI can tell a typo from a word that was never in the list.*/--const { fail } = __load(13);--const { platformRandom } = __load(15);--const { WORDS } = __load(16);++const { fail } = __load(14);++const { platformRandom } = __load(16);++const { WORDS } = __load(17);/** How many words a recovery phrase has, unless the caller says otherwise. */const RECOVERY_WORDS = 24;@@@ -2365,7 +2415,7 @@ function isRecoveryPhrase(phrase) {module.exports = { RECOVERY_WORDS, recoveryWords, isRecoveryPhrase };},--// ── 20: src/registry.js ─────────────────────────────────────────────++// ── 21: src/registry.js ─────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -2402,7 +2452,7 @@ function createRegistryClient(client, { baseUrl } = {}) {module.exports = { createRegistryClient };},--// ── 21: src/trust.js ────────────────────────────────────────────────++// ── 22: src/trust.js ────────────────────────────────────────────────function (module, exports) {'use strict';@@@ -2460,7 +2510,7 @@ function atLeast(signals, band) {module.exports = { createTrustClient, isNew, atLeast, AGE_BANDS };},--// ── 22: src/modules.js ──────────────────────────────────────────────++// ── 23: src/modules.js ──────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -2539,7 +2589,7 @@ function createModulesClient(client, { baseUrl, maxAttempts = 5 } = {}) {module.exports = { createModulesClient };},--// ── 23: src/realtime.js ─────────────────────────────────────────────++// ── 24: src/realtime.js ─────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -2792,7 +2842,7 @@ function createRealtimeClient(client, defaults = {}) {module.exports = { subscribe, createRealtimeClient, parseSSE, DEFAULT_ORIGIN };},--// ── 24: src/media.js ────────────────────────────────────────────────++// ── 25: src/media.js ────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -2814,7 +2864,7 @@ function (module, exports) {*/const { isOpenVibeError } = __load(3);const { paginate, offsetPager } = __load(7);--const { createObjectsClient } = __load(25);++const { createObjectsClient } = __load(26);const DEFAULT_PUBLIC_ORIGIN = 'https://openvibe.media';const enc = encodeURIComponent;@@@ -2906,7 +2956,7 @@ function createMediaClient(client, { app, apiKey, actingUserId, baseUrl, publicOmodule.exports = { createMediaClient, createObjectsClient, mediaUrls, DEFAULT_PUBLIC_ORIGIN };},--// ── 25: src/objects.js ──────────────────────────────────────────────++// ── 26: src/objects.js ──────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3225,7 +3275,7 @@ function createObjectsClient({module.exports = { createObjectsClient };},--// ── 26: src/cam/index.js ────────────────────────────────────────────++// ── 27: src/cam/index.js ────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3318,7 +3368,7 @@ function defineOvCamera(options = {}) {module.exports = { defineOvCamera, OV_CAMERA_SRC, CAM_KIT_SRC, CAM_KIT_SRI, loadCamKit, open };},--// ── 27: src/community.js ────────────────────────────────────────────++// ── 28: src/community.js ────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3453,7 +3503,7 @@ function createCommunityClient(client, defaults = {}) {module.exports = { createCommunityClient, actingHeaders };},--// ── 28: src/home-feed.js ────────────────────────────────────────────++// ── 29: src/home-feed.js ────────────────────────────────────────────function (module, exports) {'use strict';/** The menu's portable Home layout, network day counts and personal wall. Pass a user-token core client;@@@ -3480,7 +3530,7 @@ function createHomeFeedClient(client, { networkBaseUrl, communityBaseUrl } = {})module.exports = { createHomeFeedClient };},--// ── 29: src/bot.js ──────────────────────────────────────────────────++// ── 30: src/bot.js ──────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3702,7 +3752,7 @@ function createBotClient(client, defaults = {}) {module.exports = { createBotClient, actingHeaders };},--// ── 30: src/search.js ───────────────────────────────────────────────++// ── 31: src/search.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3815,7 +3865,7 @@ function createSearchClient(client, defaults = {}) {module.exports = { createSearchClient, queryOf, fabricOf };},--// ── 31: src/bench.js ────────────────────────────────────────────────++// ── 32: src/bench.js ────────────────────────────────────────────────function (module, exports) {'use strict';/** openvibe-sdk/bench: OpenVibe.Bench's JSON API and streamed open dataset. Browser-safe. */@@@ -3916,7 +3966,7 @@ function createBenchClient(client, defaults = {}) {module.exports = { createBenchClient };},--// ── 32: src/meme.js ─────────────────────────────────────────────────++// ── 33: src/meme.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -3984,7 +4034,7 @@ function createMemeClient(client, defaults = {}) {module.exports = { createMemeClient };},--// ── 33: src/vision.js ───────────────────────────────────────────────++// ── 34: src/vision.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4142,7 +4192,7 @@ function pick(o, keys) {module.exports = { createVisionClient, DEFAULT_AUDIENCE };},--// ── 34: src/themes.js ───────────────────────────────────────────────++// ── 35: src/themes.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4292,7 +4342,7 @@ function followTheme(fn, opts = {}) {module.exports = { createThemesClient, followTheme, readTheme, applyTheme, seasonOn, onColor, DISPLAY_OPTIONS, TOKENS };},--// ── 35: src/design.js ───────────────────────────────────────────────++// ── 36: src/design.js ───────────────────────────────────────────────function (module, exports) {'use strict';@@@ -4359,7 +4409,7 @@ function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL,module.exports = { createDesignClient, DEFAULT_DESIGN_URL };},--// ── 36: src/redact.js ───────────────────────────────────────────────++// ── 37: src/redact.js ───────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4606,7 +4656,7 @@ function onlySecret(text) {module.exports = { redact, onlySecret };},--// ── 37: src/chat.js ─────────────────────────────────────────────────++// ── 38: src/chat.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4854,7 +4904,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {module.exports = { createChatClient, createInboxVisitor, createFeedPublisher };},--// ── 38: src/ai.js ───────────────────────────────────────────────────++// ── 39: src/ai.js ───────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -4986,7 +5036,7 @@ function createAiClient(client, defaults = {}) {module.exports = { createAiClient, TERMINAL, OPS, CLASSES };},--// ── 39: src/credentials.js ──────────────────────────────────────────++// ── 40: src/credentials.js ──────────────────────────────────────────function (module, exports) {'use strict';@@@ -5004,7 +5054,7 @@ function createCredentialsClient(client, defaults = {}) {module.exports = { createCredentialsClient };},--// ── 40: src/jobs.js ─────────────────────────────────────────────────++// ── 41: src/jobs.js ─────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5042,8 +5092,8 @@ function (module, exports) {*/const { OpenVibeError, isOpenVibeError } = __load(3);const { newIdempotencyKey } = __load(5);--const { appendFiles } = __load(41);--const { parseSSE } = __load(23);++const { appendFiles } = __load(42);++const { parseSSE } = __load(24);const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);const TERMINAL_EVENTS = new Set(['job.succeeded', 'job.failed', 'job.cancelled']);@@@ -5206,7 +5256,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'openmodule.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };},--// ── 41: src/core/form.js ────────────────────────────────────────────++// ── 42: src/core/form.js ────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5240,7 +5290,7 @@ function appendFiles(form, list, where) {module.exports = { isBlob, isUpload, appendFiles };},--// ── 42: src/tools.js ────────────────────────────────────────────────++// ── 43: src/tools.js ────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5274,8 +5324,8 @@ function (module, exports) {*/const { OpenVibeError, isOpenVibeError } = __load(3);const { newIdempotencyKey } = __load(5);--const { isUpload, appendFiles } = __load(41);--const { createJobsClient } = __load(40);++const { isUpload, appendFiles } = __load(42);++const { createJobsClient } = __load(41);const enc = encodeURIComponent;const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;@@@ -5535,7 +5585,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'opemodule.exports = { createToolsClient, ToolRunError, isToolRunError };},--// ── 43: src/projects.js ─────────────────────────────────────────────++// ── 44: src/projects.js ─────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5651,7 +5701,7 @@ function createProjectsClient(client, { baseUrl } = {}) {module.exports = { createProjectsClient };},--// ── 44: src/geo.js ──────────────────────────────────────────────────++// ── 45: src/geo.js ──────────────────────────────────────────────────function (module, exports) {'use strict';/**@@@ -5727,12 +5777,13 @@ function __load(i) {const sdk = __load(0);export const {-- createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager, parseTraceparent,-- startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey, isActingSubjectId,-- satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION, auth,-- locker, registry, trust, modules, realtime, media,-- cam, community, homeFeed, bot, search, bench,-- meme, vision, themes, design, redact, chat,-- ai, credentials, jobs, tools, projects, geo,++ createWalletClient, createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager,++ parseTraceparent, startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey,++ isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,++ auth, locker, registry, trust, modules, realtime,++ media, cam, community, homeFeed, bot, search,++ bench, meme, vision, themes, design, redact,++ chat, ai, credentials, jobs, tools, projects,++ geo,} = sdk;export default sdk;@@@ -120,6 +120,7 @@]},"createClient": "function",++ "createWalletClient": "function","credentials": {"object": ["createCredentialsClient"@@@ -1191,6 +1192,9 @@"DEFAULT_AUDIENCE": "string","createVisionClient": "function"},++ "openvibe-sdk/wallet": {++ "createWalletClient": "function"++ },"openvibe-sdk/wiki": {"createWikiClient": "function"},nnew file mode 100644@@@ -0,0 +1,21 @@++# Universal wallet and store++++```js++import { createClient, createWalletClient } from 'openvibe-sdk';++const ov = createWalletClient(createClient({ tokenProvider }));++const wallet = await ov.wallet.get();++const { items } = await ov.store.list();++const purchase = await ov.store.buy(items[0].id, {++ currency: 'vibes', idempotency_key: crypto.randomUUID(),++});++const owned = await ov.items.list();++await ov.items.equip({ kind: 'live.hat', slot: 'hat', instance_id: owned.instances[0].id });++// instance_id: null clears a slot.++const checkout = await ov.wallet.topUp({ provider: 'stripe', amount_cents: 1000, idempotency_key: crypto.randomUUID() });++// Or: ov.vibes.buy({ provider: 'stripe', vibes: 100, idempotency_key: crypto.randomUUID() }).++// Navigate checkout.checkout_url in the same tab after checking it is an HTTPS URL.++```++++Use a person's Network bearer for wallet, buys and items. All calls omit cookies, even if the core client defaults to including them. Choose providers and amounts from wallet.checkout; the service computes actual prices. Keep the same idempotency_key for retries of one intent, including across a page reload after an uncertain outcome. Never generate a new key to retry a purchase. The client preserves the body's key during automatic network retries and forwards neither a price override nor another subject.++++An issuer's service/app client may call ov.store.submit(itemId, {vibes:100,coins:200}) with inventory.store.list. Prices shown here are examples. Staff must review before the listing is visible. Billing remains the payment authority and reads OpenCoins from Network. Enable the companion Billing/Inventory endpoints and pin the companion Contracts capability release before rollout. Browser CSP must permit Billing and Inventory in connect-src.@@@ -2,18 +2,18 @@import cjs from '../index.js';export const {-- createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager, parseTraceparent,-- startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey, isActingSubjectId,-- satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION, report,-- share, locker, auth, registry, identity, trust,-- modules, events, realtime, media, cam, community,-- homeFeed, bot, search, bench, meme, vision,-- themes, design, redact, chat, chatApps, ai,-- credentials, jobs, tools, projects, resources, vip,-- quest, live, inventory, tips, blog, reviews,-- wiki, coupons, deals, shoes, trade, space,-- host, news, food, actor, run, video,-- work, zone, play, download, openre, geo,-- usage, commerce, telemetry,++ createWalletClient, createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager,++ parseTraceparent, startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey,++ isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,++ report, share, locker, auth, registry, identity,++ trust, modules, events, realtime, media, cam,++ community, homeFeed, bot, search, bench, meme,++ vision, themes, design, redact, chat, chatApps,++ ai, credentials, jobs, tools, projects, resources,++ vip, quest, live, inventory, tips, blog,++ reviews, wiki, coupons, deals, shoes, trade,++ space, host, news, food, actor, run,++ video, work, zone, play, download, openre,++ geo, usage, commerce, telemetry,} = cjs;export default cjs;nnew file mode 100644@@@ -0,0 +1,7 @@++// Generated by scripts/esm.js from src/wallet.js. Do not edit.++import cjs from '../src/wallet.js';++++export const {++ createWalletClient,++} = cjs;++export default cjs;@@@ -7,6 +7,7 @@const core = require('./src/core');module.exports = {++ createWalletClient: require('./src/wallet').createWalletClient,...core,report: require('./src/report'),share: require('./src/share').share,@@@ -1,12 +1,12 @@{"name": "openvibe-sdk",-- "version": "0.118.0",++ "version": "0.119.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openvibe-sdk",-- "version": "0.118.0",++ "version": "0.119.0","license": "MIT","bin": {"openvibe-download": "bin/openvibe-download.js"@@@ -1,6 +1,6 @@{"name": "openvibe-sdk",-- "version": "0.118.0",++ "version": "0.119.0","description": "Supported browser and server clients for the OpenVibe platform: auth (incl. developer apps), registry discovery, identity, user modules, events, realtime, media, community, Bot robots, search, chat, AI runs, Tools (registry, run API and jobs), VIP memberships and developer projects, the async PostgreSQL data layer (db) and the Valkey cache, limits store, queue and pub/sub, with deadlines, safe retries, problem errors and trace propagation.","main": "index.js","types": "types/index.d.ts",@@@ -551,6 +551,12 @@"browser": null,"import": "./esm/compute.mjs","default": "./src/compute/index.js"++ },++ "./wallet": {++ "types": "./types/wallet.d.ts",++ "browser": "./src/wallet.js",++ "import": "./esm/wallet.mjs",++ "default": "./src/wallet.js"}},"bin": {@@@ -12,6 +12,7 @@ const path = require('path');const ROOT = path.join(__dirname, '..');const ENTRIES = {++ 'wallet.mjs': '../src/wallet.js','compute.mjs': '../src/compute/index.js','share.mjs': '../src/share.js','locker.mjs': '../src/locker.js',@@@ -8,7 +8,7 @@ const { paginate, offsetPager } = require('./paginate');const semver = require('./semver');/** The package version (test/version.test.js keeps it equal to package.json). */--const SDK_VERSION = '0.118.0';++const SDK_VERSION = '0.119.0';module.exports = {createClient,nnew file mode 100644@@@ -0,0 +1,46 @@++'use strict';++++/** Personal bearer wallet/store facade. Amounts and ownership are enforced by Billing and Inventory. */++function createWalletClient(client, { billingUrl, inventoryUrl } = {}) {++ if (!client || typeof client.json !== 'function') throw new TypeError('createWalletClient requires an SDK core client');++ const call = (service, path, opts = {}) => client.json({ service, baseUrl: service === 'billing' ? billingUrl : inventoryUrl,++ audience: `openvibe.${service}`, path, credentials: 'omit', ...opts });++ const key = (v) => {++ if (typeof v !== 'string' || !/^[A-Za-z0-9._:-]{8,128}$/.test(v)) throw new TypeError('An idempotency_key of 8–128 letters, digits, dot, colon, underscore or dash is required');++ return v;++ };++ const whole = (v) => { if (!Number.isSafeInteger(v) || v < 1) throw new TypeError('Choose a positive whole amount'); return v; };++ const itemId = (v) => { if (!/^itd_[0-9A-HJKMNP-TV-Z]{26}$/.test(v || '')) throw new TypeError('An item id is an itd_ id'); return encodeURIComponent(v); };++ // The BODY key is durable in both services. Retries keep it; the SDK must not add an unrelated header key.++ const write = (service, path, json, { signal } = {}) => call(service, path, { method: 'POST', json,++ idempotencyKey: false, idempotent: true, signal });++ return {++ wallet: {++ get: ({ signal } = {}) => call('billing', '/api/v1/me/wallet', { signal }),++ topUp: ({ provider, amount_cents, idempotency_key }, options) => write('billing', '/api/v1/me/wallet/topups',++ { provider, amount_cents: whole(amount_cents), idempotency_key: key(idempotency_key) }, options),++ },++ vibes: {++ buy: ({ provider, vibes, idempotency_key }, options) => write('billing', '/api/v1/me/vibes/buy',++ { provider, vibes: whole(vibes), idempotency_key: key(idempotency_key) }, options),++ },++ store: {++ list: ({ signal } = {}) => call('inventory', '/api/v1/store', { signal }),++ buy: (id, { currency, idempotency_key }, options) => {++ if (!['coins', 'vibes'].includes(currency)) throw new TypeError('currency is coins or vibes');++ return write('inventory', `/api/v1/store/${itemId(id)}/buy`, { currency, idempotency_key: key(idempotency_key) }, options);++ },++ submit: (id, prices, { signal } = {}) => call('inventory', `/api/v1/store/${itemId(id)}/list`,++ { method: 'POST', json: { prices }, idempotencyKey: false, retries: 0, signal }),++ },++ items: {++ list: ({ cursor, limit, kind, signal } = {}) => call('inventory', '/api/v1/me/items', { query: { cursor, limit, kind }, signal }),++ equip: ({ kind, slot, instance_id }, { signal } = {}) => {++ if (instance_id !== null && !/^inv_[0-9A-HJKMNP-TV-Z]{26}$/.test(instance_id || '')) throw new TypeError('instance_id is an inv_ id, or null to unequip');++ return call('inventory', '/api/v1/me/equipped', { method: 'PUT', json: { kind, slot, instance_id }, signal });++ },++ },++ };++}++++module.exports = { createWalletClient };@@@ -72,7 +72,7 @@ run([})().catch((err) => { console.error(err); process.exit(1); });`;const res = execFileSync(process.execPath, ['-e', script], { cwd: app, encoding: 'utf8' });assert.match(res, new RegExp(`consumer ok: ${subpaths.length} subpaths \\+ the browser bundle`));-- assert.equal(subpaths.length, 95); // Adds the Shoes product client.++ assert.equal(subpaths.length, 96); // Adds the wallet client (0.119.0).assert.ok(!fs.existsSync(path.join(app, 'node_modules/openvibe-contracts')), 'the optional peer is not installed');} finally {fs.rmSync(tmp, { recursive: true, force: true });nnew file mode 100644@@@ -0,0 +1,38 @@++'use strict';++const assert = require('assert');++const { createClient } = require('../src/core');++const { createWalletClient } = require('../src/wallet');++++(async () => {++ const calls = []; let retry = true;++ const client = createClient({ token: 'person-token', baseUrls: { billing: 'https://billing.test', inventory: 'https://inventory.test' },++ credentials: 'include', retries: 1, retryDelayMs: 1, fetch: async (url, init) => {++ calls.push({ url, ...init, json: init.body ? JSON.parse(init.body) : null });++ if (retry && url.endsWith('/buy')) { retry = false; return new Response(JSON.stringify({ detail: 'retry' }), { status: 503 }); }++ return new Response(JSON.stringify({ ok: true }), { status: 200, headers: { 'Content-Type': 'application/json' } });++ } });++ const ov = createWalletClient(client);++ await ov.wallet.get();++ await ov.wallet.topUp({ provider: 'stripe', amount_cents: 1000, idempotency_key: 'topup-test-01', subject: 'ignored' });++ await ov.vibes.buy({ provider: 'stripe', vibes: 100, idempotency_key: 'vibes-test-01', amount_cents: 1 });++ await ov.store.list();++ const id = 'itd_' + '0'.repeat(25) + '1';++ await ov.store.buy(id, { currency: 'coins', idempotency_key: 'store-test-01', price: 1 });++ await ov.items.list({ limit: 20 });++ await ov.items.equip({ kind: 'live.hat', slot: 'hat', instance_id: null });++ for (const call of calls) {++ assert.strictEqual(call.credentials, 'omit');++ assert.strictEqual(call.headers.get('Authorization'), 'Bearer person-token');++ assert(!call.json || !('price' in call.json) && !('subject' in call.json));++ }++ const vibes = calls.filter((c) => c.url.endsWith('/vibes/buy'));++ assert.strictEqual(vibes.length, 2); assert.deepStrictEqual(vibes[0].json, vibes[1].json);++ assert.strictEqual(vibes[0].headers.get('Idempotency-Key'), null);++ assert(!('amount_cents' in vibes[0].json));++ assert.strictEqual(calls.at(-1).method, 'PUT');++ assert.throws(() => ov.store.buy('../evil', { currency: 'coins', idempotency_key: 'safe-key-01' }));++ assert.throws(() => ov.store.buy(id, { currency: 'USD', idempotency_key: 'safe-key-01' }));++ assert.throws(() => ov.vibes.buy({ provider: 'stripe', vibes: 1.5, idempotency_key: 'safe-key-01' }));++ assert.throws(() => ov.wallet.topUp({ provider: 'stripe', amount_cents: 1000 }));++ console.log('wallet facade: routes, personal bearer, no cookies, stable retry keys and no price/subject injection');++})().catch((e) => { console.error(e); process.exitCode = 1; });@@@ -25,6 +25,7 @@ import * as geo from './geo';import * as locker from './locker';import * as trust from './trust';import * as core from './core';++export const createWalletClient: typeof import('./wallet').createWalletClient;export * from './core';export * as auth from './auth-browser';@@@ -54,6 +55,7 @@ export * as locker from './locker';export * as trust from './trust';declare const sdk: typeof core & {++ createWalletClient: typeof createWalletClient;auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;media: typeof media; cam: typeof cam; community: typeof community; homeFeed: typeof homeFeed; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; design: typeof design; redact: typeof redact; chat: typeof chat; ai: typeof ai; credentials: typeof credentials; jobs: typeof jobs; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust;};@@@ -59,3 +59,5 @@ export * as commerce from './commerce';export * as telemetry from './telemetry';export const share: typeof import('./share').share;export * as locker from './locker';++++export const createWalletClient: typeof import('./wallet').createWalletClient;nnew file mode 100644@@@ -0,0 +1,19 @@++import type { OpenVibeClient } from './core';++++export interface WalletBalance { label: string; amount: string; currency: 'USD' | 'opencoins' | 'vibes-bits'; scale: 0 | 9; purpose: string; action: string; held?: string; }++export interface Wallet {++ subject: { type: 'user'; id: string }; currency: 'USD'; money_writes_frozen: boolean; used_ai_this_month: boolean;++ balances: { coins: WalletBalance; vibes: WalletBalance; balance: WalletBalance }; bits_per_usd: number;++ recent_activity: Array<{ id: string; at: string; kind: 'coins' | 'vibes' | 'balance'; amount: string; label: string; detail: string; site: string }>;++ checkout: { providers: string[]; vibes: { minimum: number; maximum: number; price_tiers: Array<{ min: number; usd_per_bit: number }> }; topup: { enabled: boolean; amounts_cents: number[]; fee_bps: number | null } };++}++export interface StoreItem { id: string; name: string; description: string; issuer: string; prices: { coins?: number; vibes?: number }; preview: { emoji?: string; token?: string; media_id?: string }; kind: string; slots: string[]; surfaces: Array<{ surface: string; renderer?: string }>; owned: boolean; available: boolean; }++export interface Purchase { id: string; subject: string; item_id: string; name: string; issuer: string; currency: 'coins' | 'vibes'; amount: number; status: 'pending' | 'fulfilled'; instance_id: string | null; payment_id: string | null; }++export interface Checkout { intent: Record<string, unknown>; checkout_url: string | null; }++type Options = { signal?: AbortSignal };++export function createWalletClient(client: OpenVibeClient, options?: { billingUrl?: string; inventoryUrl?: string }): {++ wallet: { get(options?: Options): Promise<Wallet>; topUp(input: { provider: string; amount_cents: number; idempotency_key: string }, options?: Options): Promise<Checkout> };++ vibes: { buy(input: { provider: string; vibes: number; idempotency_key: string }, options?: Options): Promise<Checkout> };++ store: { list(options?: Options): Promise<{ items: StoreItem[] }>; buy(id: string, input: { currency: 'coins' | 'vibes'; idempotency_key: string }, options?: Options): Promise<Purchase>; submit(id: string, prices: { coins?: number; vibes?: number }, options?: Options): Promise<{ definition_id: string; issuer: string; prices: { coins?: number; vibes?: number }; status: 'in_review' }> };++ items: { list(options?: Options & { cursor?: string; limit?: number; kind?: string }): Promise<{ subject: string; instances: import('./inventory').Instance[]; definitions: Record<string, import('./inventory').Definition>; next_cursor: string | null }>; equip(input: { kind: string; slot: string; instance_id: string | null }, options?: Options): Promise<import('./inventory').EquippedSet> };++};
@@ -1,5 +1,9 @@
@@ -1,5 +1,9 @@
# Changelog
# Changelog
+## 0.119.0 (2026-11-09)
+
+- openvibe-sdk/wallet: the wallet, Vibes, the store and items, through Billing and Inventory with the person's bearer and idempotency keys
+
## 0.118.0 (2026-11-09)
## 0.118.0 (2026-11-09)
- openvibe-sdk/design: `components()` and `component(name)` read OpenVibe.Design's public design.component@1 registry
- openvibe-sdk/design: `components()` and `component(name)` read OpenVibe.Design's public design.component@1 registry
@@ -10,7 +10,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
@@ -10,7 +10,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
> Supported browser and server clients for the OpenVibe platform.
> Supported browser and server clients for the OpenVibe platform.
-**Status:** alpha, v0.118.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.
+**Status:** alpha, v0.119.0 (the five 1.0 core entries — `core`, `auth`, `events`, `db` and `media` — are frozen: their exported names change only with a major release; roadmap Wave 2; developer apps from Wave 20; Media objects v2 from Wave 4; the Tools platform API; Search, Chat, AI, Vision and consent clients; sign-in with recovery and a client health check). Every release is tagged (see [CHANGELOG.md](CHANGELOG.md)). Tested against local stub servers and the built-in mock platform only, never against the live platform. Services pin release tags; each repository's `STATUS.json` names the one it uses.
**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.
**Plan:** OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30.
**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.
**License:** MIT ([LICENSE](LICENSE)). This package is a library that apps outside the network embed, so it uses MIT. The OpenVibe services themselves stay AGPL-3.0.
@@ -19,7 +19,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
@@ -19,7 +19,7 @@ npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags
After v0.97.1 is tagged:
After v0.97.1 is tagged:
```bash
```bash
-npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.118.0
+npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.119.0
```
```
It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from the temporary Contracts sharing branch, a devDependency the tests check them against).
It has no runtime dependencies. It needs Node ≥ 20, or any browser with `fetch`, Web Crypto and `TextDecoder`. There is no build step. The package is CommonJS with ESM entry points (`import` works). Each subpath has its own `.d.ts`. For a page with no bundler, `browser/openvibe-sdk.mjs` is one self-contained ES module of the browser-safe subpaths (see [Browser without a bundler](#browser-without-a-bundler)). It does not depend on `openvibe-contracts` at runtime: it copies the contract types it uses (from the temporary Contracts sharing branch, a devDependency the tests check them against).
@@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
"stage": "alpha",
"stage": "alpha",
"code": true,
"code": true,
"wave": "W2",
"wave": "W2",
- "version": "0.118.0",
+ "version": "0.119.0",
"plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30",
"plan": "OpenVibe End-to-End Realignment & Implementation Plan, revision 3 (20 Sep 2026), §3.2; roadmap §30",
"deployed": false,
"deployed": false,
"deployment": "none: a package released as git tags; services and apps pin a tag",
"deployment": "none: a package released as git tags; services and apps pin a tag",
@@ -6,6 +6,7 @@
@@ -6,6 +6,7 @@
const core = require('./src/core');
const core = require('./src/core');
module.exports = {
module.exports = {
+ createWalletClient: require('./src/wallet').createWalletClient,
...core,
...core,
auth: require('./src/auth/browser'),
auth: require('./src/auth/browser'),
locker: require('./src/locker'),
locker: require('./src/locker'),
@@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
-// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.118.0, MIT). Do not edit.
+// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.119.0, MIT). Do not edit.
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// One self-contained ES module: core at the top level plus the browser-safe subpaths as namespaces
// (auth, locker, registry, trust, modules, realtime, media, cam, community, homeFeed, bot, search, bench, meme, vision, themes, design, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
// (auth, locker, registry, trust, modules, realtime, media, cam, community, homeFeed, bot, search, bench, meme, vision, themes, design, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
/* eslint-disable */
/* eslint-disable */
@@ -13,32 +13,33 @@ function (module, exports) {
@@ -13,32 +13,33 @@ function (module, exports) {
const core = __load(1);
const core = __load(1);
module.exports = {
module.exports = {
+ createWalletClient: __load(8).createWalletClient,
...core,
...core,
- auth: __load(8),
- locker: __load(9),
- registry: __load(20),
- trust: __load(21),
- modules: __load(22),
- realtime: __load(23),
- media: __load(24),
- cam: __load(26),
- community: __load(27),
- homeFeed: __load(28),
- bot: __load(29),
- search: __load(30),
- bench: __load(31),
- meme: __load(32),
- vision: __load(33),
- themes: __load(34),
- design: __load(35),
- redact: __load(36),
- chat: __load(37),
- ai: __load(38),
- credentials: __load(39),
- jobs: __load(40),
- tools: __load(42),
- projects: __load(43),
- geo: __load(44),
+ auth: __load(9),
+ locker: __load(10),
+ registry: __load(21),
+ trust: __load(22),
+ modules: __load(23),
+ realtime: __load(24),
+ media: __load(25),
+ cam: __load(27),
+ community: __load(28),
+ homeFeed: __load(29),
+ bot: __load(30),
+ search: __load(31),
+ bench: __load(32),
+ meme: __load(33),
+ vision: __load(34),
+ themes: __load(35),
+ design: __load(36),
+ redact: __load(37),
+ chat: __load(38),
+ ai: __load(39),
+ credentials: __load(40),
+ jobs: __load(41),
+ tools: __load(43),
+ projects: __load(44),
+ geo: __load(45),
};
};
},
},
// ── 1: src/core/index.js ───────────────────────────────────────────
// ── 1: src/core/index.js ───────────────────────────────────────────
@@ -53,7 +54,7 @@ const { paginate, offsetPager } = __load(7);
@@ -53,7 +54,7 @@ const { paginate, offsetPager } = __load(7);
const semver = __load(6);
const semver = __load(6);
/** The package version (test/version.test.js keeps it equal to package.json). */
/** The package version (test/version.test.js keeps it equal to package.json). */
-const SDK_VERSION = '0.118.0';
+const SDK_VERSION = '0.119.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -701,7 +702,56 @@ function offsetPager(load, { limit = 50 } = {}) {
@@ -701,7 +702,56 @@ function offsetPager(load, { limit = 50 } = {}) {
module.exports = { paginate, offsetPager };
module.exports = { paginate, offsetPager };
},
},
-// ── 8: src/auth/browser.js ─────────────────────────────────────────
+// ── 8: src/wallet.js ───────────────────────────────────────────────
+function (module, exports) {
+'use strict';
+
+/** Personal bearer wallet/store facade. Amounts and ownership are enforced by Billing and Inventory. */
+function createWalletClient(client, { billingUrl, inventoryUrl } = {}) {
+ if (!client || typeof client.json !== 'function') throw new TypeError('createWalletClient requires an SDK core client');
+ const call = (service, path, opts = {}) => client.json({ service, baseUrl: service === 'billing' ? billingUrl : inventoryUrl,
+ audience: `openvibe.${service}`, path, credentials: 'omit', ...opts });
+ const key = (v) => {
+ if (typeof v !== 'string' || !/^[A-Za-z0-9._:-]{8,128}$/.test(v)) throw new TypeError('An idempotency_key of 8–128 letters, digits, dot, colon, underscore or dash is required');
+ return v;
+ };
+ const whole = (v) => { if (!Number.isSafeInteger(v) || v < 1) throw new TypeError('Choose a positive whole amount'); return v; };
+ const itemId = (v) => { if (!/^itd_[0-9A-HJKMNP-TV-Z]{26}$/.test(v || '')) throw new TypeError('An item id is an itd_ id'); return encodeURIComponent(v); };
+ // The BODY key is durable in both services. Retries keep it; the SDK must not add an unrelated header key.
+ const write = (service, path, json, { signal } = {}) => call(service, path, { method: 'POST', json,
+ idempotencyKey: false, idempotent: true, signal });
+ return {
+ wallet: {
+ get: ({ signal } = {}) => call('billing', '/api/v1/me/wallet', { signal }),
+ topUp: ({ provider, amount_cents, idempotency_key }, options) => write('billing', '/api/v1/me/wallet/topups',
+ { provider, amount_cents: whole(amount_cents), idempotency_key: key(idempotency_key) }, options),
+ },
+ vibes: {
+ buy: ({ provider, vibes, idempotency_key }, options) => write('billing', '/api/v1/me/vibes/buy',
+ { provider, vibes: whole(vibes), idempotency_key: key(idempotency_key) }, options),
+ },
+ store: {
+ list: ({ signal } = {}) => call('inventory', '/api/v1/store', { signal }),
+ buy: (id, { currency, idempotency_key }, options) => {
+ if (!['coins', 'vibes'].includes(currency)) throw new TypeError('currency is coins or vibes');
+ return write('inventory', `/api/v1/store/${itemId(id)}/buy`, { currency, idempotency_key: key(idempotency_key) }, options);
+ },
+ submit: (id, prices, { signal } = {}) => call('inventory', `/api/v1/store/${itemId(id)}/list`,
+ { method: 'POST', json: { prices }, idempotencyKey: false, retries: 0, signal }),
+ },
+ items: {
+ list: ({ cursor, limit, kind, signal } = {}) => call('inventory', '/api/v1/me/items', { query: { cursor, limit, kind }, signal }),
+ equip: ({ kind, slot, instance_id }, { signal } = {}) => {
+ if (instance_id !== null && !/^inv_[0-9A-HJKMNP-TV-Z]{26}$/.test(instance_id || '')) throw new TypeError('instance_id is an inv_ id, or null to unequip');
+ return call('inventory', '/api/v1/me/equipped', { method: 'PUT', json: { kind, slot, instance_id }, signal });
+ },
+ },
+ };
+}
+
+module.exports = { createWalletClient };
+},
+// ── 9: src/auth/browser.js ─────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -844,16 +894,16 @@ function unverifiedClaims(token) {
@@ -844,16 +894,16 @@ function unverifiedClaims(token) {
module.exports = { createPkcePair, createState, buildAuthorizeUrl, startAuthorization, readCallback, base64url, decodeUnverified, unverifiedClaims };
module.exports = { createPkcePair, createState, buildAuthorizeUrl, startAuthorization, readCallback, base64url, decodeUnverified, unverifiedClaims };
},
},
-// ── 9: src/locker.js ───────────────────────────────────────────────
+// ── 10: src/locker.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
* openvibe-sdk/locker: the subpath entry. The format, the three locks, the streams and the
* openvibe-sdk/locker: the subpath entry. The format, the three locks, the streams and the
* keys. WebCrypto only, in Node and in the browser.
* keys. WebCrypto only, in Node and in the browser.
*/
*/
-module.exports = __load(10);
+module.exports = __load(11);
},
},
-// ── 10: src/locker/index.js ─────────────────────────────────────────
+// ── 11: src/locker/index.js ─────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -867,14 +917,14 @@ function (module, exports) {
@@ -867,14 +917,14 @@ function (module, exports) {
* const sealed = await seal('a note', { lock: 'people', keys: [{ subject, publicKey: person.ecdhPublic }] });
* const sealed = await seal('a note', { lock: 'people', keys: [{ subject, publicKey: person.ecdhPublic }] });
* const note = await open(sealed, { privateKey: person.ecdh.privateKey, subject });
* const note = await open(sealed, { privateKey: person.ecdh.privateKey, subject });
*/
*/
-const format = __load(11);
-const keys = __load(15);
-const seal = __load(17);
-const { padme } = __load(14);
-const { inspect } = __load(18);
-const { recoveryWords, isRecoveryPhrase, RECOVERY_WORDS } = __load(19);
-const { WORDS } = __load(16);
-const { LockerError } = __load(13);
+const format = __load(12);
+const keys = __load(16);
+const seal = __load(18);
+const { padme } = __load(15);
+const { inspect } = __load(19);
+const { recoveryWords, isRecoveryPhrase, RECOVERY_WORDS } = __load(20);
+const { WORDS } = __load(17);
+const { LockerError } = __load(14);
module.exports = {
module.exports = {
// The format.
// The format.
@@ -925,7 +975,7 @@ module.exports = {
@@ -925,7 +975,7 @@ module.exports = {
LockerError,
LockerError,
};
};
},
},
-// ── 11: src/locker/format.js ────────────────────────────────────────
+// ── 12: src/locker/format.js ────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -944,9 +994,9 @@ function (module, exports) {
@@ -944,9 +994,9 @@ function (module, exports) {
* | len | flags| nonce (12 bytes) | ciphertext + 16-byte tag |
* | len | flags| nonce (12 bytes) | ciphertext + 16-byte tag |
* +------+------+--------------------------+--------------------------+
* +------+------+--------------------------+--------------------------+
*/
*/
-const { utf8, fromUtf8, concat, base64, fromBase64, u32be, readU32be, canonicalJson } = __load(12);
-const { fail } = __load(13);
-const { padme } = __load(14);
+const { utf8, fromUtf8, concat, base64, fromBase64, u32be, readU32be, canonicalJson } = __load(13);
+const { fail } = __load(14);
+const { padme } = __load(15);
/** The four bytes that say "this is a Locker envelope". */
/** The four bytes that say "this is a Locker envelope". */
const MAGIC = 'OVLK';
const MAGIC = 'OVLK';
@@ -1074,7 +1124,7 @@ module.exports = {
@@ -1074,7 +1124,7 @@ module.exports = {
chunkCount, lastChunkSize, paddedSize, chunkNonce, encodeChunk, nonceBaseBytes,
chunkCount, lastChunkSize, paddedSize, chunkNonce, encodeChunk, nonceBaseBytes,
};
};
},
},
-// ── 12: src/locker/bytes.js ─────────────────────────────────────────
+// ── 13: src/locker/bytes.js ─────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -1163,7 +1213,7 @@ module.exports = {
@@ -1163,7 +1213,7 @@ module.exports = {
u32be, readU32be, u64be, readU64be, canonicalJson,
u32be, readU32be, u64be, readU64be, canonicalJson,
};
};
},
},
-// ── 13: src/locker/errors.js ────────────────────────────────────────
+// ── 14: src/locker/errors.js ────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -1189,7 +1239,7 @@ function fail(code, message) { throw new LockerError(code, message); }
@@ -1189,7 +1239,7 @@ function fail(code, message) { throw new LockerError(code, message); }
module.exports = { LockerError, fail };
module.exports = { LockerError, fail };
},
},
-// ── 14: src/locker/padme.js ─────────────────────────────────────────
+// ── 15: src/locker/padme.js ─────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -1240,7 +1290,7 @@ function padme(size) {
@@ -1240,7 +1290,7 @@ function padme(size) {
module.exports = { padme, exponentOf };
module.exports = { padme, exponentOf };
},
},
-// ── 15: src/locker/keys.js ──────────────────────────────────────────
+// ── 16: src/locker/keys.js ──────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -1250,9 +1300,9 @@ function (module, exports) {
@@ -1250,9 +1300,9 @@ function (module, exports) {
* WebCrypto only: globalThis.crypto.subtle. No other crypto library, nothing hand-rolled: the
* WebCrypto only: globalThis.crypto.subtle. No other crypto library, nothing hand-rolled: the
* ECDH, the ECDSA, the HKDF, the PBKDF2 and the AES-GCM are all the browser's own.
* ECDH, the ECDSA, the HKDF, the PBKDF2 and the AES-GCM are all the browser's own.
*/
*/
-const { utf8, concat, base64, base64url, fromBase64, canonicalJson } = __load(12);
-const { fail } = __load(13);
-const { WORDS } = __load(16);
+const { utf8, concat, base64, base64url, fromBase64, canonicalJson } = __load(13);
+const { fail } = __load(14);
+const { WORDS } = __load(17);
/** The suite of the key pairs: P-256, which every browser's WebCrypto has. */
/** The suite of the key pairs: P-256, which every browser's WebCrypto has. */
const CURVE = 'P-256';
const CURVE = 'P-256';
@@ -1608,7 +1658,7 @@ module.exports = {
@@ -1608,7 +1658,7 @@ module.exports = {
peopleSlotAad, passwordSlotAad, wrapFor, unwrapPeopleSlot, wrapForPassword, unwrapPasswordSlot,
peopleSlotAad, passwordSlotAad, wrapFor, unwrapPeopleSlot, wrapForPassword, unwrapPasswordSlot,
};
};
},
},
-// ── 16: src/locker/words.js ─────────────────────────────────────────
+// ── 17: src/locker/words.js ─────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -1658,7 +1708,7 @@ const WORDS = [
@@ -1658,7 +1708,7 @@ const WORDS = [
module.exports = { WORDS };
module.exports = { WORDS };
},
},
-// ── 17: src/locker/seal.js ──────────────────────────────────────────
+// ── 18: src/locker/seal.js ──────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -1670,17 +1720,17 @@ function (module, exports) {
@@ -1670,17 +1720,17 @@ function (module, exports) {
*/
*/
const {
const {
utf8, fromUtf8, concat, base64, base64url, fromBase64url, u32be, readU32be, u64be, readU64be,
utf8, fromUtf8, concat, base64, base64url, fromBase64url, u32be, readU32be, u64be, readU64be,
-} = __load(12);
-const { fail } = __load(13);
+} = __load(13);
+const { fail } = __load(14);
const {
const {
MAGIC, VERSION, SUITE, CHUNK_SIZE, TAG_SIZE, NONCE_BASE_SIZE, LENGTH_PREFIX, MIN_PADDED_SIZE,
MAGIC, VERSION, SUITE, CHUNK_SIZE, TAG_SIZE, NONCE_BASE_SIZE, LENGTH_PREFIX, MIN_PADDED_SIZE,
FINAL_FLAG, coreOf, chunkAad, encodeHeader, encodeEnvelope, readHeader, chunkCount,
FINAL_FLAG, coreOf, chunkAad, encodeHeader, encodeEnvelope, readHeader, chunkCount,
lastChunkSize, paddedSize, chunkNonce, encodeChunk, nonceBaseBytes,
lastChunkSize, paddedSize, chunkNonce, encodeChunk, nonceBaseBytes,
-} = __load(11);
+} = __load(12);
const {
const {
KEY_BYTES, PASSWORD_ITERATIONS, subtle, platformRandom, importContentKey, publicJwk,
KEY_BYTES, PASSWORD_ITERATIONS, subtle, platformRandom, importContentKey, publicJwk,
jwkThumbprint, wrapFor, unwrapPeopleSlot, wrapForPassword, unwrapPasswordSlot, resolveEphemeral,
jwkThumbprint, wrapFor, unwrapPeopleSlot, wrapForPassword, unwrapPasswordSlot, resolveEphemeral,
-} = __load(15);
+} = __load(16);
/** The content as bytes: a string is UTF-8, anything else is taken as it is. */
/** The content as bytes: a string is UTF-8, anything else is taken as it is. */
function toBytes(content) {
function toBytes(content) {
@@ -2268,7 +2318,7 @@ module.exports = {
@@ -2268,7 +2318,7 @@ module.exports = {
publicKeyOf, privateKeyOf, slotForPerson,
publicKeyOf, privateKeyOf, slotForPerson,
};
};
},
},
-// ── 18: src/locker/inspect.js ───────────────────────────────────────
+// ── 19: src/locker/inspect.js ───────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -2281,8 +2331,8 @@ function (module, exports) {
@@ -2281,8 +2331,8 @@ function (module, exports) {
* The header holds no content, only wrapped keys, so this says nothing the server does not
* The header holds no content, only wrapped keys, so this says nothing the server does not
* already see.
* already see.
*/
*/
-const { envelopeBytes, readCore } = __load(17);
-const { readHeader } = __load(11);
+const { envelopeBytes, readCore } = __load(18);
+const { readHeader } = __load(12);
/**
/**
* What an envelope says about itself.
* What an envelope says about itself.
@@ -2314,7 +2364,7 @@ function inspect(bytes) {
@@ -2314,7 +2364,7 @@ function inspect(bytes) {
module.exports = { inspect };
module.exports = { inspect };
},
},
-// ── 19: src/locker/recovery.js ──────────────────────────────────────
+// ── 20: src/locker/recovery.js ──────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -2328,9 +2378,9 @@ function (module, exports) {
@@ -2328,9 +2378,9 @@ function (module, exports) {
* wrong simply does not open anything. isRecoveryPhrase only says whether every word is one of
* wrong simply does not open anything. isRecoveryPhrase only says whether every word is one of
* the 256, so a UI can tell a typo from a word that was never in the list.
* the 256, so a UI can tell a typo from a word that was never in the list.
*/
*/
-const { fail } = __load(13);
-const { platformRandom } = __load(15);
-const { WORDS } = __load(16);
+const { fail } = __load(14);
+const { platformRandom } = __load(16);
+const { WORDS } = __load(17);
/** How many words a recovery phrase has, unless the caller says otherwise. */
/** How many words a recovery phrase has, unless the caller says otherwise. */
const RECOVERY_WORDS = 24;
const RECOVERY_WORDS = 24;
@@ -2365,7 +2415,7 @@ function isRecoveryPhrase(phrase) {
@@ -2365,7 +2415,7 @@ function isRecoveryPhrase(phrase) {
module.exports = { RECOVERY_WORDS, recoveryWords, isRecoveryPhrase };
module.exports = { RECOVERY_WORDS, recoveryWords, isRecoveryPhrase };
},
},
-// ── 20: src/registry.js ─────────────────────────────────────────────
+// ── 21: src/registry.js ─────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -2402,7 +2452,7 @@ function createRegistryClient(client, { baseUrl } = {}) {
@@ -2402,7 +2452,7 @@ function createRegistryClient(client, { baseUrl } = {}) {
module.exports = { createRegistryClient };
module.exports = { createRegistryClient };
},
},
-// ── 21: src/trust.js ────────────────────────────────────────────────
+// ── 22: src/trust.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -2460,7 +2510,7 @@ function atLeast(signals, band) {
@@ -2460,7 +2510,7 @@ function atLeast(signals, band) {
module.exports = { createTrustClient, isNew, atLeast, AGE_BANDS };
module.exports = { createTrustClient, isNew, atLeast, AGE_BANDS };
},
},
-// ── 22: src/modules.js ──────────────────────────────────────────────
+// ── 23: src/modules.js ──────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -2539,7 +2589,7 @@ function createModulesClient(client, { baseUrl, maxAttempts = 5 } = {}) {
@@ -2539,7 +2589,7 @@ function createModulesClient(client, { baseUrl, maxAttempts = 5 } = {}) {
module.exports = { createModulesClient };
module.exports = { createModulesClient };
},
},
-// ── 23: src/realtime.js ─────────────────────────────────────────────
+// ── 24: src/realtime.js ─────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -2792,7 +2842,7 @@ function createRealtimeClient(client, defaults = {}) {
@@ -2792,7 +2842,7 @@ function createRealtimeClient(client, defaults = {}) {
module.exports = { subscribe, createRealtimeClient, parseSSE, DEFAULT_ORIGIN };
module.exports = { subscribe, createRealtimeClient, parseSSE, DEFAULT_ORIGIN };
},
},
-// ── 24: src/media.js ────────────────────────────────────────────────
+// ── 25: src/media.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -2814,7 +2864,7 @@ function (module, exports) {
@@ -2814,7 +2864,7 @@ function (module, exports) {
*/
*/
const { isOpenVibeError } = __load(3);
const { isOpenVibeError } = __load(3);
const { paginate, offsetPager } = __load(7);
const { paginate, offsetPager } = __load(7);
-const { createObjectsClient } = __load(25);
+const { createObjectsClient } = __load(26);
const DEFAULT_PUBLIC_ORIGIN = 'https://openvibe.media';
const DEFAULT_PUBLIC_ORIGIN = 'https://openvibe.media';
const enc = encodeURIComponent;
const enc = encodeURIComponent;
@@ -2906,7 +2956,7 @@ function createMediaClient(client, { app, apiKey, actingUserId, baseUrl, publicO
@@ -2906,7 +2956,7 @@ function createMediaClient(client, { app, apiKey, actingUserId, baseUrl, publicO
module.exports = { createMediaClient, createObjectsClient, mediaUrls, DEFAULT_PUBLIC_ORIGIN };
module.exports = { createMediaClient, createObjectsClient, mediaUrls, DEFAULT_PUBLIC_ORIGIN };
},
},
-// ── 25: src/objects.js ──────────────────────────────────────────────
+// ── 26: src/objects.js ──────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3225,7 +3275,7 @@ function createObjectsClient({
@@ -3225,7 +3275,7 @@ function createObjectsClient({
module.exports = { createObjectsClient };
module.exports = { createObjectsClient };
},
},
-// ── 26: src/cam/index.js ────────────────────────────────────────────
+// ── 27: src/cam/index.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3318,7 +3368,7 @@ function defineOvCamera(options = {}) {
@@ -3318,7 +3368,7 @@ function defineOvCamera(options = {}) {
module.exports = { defineOvCamera, OV_CAMERA_SRC, CAM_KIT_SRC, CAM_KIT_SRI, loadCamKit, open };
module.exports = { defineOvCamera, OV_CAMERA_SRC, CAM_KIT_SRC, CAM_KIT_SRI, loadCamKit, open };
},
},
-// ── 27: src/community.js ────────────────────────────────────────────
+// ── 28: src/community.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3453,7 +3503,7 @@ function createCommunityClient(client, defaults = {}) {
@@ -3453,7 +3503,7 @@ function createCommunityClient(client, defaults = {}) {
module.exports = { createCommunityClient, actingHeaders };
module.exports = { createCommunityClient, actingHeaders };
},
},
-// ── 28: src/home-feed.js ────────────────────────────────────────────
+// ── 29: src/home-feed.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/** The menu's portable Home layout, network day counts and personal wall. Pass a user-token core client;
/** The menu's portable Home layout, network day counts and personal wall. Pass a user-token core client;
@@ -3480,7 +3530,7 @@ function createHomeFeedClient(client, { networkBaseUrl, communityBaseUrl } = {})
@@ -3480,7 +3530,7 @@ function createHomeFeedClient(client, { networkBaseUrl, communityBaseUrl } = {})
module.exports = { createHomeFeedClient };
module.exports = { createHomeFeedClient };
},
},
-// ── 29: src/bot.js ──────────────────────────────────────────────────
+// ── 30: src/bot.js ──────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3702,7 +3752,7 @@ function createBotClient(client, defaults = {}) {
@@ -3702,7 +3752,7 @@ function createBotClient(client, defaults = {}) {
module.exports = { createBotClient, actingHeaders };
module.exports = { createBotClient, actingHeaders };
},
},
-// ── 30: src/search.js ───────────────────────────────────────────────
+// ── 31: src/search.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3815,7 +3865,7 @@ function createSearchClient(client, defaults = {}) {
@@ -3815,7 +3865,7 @@ function createSearchClient(client, defaults = {}) {
module.exports = { createSearchClient, queryOf, fabricOf };
module.exports = { createSearchClient, queryOf, fabricOf };
},
},
-// ── 31: src/bench.js ────────────────────────────────────────────────
+// ── 32: src/bench.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/** openvibe-sdk/bench: OpenVibe.Bench's JSON API and streamed open dataset. Browser-safe. */
/** openvibe-sdk/bench: OpenVibe.Bench's JSON API and streamed open dataset. Browser-safe. */
@@ -3916,7 +3966,7 @@ function createBenchClient(client, defaults = {}) {
@@ -3916,7 +3966,7 @@ function createBenchClient(client, defaults = {}) {
module.exports = { createBenchClient };
module.exports = { createBenchClient };
},
},
-// ── 32: src/meme.js ─────────────────────────────────────────────────
+// ── 33: src/meme.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -3984,7 +4034,7 @@ function createMemeClient(client, defaults = {}) {
@@ -3984,7 +4034,7 @@ function createMemeClient(client, defaults = {}) {
module.exports = { createMemeClient };
module.exports = { createMemeClient };
},
},
-// ── 33: src/vision.js ───────────────────────────────────────────────
+// ── 34: src/vision.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4142,7 +4192,7 @@ function pick(o, keys) {
@@ -4142,7 +4192,7 @@ function pick(o, keys) {
module.exports = { createVisionClient, DEFAULT_AUDIENCE };
module.exports = { createVisionClient, DEFAULT_AUDIENCE };
},
},
-// ── 34: src/themes.js ───────────────────────────────────────────────
+// ── 35: src/themes.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4292,7 +4342,7 @@ function followTheme(fn, opts = {}) {
@@ -4292,7 +4342,7 @@ function followTheme(fn, opts = {}) {
module.exports = { createThemesClient, followTheme, readTheme, applyTheme, seasonOn, onColor, DISPLAY_OPTIONS, TOKENS };
module.exports = { createThemesClient, followTheme, readTheme, applyTheme, seasonOn, onColor, DISPLAY_OPTIONS, TOKENS };
},
},
-// ── 35: src/design.js ───────────────────────────────────────────────
+// ── 36: src/design.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -4359,7 +4409,7 @@ function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL,
@@ -4359,7 +4409,7 @@ function createDesignClient({ accessToken = null, baseUrl = DEFAULT_DESIGN_URL,
module.exports = { createDesignClient, DEFAULT_DESIGN_URL };
module.exports = { createDesignClient, DEFAULT_DESIGN_URL };
},
},
-// ── 36: src/redact.js ───────────────────────────────────────────────
+// ── 37: src/redact.js ───────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4606,7 +4656,7 @@ function onlySecret(text) {
@@ -4606,7 +4656,7 @@ function onlySecret(text) {
module.exports = { redact, onlySecret };
module.exports = { redact, onlySecret };
},
},
-// ── 37: src/chat.js ─────────────────────────────────────────────────
+// ── 38: src/chat.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4854,7 +4904,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {
@@ -4854,7 +4904,7 @@ function createFeedPublisher(client, { feed, key, baseUrl } = {}) {
module.exports = { createChatClient, createInboxVisitor, createFeedPublisher };
module.exports = { createChatClient, createInboxVisitor, createFeedPublisher };
},
},
-// ── 38: src/ai.js ───────────────────────────────────────────────────
+// ── 39: src/ai.js ───────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -4986,7 +5036,7 @@ function createAiClient(client, defaults = {}) {
@@ -4986,7 +5036,7 @@ function createAiClient(client, defaults = {}) {
module.exports = { createAiClient, TERMINAL, OPS, CLASSES };
module.exports = { createAiClient, TERMINAL, OPS, CLASSES };
},
},
-// ── 39: src/credentials.js ──────────────────────────────────────────
+// ── 40: src/credentials.js ──────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
@@ -5004,7 +5054,7 @@ function createCredentialsClient(client, defaults = {}) {
@@ -5004,7 +5054,7 @@ function createCredentialsClient(client, defaults = {}) {
module.exports = { createCredentialsClient };
module.exports = { createCredentialsClient };
},
},
-// ── 40: src/jobs.js ─────────────────────────────────────────────────
+// ── 41: src/jobs.js ─────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5042,8 +5092,8 @@ function (module, exports) {
@@ -5042,8 +5092,8 @@ function (module, exports) {
*/
*/
const { OpenVibeError, isOpenVibeError } = __load(3);
const { OpenVibeError, isOpenVibeError } = __load(3);
const { newIdempotencyKey } = __load(5);
const { newIdempotencyKey } = __load(5);
-const { appendFiles } = __load(41);
-const { parseSSE } = __load(23);
+const { appendFiles } = __load(42);
+const { parseSSE } = __load(24);
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled']);
const TERMINAL_EVENTS = new Set(['job.succeeded', 'job.failed', 'job.cancelled']);
const TERMINAL_EVENTS = new Set(['job.succeeded', 'job.failed', 'job.cancelled']);
@@ -5206,7 +5256,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'open
@@ -5206,7 +5256,7 @@ function createJobsClient(client, { baseUrl, service = 'tools', audience = 'open
module.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };
module.exports = { createJobsClient, isTerminal, TERMINAL_STATES: [...TERMINAL] };
},
},
-// ── 41: src/core/form.js ────────────────────────────────────────────
+// ── 42: src/core/form.js ────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5240,7 +5290,7 @@ function appendFiles(form, list, where) {
@@ -5240,7 +5290,7 @@ function appendFiles(form, list, where) {
module.exports = { isBlob, isUpload, appendFiles };
module.exports = { isBlob, isUpload, appendFiles };
},
},
-// ── 42: src/tools.js ────────────────────────────────────────────────
+// ── 43: src/tools.js ────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5274,8 +5324,8 @@ function (module, exports) {
@@ -5274,8 +5324,8 @@ function (module, exports) {
*/
*/
const { OpenVibeError, isOpenVibeError } = __load(3);
const { OpenVibeError, isOpenVibeError } = __load(3);
const { newIdempotencyKey } = __load(5);
const { newIdempotencyKey } = __load(5);
-const { isUpload, appendFiles } = __load(41);
-const { createJobsClient } = __load(40);
+const { isUpload, appendFiles } = __load(42);
+const { createJobsClient } = __load(41);
const enc = encodeURIComponent;
const enc = encodeURIComponent;
const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
const ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
@@ -5535,7 +5585,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
@@ -5535,7 +5585,7 @@ function createToolsClient(client, { baseUrl, service = 'tools', audience = 'ope
module.exports = { createToolsClient, ToolRunError, isToolRunError };
module.exports = { createToolsClient, ToolRunError, isToolRunError };
},
},
-// ── 43: src/projects.js ─────────────────────────────────────────────
+// ── 44: src/projects.js ─────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5651,7 +5701,7 @@ function createProjectsClient(client, { baseUrl } = {}) {
@@ -5651,7 +5701,7 @@ function createProjectsClient(client, { baseUrl } = {}) {
module.exports = { createProjectsClient };
module.exports = { createProjectsClient };
},
},
-// ── 44: src/geo.js ──────────────────────────────────────────────────
+// ── 45: src/geo.js ──────────────────────────────────────────────────
function (module, exports) {
function (module, exports) {
'use strict';
'use strict';
/**
/**
@@ -5727,12 +5777,13 @@ function __load(i) {
@@ -5727,12 +5777,13 @@ function __load(i) {
const sdk = __load(0);
const sdk = __load(0);
export const {
export const {
- createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager, parseTraceparent,
- startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey, isActingSubjectId,
- satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION, auth,
- locker, registry, trust, modules, realtime, media,
- cam, community, homeFeed, bot, search, bench,
- meme, vision, themes, design, redact, chat,
- ai, credentials, jobs, tools, projects, geo,
+ createWalletClient, createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager,
+ parseTraceparent, startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey,
+ isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,
+ auth, locker, registry, trust, modules, realtime,
+ media, cam, community, homeFeed, bot, search,
+ bench, meme, vision, themes, design, redact,
+ chat, ai, credentials, jobs, tools, projects,
+ geo,
} = sdk;
} = sdk;
export default sdk;
export default sdk;
@@ -120,6 +120,7 @@
@@ -120,6 +120,7 @@
]
]
},
},
"createClient": "function",
"createClient": "function",
+ "createWalletClient": "function",
"credentials": {
"credentials": {
"object": [
"object": [
"createCredentialsClient"
"createCredentialsClient"
@@ -1191,6 +1192,9 @@
@@ -1191,6 +1192,9 @@
"DEFAULT_AUDIENCE": "string",
"DEFAULT_AUDIENCE": "string",
"createVisionClient": "function"
"createVisionClient": "function"
},
},
+ "openvibe-sdk/wallet": {
+ "createWalletClient": "function"
+ },
"openvibe-sdk/wiki": {
"openvibe-sdk/wiki": {
"createWikiClient": "function"
"createWikiClient": "function"
},
},
new file mode 100644
new file mode 100644
@@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
+# Universal wallet and store
+
+```js
+import { createClient, createWalletClient } from 'openvibe-sdk';
+const ov = createWalletClient(createClient({ tokenProvider }));
+const wallet = await ov.wallet.get();
+const { items } = await ov.store.list();
+const purchase = await ov.store.buy(items[0].id, {
+ currency: 'vibes', idempotency_key: crypto.randomUUID(),
+});
+const owned = await ov.items.list();
+await ov.items.equip({ kind: 'live.hat', slot: 'hat', instance_id: owned.instances[0].id });
+// instance_id: null clears a slot.
+const checkout = await ov.wallet.topUp({ provider: 'stripe', amount_cents: 1000, idempotency_key: crypto.randomUUID() });
+// Or: ov.vibes.buy({ provider: 'stripe', vibes: 100, idempotency_key: crypto.randomUUID() }).
+// Navigate checkout.checkout_url in the same tab after checking it is an HTTPS URL.
+```
+
+Use a person's Network bearer for wallet, buys and items. All calls omit cookies, even if the core client defaults to including them. Choose providers and amounts from wallet.checkout; the service computes actual prices. Keep the same idempotency_key for retries of one intent, including across a page reload after an uncertain outcome. Never generate a new key to retry a purchase. The client preserves the body's key during automatic network retries and forwards neither a price override nor another subject.
+
+An issuer's service/app client may call ov.store.submit(itemId, {vibes:100,coins:200}) with inventory.store.list. Prices shown here are examples. Staff must review before the listing is visible. Billing remains the payment authority and reads OpenCoins from Network. Enable the companion Billing/Inventory endpoints and pin the companion Contracts capability release before rollout. Browser CSP must permit Billing and Inventory in connect-src.
@@ -2,18 +2,18 @@
@@ -2,18 +2,18 @@
import cjs from '../index.js';
import cjs from '../index.js';
export const {
export const {
- createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager, parseTraceparent,
- startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey, isActingSubjectId,
- satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION, report,
- share, locker, auth, registry, identity, trust,
- modules, events, realtime, media, cam, community,
- homeFeed, bot, search, bench, meme, vision,
- themes, design, redact, chat, chatApps, ai,
- credentials, jobs, tools, projects, resources, vip,
- quest, live, inventory, tips, blog, reviews,
- wiki, coupons, deals, shoes, trade, space,
- host, news, food, actor, run, video,
- work, zone, play, download, openre, geo,
- usage, commerce, telemetry,
+ createWalletClient, createClient, OpenVibeError, isOpenVibeError, paginate, offsetPager,
+ parseTraceparent, startSpan, contextFromHeaders, ulid, newEventId, newIdempotencyKey,
+ isActingSubjectId, satisfiesRange, compareVersions, CONTRACTS_RANGE, DEFAULT_NETWORK, SDK_VERSION,
+ report, share, locker, auth, registry, identity,
+ trust, modules, events, realtime, media, cam,
+ community, homeFeed, bot, search, bench, meme,
+ vision, themes, design, redact, chat, chatApps,
+ ai, credentials, jobs, tools, projects, resources,
+ vip, quest, live, inventory, tips, blog,
+ reviews, wiki, coupons, deals, shoes, trade,
+ space, host, news, food, actor, run,
+ video, work, zone, play, download, openre,
+ geo, usage, commerce, telemetry,
} = cjs;
} = cjs;
export default cjs;
export default cjs;
new file mode 100644
new file mode 100644
@@ -0,0 +1,7 @@
@@ -0,0 +1,7 @@
+// Generated by scripts/esm.js from src/wallet.js. Do not edit.
+import cjs from '../src/wallet.js';
+
+export const {
+ createWalletClient,
+} = cjs;
+export default cjs;
@@ -7,6 +7,7 @@
@@ -7,6 +7,7 @@
const core = require('./src/core');
const core = require('./src/core');
module.exports = {
module.exports = {
+ createWalletClient: require('./src/wallet').createWalletClient,
...core,
...core,
report: require('./src/report'),
report: require('./src/report'),
share: require('./src/share').share,
share: require('./src/share').share,
@@ -1,12 +1,12 @@
@@ -1,12 +1,12 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.118.0",
+ "version": "0.119.0",
"lockfileVersion": 3,
"lockfileVersion": 3,
"requires": true,
"requires": true,
"packages": {
"packages": {
"": {
"": {
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.118.0",
+ "version": "0.119.0",
"license": "MIT",
"license": "MIT",
"bin": {
"bin": {
"openvibe-download": "bin/openvibe-download.js"
"openvibe-download": "bin/openvibe-download.js"
@@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.118.0",
+ "version": "0.119.0",
"description": "Supported browser and server clients for the OpenVibe platform: auth (incl. developer apps), registry discovery, identity, user modules, events, realtime, media, community, Bot robots, search, chat, AI runs, Tools (registry, run API and jobs), VIP memberships and developer projects, the async PostgreSQL data layer (db) and the Valkey cache, limits store, queue and pub/sub, with deadlines, safe retries, problem errors and trace propagation.",
"description": "Supported browser and server clients for the OpenVibe platform: auth (incl. developer apps), registry discovery, identity, user modules, events, realtime, media, community, Bot robots, search, chat, AI runs, Tools (registry, run API and jobs), VIP memberships and developer projects, the async PostgreSQL data layer (db) and the Valkey cache, limits store, queue and pub/sub, with deadlines, safe retries, problem errors and trace propagation.",
"main": "index.js",
"main": "index.js",
"types": "types/index.d.ts",
"types": "types/index.d.ts",
@@ -551,6 +551,12 @@
@@ -551,6 +551,12 @@
"browser": null,
"browser": null,
"import": "./esm/compute.mjs",
"import": "./esm/compute.mjs",
"default": "./src/compute/index.js"
"default": "./src/compute/index.js"
+ },
+ "./wallet": {
+ "types": "./types/wallet.d.ts",
+ "browser": "./src/wallet.js",
+ "import": "./esm/wallet.mjs",
+ "default": "./src/wallet.js"
}
}
},
},
"bin": {
"bin": {
@@ -12,6 +12,7 @@ const path = require('path');
@@ -12,6 +12,7 @@ const path = require('path');
const ROOT = path.join(__dirname, '..');
const ROOT = path.join(__dirname, '..');
const ENTRIES = {
const ENTRIES = {
+ 'wallet.mjs': '../src/wallet.js',
'compute.mjs': '../src/compute/index.js',
'compute.mjs': '../src/compute/index.js',
'share.mjs': '../src/share.js',
'share.mjs': '../src/share.js',
'locker.mjs': '../src/locker.js',
'locker.mjs': '../src/locker.js',
@@ -8,7 +8,7 @@ const { paginate, offsetPager } = require('./paginate');
@@ -8,7 +8,7 @@ const { paginate, offsetPager } = require('./paginate');
const semver = require('./semver');
const semver = require('./semver');
/** The package version (test/version.test.js keeps it equal to package.json). */
/** The package version (test/version.test.js keeps it equal to package.json). */
-const SDK_VERSION = '0.118.0';
+const SDK_VERSION = '0.119.0';
module.exports = {
module.exports = {
createClient,
createClient,
new file mode 100644
new file mode 100644
@@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
+'use strict';
+
+/** Personal bearer wallet/store facade. Amounts and ownership are enforced by Billing and Inventory. */
+function createWalletClient(client, { billingUrl, inventoryUrl } = {}) {
+ if (!client || typeof client.json !== 'function') throw new TypeError('createWalletClient requires an SDK core client');
+ const call = (service, path, opts = {}) => client.json({ service, baseUrl: service === 'billing' ? billingUrl : inventoryUrl,
+ audience: `openvibe.${service}`, path, credentials: 'omit', ...opts });
+ const key = (v) => {
+ if (typeof v !== 'string' || !/^[A-Za-z0-9._:-]{8,128}$/.test(v)) throw new TypeError('An idempotency_key of 8–128 letters, digits, dot, colon, underscore or dash is required');
+ return v;
+ };
+ const whole = (v) => { if (!Number.isSafeInteger(v) || v < 1) throw new TypeError('Choose a positive whole amount'); return v; };
+ const itemId = (v) => { if (!/^itd_[0-9A-HJKMNP-TV-Z]{26}$/.test(v || '')) throw new TypeError('An item id is an itd_ id'); return encodeURIComponent(v); };
+ // The BODY key is durable in both services. Retries keep it; the SDK must not add an unrelated header key.
+ const write = (service, path, json, { signal } = {}) => call(service, path, { method: 'POST', json,
+ idempotencyKey: false, idempotent: true, signal });
+ return {
+ wallet: {
+ get: ({ signal } = {}) => call('billing', '/api/v1/me/wallet', { signal }),
+ topUp: ({ provider, amount_cents, idempotency_key }, options) => write('billing', '/api/v1/me/wallet/topups',
+ { provider, amount_cents: whole(amount_cents), idempotency_key: key(idempotency_key) }, options),
+ },
+ vibes: {
+ buy: ({ provider, vibes, idempotency_key }, options) => write('billing', '/api/v1/me/vibes/buy',
+ { provider, vibes: whole(vibes), idempotency_key: key(idempotency_key) }, options),
+ },
+ store: {
+ list: ({ signal } = {}) => call('inventory', '/api/v1/store', { signal }),
+ buy: (id, { currency, idempotency_key }, options) => {
+ if (!['coins', 'vibes'].includes(currency)) throw new TypeError('currency is coins or vibes');
+ return write('inventory', `/api/v1/store/${itemId(id)}/buy`, { currency, idempotency_key: key(idempotency_key) }, options);
+ },
+ submit: (id, prices, { signal } = {}) => call('inventory', `/api/v1/store/${itemId(id)}/list`,
+ { method: 'POST', json: { prices }, idempotencyKey: false, retries: 0, signal }),
+ },
+ items: {
+ list: ({ cursor, limit, kind, signal } = {}) => call('inventory', '/api/v1/me/items', { query: { cursor, limit, kind }, signal }),
+ equip: ({ kind, slot, instance_id }, { signal } = {}) => {
+ if (instance_id !== null && !/^inv_[0-9A-HJKMNP-TV-Z]{26}$/.test(instance_id || '')) throw new TypeError('instance_id is an inv_ id, or null to unequip');
+ return call('inventory', '/api/v1/me/equipped', { method: 'PUT', json: { kind, slot, instance_id }, signal });
+ },
+ },
+ };
+}
+
+module.exports = { createWalletClient };
@@ -72,7 +72,7 @@ run([
@@ -72,7 +72,7 @@ run([
})().catch((err) => { console.error(err); process.exit(1); });`;
})().catch((err) => { console.error(err); process.exit(1); });`;
const res = execFileSync(process.execPath, ['-e', script], { cwd: app, encoding: 'utf8' });
const res = execFileSync(process.execPath, ['-e', script], { cwd: app, encoding: 'utf8' });
assert.match(res, new RegExp(`consumer ok: ${subpaths.length} subpaths \\+ the browser bundle`));
assert.match(res, new RegExp(`consumer ok: ${subpaths.length} subpaths \\+ the browser bundle`));
- assert.equal(subpaths.length, 95); // Adds the Shoes product client.
+ assert.equal(subpaths.length, 96); // Adds the wallet client (0.119.0).
assert.ok(!fs.existsSync(path.join(app, 'node_modules/openvibe-contracts')), 'the optional peer is not installed');
assert.ok(!fs.existsSync(path.join(app, 'node_modules/openvibe-contracts')), 'the optional peer is not installed');
} finally {
} finally {
fs.rmSync(tmp, { recursive: true, force: true });
fs.rmSync(tmp, { recursive: true, force: true });
new file mode 100644
new file mode 100644
@@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
+'use strict';
+const assert = require('assert');
+const { createClient } = require('../src/core');
+const { createWalletClient } = require('../src/wallet');
+
+(async () => {
+ const calls = []; let retry = true;
+ const client = createClient({ token: 'person-token', baseUrls: { billing: 'https://billing.test', inventory: 'https://inventory.test' },
+ credentials: 'include', retries: 1, retryDelayMs: 1, fetch: async (url, init) => {
+ calls.push({ url, ...init, json: init.body ? JSON.parse(init.body) : null });
+ if (retry && url.endsWith('/buy')) { retry = false; return new Response(JSON.stringify({ detail: 'retry' }), { status: 503 }); }
+ return new Response(JSON.stringify({ ok: true }), { status: 200, headers: { 'Content-Type': 'application/json' } });
+ } });
+ const ov = createWalletClient(client);
+ await ov.wallet.get();
+ await ov.wallet.topUp({ provider: 'stripe', amount_cents: 1000, idempotency_key: 'topup-test-01', subject: 'ignored' });
+ await ov.vibes.buy({ provider: 'stripe', vibes: 100, idempotency_key: 'vibes-test-01', amount_cents: 1 });
+ await ov.store.list();
+ const id = 'itd_' + '0'.repeat(25) + '1';
+ await ov.store.buy(id, { currency: 'coins', idempotency_key: 'store-test-01', price: 1 });
+ await ov.items.list({ limit: 20 });
+ await ov.items.equip({ kind: 'live.hat', slot: 'hat', instance_id: null });
+ for (const call of calls) {
+ assert.strictEqual(call.credentials, 'omit');
+ assert.strictEqual(call.headers.get('Authorization'), 'Bearer person-token');
+ assert(!call.json || !('price' in call.json) && !('subject' in call.json));
+ }
+ const vibes = calls.filter((c) => c.url.endsWith('/vibes/buy'));
+ assert.strictEqual(vibes.length, 2); assert.deepStrictEqual(vibes[0].json, vibes[1].json);
+ assert.strictEqual(vibes[0].headers.get('Idempotency-Key'), null);
+ assert(!('amount_cents' in vibes[0].json));
+ assert.strictEqual(calls.at(-1).method, 'PUT');
+ assert.throws(() => ov.store.buy('../evil', { currency: 'coins', idempotency_key: 'safe-key-01' }));
+ assert.throws(() => ov.store.buy(id, { currency: 'USD', idempotency_key: 'safe-key-01' }));
+ assert.throws(() => ov.vibes.buy({ provider: 'stripe', vibes: 1.5, idempotency_key: 'safe-key-01' }));
+ assert.throws(() => ov.wallet.topUp({ provider: 'stripe', amount_cents: 1000 }));
+ console.log('wallet facade: routes, personal bearer, no cookies, stable retry keys and no price/subject injection');
+})().catch((e) => { console.error(e); process.exitCode = 1; });
@@ -25,6 +25,7 @@ import * as geo from './geo';
@@ -25,6 +25,7 @@ import * as geo from './geo';
import * as locker from './locker';
import * as locker from './locker';
import * as trust from './trust';
import * as trust from './trust';
import * as core from './core';
import * as core from './core';
+export const createWalletClient: typeof import('./wallet').createWalletClient;
export * from './core';
export * from './core';
export * as auth from './auth-browser';
export * as auth from './auth-browser';
@@ -54,6 +55,7 @@ export * as locker from './locker';
@@ -54,6 +55,7 @@ export * as locker from './locker';
export * as trust from './trust';
export * as trust from './trust';
declare const sdk: typeof core & {
declare const sdk: typeof core & {
+ createWalletClient: typeof createWalletClient;
auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;
auth: typeof auth; registry: typeof registry; modules: typeof modules; realtime: typeof realtime;
media: typeof media; cam: typeof cam; community: typeof community; homeFeed: typeof homeFeed; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; design: typeof design; redact: typeof redact; chat: typeof chat; ai: typeof ai; credentials: typeof credentials; jobs: typeof jobs; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust;
media: typeof media; cam: typeof cam; community: typeof community; homeFeed: typeof homeFeed; bot: typeof bot; search: typeof search; bench: typeof bench; meme: typeof meme; vision: typeof vision; themes: typeof themes; design: typeof design; redact: typeof redact; chat: typeof chat; ai: typeof ai; credentials: typeof credentials; jobs: typeof jobs; tools: typeof tools; projects: typeof projects; geo: typeof geo; locker: typeof locker; trust: typeof trust;
};
};
@@ -59,3 +59,5 @@ export * as commerce from './commerce';
@@ -59,3 +59,5 @@ export * as commerce from './commerce';
export * as telemetry from './telemetry';
export * as telemetry from './telemetry';
export const share: typeof import('./share').share;
export const share: typeof import('./share').share;
export * as locker from './locker';
export * as locker from './locker';
+
+export const createWalletClient: typeof import('./wallet').createWalletClient;
new file mode 100644
new file mode 100644
@@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
+import type { OpenVibeClient } from './core';
+
+export interface WalletBalance { label: string; amount: string; currency: 'USD' | 'opencoins' | 'vibes-bits'; scale: 0 | 9; purpose: string; action: string; held?: string; }
+export interface Wallet {
+ subject: { type: 'user'; id: string }; currency: 'USD'; money_writes_frozen: boolean; used_ai_this_month: boolean;
+ balances: { coins: WalletBalance; vibes: WalletBalance; balance: WalletBalance }; bits_per_usd: number;
+ recent_activity: Array<{ id: string; at: string; kind: 'coins' | 'vibes' | 'balance'; amount: string; label: string; detail: string; site: string }>;
+ checkout: { providers: string[]; vibes: { minimum: number; maximum: number; price_tiers: Array<{ min: number; usd_per_bit: number }> }; topup: { enabled: boolean; amounts_cents: number[]; fee_bps: number | null } };
+}
+export interface StoreItem { id: string; name: string; description: string; issuer: string; prices: { coins?: number; vibes?: number }; preview: { emoji?: string; token?: string; media_id?: string }; kind: string; slots: string[]; surfaces: Array<{ surface: string; renderer?: string }>; owned: boolean; available: boolean; }
+export interface Purchase { id: string; subject: string; item_id: string; name: string; issuer: string; currency: 'coins' | 'vibes'; amount: number; status: 'pending' | 'fulfilled'; instance_id: string | null; payment_id: string | null; }
+export interface Checkout { intent: Record<string, unknown>; checkout_url: string | null; }
+type Options = { signal?: AbortSignal };
+export function createWalletClient(client: OpenVibeClient, options?: { billingUrl?: string; inventoryUrl?: string }): {
+ wallet: { get(options?: Options): Promise<Wallet>; topUp(input: { provider: string; amount_cents: number; idempotency_key: string }, options?: Options): Promise<Checkout> };
+ vibes: { buy(input: { provider: string; vibes: number; idempotency_key: string }, options?: Options): Promise<Checkout> };
+ store: { list(options?: Options): Promise<{ items: StoreItem[] }>; buy(id: string, input: { currency: 'coins' | 'vibes'; idempotency_key: string }, options?: Options): Promise<Purchase>; submit(id: string, prices: { coins?: number; vibes?: number }, options?: Options): Promise<{ definition_id: string; issuer: string; prices: { coins?: number; vibes?: number }; status: 'in_review' }> };
+ items: { list(options?: Options & { cursor?: string; limit?: number; kind?: string }): Promise<{ subject: string; instances: import('./inventory').Instance[]; definitions: Record<string, import('./inventory').Definition>; next_cursor: string | null }>; equip(input: { kind: string; slot: string; instance_id: string | null }, options?: Options): Promise<import('./inventory').EquippedSet> };
+};