@kya-os/mcp-i-core 1.3.10 → 1.3.11
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/.claude/settings.local.json +9 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test$colon$coverage.log +3419 -3072
- package/.turbo/turbo-test.log +1805 -1680
- package/coverage/coverage-final.json +60 -0
- package/dist/identity/idp-token-resolver.d.ts +17 -1
- package/dist/identity/idp-token-resolver.d.ts.map +1 -1
- package/dist/identity/idp-token-resolver.js +34 -6
- package/dist/identity/idp-token-resolver.js.map +1 -1
- package/dist/identity/idp-token-storage.interface.d.ts +38 -7
- package/dist/identity/idp-token-storage.interface.d.ts.map +1 -1
- package/dist/identity/idp-token-storage.interface.js +2 -0
- package/dist/identity/idp-token-storage.interface.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/tool-context-builder.d.ts +18 -1
- package/dist/services/tool-context-builder.d.ts.map +1 -1
- package/dist/services/tool-context-builder.js +63 -10
- package/dist/services/tool-context-builder.js.map +1 -1
- package/dist/services/tool-protection.service.d.ts +1 -1
- package/dist/services/tool-protection.service.d.ts.map +1 -1
- package/dist/services/tool-protection.service.js +17 -10
- package/dist/services/tool-protection.service.js.map +1 -1
- package/dist/utils/did-helpers.d.ts +33 -0
- package/dist/utils/did-helpers.d.ts.map +1 -1
- package/dist/utils/did-helpers.js +53 -0
- package/dist/utils/did-helpers.js.map +1 -1
- package/package.json +1 -1
- package/src/delegation/__tests__/vc-issuer.test.ts +1 -1
- package/src/identity/idp-token-resolver.ts +41 -7
- package/src/identity/idp-token-storage.interface.ts +42 -7
- package/src/index.ts +6 -2
- package/src/services/tool-context-builder.ts +75 -10
- package/src/services/tool-protection.service.ts +51 -32
- package/src/utils/__tests__/did-helpers.test.ts +55 -0
- package/src/utils/did-helpers.ts +60 -0
- package/dist/__tests__/utils/mock-providers.d.ts +0 -104
- package/dist/__tests__/utils/mock-providers.d.ts.map +0 -1
- package/dist/__tests__/utils/mock-providers.js +0 -293
- package/dist/__tests__/utils/mock-providers.js.map +0 -1
|
@@ -266,7 +266,10 @@ export class ToolProtectionService {
|
|
|
266
266
|
projectId: this.config.projectId || "none",
|
|
267
267
|
toolCount: Object.keys(cached.toolProtections).length,
|
|
268
268
|
protectedTools: Object.entries(cached.toolProtections)
|
|
269
|
-
.filter(
|
|
269
|
+
.filter(
|
|
270
|
+
([_, config]: [string, ToolProtection]) =>
|
|
271
|
+
config.requiresDelegation
|
|
272
|
+
)
|
|
270
273
|
.map(([name]) => name),
|
|
271
274
|
cacheTtlMs: ttl,
|
|
272
275
|
cachedUntil,
|
|
@@ -369,13 +372,13 @@ export class ToolProtectionService {
|
|
|
369
372
|
(toolConfig as any).required_scopes ??
|
|
370
373
|
(toolConfig as any).scopes ??
|
|
371
374
|
[];
|
|
372
|
-
|
|
375
|
+
|
|
373
376
|
// NEW: Parse oauthProvider (camelCase and snake_case support)
|
|
374
377
|
const oauthProvider =
|
|
375
378
|
(toolConfig as any).oauthProvider ??
|
|
376
379
|
(toolConfig as any).oauth_provider ??
|
|
377
380
|
undefined;
|
|
378
|
-
|
|
381
|
+
|
|
379
382
|
const riskLevel =
|
|
380
383
|
(toolConfig as any).riskLevel ??
|
|
381
384
|
(toolConfig as any).risk_level ??
|
|
@@ -414,17 +417,15 @@ export class ToolProtectionService {
|
|
|
414
417
|
(tool as any).required_scopes ??
|
|
415
418
|
(tool as any).scopes ??
|
|
416
419
|
[];
|
|
417
|
-
|
|
420
|
+
|
|
418
421
|
// NEW: Parse oauthProvider
|
|
419
422
|
const oauthProvider =
|
|
420
423
|
(tool as any).oauthProvider ??
|
|
421
424
|
(tool as any).oauth_provider ??
|
|
422
425
|
undefined;
|
|
423
|
-
|
|
426
|
+
|
|
424
427
|
const riskLevel =
|
|
425
|
-
(tool as any).riskLevel ??
|
|
426
|
-
(tool as any).risk_level ??
|
|
427
|
-
undefined;
|
|
428
|
+
(tool as any).riskLevel ?? (tool as any).risk_level ?? undefined;
|
|
428
429
|
|
|
429
430
|
toolProtections[toolName] = {
|
|
430
431
|
requiresDelegation,
|
|
@@ -448,13 +449,13 @@ export class ToolProtectionService {
|
|
|
448
449
|
(toolConfig as any).required_scopes ??
|
|
449
450
|
(toolConfig as any).scopes ??
|
|
450
451
|
[];
|
|
451
|
-
|
|
452
|
+
|
|
452
453
|
// NEW: Parse oauthProvider
|
|
453
454
|
const oauthProvider =
|
|
454
455
|
(toolConfig as any).oauthProvider ??
|
|
455
456
|
(toolConfig as any).oauth_provider ??
|
|
456
457
|
undefined;
|
|
457
|
-
|
|
458
|
+
|
|
458
459
|
const riskLevel =
|
|
459
460
|
(toolConfig as any).riskLevel ??
|
|
460
461
|
(toolConfig as any).risk_level ??
|
|
@@ -480,7 +481,11 @@ export class ToolProtectionService {
|
|
|
480
481
|
)) {
|
|
481
482
|
// Skip if localConfig is empty or not a valid ToolProtection object
|
|
482
483
|
// This prevents empty objects from corrupting the merged config
|
|
483
|
-
if (
|
|
484
|
+
if (
|
|
485
|
+
!localConfig ||
|
|
486
|
+
typeof localConfig !== "object" ||
|
|
487
|
+
Object.keys(localConfig).length === 0
|
|
488
|
+
) {
|
|
484
489
|
if (this.config.debug) {
|
|
485
490
|
console.log(
|
|
486
491
|
"[ToolProtectionService] Skipping empty/invalid fallback config entry",
|
|
@@ -489,13 +494,14 @@ export class ToolProtectionService {
|
|
|
489
494
|
}
|
|
490
495
|
continue;
|
|
491
496
|
}
|
|
492
|
-
|
|
497
|
+
|
|
493
498
|
// Ensure requiredScopes exists (default to empty array if missing)
|
|
494
499
|
const validConfig: ToolProtection = {
|
|
495
|
-
requiresDelegation:
|
|
500
|
+
requiresDelegation:
|
|
501
|
+
(localConfig as any).requiresDelegation ?? false,
|
|
496
502
|
requiredScopes: (localConfig as any).requiredScopes ?? [],
|
|
497
503
|
};
|
|
498
|
-
|
|
504
|
+
|
|
499
505
|
// Local config overrides API config for this tool
|
|
500
506
|
mergedToolProtections[toolName] = validConfig;
|
|
501
507
|
if (this.config.debug) {
|
|
@@ -524,8 +530,10 @@ export class ToolProtectionService {
|
|
|
524
530
|
console.log("[ToolProtectionService] Config loaded from API", {
|
|
525
531
|
source: "api",
|
|
526
532
|
toolCount: Object.keys(mergedToolProtections).length,
|
|
527
|
-
|
|
528
|
-
.filter(
|
|
533
|
+
protectedTools: Object.entries(mergedToolProtections)
|
|
534
|
+
.filter(
|
|
535
|
+
([_, config]: [string, ToolProtection]) => config.requiresDelegation
|
|
536
|
+
)
|
|
529
537
|
.map(([name]) => name),
|
|
530
538
|
agentDid: agentDid.slice(0, 20) + "...",
|
|
531
539
|
projectId: this.config.projectId || "none",
|
|
@@ -885,28 +893,28 @@ export class ToolProtectionService {
|
|
|
885
893
|
|
|
886
894
|
/**
|
|
887
895
|
* Clear cache and immediately fetch fresh config from API
|
|
888
|
-
*
|
|
896
|
+
*
|
|
889
897
|
* This method is designed for Cloudflare Workers where KV has edge caching.
|
|
890
898
|
* After clearing the KV entry, it fetches fresh data from the API and writes
|
|
891
899
|
* it back to KV. This ensures:
|
|
892
900
|
* 1. The global KV entry is deleted
|
|
893
901
|
* 2. Fresh data is fetched from API (with CDN cache bypass!)
|
|
894
902
|
* 3. New data is written to KV (updating edge cache)
|
|
895
|
-
*
|
|
903
|
+
*
|
|
896
904
|
* The next request from the same edge location will get the fresh data.
|
|
897
|
-
*
|
|
905
|
+
*
|
|
898
906
|
* IMPORTANT: This method uses bypassCDNCache to ensure we get fresh data
|
|
899
907
|
* from AgentShield's origin server, not stale CDN-cached data. This is
|
|
900
908
|
* critical for instant cache invalidation when tool protection settings
|
|
901
909
|
* are changed in the AgentShield dashboard.
|
|
902
|
-
*
|
|
910
|
+
*
|
|
903
911
|
* @param agentDid DID of the agent (used for cache key)
|
|
904
912
|
* @returns The fresh tool protection config from API
|
|
905
913
|
*/
|
|
906
914
|
async clearAndRefresh(agentDid: string): Promise<{
|
|
907
915
|
config: ToolProtectionConfig;
|
|
908
916
|
cacheKey: string;
|
|
909
|
-
source:
|
|
917
|
+
source: "api" | "fallback";
|
|
910
918
|
}> {
|
|
911
919
|
const cacheKey = this.config.projectId
|
|
912
920
|
? `config:tool-protections:${this.config.projectId}`
|
|
@@ -926,7 +934,9 @@ export class ToolProtectionService {
|
|
|
926
934
|
// 2. Fetch fresh config from API with CDN cache bypass
|
|
927
935
|
// This ensures we get fresh data from origin, not stale CDN data
|
|
928
936
|
try {
|
|
929
|
-
const response = await this.fetchFromApi(agentDid, {
|
|
937
|
+
const response = await this.fetchFromApi(agentDid, {
|
|
938
|
+
bypassCDNCache: true,
|
|
939
|
+
});
|
|
930
940
|
|
|
931
941
|
// Transform API response to internal format (same logic as getToolProtectionConfig)
|
|
932
942
|
const toolProtections: Record<string, ToolProtection> = {};
|
|
@@ -966,15 +976,20 @@ export class ToolProtectionService {
|
|
|
966
976
|
const toolName = (tool as any).name;
|
|
967
977
|
if (!toolName) continue;
|
|
968
978
|
const requiresDelegation =
|
|
969
|
-
(tool as any).requiresDelegation ??
|
|
979
|
+
(tool as any).requiresDelegation ??
|
|
980
|
+
(tool as any).requires_delegation ??
|
|
981
|
+
false;
|
|
970
982
|
const requiredScopes =
|
|
971
983
|
(tool as any).requiredScopes ??
|
|
972
984
|
(tool as any).required_scopes ??
|
|
973
985
|
(tool as any).scopes ??
|
|
974
986
|
[];
|
|
975
987
|
const oauthProvider =
|
|
976
|
-
(tool as any).oauthProvider ??
|
|
977
|
-
|
|
988
|
+
(tool as any).oauthProvider ??
|
|
989
|
+
(tool as any).oauth_provider ??
|
|
990
|
+
undefined;
|
|
991
|
+
const riskLevel =
|
|
992
|
+
(tool as any).riskLevel ?? (tool as any).risk_level ?? undefined;
|
|
978
993
|
|
|
979
994
|
toolProtections[toolName] = {
|
|
980
995
|
requiresDelegation,
|
|
@@ -1033,19 +1048,23 @@ export class ToolProtectionService {
|
|
|
1033
1048
|
source: "api",
|
|
1034
1049
|
});
|
|
1035
1050
|
|
|
1036
|
-
return { config: freshConfig, cacheKey, source:
|
|
1051
|
+
return { config: freshConfig, cacheKey, source: "api" };
|
|
1037
1052
|
} catch (error) {
|
|
1038
|
-
console.warn(
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1053
|
+
console.warn(
|
|
1054
|
+
"[ToolProtectionService] API fetch failed during refresh, using fallback",
|
|
1055
|
+
{
|
|
1056
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1057
|
+
cacheKey,
|
|
1058
|
+
}
|
|
1059
|
+
);
|
|
1042
1060
|
|
|
1043
1061
|
// Use fallback config if API fails
|
|
1044
|
-
const fallbackConfig: ToolProtectionConfig = this.config
|
|
1062
|
+
const fallbackConfig: ToolProtectionConfig = this.config
|
|
1063
|
+
.fallbackConfig || {
|
|
1045
1064
|
toolProtections: {},
|
|
1046
1065
|
};
|
|
1047
1066
|
|
|
1048
|
-
return { config: fallbackConfig, cacheKey, source:
|
|
1067
|
+
return { config: fallbackConfig, cacheKey, source: "fallback" };
|
|
1049
1068
|
}
|
|
1050
1069
|
}
|
|
1051
1070
|
}
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
normalizeDid,
|
|
12
12
|
compareDids,
|
|
13
13
|
getServerDid,
|
|
14
|
+
generateDidKeyFromBytes,
|
|
15
|
+
generateDidKeyFromBase64,
|
|
14
16
|
} from "../did-helpers";
|
|
15
17
|
|
|
16
18
|
describe("DID Helpers", () => {
|
|
@@ -97,5 +99,58 @@ describe("DID Helpers", () => {
|
|
|
97
99
|
expect(() => getServerDid(config)).toThrow("Server DID not configured");
|
|
98
100
|
});
|
|
99
101
|
});
|
|
102
|
+
|
|
103
|
+
describe("generateDidKeyFromBytes", () => {
|
|
104
|
+
it("should generate valid did:key from 32-byte Ed25519 public key", () => {
|
|
105
|
+
// Use a known test key (32 bytes)
|
|
106
|
+
const publicKeyBytes = new Uint8Array(32).fill(0xab);
|
|
107
|
+
const did = generateDidKeyFromBytes(publicKeyBytes);
|
|
108
|
+
|
|
109
|
+
expect(did).toMatch(/^did:key:z6Mk/);
|
|
110
|
+
expect(isValidDid(did)).toBe(true);
|
|
111
|
+
expect(getDidMethod(did)).toBe("key");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("should generate consistent did:key for same input", () => {
|
|
115
|
+
const publicKeyBytes = new Uint8Array(32).fill(0x42);
|
|
116
|
+
const did1 = generateDidKeyFromBytes(publicKeyBytes);
|
|
117
|
+
const did2 = generateDidKeyFromBytes(publicKeyBytes);
|
|
118
|
+
|
|
119
|
+
expect(did1).toBe(did2);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("should generate different did:key for different inputs", () => {
|
|
123
|
+
const key1 = new Uint8Array(32).fill(0x11);
|
|
124
|
+
const key2 = new Uint8Array(32).fill(0x22);
|
|
125
|
+
|
|
126
|
+
const did1 = generateDidKeyFromBytes(key1);
|
|
127
|
+
const did2 = generateDidKeyFromBytes(key2);
|
|
128
|
+
|
|
129
|
+
expect(did1).not.toBe(did2);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe("generateDidKeyFromBase64", () => {
|
|
134
|
+
it("should generate valid did:key from base64-encoded public key", () => {
|
|
135
|
+
// Base64 encode a 32-byte key
|
|
136
|
+
const publicKeyBytes = new Uint8Array(32).fill(0xcd);
|
|
137
|
+
const publicKeyBase64 = btoa(String.fromCharCode(...publicKeyBytes));
|
|
138
|
+
|
|
139
|
+
const did = generateDidKeyFromBase64(publicKeyBase64);
|
|
140
|
+
|
|
141
|
+
expect(did).toMatch(/^did:key:z6Mk/);
|
|
142
|
+
expect(isValidDid(did)).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("should produce same result as generateDidKeyFromBytes", () => {
|
|
146
|
+
const publicKeyBytes = new Uint8Array(32).fill(0xef);
|
|
147
|
+
const publicKeyBase64 = btoa(String.fromCharCode(...publicKeyBytes));
|
|
148
|
+
|
|
149
|
+
const didFromBytes = generateDidKeyFromBytes(publicKeyBytes);
|
|
150
|
+
const didFromBase64 = generateDidKeyFromBase64(publicKeyBase64);
|
|
151
|
+
|
|
152
|
+
expect(didFromBytes).toBe(didFromBase64);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
100
155
|
});
|
|
101
156
|
|
package/src/utils/did-helpers.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* @package @kya-os/mcp-i-core/utils
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { base58Encode } from "./base58";
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Check if a string is a valid DID format
|
|
12
14
|
*
|
|
@@ -148,3 +150,61 @@ export function extractAgentSlug(did: string): string {
|
|
|
148
150
|
return extractAgentId(did);
|
|
149
151
|
}
|
|
150
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Ed25519 multicodec prefix for did:key encoding
|
|
155
|
+
* As per https://w3c-ccg.github.io/did-method-key/
|
|
156
|
+
*/
|
|
157
|
+
const ED25519_MULTICODEC_PREFIX = new Uint8Array([0xed, 0x01]);
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Generate a did:key from Ed25519 public key bytes
|
|
161
|
+
*
|
|
162
|
+
* Following spec: https://w3c-ccg.github.io/did-method-key/
|
|
163
|
+
* Format: did:key:z<multibase-base58btc(<multicodec-ed25519-pub><publicKey>)>
|
|
164
|
+
*
|
|
165
|
+
* @param publicKeyBytes - Ed25519 public key as Uint8Array (32 bytes)
|
|
166
|
+
* @returns did:key string
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const publicKey = new Uint8Array(32); // 32-byte Ed25519 public key
|
|
171
|
+
* const did = generateDidKeyFromBytes(publicKey);
|
|
172
|
+
* // did = "did:key:z6Mk..."
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export function generateDidKeyFromBytes(publicKeyBytes: Uint8Array): string {
|
|
176
|
+
// Combine multicodec prefix + public key
|
|
177
|
+
const multicodecKey = new Uint8Array(
|
|
178
|
+
ED25519_MULTICODEC_PREFIX.length + publicKeyBytes.length
|
|
179
|
+
);
|
|
180
|
+
multicodecKey.set(ED25519_MULTICODEC_PREFIX);
|
|
181
|
+
multicodecKey.set(publicKeyBytes, ED25519_MULTICODEC_PREFIX.length);
|
|
182
|
+
|
|
183
|
+
// Base58-btc encode and add multibase prefix 'z'
|
|
184
|
+
const base58Encoded = base58Encode(multicodecKey);
|
|
185
|
+
return `did:key:z${base58Encoded}`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Generate a did:key from base64-encoded Ed25519 public key
|
|
190
|
+
*
|
|
191
|
+
* Convenience wrapper around generateDidKeyFromBytes for base64-encoded keys.
|
|
192
|
+
*
|
|
193
|
+
* @param publicKeyBase64 - Ed25519 public key as base64 string
|
|
194
|
+
* @returns did:key string
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const publicKeyBase64 = "...base64 encoded key...";
|
|
199
|
+
* const did = generateDidKeyFromBase64(publicKeyBase64);
|
|
200
|
+
* // did = "did:key:z6Mk..."
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export function generateDidKeyFromBase64(publicKeyBase64: string): string {
|
|
204
|
+
// Decode base64 to bytes
|
|
205
|
+
const publicKeyBytes = Uint8Array.from(atob(publicKeyBase64), (c) =>
|
|
206
|
+
c.charCodeAt(0)
|
|
207
|
+
);
|
|
208
|
+
return generateDidKeyFromBytes(publicKeyBytes);
|
|
209
|
+
}
|
|
210
|
+
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mock Providers for Testing
|
|
3
|
-
*
|
|
4
|
-
* These mock implementations allow controlled testing of the runtime
|
|
5
|
-
* and other components that depend on providers.
|
|
6
|
-
*/
|
|
7
|
-
import { vi } from 'vitest';
|
|
8
|
-
import { CryptoProvider, ClockProvider, FetchProvider, StorageProvider, NonceCacheProvider, IdentityProvider, AgentIdentity } from '../../providers/base';
|
|
9
|
-
/**
|
|
10
|
-
* Mock Crypto Provider
|
|
11
|
-
*/
|
|
12
|
-
export declare class MockCryptoProvider extends CryptoProvider {
|
|
13
|
-
sign(data: Uint8Array, privateKey: string): Promise<Uint8Array>;
|
|
14
|
-
verify(data: Uint8Array, signature: Uint8Array, publicKey: string): Promise<boolean>;
|
|
15
|
-
generateKeyPair(): Promise<{
|
|
16
|
-
privateKey: string;
|
|
17
|
-
publicKey: string;
|
|
18
|
-
}>;
|
|
19
|
-
hash(data: Uint8Array): Promise<Uint8Array>;
|
|
20
|
-
randomBytes(length: number): Promise<Uint8Array>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Mock Clock Provider
|
|
24
|
-
*/
|
|
25
|
-
export declare class MockClockProvider extends ClockProvider {
|
|
26
|
-
private currentTime;
|
|
27
|
-
setTime(timestamp: number): void;
|
|
28
|
-
now(): number;
|
|
29
|
-
isWithinSkew(timestamp: number, skewSeconds: number): boolean;
|
|
30
|
-
hasExpired(expiresAt: number): boolean;
|
|
31
|
-
calculateExpiry(ttlSeconds: number): number;
|
|
32
|
-
format(timestamp: number): string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Mock Fetch Provider
|
|
36
|
-
*/
|
|
37
|
-
export declare class MockFetchProvider extends FetchProvider {
|
|
38
|
-
private didDocuments;
|
|
39
|
-
private statusLists;
|
|
40
|
-
private delegationChains;
|
|
41
|
-
fetch: ReturnType<typeof vi.fn>;
|
|
42
|
-
constructor();
|
|
43
|
-
setDIDDocument(did: string, doc: any): void;
|
|
44
|
-
setStatusList(url: string, list: any): void;
|
|
45
|
-
setDelegationChain(id: string, chain: any[]): void;
|
|
46
|
-
resolveDID(did: string): Promise<any>;
|
|
47
|
-
fetchStatusList(url: string): Promise<any>;
|
|
48
|
-
fetchDelegationChain(id: string): Promise<any[]>;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Mock Storage Provider
|
|
52
|
-
*/
|
|
53
|
-
export declare class MockStorageProvider extends StorageProvider {
|
|
54
|
-
private store;
|
|
55
|
-
get(key: string): Promise<string | null>;
|
|
56
|
-
set(key: string, value: string): Promise<void>;
|
|
57
|
-
delete(key: string): Promise<void>;
|
|
58
|
-
exists(key: string): Promise<boolean>;
|
|
59
|
-
list(prefix?: string): Promise<string[]>;
|
|
60
|
-
clear(): void;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Mock Nonce Cache Provider
|
|
64
|
-
*/
|
|
65
|
-
export declare class MockNonceCacheProvider extends NonceCacheProvider {
|
|
66
|
-
private nonces;
|
|
67
|
-
cleanupCalled: boolean;
|
|
68
|
-
destroyCalled: boolean;
|
|
69
|
-
private clock?;
|
|
70
|
-
setClock(clock: ClockProvider): void;
|
|
71
|
-
has(nonce: string, agentDid?: string): Promise<boolean>;
|
|
72
|
-
add(nonce: string, ttlSeconds: number, agentDid?: string): Promise<void>;
|
|
73
|
-
cleanup(): Promise<void>;
|
|
74
|
-
destroy(): Promise<void>;
|
|
75
|
-
clear(): void;
|
|
76
|
-
size(): number;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Mock Identity Provider
|
|
80
|
-
*/
|
|
81
|
-
export declare class MockIdentityProvider extends IdentityProvider {
|
|
82
|
-
private identity?;
|
|
83
|
-
rotateKeysCalled: boolean;
|
|
84
|
-
deleteIdentityCalled: boolean;
|
|
85
|
-
private rotateCount;
|
|
86
|
-
constructor(identity?: AgentIdentity);
|
|
87
|
-
getIdentity(): Promise<AgentIdentity>;
|
|
88
|
-
saveIdentity(identity: AgentIdentity): Promise<void>;
|
|
89
|
-
rotateKeys(): Promise<AgentIdentity>;
|
|
90
|
-
deleteIdentity(): Promise<void>;
|
|
91
|
-
setIdentity(identity: AgentIdentity): void;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Create a full set of mock providers for testing
|
|
95
|
-
*/
|
|
96
|
-
export declare function createMockProviders(): {
|
|
97
|
-
cryptoProvider: MockCryptoProvider;
|
|
98
|
-
clockProvider: MockClockProvider;
|
|
99
|
-
fetchProvider: MockFetchProvider;
|
|
100
|
-
storageProvider: MockStorageProvider;
|
|
101
|
-
nonceCacheProvider: MockNonceCacheProvider;
|
|
102
|
-
identityProvider: MockIdentityProvider;
|
|
103
|
-
};
|
|
104
|
-
//# sourceMappingURL=mock-providers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-providers.d.ts","sourceRoot":"","sources":["../../../src/__tests__/utils/mock-providers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,cAAc;IAC9C,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAK/D,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMpF,eAAe,IAAI,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAwBrE,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAK3C,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAOvD;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,aAAa;IAClD,OAAO,CAAC,WAAW,CAAsB;IAEzC,OAAO,CAAC,SAAS,EAAE,MAAM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