@akai-workflow-builder/cli-sdk 0.1.11 → 0.1.13
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/ctx/build-ctx.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ export interface BuildCtxParams {
|
|
|
50
50
|
* reference a key not declared at the CLI level, or when a referenced
|
|
51
51
|
* key whose CLI declaration is `required: true` has no value in
|
|
52
52
|
* `secretValues`. CLI-level required secrets that this tool does not
|
|
53
|
-
* reference are not checked.
|
|
53
|
+
* reference are not checked. A `required` + `injected` secret left empty
|
|
54
|
+
* is tolerated when `oauthAccessToken` is supplied.
|
|
54
55
|
*/
|
|
55
56
|
export declare function buildCtx(params: BuildCtxParams): ToolCtx;
|
|
56
57
|
//# sourceMappingURL=build-ctx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-ctx.d.ts","sourceRoot":"","sources":["../../src/ctx/build-ctx.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAc,MAAM,EAAiB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG1F;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6GAA6G;IAC7G,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,sGAAsG;IACtG,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,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wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAwDxD"}
|
package/dist/ctx/build-ctx.js
CHANGED
|
@@ -50,11 +50,12 @@ function nativeFetch(_url, _init) {
|
|
|
50
50
|
* reference a key not declared at the CLI level, or when a referenced
|
|
51
51
|
* key whose CLI declaration is `required: true` has no value in
|
|
52
52
|
* `secretValues`. CLI-level required secrets that this tool does not
|
|
53
|
-
* reference are not checked.
|
|
53
|
+
* reference are not checked. A `required` + `injected` secret left empty
|
|
54
|
+
* is tolerated when `oauthAccessToken` is supplied.
|
|
54
55
|
*/
|
|
55
56
|
export function buildCtx(params) {
|
|
56
57
|
const tool = resolveTool(params.cli, params.toolName);
|
|
57
|
-
const secrets = buildScopedSecrets(params.cli.secrets, tool.options.secretKeys, params.secretValues);
|
|
58
|
+
const secrets = buildScopedSecrets(params.cli.secrets, tool.options.secretKeys, params.secretValues, { oauthPresent: typeof params.oauthAccessToken === 'string' && params.oauthAccessToken !== '' });
|
|
58
59
|
const properties = buildScopedProperties(params.cli.properties, tool.options.propertyKeys, params.propertyValues ?? {});
|
|
59
60
|
const fetch = tool.transport === 'native' || tool.options.network === undefined
|
|
60
61
|
? nativeFetch
|
package/dist/ctx/secrets.d.ts
CHANGED
|
@@ -27,12 +27,16 @@ export type PropertyValues = Readonly<Record<string, string | undefined>>;
|
|
|
27
27
|
* @param toolSecretKeys - subset the tool declared via `options.secretKeys`
|
|
28
28
|
* @param values - raw values keyed by secret key (typically collected by
|
|
29
29
|
* the host runtime from its invocation request body)
|
|
30
|
+
* @param opts.oauthPresent - when true, an empty `required` + `injected`
|
|
31
|
+
* secret is tolerated; the OAuth token reaches the handler via `ctx.oauth`
|
|
30
32
|
* @returns frozen record exposing only the requested keys
|
|
31
33
|
* @throws {AkaiSecretError} when a `toolSecretKeys` entry isn't declared
|
|
32
34
|
* at the CLI level, or a `required: true` declaration has no value
|
|
33
|
-
* supplied (or empty string).
|
|
35
|
+
* supplied (or empty string) and no OAuth token is present.
|
|
34
36
|
*/
|
|
35
|
-
export declare function buildScopedSecrets(cliSecrets: readonly SecretDecl[], toolSecretKeys: readonly string[], values: SecretValues
|
|
37
|
+
export declare function buildScopedSecrets(cliSecrets: readonly SecretDecl[], toolSecretKeys: readonly string[], values: SecretValues, opts?: {
|
|
38
|
+
readonly oauthPresent?: boolean;
|
|
39
|
+
}): Readonly<Record<string, string | undefined>>;
|
|
36
40
|
/**
|
|
37
41
|
* Scope tenant-property values to the keys a single tool declared.
|
|
38
42
|
* Mirrors {@link buildScopedSecrets} so handlers see the same access shape
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/ctx/secrets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAE1E
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/ctx/secrets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,SAAS,UAAU,EAAE,EACjC,cAAc,EAAE,SAAS,MAAM,EAAE,EACjC,MAAM,EAAE,YAAY,EACpB,IAAI,CAAC,EAAE;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GACzC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAqB9C;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,SAAS,YAAY,EAAE,EACtC,gBAAgB,EAAE,SAAS,MAAM,EAAE,EACnC,MAAM,EAAE,cAAc,GACrB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAiB9C"}
|
package/dist/ctx/secrets.js
CHANGED
|
@@ -14,12 +14,14 @@ import { AkaiPropertyError, AkaiSecretError } from '../errors.js';
|
|
|
14
14
|
* @param toolSecretKeys - subset the tool declared via `options.secretKeys`
|
|
15
15
|
* @param values - raw values keyed by secret key (typically collected by
|
|
16
16
|
* the host runtime from its invocation request body)
|
|
17
|
+
* @param opts.oauthPresent - when true, an empty `required` + `injected`
|
|
18
|
+
* secret is tolerated; the OAuth token reaches the handler via `ctx.oauth`
|
|
17
19
|
* @returns frozen record exposing only the requested keys
|
|
18
20
|
* @throws {AkaiSecretError} when a `toolSecretKeys` entry isn't declared
|
|
19
21
|
* at the CLI level, or a `required: true` declaration has no value
|
|
20
|
-
* supplied (or empty string).
|
|
22
|
+
* supplied (or empty string) and no OAuth token is present.
|
|
21
23
|
*/
|
|
22
|
-
export function buildScopedSecrets(cliSecrets, toolSecretKeys, values) {
|
|
24
|
+
export function buildScopedSecrets(cliSecrets, toolSecretKeys, values, opts) {
|
|
23
25
|
const declByKey = new Map(cliSecrets.map((d) => [d.key, d]));
|
|
24
26
|
const scoped = Object.create(null);
|
|
25
27
|
for (const key of toolSecretKeys) {
|
|
@@ -29,7 +31,11 @@ export function buildScopedSecrets(cliSecrets, toolSecretKeys, values) {
|
|
|
29
31
|
}
|
|
30
32
|
const value = values[key];
|
|
31
33
|
if (decl.required && (value === undefined || value === '')) {
|
|
32
|
-
|
|
34
|
+
// OAuth token (ctx.oauth) satisfies a host-injected secret left empty.
|
|
35
|
+
const satisfiedByOAuth = opts?.oauthPresent === true && decl.injected === true;
|
|
36
|
+
if (!satisfiedByOAuth) {
|
|
37
|
+
throw new AkaiSecretError(`required secret \`${key}\` is missing`, { key });
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
scoped[key] = value;
|
|
35
41
|
}
|