@paystage/policy 0.1.0 → 0.2.0
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/schema.d.ts +25 -96
- package/dist/schema.js +19 -1
- package/dist/types.d.ts +20 -0
- package/package.json +5 -4
package/dist/schema.d.ts
CHANGED
|
@@ -6,115 +6,44 @@ export declare const PolicySchema: z.ZodObject<{
|
|
|
6
6
|
value: z.ZodString;
|
|
7
7
|
asset: z.ZodString;
|
|
8
8
|
decimals: z.ZodNumber;
|
|
9
|
-
},
|
|
10
|
-
value: string;
|
|
11
|
-
asset: string;
|
|
12
|
-
decimals: number;
|
|
13
|
-
}, {
|
|
14
|
-
value: string;
|
|
15
|
-
asset: string;
|
|
16
|
-
decimals: number;
|
|
17
|
-
}>;
|
|
9
|
+
}, z.core.$strip>;
|
|
18
10
|
daily_cap: z.ZodOptional<z.ZodObject<{
|
|
19
11
|
value: z.ZodString;
|
|
20
12
|
asset: z.ZodString;
|
|
21
13
|
decimals: z.ZodNumber;
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
asset: string;
|
|
25
|
-
decimals: number;
|
|
26
|
-
}, {
|
|
27
|
-
value: string;
|
|
28
|
-
asset: string;
|
|
29
|
-
decimals: number;
|
|
30
|
-
}>>;
|
|
31
|
-
allowed_pay_to: z.ZodArray<z.ZodString, "many">;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
allowed_pay_to: z.ZodArray<z.ZodString>;
|
|
32
16
|
allowed_assets: z.ZodArray<z.ZodObject<{
|
|
33
17
|
symbol: z.ZodString;
|
|
34
18
|
decimals: z.ZodNumber;
|
|
35
19
|
address: z.ZodString;
|
|
36
20
|
network: z.ZodString;
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
decimals: number;
|
|
40
|
-
address: string;
|
|
41
|
-
network: string;
|
|
42
|
-
}, {
|
|
43
|
-
symbol: string;
|
|
44
|
-
decimals: number;
|
|
45
|
-
address: string;
|
|
46
|
-
network: string;
|
|
47
|
-
}>, "many">;
|
|
48
|
-
allowed_networks: z.ZodArray<z.ZodString, "many">;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
allowed_networks: z.ZodArray<z.ZodString>;
|
|
49
23
|
max_timeout_seconds: z.ZodNumber;
|
|
50
24
|
require_human_above: z.ZodOptional<z.ZodObject<{
|
|
51
25
|
value: z.ZodString;
|
|
52
26
|
asset: z.ZodString;
|
|
53
27
|
decimals: z.ZodNumber;
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
decimals: number;
|
|
75
|
-
address: string;
|
|
76
|
-
network: string;
|
|
77
|
-
}[];
|
|
78
|
-
allowed_networks: string[];
|
|
79
|
-
max_timeout_seconds: number;
|
|
80
|
-
unknown_payee: "review" | "deny";
|
|
81
|
-
daily_cap?: {
|
|
82
|
-
value: string;
|
|
83
|
-
asset: string;
|
|
84
|
-
decimals: number;
|
|
85
|
-
} | undefined;
|
|
86
|
-
require_human_above?: {
|
|
87
|
-
value: string;
|
|
88
|
-
asset: string;
|
|
89
|
-
decimals: number;
|
|
90
|
-
} | undefined;
|
|
91
|
-
}, {
|
|
92
|
-
version: 1;
|
|
93
|
-
max_amount: {
|
|
94
|
-
value: string;
|
|
95
|
-
asset: string;
|
|
96
|
-
decimals: number;
|
|
97
|
-
};
|
|
98
|
-
allowed_pay_to: string[];
|
|
99
|
-
allowed_assets: {
|
|
100
|
-
symbol: string;
|
|
101
|
-
decimals: number;
|
|
102
|
-
address: string;
|
|
103
|
-
network: string;
|
|
104
|
-
}[];
|
|
105
|
-
allowed_networks: string[];
|
|
106
|
-
max_timeout_seconds: number;
|
|
107
|
-
unknown_payee: "review" | "deny";
|
|
108
|
-
daily_cap?: {
|
|
109
|
-
value: string;
|
|
110
|
-
asset: string;
|
|
111
|
-
decimals: number;
|
|
112
|
-
} | undefined;
|
|
113
|
-
require_human_above?: {
|
|
114
|
-
value: string;
|
|
115
|
-
asset: string;
|
|
116
|
-
decimals: number;
|
|
117
|
-
} | undefined;
|
|
118
|
-
}>;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
unknown_payee: z.ZodEnum<{
|
|
30
|
+
review: "review";
|
|
31
|
+
deny: "deny";
|
|
32
|
+
}>;
|
|
33
|
+
max_auth_validity_seconds: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
allowed_spenders: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
35
|
+
disallow_unlimited_approvals: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
velocity: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
windows: z.ZodArray<z.ZodObject<{
|
|
38
|
+
window_seconds: z.ZodNumber;
|
|
39
|
+
max_count: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
max_amount: z.ZodOptional<z.ZodObject<{
|
|
41
|
+
value: z.ZodString;
|
|
42
|
+
decimals: z.ZodNumber;
|
|
43
|
+
asset: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
119
48
|
export type PolicyFromSchema = z.infer<typeof PolicySchema>;
|
|
120
49
|
export type ParsedPolicy = Policy;
|
package/dist/schema.js
CHANGED
|
@@ -17,6 +17,18 @@ const assetSchema = z.object({
|
|
|
17
17
|
.string()
|
|
18
18
|
.regex(/^eip155:\d+$/, "Expected a network id like eip155:8453")
|
|
19
19
|
});
|
|
20
|
+
const velocityAmountSchema = z.object({
|
|
21
|
+
value: z
|
|
22
|
+
.string()
|
|
23
|
+
.regex(/^\d+(?:\.\d+)?$/, "Amount value must be a non-negative decimal string"),
|
|
24
|
+
decimals: z.number().int().min(0),
|
|
25
|
+
asset: z.string().min(1).optional(),
|
|
26
|
+
});
|
|
27
|
+
const velocityWindowSchema = z.object({
|
|
28
|
+
window_seconds: z.number().int().positive(),
|
|
29
|
+
max_count: z.number().int().nonnegative().optional(),
|
|
30
|
+
max_amount: velocityAmountSchema.optional(),
|
|
31
|
+
});
|
|
20
32
|
export const PolicySchema = z.object({
|
|
21
33
|
version: z.literal(1),
|
|
22
34
|
max_amount: amountSpecSchema,
|
|
@@ -28,5 +40,11 @@ export const PolicySchema = z.object({
|
|
|
28
40
|
.min(1),
|
|
29
41
|
max_timeout_seconds: z.number().int().positive(),
|
|
30
42
|
require_human_above: amountSpecSchema.optional(),
|
|
31
|
-
unknown_payee: z.enum(["review", "deny"])
|
|
43
|
+
unknown_payee: z.enum(["review", "deny"]),
|
|
44
|
+
max_auth_validity_seconds: z.number().int().positive().optional(),
|
|
45
|
+
allowed_spenders: z.array(addressSchema).optional(),
|
|
46
|
+
disallow_unlimited_approvals: z.boolean().optional(),
|
|
47
|
+
velocity: z
|
|
48
|
+
.object({ windows: z.array(velocityWindowSchema).min(1) })
|
|
49
|
+
.optional()
|
|
32
50
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -10,6 +10,19 @@ export interface Asset {
|
|
|
10
10
|
address: string;
|
|
11
11
|
network: string;
|
|
12
12
|
}
|
|
13
|
+
export interface VelocityAmountSpec {
|
|
14
|
+
value: string;
|
|
15
|
+
decimals: number;
|
|
16
|
+
asset?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface VelocityWindow {
|
|
19
|
+
/** Rolling window length in seconds (e.g. 300, 1800, 18000). */
|
|
20
|
+
window_seconds: number;
|
|
21
|
+
/** Max number of transactions allowed in the window. */
|
|
22
|
+
max_count?: number;
|
|
23
|
+
/** Max aggregate amount allowed in the window. */
|
|
24
|
+
max_amount?: VelocityAmountSpec;
|
|
25
|
+
}
|
|
13
26
|
export interface Policy {
|
|
14
27
|
version: 1;
|
|
15
28
|
max_amount: AmountSpec;
|
|
@@ -20,4 +33,11 @@ export interface Policy {
|
|
|
20
33
|
max_timeout_seconds: number;
|
|
21
34
|
require_human_above?: AmountSpec;
|
|
22
35
|
unknown_payee: UnknownPayee;
|
|
36
|
+
max_auth_validity_seconds?: number;
|
|
37
|
+
allowed_spenders?: string[];
|
|
38
|
+
disallow_unlimited_approvals?: boolean;
|
|
39
|
+
/** Optional rolling-window rate and spend-pattern limits. */
|
|
40
|
+
velocity?: {
|
|
41
|
+
windows: VelocityWindow[];
|
|
42
|
+
};
|
|
23
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paystage/policy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Shared spending policy schema and loader for PayStage agent payment tools",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"!dist/**/*.map"
|
|
17
18
|
],
|
|
18
19
|
"engines": {
|
|
19
20
|
"node": ">=20"
|
|
@@ -45,11 +46,11 @@
|
|
|
45
46
|
"prepublishOnly": "npm run typecheck && npm run build"
|
|
46
47
|
},
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"zod": "^
|
|
49
|
+
"zod": "^4.6.7"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@types/node": "^20.14.0",
|
|
52
53
|
"typescript": "^5.5.4",
|
|
53
|
-
"vitest": "^
|
|
54
|
+
"vitest": "^4.1.12"
|
|
54
55
|
}
|
|
55
56
|
}
|