@yanlinglabs/winter-provider-conformance 0.0.5 → 0.0.6
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/fakes/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { errorResponse, jsonResponse, noRequestContains, redirectResponse, requestsTo, scenarioTable, sseResponse, stalledResponse, startFake, withFake, } from "./server.js";
|
|
2
2
|
export type { FakeRoute, FakeServer, RecordedRequest, ScenarioResponder, ScenarioTableOptions, SseFrame, SseResponseOptions, StartFakeOptions } from "./server.js";
|
|
3
|
-
export * as anthropicConsoleOauthFake from "./anthropic-console-oauth.js";
|
|
4
3
|
export * as anthropicFake from "./anthropic-messages.js";
|
|
5
4
|
export * as azureFake from "./azure-openai.js";
|
|
6
5
|
export * as bedrockFake from "./bedrock.js";
|
package/dist/fakes/index.js
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
exports_openai_chat,
|
|
13
13
|
exports_openai_responses,
|
|
14
14
|
exports_azure_openai,
|
|
15
|
-
exports_anthropic_console_oauth,
|
|
16
15
|
OPAQUE_FIELD_NAMES2,
|
|
17
16
|
redactOpaqueFields2,
|
|
18
17
|
exports_anthropic_messages,
|
|
@@ -25,10 +24,9 @@ import {
|
|
|
25
24
|
verifyRs256Jwt2,
|
|
26
25
|
exports_vertex,
|
|
27
26
|
exports_xai_oauth
|
|
28
|
-
} from "../index-
|
|
27
|
+
} from "../index-nrq6zn4s.js";
|
|
29
28
|
export {
|
|
30
29
|
OPAQUE_FIELD_NAMES2 as OPAQUE_FIELD_NAMES,
|
|
31
|
-
exports_anthropic_console_oauth as anthropicConsoleOauthFake,
|
|
32
30
|
exports_anthropic_messages as anthropicFake,
|
|
33
31
|
exports_azure_openai as azureFake,
|
|
34
32
|
base64UrlDecodeBytes2 as base64UrlDecodeBytes,
|
|
@@ -157,112 +157,6 @@ function requestsTo2(fake, path) {
|
|
|
157
157
|
function noRequestContains2(fake, needle) {
|
|
158
158
|
return !fake.requests.some((r) => r.body.includes(needle) || Object.values(r.headers).some((v) => v.includes(needle)));
|
|
159
159
|
}
|
|
160
|
-
// src/fakes/anthropic-console-oauth.ts
|
|
161
|
-
var exports_anthropic_console_oauth = {};
|
|
162
|
-
__export(exports_anthropic_console_oauth, {
|
|
163
|
-
FAKE_CONSOLE_ACCESS_TOKEN: () => FAKE_CONSOLE_ACCESS_TOKEN,
|
|
164
|
-
FAKE_CONSOLE_ACCOUNT_ID: () => FAKE_CONSOLE_ACCOUNT_ID,
|
|
165
|
-
FAKE_CONSOLE_REFRESHED_ACCESS_TOKEN: () => FAKE_CONSOLE_REFRESHED_ACCESS_TOKEN,
|
|
166
|
-
FAKE_CONSOLE_REFRESH_TOKEN: () => FAKE_CONSOLE_REFRESH_TOKEN,
|
|
167
|
-
startAnthropicConsoleOauthFake: () => startAnthropicConsoleOauthFake
|
|
168
|
-
});
|
|
169
|
-
var FAKE_CONSOLE_ACCOUNT_ID = "acct-test-console-0001";
|
|
170
|
-
var FAKE_CONSOLE_ACCESS_TOKEN = "test-token-anthropic-console-access";
|
|
171
|
-
var FAKE_CONSOLE_REFRESHED_ACCESS_TOKEN = "test-token-anthropic-console-access-refreshed";
|
|
172
|
-
var FAKE_CONSOLE_REFRESH_TOKEN = "test-token-anthropic-console-refresh";
|
|
173
|
-
function base64Url(bytes) {
|
|
174
|
-
let binary = "";
|
|
175
|
-
for (const byte of bytes)
|
|
176
|
-
binary += String.fromCharCode(byte);
|
|
177
|
-
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
178
|
-
}
|
|
179
|
-
async function startAnthropicConsoleOauthFake(opts = {}) {
|
|
180
|
-
const tokenRequests = [];
|
|
181
|
-
const profileRequests = [];
|
|
182
|
-
const accountId = opts.accountId ?? FAKE_CONSOLE_ACCOUNT_ID;
|
|
183
|
-
const challenges = new Set;
|
|
184
|
-
const fake = await startFake2({
|
|
185
|
-
routes: [
|
|
186
|
-
{
|
|
187
|
-
path: "/v1/oauth/token",
|
|
188
|
-
method: "POST",
|
|
189
|
-
handler: async (_req, recorded) => {
|
|
190
|
-
tokenRequests.push(recorded);
|
|
191
|
-
if (opts.failTokenWith !== undefined) {
|
|
192
|
-
return jsonResponse2({ error: "invalid_grant", error_description: "the fake refused this grant" }, opts.failTokenWith);
|
|
193
|
-
}
|
|
194
|
-
const contentType = (recorded.headers["content-type"] ?? "").split(";")[0].trim();
|
|
195
|
-
if (contentType !== "application/json") {
|
|
196
|
-
return jsonResponse2({ error: "invalid_request", error_description: `this endpoint accepts application/json only, not ${JSON.stringify(contentType)}` }, 400);
|
|
197
|
-
}
|
|
198
|
-
let body;
|
|
199
|
-
try {
|
|
200
|
-
const parsed = JSON.parse(recorded.body);
|
|
201
|
-
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
202
|
-
throw new Error("not an object");
|
|
203
|
-
body = parsed;
|
|
204
|
-
} catch {
|
|
205
|
-
return jsonResponse2({ error: "invalid_request", error_description: "the grant body is not a JSON object" }, 400);
|
|
206
|
-
}
|
|
207
|
-
const grant = body["grant_type"];
|
|
208
|
-
if (grant === "authorization_code") {
|
|
209
|
-
if (typeof body["state"] !== "string" || body["state"].length === 0) {
|
|
210
|
-
return jsonResponse2({ error: "invalid_request", error_description: "the authorization_code grant carried no state" }, 400);
|
|
211
|
-
}
|
|
212
|
-
const verifier = typeof body["code_verifier"] === "string" ? body["code_verifier"] : "";
|
|
213
|
-
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier));
|
|
214
|
-
if (!challenges.has(base64Url(new Uint8Array(digest)))) {
|
|
215
|
-
return jsonResponse2({ error: "invalid_grant", error_description: "PKCE verifier does not match any challenge this fake saw" }, 400);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return jsonResponse2({
|
|
219
|
-
access_token: grant === "refresh_token" ? FAKE_CONSOLE_REFRESHED_ACCESS_TOKEN : FAKE_CONSOLE_ACCESS_TOKEN,
|
|
220
|
-
...opts.omitRefreshToken === true ? {} : { refresh_token: FAKE_CONSOLE_REFRESH_TOKEN },
|
|
221
|
-
expires_in: opts.expiresIn ?? 3600,
|
|
222
|
-
scope: "user:inference user:profile",
|
|
223
|
-
token_type: "Bearer"
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
path: "/api/oauth/profile",
|
|
229
|
-
method: "GET",
|
|
230
|
-
handler: (req, recorded) => {
|
|
231
|
-
profileRequests.push(recorded);
|
|
232
|
-
if ((req.headers.get("authorization") ?? "") === "")
|
|
233
|
-
return jsonResponse2({ error: "unauthorized" }, 401);
|
|
234
|
-
return jsonResponse2({
|
|
235
|
-
...opts.omitAccount === true ? {} : { account: { uuid: accountId, email: "person@example.test" } },
|
|
236
|
-
organization: { uuid: "org-test-console-0001" }
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
]
|
|
241
|
-
});
|
|
242
|
-
return Object.assign(fake, {
|
|
243
|
-
authorizeUrl: `${fake.url}/oauth/authorize`,
|
|
244
|
-
tokenUrl: `${fake.url}/v1/oauth/token`,
|
|
245
|
-
profileUrl: `${fake.url}/api/oauth/profile`,
|
|
246
|
-
tokenRequests,
|
|
247
|
-
profileRequests,
|
|
248
|
-
async completeAuthorization(url, overrides = {}) {
|
|
249
|
-
const authorize = new URL(url);
|
|
250
|
-
const challenge = authorize.searchParams.get("code_challenge");
|
|
251
|
-
if (challenge !== null)
|
|
252
|
-
challenges.add(challenge);
|
|
253
|
-
const redirectUri = authorize.searchParams.get("redirect_uri");
|
|
254
|
-
if (redirectUri === null)
|
|
255
|
-
throw new Error("the authorize URL carried no redirect_uri");
|
|
256
|
-
const callback = new URL(redirectUri);
|
|
257
|
-
callback.searchParams.set("state", overrides.state ?? authorize.searchParams.get("state") ?? "");
|
|
258
|
-
if (overrides.code !== null)
|
|
259
|
-
callback.searchParams.set("code", overrides.code ?? "test-code-anthropic-console");
|
|
260
|
-
await fetch(callback.toString()).catch(() => {
|
|
261
|
-
return;
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
160
|
// src/fakes/anthropic-messages.ts
|
|
267
161
|
var exports_anthropic_messages = {};
|
|
268
162
|
__export(exports_anthropic_messages, {
|
|
@@ -1861,7 +1755,7 @@ async function boundedFetch(url, init) {
|
|
|
1861
1755
|
// ../provider-runtime/package.json
|
|
1862
1756
|
var package_default = {
|
|
1863
1757
|
name: "@yanlinglabs/winter-provider-runtime",
|
|
1864
|
-
version: "0.0.
|
|
1758
|
+
version: "0.0.6",
|
|
1865
1759
|
license: "MIT",
|
|
1866
1760
|
type: "module",
|
|
1867
1761
|
engines: {
|
|
@@ -4374,4 +4268,4 @@ var exports_xai_oauth = {};
|
|
|
4374
4268
|
__export(exports_xai_oauth, {
|
|
4375
4269
|
startXaiOauthFake: () => startXaiOauthFake
|
|
4376
4270
|
});
|
|
4377
|
-
export { __export, ProviderRequestError, WINTER_BRAND, createRegistry, AZURE_PREVIEW_API_VERSION, createAzureOpenAIAdapter, sameDomain, summaryRequestOf, shouldRequestSummary, createEndpointResolver, descriptor, testContext, testDiscoveryContext, FAST_RETRY, fixtureModel, fixtureReasoning, fixtureProvider, fixtureCatalog, scriptedAdapter, startFake2, withFake2, sseResponse2, jsonResponse2, errorResponse2, redirectResponse2, stalledResponse2, scenarioTable2, requestsTo2, noRequestContains2, exports_openai_chat, exports_openai_responses, deploymentOf, apiVersionOf, exports_azure_openai,
|
|
4271
|
+
export { __export, ProviderRequestError, WINTER_BRAND, createRegistry, AZURE_PREVIEW_API_VERSION, createAzureOpenAIAdapter, sameDomain, summaryRequestOf, shouldRequestSummary, createEndpointResolver, descriptor, testContext, testDiscoveryContext, FAST_RETRY, fixtureModel, fixtureReasoning, fixtureProvider, fixtureCatalog, scriptedAdapter, startFake2, withFake2, sseResponse2, jsonResponse2, errorResponse2, redirectResponse2, stalledResponse2, scenarioTable2, requestsTo2, noRequestContains2, exports_openai_chat, exports_openai_responses, deploymentOf, apiVersionOf, exports_azure_openai, OPAQUE_FIELD_NAMES2, redactOpaqueFields2, exports_anthropic_messages, exports_bedrock, exports_codex_oauth, exports_gemini, exports_openai_models, base64UrlDecodeText2, base64UrlDecodeBytes2, verifyRs256Jwt2, exports_vertex, exports_xai_oauth };
|
package/dist/index.js
CHANGED
|
@@ -33,7 +33,6 @@ import {
|
|
|
33
33
|
deploymentOf,
|
|
34
34
|
apiVersionOf,
|
|
35
35
|
exports_azure_openai,
|
|
36
|
-
exports_anthropic_console_oauth,
|
|
37
36
|
OPAQUE_FIELD_NAMES2,
|
|
38
37
|
redactOpaqueFields2,
|
|
39
38
|
exports_anthropic_messages,
|
|
@@ -46,7 +45,7 @@ import {
|
|
|
46
45
|
verifyRs256Jwt2,
|
|
47
46
|
exports_vertex,
|
|
48
47
|
exports_xai_oauth
|
|
49
|
-
} from "./index-
|
|
48
|
+
} from "./index-nrq6zn4s.js";
|
|
50
49
|
|
|
51
50
|
// src/corpus/classifier-safety.ts
|
|
52
51
|
var CLASSIFIER_SAFETY_CATEGORIES = [
|
|
@@ -409,6 +408,8 @@ var inFlightRefreshes = new Map;
|
|
|
409
408
|
var DEFAULT_TIMEOUT_MS = 15 * 60000;
|
|
410
409
|
// ../provider-runtime/src/adapters/anthropic/messages.ts
|
|
411
410
|
var DEFAULT_MAX_BODY_BYTES = 32 * 1024 * 1024;
|
|
411
|
+
// ../provider-runtime/src/adapters/anthropic/console-broker.ts
|
|
412
|
+
var MAX_PROFILE_FILE_BYTES = 64 * 1024;
|
|
412
413
|
// ../provider-runtime/src/discovery.ts
|
|
413
414
|
var MAX_MODEL_ID_CHARS = 256;
|
|
414
415
|
var MAX_DISPLAY_NAME_CHARS = 512;
|
|
@@ -1625,7 +1626,6 @@ export {
|
|
|
1625
1626
|
OPAQUE_FIELD_NAMES2 as OPAQUE_FIELD_NAMES,
|
|
1626
1627
|
OPAQUE_MARKERS,
|
|
1627
1628
|
PROVIDER_CONFORMANCE_PACKAGE,
|
|
1628
|
-
exports_anthropic_console_oauth as anthropicConsoleOauthFake,
|
|
1629
1629
|
exports_anthropic_messages as anthropicFake,
|
|
1630
1630
|
exports_azure as azureCorpus,
|
|
1631
1631
|
exports_azure_openai as azureFake,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanlinglabs/winter-provider-conformance",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@yanlinglabs/winter-provider-catalog": "0.0.
|
|
47
|
-
"@yanlinglabs/winter-provider-runtime": "0.0.
|
|
46
|
+
"@yanlinglabs/winter-provider-catalog": "0.0.6",
|
|
47
|
+
"@yanlinglabs/winter-provider-runtime": "0.0.6"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {}
|
|
50
50
|
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type FakeServer, type RecordedRequest } from "./server.js";
|
|
2
|
-
export declare const FAKE_CONSOLE_ACCOUNT_ID = "acct-test-console-0001";
|
|
3
|
-
export declare const FAKE_CONSOLE_ACCESS_TOKEN = "test-token-anthropic-console-access";
|
|
4
|
-
export declare const FAKE_CONSOLE_REFRESHED_ACCESS_TOKEN = "test-token-anthropic-console-access-refreshed";
|
|
5
|
-
export declare const FAKE_CONSOLE_REFRESH_TOKEN = "test-token-anthropic-console-refresh";
|
|
6
|
-
export interface AnthropicConsoleOauthFakeOptions {
|
|
7
|
-
/** Answer every grant with this status instead of 200. */
|
|
8
|
-
failTokenWith?: number;
|
|
9
|
-
/** The profile answers 200 with no account — the shape that must REFUSE the login, not name a record `anthropic:undefined`. */
|
|
10
|
-
omitAccount?: boolean;
|
|
11
|
-
/** A refresh grant that does not rotate the refresh token, which is the common case. */
|
|
12
|
-
omitRefreshToken?: boolean;
|
|
13
|
-
accountId?: string;
|
|
14
|
-
expiresIn?: number;
|
|
15
|
-
}
|
|
16
|
-
export interface AnthropicConsoleOauthFake extends FakeServer {
|
|
17
|
-
/** Handed to the login as its authorize endpoint. Never fetched — the browser half is `completeAuthorization`. */
|
|
18
|
-
authorizeUrl: string;
|
|
19
|
-
tokenUrl: string;
|
|
20
|
-
profileUrl: string;
|
|
21
|
-
/** The grants the token endpoint actually received, in order. Headers are redacted by the base fake. */
|
|
22
|
-
tokenRequests: RecordedRequest[];
|
|
23
|
-
profileRequests: RecordedRequest[];
|
|
24
|
-
/**
|
|
25
|
-
* The browser half: reads the authorize URL the flow produced, records its PKCE challenge, and
|
|
26
|
-
* calls the flow's own loopback callback.
|
|
27
|
-
*
|
|
28
|
-
* `state` overrides the value the flow minted (a planted-callback fixture); `code: null` omits the
|
|
29
|
-
* authorization code entirely.
|
|
30
|
-
*/
|
|
31
|
-
completeAuthorization(url: string, overrides?: {
|
|
32
|
-
state?: string;
|
|
33
|
-
code?: string | null;
|
|
34
|
-
}): Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
export declare function startAnthropicConsoleOauthFake(opts?: AnthropicConsoleOauthFakeOptions): Promise<AnthropicConsoleOauthFake>;
|