@redseat/api 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/library.d.ts +33 -1
- package/dist/library.js +57 -1
- package/package.json +1 -1
package/dist/library.d.ts
CHANGED
|
@@ -79,7 +79,9 @@ export declare class LibraryApi {
|
|
|
79
79
|
private library;
|
|
80
80
|
private key?;
|
|
81
81
|
private keyText?;
|
|
82
|
-
|
|
82
|
+
private baseUrl?;
|
|
83
|
+
constructor(client: LibraryHttpClient, libraryId: string, library: ILibrary, baseUrl?: string);
|
|
84
|
+
setBaseUrl(baseUrl: string): void;
|
|
83
85
|
setKey(passPhrase: string): Promise<void>;
|
|
84
86
|
private getUrl;
|
|
85
87
|
getTags(query?: {
|
|
@@ -201,6 +203,36 @@ export declare class LibraryApi {
|
|
|
201
203
|
* @throws Error if the URL is not available or cannot be made permanent
|
|
202
204
|
*/
|
|
203
205
|
checkRequestPermanent(request: RsRequest): Promise<RsRequest>;
|
|
206
|
+
/**
|
|
207
|
+
* Get a share token for a request URL.
|
|
208
|
+
* The token can be used to stream/download the resource without authentication.
|
|
209
|
+
* @param url - The request URL to get a share token for
|
|
210
|
+
* @returns A temporary share token valid for 6 hours
|
|
211
|
+
*/
|
|
212
|
+
getRequestShareToken(url: string): Promise<string>;
|
|
213
|
+
/**
|
|
214
|
+
* Get a share token for a media file.
|
|
215
|
+
* The token can be used to access the media without authentication.
|
|
216
|
+
* @param mediaId - The media ID to get a share token for
|
|
217
|
+
* @returns A temporary share token valid for 6 hours
|
|
218
|
+
*/
|
|
219
|
+
getMediaShareToken(mediaId: string): Promise<string>;
|
|
220
|
+
/**
|
|
221
|
+
* Get a shareable URL for streaming a request.
|
|
222
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
223
|
+
* @param url - The request URL to create a share link for
|
|
224
|
+
* @returns A complete URL with sharetoken that can be used to stream the content
|
|
225
|
+
* @throws Error if baseUrl is not set
|
|
226
|
+
*/
|
|
227
|
+
getRequestShareUrl(url: string): Promise<string>;
|
|
228
|
+
/**
|
|
229
|
+
* Get a shareable URL for a media file.
|
|
230
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
231
|
+
* @param mediaId - The media ID to create a share link for
|
|
232
|
+
* @returns A complete URL with sharetoken that can be used to access the media
|
|
233
|
+
* @throws Error if baseUrl is not set
|
|
234
|
+
*/
|
|
235
|
+
getMediaShareUrl(mediaId: string): Promise<string>;
|
|
204
236
|
getUnassignedFaces(params?: Map<string, string>): Promise<any>;
|
|
205
237
|
getClusters(): Promise<any>;
|
|
206
238
|
assignFaces(request: any): Promise<any>;
|
package/dist/library.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { deriveKey, encryptText as encryptTextUtil, decryptText as decryptTextUtil, encryptBuffer, decryptBuffer, encryptFile as encryptFileUtil, decryptFile as decryptFileUtil, decryptFileThumb, encryptFilename as encryptFilenameUtil, getRandomIV as getRandomIVUtil } from './encryption.js';
|
|
2
2
|
import { uint8ArrayFromBase64 } from './crypto.js';
|
|
3
3
|
export class LibraryApi {
|
|
4
|
-
constructor(client, libraryId, library) {
|
|
4
|
+
constructor(client, libraryId, library, baseUrl) {
|
|
5
5
|
this.client = client;
|
|
6
6
|
this.libraryId = libraryId;
|
|
7
7
|
this.library = library;
|
|
8
|
+
this.baseUrl = baseUrl;
|
|
9
|
+
}
|
|
10
|
+
setBaseUrl(baseUrl) {
|
|
11
|
+
this.baseUrl = baseUrl;
|
|
8
12
|
}
|
|
9
13
|
async setKey(passPhrase) {
|
|
10
14
|
// Derive keys
|
|
@@ -459,6 +463,58 @@ export class LibraryApi {
|
|
|
459
463
|
const res = await this.client.post(this.getUrl('/plugins/requests/permanent'), request);
|
|
460
464
|
return res.data;
|
|
461
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* Get a share token for a request URL.
|
|
468
|
+
* The token can be used to stream/download the resource without authentication.
|
|
469
|
+
* @param url - The request URL to get a share token for
|
|
470
|
+
* @returns A temporary share token valid for 6 hours
|
|
471
|
+
*/
|
|
472
|
+
async getRequestShareToken(url) {
|
|
473
|
+
const res = await this.client.get(this.getUrl('/plugins/requests/url/sharetoken'), {
|
|
474
|
+
params: { url }
|
|
475
|
+
});
|
|
476
|
+
return res.data;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Get a share token for a media file.
|
|
480
|
+
* The token can be used to access the media without authentication.
|
|
481
|
+
* @param mediaId - The media ID to get a share token for
|
|
482
|
+
* @returns A temporary share token valid for 6 hours
|
|
483
|
+
*/
|
|
484
|
+
async getMediaShareToken(mediaId) {
|
|
485
|
+
const res = await this.client.get(this.getUrl(`/medias/${mediaId}/sharetoken`));
|
|
486
|
+
return res.data;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Get a shareable URL for streaming a request.
|
|
490
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
491
|
+
* @param url - The request URL to create a share link for
|
|
492
|
+
* @returns A complete URL with sharetoken that can be used to stream the content
|
|
493
|
+
* @throws Error if baseUrl is not set
|
|
494
|
+
*/
|
|
495
|
+
async getRequestShareUrl(url) {
|
|
496
|
+
if (!this.baseUrl) {
|
|
497
|
+
throw new Error('baseUrl must be set to generate share URLs. Call setBaseUrl() first.');
|
|
498
|
+
}
|
|
499
|
+
const shareToken = await this.getRequestShareToken(url);
|
|
500
|
+
const params = new URLSearchParams({ sharetoken: shareToken, url });
|
|
501
|
+
return `${this.baseUrl}${this.getUrl('/plugins/requests/url/stream')}?${params.toString()}`;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Get a shareable URL for a media file.
|
|
505
|
+
* Fetches a share token and returns a complete URL that can be used without authentication.
|
|
506
|
+
* @param mediaId - The media ID to create a share link for
|
|
507
|
+
* @returns A complete URL with sharetoken that can be used to access the media
|
|
508
|
+
* @throws Error if baseUrl is not set
|
|
509
|
+
*/
|
|
510
|
+
async getMediaShareUrl(mediaId) {
|
|
511
|
+
if (!this.baseUrl) {
|
|
512
|
+
throw new Error('baseUrl must be set to generate share URLs. Call setBaseUrl() first.');
|
|
513
|
+
}
|
|
514
|
+
const shareToken = await this.getMediaShareToken(mediaId);
|
|
515
|
+
const params = new URLSearchParams({ sharetoken: shareToken });
|
|
516
|
+
return `${this.baseUrl}${this.getUrl(`/medias/${mediaId}`)}?${params.toString()}`;
|
|
517
|
+
}
|
|
462
518
|
async getUnassignedFaces(params) {
|
|
463
519
|
const queryParams = {};
|
|
464
520
|
if (params) {
|