@once-agent/sdk 0.1.3 → 0.1.5
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 +62 -3
- package/dist/cli.js +13 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +245 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/decision.d.ts +39 -0
- package/dist/runtime/decision.d.ts.map +1 -0
- package/dist/runtime/decision.js +102 -0
- package/dist/runtime/decision.js.map +1 -0
- package/dist/runtime/fetch-interceptor.d.ts +66 -0
- package/dist/runtime/fetch-interceptor.d.ts.map +1 -0
- package/dist/runtime/fetch-interceptor.js +151 -0
- package/dist/runtime/fetch-interceptor.js.map +1 -0
- package/dist/runtime/identity.d.ts +23 -0
- package/dist/runtime/identity.d.ts.map +1 -0
- package/dist/runtime/identity.js +191 -0
- package/dist/runtime/identity.js.map +1 -0
- package/dist/runtime/pipeline.d.ts +25 -0
- package/dist/runtime/pipeline.d.ts.map +1 -0
- package/dist/runtime/pipeline.js +121 -0
- package/dist/runtime/pipeline.js.map +1 -0
- package/dist/setup.d.ts +2 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +101 -8
- package/dist/setup.js.map +1 -1
- package/dist-cjs/index.js +255 -2
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/runtime/decision.js +105 -0
- package/dist-cjs/runtime/decision.js.map +1 -0
- package/dist-cjs/runtime/fetch-interceptor.js +157 -0
- package/dist-cjs/runtime/fetch-interceptor.js.map +1 -0
- package/dist-cjs/runtime/identity.js +194 -0
- package/dist-cjs/runtime/identity.js.map +1 -0
- package/dist-cjs/runtime/pipeline.js +124 -0
- package/dist-cjs/runtime/pipeline.js.map +1 -0
- package/package.json +12 -3
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const SAFE_HTTP_METHODS = new Set([
|
|
2
|
+
"GET",
|
|
3
|
+
"HEAD",
|
|
4
|
+
"OPTIONS"
|
|
5
|
+
]);
|
|
6
|
+
const CONSEQUENTIAL_HTTP_METHODS = new Set([
|
|
7
|
+
"POST",
|
|
8
|
+
"PUT",
|
|
9
|
+
"PATCH",
|
|
10
|
+
"DELETE"
|
|
11
|
+
]);
|
|
12
|
+
function normalizeMethod(method) {
|
|
13
|
+
return String(method || "")
|
|
14
|
+
.trim()
|
|
15
|
+
.toUpperCase();
|
|
16
|
+
}
|
|
17
|
+
function nonEmpty(value) {
|
|
18
|
+
return (typeof value === "string" &&
|
|
19
|
+
value.trim().length > 0);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decide whether an outbound HTTP operation may
|
|
23
|
+
* pass normally, must be protected by Once, or
|
|
24
|
+
* must fail closed.
|
|
25
|
+
*
|
|
26
|
+
* v0.1 intentionally does NOT guess identity.
|
|
27
|
+
*
|
|
28
|
+
* A consequential operation without a stable
|
|
29
|
+
* operationId is blocked rather than executed
|
|
30
|
+
* unsafely.
|
|
31
|
+
*/
|
|
32
|
+
export function decideHttpExecution(call) {
|
|
33
|
+
const method = normalizeMethod(call.method);
|
|
34
|
+
let parsedUrl;
|
|
35
|
+
try {
|
|
36
|
+
parsedUrl =
|
|
37
|
+
new URL(call.url);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return {
|
|
41
|
+
decision: "BLOCK",
|
|
42
|
+
code: "INVALID_URL",
|
|
43
|
+
consequential: true,
|
|
44
|
+
method,
|
|
45
|
+
reason: "Runtime could not safely determine the destination URL."
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (parsedUrl.protocol !== "https:" &&
|
|
49
|
+
parsedUrl.protocol !== "http:") {
|
|
50
|
+
return {
|
|
51
|
+
decision: "BLOCK",
|
|
52
|
+
code: "UNSUPPORTED_PROTOCOL",
|
|
53
|
+
consequential: true,
|
|
54
|
+
method,
|
|
55
|
+
reason: `Runtime does not support protocol ${parsedUrl.protocol}`
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (SAFE_HTTP_METHODS.has(method)) {
|
|
59
|
+
return {
|
|
60
|
+
decision: "PASS",
|
|
61
|
+
code: "SAFE_HTTP_METHOD",
|
|
62
|
+
consequential: false,
|
|
63
|
+
method,
|
|
64
|
+
reason: `${method} is treated as a non-consequential HTTP read in Runtime v0.1.`
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (!CONSEQUENTIAL_HTTP_METHODS.has(method)) {
|
|
68
|
+
return {
|
|
69
|
+
decision: "BLOCK",
|
|
70
|
+
code: "UNSUPPORTED_HTTP_METHOD",
|
|
71
|
+
consequential: true,
|
|
72
|
+
method,
|
|
73
|
+
reason: `Runtime does not yet have a proven execution policy for HTTP method ${method || "(empty)"}.`
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (!nonEmpty(call.provider)) {
|
|
77
|
+
return {
|
|
78
|
+
decision: "BLOCK",
|
|
79
|
+
code: "MISSING_PROVIDER",
|
|
80
|
+
consequential: true,
|
|
81
|
+
method,
|
|
82
|
+
reason: "Consequential operation has no configured Once provider."
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (!nonEmpty(call.operationId)) {
|
|
86
|
+
return {
|
|
87
|
+
decision: "BLOCK",
|
|
88
|
+
code: "MISSING_OPERATION_ID",
|
|
89
|
+
consequential: true,
|
|
90
|
+
method,
|
|
91
|
+
reason: "Consequential operation has no stable operation identity. Once refuses unsafe execution."
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
decision: "PROTECT",
|
|
96
|
+
code: "CONSEQUENTIAL_HTTP_WRITE",
|
|
97
|
+
consequential: true,
|
|
98
|
+
method,
|
|
99
|
+
reason: "Consequential HTTP operation has a provider and stable identity and must execute through Once."
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=decision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision.js","sourceRoot":"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P,EACD,CAAC;QAED,OAAO;YACL,QAAQ,EACN,MAAM;YAER,IAAI,EACF,kBAAkB;YAEpB,aAAa,EACX,KAAK;YAEP,MAAM;YAEN,MAAM,EACJ,GAAG,MAAM,+DAA+D;SAC3E,CAAC;IACJ,CAAC;IAED,IACE,CAAC,0BAA0B,CAAC,GAAG,CAC7B,MAAM,CACP,EACD,CAAC;QAED,OAAO;YACL,QAAQ,EACN,OAAO;YAET,IAAI,EACF,yBAAyB;YAE3B,aAAa,EACX,IAAI;YAEN,MAAM;YAEN,MAAM,EACJ,uEAAuE,MAAM,IAAI,SAAS,GAAG;SAChG,CAAC;IACJ,CAAC;IAED,IACE,CAAC,QAAQ,CACP,IAAI,CAAC,QAAQ,CACd,EACD,CAAC;QAED,OAAO;YACL,QAAQ,EACN,OAAO;YAET,IAAI,EACF,kBAAkB;YAEpB,aAAa,EACX,IAAI;YAEN,MAAM;YAEN,MAAM,EACJ,0DAA0D;SAC7D,CAAC;IACJ,CAAC;IAED,IACE,CAAC,QAAQ,CACP,IAAI,CAAC,WAAW,CACjB,EACD,CAAC;QAED,OAAO;YACL,QAAQ,EACN,OAAO;YAET,IAAI,EACF,sBAAsB;YAExB,aAAa,EACX,IAAI;YAEN,MAAM;YAEN,MAAM,EACJ,0FAA0F;SAC7F,CAAC;IACJ,CAAC;IAED,OAAO;QACL,QAAQ,EACN,SAAS;QAEX,IAAI,EACF,0BAA0B;QAE5B,aAAa,EACX,IAAI;QAEN,MAAM;QAEN,MAAM,EACJ,gGAAgG;KACnG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type OnceRuntimePipelineResult } from "./pipeline.js";
|
|
2
|
+
export declare class OnceRuntimeBlockedError extends Error {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly decision: OnceRuntimePipelineResult;
|
|
5
|
+
constructor(decision: OnceRuntimePipelineResult);
|
|
6
|
+
}
|
|
7
|
+
export type OnceProtectedFetchContext = {
|
|
8
|
+
request: Request;
|
|
9
|
+
decision: OnceRuntimePipelineResult;
|
|
10
|
+
provider: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Native fetch captured before interception.
|
|
13
|
+
*
|
|
14
|
+
* Protected handlers MUST use this for internal
|
|
15
|
+
* Once/provider network operations so they do
|
|
16
|
+
* not recursively re-enter the interceptor.
|
|
17
|
+
*/
|
|
18
|
+
originalFetch: typeof fetch;
|
|
19
|
+
};
|
|
20
|
+
export type OnceProtectedFetchHandler = (context: OnceProtectedFetchContext) => Promise<Response>;
|
|
21
|
+
export type OnceFetchInterceptorOptions = {
|
|
22
|
+
/**
|
|
23
|
+
* Runtime v0.1 may use one configured provider
|
|
24
|
+
* for every supported outbound write.
|
|
25
|
+
*/
|
|
26
|
+
provider?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Optional provider resolver for projects with
|
|
29
|
+
* multiple provider destinations.
|
|
30
|
+
*/
|
|
31
|
+
resolveProvider?: (request: Request) => string | undefined | Promise<string | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Optional application-specific identity hook.
|
|
34
|
+
*
|
|
35
|
+
* The returned value is treated as an explicit
|
|
36
|
+
* stable operation identity by the Runtime.
|
|
37
|
+
*/
|
|
38
|
+
resolveOperationId?: (request: Request) => string | undefined | Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Called only when Runtime returns PROTECT.
|
|
41
|
+
*
|
|
42
|
+
* It must preserve fetch Response semantics.
|
|
43
|
+
*/
|
|
44
|
+
protect: OnceProtectedFetchHandler;
|
|
45
|
+
/**
|
|
46
|
+
* Primarily for tests. Normally Runtime captures
|
|
47
|
+
* the native global fetch implementation.
|
|
48
|
+
*/
|
|
49
|
+
fetchImpl?: typeof fetch;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Create a fetch-compatible Once interception
|
|
53
|
+
* function without mutating global state.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createOnceFetchInterceptor(options: OnceFetchInterceptorOptions): typeof fetch;
|
|
56
|
+
export type OnceFetchInstallation = {
|
|
57
|
+
restore: () => void;
|
|
58
|
+
fetch: typeof fetch;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Install Once at the process-wide fetch boundary.
|
|
62
|
+
*
|
|
63
|
+
* Installation is explicit and reversible.
|
|
64
|
+
*/
|
|
65
|
+
export declare function installOnceFetchInterceptor(options: OnceFetchInterceptorOptions): OnceFetchInstallation;
|
|
66
|
+
//# sourceMappingURL=fetch-interceptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-interceptor.d.ts","sourceRoot":"","sources":["../../src/runtime/fetch-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,eAAe,CAAC;AAEvB,qBAAa,uBACX,SAAQ,KAAK;IAEb,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EACf,yBAAyB,CAAC;gBAG1B,QAAQ,EACN,yBAAyB;CAgB9B;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,OAAO,CAAC;IAEjB,QAAQ,EACN,yBAAyB,CAAC;IAE5B,QAAQ,EACN,MAAM,GAAG,SAAS,CAAC;IAErB;;;;;;OAMG;IACH,aAAa,EACX,OAAO,KAAK,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GACnC,CACE,OAAO,EACL,yBAAyB,KACxB,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEzB,MAAM,MAAM,2BAA2B,GAAG;IACxC;;;OAGG;IACH,QAAQ,CAAC,EACP,MAAM,CAAC;IAET;;;OAGG;IACH,eAAe,CAAC,EACd,CACE,OAAO,EAAE,OAAO,KAEhB,MAAM,GACN,SAAS,GACT,OAAO,CACL,MAAM,GACN,SAAS,CACV,CAAC;IAEN;;;;;OAKG;IACH,kBAAkB,CAAC,EACjB,CACE,OAAO,EAAE,OAAO,KAEhB,MAAM,GACN,SAAS,GACT,OAAO,CACL,MAAM,GACN,SAAS,CACV,CAAC;IAEN;;;;OAIG;IACH,OAAO,EACL,yBAAyB,CAAC;IAE5B;;;OAGG;IACH,SAAS,CAAC,EACR,OAAO,KAAK,CAAC;CAChB,CAAC;AA6GF;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EACL,2BAA2B,GAC5B,OAAO,KAAK,CA0Gd;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EACL,MAAM,IAAI,CAAC;IAEb,KAAK,EACH,OAAO,KAAK,CAAC;CAChB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EACL,2BAA2B,GAC5B,qBAAqB,CA+CvB"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { prepareHttpExecution } from "./pipeline.js";
|
|
2
|
+
export class OnceRuntimeBlockedError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
decision;
|
|
5
|
+
constructor(decision) {
|
|
6
|
+
super(`Once blocked outbound HTTP execution: ${decision.code}. ${decision.reason}`);
|
|
7
|
+
this.name =
|
|
8
|
+
"OnceRuntimeBlockedError";
|
|
9
|
+
this.code =
|
|
10
|
+
decision.code;
|
|
11
|
+
this.decision =
|
|
12
|
+
decision;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function headersToObject(headers) {
|
|
16
|
+
const result = {};
|
|
17
|
+
headers.forEach((value, key) => {
|
|
18
|
+
result[key] =
|
|
19
|
+
value;
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
async function inspectBody(request) {
|
|
24
|
+
const method = request.method
|
|
25
|
+
.trim()
|
|
26
|
+
.toUpperCase();
|
|
27
|
+
if (method === "GET" ||
|
|
28
|
+
method === "HEAD" ||
|
|
29
|
+
method === "OPTIONS") {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
/*
|
|
33
|
+
* Identity v0.1 currently recognizes JSON-style
|
|
34
|
+
* body identity fields.
|
|
35
|
+
*
|
|
36
|
+
* Clone first so inspection never consumes the
|
|
37
|
+
* actual request body.
|
|
38
|
+
*/
|
|
39
|
+
let clone;
|
|
40
|
+
try {
|
|
41
|
+
clone =
|
|
42
|
+
request.clone();
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const contentType = clone.headers
|
|
48
|
+
.get("content-type")
|
|
49
|
+
?.toLowerCase() ??
|
|
50
|
+
"";
|
|
51
|
+
if (!contentType.includes("application/json")) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const text = await clone.text();
|
|
56
|
+
return (text.length > 0
|
|
57
|
+
? text
|
|
58
|
+
: undefined);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a fetch-compatible Once interception
|
|
66
|
+
* function without mutating global state.
|
|
67
|
+
*/
|
|
68
|
+
export function createOnceFetchInterceptor(options) {
|
|
69
|
+
const originalFetch = options.fetchImpl ??
|
|
70
|
+
globalThis.fetch;
|
|
71
|
+
if (typeof originalFetch !==
|
|
72
|
+
"function") {
|
|
73
|
+
throw new Error("Once Runtime requires a native fetch implementation.");
|
|
74
|
+
}
|
|
75
|
+
const intercepted = async (input, init) => {
|
|
76
|
+
/*
|
|
77
|
+
* Constructing a Request gives us one
|
|
78
|
+
* normalized view of URL, method, headers
|
|
79
|
+
* and body while preserving native fetch
|
|
80
|
+
* semantics for the final call.
|
|
81
|
+
*/
|
|
82
|
+
const request = new Request(input, init);
|
|
83
|
+
const provider = options.resolveProvider
|
|
84
|
+
? await options.resolveProvider(request)
|
|
85
|
+
: options.provider;
|
|
86
|
+
const explicitOperationId = options.resolveOperationId
|
|
87
|
+
? await options.resolveOperationId(request)
|
|
88
|
+
: undefined;
|
|
89
|
+
const body = await inspectBody(request);
|
|
90
|
+
const decision = prepareHttpExecution({
|
|
91
|
+
method: request.method,
|
|
92
|
+
url: request.url,
|
|
93
|
+
provider,
|
|
94
|
+
operationId: explicitOperationId,
|
|
95
|
+
headers: headersToObject(request.headers),
|
|
96
|
+
body
|
|
97
|
+
});
|
|
98
|
+
if (decision.decision ===
|
|
99
|
+
"PASS") {
|
|
100
|
+
return await originalFetch(request);
|
|
101
|
+
}
|
|
102
|
+
if (decision.decision ===
|
|
103
|
+
"BLOCK") {
|
|
104
|
+
throw new OnceRuntimeBlockedError(decision);
|
|
105
|
+
}
|
|
106
|
+
return await options.protect({
|
|
107
|
+
request,
|
|
108
|
+
decision,
|
|
109
|
+
provider,
|
|
110
|
+
originalFetch
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
return intercepted;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Install Once at the process-wide fetch boundary.
|
|
117
|
+
*
|
|
118
|
+
* Installation is explicit and reversible.
|
|
119
|
+
*/
|
|
120
|
+
export function installOnceFetchInterceptor(options) {
|
|
121
|
+
const previous = globalThis.fetch;
|
|
122
|
+
const intercepted = createOnceFetchInterceptor({
|
|
123
|
+
...options,
|
|
124
|
+
fetchImpl: options.fetchImpl ??
|
|
125
|
+
previous
|
|
126
|
+
});
|
|
127
|
+
globalThis.fetch =
|
|
128
|
+
intercepted;
|
|
129
|
+
let restored = false;
|
|
130
|
+
return {
|
|
131
|
+
fetch: intercepted,
|
|
132
|
+
restore: () => {
|
|
133
|
+
if (restored) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
/*
|
|
137
|
+
* Restore only if our interceptor still
|
|
138
|
+
* owns global fetch. Do not overwrite a
|
|
139
|
+
* later runtime/framework replacement.
|
|
140
|
+
*/
|
|
141
|
+
if (globalThis.fetch ===
|
|
142
|
+
intercepted) {
|
|
143
|
+
globalThis.fetch =
|
|
144
|
+
previous;
|
|
145
|
+
}
|
|
146
|
+
restored =
|
|
147
|
+
true;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=fetch-interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-interceptor.js","sourceRoot":"","sources":["../../src/runtime/fetch-interceptor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAErB,MAAM,eAAe,CAAC;AAEvB,MAAM,OAAO,uBACX,SAAQ,KAAK;IAEJ,IAAI,CAAS;IACb,QAAQ,CACW;IAE5B,YACE,QAC2B;QAG3B,KAAK,CACH,yCAAyC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,MAAM,EAAE,CAC7E,CAAC;QAEF,IAAI,CAAC,IAAI;YACP,yBAAyB,CAAC;QAE5B,IAAI,CAAC,IAAI;YACP,QAAQ,CAAC,IAAI,CAAC;QAEhB,IAAI,CAAC,QAAQ;YACX,QAAQ,CAAC;IACb,CAAC;CACF;AA8FD,SAAS,eAAe,CACtB,OAAgB;IAMhB,MAAM,MAAM,GAIN,EAAE,CAAC;IAET,OAAO,CAAC,OAAO,CACb,CACE,KAAK,EACL,GAAG,EACH,EAAE;QAEF,MAAM,CAAC,GAAG,CAAC;YACT,KAAK,CAAC;IACV,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,KAAK,UAAU,WAAW,CACxB,OAAgB;IAGhB,MAAM,MAAM,GACV,OAAO,CAAC,MAAM;SACX,IAAI,EAAE;SACN,WAAW,EAAE,CAAC;IAEnB,IACE,MAAM,KAAK,KAAK;QAChB,MAAM,KAAK,MAAM;QACjB,MAAM,KAAK,SAAS,EACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;OAMG;IACH,IAAI,KACK,CAAC;IAEV,IAAI,CAAC;QAEH,KAAK;YACH,OAAO,CAAC,KAAK,EAAE,CAAC;IAEpB,CAAC;IAAC,MAAM,CAAC;QAEP,OAAO,SAAS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
+
export type RuntimeIdentitySource = "explicit" | "header:idempotency-key" | "header:x-idempotency-key" | "body:once_operation_id" | "body:onceOperationId" | "body:operation_id" | "body:operationId" | "body:idempotency_key" | "body:idempotencyKey";
|
|
2
|
+
export type RuntimeIdentityInput = {
|
|
3
|
+
method: string;
|
|
4
|
+
url: string;
|
|
5
|
+
operationId?: string;
|
|
6
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
7
|
+
body?: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type RuntimeIdentityResult = {
|
|
10
|
+
status: "FOUND";
|
|
11
|
+
operationId: string;
|
|
12
|
+
source: RuntimeIdentitySource;
|
|
13
|
+
reason: string;
|
|
14
|
+
} | {
|
|
15
|
+
status: "REQUIRED";
|
|
16
|
+
reason: string;
|
|
17
|
+
} | {
|
|
18
|
+
status: "CONFLICT";
|
|
19
|
+
sources: RuntimeIdentitySource[];
|
|
20
|
+
reason: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function resolveHttpOperationIdentity(input: RuntimeIdentityInput): RuntimeIdentityResult;
|
|
23
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/runtime/identity.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,qBAAqB,GAC7B,UAAU,GACV,wBAAwB,GACxB,0BAA0B,GAC1B,wBAAwB,GACxB,sBAAsB,GACtB,mBAAmB,GACnB,kBAAkB,GAClB,sBAAsB,GACtB,qBAAqB,CAAC;AAE1B,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CACd,MAAM,EACN,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAC9B,CAAC;IACF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B;IACE,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,qBAAqB,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AA8TN,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,oBAAoB,GAC1B,qBAAqB,CAiEvB"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
const BODY_FIELDS = [
|
|
3
|
+
{
|
|
4
|
+
key: "once_operation_id",
|
|
5
|
+
source: "body:once_operation_id"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
key: "onceOperationId",
|
|
9
|
+
source: "body:onceOperationId"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
key: "operation_id",
|
|
13
|
+
source: "body:operation_id"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
key: "operationId",
|
|
17
|
+
source: "body:operationId"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: "idempotency_key",
|
|
21
|
+
source: "body:idempotency_key"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: "idempotencyKey",
|
|
25
|
+
source: "body:idempotencyKey"
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
function clean(value) {
|
|
29
|
+
if (typeof value !== "string") {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const result = value.trim();
|
|
33
|
+
return result.length > 0
|
|
34
|
+
? result
|
|
35
|
+
: null;
|
|
36
|
+
}
|
|
37
|
+
function normalizeMethod(value) {
|
|
38
|
+
return String(value || "")
|
|
39
|
+
.trim()
|
|
40
|
+
.toUpperCase();
|
|
41
|
+
}
|
|
42
|
+
function normalizeUrl(value) {
|
|
43
|
+
try {
|
|
44
|
+
const url = new URL(value);
|
|
45
|
+
if (url.protocol !== "https:" &&
|
|
46
|
+
url.protocol !== "http:") {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
url.hash = "";
|
|
50
|
+
const params = Array.from(url.searchParams.entries()).sort(([ak, av], [bk, bv]) => ak.localeCompare(bk) ||
|
|
51
|
+
av.localeCompare(bv));
|
|
52
|
+
url.search = "";
|
|
53
|
+
for (const [key, item] of params) {
|
|
54
|
+
url.searchParams.append(key, item);
|
|
55
|
+
}
|
|
56
|
+
return url.toString();
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function headerValue(headers, wanted) {
|
|
63
|
+
if (!headers) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
67
|
+
if (key.toLowerCase() !==
|
|
68
|
+
wanted.toLowerCase()) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (Array.isArray(value)) {
|
|
72
|
+
const valid = value
|
|
73
|
+
.map(clean)
|
|
74
|
+
.filter((item) => item !== null);
|
|
75
|
+
return valid.length === 1
|
|
76
|
+
? valid[0]
|
|
77
|
+
: null;
|
|
78
|
+
}
|
|
79
|
+
return clean(value);
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
function bodyObject(body) {
|
|
84
|
+
if (body === null ||
|
|
85
|
+
body === undefined) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (typeof body === "string") {
|
|
89
|
+
try {
|
|
90
|
+
const parsed = JSON.parse(body);
|
|
91
|
+
if (parsed &&
|
|
92
|
+
typeof parsed === "object" &&
|
|
93
|
+
!Array.isArray(parsed)) {
|
|
94
|
+
return parsed;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (typeof body === "object" &&
|
|
103
|
+
!Array.isArray(body)) {
|
|
104
|
+
return body;
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
function candidates(input) {
|
|
109
|
+
const result = [];
|
|
110
|
+
const explicit = clean(input.operationId);
|
|
111
|
+
if (explicit) {
|
|
112
|
+
result.push({
|
|
113
|
+
source: "explicit",
|
|
114
|
+
value: explicit
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const normalHeader = headerValue(input.headers, "idempotency-key");
|
|
118
|
+
if (normalHeader) {
|
|
119
|
+
result.push({
|
|
120
|
+
source: "header:idempotency-key",
|
|
121
|
+
value: normalHeader
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const alternateHeader = headerValue(input.headers, "x-idempotency-key");
|
|
125
|
+
if (alternateHeader) {
|
|
126
|
+
result.push({
|
|
127
|
+
source: "header:x-idempotency-key",
|
|
128
|
+
value: alternateHeader
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const body = bodyObject(input.body);
|
|
132
|
+
if (body) {
|
|
133
|
+
for (const field of BODY_FIELDS) {
|
|
134
|
+
const value = clean(body[field.key]);
|
|
135
|
+
if (value) {
|
|
136
|
+
result.push({
|
|
137
|
+
source: field.source,
|
|
138
|
+
value
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
function buildOperationId(method, url, identity) {
|
|
146
|
+
const hash = createHash("sha256");
|
|
147
|
+
hash.update("once-runtime-http-id-v1\u0000", "utf8");
|
|
148
|
+
for (const value of [method, url, identity]) {
|
|
149
|
+
const bytes = Buffer.from(value, "utf8");
|
|
150
|
+
const length = Buffer.allocUnsafe(4);
|
|
151
|
+
length.writeUInt32BE(bytes.length, 0);
|
|
152
|
+
hash.update(length);
|
|
153
|
+
hash.update(bytes);
|
|
154
|
+
}
|
|
155
|
+
return ("http:" +
|
|
156
|
+
hash
|
|
157
|
+
.digest("hex")
|
|
158
|
+
.slice(0, 32));
|
|
159
|
+
}
|
|
160
|
+
export function resolveHttpOperationIdentity(input) {
|
|
161
|
+
const method = normalizeMethod(input.method);
|
|
162
|
+
const url = normalizeUrl(input.url);
|
|
163
|
+
if (!url) {
|
|
164
|
+
return {
|
|
165
|
+
status: "REQUIRED",
|
|
166
|
+
reason: "A valid HTTP(S) destination is required."
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const found = candidates(input);
|
|
170
|
+
if (found.length === 0) {
|
|
171
|
+
return {
|
|
172
|
+
status: "REQUIRED",
|
|
173
|
+
reason: "No trustworthy stable identity carrier was found. Runtime refuses to guess."
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const values = Array.from(new Set(found.map(item => item.value)));
|
|
177
|
+
if (values.length !== 1) {
|
|
178
|
+
return {
|
|
179
|
+
status: "CONFLICT",
|
|
180
|
+
sources: found.map(item => item.source),
|
|
181
|
+
reason: "Stable identity carriers disagree. Runtime refuses ambiguous identity."
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
status: "FOUND",
|
|
186
|
+
operationId: buildOperationId(method, url, values[0]),
|
|
187
|
+
source: found[0].source,
|
|
188
|
+
reason: "Stable identity found and deterministically bound to this HTTP operation."
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/runtime/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACX,MAAM,aAAa,CAAC;AA8CrB,MAAM,WAAW,GAGZ;IACH;QACE,GAAG,EAAE,mBAAmB;QACxB,MAAM,EAAE,wBAAwB;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AEJ,MAAM,GAAG,GACP,YAAY,CACV,KAAK,CAAC,GAAG,CACV,CAAC;IAEJ,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,MAAM,EACJ,0CAA0C;SAC7C,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GACT,UAAU,CAAC,KAAK,CAAC,CAAC;IAEpB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,MAAM,EACJ,6EAA6E;SAChF,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GACV,KAAK,CAAC,IAAI,CACR,IAAI,GAAG,CACL,KAAK,CAAC,GAAG,CACP,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CACnB,CACF,CACF,CAAC;IAEJ,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EACL,KAAK,CAAC,GAAG,CACP,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CACpB;YACH,MAAM,EACJ,wEAAwE;SAC3E,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,OAAO;QACf,WAAW,EACT,gBAAgB,CACd,MAAM,EACN,GAAG,EACH,MAAM,CAAC,CAAC,CAAC,CACV;QACH,MAAM,EACJ,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM;QACjB,MAAM,EACJ,2EAA2E;KAC9E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type OnceRuntimeDecision, type OnceRuntimeDecisionCode } from "./decision.js";
|
|
2
|
+
import { type RuntimeIdentitySource, type RuntimeIdentityResult } from "./identity.js";
|
|
3
|
+
type RuntimeIdentityStatus = RuntimeIdentityResult["status"];
|
|
4
|
+
export type OnceRuntimePipelineCode = OnceRuntimeDecisionCode | "IDENTITY_REQUIRED" | "IDENTITY_CONFLICT";
|
|
5
|
+
export type OnceRuntimeHttpRequest = {
|
|
6
|
+
method: string;
|
|
7
|
+
url: string;
|
|
8
|
+
provider?: string;
|
|
9
|
+
operationId?: string;
|
|
10
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
11
|
+
body?: unknown;
|
|
12
|
+
};
|
|
13
|
+
export type OnceRuntimePipelineResult = {
|
|
14
|
+
decision: OnceRuntimeDecision;
|
|
15
|
+
code: OnceRuntimePipelineCode;
|
|
16
|
+
consequential: boolean;
|
|
17
|
+
method: string;
|
|
18
|
+
reason: string;
|
|
19
|
+
operationId?: string;
|
|
20
|
+
identitySource?: RuntimeIdentitySource;
|
|
21
|
+
identityStatus: RuntimeIdentityStatus;
|
|
22
|
+
};
|
|
23
|
+
export declare function prepareHttpExecution(request: OnceRuntimeHttpRequest): OnceRuntimePipelineResult;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/runtime/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC7B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAC;AAEvB,KAAK,qBAAqB,GACxB,qBAAqB,CAAC,QAAQ,CAAC,CAAC;AAElC,MAAM,MAAM,uBAAuB,GAC/B,uBAAuB,GACvB,mBAAmB,GACnB,mBAAmB,CAAC;AAExB,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,OAAO,CAAC,EAAE,MAAM,CACd,MAAM,EACN,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAC9B,CAAC;IAEF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,IAAI,EAAE,uBAAuB,CAAC;IAC9B,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAEf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,cAAc,EAAE,qBAAqB,CAAC;CACvC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,sBAAsB,GAC9B,yBAAyB,CA6P3B"}
|