openvidu-node-client: update dependencies

v2
pabloFuente 2025-11-19 17:46:48 +01:00
parent 5cf0cf0e11
commit 390fdc4870
16 changed files with 4524 additions and 496 deletions

View File

@ -0,0 +1,4 @@
node_modules
lib
coverage
dist

View File

@ -1,10 +1,10 @@
{ {
"singleQuote": true, "singleQuote": true,
"printWidth": 140, "printWidth": 140,
"trailingComma": "none", "trailingComma": "none",
"semi": true, "semi": true,
"bracketSpacing": true, "bracketSpacing": true,
"useTabs": false, "useTabs": false,
"jsxSingleQuote": true, "jsxSingleQuote": true,
"tabWidth": 4 "tabWidth": 4
} }

View File

@ -0,0 +1,8 @@
{
"printWidth": 120,
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "none",
"semi": true,
"arrowParens": "avoid"
}

View File

@ -5,8 +5,7 @@
[![][OpenViduLogo]](https://openvidu.io) [![][OpenViduLogo]](https://openvidu.io)
openvidu-node-client # openvidu-node-client
===
- **Description**: Library for your NODE server. It is a fully compatible and simple alternative to the REST API exposed by OpenVidu Server. - **Description**: Library for your NODE server. It is a fully compatible and simple alternative to the REST API exposed by OpenVidu Server.

View File

@ -17,4 +17,4 @@
"excludeProtected": true, "excludeProtected": true,
"excludeInternal": true "excludeInternal": true
} }
} }

View File

@ -1,81 +1,37 @@
{ {
"extends": "tslint:recommended", "extends": "tslint:recommended",
"rules": { "rules": {
"array-type": [ "array-type": [true, "array"],
true,
"array"
],
"ban-types": { "ban-types": {
"options": [ "options": [
[ ["Object", "Avoid using the `Object` type. Did you mean `object`?"],
"Object",
"Avoid using the `Object` type. Did you mean `object`?"
],
[ [
"Function", "Function",
"Avoid using the `Function` type. Prefer a specific function type, like `() => void`, or use `ts.AnyFunction`." "Avoid using the `Function` type. Prefer a specific function type, like `() => void`, or use `ts.AnyFunction`."
], ],
[ ["Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?"],
"Boolean", ["Number", "Avoid using the `Number` type. Did you mean `number`?"],
"Avoid using the `Boolean` type. Did you mean `boolean`?" ["String", "Avoid using the `String` type. Did you mean `string`?"]
],
[
"Number",
"Avoid using the `Number` type. Did you mean `number`?"
],
[
"String",
"Avoid using the `String` type. Did you mean `string`?"
]
] ]
}, },
"class-name": true, "class-name": true,
"comment-format": [ "comment-format": [true, "check-space"],
true, "curly": [true, "ignore-same-line"],
"check-space" "indent": [true, "spaces", 2],
], "interface-name": [true, "never-prefix"],
"curly": [
true,
"ignore-same-line"
],
"indent": [
true,
"spaces",
2
],
"interface-name": [
true,
"never-prefix"
],
"interface-over-type-literal": true, "interface-over-type-literal": true,
"jsdoc-format": true, "jsdoc-format": true,
"no-inferrable-types": true, "no-inferrable-types": true,
"no-internal-module": true, "no-internal-module": true,
"no-null-keyword": false, "no-null-keyword": false,
"no-switch-case-fall-through": true, "no-switch-case-fall-through": true,
"no-trailing-whitespace": [ "no-trailing-whitespace": [true, "ignore-template-strings"],
true,
"ignore-template-strings"
],
"no-var-keyword": true, "no-var-keyword": true,
"object-literal-shorthand": true, "object-literal-shorthand": true,
"one-line": [ "one-line": [true, "check-open-brace", "check-whitespace"],
true,
"check-open-brace",
"check-whitespace"
],
"prefer-const": true, "prefer-const": true,
"quotemark": [ "quotemark": [true, "single", "avoid-escape", "avoid-template"],
true, "semicolon": [true, "always", "ignore-bound-class-methods"],
"single",
"avoid-escape",
"avoid-template"
],
"semicolon": [
true,
"always",
"ignore-bound-class-methods"
],
"space-within-parens": true, "space-within-parens": true,
"triple-equals": true, "triple-equals": true,
"typedef-whitespace": [ "typedef-whitespace": [
@ -95,29 +51,10 @@
"variable-declaration": "onespace" "variable-declaration": "onespace"
} }
], ],
"whitespace": [ "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-module", "check-separator", "check-type"],
true, "no-implicit-dependencies": [true, "dev"],
"check-branch", "object-literal-key-quotes": [true, "consistent-as-needed"],
"check-decl", "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"],
"check-operator",
"check-module",
"check-separator",
"check-type"
],
"no-implicit-dependencies": [
true,
"dev"
],
"object-literal-key-quotes": [
true,
"consistent-as-needed"
],
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-leading-underscore"
],
"arrow-parens": false, "arrow-parens": false,
"arrow-return-shorthand": false, "arrow-return-shorthand": false,
"forin": false, "forin": false,
@ -151,4 +88,4 @@
"one-variable-per-declaration": false, "one-variable-per-declaration": false,
"unified-signatures": false "unified-signatures": false
} }
} }

