@scrypted/client
Advanced tools
Comparing version 1.1.15 to 1.1.16
@@ -12,1 +12,3 @@ export interface RefreshPromise<T> { | ||
export declare function timeoutFunction<T>(timeout: number, f: (isTimedOut: () => boolean) => Promise<T>): Promise<T>; | ||
export declare function createPromiseDebouncer<T>(): (func: () => Promise<T>) => Promise<T>; | ||
export declare function createMapPromiseDebouncer<T>(): (key: any, func: () => Promise<T>) => Promise<T>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.timeoutFunction = exports.timeoutPromise = exports.TimeoutError = exports.singletonPromise = void 0; | ||
exports.createMapPromiseDebouncer = exports.createPromiseDebouncer = exports.timeoutFunction = exports.timeoutPromise = exports.TimeoutError = exports.singletonPromise = void 0; | ||
function singletonPromise(rp, method, cacheDuration = 0) { | ||
@@ -62,2 +62,24 @@ if (rp?.promise) | ||
exports.timeoutFunction = timeoutFunction; | ||
function createPromiseDebouncer() { | ||
let current; | ||
return (func) => { | ||
if (!current) | ||
current = func().finally(() => current = undefined); | ||
return current; | ||
}; | ||
} | ||
exports.createPromiseDebouncer = createPromiseDebouncer; | ||
function createMapPromiseDebouncer() { | ||
const map = new Map(); | ||
return (key, func) => { | ||
const keyStr = JSON.stringify(key); | ||
let value = map.get(keyStr); | ||
if (!value) { | ||
value = func().finally(() => map.delete(keyStr)); | ||
map.set(keyStr, value); | ||
} | ||
return value; | ||
}; | ||
} | ||
exports.createMapPromiseDebouncer = createMapPromiseDebouncer; | ||
//# sourceMappingURL=promise-utils.js.map |
@@ -262,3 +262,2 @@ "use strict"; | ||
await answerClient.setRemoteDescription(offer, answerSetup); | ||
answerQueue.flush(); | ||
const answer = await answerClient.createLocalDescription('answer', answerSetup, disableTrickle ? undefined : offerQueue.queueSendCandidate); | ||
@@ -268,4 +267,5 @@ console.log('answer sdp', answer.sdp); | ||
offerQueue.flush(); | ||
answerQueue.flush(); | ||
} | ||
exports.connectRTCSignalingClients = connectRTCSignalingClients; | ||
//# sourceMappingURL=rtc-signaling.js.map |
{ | ||
"name": "@scrypted/client", | ||
"version": "1.1.15", | ||
"version": "1.1.16", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/packages/client/src/index.js", |
@@ -33,2 +33,3 @@ import { ScryptedStatic, RTCConnectionManagement } from "@scrypted/types"; | ||
} | ||
export declare function logoutScryptedClient(baseUrl?: string): Promise<any>; | ||
export declare function loginScryptedClient(options: ScryptedLoginOptions): Promise<{ | ||
@@ -35,0 +36,0 @@ authorization: string; |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.connectScryptedClient = exports.redirectScryptedLogout = exports.redirectScryptedLogin = exports.ScryptedClientLoginError = exports.checkScryptedClientLogin = exports.loginScryptedClient = void 0; | ||
exports.connectScryptedClient = exports.redirectScryptedLogout = exports.redirectScryptedLogin = exports.ScryptedClientLoginError = exports.checkScryptedClientLogin = exports.loginScryptedClient = exports.logoutScryptedClient = void 0; | ||
const axios_1 = __importDefault(require("axios")); | ||
@@ -62,2 +62,8 @@ const eio = __importStar(require("engine.io-client")); | ||
} | ||
async function logoutScryptedClient(baseUrl) { | ||
const url = baseUrl ? new URL('/logout', baseUrl).toString() : '/logout'; | ||
const response = await (0, axios_1.default)(url); | ||
return response.data; | ||
} | ||
exports.logoutScryptedClient = logoutScryptedClient; | ||
async function loginScryptedClient(options) { | ||
@@ -64,0 +70,0 @@ let { baseUrl, username, password, change_password, maxAge } = options; |
@@ -76,16 +76,36 @@ "use strict"; | ||
} | ||
/** | ||
* @deprecated | ||
*/ | ||
async getAuthenticatedPath(nativeId) { | ||
return `/endpoint/${this.getEndpoint(nativeId)}/`; | ||
return this.getPath(nativeId); | ||
} | ||
/** | ||
* @deprecated | ||
*/ | ||
async getInsecurePublicLocalEndpoint(nativeId) { | ||
return `http://${await this.getUrlSafeIp()}:${await this.api.getComponent('SCRYPTED_INSECURE_PORT')}/endpoint/${this.getEndpoint(nativeId)}/public/`; | ||
return this.getLocalEndpoint(nativeId, { | ||
insecure: true, | ||
public: true, | ||
}); | ||
} | ||
/** | ||
* @deprecated | ||
*/ | ||
async getPublicCloudEndpoint(nativeId) { | ||
const local = await this.getPublicLocalEndpoint(nativeId); | ||
const mo = await this.mediaManager.createMediaObject(Buffer.from(local), types_1.ScryptedMimeTypes.LocalUrl); | ||
return this.mediaManager.convertMediaObjectToUrl(mo, types_1.ScryptedMimeTypes.LocalUrl); | ||
return this.getCloudEndpoint(nativeId, { | ||
public: true, | ||
}); | ||
} | ||
/** | ||
* @deprecated | ||
*/ | ||
async getPublicLocalEndpoint(nativeId) { | ||
return `https://${await this.getUrlSafeIp()}:${await this.api.getComponent('SCRYPTED_SECURE_PORT')}/endpoint/${this.getEndpoint(nativeId)}/public/`; | ||
return this.getLocalEndpoint(nativeId, { | ||
public: true, | ||
}); | ||
} | ||
/** | ||
* @deprecated | ||
*/ | ||
async getPublicPushEndpoint(nativeId) { | ||
@@ -95,5 +115,32 @@ const mo = await this.mediaManager.createMediaObject(Buffer.from(this.getEndpoint(nativeId)), types_1.ScryptedMimeTypes.PushEndpoint); | ||
} | ||
async deliverPush(endpoint, request) { | ||
return this.api.deliverPush(endpoint, request); | ||
async deliverPush(id, request) { | ||
return this.api.deliverPush(id, request); | ||
} | ||
async getPath(nativeId, options) { | ||
return `/endpoint/${this.getEndpoint(nativeId)}/${options?.public ? 'public/' : ''}`; | ||
} | ||
async getLocalEndpoint(nativeId, options) { | ||
const protocol = options?.insecure ? 'http' : 'https'; | ||
const port = await this.api.getComponent(options?.insecure ? 'SCRYPTED_INSECURE_PORT' : 'SCRYPTED_SECURE_PORT'); | ||
const path = await this.getPath(nativeId, options); | ||
const url = `${protocol}://${await this.getUrlSafeIp()}:${port}${path}`; | ||
return url; | ||
} | ||
async getCloudEndpoint(nativeId, options) { | ||
const local = await this.getLocalEndpoint(nativeId, options); | ||
const mo = await this.mediaManager.createMediaObject(Buffer.from(local), types_1.ScryptedMimeTypes.LocalUrl); | ||
return this.mediaManager.convertMediaObjectToUrl(mo, types_1.ScryptedMimeTypes.LocalUrl); | ||
} | ||
async getCloudPushEndpoint(nativeId) { | ||
const mo = await this.mediaManager.createMediaObject(Buffer.from(this.getEndpoint(nativeId)), types_1.ScryptedMimeTypes.PushEndpoint); | ||
return this.mediaManager.convertMediaObjectToUrl(mo, types_1.ScryptedMimeTypes.PushEndpoint); | ||
} | ||
async setLocalAddresses(addresses) { | ||
const addressSettings = await this.api.getComponent('addresses'); | ||
return addressSettings.setLocalAddresses(addresses); | ||
} | ||
async getLocalAddresses() { | ||
const addressSettings = await this.api.getComponent('addresses'); | ||
return await addressSettings.getLocalAddresses(); | ||
} | ||
} | ||
@@ -100,0 +147,0 @@ class DeviceStateProxyHandler { |
{ | ||
"name": "@scrypted/client", | ||
"version": "1.1.15", | ||
"version": "1.1.16", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/packages/client/src/index.js", |
@@ -75,2 +75,8 @@ import { ScryptedStatic, RTCConnectionManagement, RTCSignalingSession } from "@scrypted/types"; | ||
export async function logoutScryptedClient(baseUrl?: string) { | ||
const url = baseUrl ? new URL('/logout', baseUrl).toString() : '/logout'; | ||
const response = await axios(url); | ||
return response.data; | ||
} | ||
export async function loginScryptedClient(options: ScryptedLoginOptions) { | ||
@@ -77,0 +83,0 @@ let { baseUrl, username, password, change_password, maxAge } = options; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
350863
3688