@private.me/xbind 1.2.15 → 1.2.17
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 +124 -8
- package/dist-standalone/cjs/errors.js +265 -1
- package/dist-standalone/cjs/security-policy.js +55 -14
- package/dist-standalone/cli/init.js +0 -0
- package/dist-standalone/errors.d.ts +4 -0
- package/dist-standalone/errors.js +263 -0
- package/dist-standalone/security-policy.d.ts +8 -4
- package/dist-standalone/security-policy.js +55 -14
- package/package.json +14 -13
- package/share1.dat +0 -0
|
@@ -16,10 +16,12 @@ exports.describeSecurityModeStructured = describeSecurityModeStructured;
|
|
|
16
16
|
* Default security policy for basic XBind.
|
|
17
17
|
*
|
|
18
18
|
* Rules:
|
|
19
|
-
* -
|
|
20
|
-
* -
|
|
21
|
-
* -
|
|
22
|
-
* -
|
|
19
|
+
* - Explicit risk tags: low → 2-of-2, medium → 2-of-3, high/critical → 3-of-5
|
|
20
|
+
* - Fiat transfers: USD/EUR/GBP >$100k → 2-of-3, >$1M → 3-of-5
|
|
21
|
+
* - Crypto transfers: Require explicit risk tag (no numeric auto-detection)
|
|
22
|
+
* - Sensitive scopes: custody/admin/settlement → 2-of-3
|
|
23
|
+
* - Cross-entity communication: 2-of-3
|
|
24
|
+
* - Explicit 'high' override: 2-of-3, 'critical' override: 3-of-5
|
|
23
25
|
* - Everything else: Standard encrypted transport (V3 hybrid PQ)
|
|
24
26
|
*
|
|
25
27
|
* Enterprise and Government variants extend this with custom rules.
|
|
@@ -31,6 +33,7 @@ class DefaultSecurityPolicy {
|
|
|
31
33
|
*
|
|
32
34
|
* @param options - Optional configuration
|
|
33
35
|
* @param options.highValueThreshold - Amount threshold for high security (default: 100000)
|
|
36
|
+
* @param options.criticalValueThreshold - Amount threshold for critical security (default: 1000000)
|
|
34
37
|
* @param options.enableXchange - Allow Xchange mode for performance (default: false)
|
|
35
38
|
*/
|
|
36
39
|
constructor(options = {}) {
|
|
@@ -38,7 +41,8 @@ class DefaultSecurityPolicy {
|
|
|
38
41
|
}
|
|
39
42
|
classify(context) {
|
|
40
43
|
const { action, params, securityOverride } = context;
|
|
41
|
-
const
|
|
44
|
+
const highThreshold = this.options.highValueThreshold ?? 100_000;
|
|
45
|
+
const criticalThreshold = this.options.criticalValueThreshold ?? 1_000_000;
|
|
42
46
|
// Explicit override: critical
|
|
43
47
|
if (securityOverride === 'critical') {
|
|
44
48
|
return {
|
|
@@ -63,15 +67,52 @@ class DefaultSecurityPolicy {
|
|
|
63
67
|
wasOverridden: true,
|
|
64
68
|
};
|
|
65
69
|
}
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
// Risk tag detection (preferred for crypto: BTC, ETH, etc.)
|
|
71
|
+
const riskTag = typeof params.risk === 'string' ? params.risk.toLowerCase() : undefined;
|
|
72
|
+
if (riskTag) {
|
|
73
|
+
if (riskTag === 'critical' || riskTag === 'high') {
|
|
74
|
+
return {
|
|
75
|
+
mode: { type: 'split', shares: 5, threshold: 3 },
|
|
76
|
+
reason: `Explicit risk tag "${riskTag}" requires 3-of-5 threshold`,
|
|
77
|
+
wasOverridden: false,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
else if (riskTag === 'medium') {
|
|
81
|
+
return {
|
|
82
|
+
mode: { type: 'split', shares: 3, threshold: 2 },
|
|
83
|
+
reason: `Explicit risk tag "medium" requires 2-of-3 threshold`,
|
|
84
|
+
wasOverridden: false,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
else if (riskTag === 'low') {
|
|
88
|
+
return {
|
|
89
|
+
mode: { type: 'split', shares: 2, threshold: 2 },
|
|
90
|
+
reason: `Explicit risk tag "low" requires 2-of-2 threshold`,
|
|
91
|
+
wasOverridden: false,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Numeric thresholds ONLY for fiat currencies (USD, EUR, GBP)
|
|
96
|
+
// Crypto (BTC, ETH) should use risk tags instead
|
|
97
|
+
if ((action === 'transfer' || action === 'execute') && typeof params.amount === 'number') {
|
|
98
|
+
const currency = typeof params.currency === 'string' ? params.currency.toUpperCase() : 'USD';
|
|
99
|
+
const isFiat = ['USD', 'EUR', 'GBP'].includes(currency);
|
|
100
|
+
if (isFiat) {
|
|
101
|
+
if (params.amount >= criticalThreshold) {
|
|
102
|
+
return {
|
|
103
|
+
mode: { type: 'split', shares: 5, threshold: 3 },
|
|
104
|
+
reason: `Critical-value transfer (${currency} ${params.amount.toLocaleString()}) requires 3-of-5 threshold`,
|
|
105
|
+
wasOverridden: false,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else if (params.amount >= highThreshold) {
|
|
109
|
+
return {
|
|
110
|
+
mode: { type: 'split', shares: 3, threshold: 2 },
|
|
111
|
+
reason: `High-value transfer (${currency} ${params.amount.toLocaleString()}) requires 2-of-3 threshold`,
|
|
112
|
+
wasOverridden: false,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
75
116
|
}
|
|
76
117
|
// Auto-detection: Cross-entity communication
|
|
77
118
|
if (params.crossEntity === true) {
|
|
File without changes
|
|
@@ -45,6 +45,10 @@ export declare class XBindSplitChannelError extends XBindError {
|
|
|
45
45
|
export declare class XBindAgentError extends XBindError {
|
|
46
46
|
constructor(code: string, message: string);
|
|
47
47
|
}
|
|
48
|
+
/** Billing and payment errors (subscriptions, limits, verification). */
|
|
49
|
+
export declare class XBindBillingError extends XBindError {
|
|
50
|
+
constructor(code: string, message: string);
|
|
51
|
+
}
|
|
48
52
|
/**
|
|
49
53
|
* Create detailed error information for a given error code.
|
|
50
54
|
*
|