@kya-os/create-mcpi-app 1.10.3 → 1.10.4
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/.turbo/turbo-build.log +11 -11
- package/dist/bundles/blank.js +318 -17
- package/dist/bundles/ecommerce.js +318 -17
- package/dist/bundles/hardware-world.js +318 -17
- package/dist/bundles/manifest.json +11 -11
- package/dist/bundles/mix-station.js +318 -17
- package/dist/helpers/get-package-versions.js +2 -2
- package/package.json +4 -4
|
@@ -45834,6 +45834,18 @@ var require_oauth_config_service = __commonJS({
|
|
|
45834
45834
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45835
45835
|
exports.OAuthConfigService = void 0;
|
|
45836
45836
|
var oauth_config_cache_js_1 = require_oauth_config_cache();
|
|
45837
|
+
function mapProviderSecretMetadata(raw2) {
|
|
45838
|
+
if (!raw2 || typeof raw2 !== "object")
|
|
45839
|
+
return void 0;
|
|
45840
|
+
const m3 = raw2;
|
|
45841
|
+
const metadata = {
|
|
45842
|
+
clientSecretName: m3.clientSecretName ?? m3.client_secret_name,
|
|
45843
|
+
clientIdSecretName: m3.clientIdSecretName ?? m3.client_id_secret_name,
|
|
45844
|
+
apiKeySecretName: m3.apiKeySecretName ?? m3.api_key_secret_name,
|
|
45845
|
+
clientSecretVersion: m3.clientSecretVersion ?? m3.client_secret_version
|
|
45846
|
+
};
|
|
45847
|
+
return metadata;
|
|
45848
|
+
}
|
|
45837
45849
|
var OAuthConfigService2 = class {
|
|
45838
45850
|
config;
|
|
45839
45851
|
constructor(config4) {
|
|
@@ -45907,7 +45919,16 @@ var require_oauth_config_service = __commonJS({
|
|
|
45907
45919
|
customParams: p3.customParams ?? p3.custom_params,
|
|
45908
45920
|
tokenEndpointAuthMethod: p3.tokenEndpointAuthMethod ?? p3.token_endpoint_auth_method,
|
|
45909
45921
|
responseType: p3.responseType ?? p3.response_type,
|
|
45910
|
-
grantType: p3.grantType ?? p3.grant_type
|
|
45922
|
+
grantType: p3.grantType ?? p3.grant_type,
|
|
45923
|
+
// Provider-registry secret metadata (clientSecretName etc.). REQUIRED:
|
|
45924
|
+
// OAuthService.resolveClientSecret resolves a confidential provider's
|
|
45925
|
+
// client secret from secure storage via `metadata.clientSecretName`
|
|
45926
|
+
// (the AgentShield /providers response intentionally omits the plaintext
|
|
45927
|
+
// `clientSecret`). Without mapping this field here, `metadata` is
|
|
45928
|
+
// undefined, resolveClientSecret falls back to the (absent) inline
|
|
45929
|
+
// clientSecret, and the worker sends an empty secret — token exchange
|
|
45930
|
+
// then fails with "client_id and/or client_secret incorrect".
|
|
45931
|
+
metadata: mapProviderSecretMetadata(p3.metadata)
|
|
45911
45932
|
};
|
|
45912
45933
|
}
|
|
45913
45934
|
const configuredProvider = result.data.configuredProvider ?? result.data.configured_provider ?? null;
|
|
@@ -141691,7 +141712,7 @@ async function handlePickupInternal(ctx, request, now2) {
|
|
|
141691
141712
|
// ../mcp-i-cloudflare/package.json
|
|
141692
141713
|
var package_default = {
|
|
141693
141714
|
name: "@kya-os/mcp-i-cloudflare",
|
|
141694
|
-
version: "1.12.
|
|
141715
|
+
version: "1.12.2",
|
|
141695
141716
|
description: "Cloudflare Workers adapter for MCP-I framework",
|
|
141696
141717
|
main: "dist/index.js",
|
|
141697
141718
|
types: "dist/index.d.ts",
|
|
@@ -141720,9 +141741,9 @@ var package_default = {
|
|
|
141720
141741
|
},
|
|
141721
141742
|
dependencies: {
|
|
141722
141743
|
"@kya-os/consent": "^0.1.41",
|
|
141723
|
-
"@kya-os/contracts": "^1.9.
|
|
141744
|
+
"@kya-os/contracts": "^1.9.1",
|
|
141724
141745
|
"@kya-os/mcp": "^1.10.1",
|
|
141725
|
-
"@kya-os/mcp-i-core": "^1.8.
|
|
141746
|
+
"@kya-os/mcp-i-core": "^1.8.2",
|
|
141726
141747
|
"@kya-os/mcp-i-runtime": "^1.0.0",
|
|
141727
141748
|
"@kya-os/provider-registry": "^0.1.7",
|
|
141728
141749
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
@@ -147427,6 +147448,190 @@ async function handlePickupGet(c, env2, cfg) {
|
|
|
147427
147448
|
init_dist2();
|
|
147428
147449
|
init_crypto();
|
|
147429
147450
|
init_storage();
|
|
147451
|
+
|
|
147452
|
+
// ../mcp-i-cloudflare/dist/delegation-http/credential-consent.js
|
|
147453
|
+
function readString(entry, camel, snake) {
|
|
147454
|
+
const value = entry[camel] ?? entry[snake];
|
|
147455
|
+
return typeof value === "string" ? value : void 0;
|
|
147456
|
+
}
|
|
147457
|
+
function readRecord(entry, camel, snake) {
|
|
147458
|
+
const value = entry[camel] ?? entry[snake];
|
|
147459
|
+
return value && typeof value === "object" ? value : void 0;
|
|
147460
|
+
}
|
|
147461
|
+
function isCredentialTyped(entry) {
|
|
147462
|
+
return !!entry && (entry.type === "password" || entry.type === "credential") && entry.configured !== false;
|
|
147463
|
+
}
|
|
147464
|
+
function buildSuccessCheck(raw2) {
|
|
147465
|
+
if (!raw2)
|
|
147466
|
+
return void 0;
|
|
147467
|
+
const path = typeof raw2.path === "string" ? raw2.path : void 0;
|
|
147468
|
+
const expectedValue = raw2.expectedValue ?? raw2.expected_value;
|
|
147469
|
+
if (!path || expectedValue === void 0)
|
|
147470
|
+
return void 0;
|
|
147471
|
+
if (typeof expectedValue !== "string" && typeof expectedValue !== "boolean" && typeof expectedValue !== "number") {
|
|
147472
|
+
return void 0;
|
|
147473
|
+
}
|
|
147474
|
+
return { path, expectedValue };
|
|
147475
|
+
}
|
|
147476
|
+
function buildCredentialConfig(entry) {
|
|
147477
|
+
const authEndpoint = readString(entry, "authEndpoint", "auth_endpoint");
|
|
147478
|
+
const requestBodyTemplate = readRecord(entry, "requestBodyTemplate", "request_body_template");
|
|
147479
|
+
const rawResponseFields = readRecord(entry, "responseFields", "response_fields");
|
|
147480
|
+
if (!authEndpoint || !requestBodyTemplate || !rawResponseFields)
|
|
147481
|
+
return null;
|
|
147482
|
+
const sessionToken = readString(rawResponseFields, "sessionToken", "session_token");
|
|
147483
|
+
if (!sessionToken)
|
|
147484
|
+
return null;
|
|
147485
|
+
const responseFields = {
|
|
147486
|
+
sessionToken,
|
|
147487
|
+
userId: readString(rawResponseFields, "userId", "user_id"),
|
|
147488
|
+
userEmail: readString(rawResponseFields, "userEmail", "user_email"),
|
|
147489
|
+
userDisplayName: readString(rawResponseFields, "userDisplayName", "user_display_name"),
|
|
147490
|
+
expiresIn: readString(rawResponseFields, "expiresIn", "expires_in")
|
|
147491
|
+
};
|
|
147492
|
+
const successCheck = buildSuccessCheck(readRecord(entry, "successCheck", "success_check"));
|
|
147493
|
+
const headers = readRecord(entry, "headers", "headers");
|
|
147494
|
+
const tokenUsage = readString(entry, "tokenUsage", "token_usage");
|
|
147495
|
+
const tokenHeader = readString(entry, "tokenHeader", "token_header");
|
|
147496
|
+
const cookieFormat = readString(entry, "cookieFormat", "cookie_format");
|
|
147497
|
+
return {
|
|
147498
|
+
// The handler ignores `type`, but the contract's discriminant is "credential".
|
|
147499
|
+
type: "credential",
|
|
147500
|
+
displayName: readString(entry, "displayName", "display_name"),
|
|
147501
|
+
authEndpoint,
|
|
147502
|
+
requestBodyTemplate,
|
|
147503
|
+
responseFields,
|
|
147504
|
+
...successCheck ? { successCheck } : {},
|
|
147505
|
+
...headers ? { headers } : {},
|
|
147506
|
+
...tokenUsage ? { tokenUsage } : {},
|
|
147507
|
+
...tokenHeader ? { tokenHeader } : {},
|
|
147508
|
+
...cookieFormat ? { cookieFormat } : {}
|
|
147509
|
+
};
|
|
147510
|
+
}
|
|
147511
|
+
async function resolveAnchorCredentialProvider(env2, _scopes) {
|
|
147512
|
+
const apiKey = env2.AGENTSHIELD_API_KEY;
|
|
147513
|
+
const projectId = env2.AGENTSHIELD_PROJECT_ID;
|
|
147514
|
+
if (!apiKey || !projectId)
|
|
147515
|
+
return { status: "none" };
|
|
147516
|
+
const agentShieldUrl = env2.AGENTSHIELD_API_URL || DEFAULT_AGENTSHIELD_URL;
|
|
147517
|
+
let providersMap;
|
|
147518
|
+
let configuredProvider;
|
|
147519
|
+
try {
|
|
147520
|
+
const response = await fetch(`${agentShieldUrl}/api/v1/bouncer/projects/${encodeURIComponent(projectId)}/providers`, {
|
|
147521
|
+
method: "GET",
|
|
147522
|
+
headers: {
|
|
147523
|
+
Authorization: `Bearer ${apiKey}`,
|
|
147524
|
+
"Content-Type": "application/json"
|
|
147525
|
+
}
|
|
147526
|
+
});
|
|
147527
|
+
if (!response.ok)
|
|
147528
|
+
return { status: "unavailable" };
|
|
147529
|
+
const body = await response.json();
|
|
147530
|
+
if (body.success !== true || !body.data || typeof body.data.providers !== "object" || body.data.providers === null) {
|
|
147531
|
+
return { status: "unavailable" };
|
|
147532
|
+
}
|
|
147533
|
+
providersMap = body.data.providers;
|
|
147534
|
+
configuredProvider = body.data.configuredProvider ?? body.data.configured_provider ?? null;
|
|
147535
|
+
} catch {
|
|
147536
|
+
return { status: "unavailable" };
|
|
147537
|
+
}
|
|
147538
|
+
const credentialIds = Object.keys(providersMap).filter((id) => isCredentialTyped(providersMap[id]));
|
|
147539
|
+
if (credentialIds.length === 0)
|
|
147540
|
+
return { status: "none" };
|
|
147541
|
+
const chosenId = configuredProvider && isCredentialTyped(providersMap[configuredProvider]) ? configuredProvider : credentialIds.length === 1 ? credentialIds[0] : null;
|
|
147542
|
+
if (!chosenId)
|
|
147543
|
+
return { status: "unavailable" };
|
|
147544
|
+
const config4 = buildCredentialConfig(providersMap[chosenId]);
|
|
147545
|
+
if (!config4)
|
|
147546
|
+
return { status: "unavailable" };
|
|
147547
|
+
return {
|
|
147548
|
+
status: "credential",
|
|
147549
|
+
provider: {
|
|
147550
|
+
providerId: chosenId,
|
|
147551
|
+
displayName: config4.displayName || chosenId,
|
|
147552
|
+
config: config4
|
|
147553
|
+
}
|
|
147554
|
+
};
|
|
147555
|
+
}
|
|
147556
|
+
async function resolveCredentialIdentity(env2, params) {
|
|
147557
|
+
const agentShieldUrl = env2.AGENTSHIELD_API_URL || DEFAULT_AGENTSHIELD_URL;
|
|
147558
|
+
const apiKey = env2.AGENTSHIELD_API_KEY;
|
|
147559
|
+
if (!apiKey)
|
|
147560
|
+
return { success: false };
|
|
147561
|
+
try {
|
|
147562
|
+
const response = await fetch(`${agentShieldUrl}/api/v1/bouncer/identity/resolve`, {
|
|
147563
|
+
method: "POST",
|
|
147564
|
+
headers: {
|
|
147565
|
+
"X-API-Key": apiKey,
|
|
147566
|
+
"Content-Type": "application/json"
|
|
147567
|
+
},
|
|
147568
|
+
body: JSON.stringify({
|
|
147569
|
+
project_id: params.projectId,
|
|
147570
|
+
credential_result: {
|
|
147571
|
+
provider: params.provider,
|
|
147572
|
+
user_id: params.userId,
|
|
147573
|
+
email: params.userEmail,
|
|
147574
|
+
name: params.userDisplayName
|
|
147575
|
+
}
|
|
147576
|
+
})
|
|
147577
|
+
});
|
|
147578
|
+
if (!response.ok)
|
|
147579
|
+
return { success: false };
|
|
147580
|
+
const data = await response.json();
|
|
147581
|
+
const userDid = data?.data?.user_did;
|
|
147582
|
+
return userDid ? { success: true, userDid } : { success: false };
|
|
147583
|
+
} catch {
|
|
147584
|
+
return { success: false };
|
|
147585
|
+
}
|
|
147586
|
+
}
|
|
147587
|
+
function sidToDelegationUuid(sid) {
|
|
147588
|
+
const h5 = sha256Hex(sid).slice(0, 32).split("");
|
|
147589
|
+
h5[12] = "4";
|
|
147590
|
+
h5[16] = (parseInt(h5[16], 16) & 3 | 8).toString(16);
|
|
147591
|
+
const s5 = h5.join("");
|
|
147592
|
+
return `${s5.slice(0, 8)}-${s5.slice(8, 12)}-${s5.slice(12, 16)}-${s5.slice(16, 20)}-${s5.slice(20, 32)}`;
|
|
147593
|
+
}
|
|
147594
|
+
async function notifyDelegation(env2, params) {
|
|
147595
|
+
const apiKey = env2.AGENTSHIELD_API_KEY;
|
|
147596
|
+
const projectId = env2.AGENTSHIELD_PROJECT_ID;
|
|
147597
|
+
if (!apiKey || !projectId)
|
|
147598
|
+
return;
|
|
147599
|
+
const agentShieldUrl = env2.AGENTSHIELD_API_URL || DEFAULT_AGENTSHIELD_URL;
|
|
147600
|
+
try {
|
|
147601
|
+
const response = await fetch(`${agentShieldUrl}/api/v1/bouncer/delegations/notify`, {
|
|
147602
|
+
method: "POST",
|
|
147603
|
+
headers: {
|
|
147604
|
+
"X-API-Key": apiKey,
|
|
147605
|
+
"Content-Type": "application/json"
|
|
147606
|
+
},
|
|
147607
|
+
body: JSON.stringify({
|
|
147608
|
+
delegation_id: sidToDelegationUuid(params.sid),
|
|
147609
|
+
agent_did: params.agentDid,
|
|
147610
|
+
agent_name: params.agentName || void 0,
|
|
147611
|
+
user_did: params.userDid,
|
|
147612
|
+
user_id: params.userId || void 0,
|
|
147613
|
+
user_identifier: params.userIdentifier || void 0,
|
|
147614
|
+
scopes: params.scopes,
|
|
147615
|
+
provider: params.provider,
|
|
147616
|
+
project_id: projectId,
|
|
147617
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
147618
|
+
expires_at: params.expiresAt || void 0,
|
|
147619
|
+
metadata: {
|
|
147620
|
+
source: "mcp-i-anchor-consent",
|
|
147621
|
+
sid: params.sid,
|
|
147622
|
+
...params.metadata
|
|
147623
|
+
}
|
|
147624
|
+
})
|
|
147625
|
+
});
|
|
147626
|
+
if (!response.ok) {
|
|
147627
|
+
console.warn(`[kya-http] delegation notify failed (non-blocking): ${response.status} sid=${params.sid}`);
|
|
147628
|
+
}
|
|
147629
|
+
} catch (error87) {
|
|
147630
|
+
console.warn(`[kya-http] delegation notify failed (non-blocking): ${error87 instanceof Error ? error87.message : String(error87)} sid=${params.sid}`);
|
|
147631
|
+
}
|
|
147632
|
+
}
|
|
147633
|
+
|
|
147634
|
+
// ../mcp-i-cloudflare/dist/delegation-http/consent-anchor-bridge.js
|
|
147430
147635
|
var DO_INTERNAL_ORIGIN2 = "https://do.internal";
|
|
147431
147636
|
async function callAnchor2(env2, sid, internalPath, body) {
|
|
147432
147637
|
const stub = getAnchorStub(env2, sid);
|
|
@@ -147496,6 +147701,36 @@ function approveFormPage(sid, info, csrfToken) {
|
|
|
147496
147701
|
</form>
|
|
147497
147702
|
</main>`);
|
|
147498
147703
|
}
|
|
147704
|
+
function credentialFieldNames(provider) {
|
|
147705
|
+
const names = [];
|
|
147706
|
+
for (const template of Object.values(provider.config.requestBodyTemplate)) {
|
|
147707
|
+
const match2 = /\{\{(\w+)\}\}/.exec(template);
|
|
147708
|
+
if (match2 && !names.includes(match2[1]))
|
|
147709
|
+
names.push(match2[1]);
|
|
147710
|
+
}
|
|
147711
|
+
return names.length > 0 ? names : ["email", "password"];
|
|
147712
|
+
}
|
|
147713
|
+
function credentialFormPage(sid, info, provider, csrfToken) {
|
|
147714
|
+
const scopeItems = info.requiredScopes.length > 0 ? info.requiredScopes.map((s5) => `<li class="kya-scope-item">${escapeHtml2(s5)}</li>`).join("") : `<li class="kya-scope-item">No specific permissions required.</li>`;
|
|
147715
|
+
const fieldInputs = credentialFieldNames(provider).map((name16) => {
|
|
147716
|
+
const isSecret = /pass|secret|token|pin/i.test(name16);
|
|
147717
|
+
const label = name16.charAt(0).toUpperCase() + name16.slice(1);
|
|
147718
|
+
return `<label class="kya-field-label" for="kya-field-${escapeHtml2(name16)}">${escapeHtml2(label)}</label>
|
|
147719
|
+
<input class="kya-field-input" id="kya-field-${escapeHtml2(name16)}" name="${escapeHtml2(name16)}" type="${isSecret ? "password" : "text"}" autocomplete="${isSecret ? "current-password" : "username"}" required>`;
|
|
147720
|
+
}).join("");
|
|
147721
|
+
return page("Permission Request", `<main class="kya-consent">
|
|
147722
|
+
<h1>Sign in to authorize</h1>
|
|
147723
|
+
<p class="kya-provider-name">${escapeHtml2(provider.displayName)}</p>
|
|
147724
|
+
<p class="kya-permissions-header">This request needs the following permissions:</p>
|
|
147725
|
+
<ul class="kya-permissions-list">${scopeItems}</ul>
|
|
147726
|
+
<form method="POST" action="/consent/approve?sid=${encodeURIComponent(sid)}">
|
|
147727
|
+
<input type="hidden" name="sid" value="${escapeHtml2(sid)}">
|
|
147728
|
+
<input type="hidden" name="csrf_token" value="${escapeHtml2(csrfToken)}">
|
|
147729
|
+
${fieldInputs}
|
|
147730
|
+
<button type="submit" class="kya-consent-allow">Sign in & allow</button>
|
|
147731
|
+
</form>
|
|
147732
|
+
</main>`);
|
|
147733
|
+
}
|
|
147499
147734
|
function base64UrlEncodeBytes(bytes) {
|
|
147500
147735
|
return btoa(String.fromCharCode(...bytes)).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
147501
147736
|
}
|
|
@@ -147619,7 +147854,10 @@ async function mintDelegationVcJwt(env2, sid, info, expiresInS) {
|
|
|
147619
147854
|
const signingInput = withCrossResourceClaims(unsigned, info, sid);
|
|
147620
147855
|
const signatureBytes = await cryptoProvider.sign(new TextEncoder().encode(signingInput), signingPrivateKey);
|
|
147621
147856
|
const signature = base64urlEncodeFromBytes2(signatureBytes);
|
|
147622
|
-
return
|
|
147857
|
+
return {
|
|
147858
|
+
vcJwt: completeVCJWT2(signingInput, signature),
|
|
147859
|
+
subjectDid: agentDid
|
|
147860
|
+
};
|
|
147623
147861
|
}
|
|
147624
147862
|
async function handleAnchorConsentGet(c, sid, env2, _cfg) {
|
|
147625
147863
|
const infoResponse = await callAnchor2(env2, sid, INTERNAL_PICKUP_INFO, {
|
|
@@ -147634,12 +147872,16 @@ async function handleAnchorConsentGet(c, sid, env2, _cfg) {
|
|
|
147634
147872
|
}
|
|
147635
147873
|
const info = await infoResponse.json();
|
|
147636
147874
|
const csrfToken = await mintCsrfToken(env2, sid);
|
|
147875
|
+
const resolution = await resolveAnchorCredentialProvider(env2, info.requiredScopes);
|
|
147876
|
+
if (resolution.status === "credential") {
|
|
147877
|
+
return htmlResponse(credentialFormPage(sid, info, resolution.provider, csrfToken), 200);
|
|
147878
|
+
}
|
|
147637
147879
|
return htmlResponse(approveFormPage(sid, info, csrfToken), 200);
|
|
147638
147880
|
}
|
|
147639
147881
|
async function handleAnchorConsentApprove(c, sid, env2, cfg) {
|
|
147882
|
+
const bodyFields = await readBodyFields(c);
|
|
147640
147883
|
if (!isTestConsentMode(env2)) {
|
|
147641
|
-
const
|
|
147642
|
-
const valid = await validateCsrfToken(env2, sid, csrfToken);
|
|
147884
|
+
const valid = await validateCsrfToken(env2, sid, bodyFields.csrf_token);
|
|
147643
147885
|
if (!valid) {
|
|
147644
147886
|
return htmlResponse(page("Authorization failed", `<main class="kya-consent-failed"><h1>Authorization failed</h1><p>Invalid or missing security token. Please reload and try again.</p></main>`), 403);
|
|
147645
147887
|
}
|
|
@@ -147656,9 +147898,46 @@ async function handleAnchorConsentApprove(c, sid, env2, cfg) {
|
|
|
147656
147898
|
return approvalFailedPage("This authorization request could not be loaded. Please start over.", 502);
|
|
147657
147899
|
}
|
|
147658
147900
|
const info = await infoResponse.json();
|
|
147901
|
+
const resolution = await resolveAnchorCredentialProvider(env2, info.requiredScopes);
|
|
147902
|
+
if (resolution.status === "unavailable") {
|
|
147903
|
+
return approvalFailedPage("We could not verify the sign-in requirement for this request. Please try again.", 503);
|
|
147904
|
+
}
|
|
147905
|
+
const provider = resolution.status === "credential" ? resolution.provider : null;
|
|
147906
|
+
let authorizedUser = null;
|
|
147907
|
+
if (provider) {
|
|
147908
|
+
const credentials = {};
|
|
147909
|
+
for (const name16 of credentialFieldNames(provider)) {
|
|
147910
|
+
if (bodyFields[name16] !== void 0)
|
|
147911
|
+
credentials[name16] = bodyFields[name16];
|
|
147912
|
+
}
|
|
147913
|
+
const handler = createCredentialAuthHandler({
|
|
147914
|
+
fetch: (...args) => globalThis.fetch(...args),
|
|
147915
|
+
logger: (msg, data) => console.debug(`[kya-http] ${msg}`, data)
|
|
147916
|
+
});
|
|
147917
|
+
const authResult = await handler.authenticate(provider.config, credentials);
|
|
147918
|
+
if (!authResult.success) {
|
|
147919
|
+
return htmlResponse(page("Sign-in failed", `<main class="kya-consent-failed"><h1>Sign-in failed</h1><p>${escapeHtml2(authResult.error || "Those credentials were not accepted. Please try again.")}</p></main>`), 401);
|
|
147920
|
+
}
|
|
147921
|
+
const identity = await resolveCredentialIdentity(env2, {
|
|
147922
|
+
projectId: env2.AGENTSHIELD_PROJECT_ID || "",
|
|
147923
|
+
provider: provider.providerId,
|
|
147924
|
+
userId: authResult.userId || "unknown",
|
|
147925
|
+
userEmail: authResult.userEmail,
|
|
147926
|
+
userDisplayName: authResult.userDisplayName
|
|
147927
|
+
});
|
|
147928
|
+
if (!identity.success || !identity.userDid) {
|
|
147929
|
+
return approvalFailedPage("We signed you in but could not resolve your identity. Please start over.", 500);
|
|
147930
|
+
}
|
|
147931
|
+
authorizedUser = {
|
|
147932
|
+
userDid: identity.userDid,
|
|
147933
|
+
userId: authResult.userId,
|
|
147934
|
+
userEmail: authResult.userEmail
|
|
147935
|
+
};
|
|
147936
|
+
}
|
|
147659
147937
|
let vcJwt;
|
|
147938
|
+
let subjectDid;
|
|
147660
147939
|
try {
|
|
147661
|
-
vcJwt = await mintDelegationVcJwt(env2, sid, info, cfg.delegationExpiresInS);
|
|
147940
|
+
({ vcJwt, subjectDid } = await mintDelegationVcJwt(env2, sid, info, cfg.delegationExpiresInS));
|
|
147662
147941
|
} catch (error87) {
|
|
147663
147942
|
console.warn(`[kya-http] delegation mint failed (sid=${sid}):`, error87 instanceof Error ? error87.message : String(error87));
|
|
147664
147943
|
return approvalFailedPage("We could not complete the authorization. Please start over.", 500);
|
|
@@ -147676,24 +147955,46 @@ async function handleAnchorConsentApprove(c, sid, env2, cfg) {
|
|
|
147676
147955
|
if (!approveResponse.ok) {
|
|
147677
147956
|
return approvalFailedPage("We could not complete the authorization. Please start over.", 502);
|
|
147678
147957
|
}
|
|
147958
|
+
if (authorizedUser && provider) {
|
|
147959
|
+
const report = notifyDelegation(env2, {
|
|
147960
|
+
sid,
|
|
147961
|
+
agentDid: subjectDid,
|
|
147962
|
+
userDid: authorizedUser.userDid,
|
|
147963
|
+
userId: authorizedUser.userId,
|
|
147964
|
+
userIdentifier: authorizedUser.userEmail,
|
|
147965
|
+
scopes: info.requiredScopes,
|
|
147966
|
+
provider: provider.providerId,
|
|
147967
|
+
// Record the same expiry the VC was minted with, matching the OAuth path.
|
|
147968
|
+
expiresAt: new Date(Date.now() + cfg.delegationExpiresInS * 1e3).toISOString()
|
|
147969
|
+
});
|
|
147970
|
+
const execCtx = c.executionCtx;
|
|
147971
|
+
execCtx?.waitUntil?.(report);
|
|
147972
|
+
}
|
|
147679
147973
|
return successPage();
|
|
147680
147974
|
}
|
|
147681
|
-
async function
|
|
147975
|
+
async function readBodyFields(c) {
|
|
147976
|
+
const out = {};
|
|
147682
147977
|
const raw2 = c.req?.raw;
|
|
147683
147978
|
if (!raw2)
|
|
147684
|
-
return
|
|
147979
|
+
return out;
|
|
147685
147980
|
try {
|
|
147686
147981
|
const contentType2 = raw2.headers.get("Content-Type") || "";
|
|
147687
147982
|
if (contentType2.includes("application/json")) {
|
|
147688
|
-
const body = await raw2.
|
|
147689
|
-
const
|
|
147690
|
-
|
|
147983
|
+
const body = await raw2.json();
|
|
147984
|
+
for (const [key, value] of Object.entries(body)) {
|
|
147985
|
+
if (typeof value === "string")
|
|
147986
|
+
out[key] = value;
|
|
147987
|
+
}
|
|
147988
|
+
return out;
|
|
147691
147989
|
}
|
|
147692
|
-
const form = await raw2.
|
|
147693
|
-
|
|
147694
|
-
|
|
147990
|
+
const form = await raw2.formData();
|
|
147991
|
+
form.forEach((value, key) => {
|
|
147992
|
+
if (typeof value === "string")
|
|
147993
|
+
out[key] = value;
|
|
147994
|
+
});
|
|
147995
|
+
return out;
|
|
147695
147996
|
} catch {
|
|
147696
|
-
return
|
|
147997
|
+
return out;
|
|
147697
147998
|
}
|
|
147698
147999
|
}
|
|
147699
148000
|
|
|
@@ -78,8 +78,8 @@ export async function getPackageVersions() {
|
|
|
78
78
|
return {
|
|
79
79
|
"@kya-os/mcp-i": "^1.7.13",
|
|
80
80
|
"@kya-os/cli": "^1.5.9",
|
|
81
|
-
"@kya-os/mcp-i-cloudflare": "^1.12.
|
|
82
|
-
"@kya-os/contracts": "^1.9.
|
|
81
|
+
"@kya-os/mcp-i-cloudflare": "^1.12.2",
|
|
82
|
+
"@kya-os/contracts": "^1.9.1",
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kya-os/create-mcpi-app",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.4",
|
|
4
4
|
"description": "Scaffold a new MCP-I application",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/helpers/index.js",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@apidevtools/swagger-parser": "^10.1.1",
|
|
58
|
-
"@kya-os/cli": "^1.6.
|
|
58
|
+
"@kya-os/cli": "^1.6.2",
|
|
59
59
|
"@kya-os/cli-effects": "^1.0.19",
|
|
60
|
-
"@kya-os/contracts": "^1.9.
|
|
60
|
+
"@kya-os/contracts": "^1.9.1",
|
|
61
61
|
"@kya-os/mcp-i": "^1.7.13",
|
|
62
|
-
"@kya-os/mcp-i-cloudflare": "^1.12.
|
|
62
|
+
"@kya-os/mcp-i-cloudflare": "^1.12.2",
|
|
63
63
|
"base-x": "^5.0.0",
|
|
64
64
|
"chalk": "^4.1.2",
|
|
65
65
|
"commander": "^12.1.0",
|