@unboundcx/sdk 2.6.0 → 2.6.1
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/package.json +1 -1
- package/services/storage.js +27 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
package/services/storage.js
CHANGED
|
@@ -495,4 +495,31 @@ export class StorageService {
|
|
|
495
495
|
const result = await this.sdk._fetch('/storage/files', 'GET', params);
|
|
496
496
|
return result;
|
|
497
497
|
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Generate an access key for an existing storage file
|
|
501
|
+
* @param {string} fileId - The storage file ID
|
|
502
|
+
* @param {number} expiresIn - Access key expiration time in seconds (default: 1800 = 30 minutes)
|
|
503
|
+
* @returns {Promise<Object>} Object containing access key, URL, and expiration info
|
|
504
|
+
*/
|
|
505
|
+
async generateAccessKey(fileId, expiresIn = 1800) {
|
|
506
|
+
this.sdk.validateParams(
|
|
507
|
+
{ fileId, expiresIn },
|
|
508
|
+
{
|
|
509
|
+
fileId: { type: 'string', required: true },
|
|
510
|
+
expiresIn: { type: 'number', required: false },
|
|
511
|
+
},
|
|
512
|
+
);
|
|
513
|
+
|
|
514
|
+
const params = {
|
|
515
|
+
body: { expiresIn },
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
const result = await this.sdk._fetch(
|
|
519
|
+
`/storage/${fileId}/accessKey`,
|
|
520
|
+
'POST',
|
|
521
|
+
params,
|
|
522
|
+
);
|
|
523
|
+
return result;
|
|
524
|
+
}
|
|
498
525
|
}
|