js-waku/packages/utils/src/common/is_size_valid.ts
Sasha 72f97d4545
feat: add 1MB restriction to LightPush and Relay (#1351)
* add 1MB restriction to LightPush and Relay

* fix condition

* improve lightPush test

* update test

* add isomorphic-webcrypto

* import module

* add errors to SendResult and tests

* fix lint
2023-05-17 23:40:52 +02:00

11 lines
195 B
TypeScript

const MB = 1024 ** 2;
const SIZE_CAP = 1; // 1 MB
export const isSizeValid = (payload: Uint8Array): boolean => {
if (payload.length / MB > SIZE_CAP) {
return false;
}
return true;
};