@private.me/xbind 2.3.4 → 3.0.1

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.
@@ -0,0 +1,157 @@
1
+ /**
2
+ * React Native Runtime Support for xBind
3
+ *
4
+ * Provides compatibility layer for React Native environments:
5
+ * - Polyfills for missing Node.js APIs
6
+ * - AsyncStorage adapter for persistence
7
+ * - Native crypto module integration
8
+ * - Cross-platform crypto primitives
9
+ *
10
+ * @module runtime/react-native
11
+ */
12
+ import type { Result } from '@private.me/shared';
13
+ /**
14
+ * React Native AsyncStorage interface
15
+ */
16
+ export interface AsyncStorage {
17
+ getItem(key: string): Promise<string | null>;
18
+ setItem(key: string, value: string): Promise<void>;
19
+ removeItem(key: string): Promise<void>;
20
+ getAllKeys(): Promise<string[]>;
21
+ multiGet(keys: string[]): Promise<Array<[string, string | null]>>;
22
+ multiSet(keyValuePairs: Array<[string, string]>): Promise<void>;
23
+ multiRemove(keys: string[]): Promise<void>;
24
+ }
25
+ /**
26
+ * React Native crypto capabilities
27
+ */
28
+ export interface ReactNativeCrypto {
29
+ getRandomValues(array: Uint8Array): void;
30
+ subtle?: {
31
+ digest(algorithm: string, data: BufferSource): Promise<ArrayBuffer>;
32
+ encrypt(algorithm: AlgorithmIdentifier, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
33
+ decrypt(algorithm: AlgorithmIdentifier, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
34
+ sign(algorithm: AlgorithmIdentifier, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
35
+ verify(algorithm: AlgorithmIdentifier, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>;
36
+ generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey | CryptoKeyPair>;
37
+ importKey(format: KeyFormat, keyData: BufferSource | JsonWebKey, algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
38
+ exportKey(format: KeyFormat, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
39
+ };
40
+ }
41
+ /**
42
+ * React Native runtime configuration
43
+ */
44
+ export interface ReactNativeConfig {
45
+ /**
46
+ * AsyncStorage instance (required for persistence)
47
+ */
48
+ storage: AsyncStorage;
49
+ /**
50
+ * Crypto implementation (defaults to global.crypto or react-native-quick-crypto)
51
+ */
52
+ crypto?: ReactNativeCrypto;
53
+ /**
54
+ * Storage key prefix (prevents collisions)
55
+ */
56
+ storagePrefix?: string;
57
+ /**
58
+ * Enable debug logging
59
+ */
60
+ debug?: boolean;
61
+ }
62
+ /**
63
+ * AsyncStorage adapter for xBind persistence
64
+ *
65
+ * Provides cross-platform storage for:
66
+ * - Agent identities (Ed25519/X25519 keys)
67
+ * - Nonce store (replay protection)
68
+ * - Trust registry cache
69
+ * - Connection metadata
70
+ */
71
+ export declare class AsyncStorageAdapter {
72
+ private readonly storage;
73
+ private readonly prefix;
74
+ private readonly debug;
75
+ constructor(config: ReactNativeConfig);
76
+ /**
77
+ * Get value by key
78
+ */
79
+ get(key: string): Promise<Result<string | null, Error>>;
80
+ /**
81
+ * Set key-value pair
82
+ */
83
+ set(key: string, value: string): Promise<Result<void, Error>>;
84
+ /**
85
+ * Remove key
86
+ */
87
+ remove(key: string): Promise<Result<void, Error>>;
88
+ /**
89
+ * Get all keys with prefix
90
+ */
91
+ keys(): Promise<Result<string[], Error>>;
92
+ /**
93
+ * Get multiple keys (batch operation)
94
+ */
95
+ multiGet(keys: string[]): Promise<Result<Array<[string, string | null]>, Error>>;
96
+ /**
97
+ * Set multiple key-value pairs (batch operation)
98
+ */
99
+ multiSet(pairs: Array<[string, string]>): Promise<Result<void, Error>>;
100
+ /**
101
+ * Clear all xBind data
102
+ */
103
+ clear(): Promise<Result<void, Error>>;
104
+ }
105
+ /**
106
+ * Detect available crypto implementation
107
+ */
108
+ export declare function detectCrypto(): ReactNativeCrypto | null;
109
+ /**
110
+ * Get random bytes (cross-platform)
111
+ */
112
+ export declare function getRandomBytes(length: number, crypto?: ReactNativeCrypto): Uint8Array;
113
+ /**
114
+ * SHA-256 hash (cross-platform)
115
+ */
116
+ export declare function sha256(data: Uint8Array, crypto?: ReactNativeCrypto): Promise<Uint8Array>;
117
+ /**
118
+ * Buffer polyfill for React Native
119
+ *
120
+ * Uses global Buffer if available, otherwise provides minimal implementation
121
+ */
122
+ export declare class BufferPolyfill {
123
+ static isBuffer(obj: any): boolean;
124
+ static from(data: string | Uint8Array | number[], encoding?: string): Uint8Array;
125
+ static toString(buffer: Uint8Array, encoding?: string): string;
126
+ static concat(buffers: Uint8Array[]): Uint8Array;
127
+ static alloc(size: number, fill?: number): Uint8Array;
128
+ private static fromBase64;
129
+ private static toBase64;
130
+ private static fromHex;
131
+ private static toHex;
132
+ }
133
+ /**
134
+ * Detect React Native runtime
135
+ */
136
+ export declare function isReactNative(): boolean;
137
+ /**
138
+ * Detect platform (iOS/Android)
139
+ */
140
+ export declare function detectPlatform(): 'ios' | 'android' | 'unknown';
141
+ /**
142
+ * Initialize React Native runtime environment
143
+ *
144
+ * Sets up polyfills and validates required dependencies
145
+ */
146
+ export declare function initializeReactNative(config: ReactNativeConfig): Result<void, Error>;
147
+ declare const _default: {
148
+ AsyncStorageAdapter: typeof AsyncStorageAdapter;
149
+ detectCrypto: typeof detectCrypto;
150
+ getRandomBytes: typeof getRandomBytes;
151
+ sha256: typeof sha256;
152
+ BufferPolyfill: typeof BufferPolyfill;
153
+ isReactNative: typeof isReactNative;
154
+ detectPlatform: typeof detectPlatform;
155
+ initializeReactNative: typeof initializeReactNative;
156
+ };
157
+ export default _default;
@@ -0,0 +1 @@
1
+ import{ok,err}from"../_deps/shared/index.js";export class AsyncStorageAdapter{storage;prefix;debug;constructor(t){this.storage=t.storage,this.prefix=t.storagePrefix||"@xbind:",this.debug=t.debug||!1}async get(t){try{const e=this.prefix+t,r=await this.storage.getItem(e);return this.debug&&console.log(`[AsyncStorage] GET ${e}:`,r?"found":"not found"),ok(r)}catch(t){return err(new Error(`AsyncStorage get failed: ${t}`))}}async set(t,e){try{const r=this.prefix+t;return await this.storage.setItem(r,e),this.debug&&console.log(`[AsyncStorage] SET ${r}:`,e.length,"bytes"),ok(void 0)}catch(t){return err(new Error(`AsyncStorage set failed: ${t}`))}}async remove(t){try{const e=this.prefix+t;return await this.storage.removeItem(e),this.debug&&console.log(`[AsyncStorage] REMOVE ${e}`),ok(void 0)}catch(t){return err(new Error(`AsyncStorage remove failed: ${t}`))}}async keys(){try{const t=(await this.storage.getAllKeys()).filter(t=>t.startsWith(this.prefix)).map(t=>t.substring(this.prefix.length));return this.debug&&console.log("[AsyncStorage] KEYS:",t.length,"items"),ok(t)}catch(t){return err(new Error(`AsyncStorage keys failed: ${t}`))}}async multiGet(t){try{const e=t.map(t=>this.prefix+t),r=(await this.storage.multiGet(e)).map(([t,e])=>[t.substring(this.prefix.length),e]);return this.debug&&console.log("[AsyncStorage] MULTI_GET:",t.length,"keys"),ok(r)}catch(t){return err(new Error(`AsyncStorage multiGet failed: ${t}`))}}async multiSet(t){try{const e=t.map(([t,e])=>[this.prefix+t,e]);return await this.storage.multiSet(e),this.debug&&console.log("[AsyncStorage] MULTI_SET:",t.length,"pairs"),ok(void 0)}catch(t){return err(new Error(`AsyncStorage multiSet failed: ${t}`))}}async clear(){try{const t=await this.keys();if(!t.ok)return err(t.error);const e=t.value.map(t=>this.prefix+t);return e.length>0&&await this.storage.multiRemove(e),this.debug&&console.log("[AsyncStorage] CLEAR:",e.length,"items removed"),ok(void 0)}catch(t){return err(new Error(`AsyncStorage clear failed: ${t}`))}}}export function detectCrypto(){if("undefined"!=typeof global&&global.crypto)return global.crypto;try{return require("react-native-quick-crypto")}catch{}try{const t=require("expo-crypto");return{getRandomValues:e=>{const r=t.getRandomBytes(e.length);e.set(r)}}}catch{}return null}export function getRandomBytes(t,e){const r=e||detectCrypto();if(!r)throw new Error("No crypto implementation available. Install react-native-quick-crypto or expo-crypto.");const o=new Uint8Array(t);return r.getRandomValues(o),o}export async function sha256(t,e){const r=e||detectCrypto();if(!r?.subtle)throw new Error("No SubtleCrypto implementation available. Install react-native-quick-crypto.");const o=new Uint8Array(t).buffer,n=await r.subtle.digest("SHA-256",o);return new Uint8Array(n)}export class BufferPolyfill{static isBuffer(t){return t instanceof Uint8Array}static from(t,e){if("string"==typeof t){if("base64"===e)return this.fromBase64(t);if("hex"===e)return this.fromHex(t);return(new TextEncoder).encode(t)}return Array.isArray(t),new Uint8Array(t)}static toString(t,e){if("base64"===e)return this.toBase64(t);if("hex"===e)return this.toHex(t);return(new TextDecoder).decode(t)}static concat(t){const e=t.reduce((t,e)=>t+e.length,0),r=new Uint8Array(e);let o=0;for(const e of t)r.set(e,o),o+=e.length;return r}static alloc(t,e){const r=new Uint8Array(t);return void 0!==e&&r.fill(e),r}static fromBase64(t){const e=atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r}static toBase64(t){let e="";for(let r=0;r<t.length;r++){const o=t[r];void 0!==o&&(e+=String.fromCharCode(o))}return btoa(e)}static fromHex(t){const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++)e[r]=parseInt(t.substr(2*r,2),16);return e}static toHex(t){return Array.from(t).map(t=>t.toString(16).padStart(2,"0")).join("")}}export function isReactNative(){return"undefined"!=typeof navigator&&"ReactNative"===navigator.product}export function detectPlatform(){if("undefined"==typeof navigator)return"unknown";const t=navigator.userAgent||"";return/iPhone|iPad|iPod/.test(t)?"ios":/Android/.test(t)?"android":"unknown"}export function initializeReactNative(t){try{if(!t.storage)return err(new Error("AsyncStorage is required for React Native runtime"));const e=t.crypto||detectCrypto();return e?(global.crypto||(global.crypto=e),global.Buffer||(global.Buffer=BufferPolyfill),t.debug&&console.log("[xBind] React Native runtime initialized:",{platform:detectPlatform(),crypto:e.subtle?"full":"basic",storage:"AsyncStorage",prefix:t.storagePrefix||"@xbind:"}),ok(void 0)):err(new Error("No crypto implementation found. Install react-native-quick-crypto or expo-crypto."))}catch(t){return err(new Error(`React Native initialization failed: ${t}`))}}export default{AsyncStorageAdapter:AsyncStorageAdapter,detectCrypto:detectCrypto,getRandomBytes:getRandomBytes,sha256:sha256,BufferPolyfill:BufferPolyfill,isReactNative:isReactNative,detectPlatform:detectPlatform,initializeReactNative:initializeReactNative};
@@ -0,0 +1,209 @@
1
+ /**
2
+ * Error Response Types
3
+ *
4
+ * Dual-code error response system supporting both AWS standard codes
5
+ * and legacy xBind codes for backward compatibility.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ /**
10
+ * Standardized error response structure with dual-code support
11
+ *
12
+ * Supports multiple code formats:
13
+ * - AWS standard codes (primary): InvalidParameterException, UnauthorizedException
14
+ * - Legacy xBind codes (deprecated): XBIND_INVALID_SIGNATURE, XBIND_AUTH_FAILED
15
+ * - gRPC status codes: INVALID_ARGUMENT, UNAUTHENTICATED
16
+ * - HTTP status codes: 400, 401, 403, etc.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const error: ErrorResponse = {
21
+ * code: 'UnauthorizedException',
22
+ * legacyCode: 'XBIND_AUTH_FAILED',
23
+ * httpStatus: 401,
24
+ * grpcCode: 'UNAUTHENTICATED',
25
+ * message: 'Invalid signature',
26
+ * hint: 'Ensure DID signature is correct',
27
+ * docs: 'https://private.me/docs/xbind#authentication',
28
+ * requestId: 'req_abc123',
29
+ * timestamp: Date.now()
30
+ * };
31
+ * ```
32
+ */
33
+ export interface ErrorResponse {
34
+ /**
35
+ * AWS standard error code (primary)
36
+ *
37
+ * Examples:
38
+ * - InvalidParameterException
39
+ * - UnauthorizedException
40
+ * - ResourceNotFoundException
41
+ * - InternalServerException
42
+ * - ServiceUnavailableException
43
+ * - ThrottlingException
44
+ *
45
+ * This is the primary code format. All new integrations should use this.
46
+ */
47
+ code: string;
48
+ /**
49
+ * Legacy xBind error code (deprecated)
50
+ *
51
+ * Examples:
52
+ * - XBIND_INVALID_SIGNATURE
53
+ * - XBIND_AUTH_FAILED
54
+ * - XBIND_DID_NOT_FOUND
55
+ * - XBIND_RATE_LIMIT
56
+ *
57
+ * Provided for backward compatibility only.
58
+ * Will be removed in future major version.
59
+ *
60
+ * @deprecated Use `code` field instead
61
+ */
62
+ legacyCode?: string;
63
+ /**
64
+ * HTTP status code
65
+ *
66
+ * Standard HTTP status codes:
67
+ * - 400: Bad Request (InvalidParameterException)
68
+ * - 401: Unauthorized (UnauthorizedException)
69
+ * - 403: Forbidden (AccessDeniedException)
70
+ * - 404: Not Found (ResourceNotFoundException)
71
+ * - 429: Too Many Requests (ThrottlingException)
72
+ * - 500: Internal Server Error (InternalServerException)
73
+ * - 503: Service Unavailable (ServiceUnavailableException)
74
+ */
75
+ httpStatus: number;
76
+ /**
77
+ * gRPC status code (optional)
78
+ *
79
+ * Examples:
80
+ * - INVALID_ARGUMENT
81
+ * - UNAUTHENTICATED
82
+ * - PERMISSION_DENIED
83
+ * - NOT_FOUND
84
+ * - RESOURCE_EXHAUSTED
85
+ * - INTERNAL
86
+ * - UNAVAILABLE
87
+ *
88
+ * Provided for gRPC-based integrations.
89
+ */
90
+ grpcCode?: string;
91
+ /**
92
+ * Human-readable error message
93
+ *
94
+ * Should be clear and actionable. Avoid technical jargon where possible.
95
+ *
96
+ * Example: "Invalid signature" instead of "ECDSA verification failed"
97
+ */
98
+ message: string;
99
+ /**
100
+ * Developer hint for resolving the error (optional)
101
+ *
102
+ * Provides actionable guidance for fixing the issue.
103
+ *
104
+ * Example: "Ensure DID signature is correct and not expired"
105
+ */
106
+ hint?: string;
107
+ /**
108
+ * Documentation URL for detailed error information (optional)
109
+ *
110
+ * Links to relevant documentation section for this error type.
111
+ *
112
+ * Example: "https://private.me/docs/xbind#authentication"
113
+ */
114
+ docs?: string;
115
+ /**
116
+ * Request ID for correlation and debugging (optional)
117
+ *
118
+ * Unique identifier for this request. Used for:
119
+ * - Log correlation across distributed systems
120
+ * - Customer support troubleshooting
121
+ * - Audit trail tracking
122
+ *
123
+ * Format: "req_" + random alphanumeric (e.g., "req_abc123def456")
124
+ */
125
+ requestId?: string;
126
+ /**
127
+ * Error timestamp in milliseconds since Unix epoch (optional)
128
+ *
129
+ * When the error occurred. Useful for:
130
+ * - Time-based debugging
131
+ * - Rate limit tracking
132
+ * - Audit logs
133
+ *
134
+ * Format: Unix timestamp in milliseconds (Date.now())
135
+ */
136
+ timestamp?: number;
137
+ /**
138
+ * Correlation ID for distributed tracing (optional)
139
+ *
140
+ * Tracks a single logical operation across multiple services.
141
+ * Different from requestId (per-request) - this spans multiple requests.
142
+ *
143
+ * Format: UUID or similar distributed trace ID
144
+ *
145
+ * Example: "trace_789xyz" spans: Auth request → DID lookup → Billing check
146
+ */
147
+ correlationId?: string;
148
+ }
149
+ /**
150
+ * Error response with additional metadata for internal use
151
+ *
152
+ * Extends ErrorResponse with internal fields that should NOT be
153
+ * exposed to external clients.
154
+ *
155
+ * @internal
156
+ */
157
+ export interface InternalErrorResponse extends ErrorResponse {
158
+ /**
159
+ * Stack trace (internal only, never exposed externally)
160
+ *
161
+ * @internal
162
+ */
163
+ stack?: string;
164
+ /**
165
+ * Internal error code for debugging (internal only)
166
+ *
167
+ * @internal
168
+ */
169
+ internalCode?: string;
170
+ /**
171
+ * Service name that generated the error
172
+ *
173
+ * @internal
174
+ */
175
+ service?: string;
176
+ }
177
+ /**
178
+ * Type guard to check if a value is an ErrorResponse
179
+ *
180
+ * @param value - Value to check
181
+ * @returns True if value is an ErrorResponse
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * if (isErrorResponse(result)) {
186
+ * console.error(result.message);
187
+ * }
188
+ * ```
189
+ */
190
+ export declare function isErrorResponse(value: unknown): value is ErrorResponse;
191
+ /**
192
+ * Create a standardized error response
193
+ *
194
+ * @param params - Error response parameters
195
+ * @returns Standardized ErrorResponse object
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * const error = createErrorResponse({
200
+ * code: 'UnauthorizedException',
201
+ * legacyCode: 'XBIND_AUTH_FAILED',
202
+ * httpStatus: 401,
203
+ * message: 'Invalid signature'
204
+ * });
205
+ * ```
206
+ */
207
+ export declare function createErrorResponse(params: Omit<ErrorResponse, 'timestamp'> & {
208
+ timestamp?: number;
209
+ }): ErrorResponse;
@@ -0,0 +1 @@
1
+ export function isErrorResponse(t){if(!t||"object"!=typeof t)return!1;const e=t;return"string"==typeof e.code&&"number"==typeof e.httpStatus&&"string"==typeof e.message}export function createErrorResponse(t){return{...t,timestamp:t.timestamp??Date.now()}}
@@ -1 +1 @@
1
- import{createLogger}from"./logger.js";const logger=createLogger("version-info");export var Capability;!function(e){e.ENVELOPE_V1="envelope-v1",e.ENVELOPE_V2="envelope-v2",e.ENVELOPE_V3="envelope-v3",e.ENVELOPE_V4="envelope-v4",e.ML_KEM_768="ml-kem-768",e.ML_DSA_65="ml-dsa-65",e.X25519_ECDH="x25519-ecdh",e.ED25519_SIG="ed25519-sig",e.XORIDA="xorida",e.SPLIT_CHANNEL="split-channel",e.TRUST_REGISTRY="trust-registry",e.SERVICE_DISCOVERY="service-discovery",e.INVITE_SYSTEM="invite-system",e.AGENT_CALL="agent-call",e.XFETCH="xfetch",e.DUAL_MODE="dual-mode",e.BACKUP_RESTORE="backup-restore",e.CORRELATION_ID="correlation-id",e.STRUCTURED_LOGGING="structured-logging",e.DID_SUCCESSION="did-succession",e.GATEWAY_STATE="gateway-state",e.SUBSCRIPTION_PROOF="subscription-proof",e.POLICY_ENGINE="policy-engine",e.APPROVAL_FLOW="approval-flow",e.GUARDRAILS="guardrails",e.HTTP_COMPAT="http-compat",e.DID_WEB="did-web",e.DID_PRIVATEME="did:privateme",e.REDIS_NONCE="redis-nonce",e.RETRY_TRANSPORT="retry-transport"}(Capability||(Capability={}));const VERSION_METADATA={semver:"2.3.4",major:1,minor:4,patch:2,prerelease:void 0,build:void 0,features:[Capability.ENVELOPE_V1,Capability.ENVELOPE_V2,Capability.ENVELOPE_V3,Capability.ENVELOPE_V4,Capability.ML_KEM_768,Capability.ML_DSA_65,Capability.X25519_ECDH,Capability.ED25519_SIG,Capability.XORIDA,Capability.SPLIT_CHANNEL,Capability.TRUST_REGISTRY,Capability.SERVICE_DISCOVERY,Capability.INVITE_SYSTEM,Capability.AGENT_CALL,Capability.XFETCH,Capability.DUAL_MODE,Capability.BACKUP_RESTORE,Capability.CORRELATION_ID,Capability.STRUCTURED_LOGGING,Capability.DID_SUCCESSION,Capability.GATEWAY_STATE,Capability.SUBSCRIPTION_PROOF,Capability.POLICY_ENGINE,Capability.APPROVAL_FLOW,Capability.GUARDRAILS,Capability.HTTP_COMPAT,Capability.DID_WEB,Capability.DID_PRIVATEME,Capability.REDIS_NONCE,Capability.RETRY_TRANSPORT],deprecated:[{name:"envelope-v1",since:"1.2.0",removedIn:"2.0.0",migration:"Use createEnvelopeV2() or higher for split-channel support",docs:"https://private.me/docs/xbind/migration-v2"}],buildDate:(new Date).toISOString(),nodeVersion:process.version};export function getVersion(){return Object.freeze({...VERSION_METADATA})}export function hasCapability(e){return VERSION_METADATA.features.includes(e)}export function getCapabilities(){return Object.freeze([...VERSION_METADATA.features])}export function getDeprecationInfo(e){return VERSION_METADATA.deprecated.find(i=>i.name===e)}const warnedFeatures=new Set;export function warnIfDeprecated(e){if(warnedFeatures.has(e))return;const i=getDeprecationInfo(e);if(!i)return;warnedFeatures.add(e);const r=[`Feature "${e}" is deprecated since v${i.since}`,i.removedIn?`and will be removed in v${i.removedIn}.`:".",i.migration].join(" ");logger.warn(r,{feature:e,deprecatedSince:i.since,removedIn:i.removedIn,docs:i.docs}),"undefined"!=typeof console&&console.warn&&(console.warn(`[xBind] ${r}`),i.docs&&console.warn(`[xBind] See: ${i.docs}`))}export function parseVersion(e){const i=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9.-]+))?(?:\+([a-zA-Z0-9.-]+))?$/);if(!(i&&i[1]&&i[2]&&i[3]))throw new Error(`Invalid semantic version: ${e}`);return{major:parseInt(i[1],10),minor:parseInt(i[2],10),patch:parseInt(i[3],10),prerelease:i[4]||void 0,build:i[5]||void 0}}export function compareVersions(e,i){const r=parseVersion(e),a=parseVersion(i);if(r.major<a.major)return-1;if(r.major>a.major)return 1;if(r.minor<a.minor)return-1;if(r.minor>a.minor)return 1;if(r.patch<a.patch)return-1;if(r.patch>a.patch)return 1;if(r.prerelease&&!a.prerelease)return-1;if(!r.prerelease&&a.prerelease)return 1;if(r.prerelease&&a.prerelease){if(r.prerelease<a.prerelease)return-1;if(r.prerelease>a.prerelease)return 1}return 0}export function checkCompatibility(e){const i=VERSION_METADATA.semver;if(e.startsWith("^")){const r=e.slice(1),a=parseVersion(r);return parseVersion(i).major!==a.major?{compatible:!1,message:`Incompatible major version. Required: ^${r}, Current: ${i}`,severity:"error",required:e,actual:i}:compareVersions(i,r)<0?{compatible:!1,message:`SDK version too old. Required: ^${r}, Current: ${i}`,severity:"error",required:e,actual:i}:{compatible:!0,message:`Compatible (${i} satisfies ^${r})`,severity:"info",required:e,actual:i}}if(e.startsWith("~")){const r=e.slice(1),a=parseVersion(r),t=parseVersion(i);return t.major!==a.major||t.minor!==a.minor?{compatible:!1,message:`Incompatible version. Required: ~${r}, Current: ${i}`,severity:"error",required:e,actual:i}:compareVersions(i,r)<0?{compatible:!1,message:`SDK version too old. Required: ~${r}, Current: ${i}`,severity:"error",required:e,actual:i}:{compatible:!0,message:`Compatible (${i} satisfies ~${r})`,severity:"info",required:e,actual:i}}let r,a,t;try{r=compareVersions(i,e)}catch(r){return{compatible:!1,message:`Invalid version format: ${e}`,severity:"error",required:e,actual:i}}if(0===r)return{compatible:!0,message:`Exact version match (${i})`,severity:"info",required:e,actual:i};if(r<0)return{compatible:!1,message:`SDK version too old. Required: ${e}, Current: ${i}`,severity:"error",required:e,actual:i};try{a=parseVersion(e),t=parseVersion(i)}catch(r){return{compatible:!0,message:`Compatible (${i} is newer than ${e})`,severity:"info",required:e,actual:i}}return t.major>a.major?{compatible:!1,message:`Breaking changes in SDK. Required: ${e}, Current: ${i}`,severity:"warning",required:e,actual:i}:{compatible:!0,message:`Compatible (${i} is newer than ${e})`,severity:"info",required:e,actual:i}}export function getMinimumVersionFor(e){return{[Capability.ENVELOPE_V1]:"1.0.0",[Capability.ENVELOPE_V2]:"1.1.0",[Capability.ENVELOPE_V3]:"1.2.0",[Capability.ENVELOPE_V4]:"1.3.0",[Capability.ML_KEM_768]:"1.2.0",[Capability.ML_DSA_65]:"1.3.0",[Capability.X25519_ECDH]:"1.0.0",[Capability.ED25519_SIG]:"1.0.0",[Capability.XORIDA]:"1.0.0",[Capability.SPLIT_CHANNEL]:"1.1.0",[Capability.TRUST_REGISTRY]:"1.0.0",[Capability.SERVICE_DISCOVERY]:"1.1.0",[Capability.INVITE_SYSTEM]:"1.1.0",[Capability.AGENT_CALL]:"1.0.0",[Capability.XFETCH]:"1.2.0",[Capability.DUAL_MODE]:"1.2.0",[Capability.BACKUP_RESTORE]:"1.3.0",[Capability.CORRELATION_ID]:"1.3.0",[Capability.STRUCTURED_LOGGING]:"1.3.0",[Capability.DID_SUCCESSION]:"1.2.0",[Capability.GATEWAY_STATE]:"1.2.0",[Capability.SUBSCRIPTION_PROOF]:"1.2.0",[Capability.POLICY_ENGINE]:"1.1.0",[Capability.APPROVAL_FLOW]:"1.1.0",[Capability.GUARDRAILS]:"1.2.0",[Capability.HTTP_COMPAT]:"1.2.0",[Capability.DID_WEB]:"1.1.0",[Capability.DID_PRIVATEME]:"1.2.0",[Capability.REDIS_NONCE]:"1.1.0",[Capability.RETRY_TRANSPORT]:"1.1.0"}[e]}export function assertMinimumVersion(e,i){const r=checkCompatibility(e);if(!r.compatible&&"error"===r.severity){const a=i?`${i} requires xBind >= ${e} (current: ${VERSION_METADATA.semver})`:r.message;throw new Error(a)}}
1
+ import{createLogger}from"./logger.js";const logger=createLogger("version-info");export var Capability;!function(e){e.ENVELOPE_V1="envelope-v1",e.ENVELOPE_V2="envelope-v2",e.ENVELOPE_V3="envelope-v3",e.ENVELOPE_V4="envelope-v4",e.ML_KEM_768="ml-kem-768",e.ML_DSA_65="ml-dsa-65",e.X25519_ECDH="x25519-ecdh",e.ED25519_SIG="ed25519-sig",e.XORIDA="xorida",e.SPLIT_CHANNEL="split-channel",e.TRUST_REGISTRY="trust-registry",e.SERVICE_DISCOVERY="service-discovery",e.INVITE_SYSTEM="invite-system",e.AGENT_CALL="agent-call",e.XFETCH="xfetch",e.DUAL_MODE="dual-mode",e.BACKUP_RESTORE="backup-restore",e.CORRELATION_ID="correlation-id",e.STRUCTURED_LOGGING="structured-logging",e.DID_SUCCESSION="did-succession",e.GATEWAY_STATE="gateway-state",e.SUBSCRIPTION_PROOF="subscription-proof",e.POLICY_ENGINE="policy-engine",e.APPROVAL_FLOW="approval-flow",e.GUARDRAILS="guardrails",e.HTTP_COMPAT="http-compat",e.DID_WEB="did-web",e.DID_PRIVATEME="did:privateme",e.REDIS_NONCE="redis-nonce",e.RETRY_TRANSPORT="retry-transport"}(Capability||(Capability={}));const VERSION_METADATA={semver:"3.0.0",major:1,minor:4,patch:2,prerelease:void 0,build:void 0,features:[Capability.ENVELOPE_V1,Capability.ENVELOPE_V2,Capability.ENVELOPE_V3,Capability.ENVELOPE_V4,Capability.ML_KEM_768,Capability.ML_DSA_65,Capability.X25519_ECDH,Capability.ED25519_SIG,Capability.XORIDA,Capability.SPLIT_CHANNEL,Capability.TRUST_REGISTRY,Capability.SERVICE_DISCOVERY,Capability.INVITE_SYSTEM,Capability.AGENT_CALL,Capability.XFETCH,Capability.DUAL_MODE,Capability.BACKUP_RESTORE,Capability.CORRELATION_ID,Capability.STRUCTURED_LOGGING,Capability.DID_SUCCESSION,Capability.GATEWAY_STATE,Capability.SUBSCRIPTION_PROOF,Capability.POLICY_ENGINE,Capability.APPROVAL_FLOW,Capability.GUARDRAILS,Capability.HTTP_COMPAT,Capability.DID_WEB,Capability.DID_PRIVATEME,Capability.REDIS_NONCE,Capability.RETRY_TRANSPORT],deprecated:[{name:"envelope-v1",since:"1.2.0",removedIn:"2.0.0",migration:"Use createEnvelopeV2() or higher for split-channel support",docs:"https://private.me/docs/xbind/migration-v2"}],buildDate:(new Date).toISOString(),nodeVersion:process.version};export function getVersion(){return Object.freeze({...VERSION_METADATA})}export function hasCapability(e){return VERSION_METADATA.features.includes(e)}export function getCapabilities(){return Object.freeze([...VERSION_METADATA.features])}export function getDeprecationInfo(e){return VERSION_METADATA.deprecated.find(i=>i.name===e)}const warnedFeatures=new Set;export function warnIfDeprecated(e){if(warnedFeatures.has(e))return;const i=getDeprecationInfo(e);if(!i)return;warnedFeatures.add(e);const r=[`Feature "${e}" is deprecated since v${i.since}`,i.removedIn?`and will be removed in v${i.removedIn}.`:".",i.migration].join(" ");logger.warn(r,{feature:e,deprecatedSince:i.since,removedIn:i.removedIn,docs:i.docs}),"undefined"!=typeof console&&console.warn&&(console.warn(`[xBind] ${r}`),i.docs&&console.warn(`[xBind] See: ${i.docs}`))}export function parseVersion(e){const i=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9.-]+))?(?:\+([a-zA-Z0-9.-]+))?$/);if(!(i&&i[1]&&i[2]&&i[3]))throw new Error(`Invalid semantic version: ${e}`);return{major:parseInt(i[1],10),minor:parseInt(i[2],10),patch:parseInt(i[3],10),prerelease:i[4]||void 0,build:i[5]||void 0}}export function compareVersions(e,i){const r=parseVersion(e),a=parseVersion(i);if(r.major<a.major)return-1;if(r.major>a.major)return 1;if(r.minor<a.minor)return-1;if(r.minor>a.minor)return 1;if(r.patch<a.patch)return-1;if(r.patch>a.patch)return 1;if(r.prerelease&&!a.prerelease)return-1;if(!r.prerelease&&a.prerelease)return 1;if(r.prerelease&&a.prerelease){if(r.prerelease<a.prerelease)return-1;if(r.prerelease>a.prerelease)return 1}return 0}export function checkCompatibility(e){const i=VERSION_METADATA.semver;if(e.startsWith("^")){const r=e.slice(1),a=parseVersion(r);return parseVersion(i).major!==a.major?{compatible:!1,message:`Incompatible major version. Required: ^${r}, Current: ${i}`,severity:"error",required:e,actual:i}:compareVersions(i,r)<0?{compatible:!1,message:`SDK version too old. Required: ^${r}, Current: ${i}`,severity:"error",required:e,actual:i}:{compatible:!0,message:`Compatible (${i} satisfies ^${r})`,severity:"info",required:e,actual:i}}if(e.startsWith("~")){const r=e.slice(1),a=parseVersion(r),t=parseVersion(i);return t.major!==a.major||t.minor!==a.minor?{compatible:!1,message:`Incompatible version. Required: ~${r}, Current: ${i}`,severity:"error",required:e,actual:i}:compareVersions(i,r)<0?{compatible:!1,message:`SDK version too old. Required: ~${r}, Current: ${i}`,severity:"error",required:e,actual:i}:{compatible:!0,message:`Compatible (${i} satisfies ~${r})`,severity:"info",required:e,actual:i}}let r,a,t;try{r=compareVersions(i,e)}catch(r){return{compatible:!1,message:`Invalid version format: ${e}`,severity:"error",required:e,actual:i}}if(0===r)return{compatible:!0,message:`Exact version match (${i})`,severity:"info",required:e,actual:i};if(r<0)return{compatible:!1,message:`SDK version too old. Required: ${e}, Current: ${i}`,severity:"error",required:e,actual:i};try{a=parseVersion(e),t=parseVersion(i)}catch(r){return{compatible:!0,message:`Compatible (${i} is newer than ${e})`,severity:"info",required:e,actual:i}}return t.major>a.major?{compatible:!1,message:`Breaking changes in SDK. Required: ${e}, Current: ${i}`,severity:"warning",required:e,actual:i}:{compatible:!0,message:`Compatible (${i} is newer than ${e})`,severity:"info",required:e,actual:i}}export function getMinimumVersionFor(e){return{[Capability.ENVELOPE_V1]:"1.0.0",[Capability.ENVELOPE_V2]:"1.1.0",[Capability.ENVELOPE_V3]:"1.2.0",[Capability.ENVELOPE_V4]:"1.3.0",[Capability.ML_KEM_768]:"1.2.0",[Capability.ML_DSA_65]:"1.3.0",[Capability.X25519_ECDH]:"1.0.0",[Capability.ED25519_SIG]:"1.0.0",[Capability.XORIDA]:"1.0.0",[Capability.SPLIT_CHANNEL]:"1.1.0",[Capability.TRUST_REGISTRY]:"1.0.0",[Capability.SERVICE_DISCOVERY]:"1.1.0",[Capability.INVITE_SYSTEM]:"1.1.0",[Capability.AGENT_CALL]:"1.0.0",[Capability.XFETCH]:"1.2.0",[Capability.DUAL_MODE]:"1.2.0",[Capability.BACKUP_RESTORE]:"1.3.0",[Capability.CORRELATION_ID]:"1.3.0",[Capability.STRUCTURED_LOGGING]:"1.3.0",[Capability.DID_SUCCESSION]:"1.2.0",[Capability.GATEWAY_STATE]:"1.2.0",[Capability.SUBSCRIPTION_PROOF]:"1.2.0",[Capability.POLICY_ENGINE]:"1.1.0",[Capability.APPROVAL_FLOW]:"1.1.0",[Capability.GUARDRAILS]:"1.2.0",[Capability.HTTP_COMPAT]:"1.2.0",[Capability.DID_WEB]:"1.1.0",[Capability.DID_PRIVATEME]:"1.2.0",[Capability.REDIS_NONCE]:"1.1.0",[Capability.RETRY_TRANSPORT]:"1.1.0"}[e]}export function assertMinimumVersion(e,i){const r=checkCompatibility(e);if(!r.compatible&&"error"===r.severity){const a=i?`${i} requires xBind >= ${e} (current: ${VERSION_METADATA.semver})`:r.message;throw new Error(a)}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@private.me/xbind",
3
- "version": "2.3.4",
3
+ "version": "3.0.1",
4
4
  "description": "Identity-based M2M authentication (Contains encryption - export restrictions apply)",
5
5
  "license": "Proprietary",
6
6
  "author": "Private.Me Contributors",
@@ -83,6 +83,9 @@
83
83
  "dist-standalone/cli/**",
84
84
  "dist-standalone/cjs/**",
85
85
  "dist-standalone/_deps/**",
86
+ "dist-standalone/runtime/**",
87
+ "dist-standalone/plugins/**",
88
+ "dist-standalone/types/**",
86
89
  "!dist-standalone/_deps/crypto/**",
87
90
  "dist-standalone/package.json",
88
91
  "dist-standalone/vault-store-loader.js",
package/share1.dat CHANGED
Binary file