@private.me/xbind 3.0.0 → 3.0.2
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 +55 -7
- package/dist-standalone/_deps/mldsa-wasm/dist/mldsa.js +1920 -1
- package/dist-standalone/_deps/shared/cjs/errors.js +729 -1
- package/dist-standalone/_deps/shared/cjs/index.js +463 -1
- package/dist-standalone/_deps/shared/cjs/types.js +315 -1
- package/dist-standalone/_deps/shared/errors.js +244 -1
- package/dist-standalone/_deps/shared/index.js +72 -1
- package/dist-standalone/_deps/shared/types.js +86 -1
- package/dist-standalone/_deps/ux-helpers/cjs/errors.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/index.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/pagination.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/progress.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/search.js +1 -1
- package/dist-standalone/_deps/ux-helpers/cjs/types.js +1 -1
- package/dist-standalone/_deps/ux-helpers/errors.js +1 -1
- package/dist-standalone/_deps/ux-helpers/index.js +1 -1
- package/dist-standalone/_deps/ux-helpers/pagination.js +1 -1
- package/dist-standalone/_deps/ux-helpers/progress.js +1 -1
- package/dist-standalone/_deps/ux-helpers/search.js +1 -1
- package/dist-standalone/_deps/xchange/auto-accept.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/auto-accept.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/errors.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/index.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/invite-client.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/lazy-init.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/trust-integration.js +1 -1
- package/dist-standalone/_deps/xchange/cjs/xchange.js +1 -1
- package/dist-standalone/_deps/xchange/errors.js +1 -1
- package/dist-standalone/_deps/xchange/index.js +1 -1
- package/dist-standalone/_deps/xchange/invite-client.js +1 -1
- package/dist-standalone/_deps/xchange/lazy-init.js +1 -1
- package/dist-standalone/_deps/xchange/trust-integration.js +1 -1
- package/dist-standalone/_deps/xchange/xchange.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/discovery.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/errors.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/index.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/registry.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/schema.js +1 -1
- package/dist-standalone/_deps/xregistry/cjs/types.js +1 -1
- package/dist-standalone/_deps/xregistry/discovery.js +1 -1
- package/dist-standalone/_deps/xregistry/errors.js +1 -1
- package/dist-standalone/_deps/xregistry/index.js +1 -1
- package/dist-standalone/_deps/xregistry/registry.js +1 -1
- package/dist-standalone/_deps/xregistry/schema.js +1 -1
- package/dist-standalone/_deps/xregistry/types.js +1 -1
- package/dist-standalone/agent-call.js +659 -1
- package/dist-standalone/agent-sdk.js +328 -1
- package/dist-standalone/agent.js +1800 -1
- package/dist-standalone/approval.js +193 -1
- package/dist-standalone/async-iterators.js +382 -1
- package/dist-standalone/auth.js +219 -1
- package/dist-standalone/auto-accept.js +229 -1
- package/dist-standalone/backup-config.js +201 -1
- package/dist-standalone/backup.js +326 -1
- package/dist-standalone/batch-operations.js +388 -1
- package/dist-standalone/cancellation.js +477 -1
- package/dist-standalone/checkpoint.js +186 -1
- package/dist-standalone/circuit-breaker.js +468 -1
- package/dist-standalone/cjs/agent-call.js +701 -1
- package/dist-standalone/cjs/agent-sdk.js +332 -1
- package/dist-standalone/cjs/agent.js +1837 -1
- package/dist-standalone/cjs/approval.js +199 -1
- package/dist-standalone/cjs/async-iterators.js +392 -1
- package/dist-standalone/cjs/auth.js +225 -1
- package/dist-standalone/cjs/auto-accept.js +233 -1
- package/dist-standalone/cjs/backup-config.js +207 -1
- package/dist-standalone/cjs/backup.js +330 -1
- package/dist-standalone/cjs/batch-operations.js +397 -1
- package/dist-standalone/cjs/cancellation.js +490 -1
- package/dist-standalone/cjs/checkpoint.js +193 -1
- package/dist-standalone/cjs/circuit-breaker.js +476 -1
- package/dist-standalone/cjs/cli/init.js +492 -1
- package/dist-standalone/cjs/config-validation.js +522 -1
- package/dist-standalone/cjs/connect.js +312 -1
- package/dist-standalone/cjs/connection-pool.js +506 -1
- package/dist-standalone/cjs/correlation-id.js +339 -1
- package/dist-standalone/cjs/crypto-utils.js +176 -1
- package/dist-standalone/cjs/debug-mode.js +534 -1
- package/dist-standalone/cjs/did-document.js +101 -1
- package/dist-standalone/cjs/did-privateme.js +130 -1
- package/dist-standalone/cjs/did-web.js +201 -1
- package/dist-standalone/cjs/discovery.js +462 -1
- package/dist-standalone/cjs/dual-mode.js +251 -1
- package/dist-standalone/cjs/email-templates.js +313 -1
- package/dist-standalone/cjs/email-transport.js +239 -1
- package/dist-standalone/cjs/envelope.js +538 -1
- package/dist-standalone/cjs/errors.js +913 -1
- package/dist-standalone/cjs/event-emitter.js +461 -1
- package/dist-standalone/cjs/gateway-state.js +55 -1
- package/dist-standalone/cjs/gateway-transport.js +120 -1
- package/dist-standalone/cjs/graceful-degradation.js +403 -1
- package/dist-standalone/cjs/guardrails.js +223 -1
- package/dist-standalone/cjs/health-check.js +336 -1
- package/dist-standalone/cjs/http-compat.js +272 -1
- package/dist-standalone/cjs/http-status-map.js +571 -1
- package/dist-standalone/cjs/identity.js +645 -1
- package/dist-standalone/cjs/index.js +406 -1
- package/dist-standalone/cjs/invitation.js +421 -1
- package/dist-standalone/cjs/invite.js +328 -1
- package/dist-standalone/cjs/key-agreement.js +335 -1
- package/dist-standalone/cjs/lazy-init.js +300 -1
- package/dist-standalone/cjs/logger.js +291 -1
- package/dist-standalone/cjs/mdns-discovery.js +202 -1
- package/dist-standalone/cjs/nonce-store.js +80 -1
- package/dist-standalone/cjs/pairing-manager.js +223 -1
- package/dist-standalone/cjs/plugin-system.js +264 -1
- package/dist-standalone/cjs/plugins/logging.js +168 -1
- package/dist-standalone/cjs/plugins/metrics.js +181 -1
- package/dist-standalone/cjs/plugins/validation.js +302 -1
- package/dist-standalone/cjs/policy.js +320 -1
- package/dist-standalone/cjs/progress-callbacks.js +583 -1
- package/dist-standalone/cjs/redis-nonce-store.js +76 -1
- package/dist-standalone/cjs/registry-middleware.js +50 -1
- package/dist-standalone/cjs/retry-strategies.js +544 -1
- package/dist-standalone/cjs/retry-transport.js +102 -1
- package/dist-standalone/cjs/runtime/browser.js +533 -1
- package/dist-standalone/cjs/runtime/edge.js +526 -1
- package/dist-standalone/cjs/runtime/react-native.js +394 -1
- package/dist-standalone/cjs/security-policy.js +245 -1
- package/dist-standalone/cjs/serialization.js +1040 -1
- package/dist-standalone/cjs/split-channel.js +225 -1
- package/dist-standalone/cjs/subscription-proof.js +230 -1
- package/dist-standalone/cjs/succession.js +148 -1
- package/dist-standalone/cjs/timeouts.js +412 -1
- package/dist-standalone/cjs/trace-context.js +424 -1
- package/dist-standalone/cjs/trace-spans.js +495 -1
- package/dist-standalone/cjs/transport.js +63 -1
- package/dist-standalone/cjs/trust-registry.js +991 -1
- package/dist-standalone/cjs/types/error-response.js +56 -1
- package/dist-standalone/cjs/vault-auth.js +178 -1
- package/dist-standalone/cjs/vault-store-loader.js +194 -1
- package/dist-standalone/cjs/verify.js +25 -1
- package/dist-standalone/cjs/version-info.js +543 -1
- package/dist-standalone/cjs/xfetch.js +340 -1
- package/dist-standalone/cli/init.js +455 -1
- package/dist-standalone/cli/setup.js +514 -1
- package/dist-standalone/cli/types.js +27 -1
- package/dist-standalone/cli/xbind.js +148 -1
- package/dist-standalone/config-validation.js +513 -1
- package/dist-standalone/connect.js +274 -1
- package/dist-standalone/connection-pool.js +500 -1
- package/dist-standalone/correlation-id.js +326 -1
- package/dist-standalone/crypto-utils.js +157 -1
- package/dist-standalone/debug-mode.js +510 -1
- package/dist-standalone/did-document.js +96 -1
- package/dist-standalone/did-privateme.js +121 -1
- package/dist-standalone/did-web.js +196 -1
- package/dist-standalone/discovery.js +458 -1
- package/dist-standalone/dual-mode.js +247 -1
- package/dist-standalone/email-templates.js +309 -1
- package/dist-standalone/email-transport.js +232 -1
- package/dist-standalone/envelope.js +525 -1
- package/dist-standalone/errors.js +896 -1
- package/dist-standalone/event-emitter.js +456 -1
- package/dist-standalone/gateway-state.js +51 -1
- package/dist-standalone/gateway-transport.js +116 -1
- package/dist-standalone/graceful-degradation.js +396 -1
- package/dist-standalone/guardrails.js +216 -1
- package/dist-standalone/health-check.js +332 -1
- package/dist-standalone/http-compat.js +267 -1
- package/dist-standalone/http-status-map.js +561 -1
- package/dist-standalone/identity.js +619 -1
- package/dist-standalone/index.js +78 -1
- package/dist-standalone/invitation.js +415 -1
- package/dist-standalone/invite.js +324 -1
- package/dist-standalone/key-agreement.js +325 -1
- package/dist-standalone/lazy-init.js +295 -1
- package/dist-standalone/logger.js +285 -1
- package/dist-standalone/mdns-discovery.js +195 -1
- package/dist-standalone/nonce-store.js +76 -1
- package/dist-standalone/pairing-manager.js +219 -1
- package/dist-standalone/plugin-system.js +257 -1
- package/dist-standalone/plugins/logging.d.ts +84 -0
- package/dist-standalone/plugins/logging.js +163 -0
- package/dist-standalone/plugins/metrics.d.ts +111 -0
- package/dist-standalone/plugins/metrics.js +176 -0
- package/dist-standalone/plugins/validation.d.ts +104 -0
- package/dist-standalone/plugins/validation.js +297 -0
- package/dist-standalone/policy.js +315 -1
- package/dist-standalone/progress-callbacks.js +576 -1
- package/dist-standalone/redis-nonce-store.js +72 -1
- package/dist-standalone/registry-middleware.js +47 -1
- package/dist-standalone/retry-strategies.js +534 -1
- package/dist-standalone/retry-transport.js +98 -1
- package/dist-standalone/runtime/browser.d.ts +311 -0
- package/dist-standalone/runtime/browser.js +516 -0
- package/dist-standalone/runtime/edge.d.ts +282 -0
- package/dist-standalone/runtime/edge.js +511 -0
- package/dist-standalone/runtime/react-native.d.ts +157 -0
- package/dist-standalone/runtime/react-native.js +383 -0
- package/dist-standalone/security-policy.js +239 -1
- package/dist-standalone/serialization.js +1031 -1
- package/dist-standalone/split-channel.js +219 -1
- package/dist-standalone/subscription-proof.js +224 -1
- package/dist-standalone/succession.js +142 -1
- package/dist-standalone/timeouts.js +398 -1
- package/dist-standalone/trace-context.js +414 -1
- package/dist-standalone/trace-spans.js +488 -1
- package/dist-standalone/transport.js +59 -1
- package/dist-standalone/trust-registry.js +950 -1
- package/dist-standalone/types/error-response.d.ts +209 -0
- package/dist-standalone/types/error-response.js +52 -0
- package/dist-standalone/vault-auth.js +174 -1
- package/dist-standalone/vault-store-loader.js +187 -1
- package/dist-standalone/verify.js +16 -1
- package/dist-standalone/version-info.js +530 -1
- package/dist-standalone/xfetch.js +335 -1
- package/package.json +4 -10
- package/share1.dat +0 -0
- package/dist-standalone/_deps/mldsa-wasm/LICENSE +0 -24
- package/dist-standalone/_deps/mldsa-wasm/package.json +0 -46
- package/dist-standalone/_deps/shared/cjs/package.json +0 -1
- package/dist-standalone/_deps/ux-helpers/cjs/package.json +0 -1
- package/dist-standalone/_deps/xchange/cjs/package.json +0 -1
- package/dist-standalone/_deps/xregistry/cjs/package.json +0 -1
- package/dist-standalone/cjs/package.json +0 -3
- package/dist-standalone/package.json +0 -10
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge Runtime Support for xBind
|
|
3
|
+
*
|
|
4
|
+
* Enables xBind to run on edge compute platforms:
|
|
5
|
+
* - Cloudflare Workers
|
|
6
|
+
* - Vercel Edge Functions
|
|
7
|
+
* - Deno Deploy
|
|
8
|
+
*
|
|
9
|
+
* Key Features:
|
|
10
|
+
* - Edge-compatible crypto operations (Web Crypto API only)
|
|
11
|
+
* - KV storage integration for nonce stores and trust registry
|
|
12
|
+
* - Size-optimized build (<1MB constraint)
|
|
13
|
+
* - No Node.js dependencies (no fs, crypto, process)
|
|
14
|
+
*/
|
|
15
|
+
import type { Result } from '@private.me/shared';
|
|
16
|
+
import type { NonceStore, ShareContext } from '../nonce-store.js';
|
|
17
|
+
import type { TrustRegistry, RegistryError } from '../trust-registry.js';
|
|
18
|
+
import type { XailTransportAdapter, EnvelopeHandler, TransportError } from '../transport.js';
|
|
19
|
+
import type { AnyTransportEnvelope } from '../envelope.js';
|
|
20
|
+
/**
|
|
21
|
+
* Detected edge runtime environment.
|
|
22
|
+
*/
|
|
23
|
+
export type EdgeRuntime = 'cloudflare' | 'vercel' | 'deno' | 'node' | 'unknown';
|
|
24
|
+
/**
|
|
25
|
+
* Detect the current edge runtime environment.
|
|
26
|
+
*
|
|
27
|
+
* Detection order:
|
|
28
|
+
* 1. Cloudflare Workers: globalThis.caches + EdgeRuntime
|
|
29
|
+
* 2. Vercel Edge: process.env.VERCEL + EdgeRuntime
|
|
30
|
+
* 3. Deno Deploy: globalThis.Deno
|
|
31
|
+
* 4. Node.js: process.versions.node
|
|
32
|
+
* 5. Unknown: fallback
|
|
33
|
+
*/
|
|
34
|
+
export declare function detectRuntime(): EdgeRuntime;
|
|
35
|
+
/**
|
|
36
|
+
* Check if the current runtime is an edge environment.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isEdgeRuntime(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Validate that the runtime supports required Web Crypto APIs.
|
|
41
|
+
*
|
|
42
|
+
* Edge runtimes MUST provide:
|
|
43
|
+
* - crypto.subtle (Ed25519, X25519, AES-GCM, HMAC)
|
|
44
|
+
* - crypto.getRandomValues()
|
|
45
|
+
* - TextEncoder/TextDecoder
|
|
46
|
+
*/
|
|
47
|
+
export declare function validateEdgeRuntime(): Result<void, string>;
|
|
48
|
+
/**
|
|
49
|
+
* Generic KV storage interface for edge runtimes.
|
|
50
|
+
*
|
|
51
|
+
* Implementations:
|
|
52
|
+
* - Cloudflare KV
|
|
53
|
+
* - Vercel KV (Redis)
|
|
54
|
+
* - Deno KV
|
|
55
|
+
*/
|
|
56
|
+
export interface EdgeKVStore {
|
|
57
|
+
/**
|
|
58
|
+
* Get a value by key.
|
|
59
|
+
* @returns value or null if not found
|
|
60
|
+
*/
|
|
61
|
+
get(key: string): Promise<string | null>;
|
|
62
|
+
/**
|
|
63
|
+
* Set a value with optional TTL.
|
|
64
|
+
* @param key Storage key
|
|
65
|
+
* @param value String value
|
|
66
|
+
* @param ttlSeconds Time-to-live in seconds (optional)
|
|
67
|
+
*/
|
|
68
|
+
put(key: string, value: string, ttlSeconds?: number): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Delete a key.
|
|
71
|
+
*/
|
|
72
|
+
delete(key: string): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* List keys with optional prefix.
|
|
75
|
+
* @param prefix Key prefix for filtering
|
|
76
|
+
* @param limit Maximum number of keys to return
|
|
77
|
+
* @returns Array of matching keys
|
|
78
|
+
*/
|
|
79
|
+
list(prefix?: string, limit?: number): Promise<string[]>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Cloudflare Workers KV namespace binding.
|
|
83
|
+
* Available via env.NAMESPACE in Workers.
|
|
84
|
+
*/
|
|
85
|
+
export interface CloudflareKVNamespace {
|
|
86
|
+
get(key: string): Promise<string | null>;
|
|
87
|
+
put(key: string, value: string, options?: {
|
|
88
|
+
expirationTtl?: number;
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
delete(key: string): Promise<void>;
|
|
91
|
+
list(options?: {
|
|
92
|
+
prefix?: string;
|
|
93
|
+
limit?: number;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
keys: Array<{
|
|
96
|
+
name: string;
|
|
97
|
+
}>;
|
|
98
|
+
}>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Adapter for Cloudflare Workers KV.
|
|
102
|
+
*/
|
|
103
|
+
export declare class CloudflareKVAdapter implements EdgeKVStore {
|
|
104
|
+
private readonly namespace;
|
|
105
|
+
constructor(namespace: CloudflareKVNamespace);
|
|
106
|
+
get(key: string): Promise<string | null>;
|
|
107
|
+
put(key: string, value: string, ttlSeconds?: number): Promise<void>;
|
|
108
|
+
delete(key: string): Promise<void>;
|
|
109
|
+
list(prefix?: string, limit?: number): Promise<string[]>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Vercel KV client interface (Redis-compatible).
|
|
113
|
+
*/
|
|
114
|
+
export interface VercelKVClient {
|
|
115
|
+
get(key: string): Promise<string | null>;
|
|
116
|
+
set(key: string, value: string, options?: {
|
|
117
|
+
ex?: number;
|
|
118
|
+
}): Promise<void>;
|
|
119
|
+
del(key: string): Promise<void>;
|
|
120
|
+
keys(pattern: string): Promise<string[]>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Adapter for Vercel KV (Redis).
|
|
124
|
+
*/
|
|
125
|
+
export declare class VercelKVAdapter implements EdgeKVStore {
|
|
126
|
+
private readonly client;
|
|
127
|
+
constructor(client: VercelKVClient);
|
|
128
|
+
get(key: string): Promise<string | null>;
|
|
129
|
+
put(key: string, value: string, ttlSeconds?: number): Promise<void>;
|
|
130
|
+
delete(key: string): Promise<void>;
|
|
131
|
+
list(prefix?: string, limit?: number): Promise<string[]>;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Deno KV interface.
|
|
135
|
+
*/
|
|
136
|
+
export interface DenoKV {
|
|
137
|
+
get(key: string[]): Promise<{
|
|
138
|
+
value: string | null;
|
|
139
|
+
}>;
|
|
140
|
+
set(key: string[], value: string, options?: {
|
|
141
|
+
expireIn?: number;
|
|
142
|
+
}): Promise<void>;
|
|
143
|
+
delete(key: string[]): Promise<void>;
|
|
144
|
+
list(selector: {
|
|
145
|
+
prefix: string[];
|
|
146
|
+
}): AsyncIterableIterator<{
|
|
147
|
+
key: string[];
|
|
148
|
+
value: string;
|
|
149
|
+
}>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Adapter for Deno KV.
|
|
153
|
+
*/
|
|
154
|
+
export declare class DenoKVAdapter implements EdgeKVStore {
|
|
155
|
+
private readonly kv;
|
|
156
|
+
constructor(kv: DenoKV);
|
|
157
|
+
get(key: string): Promise<string | null>;
|
|
158
|
+
put(key: string, value: string, ttlSeconds?: number): Promise<void>;
|
|
159
|
+
delete(key: string): Promise<void>;
|
|
160
|
+
list(prefix?: string, limit?: number): Promise<string[]>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Nonce store implementation using KV storage.
|
|
164
|
+
*
|
|
165
|
+
* Suitable for edge runtimes where in-memory storage
|
|
166
|
+
* is ephemeral across invocations.
|
|
167
|
+
*/
|
|
168
|
+
export declare class KVNonceStore implements NonceStore {
|
|
169
|
+
private readonly kv;
|
|
170
|
+
private readonly ttlSeconds;
|
|
171
|
+
constructor(kv: EdgeKVStore, ttlMs?: number);
|
|
172
|
+
/**
|
|
173
|
+
* Build composite key: xbind:nonce:{senderDid}:{nonce}:{shareGroupId}:{shareIndex}
|
|
174
|
+
*/
|
|
175
|
+
private buildKey;
|
|
176
|
+
check(nonce: string, senderDid: string, shareContext?: ShareContext): Promise<boolean>;
|
|
177
|
+
cleanup(): void;
|
|
178
|
+
dispose(): void;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Trust registry implementation using KV storage.
|
|
182
|
+
*
|
|
183
|
+
* Stores DID registrations in edge KV for distributed lookups.
|
|
184
|
+
* Simplified version suitable for edge runtimes - stores minimal metadata.
|
|
185
|
+
*/
|
|
186
|
+
export declare class KVTrustRegistry implements TrustRegistry {
|
|
187
|
+
private readonly kv;
|
|
188
|
+
constructor(kv: EdgeKVStore);
|
|
189
|
+
/**
|
|
190
|
+
* Build key: xbind:trust:{did}
|
|
191
|
+
*/
|
|
192
|
+
private buildKey;
|
|
193
|
+
register(did: string, publicKey: Uint8Array, name: string, scopes?: string[], x25519PublicKey?: Uint8Array, mlKemPublicKey?: Uint8Array, mlDsaPublicKey?: Uint8Array, xchange?: boolean, receiveScopes?: string[], sdkVersion?: string, minEnvelopeVersion?: number, maxEnvelopeVersion?: number, ttlMs?: number): Promise<Result<void, RegistryError>>;
|
|
194
|
+
resolve(did: string): Promise<Result<Uint8Array, RegistryError>>;
|
|
195
|
+
hasScope(did: string, scope: string): Promise<boolean>;
|
|
196
|
+
hasReceiveScope(did: string, scope: string): Promise<boolean>;
|
|
197
|
+
revoke(did: string): Promise<Result<void, RegistryError>>;
|
|
198
|
+
list(): Promise<string[]>;
|
|
199
|
+
getEntry(did: string): Promise<Result<import('../trust-registry.js').RegistryEntry, RegistryError>>;
|
|
200
|
+
/** Additional methods for edge compatibility */
|
|
201
|
+
getFullEntry(did: string): Promise<Result<Record<string, unknown>, RegistryError>>;
|
|
202
|
+
dispose(): void;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Edge-compatible HTTPS transport adapter.
|
|
206
|
+
*
|
|
207
|
+
* Uses standard fetch API (available in all edge runtimes).
|
|
208
|
+
* Optimized for edge constraints:
|
|
209
|
+
* - No Node.js http/https modules
|
|
210
|
+
* - No setTimeout (uses AbortSignal.timeout)
|
|
211
|
+
* - Minimal allocations
|
|
212
|
+
*/
|
|
213
|
+
export declare class EdgeTransportAdapter implements XailTransportAdapter {
|
|
214
|
+
private readonly baseUrl;
|
|
215
|
+
private readonly timeoutMs;
|
|
216
|
+
private handlers;
|
|
217
|
+
constructor(opts: {
|
|
218
|
+
baseUrl: string;
|
|
219
|
+
timeoutMs?: number;
|
|
220
|
+
});
|
|
221
|
+
send(envelope: AnyTransportEnvelope, recipientDid: string): Promise<Result<void, TransportError>>;
|
|
222
|
+
onReceive(handler: EnvelopeHandler): void;
|
|
223
|
+
/**
|
|
224
|
+
* Dispatch received envelope to all handlers.
|
|
225
|
+
* Called by edge function handler when processing incoming requests.
|
|
226
|
+
*/
|
|
227
|
+
dispatch(envelope: AnyTransportEnvelope): void;
|
|
228
|
+
dispose(): void;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Options for creating an edge-compatible agent.
|
|
232
|
+
*/
|
|
233
|
+
export interface EdgeAgentOptions {
|
|
234
|
+
/** KV store for nonce deduplication and trust registry */
|
|
235
|
+
readonly kv: EdgeKVStore;
|
|
236
|
+
/** Base URL for message transport */
|
|
237
|
+
readonly baseUrl: string;
|
|
238
|
+
/** Request timeout in milliseconds */
|
|
239
|
+
readonly timeoutMs?: number;
|
|
240
|
+
/** Nonce TTL in milliseconds */
|
|
241
|
+
readonly nonceTtlMs?: number;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Create edge-compatible xBind components.
|
|
245
|
+
*
|
|
246
|
+
* Returns nonce store, trust registry, and transport adapter
|
|
247
|
+
* configured for the edge runtime.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* // Cloudflare Workers
|
|
252
|
+
* const kv = new CloudflareKVAdapter(env.XBIND_KV);
|
|
253
|
+
* const { nonceStore, trustRegistry, transport } = createEdgeAgent({
|
|
254
|
+
* kv,
|
|
255
|
+
* baseUrl: 'https://private.me/relay',
|
|
256
|
+
* });
|
|
257
|
+
*
|
|
258
|
+
* const agent = new Agent({
|
|
259
|
+
* identity: 'persistent',
|
|
260
|
+
* nonceStore,
|
|
261
|
+
* trustRegistry,
|
|
262
|
+
* transport,
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
export declare function createEdgeAgent(opts: EdgeAgentOptions): {
|
|
267
|
+
nonceStore: KVNonceStore;
|
|
268
|
+
trustRegistry: KVTrustRegistry;
|
|
269
|
+
transport: EdgeTransportAdapter;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Check if the bundled size is within edge runtime limits.
|
|
273
|
+
*
|
|
274
|
+
* Cloudflare Workers: 1MB compressed limit
|
|
275
|
+
* Vercel Edge: 1MB limit
|
|
276
|
+
* Deno Deploy: 1MB limit
|
|
277
|
+
*/
|
|
278
|
+
export declare function checkBundleSize(bundleSizeBytes: number): Result<void, string>;
|
|
279
|
+
/**
|
|
280
|
+
* Get edge-optimized build recommendations.
|
|
281
|
+
*/
|
|
282
|
+
export declare function getOptimizationTips(): string[];
|