Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapper validation #933

Merged
merged 9 commits into from
Jun 21, 2022
Merged

Wrapper validation #933

merged 9 commits into from
Jun 21, 2022

Conversation

nerfZael
Copy link
Contributor

@nerfZael nerfZael commented Jun 20, 2022

Implemented the package-validation package that can be used to validate wasm packages.
Main class that accomplishes this is the WasmPackageValidator:

class WasmPackageValidator {
  constructor(private constraints: WasmPackageConstraints) {}
  async validate(reader: PackageReader): Promise<ValidationResult> ;
 }

The validator takes in WasmPackageConstraints which define the constraints that the wrapper needs to follow in order to be considered valid.

type WasmPackageConstraints = {
  maxSize: number;
  maxFileSize: number;
  maxModuleSize: number;
  maxNumberOfFiles: number;
};

The validate method can be called to validate a wasm package that can be read through the PackageReader that was passed as the argument:

interface PackageReader {
  readFileAsString: (path: string) => Promise<string>;
  readFile: (path: string) => Promise<Buffer>;
  exists: (path: string) => Promise<boolean>;
  getStats: (path: string) => Promise<PathStats>;
  readDir: (path: string) => Promise<string[]>;
}

Closes: #803

@nerfZael nerfZael marked this pull request as ready for review June 20, 2022 13:34
@nerfZael nerfZael requested a review from Niraj-Kamdar June 21, 2022 16:16
@dOrgJelli dOrgJelli merged commit 109a185 into prealpha-dev Jun 21, 2022
@dOrgJelli dOrgJelli deleted the nerfzael-validation branch April 10, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants