@bsv/message-box-client 2.0.6 → 2.0.7
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/package.json +1 -1
- package/dist/cjs/src/PeerPayClient.js +405 -5
- package/dist/cjs/src/PeerPayClient.js.map +1 -1
- package/dist/cjs/src/__tests/PeerPayClientRequestIntegration.test.js +317 -0
- package/dist/cjs/src/__tests/PeerPayClientRequestIntegration.test.js.map +1 -0
- package/dist/cjs/src/__tests/PeerPayClientUnit.test.js +505 -1
- package/dist/cjs/src/__tests/PeerPayClientUnit.test.js.map +1 -1
- package/dist/cjs/src/types.js +5 -0
- package/dist/cjs/src/types.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/PeerPayClient.js +401 -5
- package/dist/esm/src/PeerPayClient.js.map +1 -1
- package/dist/esm/src/__tests/PeerPayClientRequestIntegration.test.js +312 -0
- package/dist/esm/src/__tests/PeerPayClientRequestIntegration.test.js.map +1 -0
- package/dist/esm/src/__tests/PeerPayClientUnit.test.js +505 -1
- package/dist/esm/src/__tests/PeerPayClientUnit.test.js.map +1 -1
- package/dist/esm/src/types.js +4 -1
- package/dist/esm/src/types.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/PeerPayClient.d.ts +159 -0
- package/dist/types/src/PeerPayClient.d.ts.map +1 -1
- package/dist/types/src/__tests/PeerPayClientRequestIntegration.test.d.ts +10 -0
- package/dist/types/src/__tests/PeerPayClientRequestIntegration.test.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +88 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/package.json +1 -1
- package/src/PeerPayClient.ts +460 -9
- package/src/__tests/PeerPayClientRequestIntegration.test.ts +364 -0
- package/src/__tests/PeerPayClientUnit.test.ts +594 -1
- package/src/types.ts +95 -0
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
* between identified peers on the BSV network.
|
|
11
11
|
*/
|
|
12
12
|
import { MessageBoxClient } from './MessageBoxClient.js';
|
|
13
|
+
import { PaymentRequestResponse, IncomingPaymentRequest, PaymentRequestLimits } from './types.js';
|
|
13
14
|
import { WalletInterface, AtomicBEEF, Base64String, OriginatorDomainNameStringUnder250Bytes } from '@bsv/sdk';
|
|
14
15
|
export declare const STANDARD_PAYMENT_MESSAGEBOX = "payment_inbox";
|
|
16
|
+
export declare const PAYMENT_REQUESTS_MESSAGEBOX = "payment_requests";
|
|
17
|
+
export declare const PAYMENT_REQUEST_RESPONSES_MESSAGEBOX = "payment_request_responses";
|
|
15
18
|
/**
|
|
16
19
|
* Configuration options for initializing PeerPayClient.
|
|
17
20
|
*/
|
|
@@ -60,6 +63,41 @@ export declare class PeerPayClient extends MessageBoxClient {
|
|
|
60
63
|
private readonly settlementModule;
|
|
61
64
|
constructor(config: PeerPayClientConfig);
|
|
62
65
|
private get authFetchInstance();
|
|
66
|
+
/**
|
|
67
|
+
* Allows payment requests from a specific identity key by setting
|
|
68
|
+
* the recipientFee to 0 for the payment_requests message box.
|
|
69
|
+
*
|
|
70
|
+
* @param {Object} params - Parameters.
|
|
71
|
+
* @param {string} params.identityKey - The identity key to allow payment requests from.
|
|
72
|
+
* @returns {Promise<void>} Resolves when the permission is set.
|
|
73
|
+
*/
|
|
74
|
+
allowPaymentRequestsFrom({ identityKey }: {
|
|
75
|
+
identityKey: string;
|
|
76
|
+
}): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Blocks payment requests from a specific identity key by setting
|
|
79
|
+
* the recipientFee to -1 for the payment_requests message box.
|
|
80
|
+
*
|
|
81
|
+
* @param {Object} params - Parameters.
|
|
82
|
+
* @param {string} params.identityKey - The identity key to block payment requests from.
|
|
83
|
+
* @returns {Promise<void>} Resolves when the permission is set.
|
|
84
|
+
*/
|
|
85
|
+
blockPaymentRequestsFrom({ identityKey }: {
|
|
86
|
+
identityKey: string;
|
|
87
|
+
}): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Lists all permissions for the payment_requests message box, mapped to
|
|
90
|
+
* a simplified { identityKey, allowed } structure.
|
|
91
|
+
*
|
|
92
|
+
* A permission is considered "allowed" if recipientFee >= 0 (0 = always allow,
|
|
93
|
+
* positive = payment required). A recipientFee of -1 means blocked.
|
|
94
|
+
*
|
|
95
|
+
* @returns {Promise<Array<{ identityKey: string, allowed: boolean }>>} Resolved with the list of permissions.
|
|
96
|
+
*/
|
|
97
|
+
listPaymentRequestPermissions(): Promise<Array<{
|
|
98
|
+
identityKey: string;
|
|
99
|
+
allowed: boolean;
|
|
100
|
+
}>>;
|
|
63
101
|
/**
|
|
64
102
|
* Generates a valid payment token for a recipient.
|
|
65
103
|
*
|
|
@@ -151,5 +189,126 @@ export declare class PeerPayClient extends MessageBoxClient {
|
|
|
151
189
|
* @returns {Promise<IncomingPayment[]>} Resolves with an array of pending payments.
|
|
152
190
|
*/
|
|
153
191
|
listIncomingPayments(overrideHost?: string): Promise<IncomingPayment[]>;
|
|
192
|
+
/**
|
|
193
|
+
* Lists all responses to payment requests from the payment_request_responses message box.
|
|
194
|
+
*
|
|
195
|
+
* Retrieves messages and parses each as a PaymentRequestResponse.
|
|
196
|
+
*
|
|
197
|
+
* @param {string} [hostOverride] - Optional host override for the message box server.
|
|
198
|
+
* @returns {Promise<PaymentRequestResponse[]>} Resolves with an array of payment request responses.
|
|
199
|
+
*/
|
|
200
|
+
listPaymentRequestResponses(hostOverride?: string): Promise<PaymentRequestResponse[]>;
|
|
201
|
+
/**
|
|
202
|
+
* Listens for incoming payment requests in real time via WebSocket.
|
|
203
|
+
*
|
|
204
|
+
* Wraps listenForLiveMessages on the payment_requests box and converts each
|
|
205
|
+
* incoming PeerMessage into an IncomingPaymentRequest before calling onRequest.
|
|
206
|
+
*
|
|
207
|
+
* @param {Object} params - Listener configuration.
|
|
208
|
+
* @param {Function} params.onRequest - Callback invoked when a new payment request arrives.
|
|
209
|
+
* @param {string} [params.overrideHost] - Optional host override for the WebSocket connection.
|
|
210
|
+
* @returns {Promise<void>} Resolves when the listener is established.
|
|
211
|
+
*/
|
|
212
|
+
listenForLivePaymentRequests({ onRequest, overrideHost }: {
|
|
213
|
+
onRequest: (request: IncomingPaymentRequest) => void;
|
|
214
|
+
overrideHost?: string;
|
|
215
|
+
}): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Listens for payment request responses in real time via WebSocket.
|
|
218
|
+
*
|
|
219
|
+
* Wraps listenForLiveMessages on the payment_request_responses box and converts each
|
|
220
|
+
* incoming PeerMessage into a PaymentRequestResponse before calling onResponse.
|
|
221
|
+
*
|
|
222
|
+
* @param {Object} params - Listener configuration.
|
|
223
|
+
* @param {Function} params.onResponse - Callback invoked when a new response arrives.
|
|
224
|
+
* @param {string} [params.overrideHost] - Optional host override for the WebSocket connection.
|
|
225
|
+
* @returns {Promise<void>} Resolves when the listener is established.
|
|
226
|
+
*/
|
|
227
|
+
listenForLivePaymentRequestResponses({ onResponse, overrideHost }: {
|
|
228
|
+
onResponse: (response: PaymentRequestResponse) => void;
|
|
229
|
+
overrideHost?: string;
|
|
230
|
+
}): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* Fulfills an incoming payment request by sending the requested payment and
|
|
233
|
+
* notifying the requester with a 'paid' response in the payment_request_responses box.
|
|
234
|
+
* Also acknowledges the original request message.
|
|
235
|
+
*
|
|
236
|
+
* @param {Object} params - Fulfillment parameters.
|
|
237
|
+
* @param {IncomingPaymentRequest} params.request - The incoming payment request to fulfill.
|
|
238
|
+
* @param {string} [params.note] - Optional note to include in the response.
|
|
239
|
+
* @param {string} [hostOverride] - Optional host override for the message box server.
|
|
240
|
+
* @returns {Promise<void>} Resolves when payment is sent and acknowledgment is complete.
|
|
241
|
+
*/
|
|
242
|
+
fulfillPaymentRequest(params: {
|
|
243
|
+
request: IncomingPaymentRequest;
|
|
244
|
+
note?: string;
|
|
245
|
+
}, hostOverride?: string): Promise<void>;
|
|
246
|
+
/**
|
|
247
|
+
* Declines an incoming payment request by notifying the requester with a 'declined'
|
|
248
|
+
* response in the payment_request_responses box and acknowledging the original request.
|
|
249
|
+
*
|
|
250
|
+
* @param {Object} params - Decline parameters.
|
|
251
|
+
* @param {IncomingPaymentRequest} params.request - The incoming payment request to decline.
|
|
252
|
+
* @param {string} [params.note] - Optional note explaining why the request was declined.
|
|
253
|
+
* @param {string} [hostOverride] - Optional host override for the message box server.
|
|
254
|
+
* @returns {Promise<void>} Resolves when the response is sent and request is acknowledged.
|
|
255
|
+
*/
|
|
256
|
+
declinePaymentRequest(params: {
|
|
257
|
+
request: IncomingPaymentRequest;
|
|
258
|
+
note?: string;
|
|
259
|
+
}, hostOverride?: string): Promise<void>;
|
|
260
|
+
/**
|
|
261
|
+
* Sends a payment request to a recipient via the payment_requests message box.
|
|
262
|
+
*
|
|
263
|
+
* Generates a unique requestId using createNonce, looks up the caller's identity key,
|
|
264
|
+
* and sends a PaymentRequestMessage to the recipient.
|
|
265
|
+
*
|
|
266
|
+
* @param {Object} params - Payment request parameters.
|
|
267
|
+
* @param {string} params.recipient - The identity key of the intended payer.
|
|
268
|
+
* @param {number} params.amount - The amount in satoshis being requested (must be > 0).
|
|
269
|
+
* @param {string} params.description - Human-readable reason for the payment request.
|
|
270
|
+
* @param {number} params.expiresAt - Unix timestamp (ms) when the request expires.
|
|
271
|
+
* @param {string} [hostOverride] - Optional host override for the message box server.
|
|
272
|
+
* @returns {Promise<{ requestId: string }>} The generated requestId for this request.
|
|
273
|
+
* @throws {Error} If amount is <= 0.
|
|
274
|
+
*/
|
|
275
|
+
requestPayment(params: {
|
|
276
|
+
recipient: string;
|
|
277
|
+
amount: number;
|
|
278
|
+
description: string;
|
|
279
|
+
expiresAt: number;
|
|
280
|
+
}, hostOverride?: string): Promise<{
|
|
281
|
+
requestId: string;
|
|
282
|
+
requestProof: string;
|
|
283
|
+
}>;
|
|
284
|
+
/**
|
|
285
|
+
* Lists all incoming payment requests from the payment_requests message box.
|
|
286
|
+
*
|
|
287
|
+
* Automatically filters out:
|
|
288
|
+
* - Expired requests (expiresAt < now), which are acknowledged and discarded.
|
|
289
|
+
* - Cancelled requests (a cancellation message with the same requestId exists),
|
|
290
|
+
* both the original and cancellation messages are acknowledged and discarded.
|
|
291
|
+
* - Out-of-range requests (when limits are provided), which are acknowledged and discarded.
|
|
292
|
+
*
|
|
293
|
+
* @param {string} [hostOverride] - Optional host override for the message box server.
|
|
294
|
+
* @param {PaymentRequestLimits} [limits] - Optional min/max satoshi limits for filtering.
|
|
295
|
+
* @returns {Promise<IncomingPaymentRequest[]>} Resolves with active, valid payment requests.
|
|
296
|
+
*/
|
|
297
|
+
listIncomingPaymentRequests(hostOverride?: string, limits?: PaymentRequestLimits): Promise<IncomingPaymentRequest[]>;
|
|
298
|
+
/**
|
|
299
|
+
* Cancels a previously sent payment request by sending a cancellation message
|
|
300
|
+
* with the same requestId and `cancelled: true`.
|
|
301
|
+
*
|
|
302
|
+
* @param {Object} params - Cancellation parameters.
|
|
303
|
+
* @param {string} params.recipient - The identity key of the recipient of the original request.
|
|
304
|
+
* @param {string} params.requestId - The requestId of the payment request to cancel.
|
|
305
|
+
* @param {string} [hostOverride] - Optional host override for the message box server.
|
|
306
|
+
* @returns {Promise<void>} Resolves when the cancellation message has been sent.
|
|
307
|
+
*/
|
|
308
|
+
cancelPaymentRequest(params: {
|
|
309
|
+
recipient: string;
|
|
310
|
+
requestId: string;
|
|
311
|
+
requestProof: string;
|
|
312
|
+
}, hostOverride?: string): Promise<void>;
|
|
154
313
|
}
|
|
155
314
|
//# sourceMappingURL=PeerPayClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeerPayClient.d.ts","sourceRoot":"","sources":["../../../src/PeerPayClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA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E,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EACrF,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IA2CvD;;;;;;;;;;;;OAYG;IACG,2BAA2B,CAC/B,YAAY,CAAC,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,oBAAoB,GAC5B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IA4HpC;;;;;;;;;OASG;IACG,oBAAoB,CACxB,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,EACtE,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;CAgBjB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration tests for the PeerPayClient payment request flow.
|
|
3
|
+
*
|
|
4
|
+
* Uses a MockMessageBus to simulate the MessageBox server in memory,
|
|
5
|
+
* wiring the PeerPayClient methods (sendMessage, listMessages, acknowledgeMessage,
|
|
6
|
+
* getIdentityKey) to the mock bus so that full round-trip flows can be tested
|
|
7
|
+
* without hitting a real server.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=PeerPayClientRequestIntegration.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PeerPayClientRequestIntegration.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests/PeerPayClientRequestIntegration.test.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG"}
|
|
@@ -170,4 +170,92 @@ export interface ListDevicesResponse {
|
|
|
170
170
|
devices: RegisteredDevice[];
|
|
171
171
|
description?: string;
|
|
172
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Base fields shared by both payment request and cancellation messages.
|
|
175
|
+
*/
|
|
176
|
+
interface PaymentRequestBase {
|
|
177
|
+
/** Unique identifier for this request, generated via createNonce(). */
|
|
178
|
+
requestId: string;
|
|
179
|
+
/** Identity key of the requester, used for correlation and cancellation verification. */
|
|
180
|
+
senderIdentityKey: string;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* A new payment request sent from requester to payer.
|
|
184
|
+
* Carried in the 'payment_requests' message box.
|
|
185
|
+
*/
|
|
186
|
+
export interface PaymentRequestNew extends PaymentRequestBase {
|
|
187
|
+
/** Amount in satoshis being requested. */
|
|
188
|
+
amount: number;
|
|
189
|
+
/** Human-readable reason for the request. */
|
|
190
|
+
description: string;
|
|
191
|
+
/** Unix timestamp (ms) after which the request expires. Set by the sender. */
|
|
192
|
+
expiresAt: number;
|
|
193
|
+
/** HMAC proof tying this request to the sender's identity. Used to authorize cancellations. */
|
|
194
|
+
requestProof: string;
|
|
195
|
+
/** Omitted or false for a new payment request. */
|
|
196
|
+
cancelled?: false;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* A cancellation of a previously sent payment request.
|
|
200
|
+
* Carried in the 'payment_requests' message box.
|
|
201
|
+
*/
|
|
202
|
+
export interface PaymentRequestCancellation extends PaymentRequestBase {
|
|
203
|
+
/** If true, this message cancels a previously sent request with the same requestId. */
|
|
204
|
+
cancelled: true;
|
|
205
|
+
/** HMAC proof from the original request, proving cancellation authority. */
|
|
206
|
+
requestProof: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Discriminated union: either a new payment request or a cancellation.
|
|
210
|
+
* Discriminant field: `cancelled` (true = cancellation, absent/false = new request).
|
|
211
|
+
*/
|
|
212
|
+
export type PaymentRequestMessage = PaymentRequestNew | PaymentRequestCancellation;
|
|
213
|
+
/**
|
|
214
|
+
* Represents a response to a payment request, sent from the payer back to the requester.
|
|
215
|
+
* Carried in the 'payment_request_responses' message box.
|
|
216
|
+
*/
|
|
217
|
+
export interface PaymentRequestResponse {
|
|
218
|
+
/** The requestId of the original PaymentRequestMessage this responds to. */
|
|
219
|
+
requestId: string;
|
|
220
|
+
/** Status of the response. */
|
|
221
|
+
status: 'paid' | 'declined';
|
|
222
|
+
/** Optional note from the payer. */
|
|
223
|
+
note?: string;
|
|
224
|
+
/** Actual amount paid in satoshis (may differ from the requested amount). */
|
|
225
|
+
amountPaid?: number;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Represents an incoming payment request as returned by listIncomingPaymentRequests().
|
|
229
|
+
* Combines the transport message metadata with the parsed request body.
|
|
230
|
+
* Only active (non-cancelled) requests are returned, so cancelled field is omitted.
|
|
231
|
+
*/
|
|
232
|
+
export interface IncomingPaymentRequest {
|
|
233
|
+
/** Transport message ID used for acknowledgment. */
|
|
234
|
+
messageId: string;
|
|
235
|
+
/** Identity key of the requester. */
|
|
236
|
+
sender: string;
|
|
237
|
+
/** Unique identifier for this request. */
|
|
238
|
+
requestId: string;
|
|
239
|
+
/** Amount in satoshis requested. */
|
|
240
|
+
amount: number;
|
|
241
|
+
/** Human-readable reason for the request. */
|
|
242
|
+
description: string;
|
|
243
|
+
/** Unix timestamp (ms) when the request expires. */
|
|
244
|
+
expiresAt: number;
|
|
245
|
+
}
|
|
246
|
+
/** Default minimum satoshis for payment request filtering. */
|
|
247
|
+
export declare const DEFAULT_PAYMENT_REQUEST_MIN_AMOUNT = 1000;
|
|
248
|
+
/** Default maximum satoshis for payment request filtering. */
|
|
249
|
+
export declare const DEFAULT_PAYMENT_REQUEST_MAX_AMOUNT = 10000000;
|
|
250
|
+
/**
|
|
251
|
+
* Configurable min/max amount limits for incoming payment requests.
|
|
252
|
+
* Requests outside these bounds are auto-acknowledged and discarded.
|
|
253
|
+
*/
|
|
254
|
+
export interface PaymentRequestLimits {
|
|
255
|
+
/** Minimum satoshis to accept in a request. Requests below this are discarded. Default: 1000. */
|
|
256
|
+
minAmount?: number;
|
|
257
|
+
/** Maximum satoshis to accept in a request. Requests above this are discarded. Default: 10000000. */
|
|
258
|
+
maxAmount?: number;
|
|
259
|
+
}
|
|
260
|
+
export {};
|
|
173
261
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,yBAAyB,EAAE,IAAI,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,SAAS,EAAE,wBAAwB,EAAE,aAAa,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1Q;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,YAAY,CAAC,EAAE,eAAe,CAAA;IAE9B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IAEvB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;IAE/C;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc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