@quiltdata/benchling-webhook 0.5.4 → 0.6.1-20251104T043302Z
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/README.md +295 -12
- package/dist/bin/benchling-webhook.d.ts +1 -1
- package/dist/bin/benchling-webhook.d.ts.map +1 -1
- package/dist/bin/benchling-webhook.js +12 -22
- package/dist/bin/benchling-webhook.js.map +1 -1
- package/dist/bin/cdk-dev.js +59 -3
- package/dist/bin/cli.js +27 -9
- package/dist/bin/cli.js.map +1 -1
- package/dist/bin/commands/deploy.d.ts +6 -2
- package/dist/bin/commands/deploy.d.ts.map +1 -1
- package/dist/bin/commands/deploy.js +151 -90
- package/dist/bin/commands/deploy.js.map +1 -1
- package/dist/bin/commands/setup-wizard.d.ts +22 -0
- package/dist/bin/commands/setup-wizard.d.ts.map +1 -0
- package/dist/bin/commands/setup-wizard.js +47 -0
- package/dist/bin/commands/setup-wizard.js.map +1 -0
- package/dist/bin/config-profiles.d.ts +59 -0
- package/dist/bin/config-profiles.d.ts.map +1 -0
- package/dist/bin/config-profiles.js +272 -0
- package/dist/bin/config-profiles.js.map +1 -0
- package/dist/bin/create-secret.d.ts +25 -0
- package/dist/bin/create-secret.d.ts.map +1 -0
- package/dist/bin/create-secret.js +239 -0
- package/dist/bin/create-secret.js.map +1 -0
- package/dist/lib/benchling-auth-validator.d.ts +65 -0
- package/dist/lib/benchling-auth-validator.d.ts.map +1 -0
- package/dist/lib/benchling-auth-validator.js +213 -0
- package/dist/lib/benchling-auth-validator.js.map +1 -0
- package/dist/lib/benchling-webhook-stack.d.ts +13 -10
- package/dist/lib/benchling-webhook-stack.d.ts.map +1 -1
- package/dist/lib/benchling-webhook-stack.js +25 -69
- package/dist/lib/benchling-webhook-stack.js.map +1 -1
- package/dist/lib/config-logger.d.ts +191 -0
- package/dist/lib/config-logger.d.ts.map +1 -0
- package/dist/lib/config-logger.js +372 -0
- package/dist/lib/config-logger.js.map +1 -0
- package/dist/lib/configuration-saver.d.ts +75 -0
- package/dist/lib/configuration-saver.d.ts.map +1 -0
- package/dist/lib/configuration-saver.js +145 -0
- package/dist/lib/configuration-saver.js.map +1 -0
- package/dist/lib/configuration-validator.d.ts +63 -0
- package/dist/lib/configuration-validator.d.ts.map +1 -0
- package/dist/lib/configuration-validator.js +136 -0
- package/dist/lib/configuration-validator.js.map +1 -0
- package/dist/lib/configuration-wizard.d.ts +52 -0
- package/dist/lib/configuration-wizard.d.ts.map +1 -0
- package/dist/lib/configuration-wizard.js +193 -0
- package/dist/lib/configuration-wizard.js.map +1 -0
- package/dist/lib/fargate-service.d.ts +18 -9
- package/dist/lib/fargate-service.d.ts.map +1 -1
- package/dist/lib/fargate-service.js +177 -61
- package/dist/lib/fargate-service.js.map +1 -1
- package/dist/lib/quilt-config-resolver.d.ts +53 -0
- package/dist/lib/quilt-config-resolver.d.ts.map +1 -0
- package/dist/lib/quilt-config-resolver.js +100 -0
- package/dist/lib/quilt-config-resolver.js.map +1 -0
- package/dist/lib/s3-bucket-validator.d.ts +76 -0
- package/dist/lib/s3-bucket-validator.d.ts.map +1 -0
- package/dist/lib/s3-bucket-validator.js +237 -0
- package/dist/lib/s3-bucket-validator.js.map +1 -0
- package/dist/lib/types/config.d.ts +398 -0
- package/dist/lib/types/config.d.ts.map +1 -0
- package/dist/lib/types/config.js +11 -0
- package/dist/lib/types/config.js.map +1 -0
- package/dist/lib/utils/config-loader.d.ts +48 -0
- package/dist/lib/utils/config-loader.d.ts.map +1 -0
- package/dist/lib/utils/config-loader.js +109 -0
- package/dist/lib/utils/config-loader.js.map +1 -0
- package/dist/lib/utils/config-resolver.d.ts +138 -0
- package/dist/lib/utils/config-resolver.d.ts.map +1 -0
- package/dist/lib/utils/config-resolver.js +272 -0
- package/dist/lib/utils/config-resolver.js.map +1 -0
- package/dist/lib/utils/config.d.ts +50 -0
- package/dist/lib/utils/config.d.ts.map +1 -1
- package/dist/lib/utils/config.js +86 -0
- package/dist/lib/utils/config.js.map +1 -1
- package/dist/lib/utils/secrets.d.ts +174 -0
- package/dist/lib/utils/secrets.d.ts.map +1 -0
- package/dist/lib/utils/secrets.js +351 -0
- package/dist/lib/utils/secrets.js.map +1 -0
- package/dist/lib/xdg-cli-wrapper.d.ts +113 -0
- package/dist/lib/xdg-cli-wrapper.d.ts.map +1 -0
- package/dist/lib/xdg-cli-wrapper.js +288 -0
- package/dist/lib/xdg-cli-wrapper.js.map +1 -0
- package/dist/lib/xdg-config.d.ts +187 -0
- package/dist/lib/xdg-config.d.ts.map +1 -0
- package/dist/lib/xdg-config.js +562 -0
- package/dist/lib/xdg-config.js.map +1 -0
- package/dist/package.json +34 -26
- package/dist/scripts/config-health-check.d.ts +78 -0
- package/dist/scripts/config-health-check.d.ts.map +1 -0
- package/dist/scripts/config-health-check.js +559 -0
- package/dist/scripts/config-health-check.js.map +1 -0
- package/dist/scripts/infer-quilt-config.d.ts +50 -0
- package/dist/scripts/infer-quilt-config.d.ts.map +1 -0
- package/dist/scripts/infer-quilt-config.js +353 -0
- package/dist/scripts/infer-quilt-config.js.map +1 -0
- package/dist/scripts/install-wizard.d.ts +34 -0
- package/dist/scripts/install-wizard.d.ts.map +1 -0
- package/dist/scripts/install-wizard.js +719 -0
- package/dist/scripts/install-wizard.js.map +1 -0
- package/dist/scripts/sync-secrets.d.ts +63 -0
- package/dist/scripts/sync-secrets.d.ts.map +1 -0
- package/dist/scripts/sync-secrets.js +424 -0
- package/dist/scripts/sync-secrets.js.map +1 -0
- package/env.template +60 -47
- package/package.json +34 -26
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.BenchlingAuthValidator = void 0;
|
|
37
|
+
const https = __importStar(require("https"));
|
|
38
|
+
/**
|
|
39
|
+
* Benchling authentication validator
|
|
40
|
+
*
|
|
41
|
+
* Validates Benchling credentials by attempting OAuth authentication
|
|
42
|
+
* and checking required permissions.
|
|
43
|
+
*/
|
|
44
|
+
class BenchlingAuthValidator {
|
|
45
|
+
/**
|
|
46
|
+
* Validate Benchling credentials
|
|
47
|
+
*
|
|
48
|
+
* @param credentials - Benchling credentials to validate
|
|
49
|
+
* @returns Validation result with errors and warnings
|
|
50
|
+
*/
|
|
51
|
+
static async validate(credentials) {
|
|
52
|
+
const errors = [];
|
|
53
|
+
const warnings = [];
|
|
54
|
+
// Basic credential validation
|
|
55
|
+
if (!BenchlingAuthValidator.validateCredentials(credentials)) {
|
|
56
|
+
errors.push("Invalid credentials: missing required fields");
|
|
57
|
+
return {
|
|
58
|
+
isValid: false,
|
|
59
|
+
errors,
|
|
60
|
+
warnings,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Validate tenant format
|
|
64
|
+
if (!(await BenchlingAuthValidator.validateTenant(credentials.tenant))) {
|
|
65
|
+
errors.push("Invalid tenant format");
|
|
66
|
+
return {
|
|
67
|
+
isValid: false,
|
|
68
|
+
errors,
|
|
69
|
+
warnings,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Attempt OAuth authentication
|
|
73
|
+
try {
|
|
74
|
+
const tokenResponse = await BenchlingAuthValidator.authenticate(credentials);
|
|
75
|
+
if (!tokenResponse.access_token) {
|
|
76
|
+
if (tokenResponse.error === "invalid_client") {
|
|
77
|
+
errors.push("Invalid client credentials");
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
errors.push("Authentication failed");
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
isValid: false,
|
|
84
|
+
errors,
|
|
85
|
+
warnings,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
// Check OAuth scopes
|
|
89
|
+
const hasPermissions = BenchlingAuthValidator.checkPermissions(tokenResponse.scope || "");
|
|
90
|
+
if (!hasPermissions) {
|
|
91
|
+
warnings.push("Missing required permissions");
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
isValid: true,
|
|
95
|
+
hasRequiredPermissions: hasPermissions,
|
|
96
|
+
errors: [],
|
|
97
|
+
warnings: warnings.length > 0 ? warnings : undefined,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
if (error instanceof Error) {
|
|
102
|
+
if (error.message.includes("404") || error.message.includes("tenant_not_found")) {
|
|
103
|
+
errors.push("Tenant not found");
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
errors.push("Network error during validation");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
isValid: false,
|
|
111
|
+
errors,
|
|
112
|
+
warnings,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Validate tenant format
|
|
118
|
+
*
|
|
119
|
+
* @param tenant - Benchling tenant name
|
|
120
|
+
* @returns True if tenant format is valid
|
|
121
|
+
*/
|
|
122
|
+
static async validateTenant(tenant) {
|
|
123
|
+
if (!tenant || tenant.trim() === "") {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
// Check for invalid characters (spaces, special chars)
|
|
127
|
+
if (/\s/.test(tenant)) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Validate credentials completeness
|
|
134
|
+
*
|
|
135
|
+
* @param credentials - Credentials to validate
|
|
136
|
+
* @returns True if all required fields are present
|
|
137
|
+
*/
|
|
138
|
+
static validateCredentials(credentials) {
|
|
139
|
+
return !!(credentials.tenant &&
|
|
140
|
+
credentials.clientId &&
|
|
141
|
+
credentials.clientSecret &&
|
|
142
|
+
credentials.tenant.trim() !== "" &&
|
|
143
|
+
credentials.clientId.trim() !== "" &&
|
|
144
|
+
credentials.clientSecret.trim() !== "");
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Authenticate with Benchling OAuth API
|
|
148
|
+
*
|
|
149
|
+
* @param credentials - Benchling credentials
|
|
150
|
+
* @returns Token response from Benchling
|
|
151
|
+
*/
|
|
152
|
+
static async authenticate(credentials) {
|
|
153
|
+
const { tenant, clientId, clientSecret } = credentials;
|
|
154
|
+
return new Promise((resolve, reject) => {
|
|
155
|
+
const authString = Buffer.from(`${clientId}:${clientSecret}`).toString("base64");
|
|
156
|
+
const postData = "grant_type=client_credentials";
|
|
157
|
+
const options = {
|
|
158
|
+
hostname: `${tenant}.benchling.com`,
|
|
159
|
+
port: 443,
|
|
160
|
+
path: "/api/v2/token",
|
|
161
|
+
method: "POST",
|
|
162
|
+
headers: {
|
|
163
|
+
"Authorization": `Basic ${authString}`,
|
|
164
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
165
|
+
"Content-Length": Buffer.byteLength(postData),
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
const req = https.request(options, (res) => {
|
|
169
|
+
let data = "";
|
|
170
|
+
res.on("data", (chunk) => {
|
|
171
|
+
data += chunk.toString();
|
|
172
|
+
});
|
|
173
|
+
res.on("end", () => {
|
|
174
|
+
if (res.statusCode === 404) {
|
|
175
|
+
reject(new Error("404: Tenant not found"));
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const response = JSON.parse(data);
|
|
180
|
+
if (res.statusCode === 401) {
|
|
181
|
+
response.error = "invalid_client";
|
|
182
|
+
}
|
|
183
|
+
resolve(response);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
reject(error);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
req.on("error", (error) => {
|
|
191
|
+
reject(error);
|
|
192
|
+
});
|
|
193
|
+
req.write(postData);
|
|
194
|
+
req.end();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Check if OAuth scopes include required permissions
|
|
199
|
+
*
|
|
200
|
+
* @param scope - OAuth scope string
|
|
201
|
+
* @returns True if all required scopes are present
|
|
202
|
+
*/
|
|
203
|
+
static checkPermissions(scope) {
|
|
204
|
+
const scopes = scope.toLowerCase().split(" ");
|
|
205
|
+
return BenchlingAuthValidator.REQUIRED_SCOPES.every((requiredScope) => scopes.includes(requiredScope));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.BenchlingAuthValidator = BenchlingAuthValidator;
|
|
209
|
+
/**
|
|
210
|
+
* Required OAuth scopes for the webhook integration
|
|
211
|
+
*/
|
|
212
|
+
BenchlingAuthValidator.REQUIRED_SCOPES = ["read", "write"];
|
|
213
|
+
//# sourceMappingURL=benchling-auth-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"benchling-auth-validator.js","sourceRoot":"","sources":["../../lib/benchling-auth-validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AA8B/B;;;;;GAKG;AACH,MAAa,sBAAsB;IAM/B;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAiC;QAC1D,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,8BAA8B;QAC9B,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC;YAC3D,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;YAC5D,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,MAAM;gBACN,QAAQ;aACX,CAAC;QACN,CAAC;QAED,yBAAyB;QACzB,IAAI,CAAC,CAAC,MAAM,sBAAsB,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACrE,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACrC,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,MAAM;gBACN,QAAQ;aACX,CAAC;QACN,CAAC;QAED,+BAA+B;QAC/B,IAAI,CAAC;YACD,MAAM,aAAa,GAAG,MAAM,sBAAsB,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;YAE7E,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC;gBAC9B,IAAI,aAAa,CAAC,KAAK,KAAK,gBAAgB,EAAE,CAAC;oBA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AC,KAAK,CAAC,CAAC,aAAa,EAAE,EAAE,CAClE,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CACjC,CAAC;IACN,CAAC;;AA3LL,wDA4LC;AA3LG;;GAEG;AACqB,sCAAe,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import * as cdk from "aws-cdk-lib";
|
|
2
2
|
import { Construct } from "constructs";
|
|
3
3
|
export interface BenchlingWebhookStackProps extends cdk.StackProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
/**
|
|
5
|
+
* ARN of the Quilt CloudFormation stack.
|
|
6
|
+
* All configuration is resolved from AWS (CloudFormation outputs + Secrets Manager).
|
|
7
|
+
* Format: arn:aws:cloudformation:{region}:{account}:stack/{name}/{id}
|
|
8
|
+
* REQUIRED.
|
|
9
|
+
*/
|
|
10
|
+
readonly quiltStackArn: string;
|
|
11
|
+
/**
|
|
12
|
+
* Name or ARN of the AWS Secrets Manager secret containing Benchling credentials.
|
|
13
|
+
* Secret must contain: client_id, client_secret, tenant, app_definition_id (optional)
|
|
14
|
+
* REQUIRED.
|
|
15
|
+
*/
|
|
16
|
+
readonly benchlingSecret: string;
|
|
14
17
|
readonly createEcrRepository?: boolean;
|
|
15
18
|
readonly ecrRepositoryName?: string;
|
|
16
19
|
readonly logLevel?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"benchling-webhook-stack.d.ts","sourceRoot":"","sources":["../../lib/benchling-webhook-stack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAInC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMvC,MAAM,WAAW,0BAA2B,SAAQ,GAAG,CAAC,UAAU;
|
|
1
|
+
{"version":3,"file":"benchling-webhook-stack.d.ts","sourceRoot":"","sources":["../../lib/benchling-webhook-stack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAInC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMvC,MAAM,WAAW,0BAA2B,SAAQ,GAAG,CAAC,UAAU;IAE9D;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAGjC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,qBAAa,qBAAsB,SAAQ,GAAG,CAAC,KAAK;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IACpC,SAAgB,eAAe,EAAE,MAAM,CAAC;gBAGpC,KAAK,EAAE,SAAS,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,0BAA0B;CA0IxC"}
|
|
@@ -48,53 +48,26 @@ const package_json_1 = __importDefault(require("../package.json"));
|
|
|
48
48
|
class BenchlingWebhookStack extends cdk.Stack {
|
|
49
49
|
constructor(scope, id, props) {
|
|
50
50
|
super(scope, id, props);
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// Validate required secrets-only mode parameters
|
|
52
|
+
if (!props.quiltStackArn || !props.benchlingSecret) {
|
|
53
|
+
throw new Error("Secrets-only mode (v0.6.0+) requires both:\n" +
|
|
54
|
+
" - quiltStackArn: CloudFormation stack ARN\n" +
|
|
55
|
+
" - benchlingSecret: Secrets Manager secret name\n\n" +
|
|
56
|
+
"See: https://github.com/quiltdata/benchling-webhook/issues/156");
|
|
53
57
|
}
|
|
58
|
+
console.log("✓ Using secrets-only mode (v0.6.0+)");
|
|
54
59
|
// Create CloudFormation parameters for runtime-configurable values
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
const webhookAllowListParam = new cdk.CfnParameter(this, "WebhookAllowList", {
|
|
60
|
+
// Parameters can be updated via CloudFormation stack updates
|
|
61
|
+
// ===== Secrets-Only Mode Parameters (v0.6.0+) =====
|
|
62
|
+
const quiltStackArnParam = new cdk.CfnParameter(this, "QuiltStackARN", {
|
|
59
63
|
type: "String",
|
|
60
|
-
description: "
|
|
61
|
-
default: props.
|
|
64
|
+
description: "ARN of Quilt CloudFormation stack for configuration resolution",
|
|
65
|
+
default: props.quiltStackArn,
|
|
62
66
|
});
|
|
63
|
-
const
|
|
67
|
+
const benchlingSecretParam = new cdk.CfnParameter(this, "BenchlingSecret", {
|
|
64
68
|
type: "String",
|
|
65
|
-
description: "
|
|
66
|
-
default: props.
|
|
67
|
-
});
|
|
68
|
-
// Infrastructure parameters - these can be updated without redeploying
|
|
69
|
-
const bucketNameParam = new cdk.CfnParameter(this, "BucketName", {
|
|
70
|
-
type: "String",
|
|
71
|
-
description: "S3 bucket name for storing packages",
|
|
72
|
-
default: props.bucketName,
|
|
73
|
-
});
|
|
74
|
-
const prefixParam = new cdk.CfnParameter(this, "PackagePrefix", {
|
|
75
|
-
type: "String",
|
|
76
|
-
description: "Prefix for package names (no slashes)",
|
|
77
|
-
default: props.prefix,
|
|
78
|
-
});
|
|
79
|
-
const pkgKeyParam = new cdk.CfnParameter(this, "PackageKey", {
|
|
80
|
-
type: "String",
|
|
81
|
-
description: "Metadata key used to link Benchling entries to Quilt packages",
|
|
82
|
-
default: "experiment_id",
|
|
83
|
-
});
|
|
84
|
-
const queueArnParam = new cdk.CfnParameter(this, "QueueArn", {
|
|
85
|
-
type: "String",
|
|
86
|
-
description: "SQS queue ARN for package notifications",
|
|
87
|
-
default: props.queueArn,
|
|
88
|
-
});
|
|
89
|
-
const quiltDatabaseParam = new cdk.CfnParameter(this, "QuiltDatabase", {
|
|
90
|
-
type: "String",
|
|
91
|
-
description: "Quilt database name (Glue Data Catalog database)",
|
|
92
|
-
default: props.quiltDatabase,
|
|
93
|
-
});
|
|
94
|
-
const benchlingTenantParam = new cdk.CfnParameter(this, "BenchlingTenant", {
|
|
95
|
-
type: "String",
|
|
96
|
-
description: "Benchling tenant name (e.g., 'company' for company.benchling.com)",
|
|
97
|
-
default: props.benchlingTenant,
|
|
69
|
+
description: "Name/ARN of Secrets Manager secret with Benchling credentials",
|
|
70
|
+
default: props.benchlingSecret,
|
|
98
71
|
});
|
|
99
72
|
const logLevelParam = new cdk.CfnParameter(this, "LogLevel", {
|
|
100
73
|
type: "String",
|
|
@@ -102,12 +75,6 @@ class BenchlingWebhookStack extends cdk.Stack {
|
|
|
102
75
|
default: props.logLevel || "INFO",
|
|
103
76
|
allowedValues: ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
|
|
104
77
|
});
|
|
105
|
-
const enableWebhookVerificationParam = new cdk.CfnParameter(this, "EnableWebhookVerification", {
|
|
106
|
-
type: "String",
|
|
107
|
-
description: "Enable webhook signature verification (true/false)",
|
|
108
|
-
default: "true",
|
|
109
|
-
allowedValues: ["true", "false"],
|
|
110
|
-
});
|
|
111
78
|
const imageTagParam = new cdk.CfnParameter(this, "ImageTag", {
|
|
112
79
|
type: "String",
|
|
113
80
|
description: "Docker image tag to deploy (e.g., latest, 0.5.3, 0.5.3-20251030T123456Z)",
|
|
@@ -115,18 +82,13 @@ class BenchlingWebhookStack extends cdk.Stack {
|
|
|
115
82
|
});
|
|
116
83
|
// Use parameter values (which have props as defaults)
|
|
117
84
|
// This allows runtime updates via CloudFormation
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const bucketNameValue = bucketNameParam.valueAsString;
|
|
121
|
-
const prefixValue = prefixParam.valueAsString;
|
|
122
|
-
const pkgKeyValue = pkgKeyParam.valueAsString;
|
|
123
|
-
const queueArnValue = queueArnParam.valueAsString;
|
|
124
|
-
const quiltDatabaseValue = quiltDatabaseParam.valueAsString;
|
|
125
|
-
const benchlingTenantValue = benchlingTenantParam.valueAsString;
|
|
85
|
+
const quiltStackArnValue = quiltStackArnParam.valueAsString;
|
|
86
|
+
const benchlingSecretValue = benchlingSecretParam.valueAsString;
|
|
126
87
|
const logLevelValue = logLevelParam.valueAsString;
|
|
127
|
-
const enableWebhookVerificationValue = enableWebhookVerificationParam.valueAsString;
|
|
128
88
|
const imageTagValue = imageTagParam.valueAsString;
|
|
129
|
-
|
|
89
|
+
// Bucket name will be resolved at runtime from CloudFormation outputs
|
|
90
|
+
// For CDK purposes, we use a placeholder for IAM permissions
|
|
91
|
+
this.bucket = s3.Bucket.fromBucketName(this, "BWBucket", "placeholder-bucket-resolved-at-runtime");
|
|
130
92
|
// Get the default VPC or create a new one
|
|
131
93
|
const vpc = ec2.Vpc.fromLookup(this, "DefaultVPC", {
|
|
132
94
|
isDefault: true,
|
|
@@ -153,30 +115,24 @@ class BenchlingWebhookStack extends cdk.Stack {
|
|
|
153
115
|
// (e.g., "0.5.3-20251031T000139Z"), otherwise use package.json version
|
|
154
116
|
const isDevVersion = imageTagValue.match(/^\d+\.\d+\.\d+-\d{8}T\d{6}Z$/);
|
|
155
117
|
const stackVersion = isDevVersion ? imageTagValue : package_json_1.default.version;
|
|
118
|
+
// Build Fargate Service props - secrets-only mode
|
|
156
119
|
this.fargateService = new fargate_service_1.FargateService(this, "FargateService", {
|
|
157
120
|
vpc,
|
|
158
121
|
bucket: this.bucket,
|
|
159
|
-
queueArn: queueArnValue,
|
|
160
122
|
region: this.region,
|
|
161
123
|
account: this.account,
|
|
162
|
-
prefix: prefixValue,
|
|
163
|
-
pkgKey: pkgKeyValue,
|
|
164
|
-
benchlingClientId: props.benchlingClientId,
|
|
165
|
-
benchlingClientSecret: props.benchlingClientSecret,
|
|
166
|
-
benchlingTenant: benchlingTenantValue,
|
|
167
|
-
quiltCatalog: quiltCatalogValue,
|
|
168
|
-
quiltDatabase: quiltDatabaseValue,
|
|
169
|
-
webhookAllowList: webhookAllowListValue,
|
|
170
124
|
ecrRepository: ecrRepo,
|
|
171
125
|
imageTag: imageTagValue,
|
|
172
126
|
stackVersion: stackVersion,
|
|
173
127
|
logLevel: logLevelValue,
|
|
174
|
-
|
|
128
|
+
// Secrets-only mode: Only 2 required parameters
|
|
129
|
+
quiltStackArn: quiltStackArnValue,
|
|
130
|
+
benchlingSecret: benchlingSecretValue,
|
|
175
131
|
});
|
|
176
132
|
// Create API Gateway that routes to the ALB
|
|
177
133
|
this.api = new alb_api_gateway_1.AlbApiGateway(this, "ApiGateway", {
|
|
178
134
|
loadBalancer: this.fargateService.loadBalancer,
|
|
179
|
-
webhookAllowList:
|
|
135
|
+
webhookAllowList: "", // Empty allow list = allow all IPs
|
|
180
136
|
});
|
|
181
137
|
// Store webhook endpoint for easy access
|
|
182
138
|
this.webhookEndpoint = this.api.api.url;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"benchling-webhook-stack.js","sourceRoot":"","sources":["../../lib/benchling-webhook-stack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,uDAAyC;AACzC,yDAA2C;AAC3C,yDAA2C;AAE3C,uDAAmD;AACnD,uDAAkD;AAClD,qDAAiD;AACjD,mEAA0C;
|
|
1
|
+
{"version":3,"file":"benchling-webhook-stack.js","sourceRoot":"","sources":["../../lib/benchling-webhook-stack.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,uDAAyC;AACzC,yDAA2C;AAC3C,yDAA2C;AAE3C,uDAAmD;AACnD,uDAAkD;AAClD,qDAAiD;AACjD,mEAA0C;AAyB1C,MAAa,qBAAsB,SAAQ,GA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6B;QAC7B,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,cAAc,EAAE;YACpC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,sBAAW,CAAC,OAAO;YAChE,WAAW,EAAE,eAAe;SAC/B,CAAC,CAAC;QAEH,+BAA+B;QAC/B,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE;YACnC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY;YAChD,WAAW,EAAE,6CAA6C;SAC7D,CAAC,CAAC;QAEH,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,oBAAoB,EAAE;YAC1C,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY;YACrC,WAAW,EAAE,kDAAkD;SAClE,CAAC,CAAC;IACP,CAAC;CAGJ;AAnJD,sDAmJC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Diagnostic Logging
|
|
3
|
+
*
|
|
4
|
+
* Provides comprehensive logging for configuration operations:
|
|
5
|
+
* - Configuration sources tracking
|
|
6
|
+
* - Operation audit trail
|
|
7
|
+
* - Troubleshooting insights
|
|
8
|
+
* - Performance metrics
|
|
9
|
+
*
|
|
10
|
+
* @module lib/config-logger
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Log level enumeration
|
|
14
|
+
*/
|
|
15
|
+
export declare enum LogLevel {
|
|
16
|
+
DEBUG = "DEBUG",
|
|
17
|
+
INFO = "INFO",
|
|
18
|
+
WARN = "WARN",
|
|
19
|
+
ERROR = "ERROR"
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Log entry structure
|
|
23
|
+
*/
|
|
24
|
+
export interface LogEntry {
|
|
25
|
+
timestamp: string;
|
|
26
|
+
level: LogLevel;
|
|
27
|
+
operation: string;
|
|
28
|
+
message: string;
|
|
29
|
+
data?: Record<string, unknown>;
|
|
30
|
+
source?: string;
|
|
31
|
+
profileName?: string;
|
|
32
|
+
duration?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Configuration operation types
|
|
36
|
+
*/
|
|
37
|
+
export declare enum ConfigOperation {
|
|
38
|
+
READ = "read",
|
|
39
|
+
WRITE = "write",
|
|
40
|
+
VALIDATE = "validate",
|
|
41
|
+
MERGE = "merge",
|
|
42
|
+
SYNC_SECRETS = "sync-secrets",
|
|
43
|
+
INFER_CONFIG = "infer-config",
|
|
44
|
+
CREATE_PROFILE = "create-profile",
|
|
45
|
+
DELETE_PROFILE = "delete-profile"
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Configuration logger for diagnostic and audit purposes
|
|
49
|
+
*/
|
|
50
|
+
export declare class ConfigLogger {
|
|
51
|
+
private logFile;
|
|
52
|
+
private enableConsole;
|
|
53
|
+
private minLogLevel;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new configuration logger
|
|
56
|
+
*
|
|
57
|
+
* @param options - Logger configuration options
|
|
58
|
+
*/
|
|
59
|
+
constructor(options?: {
|
|
60
|
+
logFile?: string;
|
|
61
|
+
enableConsole?: boolean;
|
|
62
|
+
minLogLevel?: LogLevel;
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Gets log level priority for comparison
|
|
66
|
+
*
|
|
67
|
+
* @param level - Log level
|
|
68
|
+
* @returns Priority number (higher = more severe)
|
|
69
|
+
*/
|
|
70
|
+
private getLogLevelPriority;
|
|
71
|
+
/**
|
|
72
|
+
* Checks if log level should be output
|
|
73
|
+
*
|
|
74
|
+
* @param level - Log level to check
|
|
75
|
+
* @returns True if should log
|
|
76
|
+
*/
|
|
77
|
+
private shouldLog;
|
|
78
|
+
/**
|
|
79
|
+
* Formats log entry for output
|
|
80
|
+
*
|
|
81
|
+
* @param entry - Log entry
|
|
82
|
+
* @returns Formatted log string
|
|
83
|
+
*/
|
|
84
|
+
private formatLogEntry;
|
|
85
|
+
/**
|
|
86
|
+
* Writes log entry to file and console
|
|
87
|
+
*
|
|
88
|
+
* @param entry - Log entry to write
|
|
89
|
+
*/
|
|
90
|
+
private writeLog;
|
|
91
|
+
/**
|
|
92
|
+
* Logs a debug message
|
|
93
|
+
*
|
|
94
|
+
* @param operation - Configuration operation
|
|
95
|
+
* @param message - Log message
|
|
96
|
+
* @param data - Additional data
|
|
97
|
+
*/
|
|
98
|
+
debug(operation: ConfigOperation | string, message: string, data?: Record<string, unknown>): void;
|
|
99
|
+
/**
|
|
100
|
+
* Logs an info message
|
|
101
|
+
*
|
|
102
|
+
* @param operation - Configuration operation
|
|
103
|
+
* @param message - Log message
|
|
104
|
+
* @param data - Additional data
|
|
105
|
+
*/
|
|
106
|
+
info(operation: ConfigOperation | string, message: string, data?: Record<string, unknown>): void;
|
|
107
|
+
/**
|
|
108
|
+
* Logs a warning message
|
|
109
|
+
*
|
|
110
|
+
* @param operation - Configuration operation
|
|
111
|
+
* @param message - Log message
|
|
112
|
+
* @param data - Additional data
|
|
113
|
+
*/
|
|
114
|
+
warn(operation: ConfigOperation | string, message: string, data?: Record<string, unknown>): void;
|
|
115
|
+
/**
|
|
116
|
+
* Logs an error message
|
|
117
|
+
*
|
|
118
|
+
* @param operation - Configuration operation
|
|
119
|
+
* @param message - Log message
|
|
120
|
+
* @param data - Additional data
|
|
121
|
+
*/
|
|
122
|
+
error(operation: ConfigOperation | string, message: string, data?: Record<string, unknown>): void;
|
|
123
|
+
/**
|
|
124
|
+
* Logs configuration operation with timing
|
|
125
|
+
*
|
|
126
|
+
* @param operation - Configuration operation
|
|
127
|
+
* @param profileName - Profile name
|
|
128
|
+
* @param source - Configuration source
|
|
129
|
+
* @param fn - Function to execute and time
|
|
130
|
+
* @returns Result of the function
|
|
131
|
+
*/
|
|
132
|
+
logOperation<T>(operation: ConfigOperation, profileName: string, source: string, fn: () => Promise<T> | T): Promise<T>;
|
|
133
|
+
/**
|
|
134
|
+
* Logs configuration read operation
|
|
135
|
+
*
|
|
136
|
+
* @param profileName - Profile name
|
|
137
|
+
* @param configType - Configuration type
|
|
138
|
+
* @param success - Whether read was successful
|
|
139
|
+
* @param source - Configuration source
|
|
140
|
+
*/
|
|
141
|
+
logRead(profileName: string, configType: string, success: boolean, source?: string): void;
|
|
142
|
+
/**
|
|
143
|
+
* Logs configuration write operation
|
|
144
|
+
*
|
|
145
|
+
* @param profileName - Profile name
|
|
146
|
+
* @param configType - Configuration type
|
|
147
|
+
* @param success - Whether write was successful
|
|
148
|
+
* @param source - Configuration source
|
|
149
|
+
*/
|
|
150
|
+
logWrite(profileName: string, configType: string, success: boolean, source?: string): void;
|
|
151
|
+
/**
|
|
152
|
+
* Logs configuration validation
|
|
153
|
+
*
|
|
154
|
+
* @param profileName - Profile name
|
|
155
|
+
* @param isValid - Whether configuration is valid
|
|
156
|
+
* @param errors - Validation errors
|
|
157
|
+
*/
|
|
158
|
+
logValidation(profileName: string, isValid: boolean, errors?: string[]): void;
|
|
159
|
+
/**
|
|
160
|
+
* Logs secrets sync operation
|
|
161
|
+
*
|
|
162
|
+
* @param profileName - Profile name
|
|
163
|
+
* @param secretArn - Secret ARN
|
|
164
|
+
* @param action - Action performed (created/updated/skipped)
|
|
165
|
+
*/
|
|
166
|
+
logSecretsSync(profileName: string, secretArn: string, action: string): void;
|
|
167
|
+
/**
|
|
168
|
+
* Gets the log file path
|
|
169
|
+
*
|
|
170
|
+
* @returns Log file path
|
|
171
|
+
*/
|
|
172
|
+
getLogFile(): string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Gets or creates the global configuration logger
|
|
176
|
+
*
|
|
177
|
+
* @param options - Logger options (only used on first call)
|
|
178
|
+
* @returns Configuration logger instance
|
|
179
|
+
*/
|
|
180
|
+
export declare function getConfigLogger(options?: {
|
|
181
|
+
logFile?: string;
|
|
182
|
+
enableConsole?: boolean;
|
|
183
|
+
minLogLevel?: LogLevel;
|
|
184
|
+
}): ConfigLogger;
|
|
185
|
+
/**
|
|
186
|
+
* Sets the global configuration logger
|
|
187
|
+
*
|
|
188
|
+
* @param logger - Logger instance
|
|
189
|
+
*/
|
|
190
|
+
export declare function setConfigLogger(logger: ConfigLogger): void;
|
|
191
|
+
//# sourceMappingURL=config-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-logger.d.ts","sourceRoot":"","sources":["../../lib/config-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;GAEG;AACH,oBAAY,QAAQ;IAChB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,oBAAY,eAAe;IACvB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,cAAc,mBAAmB;CACpC;AAED;;GAEG;AACH,qBAAa,YAAY;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,WAAW,CAAW;IAE9B;;;;OAIG;gBACS,OAAO,CAAC,EAAE;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,WAAW,CAAC,EAAE,QAAQ,CAAC;KAC1B;IAcD;;;;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