openvibers/openvibe.sdk Commits
Add identity SDK account email helpers (#144)
Changes
@@@ -1,5 +1,9 @@# Changelog++## 0.104.0 (2026-11-08)++++- Add `createAccountEmailsClient` to `openvibe-sdk/identity` for managing the signed-in person's verified Network email addresses.++## 0.103.0 (2026-11-08)- Add `openvibe-sdk/credentials`: `createCredentialsClient` for a person's own provider credentials on OpenVibe.AI:@@@ -2,7 +2,7 @@> Supported browser and server clients for the OpenVibe platform.--**Status:** alpha, v0.103.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.104.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.@@@ -11,7 +11,7 @@After v0.97.1 is tagged:```bash--npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.103.0++npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.104.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).@@@ -166,7 +166,7 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client| `openvibe-sdk/core` | both | `createClient()`, `OpenVibeError`, `paginate()`, `offsetPager()`, trace and id helpers, `CONTRACTS_RANGE` || `openvibe-sdk/auth` | server (browser build: PKCE only) | `createServiceTokenClient()` (+ `getTokenInfo()`), `createNetworkKeys()`, `verifyUserToken()`, `verifyAppToken()`, `verifyServiceToken()`, `exchangeCode()`, `refreshUserToken()`; `startAuthorization()`, `buildAuthorizeUrl()`, `createPkcePair()`, `readCallback()`, `decodeUnverified()`, `unverifiedClaims()` || `openvibe-sdk/registry` | both | `createRegistryClient(client)`: `services({status})`, `service(id)`, `capabilities({owner})`, `capability(id)`, `namespaces()`, `contracts()`, `topics()`, `domain(host)`, `descriptor()` |--| `openvibe-sdk/identity` | server | `createIdentityClient(client)`: `resolve({subjectId} \| {system,type,id})`, `resolveBatch({subjectIds} \| {system,type,ids})` |++| `openvibe-sdk/identity` | server | `createIdentityClient(client)`: `resolve({subjectId} \| {system,type,id})`, `resolveBatch({subjectIds} \| {system,type,ids})`; `createAccountEmailsClient({getToken})` manages the signed-in person's verified addresses ([guide](docs/identity-emails.md)) || `openvibe-sdk/trust` | both | `createTrustClient({networkUrl, getToken})`: `me()` reads the caller's own account or guest signals; `of(subject)` reads an account or guest with `identity.trust.read`; `isNew(signals, {hours})`, `atLeast(signals, band)`, `AGE_BANDS` || `openvibe-sdk/notifications` | server | `createNotificationsClient(client)`: `push({subjectId \| userId, type, title, message, url, category, priority, …})` through Network (`network.notifications.push`); `{ sent, skipped }` or `{ sent: false, reason: 'unknown_subject' }`; attempted once, the caller retries || `openvibe-sdk/modules` | both | `createModulesClient(client)`: `get`, `put(ns, data, {revision})`, `delete`, `list`, `update(ns, fn)`, `publicGet`; `forSubject.get/put/update` for services |@@@ -3,7 +3,7 @@"stage": "alpha","code": true,"wave": "W2",-- "version": "0.103.0",++ "version": "0.104.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",@@@ -1,4 +1,4 @@--// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.103.0, MIT). Do not edit.++// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.104.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, community, bot, search, bench, meme, vision, themes, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity./* eslint-disable */@@@ -50,7 +50,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.103.0';++const SDK_VERSION = '0.104.0';module.exports = {createClient,@@@ -162,6 +162,7 @@},"identity": {"object": [++ "createAccountEmailsClient","createIdentityClient"]},@@@ -720,6 +721,7 @@"createHostClient": "function"},"openvibe-sdk/identity": {++ "createAccountEmailsClient": "function","createIdentityClient": "function"},"openvibe-sdk/inventory": {nnew file mode 100644@@@ -0,0 +1,28 @@++# Account email addresses++++Use `createAccountEmailsClient` with the signed-in person's Network access token. It only reads and changes that person's own list; email addresses are private until the person shares one.++++```js++const { createAccountEmailsClient } = require('openvibe-sdk/identity');++++const emails = createAccountEmailsClient({++ getToken: () => session.accessToken,++});++++const { emails: addresses } = await emails.list();++await emails.add('[email protected]'); // Network sends a single-use verification link++await emails.makePrimary(addresses[1].id); // verified addresses only++await emails.remove(addresses[0].id); // choose a new primary first++```++++`verify(id)` asks Network to send the verification link again. Verification links expire after one hour and can be used once. Keep the access token on the person's trusted client or server and do not log it.++++Services holding `identity.emails.read` can check one subject and address without receiving an address list:++++```js++const { createIdentityClient } = require('openvibe-sdk/identity');++const identity = createIdentityClient(serviceClient);++const verified = await identity.isEmailVerified({ subject: 'usr_…', email: '[email protected]' });++```++++Unknown subjects and addresses both return `false`. Making an address primary or removing one requires a sign-in from the last ten minutes.@@@ -2,6 +2,6 @@import cjs from '../src/identity.js';export const {-- createIdentityClient,++ createIdentityClient, createAccountEmailsClient,} = cjs;export default cjs;@@@ -1,12 +1,12 @@{"name": "openvibe-sdk",-- "version": "0.103.0",++ "version": "0.104.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "openvibe-sdk",-- "version": "0.103.0",++ "version": "0.104.0","license": "MIT","bin": {"openvibe-download": "bin/openvibe-download.js"@@@ -1,6 +1,6 @@{"name": "openvibe-sdk",-- "version": "0.103.0",++ "version": "0.104.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",@@@ -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.103.0';++const SDK_VERSION = '0.104.0';module.exports = {createClient,@@@ -10,6 +10,38 @@*/const { isOpenVibeError } = require('./core/errors');++/** Manage the authenticated person's private, verified email addresses on Network. */++function createAccountEmailsClient({ networkUrl = 'https://openvibe.network', getToken, fetchImpl = globalThis.fetch } = {}) {++ if (typeof getToken !== 'function') throw new TypeError('createAccountEmailsClient: getToken must be a function');++ if (typeof fetchImpl !== 'function') throw new TypeError('createAccountEmailsClient: fetch is not available');++ const base = String(networkUrl || '').replace(/\/+$/, '');++ if (!base) throw new TypeError('createAccountEmailsClient: networkUrl is required');++ async function request(path, { method = 'GET', body } = {}) {++ const token = await getToken();++ if (!token) throw new TypeError('createAccountEmailsClient: getToken returned no token');++ const response = await fetchImpl(`${base}/api/v1/me/emails${path}`, {++ method,++ headers: { Accept: 'application/json', Authorization: `Bearer ${token}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },++ ...(body ? { body: JSON.stringify(body) } : {}),++ });++ const data = await response.json().catch(() => null);++ if (!response.ok) {++ const error = new Error(data && (data.detail || data.error) || `Network email request failed (${response.status})`);++ error.status = response.status;++ error.code = data && (data.code || data.error);++ throw error;++ }++ return data;++ }++ return {++ list: () => request(''),++ add: (email) => request('', { method: 'POST', body: { email } }),++ verify: (id) => request(`/${encodeURIComponent(String(id))}/verify`, { method: 'POST' }),++ remove: (id) => request(`/${encodeURIComponent(String(id))}`, { method: 'DELETE' }),++ makePrimary: (id) => request(`/${encodeURIComponent(String(id))}/primary`, { method: 'POST' }),++ };++}++const BATCH = 500;function createIdentityClient(client, { baseUrl } = {}) {@@@ -50,7 +82,14 @@ function createIdentityClient(client, { baseUrl } = {}) {return results;}-- return { resolve, resolveBatch };++ /** True only when the supplied email is verified for the supplied Network user subject. */++ async function isEmailVerified({ subject, email } = {}) {++ if (typeof subject !== 'string' || !subject || typeof email !== 'string' || !email) throw new TypeError('isEmailVerified: subject and email are required');++ const result = await call({ method: 'POST', path: '/api/v1/identity/emails/verified-check', json: { subject, email }, idempotent: true });++ return result?.verified === true;++ }++++ return { resolve, resolveBatch, isEmailVerified };}--module.exports = { createIdentityClient };++module.exports = { createIdentityClient, createAccountEmailsClient };@@@ -4,7 +4,7 @@ const assert = require('node:assert/strict');const { stubServer, send, run } = require('./helpers');const { createClient } = require('../src/core');const { createServiceTokenClient } = require('../src/auth');--const { createIdentityClient } = require('../src/identity');++const { createIdentityClient, createAccountEmailsClient } = require('../src/identity');const { createMockPlatform } = require('../src/testing');run([@@@ -42,4 +42,34 @@ run([await assert.rejects(identity.resolveBatch({ ids: [1] }), TypeError);await srv.close();}],++++ ['verified email check asks Network for one subject and address only', async () => {++ const srv = await stubServer((req, res, body) => {++ assert.equal(req.method, 'POST');++ assert.equal(req.url, '/api/v1/identity/emails/verified-check');++ assert.deepEqual(JSON.parse(body.toString()), { subject: 'usr_01JAB2C3D4E5F6G7H8J9K0MNPQ', email: '[email protected]' });++ send(res, 200, { verified: true });++ });++ const identity = createIdentityClient(createClient({ baseUrls: { network: srv.url }, token: 'svc' }));++ assert.equal(await identity.isEmailVerified({ subject: 'usr_01JAB2C3D4E5F6G7H8J9K0MNPQ', email: '[email protected]' }), true);++ await assert.rejects(identity.isEmailVerified({ email: '[email protected]' }), TypeError);++ await srv.close();++ }],++++ ["account email helpers use the signed-in person's Network API", async () => {++ const srv = await stubServer((req, res) => send(res, 200, { ok: true, emails: [] }));++ const emails = createAccountEmailsClient({ networkUrl: srv.url, getToken: () => 'person-token' });++ await emails.list();++ await emails.add('[email protected]');++ await emails.verify('email-id');++ await emails.makePrimary('email-id');++ await emails.remove('email-id');++ assert.deepEqual(srv.requests.map((r) => [r.method, r.url]), [++ ['GET', '/api/v1/me/emails'], ['POST', '/api/v1/me/emails'], ['POST', '/api/v1/me/emails/email-id/verify'],++ ['POST', '/api/v1/me/emails/email-id/primary'], ['DELETE', '/api/v1/me/emails/email-id'],++ ]);++ assert.ok(srv.requests.every((r) => r.headers.authorization === 'Bearer person-token'));++ assert.deepEqual(JSON.parse(srv.requests[1].body.toString()), { email: '[email protected]' });++ await srv.close();++ }],]);@@@ -16,5 +16,28 @@ export type ResolveBatchInput = { subjectIds: string[] } | { system: string; typexport interface IdentityClient {resolve(input: ResolveInput): Promise<SubjectProjection | null>;resolveBatch(input: ResolveBatchInput): Promise<Record<string, SubjectProjection | null>>;++ isEmailVerified(input: { subject: string; email: string }): Promise<boolean>;}export declare function createIdentityClient(client: OpenVibeClient, opts?: { baseUrl?: string }): IdentityClient;++++export interface AccountEmail {++ id: string;++ email: string;++ verified: boolean;++ verified_at: string | null;++ primary: boolean;++ created_at: string;++}++export interface AccountEmailsClient {++ list(): Promise<{ emails: AccountEmail[] }>;++ add(email: string): Promise<{ ok: boolean; message: string }>;++ verify(id: string): Promise<{ ok: boolean; message: string }>;++ remove(id: string): Promise<{ ok: boolean; emails: AccountEmail[] }>;++ makePrimary(id: string): Promise<{ ok: boolean; emails: AccountEmail[] }>;++}++/** Manage the current person's own addresses with an OpenVibe.Network user access token. */++export declare function createAccountEmailsClient(opts: {++ networkUrl?: string;++ getToken: () => string | Promise<string>;++ fetchImpl?: typeof fetch;++}): AccountEmailsClient;
@@ -1,5 +1,9 @@
@@ -1,5 +1,9 @@
# Changelog
# Changelog
+## 0.104.0 (2026-11-08)
+
+- Add `createAccountEmailsClient` to `openvibe-sdk/identity` for managing the signed-in person's verified Network email addresses.
+
## 0.103.0 (2026-11-08)
## 0.103.0 (2026-11-08)
- Add `openvibe-sdk/credentials`: `createCredentialsClient` for a person's own provider credentials on OpenVibe.AI:
- Add `openvibe-sdk/credentials`: `createCredentialsClient` for a person's own provider credentials on OpenVibe.AI:
@@ -2,7 +2,7 @@
@@ -2,7 +2,7 @@
> Supported browser and server clients for the OpenVibe platform.
> Supported browser and server clients for the OpenVibe platform.
-**Status:** alpha, v0.103.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.104.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.
@@ -11,7 +11,7 @@
@@ -11,7 +11,7 @@
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.103.0
+npm install https://codeload.github.com/OpenVibers/OpenVibe.SDK/tar.gz/refs/tags/v0.104.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).
@@ -166,7 +166,7 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client
@@ -166,7 +166,7 @@ Until OpenVibe.Tools serves the gateway facade (Tools S6), point the jobs client
| `openvibe-sdk/core` | both | `createClient()`, `OpenVibeError`, `paginate()`, `offsetPager()`, trace and id helpers, `CONTRACTS_RANGE` |
| `openvibe-sdk/core` | both | `createClient()`, `OpenVibeError`, `paginate()`, `offsetPager()`, trace and id helpers, `CONTRACTS_RANGE` |
| `openvibe-sdk/auth` | server (browser build: PKCE only) | `createServiceTokenClient()` (+ `getTokenInfo()`), `createNetworkKeys()`, `verifyUserToken()`, `verifyAppToken()`, `verifyServiceToken()`, `exchangeCode()`, `refreshUserToken()`; `startAuthorization()`, `buildAuthorizeUrl()`, `createPkcePair()`, `readCallback()`, `decodeUnverified()`, `unverifiedClaims()` |
| `openvibe-sdk/auth` | server (browser build: PKCE only) | `createServiceTokenClient()` (+ `getTokenInfo()`), `createNetworkKeys()`, `verifyUserToken()`, `verifyAppToken()`, `verifyServiceToken()`, `exchangeCode()`, `refreshUserToken()`; `startAuthorization()`, `buildAuthorizeUrl()`, `createPkcePair()`, `readCallback()`, `decodeUnverified()`, `unverifiedClaims()` |
| `openvibe-sdk/registry` | both | `createRegistryClient(client)`: `services({status})`, `service(id)`, `capabilities({owner})`, `capability(id)`, `namespaces()`, `contracts()`, `topics()`, `domain(host)`, `descriptor()` |
| `openvibe-sdk/registry` | both | `createRegistryClient(client)`: `services({status})`, `service(id)`, `capabilities({owner})`, `capability(id)`, `namespaces()`, `contracts()`, `topics()`, `domain(host)`, `descriptor()` |
-| `openvibe-sdk/identity` | server | `createIdentityClient(client)`: `resolve({subjectId} \| {system,type,id})`, `resolveBatch({subjectIds} \| {system,type,ids})` |
+| `openvibe-sdk/identity` | server | `createIdentityClient(client)`: `resolve({subjectId} \| {system,type,id})`, `resolveBatch({subjectIds} \| {system,type,ids})`; `createAccountEmailsClient({getToken})` manages the signed-in person's verified addresses ([guide](docs/identity-emails.md)) |
| `openvibe-sdk/trust` | both | `createTrustClient({networkUrl, getToken})`: `me()` reads the caller's own account or guest signals; `of(subject)` reads an account or guest with `identity.trust.read`; `isNew(signals, {hours})`, `atLeast(signals, band)`, `AGE_BANDS` |
| `openvibe-sdk/trust` | both | `createTrustClient({networkUrl, getToken})`: `me()` reads the caller's own account or guest signals; `of(subject)` reads an account or guest with `identity.trust.read`; `isNew(signals, {hours})`, `atLeast(signals, band)`, `AGE_BANDS` |
| `openvibe-sdk/notifications` | server | `createNotificationsClient(client)`: `push({subjectId \| userId, type, title, message, url, category, priority, …})` through Network (`network.notifications.push`); `{ sent, skipped }` or `{ sent: false, reason: 'unknown_subject' }`; attempted once, the caller retries |
| `openvibe-sdk/notifications` | server | `createNotificationsClient(client)`: `push({subjectId \| userId, type, title, message, url, category, priority, …})` through Network (`network.notifications.push`); `{ sent, skipped }` or `{ sent: false, reason: 'unknown_subject' }`; attempted once, the caller retries |
| `openvibe-sdk/modules` | both | `createModulesClient(client)`: `get`, `put(ns, data, {revision})`, `delete`, `list`, `update(ns, fn)`, `publicGet`; `forSubject.get/put/update` for services |
| `openvibe-sdk/modules` | both | `createModulesClient(client)`: `get`, `put(ns, data, {revision})`, `delete`, `list`, `update(ns, fn)`, `publicGet`; `forSubject.get/put/update` for services |
@@ -3,7 +3,7 @@
@@ -3,7 +3,7 @@
"stage": "alpha",
"stage": "alpha",
"code": true,
"code": true,
"wave": "W2",
"wave": "W2",
- "version": "0.103.0",
+ "version": "0.104.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",
@@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
-// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.103.0, MIT). Do not edit.
+// Generated by scripts/browser-bundle.js from browser.js (openvibe-sdk 0.104.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, community, bot, search, bench, meme, vision, themes, 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, community, bot, search, bench, meme, vision, themes, redact, chat, ai, credentials, jobs, tools, projects, geo). No server-only code: no service tokens, JWT verification, events, identity.
/* eslint-disable */
/* eslint-disable */
@@ -50,7 +50,7 @@ const { paginate, offsetPager } = __load(7);
@@ -50,7 +50,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.103.0';
+const SDK_VERSION = '0.104.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -162,6 +162,7 @@
@@ -162,6 +162,7 @@
},
},
"identity": {
"identity": {
"object": [
"object": [
+ "createAccountEmailsClient",
"createIdentityClient"
"createIdentityClient"
]
]
},
},
@@ -720,6 +721,7 @@
@@ -720,6 +721,7 @@
"createHostClient": "function"
"createHostClient": "function"
},
},
"openvibe-sdk/identity": {
"openvibe-sdk/identity": {
+ "createAccountEmailsClient": "function",
"createIdentityClient": "function"
"createIdentityClient": "function"
},
},
"openvibe-sdk/inventory": {
"openvibe-sdk/inventory": {
new file mode 100644
new file mode 100644
@@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
+# Account email addresses
+
+Use `createAccountEmailsClient` with the signed-in person's Network access token. It only reads and changes that person's own list; email addresses are private until the person shares one.
+
+```js
+const { createAccountEmailsClient } = require('openvibe-sdk/identity');
+
+const emails = createAccountEmailsClient({
+ getToken: () => session.accessToken,
+});
+
+const { emails: addresses } = await emails.list();
+await emails.add('[email protected]'); // Network sends a single-use verification link
+await emails.makePrimary(addresses[1].id); // verified addresses only
+await emails.remove(addresses[0].id); // choose a new primary first
+```
+
+`verify(id)` asks Network to send the verification link again. Verification links expire after one hour and can be used once. Keep the access token on the person's trusted client or server and do not log it.
+
+Services holding `identity.emails.read` can check one subject and address without receiving an address list:
+
+```js
+const { createIdentityClient } = require('openvibe-sdk/identity');
+const identity = createIdentityClient(serviceClient);
+const verified = await identity.isEmailVerified({ subject: 'usr_…', email: '[email protected]' });
+```
+
+Unknown subjects and addresses both return `false`. Making an address primary or removing one requires a sign-in from the last ten minutes.
@@ -2,6 +2,6 @@
@@ -2,6 +2,6 @@
import cjs from '../src/identity.js';
import cjs from '../src/identity.js';
export const {
export const {
- createIdentityClient,
+ createIdentityClient, createAccountEmailsClient,
} = cjs;
} = cjs;
export default cjs;
export default cjs;
@@ -1,12 +1,12 @@
@@ -1,12 +1,12 @@
{
{
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.103.0",
+ "version": "0.104.0",
"lockfileVersion": 3,
"lockfileVersion": 3,
"requires": true,
"requires": true,
"packages": {
"packages": {
"": {
"": {
"name": "openvibe-sdk",
"name": "openvibe-sdk",
- "version": "0.103.0",
+ "version": "0.104.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.103.0",
+ "version": "0.104.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",
@@ -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.103.0';
+const SDK_VERSION = '0.104.0';
module.exports = {
module.exports = {
createClient,
createClient,
@@ -10,6 +10,38 @@
@@ -10,6 +10,38 @@
*/
*/
const { isOpenVibeError } = require('./core/errors');
const { isOpenVibeError } = require('./core/errors');
+/** Manage the authenticated person's private, verified email addresses on Network. */
+function createAccountEmailsClient({ networkUrl = 'https://openvibe.network', getToken, fetchImpl = globalThis.fetch } = {}) {
+ if (typeof getToken !== 'function') throw new TypeError('createAccountEmailsClient: getToken must be a function');
+ if (typeof fetchImpl !== 'function') throw new TypeError('createAccountEmailsClient: fetch is not available');
+ const base = String(networkUrl || '').replace(/\/+$/, '');
+ if (!base) throw new TypeError('createAccountEmailsClient: networkUrl is required');
+ async function request(path, { method = 'GET', body } = {}) {
+ const token = await getToken();
+ if (!token) throw new TypeError('createAccountEmailsClient: getToken returned no token');
+ const response = await fetchImpl(`${base}/api/v1/me/emails${path}`, {
+ method,
+ headers: { Accept: 'application/json', Authorization: `Bearer ${token}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },
+ ...(body ? { body: JSON.stringify(body) } : {}),
+ });
+ const data = await response.json().catch(() => null);
+ if (!response.ok) {
+ const error = new Error(data && (data.detail || data.error) || `Network email request failed (${response.status})`);
+ error.status = response.status;
+ error.code = data && (data.code || data.error);
+ throw error;
+ }
+ return data;
+ }
+ return {
+ list: () => request(''),
+ add: (email) => request('', { method: 'POST', body: { email } }),
+ verify: (id) => request(`/${encodeURIComponent(String(id))}/verify`, { method: 'POST' }),
+ remove: (id) => request(`/${encodeURIComponent(String(id))}`, { method: 'DELETE' }),
+ makePrimary: (id) => request(`/${encodeURIComponent(String(id))}/primary`, { method: 'POST' }),
+ };
+}
+
const BATCH = 500;
const BATCH = 500;
function createIdentityClient(client, { baseUrl } = {}) {
function createIdentityClient(client, { baseUrl } = {}) {
@@ -50,7 +82,14 @@ function createIdentityClient(client, { baseUrl } = {}) {
@@ -50,7 +82,14 @@ function createIdentityClient(client, { baseUrl } = {}) {
return results;
return results;
}
}
- return { resolve, resolveBatch };
+ /** True only when the supplied email is verified for the supplied Network user subject. */
+ async function isEmailVerified({ subject, email } = {}) {
+ if (typeof subject !== 'string' || !subject || typeof email !== 'string' || !email) throw new TypeError('isEmailVerified: subject and email are required');
+ const result = await call({ method: 'POST', path: '/api/v1/identity/emails/verified-check', json: { subject, email }, idempotent: true });
+ return result?.verified === true;
+ }
+
+ return { resolve, resolveBatch, isEmailVerified };
}
}
-module.exports = { createIdentityClient };
+module.exports = { createIdentityClient, createAccountEmailsClient };
@@ -4,7 +4,7 @@ const assert = require('node:assert/strict');
@@ -4,7 +4,7 @@ const assert = require('node:assert/strict');
const { stubServer, send, run } = require('./helpers');
const { stubServer, send, run } = require('./helpers');
const { createClient } = require('../src/core');
const { createClient } = require('../src/core');
const { createServiceTokenClient } = require('../src/auth');
const { createServiceTokenClient } = require('../src/auth');
-const { createIdentityClient } = require('../src/identity');
+const { createIdentityClient, createAccountEmailsClient } = require('../src/identity');
const { createMockPlatform } = require('../src/testing');
const { createMockPlatform } = require('../src/testing');
run([
run([
@@ -42,4 +42,34 @@ run([
@@ -42,4 +42,34 @@ run([
await assert.rejects(identity.resolveBatch({ ids: [1] }), TypeError);
await assert.rejects(identity.resolveBatch({ ids: [1] }), TypeError);
await srv.close();
await srv.close();
}],
}],
+
+ ['verified email check asks Network for one subject and address only', async () => {
+ const srv = await stubServer((req, res, body) => {
+ assert.equal(req.method, 'POST');
+ assert.equal(req.url, '/api/v1/identity/emails/verified-check');
+ assert.deepEqual(JSON.parse(body.toString()), { subject: 'usr_01JAB2C3D4E5F6G7H8J9K0MNPQ', email: '[email protected]' });
+ send(res, 200, { verified: true });
+ });
+ const identity = createIdentityClient(createClient({ baseUrls: { network: srv.url }, token: 'svc' }));
+ assert.equal(await identity.isEmailVerified({ subject: 'usr_01JAB2C3D4E5F6G7H8J9K0MNPQ', email: '[email protected]' }), true);
+ await assert.rejects(identity.isEmailVerified({ email: '[email protected]' }), TypeError);
+ await srv.close();
+ }],
+
+ ["account email helpers use the signed-in person's Network API", async () => {
+ const srv = await stubServer((req, res) => send(res, 200, { ok: true, emails: [] }));
+ const emails = createAccountEmailsClient({ networkUrl: srv.url, getToken: () => 'person-token' });
+ await emails.list();
+ await emails.add('[email protected]');
+ await emails.verify('email-id');
+ await emails.makePrimary('email-id');
+ await emails.remove('email-id');
+ assert.deepEqual(srv.requests.map((r) => [r.method, r.url]), [
+ ['GET', '/api/v1/me/emails'], ['POST', '/api/v1/me/emails'], ['POST', '/api/v1/me/emails/email-id/verify'],
+ ['POST', '/api/v1/me/emails/email-id/primary'], ['DELETE', '/api/v1/me/emails/email-id'],
+ ]);
+ assert.ok(srv.requests.every((r) => r.headers.authorization === 'Bearer person-token'));
+ assert.deepEqual(JSON.parse(srv.requests[1].body.toString()), { email: '[email protected]' });
+ await srv.close();
+ }],
]);
]);
@@ -16,5 +16,28 @@ export type ResolveBatchInput = { subjectIds: string[] } | { system: string; typ
@@ -16,5 +16,28 @@ export type ResolveBatchInput = { subjectIds: string[] } | { system: string; typ
export interface IdentityClient {
export interface IdentityClient {
resolve(input: ResolveInput): Promise<SubjectProjection | null>;
resolve(input: ResolveInput): Promise<SubjectProjection | null>;
resolveBatch(input: ResolveBatchInput): Promise<Record<string, SubjectProjection | null>>;
resolveBatch(input: ResolveBatchInput): Promise<Record<string, SubjectProjection | null>>;
+ isEmailVerified(input: { subject: string; email: string }): Promise<boolean>;
}
}
export declare function createIdentityClient(client: OpenVibeClient, opts?: { baseUrl?: string }): IdentityClient;
export declare function createIdentityClient(client: OpenVibeClient, opts?: { baseUrl?: string }): IdentityClient;
+
+export interface AccountEmail {
+ id: string;
+ email: string;
+ verified: boolean;
+ verified_at: string | null;
+ primary: boolean;
+ created_at: string;
+}
+export interface AccountEmailsClient {
+ list(): Promise<{ emails: AccountEmail[] }>;
+ add(email: string): Promise<{ ok: boolean; message: string }>;
+ verify(id: string): Promise<{ ok: boolean; message: string }>;
+ remove(id: string): Promise<{ ok: boolean; emails: AccountEmail[] }>;
+ makePrimary(id: string): Promise<{ ok: boolean; emails: AccountEmail[] }>;
+}
+/** Manage the current person's own addresses with an OpenVibe.Network user access token. */
+export declare function createAccountEmailsClient(opts: {
+ networkUrl?: string;
+ getToken: () => string | Promise<string>;
+ fetchImpl?: typeof fetch;
+}): AccountEmailsClient;