+21
-9
@@ -282,2 +282,3 @@ #!/usr/bin/env node | ||
| .option('--respond-match <k=v>', 'Make the --respond* flags a CONDITIONAL rule: only matching requests get that response, everything else gets the default (repeatable: method=, path=, or a JSON body field)', (v, prev) => prev.concat(v), []) | ||
| .option('--respond-script <code>', 'DYNAMIC response: run this JavaScript/TypeScript per request in a sandboxed isolate - export default {respond(req)} returning {status?, body?, contentType?, headers?, delayMs?} | string | null (fall through to the default). @file reads from disk. Combine with --respond-match to scope it') | ||
| .option('--notify-email', 'Email you when requests arrive - works with your machine off (max 1 email / 15 min)') | ||
@@ -346,2 +347,3 @@ .option('--notify-match <k=v>', 'Email you when a MATCHING request arrives: method=, path=, or a JSON body field (repeatable; throttled like --notify-email)', (v, prev) => prev.concat(v), []) | ||
| const forwardScript = readAtFile(options.forwardScript, 'script'); | ||
| const respondScript = readAtFile(options.respondScript, 'respond script'); | ||
| const respondHeaders = {}; | ||
@@ -367,11 +369,16 @@ for (const raw of options.respondHeader) { | ||
| } | ||
| // --respond-match turns the --respond* flags into ONE conditional rule; | ||
| // non-matching requests get the stock default response. | ||
| // --respond-match / --respond-script turn the --respond* flags into ONE | ||
| // rule; non-matching requests get the stock default response. | ||
| let respondRule; | ||
| if (options.respondMatch.length > 0) { | ||
| if (buildMatch(options.respondMatch) === null) { | ||
| if (respondScript !== undefined && options.respondBody !== undefined) { | ||
| console.log(`\n ${CROSS} a rule takes --respond-script OR --respond-body, not both\n`); | ||
| process.exit(1); | ||
| } | ||
| if (options.respondMatch.length > 0 || respondScript !== undefined) { | ||
| if (options.respondMatch.length > 0 && buildMatch(options.respondMatch) === null) { | ||
| console.log(`\n ${CROSS} --respond-match expects k=v: method=POST, path=/slack, or event.type=paid\n`); | ||
| process.exit(1); | ||
| } | ||
| const hasResponse = options.respond !== undefined || | ||
| const hasResponse = respondScript !== undefined || | ||
| options.respond !== undefined || | ||
| options.respondBody !== undefined || | ||
@@ -382,3 +389,3 @@ options.respondContentType !== undefined || | ||
| if (!hasResponse) { | ||
| console.log(`\n ${CROSS} --respond-match shapes a conditional response - add --respond / --respond-body / --respond-header / --respond-delay\n`); | ||
| console.log(`\n ${CROSS} --respond-match shapes a conditional response - add --respond / --respond-body / --respond-header / --respond-delay / --respond-script\n`); | ||
| process.exit(1); | ||
@@ -389,5 +396,10 @@ } | ||
| status: options.respond ?? 200, | ||
| body: options.respondBody ?? null, | ||
| // {{placeholders}} render per request; plain bodies serve verbatim. | ||
| mode: options.respondBody?.includes('{{') ? 'template' : 'static', | ||
| body: respondScript ?? options.respondBody ?? null, | ||
| // Scripts run per request; {{placeholders}} render per request; | ||
| // plain bodies serve verbatim. | ||
| mode: respondScript !== undefined | ||
| ? 'script' | ||
| : options.respondBody?.includes('{{') | ||
| ? 'template' | ||
| : 'static', | ||
| contentType: options.respondContentType ?? 'application/json', | ||
@@ -394,0 +406,0 @@ headers: Object.keys(respondHeaders).length > 0 ? respondHeaders : null, |
+1
-1
| { | ||
| "name": "otterkit", | ||
| "version": "0.26.0", | ||
| "version": "0.27.0", | ||
| "description": "OtterKit CLI - provision and connect tunnels for AI agents", | ||
@@ -5,0 +5,0 @@ "mcpName": "io.github.useotterkit/otterkit", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
238335
0.39%5530
0.24%