openvibers/openvibe.sdk Commits

Add ov.cam.settings and pin updated Cam kit (#158)

OP OpenVibers committed 4 days ago · 52a2b98d9d · 13 files, +95 −15

* Expose Cam recorder through SDK browser namespace

* Expose per-person camera settings in SDK

* Merge remote-tracking branch 'origin/main' into feat/sdk-cam-settings-1109

# Conflicts:
#	browser/openvibe-sdk.mjs
#	docs/api-surface.json
#	esm/cam.mjs
#	src/cam/index.js
#	test/cam.test.js
#	types/cam.d.ts

* 0.121.0

Changes

ddiff --git a/CHANGELOG.md b/CHANGELOG.md
iindex d9df8b8..e459236 100644
---- a/CHANGELOG.md
++++ b/CHANGELOG.md
@@@ -1,5 +1,9 @@
# Changelog
++## 0.121.0 (2026-11-09)
++
++- ov.cam.settings.get/put: a person's saved camera choices (Cam #116)
++
## 0.120.0 (2026-11-09)
- createUploadClient(): resumable Media uploads in 8 MiB parts, three at a time, with a session reference to resume; ov.ui.progress(el)
ddiff --git a/README.md b/README.md
iindex a72c098..75872cd 100644
---- a/README.md
++++ b/README.md
@@@ -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.120.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.121.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/tags
After v0.97.1 is tagged:
```bash
--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.120.0
++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.121.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).
@@@ -688,3 +688,8 @@ const exchange = require('openvibe-sdk/exchange').createExchangeClient({ develop
const round = await exchange.arena.start({ prompt: 'Explain a binary search.', category: 'code', entries });
await exchange.arena.vote(round.id, 'left');
```
++## Camera settings
++
++Camera choices can be read or saved on behalf of a signed-in person with `ov.cam.settings.get({ token })` and
++`ov.cam.settings.put({ token, values: { facing, lens, mic, resolution, mirror } })`. Server callers should forward
++the person's Network token; Cam keeps these preferences per person, and a missing device id is only a hint.
ddiff --git a/STATUS.json b/STATUS.json
iindex 953ea18..a08f370 100644
---- a/STATUS.json
++++ b/STATUS.json
@@@ -3,7 +3,7 @@
"stage": "alpha",
"code": true,
"wave": "W2",
-- "version": "0.120.0",
++ "version": "0.121.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",
ddiff --git a/browser/openvibe-sdk.mjs b/browser/openvibe-sdk.mjs
iindex ebc3528..44a60c9 100644
---- a/browser/openvibe-sdk.mjs
++++ b/browser/openvibe-sdk.mjs
@@@ -1,4 +1,4 @@
--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.120.0, MIT). Do not edit.
++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.121.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, mediaUpload, ui, 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 */
@@@ -56,7 +56,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.120.0';
++const SDK_VERSION = '0.121.0';
module.exports = {
createClient,
@@@ -3334,6 +3334,23 @@ function loadCamKit() {
/** Open Cam on this page. Resolves to a File and metadata after Use this, or null on cancel. */
function open(options = {}) { return loadCamKit().then((kit) => kit.open(options)); }
++async function cameraSettings(token, method, body) {
++ if (typeof token !== 'string' || !token) throw new TypeError('A person’s Network token is required.');
++ const response = await fetch('https://openvibe.cam/api/v1/me/camera-settings', {
++ method, headers: { Authorization: `Bearer ${token}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },
++ ...(body ? { body: JSON.stringify(body) } : {}),
++ });
++ const data = await response.json();
++ if (!response.ok) throw new Error(data.detail || 'Could not load camera settings');
++ return data;
++}
++
++/** Camera choices follow a signed-in person across sites. Server callers forward the person's token. */
++const settings = Object.freeze({
++ get: ({ token }) => cameraSettings(token, 'GET'),
++ put: ({ token, values }) => cameraSettings(token, 'PUT', values),
++});
++
/**
* Inject the <ov-camera> embed once and resolve to the element class.
* @param {{ src?: string }} [options]
@@@ -3370,7 +3387,7 @@ function defineOvCamera(options = {}) {
return load;
}
--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, settings };
},
// ── 28: src/media-upload.js ─────────────────────────────────────────
function (module, exports) {
ddiff --git a/docs/api-surface.json b/docs/api-surface.json
iindex 53a58d9..ca1c0d3 100644
---- a/docs/api-surface.json
++++ b/docs/api-surface.json
@@@ -65,7 +65,8 @@
"OV_CAMERA_SRC",
"defineOvCamera",
"loadCamKit",
-- "open"
++ "open",
++ "settings"
]
},
"chat": {
@@@ -546,7 +547,13 @@
"OV_CAMERA_SRC": "string",
"defineOvCamera": "function",
"loadCamKit": "function",
-- "open": "function"
++ "open": "function",
++ "settings": {
++ "object": [
++ "get",
++ "put"
++ ]
++ }
},
"openvibe-sdk/chat": {
"createChatClient": "function",
ddiff --git a/esm/cam.mjs b/esm/cam.mjs
iindex 6752763..9a4a106 100644
---- a/esm/cam.mjs
++++ b/esm/cam.mjs
@@@ -3,5 +3,6 @@ import cjs from '../src/cam/index.js';
export const {
defineOvCamera, OV_CAMERA_SRC, CAM_KIT_SRC, CAM_KIT_SRI, loadCamKit, open,
++ settings,
} = cjs;
export default cjs;
ddiff --git a/package-lock.json b/package-lock.json
iindex f671046..d70790d 100644
---- a/package-lock.json
++++ b/package-lock.json
@@@ -1,12 +1,12 @@
{
"name": "openvibe-sdk",
-- "version": "0.120.0",
++ "version": "0.121.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "openvibe-sdk",
-- "version": "0.120.0",
++ "version": "0.121.0",
"license": "MIT",
"bin": {
"openvibe-download": "bin/openvibe-download.js"
ddiff --git a/package.json b/package.json
iindex 7319ce5..f0c7359 100644
---- a/package.json
++++ b/package.json
@@@ -1,6 +1,6 @@
{
"name": "openvibe-sdk",
-- "version": "0.120.0",
++ "version": "0.121.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",
ddiff --git a/src/cam/index.js b/src/cam/index.js
iindex 798acdb..f973cf2 100644
---- a/src/cam/index.js
++++ b/src/cam/index.js
@@@ -51,6 +51,23 @@ function loadCamKit() {
/** Open Cam on this page. Resolves to a File and metadata after Use this, or null on cancel. */
function open(options = {}) { return loadCamKit().then((kit) => kit.open(options)); }
++async function cameraSettings(token, method, body) {
++ if (typeof token !== 'string' || !token) throw new TypeError('A person’s Network token is required.');
++ const response = await fetch('https://openvibe.cam/api/v1/me/camera-settings', {
++ method, headers: { Authorization: `Bearer ${token}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },
++ ...(body ? { body: JSON.stringify(body) } : {}),
++ });
++ const data = await response.json();
++ if (!response.ok) throw new Error(data.detail || 'Could not load camera settings');
++ return data;
++}
++
++/** Camera choices follow a signed-in person across sites. Server callers forward the person's token. */
++const settings = Object.freeze({
++ get: ({ token }) => cameraSettings(token, 'GET'),
++ put: ({ token, values }) => cameraSettings(token, 'PUT', values),
++});
++
/**
* Inject the <ov-camera> embed once and resolve to the element class.
* @param {{ src?: string }} [options]
@@@ -87,4 +104,4 @@ function defineOvCamera(options = {}) {
return load;
}
--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, settings };
ddiff --git a/src/core/index.js b/src/core/index.js
iindex 9c84823..203cf36 100644
---- a/src/core/index.js
++++ b/src/core/index.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.120.0';
++const SDK_VERSION = '0.121.0';
module.exports = {
createClient,
ddiff --git a/test/cam.test.js b/test/cam.test.js
iindex 143d089..d3476bc 100644
---- a/test/cam.test.js
++++ b/test/cam.test.js
@@@ -14,8 +14,25 @@ const cam = require('../src/cam');
const pkg = require('../package.json');
run([
++ ['camera settings use the person token and return saved choices', async () => {
++ const original = global.fetch;
++ const calls = [];
++ global.fetch = async (url, options) => {
++ calls.push({ url, options });
++ return { ok: true, json: async () => ({ facing: 'user', lens: 'main', mic: 'default', resolution: '720', mirror: true, updated_at: null }) };
++ };
++ try {
++ await cam.settings.get({ token: 'person-token' });
++ await cam.settings.put({ token: 'person-token', values: { mirror: false } });
++ assert.equal(calls[0].url, 'https://openvibe.cam/api/v1/me/camera-settings');
++ assert.equal(calls[0].options.method, 'GET');
++ assert.equal(calls[1].options.method, 'PUT');
++ assert.equal(JSON.parse(calls[1].options.body).mirror, false);
++ assert.equal(calls[1].options.headers.Authorization, 'Bearer person-token');
++ } finally { global.fetch = original; }
++ }],
['the entry resolves by name and names the loader and the default script', async () => {
-- assert.deepEqual(Object.keys(cam).sort(), ['CAM_KIT_SRC', 'CAM_KIT_SRI', 'OV_CAMERA_SRC', 'defineOvCamera', 'loadCamKit', 'open']);
++ assert.deepEqual(Object.keys(cam).sort(), ['CAM_KIT_SRC', 'CAM_KIT_SRI', 'OV_CAMERA_SRC', 'defineOvCamera', 'loadCamKit', 'open', 'settings']);
assert.equal(cam.OV_CAMERA_SRC, 'https://openvibe.cam/embed/ov-camera.js');
assert.equal(cam.CAM_KIT_SRC, 'https://openvibe.cam/embed/cam-kit.js?v=yqqjh1FiP7a4');
assert.match(cam.CAM_KIT_SRI, /^sha384-/);
ddiff --git a/test/pack.test.js b/test/pack.test.js
iindex d059de2..d9a63dd 100644
---- a/test/pack.test.js
++++ b/test/pack.test.js
@@@ -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, 98); // Adds the upload client and the UI entry (0.120.0); the wallet came in 0.119.0.
++ assert.equal(subpaths.length, 98); // Adds the upload client and the UI entry (0.121.0); the wallet came in 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 });
ddiff --git a/types/cam.d.ts b/types/cam.d.ts
iindex 675db63..31b082b 100644
---- a/types/cam.d.ts
++++ b/types/cam.d.ts
@@@ -10,6 +10,18 @@ export declare const OV_CAMERA_SRC: string;
/** The pinned in-page recorder script and its SHA-384 integrity value. */
export declare const CAM_KIT_SRC: string;
export declare const CAM_KIT_SRI: string;
++export interface CamSettings {
++ facing: 'user' | 'environment';
++ lens: string;
++ mic: string;
++ resolution: '480' | '720' | '1080';
++ mirror: boolean;
++ updated_at: string | null;
++}
++export declare const settings: {
++ get(options: { token: string }): Promise<CamSettings>;
++ put(options: { token: string; values: Partial<Omit<CamSettings, 'updated_at'>> }): Promise<CamSettings>;
++};
export type CamKitMode = 'video' | 'photo' | 'screen';
export interface CamKitResult {