@btps/sdk 0.0.0-stage → 1.1.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/CHANGELOG.md +149 -0
- package/LICENSE +190 -0
- package/NOTICE +25 -0
- package/README.md +261 -2
- package/dist/client/btpsAgent.d.ts +20 -0
- package/dist/client/btpsAgent.js +172 -0
- package/dist/client/btpsClient.d.ts +202 -0
- package/dist/client/btpsClient.js +602 -0
- package/dist/client/btpsTransporter.d.ts +52 -0
- package/dist/client/btpsTransporter.js +249 -0
- package/dist/client/constants.ts/index.d.ts +11 -0
- package/dist/client/constants.ts/index.js +20 -0
- package/dist/client/index.d.ts +12 -0
- package/dist/client/index.js +27 -0
- package/dist/client/libs/schema.d.ts +27604 -0
- package/dist/client/libs/schema.js +56 -0
- package/dist/client/libs/timeouts.d.ts +22 -0
- package/dist/client/libs/timeouts.js +19 -0
- package/dist/client/types/index.d.ts +155 -0
- package/dist/client/types/index.js +7 -0
- package/dist/core/authentication/BtpsAuthentication.d.ts +128 -0
- package/dist/core/authentication/BtpsAuthentication.js +293 -0
- package/dist/core/authentication/index.d.ts +11 -0
- package/dist/core/authentication/index.js +12 -0
- package/dist/core/authentication/keyProof.d.ts +18 -0
- package/dist/core/authentication/keyProof.js +16 -0
- package/dist/core/authentication/storage/InMemoryAuthSessionStore.d.ts +55 -0
- package/dist/core/authentication/storage/InMemoryAuthSessionStore.js +62 -0
- package/dist/core/authentication/storage/InMemoryTokenStore.d.ts +63 -0
- package/dist/core/authentication/storage/InMemoryTokenStore.js +63 -0
- package/dist/core/authentication/types.d.ts +135 -0
- package/dist/core/authentication/types.js +7 -0
- package/dist/core/crypto/decryptVerify.d.ts +9 -0
- package/dist/core/crypto/decryptVerify.js +45 -0
- package/dist/core/crypto/decrypter-interface.d.ts +25 -0
- package/dist/core/crypto/decrypter-interface.js +7 -0
- package/dist/core/crypto/index.d.ts +77 -0
- package/dist/core/crypto/index.js +210 -0
- package/dist/core/crypto/jcs.d.ts +28 -0
- package/dist/core/crypto/jcs.js +60 -0
- package/dist/core/crypto/keygen.d.ts +9 -0
- package/dist/core/crypto/keygen.js +35 -0
- package/dist/core/crypto/pem-decrypter.d.ts +26 -0
- package/dist/core/crypto/pem-decrypter.js +52 -0
- package/dist/core/crypto/pem-signer.d.ts +21 -0
- package/dist/core/crypto/pem-signer.js +34 -0
- package/dist/core/crypto/signEncrypt.d.ts +34 -0
- package/dist/core/crypto/signEncrypt.js +75 -0
- package/dist/core/crypto/signer-interface.d.ts +22 -0
- package/dist/core/crypto/signer-interface.js +7 -0
- package/dist/core/crypto/types.d.ts +79 -0
- package/dist/core/crypto/types.js +7 -0
- package/dist/core/delegation/BtpsDelegator.d.ts +102 -0
- package/dist/core/delegation/BtpsDelegator.js +118 -0
- package/dist/core/delegation/index.d.ts +7 -0
- package/dist/core/delegation/index.js +8 -0
- package/dist/core/error/constant.d.ts +66 -0
- package/dist/core/error/constant.js +194 -0
- package/dist/core/error/index.d.ts +35 -0
- package/dist/core/error/index.js +52 -0
- package/dist/core/error/types.d.ts +16 -0
- package/dist/core/error/types.js +7 -0
- package/dist/core/server/constants/btps-protocol.d.ts +17 -0
- package/dist/core/server/constants/btps-protocol.js +25 -0
- package/dist/core/server/constants/control.d.ts +7 -0
- package/dist/core/server/constants/control.js +11 -0
- package/dist/core/server/constants/currency.d.ts +7 -0
- package/dist/core/server/constants/currency.js +332 -0
- package/dist/core/server/constants/index.d.ts +26 -0
- package/dist/core/server/constants/index.js +61 -0
- package/dist/core/server/constants/limits.d.ts +50 -0
- package/dist/core/server/constants/limits.js +50 -0
- package/dist/core/server/helpers/BtpsMessageQueue.d.ts +13 -0
- package/dist/core/server/helpers/BtpsMessageQueue.js +12 -0
- package/dist/core/server/helpers/InMemoryQueue.d.ts +16 -0
- package/dist/core/server/helpers/InMemoryQueue.js +35 -0
- package/dist/core/server/helpers/index.d.ts +8 -0
- package/dist/core/server/helpers/index.js +9 -0
- package/dist/core/server/schemas/artifacts/agentSchema.d.ts +4565 -0
- package/dist/core/server/schemas/artifacts/agentSchema.js +51 -0
- package/dist/core/server/schemas/artifacts/artifacts.d.ts +4920 -0
- package/dist/core/server/schemas/artifacts/artifacts.js +21 -0
- package/dist/core/server/schemas/artifacts/controlSchema.d.ts +23 -0
- package/dist/core/server/schemas/artifacts/controlSchema.js +18 -0
- package/dist/core/server/schemas/artifacts/identityLookupSchema.d.ts +32 -0
- package/dist/core/server/schemas/artifacts/identityLookupSchema.js +21 -0
- package/dist/core/server/schemas/artifacts/transporterSchema.d.ts +553 -0
- package/dist/core/server/schemas/artifacts/transporterSchema.js +60 -0
- package/dist/core/server/schemas/btpsDocsSchema.d.ts +4519 -0
- package/dist/core/server/schemas/btpsDocsSchema.js +272 -0
- package/dist/core/server/schemas/helpers.d.ts +1612 -0
- package/dist/core/server/schemas/helpers.js +87 -0
- package/dist/core/server/schemas/responseSchema.d.ts +6918 -0
- package/dist/core/server/schemas/responseSchema.js +86 -0
- package/dist/core/server/schemas/schema.d.ts +4916 -0
- package/dist/core/server/schemas/schema.js +70 -0
- package/dist/core/server/schemas/shared.d.ts +21 -0
- package/dist/core/server/schemas/shared.js +18 -0
- package/dist/core/server/types.d.ts +172 -0
- package/dist/core/server/types.js +7 -0
- package/dist/core/storage/AbstractIdentityStore.d.ts +17 -0
- package/dist/core/storage/AbstractIdentityStore.js +13 -0
- package/dist/core/storage/AbstractStorageStore.d.ts +16 -0
- package/dist/core/storage/AbstractStorageStore.js +17 -0
- package/dist/core/storage/JsonIdentityStore.d.ts +29 -0
- package/dist/core/storage/JsonIdentityStore.js +39 -0
- package/dist/core/storage/JsonStorageStore.d.ts +59 -0
- package/dist/core/storage/JsonStorageStore.js +110 -0
- package/dist/core/storage/index.d.ts +11 -0
- package/dist/core/storage/index.js +18 -0
- package/dist/core/storage/types.d.ts +28 -0
- package/dist/core/storage/types.js +7 -0
- package/dist/core/trust/index.d.ts +10 -0
- package/dist/core/trust/index.js +15 -0
- package/dist/core/trust/storage/AbstractTrustStore.d.ts +23 -0
- package/dist/core/trust/storage/AbstractTrustStore.js +13 -0
- package/dist/core/trust/storage/JsonTrustStore.d.ts +33 -0
- package/dist/core/trust/storage/JsonTrustStore.js +42 -0
- package/dist/core/trust/trustUtils.d.ts +78 -0
- package/dist/core/trust/trustUtils.js +41 -0
- package/dist/core/trust/types.d.ts +53 -0
- package/dist/core/trust/types.js +7 -0
- package/dist/core/utils/identity.d.ts +20 -0
- package/dist/core/utils/identity.js +22 -0
- package/dist/core/utils/index.d.ts +70 -0
- package/dist/core/utils/index.js +124 -0
- package/dist/core/utils/types.d.ts +10 -0
- package/dist/core/utils/types.js +7 -0
- package/dist/core/utils/validation.d.ts +14 -0
- package/dist/core/utils/validation.js +13 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/server/btpsServer.d.ts +292 -0
- package/dist/server/btpsServer.js +827 -0
- package/dist/server/index.d.ts +11 -0
- package/dist/server/index.js +15 -0
- package/dist/server/libs/abstractRateLimiter.d.ts +10 -0
- package/dist/server/libs/abstractRateLimiter.js +15 -0
- package/dist/server/libs/artifactSizeGuard.d.ts +27 -0
- package/dist/server/libs/artifactSizeGuard.js +44 -0
- package/dist/server/libs/artifactTimeWindow.d.ts +24 -0
- package/dist/server/libs/artifactTimeWindow.js +30 -0
- package/dist/server/libs/btpsFactory.d.ts +29 -0
- package/dist/server/libs/btpsFactory.js +49 -0
- package/dist/server/libs/btpsLightweightFactory.d.ts +35 -0
- package/dist/server/libs/btpsLightweightFactory.js +37 -0
- package/dist/server/libs/btpsRegistry.d.ts +14 -0
- package/dist/server/libs/btpsRegistry.js +16 -0
- package/dist/server/libs/btpsSimpleMetricsTracker.d.ts +13 -0
- package/dist/server/libs/btpsSimpleMetricsTracker.js +21 -0
- package/dist/server/libs/btpsSimpleRateLimiter.d.ts +28 -0
- package/dist/server/libs/btpsSimpleRateLimiter.js +46 -0
- package/dist/server/libs/connectionTimeout.d.ts +16 -0
- package/dist/server/libs/connectionTimeout.js +14 -0
- package/dist/server/libs/defaultMiddleware.d.ts +8 -0
- package/dist/server/libs/defaultMiddleware.js +128 -0
- package/dist/server/libs/inFlightLimit.d.ts +18 -0
- package/dist/server/libs/inFlightLimit.js +17 -0
- package/dist/server/libs/index.d.ts +18 -0
- package/dist/server/libs/index.js +34 -0
- package/dist/server/libs/middlewareManager.d.ts +59 -0
- package/dist/server/libs/middlewareManager.js +126 -0
- package/dist/server/libs/type.d.ts +22 -0
- package/dist/server/libs/type.js +7 -0
- package/dist/server/types.d.ts +236 -0
- package/dist/server/types.js +7 -0
- package/package.json +126 -4
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2025 Bhupendra Tamang
|
|
4
|
+
* Licensed under the Apache License, Version 2.0
|
|
5
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { CURRENCY_CODES } from "../constants/currency.js";
|
|
10
|
+
import { BTPS_FIELD_LIMITS } from "../constants/limits.js";
|
|
11
|
+
import { BtpSignatureSchema, identitySchema } from "./shared.js";
|
|
12
|
+
const { trustRequest, trustResponse, event, receipt, payslip, letter, documentId, referenceType } = BTPS_FIELD_LIMITS, codeSchema = (max) => z.string().max(max).regex(/^[a-z0-9_]+(:[a-z0-9_]+)?$/, "must be a bare or prefixed code"), decimalText = z.string().regex(/^-?\d+(\.\d+)?$/, "must be a decimal written as text"), sha256Hex = z.string().regex(/^[0-9a-f]{64}$/, "must be a SHA-256 in lowercase hex"), BtpAttachmentSchema = z.object({
|
|
13
|
+
content: z.string(),
|
|
14
|
+
|
|
15
|
+
type: z.enum(["application/pdf", "image/jpeg", "image/png"]),
|
|
16
|
+
filename: z.string().optional(),
|
|
17
|
+
size: z.number().int().nonnegative(),
|
|
18
|
+
sha256: sha256Hex
|
|
19
|
+
}), BtpMoneySchema = z.object({
|
|
20
|
+
amount: z.number().int().safe(),
|
|
21
|
+
currency: z.enum(CURRENCY_CODES)
|
|
22
|
+
}), BtpDocReferenceSchema = z.object({
|
|
23
|
+
type: codeSchema(referenceType),
|
|
24
|
+
from: identitySchema,
|
|
25
|
+
id: z.string().min(1).max(documentId),
|
|
26
|
+
sha256: sha256Hex
|
|
27
|
+
}), BtpStringQueryFilterSchema = z.object({
|
|
28
|
+
like: z.string().optional(),
|
|
29
|
+
in: z.array(z.string()).optional(),
|
|
30
|
+
eq: z.string().optional(),
|
|
31
|
+
ne: z.string().optional(),
|
|
32
|
+
notIn: z.array(z.string()).optional(),
|
|
33
|
+
notLike: z.string().optional()
|
|
34
|
+
}), BtpTrustReqDocSchema = z.object({
|
|
35
|
+
id: z.string().max(trustRequest.id),
|
|
36
|
+
name: z.string().max(trustRequest.name),
|
|
37
|
+
email: z.string().max(trustRequest.email).email(),
|
|
38
|
+
reason: z.string().max(trustRequest.reason),
|
|
39
|
+
phone: z.string().max(trustRequest.phone),
|
|
40
|
+
address: z.string().max(trustRequest.address).optional(),
|
|
41
|
+
logoUrl: z.string().max(trustRequest.logoUrl).url().optional(),
|
|
42
|
+
displayName: z.string().max(trustRequest.displayName).optional(),
|
|
43
|
+
websiteUrl: z.string().max(trustRequest.websiteUrl).url().optional(),
|
|
44
|
+
message: z.string().max(trustRequest.message).optional(),
|
|
45
|
+
expiresAt: z.string().datetime().optional(),
|
|
46
|
+
privacyType: z.enum(["unencrypted", "encrypted", "mixed"]).optional()
|
|
47
|
+
}), BtpTrustResDocSchema = z.object({
|
|
48
|
+
id: z.string().max(trustResponse.id),
|
|
49
|
+
decision: z.enum(["accepted", "rejected", "revoked", "blocked"]),
|
|
50
|
+
decidedAt: z.string().datetime(),
|
|
51
|
+
decidedBy: z.string().max(trustResponse.decidedBy),
|
|
52
|
+
expiresAt: z.string().datetime().optional(),
|
|
53
|
+
retryAfterDate: z.string().datetime().optional(),
|
|
54
|
+
message: z.string().max(trustResponse.message).optional(),
|
|
55
|
+
privacyType: z.enum(["unencrypted", "encrypted", "mixed"]).optional()
|
|
56
|
+
}), BtpLineItemsSchema = z.object({
|
|
57
|
+
columns: z.array(z.string()),
|
|
58
|
+
|
|
59
|
+
rows: z.array(z.record(z.union([z.string(), z.number().int().safe()])))
|
|
60
|
+
}), BtpIssuerSchema = z.object({
|
|
61
|
+
name: z.string(),
|
|
62
|
+
email: z.string().email().optional(),
|
|
63
|
+
phone: z.string().optional(),
|
|
64
|
+
address: z.string().optional(),
|
|
65
|
+
|
|
66
|
+
identifiers: z.record(z.string().regex(/^[a-z0-9_]+:[a-z0-9_]+$/), z.string()).optional()
|
|
67
|
+
}), BtpInvoiceDocSchema = z.object({
|
|
68
|
+
type: z.literal("invoice"),
|
|
69
|
+
title: z.string(),
|
|
70
|
+
id: z.string().max(documentId),
|
|
71
|
+
|
|
72
|
+
issuedAt: z.string().datetime(),
|
|
73
|
+
dueAt: z.string().datetime().optional(),
|
|
74
|
+
totalAmount: BtpMoneySchema,
|
|
75
|
+
lineItems: BtpLineItemsSchema,
|
|
76
|
+
issuer: BtpIssuerSchema.optional(),
|
|
77
|
+
paymentLink: z.object({
|
|
78
|
+
linkText: z.string(),
|
|
79
|
+
url: z.string().url()
|
|
80
|
+
}).optional(),
|
|
81
|
+
description: z.string().optional(),
|
|
82
|
+
attachments: z.array(BtpAttachmentSchema).optional(),
|
|
83
|
+
|
|
84
|
+
references: z.array(BtpDocReferenceSchema).optional(),
|
|
85
|
+
template: z.object({
|
|
86
|
+
name: z.string(),
|
|
87
|
+
data: z.record(z.unknown())
|
|
88
|
+
}).optional(),
|
|
89
|
+
|
|
90
|
+
metadata: z.record(z.unknown()).optional()
|
|
91
|
+
}).strict(), BtpPositiveMoneySchema = BtpMoneySchema.extend({
|
|
92
|
+
amount: z.number().int().safe().positive()
|
|
93
|
+
}), BtpReceiptDocSchema = BtpInvoiceDocSchema.omit({ dueAt: !0, paymentLink: !0 }).extend({
|
|
94
|
+
type: z.literal("receipt"),
|
|
95
|
+
lineItems: BtpLineItemsSchema.optional(),
|
|
96
|
+
payment: z.object({
|
|
97
|
+
amount: BtpPositiveMoneySchema,
|
|
98
|
+
paidAt: z.string().datetime(),
|
|
99
|
+
|
|
100
|
+
method: codeSchema(receipt.paymentMethod).optional(),
|
|
101
|
+
reference: z.string().max(receipt.paymentReference).optional()
|
|
102
|
+
})
|
|
103
|
+
}).strict(), payslipCode = codeSchema(payslip.code), BtpPayslipDocSchema = z.object({
|
|
104
|
+
type: z.literal("payslip"),
|
|
105
|
+
title: z.string(),
|
|
106
|
+
id: z.string().max(documentId),
|
|
107
|
+
issuedAt: z.string().datetime(),
|
|
108
|
+
issuer: BtpIssuerSchema.optional(),
|
|
109
|
+
|
|
110
|
+
employee: z.object({
|
|
111
|
+
name: z.string(),
|
|
112
|
+
employeeId: z.string().optional(),
|
|
113
|
+
payBasis: z.enum(["hourly", "salaried"]).optional()
|
|
114
|
+
}),
|
|
115
|
+
jurisdiction: z.string().regex(/^[A-Z]{2}$/, "must be an ISO 3166-1 alpha-2 code").optional(),
|
|
116
|
+
payPeriod: z.object({ start: z.string().datetime(), end: z.string().datetime() }).optional(),
|
|
117
|
+
payDate: z.string().datetime().optional(),
|
|
118
|
+
payRate: z.object({ amount: BtpMoneySchema, unit: payslipCode, asAt: z.string().datetime() }).optional(),
|
|
119
|
+
earnings: z.array(
|
|
120
|
+
z.object({
|
|
121
|
+
category: payslipCode,
|
|
122
|
+
description: z.string().optional(),
|
|
123
|
+
rate: decimalText.optional(),
|
|
124
|
+
rateUnit: payslipCode.optional(),
|
|
125
|
+
quantity: decimalText.optional(),
|
|
126
|
+
amount: BtpMoneySchema
|
|
127
|
+
})
|
|
128
|
+
),
|
|
129
|
+
deductions: z.array(
|
|
130
|
+
z.object({
|
|
131
|
+
category: payslipCode,
|
|
132
|
+
description: z.string().optional(),
|
|
133
|
+
amount: BtpMoneySchema,
|
|
134
|
+
payee: z.object({ name: z.string(), accountRef: z.string().optional() }).optional()
|
|
135
|
+
})
|
|
136
|
+
),
|
|
137
|
+
|
|
138
|
+
contributions: z.array(
|
|
139
|
+
z.object({
|
|
140
|
+
category: payslipCode.optional(),
|
|
141
|
+
amount: BtpMoneySchema,
|
|
142
|
+
fund: z.object({
|
|
143
|
+
name: z.string().optional(),
|
|
144
|
+
memberNumber: z.string().optional(),
|
|
145
|
+
accountRef: z.string().optional()
|
|
146
|
+
}).optional()
|
|
147
|
+
})
|
|
148
|
+
),
|
|
149
|
+
leave: z.array(
|
|
150
|
+
z.object({
|
|
151
|
+
category: payslipCode,
|
|
152
|
+
description: z.string().optional(),
|
|
153
|
+
unit: payslipCode,
|
|
154
|
+
|
|
155
|
+
balance: decimalText,
|
|
156
|
+
accrued: decimalText.optional(),
|
|
157
|
+
taken: decimalText.optional()
|
|
158
|
+
})
|
|
159
|
+
).optional(),
|
|
160
|
+
taxWithheld: BtpMoneySchema.optional(),
|
|
161
|
+
gross: BtpMoneySchema,
|
|
162
|
+
net: BtpMoneySchema,
|
|
163
|
+
yearToDate: z.record(BtpMoneySchema).optional(),
|
|
164
|
+
attachments: z.array(BtpAttachmentSchema).optional(),
|
|
165
|
+
references: z.array(BtpDocReferenceSchema).optional(),
|
|
166
|
+
metadata: z.record(z.unknown()).optional()
|
|
167
|
+
}).strict(), BtpLetterDocSchema = z.object({
|
|
168
|
+
type: z.literal("letter"),
|
|
169
|
+
title: z.string().max(letter.title),
|
|
170
|
+
id: z.string().max(documentId),
|
|
171
|
+
issuedAt: z.string().datetime(),
|
|
172
|
+
body: z.object({
|
|
173
|
+
format: z.enum(["text", "markdown"]),
|
|
174
|
+
content: z.string().max(letter.content)
|
|
175
|
+
}),
|
|
176
|
+
issuer: BtpIssuerSchema.optional(),
|
|
177
|
+
attachments: z.array(BtpAttachmentSchema).max(letter.attachments).optional(),
|
|
178
|
+
references: z.array(BtpDocReferenceSchema).max(letter.references).optional(),
|
|
179
|
+
metadata: z.record(z.unknown()).optional()
|
|
180
|
+
}).strict(), BtpDocumentSchema = z.discriminatedUnion("type", [
|
|
181
|
+
BtpInvoiceDocSchema,
|
|
182
|
+
BtpReceiptDocSchema,
|
|
183
|
+
BtpPayslipDocSchema,
|
|
184
|
+
BtpLetterDocSchema
|
|
185
|
+
]), lifecycleEventFields = {
|
|
186
|
+
type: z.literal("lifecycle_event"),
|
|
187
|
+
id: z.string().uuid(),
|
|
188
|
+
|
|
189
|
+
occurredAt: z.string().datetime(),
|
|
190
|
+
|
|
191
|
+
document: BtpDocReferenceSchema.omit({ type: !0 }),
|
|
192
|
+
|
|
193
|
+
message: z.string().max(event.message).optional()
|
|
194
|
+
}, BtpEventAmountSchema = BtpMoneySchema.extend({
|
|
195
|
+
amount: z.number().int().safe().positive()
|
|
196
|
+
}), BtpLifecycleEventSchema = z.discriminatedUnion("eventType", [
|
|
197
|
+
z.object({ ...lifecycleEventFields, eventType: z.literal("paid") }).strict(),
|
|
198
|
+
z.object({
|
|
199
|
+
...lifecycleEventFields,
|
|
200
|
+
eventType: z.literal("partially_paid"),
|
|
201
|
+
amount: BtpEventAmountSchema
|
|
202
|
+
}).strict(),
|
|
203
|
+
z.object({
|
|
204
|
+
...lifecycleEventFields,
|
|
205
|
+
eventType: z.literal("disputed"),
|
|
206
|
+
|
|
207
|
+
reason: codeSchema(event.reason)
|
|
208
|
+
}).strict(),
|
|
209
|
+
z.object({ ...lifecycleEventFields, eventType: z.literal("refund_requested") }).strict(),
|
|
210
|
+
z.object({
|
|
211
|
+
...lifecycleEventFields,
|
|
212
|
+
eventType: z.literal("refund"),
|
|
213
|
+
amount: BtpEventAmountSchema,
|
|
214
|
+
inReplyTo: z.string().uuid()
|
|
215
|
+
|
|
216
|
+
}).strict(),
|
|
217
|
+
z.object({
|
|
218
|
+
...lifecycleEventFields,
|
|
219
|
+
eventType: z.literal("response"),
|
|
220
|
+
decision: z.enum(["accepted", "rejected"]),
|
|
221
|
+
inReplyTo: z.string().uuid(),
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
remainingDueDate: z.string().datetime().optional()
|
|
225
|
+
}).strict()
|
|
226
|
+
]).refine(
|
|
227
|
+
(event2) => event2.eventType !== "response" || event2.remainingDueDate === void 0 || event2.decision === "accepted",
|
|
228
|
+
{ message: "remainingDueDate is only on an accepted response", path: ["remainingDueDate"] }
|
|
229
|
+
), BtpAuthReqDocSchema = z.object({
|
|
230
|
+
identity: identitySchema,
|
|
231
|
+
authToken: z.string(),
|
|
232
|
+
publicKey: z.string(),
|
|
233
|
+
agentInfo: z.record(z.union([z.string(), z.array(z.string())])).optional(),
|
|
234
|
+
keyProof: BtpSignatureSchema.optional()
|
|
235
|
+
}), BtpAuthResDocSchema = z.object({
|
|
236
|
+
agentId: z.string(),
|
|
237
|
+
refreshToken: z.string(),
|
|
238
|
+
expiresAt: z.string().datetime(),
|
|
239
|
+
decryptBy: identitySchema
|
|
240
|
+
}), BtpIdentityResDocSchema = z.object({
|
|
241
|
+
selector: z.string(),
|
|
242
|
+
publicKey: z.string(),
|
|
243
|
+
keyType: z.literal("rsa"),
|
|
244
|
+
version: z.string()
|
|
245
|
+
}), BtpAgentQueryDocSchema = z.object({
|
|
246
|
+
title: BtpStringQueryFilterSchema.optional(),
|
|
247
|
+
from: BtpStringQueryFilterSchema.optional(),
|
|
248
|
+
to: BtpStringQueryFilterSchema.optional()
|
|
249
|
+
}), BtpDocSchema = z.union([
|
|
250
|
+
BtpTrustReqDocSchema,
|
|
251
|
+
BtpTrustResDocSchema,
|
|
252
|
+
BtpDocumentSchema,
|
|
253
|
+
BtpLifecycleEventSchema
|
|
254
|
+
]);
|
|
255
|
+
export {
|
|
256
|
+
BtpAgentQueryDocSchema,
|
|
257
|
+
BtpAttachmentSchema,
|
|
258
|
+
BtpAuthReqDocSchema,
|
|
259
|
+
BtpAuthResDocSchema,
|
|
260
|
+
BtpDocReferenceSchema,
|
|
261
|
+
BtpDocSchema,
|
|
262
|
+
BtpDocumentSchema,
|
|
263
|
+
BtpIdentityResDocSchema,
|
|
264
|
+
BtpInvoiceDocSchema,
|
|
265
|
+
BtpLetterDocSchema,
|
|
266
|
+
BtpLifecycleEventSchema,
|
|
267
|
+
BtpPayslipDocSchema,
|
|
268
|
+
BtpReceiptDocSchema,
|
|
269
|
+
BtpStringQueryFilterSchema,
|
|
270
|
+
BtpTrustReqDocSchema,
|
|
271
|
+
BtpTrustResDocSchema
|
|
272
|
+
};
|