@stigmer/server 3.30.0 → 3.31.0
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 +1 -1
- package/dist/boot/compose.d.ts.map +1 -1
- package/dist/boot/compose.js +5 -0
- package/dist/boot/compose.js.map +1 -1
- package/dist/boot/config.d.ts +10 -0
- package/dist/boot/config.d.ts.map +1 -1
- package/dist/boot/config.js +2 -0
- package/dist/boot/config.js.map +1 -1
- package/dist/domain/oauthapp/controller.d.ts +16 -8
- package/dist/domain/oauthapp/controller.d.ts.map +1 -1
- package/dist/domain/oauthapp/controller.js +28 -11
- package/dist/domain/oauthapp/controller.js.map +1 -1
- package/dist/domain/oauthapp/refresolution.d.ts.map +1 -1
- package/dist/domain/oauthapp/refresolution.js +3 -2
- package/dist/domain/oauthapp/refresolution.js.map +1 -1
- package/dist/domain/oauthapp/steps.d.ts +5 -5
- package/dist/domain/oauthapp/steps.js +6 -6
- package/dist/domain/oauthapp/steps.js.map +1 -1
- package/dist/sandbox/docker.d.ts.map +1 -1
- package/dist/sandbox/docker.js +13 -5
- package/dist/sandbox/docker.js.map +1 -1
- package/dist/sandbox/kubernetes.d.ts +1 -1
- package/dist/sandbox/kubernetes.d.ts.map +1 -1
- package/dist/sandbox/kubernetes.js +18 -4
- package/dist/sandbox/kubernetes.js.map +1 -1
- package/dist/sandbox/local-process.d.ts.map +1 -1
- package/dist/sandbox/local-process.js +8 -1
- package/dist/sandbox/local-process.js.map +1 -1
- package/dist/sandbox/provisioner.d.ts +12 -0
- package/dist/sandbox/provisioner.d.ts.map +1 -1
- package/dist/sandbox/provisioner.js.map +1 -1
- package/dist/temporal/manager.d.ts +10 -0
- package/dist/temporal/manager.d.ts.map +1 -1
- package/dist/temporal/manager.js +10 -0
- package/dist/temporal/manager.js.map +1 -1
- package/package.json +6 -6
- package/src/boot/__tests__/config.test.ts +23 -1
- package/src/boot/compose.ts +5 -0
- package/src/boot/config.ts +13 -0
- package/src/domain/oauthapp/__tests__/oauthapp.test.ts +17 -10
- package/src/domain/oauthapp/controller.ts +51 -18
- package/src/domain/oauthapp/refresolution.ts +3 -2
- package/src/domain/oauthapp/steps.ts +6 -6
- package/src/sandbox/__tests__/docker.integration.test.ts +2 -0
- package/src/sandbox/__tests__/kubernetes.test.ts +27 -0
- package/src/sandbox/__tests__/local-process.integration.test.ts +10 -0
- package/src/sandbox/__tests__/provisioner.test.ts +2 -0
- package/src/sandbox/docker.ts +11 -5
- package/src/sandbox/kubernetes.ts +18 -3
- package/src/sandbox/local-process.ts +11 -1
- package/src/sandbox/provisioner.ts +12 -0
- package/src/temporal/__tests__/manager.test.ts +59 -1
- package/src/temporal/manager.ts +13 -0
- package/dist/domain/oauthapp/refresolution/refresolution.d.ts +0 -12
- package/dist/domain/oauthapp/refresolution/refresolution.d.ts.map +0 -1
- package/dist/domain/oauthapp/refresolution/refresolution.js +0 -79
- package/dist/domain/oauthapp/refresolution/refresolution.js.map +0 -1
- package/src/domain/oauthapp/refresolution/refresolution.ts +0 -94
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ApiResourceReference } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
2
|
-
import type { OAuthApp } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/api_pb";
|
|
3
|
-
import type { Logger } from "../../../boot/logger.js";
|
|
4
|
-
import type { Store } from "../../../store/interface.js";
|
|
5
|
-
/**
|
|
6
|
-
* Resolves the OAuthApp the ref means (Go refresolution.Resolve). A ref
|
|
7
|
-
* without a slug resolves to nothing — an McpServerAuth with no (or an
|
|
8
|
-
* empty) oauth_app_ref is the DCR/manual-token arm, not a lookup. Store
|
|
9
|
-
* errors propagate to the caller (Go returns them).
|
|
10
|
-
*/
|
|
11
|
-
export declare function resolveOAuthAppRef(store: Store, ref: ApiResourceReference, logger: Logger): Promise<OAuthApp | undefined>;
|
|
12
|
-
//# sourceMappingURL=refresolution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"refresolution.d.ts","sourceRoot":"","sources":["../../../../src/domain/oauthapp/refresolution/refresolution.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sDAAsD,CAAC;AAGjG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAC;AAElF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,oBAAoB,EACzB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CA2C/B"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OAuthApp ref resolution — ports pkg/domain/oauthapp/refresolution: the
|
|
3
|
-
* ONE answer to "which OAuthApp does this `oauth_app_ref` mean?" (the
|
|
4
|
-
* defaultinstance pattern — one small module holds a cross-domain semantic
|
|
5
|
-
* so its consumers cannot drift apart, stigmer/stigmer#584).
|
|
6
|
-
*
|
|
7
|
-
* Consumers: the OAuthApp delete guard (this domain, #13); the OAuth
|
|
8
|
-
* initiate path, the read-path oauth_status enricher, and the token-refresh
|
|
9
|
-
* path arrive with the mcpserver connect/OAuth sub-project (#19) and MUST
|
|
10
|
-
* route through this function — three hand-rolled divergent answers are
|
|
11
|
-
* exactly what #584 removed.
|
|
12
|
-
*
|
|
13
|
-
* Resolution semantics (OSS has a flat OAuthApp store — no org-override
|
|
14
|
-
* chain like the cloud's OAuthAppResolutionService, so the ref is the whole
|
|
15
|
-
* resolution): matching is by slug, with the ref's org as a preference
|
|
16
|
-
* rather than a gate:
|
|
17
|
-
*
|
|
18
|
-
* 1. An exact (org, slug) match wins — unique by the create pipeline's
|
|
19
|
-
* duplicate check.
|
|
20
|
-
* 2. Otherwise a slug-only match is honored when it is UNIQUE. This lets
|
|
21
|
-
* a deployment satisfy a public server's ref pinned to
|
|
22
|
-
* `org: stigmer` with an OAuthApp applied in the user's own org (#584).
|
|
23
|
-
* 3. Two or more slug matches with no exact hit resolve to nothing, with
|
|
24
|
-
* a WARN naming the candidate orgs: ambiguity is never silently
|
|
25
|
-
* collapsed into a credential pick.
|
|
26
|
-
*
|
|
27
|
-
* Returns undefined when nothing resolves; callers own the severity of that
|
|
28
|
-
* outcome (the delete guard treats it as unreferenced; initiate will refuse
|
|
29
|
-
* NOT_FOUND, refresh will error — #19).
|
|
30
|
-
*/
|
|
31
|
-
import { fromBinary } from "@bufbuild/protobuf";
|
|
32
|
-
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
33
|
-
import { OAuthAppSchema } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/api_pb";
|
|
34
|
-
/**
|
|
35
|
-
* Resolves the OAuthApp the ref means (Go refresolution.Resolve). A ref
|
|
36
|
-
* without a slug resolves to nothing — an McpServerAuth with no (or an
|
|
37
|
-
* empty) oauth_app_ref is the DCR/manual-token arm, not a lookup. Store
|
|
38
|
-
* errors propagate to the caller (Go returns them).
|
|
39
|
-
*/
|
|
40
|
-
export async function resolveOAuthAppRef(store, ref, logger) {
|
|
41
|
-
if (ref.slug === "") {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
const rows = await store.listResources(ApiResourceKind.oauth_app);
|
|
45
|
-
// Collect-then-decide: a single pass gathers every slug match so the
|
|
46
|
-
// outcome depends only on the store's contents, never on its iteration
|
|
47
|
-
// order (Go's earlier first-match-wins scan was nondeterministic when a
|
|
48
|
-
// slug existed in several orgs).
|
|
49
|
-
const slugMatches = [];
|
|
50
|
-
for (const data of rows) {
|
|
51
|
-
let app;
|
|
52
|
-
try {
|
|
53
|
-
app = fromBinary(OAuthAppSchema, data);
|
|
54
|
-
}
|
|
55
|
-
catch {
|
|
56
|
-
continue; // skip malformed rows, as Go does
|
|
57
|
-
}
|
|
58
|
-
if ((app.metadata?.slug ?? "") !== ref.slug) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
if (ref.org !== "" && app.metadata?.org === ref.org) {
|
|
62
|
-
return app; // exact match: unique by the create duplicate check
|
|
63
|
-
}
|
|
64
|
-
slugMatches.push(app);
|
|
65
|
-
}
|
|
66
|
-
if (slugMatches.length === 0) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
if (slugMatches.length === 1) {
|
|
70
|
-
return slugMatches[0];
|
|
71
|
-
}
|
|
72
|
-
logger.warn("oauth_app_ref is ambiguous (slug exists in several orgs, none matching the ref); refusing to pick — pin the ref's org to resolve", {
|
|
73
|
-
oauthAppSlug: ref.slug,
|
|
74
|
-
refOrg: ref.org,
|
|
75
|
-
candidateOrgs: slugMatches.map((app) => app.metadata?.org ?? ""),
|
|
76
|
-
});
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=refresolution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"refresolution.js","sourceRoot":"","sources":["../../../../src/domain/oauthapp/refresolution/refresolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,eAAe,EAAE,MAAM,qFAAqF,CAAC;AACtH,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAMnF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAY,EACZ,GAAyB,EACzB,MAAc;IAEd,IAAI,GAAG,CAAC,IAAI,KAAK,EAAE,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,eAAe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thApp ref resolution — ports pkg/domain/oauthapp/refresolution: the
|
|
3
|
-
* ONE answer to "which OAuthApp does this `oauth_app_ref` mean?" (the
|
|
4
|
-
* defaultinstance pattern — one small module holds a cross-domain semantic
|
|
5
|
-
* so its consumers cannot drift apart, stigmer/stigmer#584).
|
|
6
|
-
*
|
|
7
|
-
* Consumers: the OAuthApp delete guard (this domain, #13); the OAuth
|
|
8
|
-
* initiate path, the read-path oauth_status enricher, and the token-refresh
|
|
9
|
-
* path arrive with the mcpserver connect/OAuth sub-project (#19) and MUST
|
|
10
|
-
* route through this function — three hand-rolled divergent answers are
|
|
11
|
-
* exactly what #584 removed.
|
|
12
|
-
*
|
|
13
|
-
* Resolution semantics (OSS has a flat OAuthApp store — no org-override
|
|
14
|
-
* chain like the cloud's OAuthAppResolutionService, so the ref is the whole
|
|
15
|
-
* resolution): matching is by slug, with the ref's org as a preference
|
|
16
|
-
* rather than a gate:
|
|
17
|
-
*
|
|
18
|
-
* 1. An exact (org, slug) match wins — unique by the create pipeline's
|
|
19
|
-
* duplicate check.
|
|
20
|
-
* 2. Otherwise a slug-only match is honored when it is UNIQUE. This lets
|
|
21
|
-
* a deployment satisfy a public server's ref pinned to
|
|
22
|
-
* `org: stigmer` with an OAuthApp applied in the user's own org (#584).
|
|
23
|
-
* 3. Two or more slug matches with no exact hit resolve to nothing, with
|
|
24
|
-
* a WARN naming the candidate orgs: ambiguity is never silently
|
|
25
|
-
* collapsed into a credential pick.
|
|
26
|
-
*
|
|
27
|
-
* Returns undefined when nothing resolves; callers own the severity of that
|
|
28
|
-
* outcome (the delete guard treats it as unreferenced; initiate will refuse
|
|
29
|
-
* NOT_FOUND, refresh will error — #19).
|
|
30
|
-
*/
|
|
31
|
-
import { fromBinary } from "@bufbuild/protobuf";
|
|
32
|
-
|
|
33
|
-
import type { ApiResourceReference } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
34
|
-
import { ApiResourceKind } from "@stigmer/protos/ai/stigmer/commons/apiresource/apiresourcekind/api_resource_kind_pb";
|
|
35
|
-
import { OAuthAppSchema } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/api_pb";
|
|
36
|
-
import type { OAuthApp } from "@stigmer/protos/ai/stigmer/iam/oauthapp/v1/api_pb";
|
|
37
|
-
|
|
38
|
-
import type { Logger } from "../../../boot/logger.js";
|
|
39
|
-
import type { Store } from "../../../store/interface.js";
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Resolves the OAuthApp the ref means (Go refresolution.Resolve). A ref
|
|
43
|
-
* without a slug resolves to nothing — an McpServerAuth with no (or an
|
|
44
|
-
* empty) oauth_app_ref is the DCR/manual-token arm, not a lookup. Store
|
|
45
|
-
* errors propagate to the caller (Go returns them).
|
|
46
|
-
*/
|
|
47
|
-
export async function resolveOAuthAppRef(
|
|
48
|
-
store: Store,
|
|
49
|
-
ref: ApiResourceReference,
|
|
50
|
-
logger: Logger,
|
|
51
|
-
): Promise<OAuthApp | undefined> {
|
|
52
|
-
if (ref.slug === "") {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const rows = await store.listResources(ApiResourceKind.oauth_app);
|
|
57
|
-
|
|
58
|
-
// Collect-then-decide: a single pass gathers every slug match so the
|
|
59
|
-
// outcome depends only on the store's contents, never on its iteration
|
|
60
|
-
// order (Go's earlier first-match-wins scan was nondeterministic when a
|
|
61
|
-
// slug existed in several orgs).
|
|
62
|
-
const slugMatches: OAuthApp[] = [];
|
|
63
|
-
for (const data of rows) {
|
|
64
|
-
let app: OAuthApp;
|
|
65
|
-
try {
|
|
66
|
-
app = fromBinary(OAuthAppSchema, data);
|
|
67
|
-
} catch {
|
|
68
|
-
continue; // skip malformed rows, as Go does
|
|
69
|
-
}
|
|
70
|
-
if ((app.metadata?.slug ?? "") !== ref.slug) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (ref.org !== "" && app.metadata?.org === ref.org) {
|
|
74
|
-
return app; // exact match: unique by the create duplicate check
|
|
75
|
-
}
|
|
76
|
-
slugMatches.push(app);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (slugMatches.length === 0) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
if (slugMatches.length === 1) {
|
|
83
|
-
return slugMatches[0];
|
|
84
|
-
}
|
|
85
|
-
logger.warn(
|
|
86
|
-
"oauth_app_ref is ambiguous (slug exists in several orgs, none matching the ref); refusing to pick — pin the ref's org to resolve",
|
|
87
|
-
{
|
|
88
|
-
oauthAppSlug: ref.slug,
|
|
89
|
-
refOrg: ref.org,
|
|
90
|
-
candidateOrgs: slugMatches.map((app) => app.metadata?.org ?? ""),
|
|
91
|
-
},
|
|
92
|
-
);
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|