@squidcloud/client 1.0.104 → 1.0.106
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/cjs/index.js +115 -26
- package/dist/common/src/secret.types.d.ts +6 -0
- package/dist/esm/index.js +115 -26
- package/dist/typescript-client/src/rpc.manager.d.ts +5 -0
- package/dist/typescript-client/src/secret.client.d.ts +20 -0
- package/dist/typescript-client/src/squid.d.ts +3 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -29604,16 +29604,22 @@ function findMatchingPropertiesForKey(schema, key) {
|
|
|
29604
29604
|
|
|
29605
29605
|
;// CONCATENATED MODULE: ../common/src/secret.schemas.ts
|
|
29606
29606
|
/** @internal */
|
|
29607
|
-
const
|
|
29607
|
+
const SetSecretRequestSchema = {
|
|
29608
29608
|
type: 'object',
|
|
29609
29609
|
required: ['key', 'value'],
|
|
29610
29610
|
properties: {
|
|
29611
29611
|
key: { type: 'string', pattern: '[a-zA-Z0-9-_+]', nullable: false },
|
|
29612
|
-
value: {
|
|
29612
|
+
value: {
|
|
29613
|
+
anyOf: [
|
|
29614
|
+
{ type: 'string', nullable: false },
|
|
29615
|
+
{ type: 'number', nullable: false },
|
|
29616
|
+
{ type: 'boolean', nullable: false },
|
|
29617
|
+
],
|
|
29618
|
+
},
|
|
29613
29619
|
},
|
|
29614
29620
|
};
|
|
29615
29621
|
/** @internal */
|
|
29616
|
-
const
|
|
29622
|
+
const DeleteSecretRequestSchema = {
|
|
29617
29623
|
type: 'object',
|
|
29618
29624
|
required: ['key'],
|
|
29619
29625
|
properties: {
|
|
@@ -29786,6 +29792,7 @@ function getApplicationUrl(regionPrefix, appId, path) {
|
|
|
29786
29792
|
}
|
|
29787
29793
|
}
|
|
29788
29794
|
const url = parsedBaseUrl.toString();
|
|
29795
|
+
path = path.startsWith('/') ? path.slice(1) : path;
|
|
29789
29796
|
return (url.endsWith('/') ? url : url + '/') + path;
|
|
29790
29797
|
}
|
|
29791
29798
|
function getApplicationHttpHeaders(regionPrefix, appId) {
|
|
@@ -29947,7 +29954,9 @@ function createWebSocketWrapper(url, opts = {}) {
|
|
|
29947
29954
|
const $ = {
|
|
29948
29955
|
connected: false,
|
|
29949
29956
|
open() {
|
|
29950
|
-
|
|
29957
|
+
var _a;
|
|
29958
|
+
const wsConstructor = (_a = WebSocketClass === null || WebSocketClass === void 0 ? void 0 : WebSocketClass['WebSocket']) !== null && _a !== void 0 ? _a : WebSocketClass;
|
|
29959
|
+
ws = new wsConstructor(url, opts.protocols || []);
|
|
29951
29960
|
ws.onmessage = opts.onmessage || noop;
|
|
29952
29961
|
ws.onopen = function (e) {
|
|
29953
29962
|
$.connected = true;
|
|
@@ -32688,7 +32697,7 @@ class ClientIdService {
|
|
|
32688
32697
|
return this.clientIdSubject;
|
|
32689
32698
|
}
|
|
32690
32699
|
observeClientTooOld() {
|
|
32691
|
-
return this.clientTooOldSubject.pipe((0,external_rxjs_namespaceObject.filter)((v) => v), (0,external_rxjs_namespaceObject.map)((
|
|
32700
|
+
return this.clientTooOldSubject.pipe((0,external_rxjs_namespaceObject.filter)((v) => v), (0,external_rxjs_namespaceObject.map)(() => undefined));
|
|
32692
32701
|
}
|
|
32693
32702
|
/** there was a long-term disconnection of the socket */
|
|
32694
32703
|
notifyClientTooOld() {
|
|
@@ -48492,12 +48501,43 @@ class RpcManager {
|
|
|
48492
48501
|
getStaticHeaders() {
|
|
48493
48502
|
return this.staticHeaders;
|
|
48494
48503
|
}
|
|
48504
|
+
async ready() {
|
|
48505
|
+
// Waiting for socket connection to be established before sending an RPC request
|
|
48506
|
+
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(this.socketManager.observeConnectionReady().pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing()));
|
|
48507
|
+
await this.authManager.waitForReadyState();
|
|
48508
|
+
}
|
|
48509
|
+
async get(path, params) {
|
|
48510
|
+
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48511
|
+
try {
|
|
48512
|
+
await this.ready();
|
|
48513
|
+
const url = new URL(getApplicationUrl(this.region, this.appId, path));
|
|
48514
|
+
const searchParams = new URLSearchParams(url.search);
|
|
48515
|
+
for (const [key, value] of Object.entries(params || {})) {
|
|
48516
|
+
if (value !== null) {
|
|
48517
|
+
searchParams.set(key, value);
|
|
48518
|
+
}
|
|
48519
|
+
}
|
|
48520
|
+
url.search = searchParams.toString();
|
|
48521
|
+
const response = await external_cross_fetch_default()(url.toString(), {
|
|
48522
|
+
method: 'GET',
|
|
48523
|
+
headers: this.staticHeaders,
|
|
48524
|
+
});
|
|
48525
|
+
return await this.parseResponse(response);
|
|
48526
|
+
}
|
|
48527
|
+
finally {
|
|
48528
|
+
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
48529
|
+
}
|
|
48530
|
+
}
|
|
48495
48531
|
async post(path, message) {
|
|
48532
|
+
return this.postOrDelete('POST', path, message);
|
|
48533
|
+
}
|
|
48534
|
+
async delete(path, message) {
|
|
48535
|
+
return this.postOrDelete('DELETE', path, message);
|
|
48536
|
+
}
|
|
48537
|
+
async postOrDelete(method, path, message) {
|
|
48496
48538
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48497
48539
|
try {
|
|
48498
|
-
|
|
48499
|
-
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(this.socketManager.observeConnectionReady().pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing()));
|
|
48500
|
-
await this.authManager.waitForReadyState();
|
|
48540
|
+
await this.ready();
|
|
48501
48541
|
let headers = {
|
|
48502
48542
|
'Content-Type': 'application/json',
|
|
48503
48543
|
};
|
|
@@ -48507,31 +48547,34 @@ class RpcManager {
|
|
|
48507
48547
|
DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
|
|
48508
48548
|
const url = getApplicationUrl(this.region, this.appId, path);
|
|
48509
48549
|
const response = await external_cross_fetch_default()(url, {
|
|
48510
|
-
method
|
|
48550
|
+
method,
|
|
48511
48551
|
body: serialization_serializeObj(message),
|
|
48512
48552
|
headers: headers,
|
|
48513
48553
|
});
|
|
48514
|
-
|
|
48515
|
-
let json;
|
|
48516
|
-
try {
|
|
48517
|
-
text = await response.text();
|
|
48518
|
-
try {
|
|
48519
|
-
json = JSON.parse(text);
|
|
48520
|
-
}
|
|
48521
|
-
catch (_a) { }
|
|
48522
|
-
}
|
|
48523
|
-
catch (_b) {
|
|
48524
|
-
text = 'Cannot read body';
|
|
48525
|
-
}
|
|
48526
|
-
if (!response.ok) {
|
|
48527
|
-
throw new RpcError(response.status, response.statusText, response.headers, response.url, json === null || json === void 0 ? void 0 : json['message']);
|
|
48528
|
-
}
|
|
48529
|
-
return (json || text);
|
|
48554
|
+
return await this.parseResponse(response);
|
|
48530
48555
|
}
|
|
48531
48556
|
finally {
|
|
48532
48557
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
48533
48558
|
}
|
|
48534
48559
|
}
|
|
48560
|
+
async parseResponse(response) {
|
|
48561
|
+
let text;
|
|
48562
|
+
let json;
|
|
48563
|
+
try {
|
|
48564
|
+
text = await response.text();
|
|
48565
|
+
try {
|
|
48566
|
+
json = JSON.parse(text);
|
|
48567
|
+
}
|
|
48568
|
+
catch (_a) { }
|
|
48569
|
+
}
|
|
48570
|
+
catch (_b) {
|
|
48571
|
+
text = 'Cannot read body';
|
|
48572
|
+
}
|
|
48573
|
+
if (!response.ok) {
|
|
48574
|
+
throw new RpcError(response.status, response.statusText, response.headers, response.url, json === null || json === void 0 ? void 0 : json['message']);
|
|
48575
|
+
}
|
|
48576
|
+
return (json || text);
|
|
48577
|
+
}
|
|
48535
48578
|
}
|
|
48536
48579
|
class RpcError extends Error {
|
|
48537
48580
|
constructor(statusCode, statusText, headers, url, message) {
|
|
@@ -48543,6 +48586,45 @@ class RpcError extends Error {
|
|
|
48543
48586
|
}
|
|
48544
48587
|
}
|
|
48545
48588
|
|
|
48589
|
+
;// CONCATENATED MODULE: ./src/secret.client.ts
|
|
48590
|
+
class SecretClient {
|
|
48591
|
+
constructor(rpcManager) {
|
|
48592
|
+
this.rpcManager = rpcManager;
|
|
48593
|
+
}
|
|
48594
|
+
get(key) {
|
|
48595
|
+
return this.rpcManager.get('/secret/get', { key });
|
|
48596
|
+
}
|
|
48597
|
+
getAll() {
|
|
48598
|
+
return this.rpcManager.get('/secret/getAll');
|
|
48599
|
+
}
|
|
48600
|
+
upsert(key, value) {
|
|
48601
|
+
return this.rpcManager.post('/secret/upsert', { key, value });
|
|
48602
|
+
}
|
|
48603
|
+
delete(key) {
|
|
48604
|
+
return this.rpcManager.delete('/secret/delete', { key });
|
|
48605
|
+
}
|
|
48606
|
+
get apiKeys() {
|
|
48607
|
+
return new ApiKeysSecretClient(this.rpcManager);
|
|
48608
|
+
}
|
|
48609
|
+
}
|
|
48610
|
+
class ApiKeysSecretClient {
|
|
48611
|
+
constructor(rpcManager) {
|
|
48612
|
+
this.rpcManager = rpcManager;
|
|
48613
|
+
}
|
|
48614
|
+
get(key) {
|
|
48615
|
+
return this.rpcManager.get('/secret/api-key/get', { key });
|
|
48616
|
+
}
|
|
48617
|
+
getAll() {
|
|
48618
|
+
return this.rpcManager.get('/secret/api-key/getAll');
|
|
48619
|
+
}
|
|
48620
|
+
upsert(key) {
|
|
48621
|
+
return this.rpcManager.post('/secret/api-key/upsert', { key });
|
|
48622
|
+
}
|
|
48623
|
+
delete(key) {
|
|
48624
|
+
return this.rpcManager.delete('/secret/api-key/delete', { key });
|
|
48625
|
+
}
|
|
48626
|
+
}
|
|
48627
|
+
|
|
48546
48628
|
;// CONCATENATED MODULE: ./src/types.ts
|
|
48547
48629
|
/**
|
|
48548
48630
|
* @internal
|
|
@@ -48575,7 +48657,7 @@ class SocketManager {
|
|
|
48575
48657
|
* This value means we wait for 5 minutes before considering the client to be too old.
|
|
48576
48658
|
* Note: we make this a function so that we can easily override it in tests.
|
|
48577
48659
|
*/
|
|
48578
|
-
this.clientTooOldThreshold =
|
|
48660
|
+
this.clientTooOldThreshold = 30000;
|
|
48579
48661
|
this.destructManager.onDestruct(async () => {
|
|
48580
48662
|
await this.destruct();
|
|
48581
48663
|
});
|
|
@@ -48716,6 +48798,7 @@ class SocketManager {
|
|
|
48716
48798
|
|
|
48717
48799
|
|
|
48718
48800
|
|
|
48801
|
+
|
|
48719
48802
|
|
|
48720
48803
|
|
|
48721
48804
|
/**
|
|
@@ -48918,6 +49001,7 @@ class Squid {
|
|
|
48918
49001
|
this.apiManager = new ApiManager(this.clientIdService, this.rpcManager, this.socketManager, options.apiServerUrlOverrideMapping);
|
|
48919
49002
|
this.graphqlClientFactory = new GraphQLClientFactory(this.rpcManager, options.region, appId);
|
|
48920
49003
|
this.aiClientFactory = new AiClientFactory(this.rpcManager, this.socketManager);
|
|
49004
|
+
this.secretClient = new SecretClient(this.rpcManager);
|
|
48921
49005
|
this._connectionDetails = new ConnectionDetails(this.clientIdService, this.socketManager);
|
|
48922
49006
|
}
|
|
48923
49007
|
/**
|
|
@@ -48944,6 +49028,11 @@ class Squid {
|
|
|
48944
49028
|
static getInstances() {
|
|
48945
49029
|
return Object.values(Squid.squidInstancesMap);
|
|
48946
49030
|
}
|
|
49031
|
+
get secrets() {
|
|
49032
|
+
return (() => {
|
|
49033
|
+
return this.secretClient;
|
|
49034
|
+
})();
|
|
49035
|
+
}
|
|
48947
49036
|
validateNotDestructed() {
|
|
48948
49037
|
assert_assertTruthy(!this.destructManager.isDestructing, 'The client was already destructed.');
|
|
48949
49038
|
}
|
|
@@ -6,3 +6,9 @@ export type SecretValue = string | number | boolean;
|
|
|
6
6
|
export type ApiKey = string;
|
|
7
7
|
export declare const BACKEND_API_KEY = "_BACKEND_API_KEY";
|
|
8
8
|
export declare const APP_API_KEY = "APP_API_KEY";
|
|
9
|
+
export interface SecretEntry<T extends SecretValue = SecretValue> extends SecretMetadata {
|
|
10
|
+
value: T;
|
|
11
|
+
}
|
|
12
|
+
export interface ApiKeyEntry extends SecretMetadata {
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -29519,16 +29519,22 @@ function findMatchingPropertiesForKey(schema, key) {
|
|
|
29519
29519
|
|
|
29520
29520
|
;// CONCATENATED MODULE: ../common/src/secret.schemas.ts
|
|
29521
29521
|
/** @internal */
|
|
29522
|
-
const
|
|
29522
|
+
const SetSecretRequestSchema = {
|
|
29523
29523
|
type: 'object',
|
|
29524
29524
|
required: ['key', 'value'],
|
|
29525
29525
|
properties: {
|
|
29526
29526
|
key: { type: 'string', pattern: '[a-zA-Z0-9-_+]', nullable: false },
|
|
29527
|
-
value: {
|
|
29527
|
+
value: {
|
|
29528
|
+
anyOf: [
|
|
29529
|
+
{ type: 'string', nullable: false },
|
|
29530
|
+
{ type: 'number', nullable: false },
|
|
29531
|
+
{ type: 'boolean', nullable: false },
|
|
29532
|
+
],
|
|
29533
|
+
},
|
|
29528
29534
|
},
|
|
29529
29535
|
};
|
|
29530
29536
|
/** @internal */
|
|
29531
|
-
const
|
|
29537
|
+
const DeleteSecretRequestSchema = {
|
|
29532
29538
|
type: 'object',
|
|
29533
29539
|
required: ['key'],
|
|
29534
29540
|
properties: {
|
|
@@ -29701,6 +29707,7 @@ function getApplicationUrl(regionPrefix, appId, path) {
|
|
|
29701
29707
|
}
|
|
29702
29708
|
}
|
|
29703
29709
|
const url = parsedBaseUrl.toString();
|
|
29710
|
+
path = path.startsWith('/') ? path.slice(1) : path;
|
|
29704
29711
|
return (url.endsWith('/') ? url : url + '/') + path;
|
|
29705
29712
|
}
|
|
29706
29713
|
function getApplicationHttpHeaders(regionPrefix, appId) {
|
|
@@ -29862,7 +29869,9 @@ function createWebSocketWrapper(url, opts = {}) {
|
|
|
29862
29869
|
const $ = {
|
|
29863
29870
|
connected: false,
|
|
29864
29871
|
open() {
|
|
29865
|
-
|
|
29872
|
+
var _a;
|
|
29873
|
+
const wsConstructor = (_a = WebSocketClass === null || WebSocketClass === void 0 ? void 0 : WebSocketClass['WebSocket']) !== null && _a !== void 0 ? _a : WebSocketClass;
|
|
29874
|
+
ws = new wsConstructor(url, opts.protocols || []);
|
|
29866
29875
|
ws.onmessage = opts.onmessage || noop;
|
|
29867
29876
|
ws.onopen = function (e) {
|
|
29868
29877
|
$.connected = true;
|
|
@@ -32603,7 +32612,7 @@ class ClientIdService {
|
|
|
32603
32612
|
return this.clientIdSubject;
|
|
32604
32613
|
}
|
|
32605
32614
|
observeClientTooOld() {
|
|
32606
|
-
return this.clientTooOldSubject.pipe((0,external_rxjs_namespaceObject.filter)((v) => v), (0,external_rxjs_namespaceObject.map)((
|
|
32615
|
+
return this.clientTooOldSubject.pipe((0,external_rxjs_namespaceObject.filter)((v) => v), (0,external_rxjs_namespaceObject.map)(() => undefined));
|
|
32607
32616
|
}
|
|
32608
32617
|
/** there was a long-term disconnection of the socket */
|
|
32609
32618
|
notifyClientTooOld() {
|
|
@@ -48408,12 +48417,43 @@ class RpcManager {
|
|
|
48408
48417
|
getStaticHeaders() {
|
|
48409
48418
|
return this.staticHeaders;
|
|
48410
48419
|
}
|
|
48420
|
+
async ready() {
|
|
48421
|
+
// Waiting for socket connection to be established before sending an RPC request
|
|
48422
|
+
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(this.socketManager.observeConnectionReady().pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing()));
|
|
48423
|
+
await this.authManager.waitForReadyState();
|
|
48424
|
+
}
|
|
48425
|
+
async get(path, params) {
|
|
48426
|
+
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48427
|
+
try {
|
|
48428
|
+
await this.ready();
|
|
48429
|
+
const url = new URL(getApplicationUrl(this.region, this.appId, path));
|
|
48430
|
+
const searchParams = new URLSearchParams(url.search);
|
|
48431
|
+
for (const [key, value] of Object.entries(params || {})) {
|
|
48432
|
+
if (value !== null) {
|
|
48433
|
+
searchParams.set(key, value);
|
|
48434
|
+
}
|
|
48435
|
+
}
|
|
48436
|
+
url.search = searchParams.toString();
|
|
48437
|
+
const response = await (0,external_cross_fetch_namespaceObject["default"])(url.toString(), {
|
|
48438
|
+
method: 'GET',
|
|
48439
|
+
headers: this.staticHeaders,
|
|
48440
|
+
});
|
|
48441
|
+
return await this.parseResponse(response);
|
|
48442
|
+
}
|
|
48443
|
+
finally {
|
|
48444
|
+
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
48445
|
+
}
|
|
48446
|
+
}
|
|
48411
48447
|
async post(path, message) {
|
|
48448
|
+
return this.postOrDelete('POST', path, message);
|
|
48449
|
+
}
|
|
48450
|
+
async delete(path, message) {
|
|
48451
|
+
return this.postOrDelete('DELETE', path, message);
|
|
48452
|
+
}
|
|
48453
|
+
async postOrDelete(method, path, message) {
|
|
48412
48454
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48413
48455
|
try {
|
|
48414
|
-
|
|
48415
|
-
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(this.socketManager.observeConnectionReady().pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing()));
|
|
48416
|
-
await this.authManager.waitForReadyState();
|
|
48456
|
+
await this.ready();
|
|
48417
48457
|
let headers = {
|
|
48418
48458
|
'Content-Type': 'application/json',
|
|
48419
48459
|
};
|
|
@@ -48423,31 +48463,34 @@ class RpcManager {
|
|
|
48423
48463
|
DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
|
|
48424
48464
|
const url = getApplicationUrl(this.region, this.appId, path);
|
|
48425
48465
|
const response = await (0,external_cross_fetch_namespaceObject["default"])(url, {
|
|
48426
|
-
method
|
|
48466
|
+
method,
|
|
48427
48467
|
body: serialization_serializeObj(message),
|
|
48428
48468
|
headers: headers,
|
|
48429
48469
|
});
|
|
48430
|
-
|
|
48431
|
-
let json;
|
|
48432
|
-
try {
|
|
48433
|
-
text = await response.text();
|
|
48434
|
-
try {
|
|
48435
|
-
json = JSON.parse(text);
|
|
48436
|
-
}
|
|
48437
|
-
catch (_a) { }
|
|
48438
|
-
}
|
|
48439
|
-
catch (_b) {
|
|
48440
|
-
text = 'Cannot read body';
|
|
48441
|
-
}
|
|
48442
|
-
if (!response.ok) {
|
|
48443
|
-
throw new RpcError(response.status, response.statusText, response.headers, response.url, json === null || json === void 0 ? void 0 : json['message']);
|
|
48444
|
-
}
|
|
48445
|
-
return (json || text);
|
|
48470
|
+
return await this.parseResponse(response);
|
|
48446
48471
|
}
|
|
48447
48472
|
finally {
|
|
48448
48473
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
48449
48474
|
}
|
|
48450
48475
|
}
|
|
48476
|
+
async parseResponse(response) {
|
|
48477
|
+
let text;
|
|
48478
|
+
let json;
|
|
48479
|
+
try {
|
|
48480
|
+
text = await response.text();
|
|
48481
|
+
try {
|
|
48482
|
+
json = JSON.parse(text);
|
|
48483
|
+
}
|
|
48484
|
+
catch (_a) { }
|
|
48485
|
+
}
|
|
48486
|
+
catch (_b) {
|
|
48487
|
+
text = 'Cannot read body';
|
|
48488
|
+
}
|
|
48489
|
+
if (!response.ok) {
|
|
48490
|
+
throw new RpcError(response.status, response.statusText, response.headers, response.url, json === null || json === void 0 ? void 0 : json['message']);
|
|
48491
|
+
}
|
|
48492
|
+
return (json || text);
|
|
48493
|
+
}
|
|
48451
48494
|
}
|
|
48452
48495
|
class RpcError extends Error {
|
|
48453
48496
|
constructor(statusCode, statusText, headers, url, message) {
|
|
@@ -48459,6 +48502,45 @@ class RpcError extends Error {
|
|
|
48459
48502
|
}
|
|
48460
48503
|
}
|
|
48461
48504
|
|
|
48505
|
+
;// CONCATENATED MODULE: ./src/secret.client.ts
|
|
48506
|
+
class SecretClient {
|
|
48507
|
+
constructor(rpcManager) {
|
|
48508
|
+
this.rpcManager = rpcManager;
|
|
48509
|
+
}
|
|
48510
|
+
get(key) {
|
|
48511
|
+
return this.rpcManager.get('/secret/get', { key });
|
|
48512
|
+
}
|
|
48513
|
+
getAll() {
|
|
48514
|
+
return this.rpcManager.get('/secret/getAll');
|
|
48515
|
+
}
|
|
48516
|
+
upsert(key, value) {
|
|
48517
|
+
return this.rpcManager.post('/secret/upsert', { key, value });
|
|
48518
|
+
}
|
|
48519
|
+
delete(key) {
|
|
48520
|
+
return this.rpcManager.delete('/secret/delete', { key });
|
|
48521
|
+
}
|
|
48522
|
+
get apiKeys() {
|
|
48523
|
+
return new ApiKeysSecretClient(this.rpcManager);
|
|
48524
|
+
}
|
|
48525
|
+
}
|
|
48526
|
+
class ApiKeysSecretClient {
|
|
48527
|
+
constructor(rpcManager) {
|
|
48528
|
+
this.rpcManager = rpcManager;
|
|
48529
|
+
}
|
|
48530
|
+
get(key) {
|
|
48531
|
+
return this.rpcManager.get('/secret/api-key/get', { key });
|
|
48532
|
+
}
|
|
48533
|
+
getAll() {
|
|
48534
|
+
return this.rpcManager.get('/secret/api-key/getAll');
|
|
48535
|
+
}
|
|
48536
|
+
upsert(key) {
|
|
48537
|
+
return this.rpcManager.post('/secret/api-key/upsert', { key });
|
|
48538
|
+
}
|
|
48539
|
+
delete(key) {
|
|
48540
|
+
return this.rpcManager.delete('/secret/api-key/delete', { key });
|
|
48541
|
+
}
|
|
48542
|
+
}
|
|
48543
|
+
|
|
48462
48544
|
;// CONCATENATED MODULE: ./src/types.ts
|
|
48463
48545
|
/**
|
|
48464
48546
|
* @internal
|
|
@@ -48491,7 +48573,7 @@ class SocketManager {
|
|
|
48491
48573
|
* This value means we wait for 5 minutes before considering the client to be too old.
|
|
48492
48574
|
* Note: we make this a function so that we can easily override it in tests.
|
|
48493
48575
|
*/
|
|
48494
|
-
this.clientTooOldThreshold =
|
|
48576
|
+
this.clientTooOldThreshold = 30000;
|
|
48495
48577
|
this.destructManager.onDestruct(async () => {
|
|
48496
48578
|
await this.destruct();
|
|
48497
48579
|
});
|
|
@@ -48632,6 +48714,7 @@ class SocketManager {
|
|
|
48632
48714
|
|
|
48633
48715
|
|
|
48634
48716
|
|
|
48717
|
+
|
|
48635
48718
|
|
|
48636
48719
|
|
|
48637
48720
|
/**
|
|
@@ -48834,6 +48917,7 @@ class Squid {
|
|
|
48834
48917
|
this.apiManager = new ApiManager(this.clientIdService, this.rpcManager, this.socketManager, options.apiServerUrlOverrideMapping);
|
|
48835
48918
|
this.graphqlClientFactory = new GraphQLClientFactory(this.rpcManager, options.region, appId);
|
|
48836
48919
|
this.aiClientFactory = new AiClientFactory(this.rpcManager, this.socketManager);
|
|
48920
|
+
this.secretClient = new SecretClient(this.rpcManager);
|
|
48837
48921
|
this._connectionDetails = new ConnectionDetails(this.clientIdService, this.socketManager);
|
|
48838
48922
|
}
|
|
48839
48923
|
/**
|
|
@@ -48860,6 +48944,11 @@ class Squid {
|
|
|
48860
48944
|
static getInstances() {
|
|
48861
48945
|
return Object.values(Squid.squidInstancesMap);
|
|
48862
48946
|
}
|
|
48947
|
+
get secrets() {
|
|
48948
|
+
return (() => {
|
|
48949
|
+
return this.secretClient;
|
|
48950
|
+
})();
|
|
48951
|
+
}
|
|
48863
48952
|
validateNotDestructed() {
|
|
48864
48953
|
assert_assertTruthy(!this.destructManager.isDestructing, 'The client was already destructed.');
|
|
48865
48954
|
}
|
|
@@ -17,7 +17,12 @@ export declare class RpcManager {
|
|
|
17
17
|
setStaticHeader(key: string, value: string): void;
|
|
18
18
|
deleteStaticHeader(key: string): void;
|
|
19
19
|
getStaticHeaders(): Record<string, string>;
|
|
20
|
+
private ready;
|
|
21
|
+
get<T>(path: string, params?: Record<string, any>): Promise<T>;
|
|
20
22
|
post<T>(path: string, message: any): Promise<T>;
|
|
23
|
+
delete<T>(path: string, message: any): Promise<T>;
|
|
24
|
+
private postOrDelete;
|
|
25
|
+
private parseResponse;
|
|
21
26
|
}
|
|
22
27
|
export declare class RpcError extends Error {
|
|
23
28
|
readonly statusCode: number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SecretEntry, SecretKey, SecretValue } from '@squidcloud/common';
|
|
2
|
+
import { RpcManager } from './rpc.manager';
|
|
3
|
+
export declare class SecretClient {
|
|
4
|
+
private readonly rpcManager;
|
|
5
|
+
constructor(rpcManager: RpcManager);
|
|
6
|
+
get(key: SecretKey): Promise<SecretEntry | undefined>;
|
|
7
|
+
getAll(): Promise<Record<SecretKey, SecretEntry>>;
|
|
8
|
+
upsert(key: SecretKey, value: SecretValue): Promise<SecretEntry>;
|
|
9
|
+
delete(key: SecretKey): Promise<void>;
|
|
10
|
+
get apiKeys(): ApiKeysSecretClient;
|
|
11
|
+
}
|
|
12
|
+
declare class ApiKeysSecretClient {
|
|
13
|
+
private readonly rpcManager;
|
|
14
|
+
constructor(rpcManager: RpcManager);
|
|
15
|
+
get(key: SecretKey): Promise<SecretEntry | undefined>;
|
|
16
|
+
getAll(): Promise<Record<SecretKey, SecretEntry>>;
|
|
17
|
+
upsert(key: SecretKey): Promise<SecretEntry>;
|
|
18
|
+
delete(key: SecretKey): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import { CollectionReference } from './collection-reference';
|
|
|
5
5
|
import { ConnectionDetails } from './connection-details';
|
|
6
6
|
import { DistributedLock } from './distributed-lock.manager';
|
|
7
7
|
import { GraphQLClient } from './graphql-client';
|
|
8
|
+
import { SecretClient } from './secret.client';
|
|
8
9
|
import { TransactionId } from './types';
|
|
9
10
|
/** The different options that can be used to initialize a Squid instance. */
|
|
10
11
|
export interface SquidOptions {
|
|
@@ -71,6 +72,7 @@ export declare class Squid {
|
|
|
71
72
|
private readonly clientIdService;
|
|
72
73
|
private readonly aiClientFactory;
|
|
73
74
|
private readonly _connectionDetails;
|
|
75
|
+
private readonly secretClient;
|
|
74
76
|
private static readonly squidInstancesMap;
|
|
75
77
|
/**
|
|
76
78
|
* Creates a new instance of Squid with the given options.
|
|
@@ -195,6 +197,7 @@ export declare class Squid {
|
|
|
195
197
|
*/
|
|
196
198
|
assistant: (integrationId: IntegrationId) => AiAssistantClient;
|
|
197
199
|
};
|
|
200
|
+
get secrets(): SecretClient;
|
|
198
201
|
/**
|
|
199
202
|
* Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
|
|
200
203
|
* The lock will be released when the release method on the returned object is invoked or whenever the connection
|