@kya-os/mcp-i-core 1.3.12 → 1.3.14
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/config/remote-config.js +9 -12
- package/dist/runtime/base.js +11 -0
- package/dist/services/access-control.service.js +5 -0
- package/dist/services/tool-protection.service.js +17 -8
- package/package.json +2 -2
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-test$colon$coverage.log +0 -4586
- package/.turbo/turbo-test.log +0 -3169
- package/COMPLIANCE_IMPROVEMENT_REPORT.md +0 -483
- package/Composer 3.md +0 -615
- package/GPT-5.md +0 -1169
- package/OPUS-plan.md +0 -352
- package/PHASE_3_AND_4.1_SUMMARY.md +0 -585
- package/PHASE_3_SUMMARY.md +0 -317
- package/PHASE_4.1.3_SUMMARY.md +0 -428
- package/PHASE_4.1_COMPLETE.md +0 -525
- package/PHASE_4_USER_DID_IDENTITY_LINKING_PLAN.md +0 -1240
- package/SCHEMA_COMPLIANCE_REPORT.md +0 -275
- package/TEST_PLAN.md +0 -571
- package/coverage/coverage-final.json +0 -60
- package/dist/cache/oauth-config-cache.d.ts.map +0 -1
- package/dist/cache/oauth-config-cache.js.map +0 -1
- package/dist/cache/tool-protection-cache.d.ts.map +0 -1
- package/dist/cache/tool-protection-cache.js.map +0 -1
- package/dist/compliance/index.d.ts.map +0 -1
- package/dist/compliance/index.js.map +0 -1
- package/dist/compliance/schema-registry.d.ts.map +0 -1
- package/dist/compliance/schema-registry.js.map +0 -1
- package/dist/compliance/schema-verifier.d.ts.map +0 -1
- package/dist/compliance/schema-verifier.js.map +0 -1
- package/dist/config/remote-config.d.ts.map +0 -1
- package/dist/config/remote-config.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/delegation/audience-validator.d.ts.map +0 -1
- package/dist/delegation/audience-validator.js.map +0 -1
- package/dist/delegation/bitstring.d.ts.map +0 -1
- package/dist/delegation/bitstring.js.map +0 -1
- package/dist/delegation/cascading-revocation.d.ts.map +0 -1
- package/dist/delegation/cascading-revocation.js.map +0 -1
- package/dist/delegation/delegation-graph.d.ts.map +0 -1
- package/dist/delegation/delegation-graph.js.map +0 -1
- package/dist/delegation/did-key-resolver.d.ts.map +0 -1
- package/dist/delegation/did-key-resolver.js.map +0 -1
- package/dist/delegation/index.d.ts.map +0 -1
- package/dist/delegation/index.js.map +0 -1
- package/dist/delegation/statuslist-manager.d.ts.map +0 -1
- package/dist/delegation/statuslist-manager.js.map +0 -1
- package/dist/delegation/storage/index.d.ts.map +0 -1
- package/dist/delegation/storage/index.js.map +0 -1
- package/dist/delegation/storage/memory-graph-storage.d.ts.map +0 -1
- package/dist/delegation/storage/memory-graph-storage.js.map +0 -1
- package/dist/delegation/storage/memory-statuslist-storage.d.ts.map +0 -1
- package/dist/delegation/storage/memory-statuslist-storage.js.map +0 -1
- package/dist/delegation/utils.d.ts.map +0 -1
- package/dist/delegation/utils.js.map +0 -1
- package/dist/delegation/vc-issuer.d.ts.map +0 -1
- package/dist/delegation/vc-issuer.js.map +0 -1
- package/dist/delegation/vc-verifier.d.ts.map +0 -1
- package/dist/delegation/vc-verifier.js.map +0 -1
- package/dist/identity/idp-token-resolver.d.ts.map +0 -1
- package/dist/identity/idp-token-resolver.js.map +0 -1
- package/dist/identity/idp-token-storage.interface.d.ts.map +0 -1
- package/dist/identity/idp-token-storage.interface.js.map +0 -1
- package/dist/identity/user-did-manager.d.ts.map +0 -1
- package/dist/identity/user-did-manager.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/providers/base.d.ts.map +0 -1
- package/dist/providers/base.js.map +0 -1
- package/dist/providers/memory.d.ts.map +0 -1
- package/dist/providers/memory.js.map +0 -1
- package/dist/runtime/audit-logger.d.ts.map +0 -1
- package/dist/runtime/audit-logger.js.map +0 -1
- package/dist/runtime/base.d.ts.map +0 -1
- package/dist/runtime/base.js.map +0 -1
- package/dist/services/access-control.service.d.ts.map +0 -1
- package/dist/services/access-control.service.js.map +0 -1
- package/dist/services/authorization/authorization-registry.d.ts.map +0 -1
- package/dist/services/authorization/authorization-registry.js.map +0 -1
- package/dist/services/authorization/types.d.ts.map +0 -1
- package/dist/services/authorization/types.js.map +0 -1
- package/dist/services/batch-delegation.service.d.ts.map +0 -1
- package/dist/services/batch-delegation.service.js.map +0 -1
- package/dist/services/crypto.service.d.ts.map +0 -1
- package/dist/services/crypto.service.js.map +0 -1
- package/dist/services/errors.d.ts.map +0 -1
- package/dist/services/errors.js.map +0 -1
- package/dist/services/index.d.ts.map +0 -1
- package/dist/services/index.js.map +0 -1
- package/dist/services/oauth-config.service.d.ts.map +0 -1
- package/dist/services/oauth-config.service.js.map +0 -1
- package/dist/services/oauth-provider-registry.d.ts.map +0 -1
- package/dist/services/oauth-provider-registry.js.map +0 -1
- package/dist/services/oauth-service.d.ts.map +0 -1
- package/dist/services/oauth-service.js.map +0 -1
- package/dist/services/oauth-token-retrieval.service.d.ts.map +0 -1
- package/dist/services/oauth-token-retrieval.service.js.map +0 -1
- package/dist/services/proof-verifier.d.ts.map +0 -1
- package/dist/services/proof-verifier.js.map +0 -1
- package/dist/services/provider-resolver.d.ts.map +0 -1
- package/dist/services/provider-resolver.js.map +0 -1
- package/dist/services/provider-validator.d.ts.map +0 -1
- package/dist/services/provider-validator.js.map +0 -1
- package/dist/services/session-registration.service.d.ts.map +0 -1
- package/dist/services/session-registration.service.js.map +0 -1
- package/dist/services/storage.service.d.ts.map +0 -1
- package/dist/services/storage.service.js.map +0 -1
- package/dist/services/tool-context-builder.d.ts.map +0 -1
- package/dist/services/tool-context-builder.js.map +0 -1
- package/dist/services/tool-protection.service.d.ts.map +0 -1
- package/dist/services/tool-protection.service.js.map +0 -1
- package/dist/types/oauth-required-error.d.ts.map +0 -1
- package/dist/types/oauth-required-error.js.map +0 -1
- package/dist/types/tool-protection.d.ts.map +0 -1
- package/dist/types/tool-protection.js.map +0 -1
- package/dist/utils/base58.d.ts.map +0 -1
- package/dist/utils/base58.js.map +0 -1
- package/dist/utils/base64.d.ts.map +0 -1
- package/dist/utils/base64.js.map +0 -1
- package/dist/utils/cors.d.ts.map +0 -1
- package/dist/utils/cors.js.map +0 -1
- package/dist/utils/did-helpers.d.ts.map +0 -1
- package/dist/utils/did-helpers.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/storage-keys.d.ts.map +0 -1
- package/dist/utils/storage-keys.js.map +0 -1
- package/docs/API_REFERENCE.md +0 -1362
- package/docs/COMPLIANCE_MATRIX.md +0 -691
- package/docs/STATUSLIST2021_GUIDE.md +0 -696
- package/docs/W3C_VC_DELEGATION_GUIDE.md +0 -710
- package/src/__tests__/cache/tool-protection-cache.test.ts +0 -640
- package/src/__tests__/config/provider-runtime-config.test.ts +0 -309
- package/src/__tests__/delegation-e2e.test.ts +0 -690
- package/src/__tests__/identity/user-did-manager.test.ts +0 -232
- package/src/__tests__/index.test.ts +0 -56
- package/src/__tests__/integration/full-flow.test.ts +0 -789
- package/src/__tests__/integration.test.ts +0 -281
- package/src/__tests__/providers/base.test.ts +0 -173
- package/src/__tests__/providers/memory.test.ts +0 -319
- package/src/__tests__/regression/phase2-regression.test.ts +0 -429
- package/src/__tests__/runtime/audit-logger.test.ts +0 -154
- package/src/__tests__/runtime/base-extensions.test.ts +0 -595
- package/src/__tests__/runtime/base.test.ts +0 -869
- package/src/__tests__/runtime/delegation-flow.test.ts +0 -164
- package/src/__tests__/runtime/proof-client-did.test.ts +0 -376
- package/src/__tests__/runtime/route-interception.test.ts +0 -686
- package/src/__tests__/runtime/tool-protection-enforcement.test.ts +0 -908
- package/src/__tests__/services/agentshield-integration.test.ts +0 -791
- package/src/__tests__/services/cache-busting.test.ts +0 -125
- package/src/__tests__/services/oauth-service-pkce.test.ts +0 -556
- package/src/__tests__/services/provider-resolver-edge-cases.test.ts +0 -591
- package/src/__tests__/services/tool-protection-merged-config.test.ts +0 -485
- package/src/__tests__/services/tool-protection-oauth-provider.test.ts +0 -480
- package/src/__tests__/services/tool-protection.service.test.ts +0 -1373
- package/src/__tests__/utils/mock-providers.ts +0 -340
- package/src/cache/oauth-config-cache.d.ts +0 -69
- package/src/cache/oauth-config-cache.d.ts.map +0 -1
- package/src/cache/oauth-config-cache.js.map +0 -1
- package/src/cache/oauth-config-cache.ts +0 -123
- package/src/cache/tool-protection-cache.ts +0 -171
- package/src/compliance/EXAMPLE.md +0 -412
- package/src/compliance/__tests__/schema-verifier.test.ts +0 -797
- package/src/compliance/index.ts +0 -8
- package/src/compliance/schema-registry.ts +0 -460
- package/src/compliance/schema-verifier.ts +0 -708
- package/src/config/__tests__/merged-config.spec.ts +0 -445
- package/src/config/__tests__/remote-config.spec.ts +0 -268
- package/src/config/remote-config.ts +0 -264
- package/src/config.ts +0 -312
- package/src/delegation/__tests__/audience-validator.test.ts +0 -112
- package/src/delegation/__tests__/bitstring.test.ts +0 -346
- package/src/delegation/__tests__/cascading-revocation.test.ts +0 -628
- package/src/delegation/__tests__/delegation-graph.test.ts +0 -584
- package/src/delegation/__tests__/did-key-resolver.test.ts +0 -265
- package/src/delegation/__tests__/utils.test.ts +0 -152
- package/src/delegation/__tests__/vc-issuer.test.ts +0 -442
- package/src/delegation/__tests__/vc-verifier.test.ts +0 -922
- package/src/delegation/audience-validator.ts +0 -52
- package/src/delegation/bitstring.ts +0 -278
- package/src/delegation/cascading-revocation.ts +0 -370
- package/src/delegation/delegation-graph.ts +0 -299
- package/src/delegation/did-key-resolver.ts +0 -179
- package/src/delegation/index.ts +0 -14
- package/src/delegation/statuslist-manager.ts +0 -353
- package/src/delegation/storage/__tests__/memory-graph-storage.test.ts +0 -366
- package/src/delegation/storage/__tests__/memory-statuslist-storage.test.ts +0 -228
- package/src/delegation/storage/index.ts +0 -9
- package/src/delegation/storage/memory-graph-storage.ts +0 -178
- package/src/delegation/storage/memory-statuslist-storage.ts +0 -77
- package/src/delegation/utils.ts +0 -221
- package/src/delegation/vc-issuer.ts +0 -232
- package/src/delegation/vc-verifier.ts +0 -568
- package/src/identity/idp-token-resolver.ts +0 -181
- package/src/identity/idp-token-storage.interface.ts +0 -94
- package/src/identity/user-did-manager.ts +0 -526
- package/src/index.ts +0 -310
- package/src/providers/base.d.ts +0 -91
- package/src/providers/base.d.ts.map +0 -1
- package/src/providers/base.js.map +0 -1
- package/src/providers/base.ts +0 -96
- package/src/providers/memory.ts +0 -142
- package/src/runtime/audit-logger.ts +0 -39
- package/src/runtime/base.ts +0 -1392
- package/src/services/__tests__/access-control.integration.test.ts +0 -443
- package/src/services/__tests__/access-control.proof-response-validation.test.ts +0 -578
- package/src/services/__tests__/access-control.service.test.ts +0 -970
- package/src/services/__tests__/batch-delegation.service.test.ts +0 -351
- package/src/services/__tests__/crypto.service.test.ts +0 -531
- package/src/services/__tests__/oauth-provider-registry.test.ts +0 -142
- package/src/services/__tests__/proof-verifier.integration.test.ts +0 -485
- package/src/services/__tests__/proof-verifier.test.ts +0 -489
- package/src/services/__tests__/provider-resolution.integration.test.ts +0 -202
- package/src/services/__tests__/provider-resolver.test.ts +0 -213
- package/src/services/__tests__/storage.service.test.ts +0 -358
- package/src/services/access-control.service.ts +0 -990
- package/src/services/authorization/authorization-registry.ts +0 -66
- package/src/services/authorization/types.ts +0 -71
- package/src/services/batch-delegation.service.ts +0 -137
- package/src/services/crypto.service.ts +0 -302
- package/src/services/errors.ts +0 -76
- package/src/services/index.ts +0 -18
- package/src/services/oauth-config.service.d.ts +0 -53
- package/src/services/oauth-config.service.d.ts.map +0 -1
- package/src/services/oauth-config.service.js.map +0 -1
- package/src/services/oauth-config.service.ts +0 -192
- package/src/services/oauth-provider-registry.d.ts +0 -57
- package/src/services/oauth-provider-registry.d.ts.map +0 -1
- package/src/services/oauth-provider-registry.js.map +0 -1
- package/src/services/oauth-provider-registry.ts +0 -141
- package/src/services/oauth-service.ts +0 -544
- package/src/services/oauth-token-retrieval.service.ts +0 -245
- package/src/services/proof-verifier.ts +0 -478
- package/src/services/provider-resolver.d.ts +0 -48
- package/src/services/provider-resolver.d.ts.map +0 -1
- package/src/services/provider-resolver.js.map +0 -1
- package/src/services/provider-resolver.ts +0 -146
- package/src/services/provider-validator.ts +0 -170
- package/src/services/session-registration.service.ts +0 -251
- package/src/services/storage.service.ts +0 -566
- package/src/services/tool-context-builder.ts +0 -237
- package/src/services/tool-protection.service.ts +0 -1070
- package/src/types/oauth-required-error.ts +0 -63
- package/src/types/tool-protection.ts +0 -155
- package/src/utils/__tests__/did-helpers.test.ts +0 -156
- package/src/utils/base58.ts +0 -109
- package/src/utils/base64.ts +0 -148
- package/src/utils/cors.ts +0 -83
- package/src/utils/did-helpers.ts +0 -210
- package/src/utils/index.ts +0 -8
- package/src/utils/storage-keys.ts +0 -278
- package/tsconfig.json +0 -21
- package/vitest.config.ts +0 -56
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for Merged Configuration Handling
|
|
3
|
-
*
|
|
4
|
-
* TDD tests for the merged config API response format where tool protections
|
|
5
|
-
* are embedded in the config at `toolProtection.tools`.
|
|
6
|
-
*
|
|
7
|
-
* These tests document the expected behavior BEFORE implementation.
|
|
8
|
-
*
|
|
9
|
-
* @since 1.6.0
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
13
|
-
import {
|
|
14
|
-
fetchRemoteConfig,
|
|
15
|
-
type RemoteConfigOptions,
|
|
16
|
-
type RemoteConfigCache
|
|
17
|
-
} from '../remote-config.js';
|
|
18
|
-
import type { MergedMCPIServerConfig } from '@kya-os/contracts/dashboard-config';
|
|
19
|
-
|
|
20
|
-
describe('fetchRemoteConfig - Merged Config Format', () => {
|
|
21
|
-
let mockFetch: ReturnType<typeof vi.fn>;
|
|
22
|
-
let mockCache: RemoteConfigCache;
|
|
23
|
-
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
mockFetch = vi.fn();
|
|
26
|
-
mockCache = {
|
|
27
|
-
get: vi.fn(),
|
|
28
|
-
set: vi.fn()
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('Embedded tool protections', () => {
|
|
33
|
-
it('should handle merged config with toolProtection.tools field', async () => {
|
|
34
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
35
|
-
|
|
36
|
-
const mergedConfig: MergedMCPIServerConfig = {
|
|
37
|
-
identity: {
|
|
38
|
-
serverDid: 'did:key:test',
|
|
39
|
-
environment: 'production',
|
|
40
|
-
storageLocation: 'cloudflare-kv'
|
|
41
|
-
},
|
|
42
|
-
proofing: {
|
|
43
|
-
enabled: true,
|
|
44
|
-
destinations: [],
|
|
45
|
-
batchQueue: { maxBatchSize: 10, flushIntervalMs: 5000, maxRetries: 3 }
|
|
46
|
-
},
|
|
47
|
-
delegation: {
|
|
48
|
-
enabled: true,
|
|
49
|
-
enforceStrictly: true,
|
|
50
|
-
verifier: { type: 'agentshield' },
|
|
51
|
-
authorization: {}
|
|
52
|
-
},
|
|
53
|
-
toolProtection: {
|
|
54
|
-
source: 'agentshield',
|
|
55
|
-
tools: {
|
|
56
|
-
greet: {
|
|
57
|
-
requiresDelegation: true,
|
|
58
|
-
requiredScopes: ['greeting:write'],
|
|
59
|
-
riskLevel: 'low'
|
|
60
|
-
},
|
|
61
|
-
checkout: {
|
|
62
|
-
requiresDelegation: true,
|
|
63
|
-
requiredScopes: ['checkout:execute', 'payment:write'],
|
|
64
|
-
riskLevel: 'high'
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
audit: {
|
|
69
|
-
enabled: true,
|
|
70
|
-
includeProofHashes: true,
|
|
71
|
-
includePayloads: false
|
|
72
|
-
},
|
|
73
|
-
session: {
|
|
74
|
-
timestampSkewSeconds: 120,
|
|
75
|
-
ttlMinutes: 30
|
|
76
|
-
},
|
|
77
|
-
platform: {
|
|
78
|
-
type: 'cloudflare'
|
|
79
|
-
},
|
|
80
|
-
metadata: {
|
|
81
|
-
version: '1.6.0',
|
|
82
|
-
lastUpdated: new Date().toISOString(),
|
|
83
|
-
source: 'dashboard'
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
mockFetch.mockResolvedValue({
|
|
88
|
-
ok: true,
|
|
89
|
-
json: async () => ({
|
|
90
|
-
success: true,
|
|
91
|
-
data: { config: mergedConfig }
|
|
92
|
-
})
|
|
93
|
-
} as Response);
|
|
94
|
-
|
|
95
|
-
const options: RemoteConfigOptions = {
|
|
96
|
-
apiUrl: 'https://kya.vouched.id',
|
|
97
|
-
apiKey: 'test-key',
|
|
98
|
-
projectId: 'test-project',
|
|
99
|
-
fetchProvider: mockFetch
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
103
|
-
|
|
104
|
-
expect(result).toBeDefined();
|
|
105
|
-
// The toolProtection.tools should be accessible
|
|
106
|
-
expect(result?.toolProtection?.tools).toBeDefined();
|
|
107
|
-
expect(result?.toolProtection?.tools?.greet).toEqual({
|
|
108
|
-
requiresDelegation: true,
|
|
109
|
-
requiredScopes: ['greeting:write'],
|
|
110
|
-
riskLevel: 'low'
|
|
111
|
-
});
|
|
112
|
-
expect(result?.toolProtection?.tools?.checkout).toEqual({
|
|
113
|
-
requiresDelegation: true,
|
|
114
|
-
requiredScopes: ['checkout:execute', 'payment:write'],
|
|
115
|
-
riskLevel: 'high'
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should handle empty tools object when no tools discovered', async () => {
|
|
120
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
121
|
-
|
|
122
|
-
const mergedConfig = {
|
|
123
|
-
identity: {
|
|
124
|
-
serverDid: 'did:key:test',
|
|
125
|
-
environment: 'production',
|
|
126
|
-
storageLocation: 'cloudflare-kv'
|
|
127
|
-
},
|
|
128
|
-
proofing: {
|
|
129
|
-
enabled: false,
|
|
130
|
-
destinations: [],
|
|
131
|
-
batchQueue: { maxBatchSize: 10, flushIntervalMs: 5000, maxRetries: 3 }
|
|
132
|
-
},
|
|
133
|
-
delegation: {
|
|
134
|
-
enabled: false,
|
|
135
|
-
enforceStrictly: false,
|
|
136
|
-
verifier: { type: 'memory' },
|
|
137
|
-
authorization: {}
|
|
138
|
-
},
|
|
139
|
-
toolProtection: {
|
|
140
|
-
source: 'agentshield',
|
|
141
|
-
tools: {} // Empty - no tools discovered yet
|
|
142
|
-
},
|
|
143
|
-
audit: {
|
|
144
|
-
enabled: false,
|
|
145
|
-
includeProofHashes: false,
|
|
146
|
-
includePayloads: false
|
|
147
|
-
},
|
|
148
|
-
session: {
|
|
149
|
-
timestampSkewSeconds: 120,
|
|
150
|
-
ttlMinutes: 30
|
|
151
|
-
},
|
|
152
|
-
platform: {
|
|
153
|
-
type: 'node'
|
|
154
|
-
},
|
|
155
|
-
metadata: {
|
|
156
|
-
version: '1.6.0',
|
|
157
|
-
lastUpdated: new Date().toISOString(),
|
|
158
|
-
source: 'dashboard'
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
mockFetch.mockResolvedValue({
|
|
163
|
-
ok: true,
|
|
164
|
-
json: async () => ({
|
|
165
|
-
success: true,
|
|
166
|
-
data: { config: mergedConfig }
|
|
167
|
-
})
|
|
168
|
-
} as Response);
|
|
169
|
-
|
|
170
|
-
const options: RemoteConfigOptions = {
|
|
171
|
-
apiUrl: 'https://kya.vouched.id',
|
|
172
|
-
apiKey: 'test-key',
|
|
173
|
-
projectId: 'test-project',
|
|
174
|
-
fetchProvider: mockFetch
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
178
|
-
|
|
179
|
-
expect(result).toBeDefined();
|
|
180
|
-
expect(result?.toolProtection?.tools).toEqual({});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it('should gracefully handle missing tools field for backward compatibility', async () => {
|
|
184
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
185
|
-
|
|
186
|
-
// Old API format without tools field
|
|
187
|
-
const oldFormatConfig = {
|
|
188
|
-
identity: {
|
|
189
|
-
serverDid: 'did:key:test',
|
|
190
|
-
environment: 'production',
|
|
191
|
-
storageLocation: 'cloudflare-kv'
|
|
192
|
-
},
|
|
193
|
-
proofing: {
|
|
194
|
-
enabled: false,
|
|
195
|
-
destinations: [],
|
|
196
|
-
batchQueue: { maxBatchSize: 10, flushIntervalMs: 5000, maxRetries: 3 }
|
|
197
|
-
},
|
|
198
|
-
delegation: {
|
|
199
|
-
enabled: false,
|
|
200
|
-
enforceStrictly: false,
|
|
201
|
-
verifier: { type: 'memory' },
|
|
202
|
-
authorization: {}
|
|
203
|
-
},
|
|
204
|
-
toolProtection: {
|
|
205
|
-
source: 'agentshield'
|
|
206
|
-
// No tools field - old format
|
|
207
|
-
},
|
|
208
|
-
audit: {
|
|
209
|
-
enabled: false,
|
|
210
|
-
includeProofHashes: false,
|
|
211
|
-
includePayloads: false
|
|
212
|
-
},
|
|
213
|
-
session: {
|
|
214
|
-
timestampSkewSeconds: 120,
|
|
215
|
-
ttlMinutes: 30
|
|
216
|
-
},
|
|
217
|
-
platform: {
|
|
218
|
-
type: 'node'
|
|
219
|
-
},
|
|
220
|
-
metadata: {
|
|
221
|
-
version: '1.5.0',
|
|
222
|
-
lastUpdated: new Date().toISOString(),
|
|
223
|
-
source: 'dashboard'
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
mockFetch.mockResolvedValue({
|
|
228
|
-
ok: true,
|
|
229
|
-
json: async () => ({
|
|
230
|
-
success: true,
|
|
231
|
-
data: { config: oldFormatConfig }
|
|
232
|
-
})
|
|
233
|
-
} as Response);
|
|
234
|
-
|
|
235
|
-
const options: RemoteConfigOptions = {
|
|
236
|
-
apiUrl: 'https://kya.vouched.id',
|
|
237
|
-
apiKey: 'test-key',
|
|
238
|
-
projectId: 'test-project',
|
|
239
|
-
fetchProvider: mockFetch
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
243
|
-
|
|
244
|
-
// Should not throw and should return config (implementation will add empty tools)
|
|
245
|
-
expect(result).toBeDefined();
|
|
246
|
-
// Current implementation doesn't handle this - test documents expected behavior
|
|
247
|
-
// After implementation, toolProtection.tools should default to {}
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
describe('Response format with embedded tools', () => {
|
|
252
|
-
it('should handle response with deprecated top-level toolProtections field', async () => {
|
|
253
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
254
|
-
|
|
255
|
-
const mergedConfig = {
|
|
256
|
-
identity: {
|
|
257
|
-
serverDid: 'did:key:test',
|
|
258
|
-
environment: 'production',
|
|
259
|
-
storageLocation: 'cloudflare-kv'
|
|
260
|
-
},
|
|
261
|
-
proofing: {
|
|
262
|
-
enabled: false,
|
|
263
|
-
destinations: [],
|
|
264
|
-
batchQueue: { maxBatchSize: 10, flushIntervalMs: 5000, maxRetries: 3 }
|
|
265
|
-
},
|
|
266
|
-
delegation: {
|
|
267
|
-
enabled: false,
|
|
268
|
-
enforceStrictly: false,
|
|
269
|
-
verifier: { type: 'memory' },
|
|
270
|
-
authorization: {}
|
|
271
|
-
},
|
|
272
|
-
toolProtection: {
|
|
273
|
-
source: 'agentshield',
|
|
274
|
-
tools: {
|
|
275
|
-
greet: { requiresDelegation: true, requiredScopes: ['greeting:write'] }
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
audit: {
|
|
279
|
-
enabled: false,
|
|
280
|
-
includeProofHashes: false,
|
|
281
|
-
includePayloads: false
|
|
282
|
-
},
|
|
283
|
-
session: {
|
|
284
|
-
timestampSkewSeconds: 120,
|
|
285
|
-
ttlMinutes: 30
|
|
286
|
-
},
|
|
287
|
-
platform: {
|
|
288
|
-
type: 'node'
|
|
289
|
-
},
|
|
290
|
-
metadata: {
|
|
291
|
-
version: '1.6.0',
|
|
292
|
-
lastUpdated: new Date().toISOString(),
|
|
293
|
-
source: 'dashboard'
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
// Response includes both embedded tools and deprecated top-level field
|
|
298
|
-
mockFetch.mockResolvedValue({
|
|
299
|
-
ok: true,
|
|
300
|
-
json: async () => ({
|
|
301
|
-
success: true,
|
|
302
|
-
data: {
|
|
303
|
-
config: mergedConfig,
|
|
304
|
-
// Deprecated: This field exists for backward compatibility
|
|
305
|
-
toolProtections: {
|
|
306
|
-
greet: { requiresDelegation: true, requiredScopes: ['greeting:write'] }
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
metadata: {
|
|
310
|
-
timestamp: new Date().toISOString(),
|
|
311
|
-
cachedUntil: new Date(Date.now() + 60000).toISOString()
|
|
312
|
-
}
|
|
313
|
-
})
|
|
314
|
-
} as Response);
|
|
315
|
-
|
|
316
|
-
const options: RemoteConfigOptions = {
|
|
317
|
-
apiUrl: 'https://kya.vouched.id',
|
|
318
|
-
apiKey: 'test-key',
|
|
319
|
-
projectId: 'test-project',
|
|
320
|
-
fetchProvider: mockFetch
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
324
|
-
|
|
325
|
-
expect(result).toBeDefined();
|
|
326
|
-
// Should use config.toolProtection.tools (embedded), not top-level toolProtections
|
|
327
|
-
expect(result?.toolProtection?.tools?.greet).toEqual({
|
|
328
|
-
requiresDelegation: true,
|
|
329
|
-
requiredScopes: ['greeting:write']
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
describe('Caching with merged config', () => {
|
|
335
|
-
it('should cache merged config correctly', async () => {
|
|
336
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
337
|
-
|
|
338
|
-
const mergedConfig = {
|
|
339
|
-
identity: {
|
|
340
|
-
serverDid: 'did:key:test',
|
|
341
|
-
environment: 'production',
|
|
342
|
-
storageLocation: 'cloudflare-kv'
|
|
343
|
-
},
|
|
344
|
-
proofing: {
|
|
345
|
-
enabled: false,
|
|
346
|
-
destinations: [],
|
|
347
|
-
batchQueue: { maxBatchSize: 10, flushIntervalMs: 5000, maxRetries: 3 }
|
|
348
|
-
},
|
|
349
|
-
delegation: {
|
|
350
|
-
enabled: false,
|
|
351
|
-
enforceStrictly: false,
|
|
352
|
-
verifier: { type: 'memory' },
|
|
353
|
-
authorization: {}
|
|
354
|
-
},
|
|
355
|
-
toolProtection: {
|
|
356
|
-
source: 'agentshield',
|
|
357
|
-
tools: {
|
|
358
|
-
greet: { requiresDelegation: true, requiredScopes: ['greeting:write'] }
|
|
359
|
-
}
|
|
360
|
-
},
|
|
361
|
-
audit: {
|
|
362
|
-
enabled: false,
|
|
363
|
-
includeProofHashes: false,
|
|
364
|
-
includePayloads: false
|
|
365
|
-
},
|
|
366
|
-
session: {
|
|
367
|
-
timestampSkewSeconds: 120,
|
|
368
|
-
ttlMinutes: 30
|
|
369
|
-
},
|
|
370
|
-
platform: {
|
|
371
|
-
type: 'node'
|
|
372
|
-
},
|
|
373
|
-
metadata: {
|
|
374
|
-
version: '1.6.0',
|
|
375
|
-
lastUpdated: new Date().toISOString(),
|
|
376
|
-
source: 'dashboard'
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
mockFetch.mockResolvedValue({
|
|
381
|
-
ok: true,
|
|
382
|
-
json: async () => ({
|
|
383
|
-
success: true,
|
|
384
|
-
data: { config: mergedConfig }
|
|
385
|
-
})
|
|
386
|
-
} as Response);
|
|
387
|
-
|
|
388
|
-
const options: RemoteConfigOptions = {
|
|
389
|
-
apiUrl: 'https://kya.vouched.id',
|
|
390
|
-
apiKey: 'test-key',
|
|
391
|
-
projectId: 'test-project',
|
|
392
|
-
fetchProvider: mockFetch,
|
|
393
|
-
cacheTtl: 300000
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
await fetchRemoteConfig(options, mockCache);
|
|
397
|
-
|
|
398
|
-
expect(mockCache.set).toHaveBeenCalledWith(
|
|
399
|
-
'config:project:test-project',
|
|
400
|
-
expect.stringContaining('toolProtection'),
|
|
401
|
-
300000
|
|
402
|
-
);
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
it('should return cached merged config with embedded tools', async () => {
|
|
406
|
-
const cachedConfig = {
|
|
407
|
-
identity: {
|
|
408
|
-
serverDid: 'did:key:test',
|
|
409
|
-
environment: 'production',
|
|
410
|
-
storageLocation: 'cloudflare-kv'
|
|
411
|
-
},
|
|
412
|
-
toolProtection: {
|
|
413
|
-
source: 'agentshield',
|
|
414
|
-
tools: {
|
|
415
|
-
greet: { requiresDelegation: true, requiredScopes: ['greeting:write'] }
|
|
416
|
-
}
|
|
417
|
-
},
|
|
418
|
-
// ... other fields
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
vi.mocked(mockCache.get).mockResolvedValue(
|
|
422
|
-
JSON.stringify({
|
|
423
|
-
config: cachedConfig,
|
|
424
|
-
expiresAt: Date.now() + 60000
|
|
425
|
-
})
|
|
426
|
-
);
|
|
427
|
-
|
|
428
|
-
const options: RemoteConfigOptions = {
|
|
429
|
-
apiUrl: 'https://kya.vouched.id',
|
|
430
|
-
apiKey: 'test-key',
|
|
431
|
-
projectId: 'test-project',
|
|
432
|
-
fetchProvider: mockFetch
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
436
|
-
|
|
437
|
-
expect(result?.toolProtection?.tools?.greet).toEqual({
|
|
438
|
-
requiresDelegation: true,
|
|
439
|
-
requiredScopes: ['greeting:write']
|
|
440
|
-
});
|
|
441
|
-
expect(mockFetch).not.toHaveBeenCalled();
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
});
|
|
445
|
-
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for Remote Configuration Fetching
|
|
3
|
-
*
|
|
4
|
-
* Validates that remote config fetching works correctly with caching
|
|
5
|
-
* and fallback behavior.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
9
|
-
import {
|
|
10
|
-
fetchRemoteConfig,
|
|
11
|
-
type RemoteConfigOptions,
|
|
12
|
-
type RemoteConfigCache
|
|
13
|
-
} from '../remote-config.js';
|
|
14
|
-
import type { MCPIConfig } from '@kya-os/contracts/config';
|
|
15
|
-
|
|
16
|
-
describe('fetchRemoteConfig', () => {
|
|
17
|
-
let mockFetch: ReturnType<typeof vi.fn>;
|
|
18
|
-
let mockCache: RemoteConfigCache;
|
|
19
|
-
|
|
20
|
-
beforeEach(() => {
|
|
21
|
-
mockFetch = vi.fn();
|
|
22
|
-
mockCache = {
|
|
23
|
-
get: vi.fn(),
|
|
24
|
-
set: vi.fn()
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe('Cache hit scenario', () => {
|
|
29
|
-
it('should return cached config if available and not expired', async () => {
|
|
30
|
-
const cachedConfig: MCPIConfig = {
|
|
31
|
-
environment: 'production',
|
|
32
|
-
identity: { enabled: true, environment: 'production' }
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
vi.mocked(mockCache.get).mockResolvedValue(
|
|
36
|
-
JSON.stringify({
|
|
37
|
-
config: cachedConfig,
|
|
38
|
-
expiresAt: Date.now() + 60000 // 1 minute in future
|
|
39
|
-
})
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const options: RemoteConfigOptions = {
|
|
43
|
-
apiUrl: 'https://kya.vouched.id',
|
|
44
|
-
apiKey: 'test-key',
|
|
45
|
-
projectId: 'test-project',
|
|
46
|
-
fetchProvider: mockFetch
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
50
|
-
|
|
51
|
-
expect(result).toEqual(cachedConfig);
|
|
52
|
-
expect(mockCache.get).toHaveBeenCalledWith('config:project:test-project');
|
|
53
|
-
expect(mockFetch).not.toHaveBeenCalled();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('should fetch fresh config if cache expired', async () => {
|
|
57
|
-
const cachedConfig: MCPIConfig = {
|
|
58
|
-
environment: 'production'
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
vi.mocked(mockCache.get).mockResolvedValue(
|
|
62
|
-
JSON.stringify({
|
|
63
|
-
config: cachedConfig,
|
|
64
|
-
expiresAt: Date.now() - 1000 // Expired
|
|
65
|
-
})
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const freshConfig: MCPIConfig = {
|
|
69
|
-
environment: 'production',
|
|
70
|
-
identity: { enabled: true, environment: 'production' }
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
mockFetch.mockResolvedValue({
|
|
74
|
-
ok: true,
|
|
75
|
-
json: async () => ({ success: true, data: freshConfig })
|
|
76
|
-
} as Response);
|
|
77
|
-
|
|
78
|
-
const options: RemoteConfigOptions = {
|
|
79
|
-
apiUrl: 'https://kya.vouched.id',
|
|
80
|
-
apiKey: 'test-key',
|
|
81
|
-
projectId: 'test-project',
|
|
82
|
-
fetchProvider: mockFetch
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
86
|
-
|
|
87
|
-
expect(result).toEqual(freshConfig);
|
|
88
|
-
expect(mockFetch).toHaveBeenCalled();
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe('Cache miss scenario', () => {
|
|
93
|
-
it('should fetch from API when cache is empty', async () => {
|
|
94
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
95
|
-
|
|
96
|
-
const config: MCPIConfig = {
|
|
97
|
-
environment: 'production',
|
|
98
|
-
identity: { enabled: true, environment: 'production' }
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
mockFetch.mockResolvedValue({
|
|
102
|
-
ok: true,
|
|
103
|
-
json: async () => ({ success: true, data: config })
|
|
104
|
-
} as Response);
|
|
105
|
-
|
|
106
|
-
const options: RemoteConfigOptions = {
|
|
107
|
-
apiUrl: 'https://kya.vouched.id',
|
|
108
|
-
apiKey: 'test-key',
|
|
109
|
-
projectId: 'test-project',
|
|
110
|
-
fetchProvider: mockFetch
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
114
|
-
|
|
115
|
-
expect(result).toEqual(config);
|
|
116
|
-
expect(mockCache.set).toHaveBeenCalled();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should use agentDid when projectId not available', async () => {
|
|
120
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
121
|
-
|
|
122
|
-
const config: MCPIConfig = {
|
|
123
|
-
environment: 'production'
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
mockFetch.mockResolvedValue({
|
|
127
|
-
ok: true,
|
|
128
|
-
json: async () => ({ success: true, data: config })
|
|
129
|
-
} as Response);
|
|
130
|
-
|
|
131
|
-
const options: RemoteConfigOptions = {
|
|
132
|
-
apiUrl: 'https://kya.vouched.id',
|
|
133
|
-
apiKey: 'test-key',
|
|
134
|
-
agentDid: 'did:key:test',
|
|
135
|
-
fetchProvider: mockFetch
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
139
|
-
|
|
140
|
-
expect(result).toEqual(config);
|
|
141
|
-
expect(mockCache.get).toHaveBeenCalledWith('config:agent:did:key:test');
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe('Error handling', () => {
|
|
146
|
-
it('should return null if API request fails', async () => {
|
|
147
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
148
|
-
|
|
149
|
-
mockFetch.mockResolvedValue({
|
|
150
|
-
ok: false,
|
|
151
|
-
status: 404,
|
|
152
|
-
statusText: 'Not Found'
|
|
153
|
-
} as Response);
|
|
154
|
-
|
|
155
|
-
const options: RemoteConfigOptions = {
|
|
156
|
-
apiUrl: 'https://kya.vouched.id',
|
|
157
|
-
apiKey: 'test-key',
|
|
158
|
-
projectId: 'test-project',
|
|
159
|
-
fetchProvider: mockFetch
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
163
|
-
|
|
164
|
-
expect(result).toBeNull();
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('should return null if API throws error', async () => {
|
|
168
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
169
|
-
|
|
170
|
-
mockFetch.mockRejectedValue(new Error('Network error'));
|
|
171
|
-
|
|
172
|
-
const options: RemoteConfigOptions = {
|
|
173
|
-
apiUrl: 'https://kya.vouched.id',
|
|
174
|
-
apiKey: 'test-key',
|
|
175
|
-
projectId: 'test-project',
|
|
176
|
-
fetchProvider: mockFetch
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
180
|
-
|
|
181
|
-
expect(result).toBeNull();
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('should return null if neither projectId nor agentDid provided', async () => {
|
|
185
|
-
const options: RemoteConfigOptions = {
|
|
186
|
-
apiUrl: 'https://kya.vouched.id',
|
|
187
|
-
apiKey: 'test-key',
|
|
188
|
-
fetchProvider: mockFetch
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
192
|
-
|
|
193
|
-
expect(result).toBeNull();
|
|
194
|
-
expect(mockFetch).not.toHaveBeenCalled();
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it('should handle cache read errors gracefully', async () => {
|
|
198
|
-
vi.mocked(mockCache.get).mockRejectedValue(new Error('Cache error'));
|
|
199
|
-
|
|
200
|
-
const config: MCPIConfig = {
|
|
201
|
-
environment: 'production'
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
mockFetch.mockResolvedValue({
|
|
205
|
-
ok: true,
|
|
206
|
-
json: async () => ({ success: true, data: config })
|
|
207
|
-
} as Response);
|
|
208
|
-
|
|
209
|
-
const options: RemoteConfigOptions = {
|
|
210
|
-
apiUrl: 'https://kya.vouched.id',
|
|
211
|
-
apiKey: 'test-key',
|
|
212
|
-
projectId: 'test-project',
|
|
213
|
-
fetchProvider: mockFetch
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const result = await fetchRemoteConfig(options, mockCache);
|
|
217
|
-
|
|
218
|
-
expect(result).toEqual(config);
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
describe('Response format handling', () => {
|
|
223
|
-
it('should handle different API response formats', async () => {
|
|
224
|
-
vi.mocked(mockCache.get).mockResolvedValue(null);
|
|
225
|
-
|
|
226
|
-
const config: MCPIConfig = {
|
|
227
|
-
environment: 'production'
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
// Format 1: { config: {...} }
|
|
231
|
-
mockFetch.mockResolvedValueOnce({
|
|
232
|
-
ok: true,
|
|
233
|
-
json: async () => ({ config })
|
|
234
|
-
} as Response);
|
|
235
|
-
|
|
236
|
-
const options: RemoteConfigOptions = {
|
|
237
|
-
apiUrl: 'https://kya.vouched.id',
|
|
238
|
-
apiKey: 'test-key',
|
|
239
|
-
projectId: 'test-project',
|
|
240
|
-
fetchProvider: mockFetch
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const result1 = await fetchRemoteConfig(options, mockCache);
|
|
244
|
-
expect(result1).toEqual(config);
|
|
245
|
-
|
|
246
|
-
// Format 2: { data: { config: {...} } }
|
|
247
|
-
mockCache.get.mockResolvedValue(null);
|
|
248
|
-
mockFetch.mockResolvedValueOnce({
|
|
249
|
-
ok: true,
|
|
250
|
-
json: async () => ({ data: { config } })
|
|
251
|
-
} as Response);
|
|
252
|
-
|
|
253
|
-
const result2 = await fetchRemoteConfig(options, mockCache);
|
|
254
|
-
expect(result2).toEqual(config);
|
|
255
|
-
|
|
256
|
-
// Format 3: { success: true, data: {...} }
|
|
257
|
-
mockCache.get.mockResolvedValue(null);
|
|
258
|
-
mockFetch.mockResolvedValueOnce({
|
|
259
|
-
ok: true,
|
|
260
|
-
json: async () => ({ success: true, data: config })
|
|
261
|
-
} as Response);
|
|
262
|
-
|
|
263
|
-
const result3 = await fetchRemoteConfig(options, mockCache);
|
|
264
|
-
expect(result3).toEqual(config);
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|