@ductape/sdk 0.1.155 → 0.1.156
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/apps/utils/credential-manager.d.ts +7 -0
- package/dist/apps/utils/credential-manager.js +30 -1
- package/dist/apps/utils/credential-manager.js.map +1 -1
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -1
- package/dist/processor/services/processor.service.d.ts +2 -2
- package/dist/processor/services/processor.service.js +21 -20
- package/dist/processor/services/processor.service.js.map +1 -1
- package/dist/products/services/products.service.js +11 -7
- package/dist/products/services/products.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -63,6 +63,8 @@ export declare class CredentialError extends Error {
|
|
|
63
63
|
export declare class CredentialManager {
|
|
64
64
|
/** Storage for credentials, keyed by product:app:env */
|
|
65
65
|
private credentials;
|
|
66
|
+
/** Credentials hydrated from the product runtime snapshot. */
|
|
67
|
+
private runtimeCredentials;
|
|
66
68
|
/**
|
|
67
69
|
* Share credentials for a product/app/env combination
|
|
68
70
|
*
|
|
@@ -77,6 +79,11 @@ export declare class CredentialManager {
|
|
|
77
79
|
* @returns Shared credentials or undefined if not set
|
|
78
80
|
*/
|
|
79
81
|
get(options: IGetCredentialsOptions): Record<string, unknown> | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Atomically replace credentials owned by a product runtime snapshot.
|
|
84
|
+
* Explicit api.config() values live in a separate layer and keep precedence.
|
|
85
|
+
*/
|
|
86
|
+
replaceRuntimeScope(product: string, env: string, configs: Array<Pick<IShareCredentialsConfig, 'app' | 'credentials'>>): void;
|
|
80
87
|
/**
|
|
81
88
|
* Check if shared credentials exist for a product/app/env combination
|
|
82
89
|
*/
|
|
@@ -56,6 +56,8 @@ class CredentialManager {
|
|
|
56
56
|
constructor() {
|
|
57
57
|
/** Storage for credentials, keyed by product:app:env */
|
|
58
58
|
this.credentials = new Map();
|
|
59
|
+
/** Credentials hydrated from the product runtime snapshot. */
|
|
60
|
+
this.runtimeCredentials = new Map();
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Share credentials for a product/app/env combination
|
|
@@ -98,7 +100,29 @@ class CredentialManager {
|
|
|
98
100
|
*/
|
|
99
101
|
get(options) {
|
|
100
102
|
const key = generateCredentialKey(options.product, options.app, options.env);
|
|
101
|
-
|
|
103
|
+
const runtime = this.runtimeCredentials.get(key);
|
|
104
|
+
const local = this.credentials.get(key);
|
|
105
|
+
if (!runtime && !local)
|
|
106
|
+
return undefined;
|
|
107
|
+
return Object.assign(Object.assign({}, (runtime !== null && runtime !== void 0 ? runtime : {})), (local !== null && local !== void 0 ? local : {}));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Atomically replace credentials owned by a product runtime snapshot.
|
|
111
|
+
* Explicit api.config() values live in a separate layer and keep precedence.
|
|
112
|
+
*/
|
|
113
|
+
replaceRuntimeScope(product, env, configs) {
|
|
114
|
+
const next = new Map(this.runtimeCredentials);
|
|
115
|
+
const suffix = `:${env}`;
|
|
116
|
+
for (const key of next.keys()) {
|
|
117
|
+
if (key.startsWith(`${product}:`) && key.endsWith(suffix))
|
|
118
|
+
next.delete(key);
|
|
119
|
+
}
|
|
120
|
+
for (const config of configs) {
|
|
121
|
+
if (!config.app || !config.credentials || Object.keys(config.credentials).length === 0)
|
|
122
|
+
continue;
|
|
123
|
+
next.set(generateCredentialKey(product, config.app, env), Object.assign({}, config.credentials));
|
|
124
|
+
}
|
|
125
|
+
this.runtimeCredentials = next;
|
|
102
126
|
}
|
|
103
127
|
/**
|
|
104
128
|
* Check if shared credentials exist for a product/app/env combination
|
|
@@ -121,6 +145,7 @@ class CredentialManager {
|
|
|
121
145
|
*/
|
|
122
146
|
clearAll() {
|
|
123
147
|
this.credentials.clear();
|
|
148
|
+
this.runtimeCredentials.clear();
|
|
124
149
|
}
|
|
125
150
|
/**
|
|
126
151
|
* Clear all credentials for a specific product
|
|
@@ -135,6 +160,10 @@ class CredentialManager {
|
|
|
135
160
|
for (const key of keysToDelete) {
|
|
136
161
|
this.credentials.delete(key);
|
|
137
162
|
}
|
|
163
|
+
for (const key of this.runtimeCredentials.keys()) {
|
|
164
|
+
if (key.startsWith(`${product}:`))
|
|
165
|
+
this.runtimeCredentials.delete(key);
|
|
166
|
+
}
|
|
138
167
|
}
|
|
139
168
|
/**
|
|
140
169
|
* Clear all credentials for a specific app (across all products)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../../src/apps/utils/credential-manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAyBH;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACxC,YACE,OAAe,EACC,SAAyC;QAEzD,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,cAAS,GAAT,SAAS,CAAgC;QAGzD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AARD,0CAQC;AAED;;GAEG;AACH,SAAS,qBAAqB,CAAC,OAAe,EAAE,GAAW,EAAE,GAAW;IACtE,OAAO,GAAG,OAAO,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAa,iBAAiB;IAA9B;QACE,wDAAwD;QAChD,gBAAW,GAAyC,IAAI,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"credential-manager.js","sourceRoot":"","sources":["../../../src/apps/utils/credential-manager.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAyBH;;GAEG;AACH,MAAa,eAAgB,SAAQ,KAAK;IACxC,YACE,OAAe,EACC,SAAyC;QAEzD,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,cAAS,GAAT,SAAS,CAAgC;QAGzD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAR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CAAC,EAAE,CAAC;gBAC5B,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QAED,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;YAC/B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI;QACF,MAAM,MAAM,GAAyD,EAAE,CAAC;QAExE,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;YAC1C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;;;OAOG;IACH,cAAc,CACZ,iBAA0C,EAC1C,SAAkC;QAElC,wEAAwE;QACxE,uCAAY,iBAAiB,GAAK,SAAS,EAAG;IAChD,CAAC;CACF;AAnND,8CAmNC;AAED;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -69,6 +69,7 @@ const productsApi_service_1 = require("./api/services/productsApi.service");
|
|
|
69
69
|
const bootstrap_cache_1 = require("./products/bootstrap-cache");
|
|
70
70
|
const imports_service_1 = __importDefault(require("./imports/imports.service"));
|
|
71
71
|
const processor_service_1 = __importDefault(require("./processor/services/processor.service"));
|
|
72
|
+
const processor_utils_1 = require("./processor/utils/processor.utils");
|
|
72
73
|
const logs_service_1 = __importDefault(require("./logs/logs.service"));
|
|
73
74
|
const mime = __importStar(require("mime-types"));
|
|
74
75
|
const database_1 = require("./database");
|
|
@@ -5795,10 +5796,50 @@ class Ductape {
|
|
|
5795
5796
|
};
|
|
5796
5797
|
}
|
|
5797
5798
|
applyRuntimeSnapshot(response) {
|
|
5799
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5798
5800
|
if (!(response === null || response === void 0 ? void 0 : response.snapshot))
|
|
5799
5801
|
return;
|
|
5800
5802
|
const scope = `${this.workspace_id}:${response.snapshot.product_tag}:${response.snapshot.env_slug}`;
|
|
5801
5803
|
(0, bootstrap_cache_1.primeRuntimeBootstrapCache)(this.workspace_id, scope, response.snapshot.entries);
|
|
5804
|
+
const runtimeCredentials = new Map();
|
|
5805
|
+
for (const entry of response.snapshot.entries) {
|
|
5806
|
+
if ((entry === null || entry === void 0 ? void 0 : entry.domain) !== 'action')
|
|
5807
|
+
continue;
|
|
5808
|
+
const app = String(((_a = entry.parts) === null || _a === void 0 ? void 0 : _a[1]) || '');
|
|
5809
|
+
const mapping = (_b = entry.data) === null || _b === void 0 ? void 0 : _b.product_env_mapping;
|
|
5810
|
+
if (!app || !mapping)
|
|
5811
|
+
continue;
|
|
5812
|
+
const credentials = (_c = runtimeCredentials.get(app)) !== null && _c !== void 0 ? _c : {};
|
|
5813
|
+
for (const variable of (_d = mapping.variables) !== null && _d !== void 0 ? _d : []) {
|
|
5814
|
+
if ((variable === null || variable === void 0 ? void 0 : variable.key) && variable.value !== undefined)
|
|
5815
|
+
credentials[String(variable.key)] = variable.value;
|
|
5816
|
+
}
|
|
5817
|
+
// token_access data is the reusable request credential itself. credential_access
|
|
5818
|
+
// data contains login secrets and must only be sent to its dedicated auth action.
|
|
5819
|
+
if (((_f = (_e = entry.data) === null || _e === void 0 ? void 0 : _e.app_auth) === null || _f === void 0 ? void 0 : _f.setup_type) === 'token_access' && ((_g = mapping.auth) === null || _g === void 0 ? void 0 : _g.data)) {
|
|
5820
|
+
let authData = mapping.auth.data;
|
|
5821
|
+
if (typeof authData === 'string') {
|
|
5822
|
+
try {
|
|
5823
|
+
authData = JSON.parse((0, processor_utils_1.decrypt)(authData, String(entry.data.private_key)));
|
|
5824
|
+
}
|
|
5825
|
+
catch (_h) {
|
|
5826
|
+
authData = undefined;
|
|
5827
|
+
}
|
|
5828
|
+
}
|
|
5829
|
+
if (authData && typeof authData === 'object') {
|
|
5830
|
+
for (const location of ['headers', 'query', 'params', 'body']) {
|
|
5831
|
+
const values = authData[location];
|
|
5832
|
+
if (!values || typeof values !== 'object' || Array.isArray(values))
|
|
5833
|
+
continue;
|
|
5834
|
+
for (const [key, value] of Object.entries(values)) {
|
|
5835
|
+
credentials[`${location}:${key}`] = value;
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
}
|
|
5839
|
+
}
|
|
5840
|
+
runtimeCredentials.set(app, credentials);
|
|
5841
|
+
}
|
|
5842
|
+
credential_manager_1.credentialManager.replaceRuntimeScope(response.snapshot.product_tag, response.snapshot.env_slug, [...runtimeCredentials].map(([app, credentials]) => ({ app, credentials })));
|
|
5802
5843
|
this.runtimeManifest = response.manifest;
|
|
5803
5844
|
this.runtimeLastRefreshAt = Date.now();
|
|
5804
5845
|
this.runtimeLastError = undefined;
|