@getpara/shared 1.29.0 → 1.31.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/cjs/index.js +1 -0
- package/dist/cjs/schemas/permissionsV2.js +577 -6
- package/dist/cjs/schemas/permissionsV2UserParameters.js +85 -0
- package/dist/cjs/types/authFactor.js +9 -7
- package/dist/cjs/types/authState.js +15 -16
- package/dist/esm/index.js +1 -0
- package/dist/esm/schemas/permissionsV2.js +575 -5
- package/dist/esm/schemas/permissionsV2UserParameters.js +82 -0
- package/dist/esm/types/authFactor.js +9 -7
- package/dist/esm/types/authState.js +15 -16
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/schemas/permissionsV2.d.ts +12656 -513
- package/dist/types/schemas/permissionsV2.d.ts.map +1 -1
- package/dist/types/schemas/permissionsV2UserParameters.d.ts +468 -0
- package/dist/types/schemas/permissionsV2UserParameters.d.ts.map +1 -0
- package/dist/types/types/auth.d.ts +46 -0
- package/dist/types/types/auth.d.ts.map +1 -1
- package/dist/types/types/authFactor.d.ts +57 -23
- package/dist/types/types/authFactor.d.ts.map +1 -1
- package/dist/types/types/authState.d.ts +224 -88
- package/dist/types/types/authState.d.ts.map +1 -1
- package/dist/types/types/partner.d.ts +2 -0
- package/dist/types/types/partner.d.ts.map +1 -1
- package/dist/types/types/pending-transaction.d.ts +2 -0
- package/dist/types/types/pending-transaction.d.ts.map +1 -1
- package/dist/types/types/permissions.d.ts +25 -2
- package/dist/types/types/permissions.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.permissionsV2DelegationConsentViewSchema = exports.permissionsV2DelegationConsentSubmissionSchema = exports.permissionsV2DelegationConsentStandingRouteMutationSchema = exports.permissionsV2DelegationConsentNativeStandingMutationSchema = exports.permissionsV2DelegationConsentStandingMutationSchema = exports.permissionsV2DelegationConsentMutationSchema = exports.permissionsV2DelegationConsentApiStatusSchema = exports.permissionsV2DelegationPolicyDefinitionSchema = exports.permissionsV2PartnerAuthoredPolicyDefinitionSchema = exports.permissionsV2PartnerPolicyCandidateSchema = exports.permissionsV2PolicyRuleSchema = exports.permissionsV2ConditionalApprovalCaseListSchema = exports.permissionsV2TransactionSignatureCollectionSchema = exports.permissionsV2ConditionalApprovalSignatureSchema = exports.permissionsV2ConditionalApprovalDecisionSchema = exports.permissionsV2AuthorizationConfigurationViewSchema = exports.permissionsV2AuthorizationConfigurationWriteSchema = exports.permissionsV2AuthorizationScopeBindingViewSchema = exports.permissionsV2AuthorizationScopeBindingWriteSchema = exports.permissionsV2AuthoritySetViewSchema = exports.permissionsV2AuthoritySetWriteSchema = exports.permissionsV2AuthorityAssignmentSchema = exports.permissionsV2ConditionalApprovalCaseViewSchema = exports.permissionsV2ConditionalApprovalRequirementIdentitySchema = exports.permissionsV2ConditionalApprovalDecisionCapabilitySchema = exports.permissionsV2ConditionalApprovalDecisionUnavailableReasonSchema = exports.permissionsV2ConditionalApprovalCaseStatusSchema = exports.permissionsV2ConditionalApprovalRequirementSchema = exports.permissionsV2ConditionalApprovalSafeKnobSchema = exports.permissionsV2ConditionalApprovalStageSchema = exports.permissionsV2ConditionalApprovalEligibilitySchema = exports.permissionsV2PartnerPolicyMetadataSchema = exports.permissionsV2PolicyMetadataSchema = exports.permissionsV2PartnerAuthoredPolicySelectorSchema = exports.permissionsV2ConditionSchema = exports.policyAuthoringJsonObjectSchema = exports.policyAuthoringJsonValueSchema = exports.policyAuthoringJsonPrimitiveSchema = exports.permissionsV2SigningRequestTypeSchema = exports.permissionsV2SigningRequestRouteSchema = exports.permissionsV2SigningWalletTypeSchema = exports.permissionsV2AggregateOperatorSchema = exports.permissionsV2CompareOperatorSchema = exports.permissionsV2PolicyEffectSchema = exports.permissionsV2PolicyModeSchema = exports.permissionsV2PolicyLayerSchema = exports.permissionsV2ParameterDeclarationSchema = exports.permissionsV2SigningRequestTypes = exports.policyAuthoringSigningRequestRoutes = exports.policyAuthoringSigningWalletTypes = void 0;
|
|
4
|
+
exports.permissionsV2ValidationErrorSchema = exports.permissionsV2DelegationConsentDiscoveryResponseSchema = exports.permissionsV2DelegationConsentSubmissionResponseSchema = exports.permissionsV2DelegationConsentRequestSchema = void 0;
|
|
4
5
|
const zod_1 = require("zod");
|
|
5
|
-
|
|
6
|
+
const permissionsV2UserParameters_js_1 = require("./permissionsV2UserParameters.js");
|
|
7
|
+
exports.policyAuthoringSigningWalletTypes = ['EVM', 'SOLANA', 'COSMOS', 'STELLAR', 'SUI'];
|
|
6
8
|
exports.policyAuthoringSigningRequestRoutes = [
|
|
7
9
|
'evm.sign_transaction',
|
|
8
10
|
'evm.sign_raw',
|
|
@@ -10,6 +12,10 @@ exports.policyAuthoringSigningRequestRoutes = [
|
|
|
10
12
|
'evm.sign_authorization',
|
|
11
13
|
'evm.sign_message',
|
|
12
14
|
'smart_account.user_operation',
|
|
15
|
+
'solana.sign_transaction',
|
|
16
|
+
'cosmos.sign_transaction',
|
|
17
|
+
'stellar.sign_transaction',
|
|
18
|
+
'sui.sign_transaction',
|
|
13
19
|
];
|
|
14
20
|
exports.permissionsV2SigningRequestTypes = [
|
|
15
21
|
'evm_transaction',
|
|
@@ -18,8 +24,20 @@ exports.permissionsV2SigningRequestTypes = [
|
|
|
18
24
|
'evm_typed_data',
|
|
19
25
|
'evm_authorization',
|
|
20
26
|
'smart_account_user_operation',
|
|
27
|
+
'solana_transaction',
|
|
28
|
+
'cosmos_transaction',
|
|
29
|
+
'cosmos_message',
|
|
30
|
+
'stellar_transaction',
|
|
31
|
+
'sui_transaction',
|
|
32
|
+
'raw_message',
|
|
21
33
|
];
|
|
22
34
|
const nonEmptyStringSchema = zod_1.z.string().min(1);
|
|
35
|
+
exports.permissionsV2ParameterDeclarationSchema = zod_1.z
|
|
36
|
+
.object({
|
|
37
|
+
id: nonEmptyStringSchema,
|
|
38
|
+
label: nonEmptyStringSchema,
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
23
41
|
const uniqueNonEmptyStringsSchema = zod_1.z
|
|
24
42
|
.array(nonEmptyStringSchema)
|
|
25
43
|
.min(1)
|
|
@@ -51,6 +69,7 @@ exports.permissionsV2ConditionSchema = zod_1.z.lazy(() => zod_1.z.discriminatedU
|
|
|
51
69
|
fact: nonEmptyStringSchema,
|
|
52
70
|
op: exports.permissionsV2CompareOperatorSchema,
|
|
53
71
|
value: exports.policyAuthoringJsonValueSchema,
|
|
72
|
+
parameter: exports.permissionsV2ParameterDeclarationSchema.optional(),
|
|
54
73
|
})
|
|
55
74
|
.strict(),
|
|
56
75
|
zod_1.z
|
|
@@ -61,6 +80,7 @@ exports.permissionsV2ConditionSchema = zod_1.z.lazy(() => zod_1.z.discriminatedU
|
|
|
61
80
|
value: nonEmptyStringSchema,
|
|
62
81
|
window: nonEmptyStringSchema,
|
|
63
82
|
asset: nonEmptyStringSchema.optional(),
|
|
83
|
+
parameter: exports.permissionsV2ParameterDeclarationSchema.optional(),
|
|
64
84
|
})
|
|
65
85
|
.strict(),
|
|
66
86
|
zod_1.z
|
|
@@ -82,7 +102,7 @@ exports.permissionsV2ConditionSchema = zod_1.z.lazy(() => zod_1.z.discriminatedU
|
|
|
82
102
|
})
|
|
83
103
|
.strict(),
|
|
84
104
|
]));
|
|
85
|
-
|
|
105
|
+
const permissionsV2PartnerAuthoredPolicySelectorObjectSchema = zod_1.z
|
|
86
106
|
.object({
|
|
87
107
|
walletId: nonEmptyStringSchema.optional(),
|
|
88
108
|
chainId: zod_1.z.union([nonEmptyStringSchema, uniqueNonEmptyStringsSchema]).optional(),
|
|
@@ -91,6 +111,7 @@ exports.permissionsV2PartnerAuthoredPolicySelectorSchema = zod_1.z
|
|
|
91
111
|
requestType: exports.permissionsV2SigningRequestTypeSchema.optional(),
|
|
92
112
|
})
|
|
93
113
|
.strict();
|
|
114
|
+
exports.permissionsV2PartnerAuthoredPolicySelectorSchema = permissionsV2PartnerAuthoredPolicySelectorObjectSchema;
|
|
94
115
|
exports.permissionsV2PolicyMetadataSchema = zod_1.z
|
|
95
116
|
.object({
|
|
96
117
|
label: zod_1.z.string().optional(),
|
|
@@ -102,19 +123,544 @@ exports.permissionsV2PolicyMetadataSchema = zod_1.z
|
|
|
102
123
|
exports.permissionsV2PartnerPolicyMetadataSchema = exports.permissionsV2PolicyMetadataSchema.extend({
|
|
103
124
|
productMode: exports.permissionsV2PolicyModeSchema,
|
|
104
125
|
});
|
|
126
|
+
const conditionalApprovalNameSchema = zod_1.z
|
|
127
|
+
.string()
|
|
128
|
+
.trim()
|
|
129
|
+
.min(1)
|
|
130
|
+
.max(64)
|
|
131
|
+
.refine((value) => value === value.normalize('NFKC'), {
|
|
132
|
+
message: 'names must use normalized Unicode',
|
|
133
|
+
});
|
|
134
|
+
const conditionalApprovalIdentifierSchema = zod_1.z.string().trim().min(1).max(64);
|
|
135
|
+
const conditionalApprovalActorIdSchema = zod_1.z.string().trim().min(1).max(128);
|
|
136
|
+
const conditionalApprovalRequestIdSchema = zod_1.z.string().trim().min(1).max(256);
|
|
137
|
+
exports.permissionsV2ConditionalApprovalEligibilitySchema = zod_1.z.union([
|
|
138
|
+
zod_1.z
|
|
139
|
+
.object({
|
|
140
|
+
kind: zod_1.z.literal('role'),
|
|
141
|
+
name: conditionalApprovalNameSchema,
|
|
142
|
+
})
|
|
143
|
+
.strict(),
|
|
144
|
+
zod_1.z
|
|
145
|
+
.object({
|
|
146
|
+
kind: zod_1.z.literal('attribute'),
|
|
147
|
+
name: conditionalApprovalNameSchema,
|
|
148
|
+
operator: zod_1.z.literal('eq'),
|
|
149
|
+
value: conditionalApprovalNameSchema,
|
|
150
|
+
})
|
|
151
|
+
.strict(),
|
|
152
|
+
zod_1.z
|
|
153
|
+
.object({
|
|
154
|
+
kind: zod_1.z.literal('attribute'),
|
|
155
|
+
name: conditionalApprovalNameSchema,
|
|
156
|
+
operator: zod_1.z.literal('in'),
|
|
157
|
+
values: zod_1.z
|
|
158
|
+
.array(conditionalApprovalNameSchema)
|
|
159
|
+
.min(1)
|
|
160
|
+
.refine((values) => new Set(values).size === values.length, {
|
|
161
|
+
message: 'attribute values must be unique',
|
|
162
|
+
}),
|
|
163
|
+
})
|
|
164
|
+
.strict(),
|
|
165
|
+
]);
|
|
166
|
+
const conditionalApprovalEligibilityListSchema = zod_1.z
|
|
167
|
+
.array(exports.permissionsV2ConditionalApprovalEligibilitySchema)
|
|
168
|
+
.min(1)
|
|
169
|
+
.max(10)
|
|
170
|
+
.refine((eligibility) => new Set(eligibility.map((clause) => JSON.stringify(clause))).size === eligibility.length, {
|
|
171
|
+
message: 'eligibility clauses must be unique',
|
|
172
|
+
});
|
|
173
|
+
exports.permissionsV2ConditionalApprovalStageSchema = zod_1.z
|
|
174
|
+
.object({
|
|
175
|
+
id: conditionalApprovalIdentifierSchema,
|
|
176
|
+
requiredApprovals: zod_1.z.union([zod_1.z.number().int().min(1).max(25), zod_1.z.literal('all')]),
|
|
177
|
+
eligibility: conditionalApprovalEligibilityListSchema,
|
|
178
|
+
minimumAmount: zod_1.z
|
|
179
|
+
.string()
|
|
180
|
+
.regex(/^(0|[1-9][0-9]*)$/)
|
|
181
|
+
.optional(),
|
|
182
|
+
})
|
|
183
|
+
.strict();
|
|
184
|
+
const conditionalApprovalRequiredCountKnobSchema = zod_1.z
|
|
185
|
+
.object({
|
|
186
|
+
id: conditionalApprovalIdentifierSchema,
|
|
187
|
+
kind: zod_1.z.literal('required_approvals'),
|
|
188
|
+
stageId: conditionalApprovalIdentifierSchema,
|
|
189
|
+
min: zod_1.z.number().int().min(1).max(25),
|
|
190
|
+
max: zod_1.z.number().int().min(1).max(25),
|
|
191
|
+
})
|
|
192
|
+
.strict()
|
|
193
|
+
.refine((knob) => knob.min <= knob.max, { message: 'minimum required approvals must not exceed maximum' });
|
|
194
|
+
const conditionalApprovalEligibleGroupOptionSchema = zod_1.z
|
|
195
|
+
.object({
|
|
196
|
+
id: conditionalApprovalIdentifierSchema,
|
|
197
|
+
eligibility: conditionalApprovalEligibilityListSchema,
|
|
198
|
+
})
|
|
199
|
+
.strict();
|
|
200
|
+
const conditionalApprovalEligibleGroupKnobSchema = zod_1.z
|
|
201
|
+
.object({
|
|
202
|
+
id: conditionalApprovalIdentifierSchema,
|
|
203
|
+
kind: zod_1.z.literal('eligible_group'),
|
|
204
|
+
stageId: conditionalApprovalIdentifierSchema,
|
|
205
|
+
defaultOptionId: conditionalApprovalIdentifierSchema,
|
|
206
|
+
options: zod_1.z
|
|
207
|
+
.array(conditionalApprovalEligibleGroupOptionSchema)
|
|
208
|
+
.min(1)
|
|
209
|
+
.max(25)
|
|
210
|
+
.refine((options) => new Set(options.map((option) => option.id)).size === options.length, {
|
|
211
|
+
message: 'eligible group option identifiers must be unique',
|
|
212
|
+
}),
|
|
213
|
+
})
|
|
214
|
+
.strict();
|
|
215
|
+
exports.permissionsV2ConditionalApprovalSafeKnobSchema = zod_1.z.union([
|
|
216
|
+
conditionalApprovalRequiredCountKnobSchema,
|
|
217
|
+
conditionalApprovalEligibleGroupKnobSchema,
|
|
218
|
+
zod_1.z
|
|
219
|
+
.object({
|
|
220
|
+
id: conditionalApprovalIdentifierSchema,
|
|
221
|
+
kind: zod_1.z.literal('minimum_amount'),
|
|
222
|
+
stageId: conditionalApprovalIdentifierSchema,
|
|
223
|
+
})
|
|
224
|
+
.strict(),
|
|
225
|
+
]);
|
|
226
|
+
exports.permissionsV2ConditionalApprovalRequirementSchema = zod_1.z
|
|
227
|
+
.object({
|
|
228
|
+
id: conditionalApprovalIdentifierSchema,
|
|
229
|
+
evidence: zod_1.z.enum(['authenticated_approval', 'transaction_signature']).optional(),
|
|
230
|
+
amountFact: zod_1.z.enum(['request.value.baseUnits', 'request.token.value.baseUnits']).optional(),
|
|
231
|
+
stages: zod_1.z
|
|
232
|
+
.array(exports.permissionsV2ConditionalApprovalStageSchema)
|
|
233
|
+
.min(1)
|
|
234
|
+
.max(5)
|
|
235
|
+
.refine((stages) => new Set(stages.map((stage) => stage.id)).size === stages.length, {
|
|
236
|
+
message: 'stage identifiers must be unique',
|
|
237
|
+
}),
|
|
238
|
+
configurationManagerEligibility: conditionalApprovalEligibilityListSchema.optional(),
|
|
239
|
+
safeKnobs: zod_1.z
|
|
240
|
+
.array(exports.permissionsV2ConditionalApprovalSafeKnobSchema)
|
|
241
|
+
.min(1)
|
|
242
|
+
.refine((knobs) => new Set(knobs.map((knob) => knob.id)).size === knobs.length, {
|
|
243
|
+
message: 'safe knob identifiers must be unique',
|
|
244
|
+
})
|
|
245
|
+
.optional(),
|
|
246
|
+
})
|
|
247
|
+
.strict()
|
|
248
|
+
.superRefine((requirement, context) => {
|
|
249
|
+
const stagesById = new Map(requirement.stages.map((stage) => [stage.id, stage]));
|
|
250
|
+
const configuredStageIds = new Set();
|
|
251
|
+
const hasBands = requirement.stages.some((stage) => stage.minimumAmount !== undefined);
|
|
252
|
+
if (hasBands !== (requirement.amountFact !== undefined)) {
|
|
253
|
+
context.addIssue({
|
|
254
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
255
|
+
path: ['amountFact'],
|
|
256
|
+
message: 'amount bands require an explicit amount fact',
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
let previousAmount = BigInt(0);
|
|
260
|
+
requirement.stages.forEach((stage, index) => {
|
|
261
|
+
if (index === 0) {
|
|
262
|
+
if (stage.minimumAmount !== undefined) {
|
|
263
|
+
context.addIssue({
|
|
264
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
265
|
+
path: ['stages', index, 'minimumAmount'],
|
|
266
|
+
message: 'the first stage must apply to every amount',
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (!hasBands)
|
|
272
|
+
return;
|
|
273
|
+
if (stage.minimumAmount === undefined ||
|
|
274
|
+
!/^(0|[1-9][0-9]*)$/.test(stage.minimumAmount) ||
|
|
275
|
+
BigInt(stage.minimumAmount) <= previousAmount) {
|
|
276
|
+
context.addIssue({
|
|
277
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
278
|
+
path: ['stages', index, 'minimumAmount'],
|
|
279
|
+
message: 'stage amount thresholds must be positive and strictly increasing',
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
previousAmount = BigInt(stage.minimumAmount);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
requirement.safeKnobs?.forEach((knob, index) => {
|
|
287
|
+
const stage = stagesById.get(knob.stageId);
|
|
288
|
+
if (stage === undefined) {
|
|
289
|
+
context.addIssue({
|
|
290
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
291
|
+
path: ['safeKnobs', index, 'stageId'],
|
|
292
|
+
message: 'safe knob must reference an existing stage',
|
|
293
|
+
});
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const settingKey = `${knob.stageId}:${knob.kind === 'minimum_amount' ? 'amount' : 'participation'}`;
|
|
297
|
+
if (configuredStageIds.has(settingKey)) {
|
|
298
|
+
context.addIssue({
|
|
299
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
300
|
+
path: ['safeKnobs', index, 'stageId'],
|
|
301
|
+
message: 'a stage may expose one participation setting and one amount threshold',
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
configuredStageIds.add(settingKey);
|
|
305
|
+
if (knob.kind === 'minimum_amount') {
|
|
306
|
+
if (stage.minimumAmount === undefined) {
|
|
307
|
+
context.addIssue({
|
|
308
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
309
|
+
path: ['safeKnobs', index, 'stageId'],
|
|
310
|
+
message: 'amount settings must reference a declared stage threshold',
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (knob.kind === 'required_approvals') {
|
|
316
|
+
if (typeof stage.requiredApprovals !== 'number') {
|
|
317
|
+
context.addIssue({
|
|
318
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
319
|
+
path: ['safeKnobs', index, 'stageId'],
|
|
320
|
+
message: 'required count ranges apply only to numeric approval counts',
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
else if (stage.requiredApprovals < knob.min || stage.requiredApprovals > knob.max) {
|
|
324
|
+
context.addIssue({
|
|
325
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
326
|
+
path: ['safeKnobs', index],
|
|
327
|
+
message: 'the published approval count must be within the configurable range',
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const defaultOption = knob.options.find((option) => option.id === knob.defaultOptionId);
|
|
333
|
+
if (defaultOption === undefined) {
|
|
334
|
+
context.addIssue({
|
|
335
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
336
|
+
path: ['safeKnobs', index, 'defaultOptionId'],
|
|
337
|
+
message: 'default group must reference a declared option',
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
else if (JSON.stringify(defaultOption.eligibility) !== JSON.stringify(stage.eligibility)) {
|
|
341
|
+
context.addIssue({
|
|
342
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
343
|
+
path: ['safeKnobs', index, 'defaultOptionId'],
|
|
344
|
+
message: 'default group must match the published stage eligibility',
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
exports.permissionsV2ConditionalApprovalCaseStatusSchema = zod_1.z.enum([
|
|
350
|
+
'pending',
|
|
351
|
+
'completed',
|
|
352
|
+
'rejected',
|
|
353
|
+
'expired',
|
|
354
|
+
'invalidated',
|
|
355
|
+
]);
|
|
356
|
+
exports.permissionsV2ConditionalApprovalDecisionUnavailableReasonSchema = zod_1.z.enum([
|
|
357
|
+
'not_eligible',
|
|
358
|
+
'initiator',
|
|
359
|
+
'already_decided',
|
|
360
|
+
'case_terminal',
|
|
361
|
+
'authority_changed',
|
|
362
|
+
]);
|
|
363
|
+
exports.permissionsV2ConditionalApprovalDecisionCapabilitySchema = zod_1.z.discriminatedUnion('canDecide', [
|
|
364
|
+
zod_1.z
|
|
365
|
+
.object({
|
|
366
|
+
canDecide: zod_1.z.literal(true),
|
|
367
|
+
intents: zod_1.z.tuple([zod_1.z.literal('approve'), zod_1.z.literal('reject')]),
|
|
368
|
+
})
|
|
369
|
+
.strict(),
|
|
370
|
+
zod_1.z
|
|
371
|
+
.object({
|
|
372
|
+
canDecide: zod_1.z.literal(false),
|
|
373
|
+
reason: exports.permissionsV2ConditionalApprovalDecisionUnavailableReasonSchema,
|
|
374
|
+
})
|
|
375
|
+
.strict(),
|
|
376
|
+
]);
|
|
377
|
+
exports.permissionsV2ConditionalApprovalRequirementIdentitySchema = zod_1.z
|
|
378
|
+
.object({
|
|
379
|
+
requirementId: conditionalApprovalIdentifierSchema,
|
|
380
|
+
policyId: conditionalApprovalIdentifierSchema,
|
|
381
|
+
policyVersion: conditionalApprovalIdentifierSchema,
|
|
382
|
+
ruleId: conditionalApprovalIdentifierSchema,
|
|
383
|
+
stackHash: zod_1.z.string().min(1),
|
|
384
|
+
authorizationScopeId: conditionalApprovalActorIdSchema,
|
|
385
|
+
configurationHash: zod_1.z.string().min(1).optional(),
|
|
386
|
+
})
|
|
387
|
+
.strict();
|
|
388
|
+
const conditionalApprovalCaseStageViewSchema = zod_1.z
|
|
389
|
+
.object({
|
|
390
|
+
id: conditionalApprovalIdentifierSchema,
|
|
391
|
+
requiredApprovals: zod_1.z.number().int().min(1).max(25),
|
|
392
|
+
eligibleActorCount: zod_1.z.number().int().min(1).max(100),
|
|
393
|
+
approvedActorIds: zod_1.z
|
|
394
|
+
.array(conditionalApprovalActorIdSchema)
|
|
395
|
+
.refine((actorIds) => new Set(actorIds).size === actorIds.length, {
|
|
396
|
+
message: 'approved actor identifiers must be unique',
|
|
397
|
+
}),
|
|
398
|
+
})
|
|
399
|
+
.strict();
|
|
400
|
+
const conditionalApprovalRequestArgsSchema = zod_1.z
|
|
401
|
+
.record(conditionalApprovalIdentifierSchema, zod_1.z.string().min(1).max(512))
|
|
402
|
+
.refine((args) => Object.keys(args).length <= 25, {
|
|
403
|
+
message: 'request summaries may include at most twenty-five arguments',
|
|
404
|
+
});
|
|
405
|
+
exports.permissionsV2ConditionalApprovalCaseViewSchema = zod_1.z
|
|
406
|
+
.object({
|
|
407
|
+
kind: zod_1.z.literal('conditional_approval'),
|
|
408
|
+
caseId: conditionalApprovalIdentifierSchema,
|
|
409
|
+
status: exports.permissionsV2ConditionalApprovalCaseStatusSchema,
|
|
410
|
+
evidence: zod_1.z.enum(['authenticated_approval', 'transaction_signature']).optional(),
|
|
411
|
+
request: zod_1.z
|
|
412
|
+
.object({
|
|
413
|
+
id: conditionalApprovalRequestIdSchema,
|
|
414
|
+
requestHash: nonEmptyStringSchema,
|
|
415
|
+
walletId: nonEmptyStringSchema,
|
|
416
|
+
requestType: exports.permissionsV2SigningRequestTypeSchema,
|
|
417
|
+
chainId: nonEmptyStringSchema.optional(),
|
|
418
|
+
classification: nonEmptyStringSchema,
|
|
419
|
+
// Signature collections expose only an encoded source; some native payloads have none.
|
|
420
|
+
from: nonEmptyStringSchema.optional(),
|
|
421
|
+
to: nonEmptyStringSchema.optional(),
|
|
422
|
+
value: zod_1.z
|
|
423
|
+
.object({
|
|
424
|
+
baseUnits: zod_1.z.string().regex(/^(0|[1-9][0-9]*)$/),
|
|
425
|
+
asset: nonEmptyStringSchema.optional(),
|
|
426
|
+
decimals: zod_1.z.number().int().nonnegative().optional(),
|
|
427
|
+
})
|
|
428
|
+
.strict()
|
|
429
|
+
.optional(),
|
|
430
|
+
method: zod_1.z.string().min(1).max(256).optional(),
|
|
431
|
+
payloadDigest: zod_1.z.string().min(1).max(256).optional(),
|
|
432
|
+
args: conditionalApprovalRequestArgsSchema.optional(),
|
|
433
|
+
})
|
|
434
|
+
.strict(),
|
|
435
|
+
requirementIdentity: exports.permissionsV2ConditionalApprovalRequirementIdentitySchema,
|
|
436
|
+
currentStageIndex: zod_1.z.number().int().nonnegative(),
|
|
437
|
+
stages: zod_1.z.array(conditionalApprovalCaseStageViewSchema).min(1).max(5),
|
|
438
|
+
decisions: zod_1.z
|
|
439
|
+
.array(zod_1.z
|
|
440
|
+
.object({
|
|
441
|
+
actorId: conditionalApprovalActorIdSchema,
|
|
442
|
+
stageId: conditionalApprovalIdentifierSchema,
|
|
443
|
+
intent: zod_1.z.enum(['approve', 'reject']),
|
|
444
|
+
decidedAt: zod_1.z.string().datetime(),
|
|
445
|
+
})
|
|
446
|
+
.strict())
|
|
447
|
+
.max(126),
|
|
448
|
+
expiresAt: zod_1.z.string().datetime(),
|
|
449
|
+
terminalReason: zod_1.z.string().min(1).optional(),
|
|
450
|
+
decision: exports.permissionsV2ConditionalApprovalDecisionCapabilitySchema,
|
|
451
|
+
})
|
|
452
|
+
.strict();
|
|
453
|
+
exports.permissionsV2AuthorityAssignmentSchema = zod_1.z.union([
|
|
454
|
+
zod_1.z
|
|
455
|
+
.object({
|
|
456
|
+
kind: zod_1.z.literal('role'),
|
|
457
|
+
name: conditionalApprovalNameSchema,
|
|
458
|
+
})
|
|
459
|
+
.strict(),
|
|
460
|
+
zod_1.z
|
|
461
|
+
.object({
|
|
462
|
+
kind: zod_1.z.literal('attribute'),
|
|
463
|
+
name: conditionalApprovalNameSchema,
|
|
464
|
+
value: conditionalApprovalNameSchema,
|
|
465
|
+
})
|
|
466
|
+
.strict(),
|
|
467
|
+
]);
|
|
468
|
+
const conditionalApprovalRevisionSchema = zod_1.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
469
|
+
const conditionalApprovalChangeActorSchema = zod_1.z
|
|
470
|
+
.object({
|
|
471
|
+
type: zod_1.z.enum(['partner_secret', 'configuration_manager']),
|
|
472
|
+
id: conditionalApprovalActorIdSchema,
|
|
473
|
+
})
|
|
474
|
+
.strict();
|
|
475
|
+
exports.permissionsV2AuthoritySetWriteSchema = zod_1.z
|
|
476
|
+
.object({
|
|
477
|
+
expectedRevision: conditionalApprovalRevisionSchema,
|
|
478
|
+
assignments: zod_1.z
|
|
479
|
+
.array(exports.permissionsV2AuthorityAssignmentSchema)
|
|
480
|
+
.max(25)
|
|
481
|
+
.refine((assignments) => new Set(assignments.map((assignment) => JSON.stringify(assignment))).size === assignments.length, {
|
|
482
|
+
message: 'authority assignments must be unique',
|
|
483
|
+
}),
|
|
484
|
+
})
|
|
485
|
+
.strict();
|
|
486
|
+
exports.permissionsV2AuthoritySetViewSchema = zod_1.z
|
|
487
|
+
.object({
|
|
488
|
+
userId: conditionalApprovalActorIdSchema,
|
|
489
|
+
partnerId: nonEmptyStringSchema,
|
|
490
|
+
appId: nonEmptyStringSchema,
|
|
491
|
+
authorizationScopeId: conditionalApprovalActorIdSchema,
|
|
492
|
+
revision: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
493
|
+
assignments: zod_1.z.array(exports.permissionsV2AuthorityAssignmentSchema).max(25),
|
|
494
|
+
changedAt: zod_1.z.string().datetime(),
|
|
495
|
+
changedBy: conditionalApprovalChangeActorSchema,
|
|
496
|
+
})
|
|
497
|
+
.strict();
|
|
498
|
+
exports.permissionsV2AuthorizationScopeBindingWriteSchema = zod_1.z
|
|
499
|
+
.object({
|
|
500
|
+
expectedRevision: conditionalApprovalRevisionSchema,
|
|
501
|
+
authorizationScopeId: conditionalApprovalActorIdSchema,
|
|
502
|
+
})
|
|
503
|
+
.strict();
|
|
504
|
+
exports.permissionsV2AuthorizationScopeBindingViewSchema = zod_1.z
|
|
505
|
+
.object({
|
|
506
|
+
walletId: nonEmptyStringSchema,
|
|
507
|
+
partnerId: nonEmptyStringSchema,
|
|
508
|
+
appId: nonEmptyStringSchema,
|
|
509
|
+
authorizationScopeId: conditionalApprovalActorIdSchema,
|
|
510
|
+
revision: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
511
|
+
changedAt: zod_1.z.string().datetime(),
|
|
512
|
+
changedBy: conditionalApprovalChangeActorSchema,
|
|
513
|
+
})
|
|
514
|
+
.strict();
|
|
515
|
+
const conditionalApprovalConfigurationValuesSchema = zod_1.z
|
|
516
|
+
.record(conditionalApprovalIdentifierSchema, zod_1.z.union([zod_1.z.string(), zod_1.z.number().int()]))
|
|
517
|
+
.refine((values) => Object.keys(values).length <= 25, {
|
|
518
|
+
message: 'conditional approval configuration may contain at most 25 values',
|
|
519
|
+
});
|
|
520
|
+
exports.permissionsV2AuthorizationConfigurationWriteSchema = zod_1.z
|
|
521
|
+
.object({
|
|
522
|
+
expectedRevision: conditionalApprovalRevisionSchema,
|
|
523
|
+
values: conditionalApprovalConfigurationValuesSchema,
|
|
524
|
+
})
|
|
525
|
+
.strict();
|
|
526
|
+
exports.permissionsV2AuthorizationConfigurationViewSchema = zod_1.z
|
|
527
|
+
.object({
|
|
528
|
+
partnerId: nonEmptyStringSchema,
|
|
529
|
+
appId: nonEmptyStringSchema,
|
|
530
|
+
authorizationScopeId: conditionalApprovalActorIdSchema,
|
|
531
|
+
policyId: conditionalApprovalIdentifierSchema,
|
|
532
|
+
policyVersion: conditionalApprovalIdentifierSchema,
|
|
533
|
+
requirementId: conditionalApprovalIdentifierSchema,
|
|
534
|
+
revision: zod_1.z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
535
|
+
values: conditionalApprovalConfigurationValuesSchema,
|
|
536
|
+
configurationHash: nonEmptyStringSchema,
|
|
537
|
+
changedAt: zod_1.z.string().datetime(),
|
|
538
|
+
changedBy: conditionalApprovalChangeActorSchema,
|
|
539
|
+
})
|
|
540
|
+
.strict();
|
|
541
|
+
exports.permissionsV2ConditionalApprovalDecisionSchema = zod_1.z
|
|
542
|
+
.object({
|
|
543
|
+
intent: zod_1.z.enum(['approve', 'reject']),
|
|
544
|
+
})
|
|
545
|
+
.strict();
|
|
546
|
+
exports.permissionsV2ConditionalApprovalSignatureSchema = zod_1.z
|
|
547
|
+
.object({
|
|
548
|
+
walletId: zod_1.z.string().min(1).max(128),
|
|
549
|
+
signature: zod_1.z.string().min(1).max(512),
|
|
550
|
+
})
|
|
551
|
+
.strict();
|
|
552
|
+
/** Original transaction payloads for signature collection, not caller-provided policy facts. */
|
|
553
|
+
exports.permissionsV2TransactionSignatureCollectionSchema = zod_1.z
|
|
554
|
+
.object({
|
|
555
|
+
requestId: zod_1.z.string().min(1).max(128),
|
|
556
|
+
walletId: zod_1.z.string().uuid(),
|
|
557
|
+
transaction: zod_1.z.discriminatedUnion('format', [
|
|
558
|
+
zod_1.z
|
|
559
|
+
.object({
|
|
560
|
+
format: zod_1.z.literal('safe_eip712'),
|
|
561
|
+
typedDataJson: zod_1.z.string().min(1).max(131072),
|
|
562
|
+
chainId: zod_1.z
|
|
563
|
+
.string()
|
|
564
|
+
.regex(/^[1-9][0-9]*$/)
|
|
565
|
+
.max(78),
|
|
566
|
+
})
|
|
567
|
+
.strict(),
|
|
568
|
+
zod_1.z
|
|
569
|
+
.object({
|
|
570
|
+
format: zod_1.z.literal('evm_typed_data'),
|
|
571
|
+
typedDataJson: zod_1.z.string().min(1).max(131072),
|
|
572
|
+
chainId: zod_1.z
|
|
573
|
+
.string()
|
|
574
|
+
.regex(/^[1-9][0-9]*$/)
|
|
575
|
+
.max(78),
|
|
576
|
+
})
|
|
577
|
+
.strict(),
|
|
578
|
+
zod_1.z
|
|
579
|
+
.object({
|
|
580
|
+
format: zod_1.z.literal('evm_transaction'),
|
|
581
|
+
transactionBase64: zod_1.z.string().min(1).max(131072),
|
|
582
|
+
chainId: zod_1.z
|
|
583
|
+
.string()
|
|
584
|
+
.regex(/^[1-9][0-9]*$/)
|
|
585
|
+
.max(78),
|
|
586
|
+
})
|
|
587
|
+
.strict(),
|
|
588
|
+
zod_1.z
|
|
589
|
+
.object({
|
|
590
|
+
format: zod_1.z.literal('solana_transaction'),
|
|
591
|
+
transactionBase64: zod_1.z.string().min(1).max(131072),
|
|
592
|
+
})
|
|
593
|
+
.strict(),
|
|
594
|
+
zod_1.z
|
|
595
|
+
.object({
|
|
596
|
+
format: zod_1.z.literal('cosmos_transaction'),
|
|
597
|
+
signMode: zod_1.z.enum(['DIRECT', 'AMINO']),
|
|
598
|
+
signDocBase64: zod_1.z.string().min(1).max(131072),
|
|
599
|
+
})
|
|
600
|
+
.strict(),
|
|
601
|
+
zod_1.z
|
|
602
|
+
.object({
|
|
603
|
+
format: zod_1.z.literal('stellar_xdr'),
|
|
604
|
+
transactionXdr: zod_1.z.string().min(1).max(131072),
|
|
605
|
+
networkPassphrase: zod_1.z.string().min(1).max(256),
|
|
606
|
+
})
|
|
607
|
+
.strict(),
|
|
608
|
+
zod_1.z
|
|
609
|
+
.object({
|
|
610
|
+
format: zod_1.z.literal('sui_transaction'),
|
|
611
|
+
transactionBase64: zod_1.z.string().min(1).max(131072),
|
|
612
|
+
})
|
|
613
|
+
.strict(),
|
|
614
|
+
]),
|
|
615
|
+
})
|
|
616
|
+
.strict();
|
|
617
|
+
exports.permissionsV2ConditionalApprovalCaseListSchema = zod_1.z
|
|
618
|
+
.object({
|
|
619
|
+
cases: zod_1.z.array(exports.permissionsV2ConditionalApprovalCaseViewSchema),
|
|
620
|
+
})
|
|
621
|
+
.strict();
|
|
105
622
|
exports.permissionsV2PolicyRuleSchema = zod_1.z
|
|
106
623
|
.object({
|
|
107
624
|
id: nonEmptyStringSchema,
|
|
108
625
|
effect: exports.permissionsV2PolicyEffectSchema,
|
|
109
626
|
when: exports.permissionsV2ConditionSchema,
|
|
627
|
+
approvalRequirement: exports.permissionsV2ConditionalApprovalRequirementSchema.optional(),
|
|
110
628
|
})
|
|
111
|
-
.strict()
|
|
629
|
+
.strict()
|
|
630
|
+
.superRefine((rule, context) => {
|
|
631
|
+
if (rule.approvalRequirement !== undefined && rule.effect !== 'require_approval') {
|
|
632
|
+
context.addIssue({
|
|
633
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
634
|
+
path: ['approvalRequirement'],
|
|
635
|
+
message: 'structured approval requirements are only valid for require_approval rules',
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
const permissionsV2PolicyRulesSchema = zod_1.z
|
|
640
|
+
.array(exports.permissionsV2PolicyRuleSchema)
|
|
641
|
+
.min(1)
|
|
642
|
+
.superRefine((rules, context) => {
|
|
643
|
+
const requirementIds = new Set();
|
|
644
|
+
rules.forEach((rule, index) => {
|
|
645
|
+
const requirementId = rule.approvalRequirement?.id;
|
|
646
|
+
if (requirementId === undefined)
|
|
647
|
+
return;
|
|
648
|
+
if (requirementIds.has(requirementId)) {
|
|
649
|
+
context.addIssue({
|
|
650
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
651
|
+
path: [index, 'approvalRequirement', 'id'],
|
|
652
|
+
message: 'approval requirement identifiers must be unique within a policy',
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
requirementIds.add(requirementId);
|
|
656
|
+
});
|
|
657
|
+
});
|
|
112
658
|
const partnerPolicyCandidateFields = {
|
|
113
659
|
id: nonEmptyStringSchema,
|
|
114
660
|
schemaVersion: zod_1.z.literal('permissions.policy.v1'),
|
|
115
661
|
version: nonEmptyStringSchema,
|
|
116
662
|
selector: exports.permissionsV2PartnerAuthoredPolicySelectorSchema,
|
|
117
|
-
rules:
|
|
663
|
+
rules: permissionsV2PolicyRulesSchema,
|
|
118
664
|
metadata: exports.permissionsV2PolicyMetadataSchema.optional(),
|
|
119
665
|
};
|
|
120
666
|
exports.permissionsV2PartnerPolicyCandidateSchema = zod_1.z.object(partnerPolicyCandidateFields).strict();
|
|
@@ -123,7 +669,7 @@ exports.permissionsV2PartnerAuthoredPolicyDefinitionSchema = exports.permissions
|
|
|
123
669
|
});
|
|
124
670
|
exports.permissionsV2DelegationPolicyDefinitionSchema = exports.permissionsV2PartnerAuthoredPolicyDefinitionSchema.extend({
|
|
125
671
|
layer: zod_1.z.literal('partner'),
|
|
126
|
-
selector:
|
|
672
|
+
selector: permissionsV2PartnerAuthoredPolicySelectorObjectSchema.extend({
|
|
127
673
|
partnerId: nonEmptyStringSchema,
|
|
128
674
|
appId: nonEmptyStringSchema,
|
|
129
675
|
}),
|
|
@@ -145,6 +691,7 @@ exports.permissionsV2DelegationConsentMutationSchema = zod_1.z
|
|
|
145
691
|
walletId: nonEmptyStringSchema,
|
|
146
692
|
policyVersion: nonEmptyStringSchema,
|
|
147
693
|
policyHash: nonEmptyStringSchema,
|
|
694
|
+
configurationHash: nonEmptyStringSchema.optional(),
|
|
148
695
|
expiresAt: zod_1.z.string().datetime().optional(),
|
|
149
696
|
})
|
|
150
697
|
.strict();
|
|
@@ -153,6 +700,23 @@ exports.permissionsV2DelegationConsentStandingMutationSchema = exports.permissio
|
|
|
153
700
|
pendingTransactionId: nonEmptyStringSchema,
|
|
154
701
|
})
|
|
155
702
|
.strict();
|
|
703
|
+
exports.permissionsV2DelegationConsentNativeStandingMutationSchema = exports.permissionsV2DelegationConsentMutationSchema
|
|
704
|
+
.extend({
|
|
705
|
+
requestId: exports.permissionsV2TransactionSignatureCollectionSchema.shape.requestId,
|
|
706
|
+
walletId: exports.permissionsV2TransactionSignatureCollectionSchema.shape.walletId,
|
|
707
|
+
transaction: exports.permissionsV2TransactionSignatureCollectionSchema.shape.transaction,
|
|
708
|
+
})
|
|
709
|
+
.strict();
|
|
710
|
+
exports.permissionsV2DelegationConsentStandingRouteMutationSchema = zod_1.z.union([
|
|
711
|
+
exports.permissionsV2DelegationConsentStandingMutationSchema,
|
|
712
|
+
exports.permissionsV2DelegationConsentNativeStandingMutationSchema,
|
|
713
|
+
]);
|
|
714
|
+
/** Explicit owner consent, optionally committed together with personal settings. */
|
|
715
|
+
exports.permissionsV2DelegationConsentSubmissionSchema = exports.permissionsV2DelegationConsentMutationSchema.extend({
|
|
716
|
+
posture: zod_1.z.enum(['standing', 'manual_review']),
|
|
717
|
+
pendingTransactionId: nonEmptyStringSchema.optional(),
|
|
718
|
+
settings: permissionsV2UserParameters_js_1.permissionsV2UserParameterSaveSchema.pick({ expectedRevision: true, values: true }).optional(),
|
|
719
|
+
});
|
|
156
720
|
exports.permissionsV2DelegationConsentViewSchema = zod_1.z
|
|
157
721
|
.object({
|
|
158
722
|
status: exports.permissionsV2DelegationConsentApiStatusSchema,
|
|
@@ -163,6 +727,7 @@ exports.permissionsV2DelegationConsentViewSchema = zod_1.z
|
|
|
163
727
|
policyId: nonEmptyStringSchema,
|
|
164
728
|
policyVersion: nonEmptyStringSchema,
|
|
165
729
|
policyHash: nonEmptyStringSchema,
|
|
730
|
+
configurationHash: nonEmptyStringSchema.optional(),
|
|
166
731
|
grantedAt: zod_1.z.string().datetime().optional(),
|
|
167
732
|
expiresAt: zod_1.z.string().datetime().optional(),
|
|
168
733
|
revokedAt: zod_1.z.string().datetime().optional(),
|
|
@@ -174,6 +739,12 @@ exports.permissionsV2DelegationConsentRequestSchema = zod_1.z
|
|
|
174
739
|
consent: exports.permissionsV2DelegationConsentViewSchema,
|
|
175
740
|
})
|
|
176
741
|
.strict();
|
|
742
|
+
exports.permissionsV2DelegationConsentSubmissionResponseSchema = zod_1.z
|
|
743
|
+
.object({
|
|
744
|
+
consent: exports.permissionsV2DelegationConsentViewSchema,
|
|
745
|
+
settings: permissionsV2UserParameters_js_1.permissionsV2UserParameterViewSchema.nullable(),
|
|
746
|
+
})
|
|
747
|
+
.strict();
|
|
177
748
|
exports.permissionsV2DelegationConsentDiscoveryResponseSchema = zod_1.z
|
|
178
749
|
.object({
|
|
179
750
|
requests: zod_1.z.array(exports.permissionsV2DelegationConsentRequestSchema),
|