@kya-os/mcp-i-cloudflare 1.14.8 → 1.15.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 +2 -2
- package/dist/agent.d.ts +1 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +13 -10
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +6 -5
- package/dist/app.js.map +1 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/constants.js.map +1 -1
- package/dist/delegation-http/credential-consent.js +7 -7
- package/dist/delegation-http/credential-consent.js.map +1 -1
- package/dist/delegation-http/native-oauth.js +2 -2
- package/dist/delegation-http/native-oauth.js.map +1 -1
- package/dist/runtime/oauth-handler.d.ts +3 -3
- package/dist/runtime/oauth-handler.d.ts.map +1 -1
- package/dist/runtime/oauth-handler.js +18 -18
- package/dist/runtime/oauth-handler.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/services/admin.service.js +5 -5
- package/dist/services/admin.service.js.map +1 -1
- package/dist/services/consent-config.service.js +3 -3
- package/dist/services/consent-config.service.js.map +1 -1
- package/dist/services/consent.service.d.ts +1 -1
- package/dist/services/consent.service.js +24 -24
- package/dist/services/consent.service.js.map +1 -1
- package/dist/services/delegation.service.d.ts +26 -10
- package/dist/services/delegation.service.d.ts.map +1 -1
- package/dist/services/delegation.service.js +85 -96
- package/dist/services/delegation.service.js.map +1 -1
- package/dist/services/proof-batch-queue.d.ts +1 -1
- package/dist/services/proof-batch-queue.d.ts.map +1 -1
- package/dist/services/proof-batch-queue.js +1 -1
- package/dist/services/proof-batch-queue.js.map +1 -1
- package/dist/services/proof.service.d.ts +1 -1
- package/dist/services/proof.service.d.ts.map +1 -1
- package/dist/services/proof.service.js +13 -13
- package/dist/services/proof.service.js.map +1 -1
- package/package.json +3 -3
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { ConsentConfigService } from "./consent-config.service";
|
|
10
10
|
import { TemplateRenderer } from "./consent-templates/template-renderer";
|
|
11
|
-
import {
|
|
11
|
+
import { DEFAULT_CHECKPOINT_URL, DEFAULT_SESSION_CACHE_TTL, KEY_PAIR_TTL_SECONDS, CONSENT_PROVIDER_TYPES, } from "../constants";
|
|
12
12
|
import { STORAGE_KEYS, isPendingDelegationId } from "../constants/storage-keys";
|
|
13
13
|
import { loadDay0Config, getDelegationFieldName } from "../utils/day0-config";
|
|
14
14
|
import { buildProviderAuthorizeUrl } from "../runtime/oidc/authorize-url.js";
|
|
15
15
|
import { resolveIdpScopes } from "../runtime/oidc/idp-scopes.js";
|
|
16
16
|
import { validateConsentApprovalRequest, } from "@kya-os/contracts/consent";
|
|
17
|
-
import {
|
|
17
|
+
import { CHECKPOINT_ENDPOINTS, createDelegationAPIResponseSchema, createDelegationResponseSchema, } from "@kya-os/contracts/checkpoint-api";
|
|
18
18
|
import { createUnsignedVCJWT, completeVCJWT, parseVCJWT, generateDidKeyFromBase64, createDelegationVerifier, createDidKeyResolver, logger, base64urlEncodeFromBytes, base64urlDecodeToBytes, bytesToBase64, wrapDelegationAsVC, } from "@kya-os/mcp";
|
|
19
19
|
import { fetchRemoteConfig, normalizeAuthType, } from "@kya-os/mcp-i-runtime"; // product-layer symbols stay on OLD (C2 #2918)
|
|
20
20
|
import { WebCryptoProvider } from "../providers/crypto";
|
|
@@ -580,7 +580,7 @@ export class ConsentService {
|
|
|
580
580
|
*
|
|
581
581
|
* NOTE: The generated key pair has its own did:key which may differ
|
|
582
582
|
* from Checkpoint's persistentUserDid. Both are tied to the same
|
|
583
|
-
* OAuth identity. See docs/proposals/VC/
|
|
583
|
+
* OAuth identity. See docs/proposals/VC/CHECKPOINT_SIGNING_ENDPOINT.md
|
|
584
584
|
* for the future cleaner architecture.
|
|
585
585
|
*
|
|
586
586
|
* @param sessionId - Session ID for caching
|
|
@@ -1002,14 +1002,14 @@ export class ConsentService {
|
|
|
1002
1002
|
}
|
|
1003
1003
|
// Check project config to see if OAuth is configured
|
|
1004
1004
|
try {
|
|
1005
|
-
const
|
|
1005
|
+
const checkpointUrl = this.env.CHECKPOINT_API_URL || DEFAULT_CHECKPOINT_URL;
|
|
1006
1006
|
const apiKey = this.env.CHECKPOINT_API_KEY;
|
|
1007
1007
|
if (!apiKey) {
|
|
1008
1008
|
// No API key - can't check, assume OAuth not required
|
|
1009
1009
|
return false;
|
|
1010
1010
|
}
|
|
1011
1011
|
// Fetch project config to check for OAuth provider
|
|
1012
|
-
const configUrl = `${
|
|
1012
|
+
const configUrl = `${checkpointUrl}/api/v1/bouncer/projects/${projectId}/config`;
|
|
1013
1013
|
const response = await fetch(configUrl, {
|
|
1014
1014
|
headers: {
|
|
1015
1015
|
Authorization: `Bearer ${apiKey}`,
|
|
@@ -1057,7 +1057,7 @@ export class ConsentService {
|
|
|
1057
1057
|
oauthSecurityService, agentName, // Human-readable agent name for Checkpoint dashboard
|
|
1058
1058
|
tool // Tool name to preserve through OAuth callback for clickwrap redirect
|
|
1059
1059
|
) {
|
|
1060
|
-
const
|
|
1060
|
+
const checkpointUrl = this.env.CHECKPOINT_API_URL || DEFAULT_CHECKPOINT_URL;
|
|
1061
1061
|
// Generate a temporary delegation ID for state (will be created after OAuth)
|
|
1062
1062
|
const delegationId = `temp-${Date.now()}`;
|
|
1063
1063
|
// ✅ Phase 1: Generate PKCE challenge if OAuthSecurityService is available
|
|
@@ -1138,7 +1138,7 @@ export class ConsentService {
|
|
|
1138
1138
|
provider,
|
|
1139
1139
|
});
|
|
1140
1140
|
try {
|
|
1141
|
-
await this.providerRegistry.
|
|
1141
|
+
await this.providerRegistry.loadFromCheckpoint(projectId);
|
|
1142
1142
|
logger.debug("[ConsentService] Providers loaded successfully", {
|
|
1143
1143
|
projectId,
|
|
1144
1144
|
providers: this.providerRegistry.getProviderNames(),
|
|
@@ -1240,7 +1240,7 @@ export class ConsentService {
|
|
|
1240
1240
|
// NOTE: This is a legacy proxy mode path that requires Checkpoint to act as an OAuth proxy.
|
|
1241
1241
|
// Most providers (GitHub, Google) use direct PKCE mode instead (see buildDirectOAuthUrl).
|
|
1242
1242
|
// If this path is hit and results in a 404, check if the provider supports PKCE.
|
|
1243
|
-
const oauthUrl = new URL(`${
|
|
1243
|
+
const oauthUrl = new URL(`${checkpointUrl}/bouncer/oauth/authorize`);
|
|
1244
1244
|
oauthUrl.searchParams.set("response_type", "code");
|
|
1245
1245
|
oauthUrl.searchParams.set("client_id", projectId); // Use projectId as client_id
|
|
1246
1246
|
oauthUrl.searchParams.set("redirect_uri", `${serverUrl}/oauth/callback`);
|
|
@@ -1416,7 +1416,7 @@ export class ConsentService {
|
|
|
1416
1416
|
provider: oauthIdentity.provider,
|
|
1417
1417
|
subject: oauthIdentity.subject.substring(0, 20) + "...",
|
|
1418
1418
|
userDid: userDid.substring(0, 30) + "...",
|
|
1419
|
-
source: "
|
|
1419
|
+
source: "checkpoint_identity_resolution",
|
|
1420
1420
|
});
|
|
1421
1421
|
}
|
|
1422
1422
|
catch (error) {
|
|
@@ -1986,7 +1986,7 @@ export class ConsentService {
|
|
|
1986
1986
|
// Build consent page config
|
|
1987
1987
|
// ✅ CRITICAL: Pass the FULL consent config (ui, credentials, etc.) not just branding/terms
|
|
1988
1988
|
// Type assertion to handle updated schema before rebuild
|
|
1989
|
-
// The remote consent config (from
|
|
1989
|
+
// The remote consent config (from checkpoint) carries fields that
|
|
1990
1990
|
// aren't in the trimmed contracts ConsentPageConfig type. Read them off
|
|
1991
1991
|
// a Record<string, unknown> view so we can plumb them through without
|
|
1992
1992
|
// touching contracts.
|
|
@@ -3801,7 +3801,7 @@ export class ConsentService {
|
|
|
3801
3801
|
return { success: false, ...MANDATE_ERROR };
|
|
3802
3802
|
}
|
|
3803
3803
|
const mandate = mandateResolution.mandate;
|
|
3804
|
-
const
|
|
3804
|
+
const checkpointUrl = this.env.CHECKPOINT_API_URL || DEFAULT_CHECKPOINT_URL;
|
|
3805
3805
|
const apiKey = this.env.CHECKPOINT_API_KEY;
|
|
3806
3806
|
if (!apiKey) {
|
|
3807
3807
|
logger.warn("[ConsentService] No API key configured, cannot create delegation");
|
|
@@ -3924,7 +3924,7 @@ export class ConsentService {
|
|
|
3924
3924
|
? withMandateConstraints(builtRequest, mandate.constraints)
|
|
3925
3925
|
: builtRequest;
|
|
3926
3926
|
logger.debug("[ConsentService] Creating delegation:", {
|
|
3927
|
-
url: `${
|
|
3927
|
+
url: `${checkpointUrl}${CHECKPOINT_ENDPOINTS.DELEGATIONS_CREATE}`,
|
|
3928
3928
|
agentDid: request.agent_did.substring(0, 20) + "...",
|
|
3929
3929
|
scopes: request.scopes,
|
|
3930
3930
|
expiresInDays,
|
|
@@ -3933,12 +3933,12 @@ export class ConsentService {
|
|
|
3933
3933
|
hasUserDid: !!userDid,
|
|
3934
3934
|
});
|
|
3935
3935
|
// Error-based format detection: try request format, fallback on error
|
|
3936
|
-
const response = await this.tryAPICall(
|
|
3936
|
+
const response = await this.tryAPICall(checkpointUrl, apiKey, delegationRequest);
|
|
3937
3937
|
if (!response.success) {
|
|
3938
3938
|
return response;
|
|
3939
3939
|
}
|
|
3940
3940
|
const responseData = response.data;
|
|
3941
|
-
// Canonical format per @kya-os/contracts/
|
|
3941
|
+
// Canonical format per @kya-os/contracts/checkpoint-api:
|
|
3942
3942
|
// Wrapped: { success: true, data: { delegation_id: string, agent_did: string, ... } }
|
|
3943
3943
|
// Unwrapped: { delegation_id: string, agent_did: string, ... }
|
|
3944
3944
|
//
|
|
@@ -4762,7 +4762,7 @@ export class ConsentService {
|
|
|
4762
4762
|
* @see OAuthConfigService.getOAuthConfig() for the same endpoint usage
|
|
4763
4763
|
*/
|
|
4764
4764
|
async getCredentialProviderConfig(projectId, providerName) {
|
|
4765
|
-
const
|
|
4765
|
+
const checkpointUrl = this.env.CHECKPOINT_API_URL || DEFAULT_CHECKPOINT_URL;
|
|
4766
4766
|
const apiKey = this.env.CHECKPOINT_API_KEY;
|
|
4767
4767
|
if (!apiKey) {
|
|
4768
4768
|
logger.warn("[ConsentService] No Checkpoint API key configured");
|
|
@@ -4772,7 +4772,7 @@ export class ConsentService {
|
|
|
4772
4772
|
// Use the /providers endpoint - same as OAuthConfigService.getOAuthConfig()
|
|
4773
4773
|
// This endpoint was updated in fix/provider-config to read from oauthProviders JSONB
|
|
4774
4774
|
// Authentication: Use Authorization: Bearer header for consistency with OAuthConfigService
|
|
4775
|
-
const response = await fetch(`${
|
|
4775
|
+
const response = await fetch(`${checkpointUrl}/api/v1/bouncer/projects/${encodeURIComponent(projectId)}/providers`, {
|
|
4776
4776
|
headers: {
|
|
4777
4777
|
Authorization: `Bearer ${apiKey}`,
|
|
4778
4778
|
"Content-Type": "application/json",
|
|
@@ -4922,14 +4922,14 @@ export class ConsentService {
|
|
|
4922
4922
|
* Resolve identity via Checkpoint for credential-based auth
|
|
4923
4923
|
*/
|
|
4924
4924
|
async resolveCredentialIdentity(params) {
|
|
4925
|
-
const
|
|
4925
|
+
const checkpointUrl = this.env.CHECKPOINT_API_URL || DEFAULT_CHECKPOINT_URL;
|
|
4926
4926
|
const apiKey = this.env.CHECKPOINT_API_KEY;
|
|
4927
4927
|
if (!apiKey) {
|
|
4928
4928
|
logger.warn("[ConsentService] No Checkpoint API key for identity resolution");
|
|
4929
4929
|
return { success: false };
|
|
4930
4930
|
}
|
|
4931
4931
|
try {
|
|
4932
|
-
const response = await fetch(`${
|
|
4932
|
+
const response = await fetch(`${checkpointUrl}/api/v1/bouncer/identity/resolve`, {
|
|
4933
4933
|
method: "POST",
|
|
4934
4934
|
headers: {
|
|
4935
4935
|
"X-API-Key": apiKey,
|
|
@@ -5624,11 +5624,11 @@ export class ConsentService {
|
|
|
5624
5624
|
/**
|
|
5625
5625
|
* Try API call with error-based format detection
|
|
5626
5626
|
*/
|
|
5627
|
-
async tryAPICall(
|
|
5627
|
+
async tryAPICall(checkpointUrl, apiKey, request) {
|
|
5628
5628
|
// Handle format detection
|
|
5629
5629
|
if (request._tryFormats && request.fullFormat && request.simplifiedFormat) {
|
|
5630
5630
|
// Try full format first
|
|
5631
|
-
const fullResponse = await this.makeAPICall(
|
|
5631
|
+
const fullResponse = await this.makeAPICall(checkpointUrl, apiKey, request.fullFormat);
|
|
5632
5632
|
if (fullResponse.success) {
|
|
5633
5633
|
await this.cacheFormatPreference("full");
|
|
5634
5634
|
return fullResponse;
|
|
@@ -5641,14 +5641,14 @@ export class ConsentService {
|
|
|
5641
5641
|
}
|
|
5642
5642
|
// Full format failed with validation error, try simplified
|
|
5643
5643
|
logger.debug("[ConsentService] Full format failed, trying simplified format...");
|
|
5644
|
-
const simplifiedResponse = await this.makeAPICall(
|
|
5644
|
+
const simplifiedResponse = await this.makeAPICall(checkpointUrl, apiKey, request.simplifiedFormat);
|
|
5645
5645
|
if (simplifiedResponse.success) {
|
|
5646
5646
|
await this.cacheFormatPreference("simplified");
|
|
5647
5647
|
}
|
|
5648
5648
|
return simplifiedResponse;
|
|
5649
5649
|
}
|
|
5650
5650
|
// Direct call (format already determined)
|
|
5651
|
-
return this.makeAPICall(
|
|
5651
|
+
return this.makeAPICall(checkpointUrl, apiKey, request);
|
|
5652
5652
|
}
|
|
5653
5653
|
/**
|
|
5654
5654
|
* Make API call and parse response
|
|
@@ -5656,7 +5656,7 @@ export class ConsentService {
|
|
|
5656
5656
|
* CRITICAL: This method ensures session_id and project_id are never sent to Checkpoint.
|
|
5657
5657
|
* These fields are NOT part of the createDelegationSchema and will cause validation errors.
|
|
5658
5658
|
*/
|
|
5659
|
-
async makeAPICall(
|
|
5659
|
+
async makeAPICall(checkpointUrl, apiKey, requestBody) {
|
|
5660
5660
|
try {
|
|
5661
5661
|
// FINAL SAFEGUARD: Remove session_id and project_id if they somehow got added
|
|
5662
5662
|
// This provides defense-in-depth protection
|
|
@@ -5669,7 +5669,7 @@ export class ConsentService {
|
|
|
5669
5669
|
logger.warn("[ConsentService] ⚠️ project_id detected in request body - removing (not in schema)");
|
|
5670
5670
|
delete sanitizedBody.project_id;
|
|
5671
5671
|
}
|
|
5672
|
-
const response = await fetch(`${
|
|
5672
|
+
const response = await fetch(`${checkpointUrl}${CHECKPOINT_ENDPOINTS.DELEGATIONS_CREATE}`, {
|
|
5673
5673
|
method: "POST",
|
|
5674
5674
|
headers: {
|
|
5675
5675
|
Authorization: `Bearer ${apiKey}`,
|