View File

@ -1,22 +1,17 @@
module.exports = { module.exports = {
lib: [ lib: ['lib.dom.d.ts', 'lib.es5.d.ts', 'lib.es2015.promise.d.ts', 'lib.scripthost.d.ts'],
"lib.dom.d.ts", mode: 'file',
"lib.es5.d.ts", module: 'commonjs',
"lib.es2015.promise.d.ts", name: 'OpenVidu Node Client',
"lib.scripthost.d.ts" target: 'es5',
], externalPattern: 'node_modules',
mode: "file",
module: "commonjs",
name: "OpenVidu Node Client",
target: "es5",
externalPattern: "node_modules",
excludeExternals: true, excludeExternals: true,
excludePrivate: true, excludePrivate: true,
excludeProtected: true, excludeProtected: true,
excludeNotExported: true, excludeNotExported: true,
theme: "default", theme: 'default',
readme: "none", readme: 'none',
includeVersion: true, includeVersion: true,
listInvalidSymbolLinks: true, listInvalidSymbolLinks: true,
out: "./docs" out: './docs'
} };

View File

@ -0,0 +1,90 @@
import importPlugin from 'eslint-plugin-import';
import jsdoc from 'eslint-plugin-jsdoc';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: ['lib/**', 'node_modules/**']
},
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
files: ['src/**/*.ts'],
languageOptions: {
parser: tseslint.parser
},
plugins: {
'@typescript-eslint': tseslint.plugin,
import: importPlugin,
jsdoc
},
settings: {
jsdoc: {
mode: 'typescript'
},
'import/resolver': {
typescript: {
project: ['./tsconfig.json']
}
}
},
rules: {
'@typescript-eslint/array-type': ['error', { default: 'array-simple', readonly: 'array-simple' }],
'@typescript-eslint/no-restricted-types': [
'error',
{
types: {
Object: {
message: 'Avoid using the `Object` type. Did you mean `object`?'
},
Function: {
message: 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.'
},
Boolean: {
message: 'Avoid using the `Boolean` type. Did you mean `boolean`?'
},
Number: {
message: 'Avoid using the `Number` type. Did you mean `number`?'
},
String: {
message: 'Avoid using the `String` type. Did you mean `string`?'
}
}
}
],
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/no-duplicate-enum-values': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }
],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: false
}
}
],
'dot-notation': 'error',
semi: ['error', 'always'],
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'jsdoc/check-alignment': 'off',
'jsdoc/check-indentation': 'off',
'no-trailing-spaces': ['error', { skipBlankLines: false, ignoreComments: false }],
'no-var': 'off',
'prefer-rest-params': 'off',
'prefer-const': 'off',
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }]
}
}
);

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,22 @@
{ {
"author": "OpenVidu", "author": "OpenVidu",
"dependencies": { "dependencies": {
"axios": "1.7.9", "axios": "1.13.2",
"buffer": "6.0.3" "buffer": "6.0.3"
}, },
"description": "OpenVidu Node Client", "description": "OpenVidu Node Client",
"devDependencies": { "devDependencies": {
"@types/node": "20.12.12", "@eslint/js": "9.39.1",
"@types/node": "24.10.1",
"eslint": "9.39.1",
"eslint-import-resolver-typescript": "4.4.4",
"eslint-plugin-import": "2.32.0",
"eslint-plugin-jsdoc": "61.3.0",
"prettier": "3.6.2",
"ts-node": "10.9.2", "ts-node": "10.9.2",
"tslint": "6.1.3", "typedoc": "0.28.14",
"typedoc": "0.25.13", "typescript": "5.9.3",
"typescript": "5.4.5" "typescript-eslint": "8.47.0"
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"main": "lib/index.js", "main": "lib/index.js",
@ -20,8 +26,10 @@
"url": "git://github.com/OpenVidu/openvidu" "url": "git://github.com/OpenVidu/openvidu"
}, },
"scripts": { "scripts": {
"build": "./node_modules/typescript/bin/tsc", "build": "npm run lint && npm run beautify && ./node_modules/typescript/bin/tsc",
"docs": "./generate-docs.sh" "docs": "./generate-docs.sh",
"lint": "eslint \"src/**/*.ts\"",
"beautify": "prettier --write ."
}, },
"typings": "lib/index.d.ts", "typings": "lib/index.d.ts",
"version": "2.31.0" "version": "2.31.0"

View File

@ -162,7 +162,7 @@ export class Connection {
json.publishers.forEach((jsonPublisher) => { json.publishers.forEach((jsonPublisher) => {
const publisherObj: Publisher = new Publisher(jsonPublisher); const publisherObj: Publisher = new Publisher(jsonPublisher);
fetchedPublisherIds.push(publisherObj.streamId); fetchedPublisherIds.push(publisherObj.streamId);
let storedPublisher = this.publishers.find((c) => c.streamId === publisherObj.streamId); const storedPublisher = this.publishers.find((c) => c.streamId === publisherObj.streamId);
if (!!storedPublisher) { if (!!storedPublisher) {
// 2. Update existing Publisher // 2. Update existing Publisher
@ -174,7 +174,7 @@ export class Connection {
}); });
// 4. Remove closed Publishers from local collection // 4. Remove closed Publishers from local collection
for (var i = this.publishers.length - 1; i >= 0; --i) { for (let i = this.publishers.length - 1; i >= 0; --i) {
if (!fetchedPublisherIds.includes(this.publishers[i].streamId)) { if (!fetchedPublisherIds.includes(this.publishers[i].streamId)) {
this.publishers.splice(i, 1); this.publishers.splice(i, 1);
} }
@ -194,7 +194,7 @@ export class Connection {
}); });
// 3. Remove closed Subscribers from local collection // 3. Remove closed Subscribers from local collection
for (var i = this.subscribers.length - 1; i >= 0; --i) { for (let i = this.subscribers.length - 1; i >= 0; --i) {
if (!fetchedSubscriberIds.includes(this.subscribers[i])) { if (!fetchedSubscriberIds.includes(this.subscribers[i])) {
this.subscribers.splice(i, 1); this.subscribers.splice(i, 1);
} }

View File

@ -20,7 +20,7 @@ export class OpenViduLogger {
*/ */
log(...args: any[]) { log(...args: any[]) {
if (!this.isProdMode) { if (!this.isProdMode) {
this.defaultConsoleLogger.log.apply(this.defaultConsoleLogger.logger, arguments); this.defaultConsoleLogger.log.apply(this.defaultConsoleLogger.logger, args);
} }
} }
@ -29,7 +29,7 @@ export class OpenViduLogger {
*/ */
debug(...args: any[]) { debug(...args: any[]) {
if (!this.isProdMode) { if (!this.isProdMode) {
this.defaultConsoleLogger.debug.apply(this.defaultConsoleLogger.logger, arguments); this.defaultConsoleLogger.debug.apply(this.defaultConsoleLogger.logger, args);
} }
} }
@ -38,7 +38,7 @@ export class OpenViduLogger {
*/ */
info(...args: any[]) { info(...args: any[]) {
if (!this.isProdMode) { if (!this.isProdMode) {
this.defaultConsoleLogger.info.apply(this.defaultConsoleLogger.logger, arguments); this.defaultConsoleLogger.info.apply(this.defaultConsoleLogger.logger, args);
} }
} }
@ -46,14 +46,14 @@ export class OpenViduLogger {
* @hidden * @hidden
*/ */
warn(...args: any[]) { warn(...args: any[]) {
this.defaultConsoleLogger.warn.apply(this.defaultConsoleLogger.logger, arguments); this.defaultConsoleLogger.warn.apply(this.defaultConsoleLogger.logger, args);
} }
/** /**
* @hidden * @hidden
*/ */
error(...args: any[]) { error(...args: any[]) {
this.defaultConsoleLogger.error.apply(this.defaultConsoleLogger.logger, arguments); this.defaultConsoleLogger.error.apply(this.defaultConsoleLogger.logger, args);
} }
enableProdMode() { enableProdMode() {

View File

@ -114,7 +114,10 @@ export class OpenVidu {
* *
* @param secret Secret configured in your OpenVidu deployment * @param secret Secret configured in your OpenVidu deployment
*/ */
constructor(private hostname: string, secret: string) { constructor(
private hostname: string,
secret: string
) {
this.setHostnameAndPort(); this.setHostnameAndPort();
this.basicAuth = this.getBasicAuth(secret); this.basicAuth = this.getBasicAuth(secret);
} }
@ -136,7 +139,7 @@ export class OpenVidu {
const session = new Session(this, properties); const session = new Session(this, properties);
session session
.getSessionHttp() .getSessionHttp()
.then((response) => { .then((_response) => {
this.activeSessions.push(session); this.activeSessions.push(session);
resolve(session); resolve(session);
}) })
@ -542,7 +545,7 @@ export class OpenVidu {
res.data.content.forEach((jsonSession) => { res.data.content.forEach((jsonSession) => {
const fetchedSession: Session = new Session(this, jsonSession); const fetchedSession: Session = new Session(this, jsonSession);
fetchedSessionIds.push(fetchedSession.sessionId); fetchedSessionIds.push(fetchedSession.sessionId);
let storedSession = this.activeSessions.find((s) => s.sessionId === fetchedSession.sessionId); const storedSession = this.activeSessions.find((s) => s.sessionId === fetchedSession.sessionId);
if (!!storedSession) { if (!!storedSession) {
// 2. Update existing Session // 2. Update existing Session
@ -559,8 +562,8 @@ export class OpenVidu {
}); });
// 4. Remove closed sessions from local collection // 4. Remove closed sessions from local collection
for (var i = this.activeSessions.length - 1; i >= 0; --i) { for (let i = this.activeSessions.length - 1; i >= 0; --i) {
let sessionId = this.activeSessions[i].sessionId; const sessionId = this.activeSessions[i].sessionId;
if (!fetchedSessionIds.includes(sessionId)) { if (!fetchedSessionIds.includes(sessionId)) {
logger.log("Removing closed session '" + sessionId + "'"); logger.log("Removing closed session '" + sessionId + "'");
hasChanged = true; hasChanged = true;
@ -587,7 +590,7 @@ export class OpenVidu {
* @returns A map paring every existing sessionId with true or false depending on whether it has changed or not * @returns A map paring every existing sessionId with true or false depending on whether it has changed or not
*/ */
fetchWebRtc(): Promise<any> { fetchWebRtc(): Promise<any> {
// tslint:disable:no-string-literal /* eslint-disable dot-notation */
const addWebRtcStatsToConnections = (connection: Connection, connectionsExtendedInfo: any) => { const addWebRtcStatsToConnections = (connection: Connection, connectionsExtendedInfo: any) => {
const connectionExtended = connectionsExtendedInfo.find((c) => c.connectionId === connection.connectionId); const connectionExtended = connectionsExtendedInfo.find((c) => c.connectionId === connection.connectionId);
if (!!connectionExtended) { if (!!connectionExtended) {
@ -679,7 +682,7 @@ export class OpenVidu {
addWebRtcStatsToConnections(connection, jsonSession.connections.content); addWebRtcStatsToConnections(connection, jsonSession.connections.content);
}); });
fetchedSessionIds.push(fetchedSession.sessionId); fetchedSessionIds.push(fetchedSession.sessionId);
let storedSession = this.activeSessions.find((s) => s.sessionId === fetchedSession.sessionId); const storedSession = this.activeSessions.find((s) => s.sessionId === fetchedSession.sessionId);
if (!!storedSession) { if (!!storedSession) {
// 2. Update existing Session // 2. Update existing Session
@ -713,8 +716,8 @@ export class OpenVidu {
}); });
// 4. Remove closed sessions from local collection // 4. Remove closed sessions from local collection
for (var i = this.activeSessions.length - 1; i >= 0; --i) { for (let i = this.activeSessions.length - 1; i >= 0; --i) {
let sessionId = this.activeSessions[i].sessionId; const sessionId = this.activeSessions[i].sessionId;
if (!fetchedSessionIds.includes(sessionId)) { if (!fetchedSessionIds.includes(sessionId)) {
logger.log("Removing closed session '" + sessionId + "'"); logger.log("Removing closed session '" + sessionId + "'");
sessionChanges[sessionId] = true; sessionChanges[sessionId] = true;
@ -736,7 +739,7 @@ export class OpenVidu {
}); });
}); });
} }
// tslint:enable:no-string-literal /* eslint-enable dot-notation */
/** /**
* Disable all logging except error level * Disable all logging except error level

View File

@ -62,7 +62,7 @@ export class Recording {
*/ */
properties: RecordingProperties; properties: RecordingProperties;
/* tslint:disable:no-string-literal */ /* eslint-disable dot-notation */
/** /**
* @hidden * @hidden
*/ */
@ -105,7 +105,7 @@ export class Recording {
: Recording.DefaultRecordingPropertiesValues.ignoreFailedStreams; : Recording.DefaultRecordingPropertiesValues.ignoreFailedStreams;
} }
} }
/* tslint:enable:no-string-literal */ /* eslint-enable dot-notation */
} }
export namespace Recording { export namespace Recording {

View File

@ -85,7 +85,10 @@ export class Session {
/** /**
* @hidden * @hidden
*/ */
constructor(private ov: OpenVidu, propertiesOrJson?) { constructor(
private ov: OpenVidu,
propertiesOrJson?
) {
if (!!propertiesOrJson) { if (!!propertiesOrJson) {
// Defined parameter // Defined parameter
if (!!propertiesOrJson.sessionId) { if (!!propertiesOrJson.sessionId) {
@ -315,11 +318,11 @@ export class Session {
connectionClosed.publishers.forEach((publisher) => { connectionClosed.publishers.forEach((publisher) => {
this.connections.forEach((con) => { this.connections.forEach((con) => {
con.subscribers = con.subscribers.filter((subscriber) => { con.subscribers = con.subscribers.filter((subscriber) => {
// tslint:disable:no-string-literal /* eslint-disable dot-notation */
if (!!subscriber['streamId']) { if (!!subscriber['streamId']) {
// Subscriber with advanced webRtc configuration properties // Subscriber with advanced webRtc configuration properties
return subscriber['streamId'] !== publisher.streamId; return subscriber['streamId'] !== publisher.streamId;
// tslint:enable:no-string-literal /* eslint-enable dot-notation */
} else { } else {
// Regular string subscribers // Regular string subscribers
return subscriber !== publisher.streamId; return subscriber !== publisher.streamId;
@ -381,11 +384,11 @@ export class Session {
connection.publishers = connection.publishers.filter((pub) => pub.streamId !== streamId); connection.publishers = connection.publishers.filter((pub) => pub.streamId !== streamId);
// Try to remove the Publisher from the Connection subscribers collection // Try to remove the Publisher from the Connection subscribers collection
if (!!connection.subscribers && connection.subscribers.length > 0) { if (!!connection.subscribers && connection.subscribers.length > 0) {
// tslint:disable:no-string-literal /* eslint-disable dot-notation */
if (!!connection.subscribers[0]['streamId']) { if (!!connection.subscribers[0]['streamId']) {
// Subscriber with advanced webRtc configuration properties // Subscriber with advanced webRtc configuration properties
connection.subscribers = connection.subscribers.filter((sub) => sub['streamId'] !== streamId); connection.subscribers = connection.subscribers.filter((sub) => sub['streamId'] !== streamId);
// tslint:enable:no-string-literal /* eslint-enable dot-notation */
} else { } else {
// Regular string subscribers // Regular string subscribers
connection.subscribers = connection.subscribers.filter((sub) => sub !== streamId); connection.subscribers = connection.subscribers.filter((sub) => sub !== streamId);
@ -570,7 +573,7 @@ export class Session {
json.connections.content.forEach((jsonConnection) => { json.connections.content.forEach((jsonConnection) => {
const connectionObj: Connection = new Connection(jsonConnection); const connectionObj: Connection = new Connection(jsonConnection);
fetchedConnectionIds.push(connectionObj.connectionId); fetchedConnectionIds.push(connectionObj.connectionId);
let storedConnection = this.connections.find((c) => c.connectionId === connectionObj.connectionId); const storedConnection = this.connections.find((c) => c.connectionId === connectionObj.connectionId);
if (!!storedConnection) { if (!!storedConnection) {
// 2. Update existing Connection // 2. Update existing Connection
@ -582,7 +585,7 @@ export class Session {
}); });
// 4. Remove closed sessions from local collection // 4. Remove closed sessions from local collection
for (var i = this.connections.length - 1; i >= 0; --i) { for (let i = this.connections.length - 1; i >= 0; --i) {
if (!fetchedConnectionIds.includes(this.connections[i].connectionId)) { if (!fetchedConnectionIds.includes(this.connections[i].connectionId)) {
this.connections.splice(i, 1); this.connections.splice(i, 1);
} }

View File

@ -1,27 +1,17 @@
{ {
"compileOnSave": false, "compileOnSave": false,
"compilerOptions": { "compilerOptions": {
"outDir": "lib", "outDir": "lib",
"baseUrl": "src", "baseUrl": "src",
"sourceMap": true, "sourceMap": true,
"declaration": true, "declaration": true,
"moduleResolution": "node", "moduleResolution": "node",
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"target": "es5", "target": "es5",
"typeRoots": [ "typeRoots": ["node_modules/@types"],
"node_modules/@types" "types": ["node"],
], "lib": ["es2016", "dom"]
"types": ["node"], },
"lib": [ "exclude": ["config", "docs", "lib", "node_modules"]
"es2016",
"dom"
]
},
"exclude": [
"config",
"docs",
"lib",
"node_modules"
]
} }