diff --git a/CHANGELOG.md b/CHANGELOG.md index 64981986..fb93786d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +## [v0.3.17] - 2023-04-16 + +### Changes + +- Adding the `random_get` WASI Syscall implementation to the `Typescript` Hosts's `DisabledWASI` Polyfill + ## [v0.3.16] - 2023-04-15 ### Changes @@ -218,7 +224,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Initial release of the Scale Runtime library. -[unreleased]: https://github.com/loopholelabs/scale/compare/v0.3.16...HEAD +[unreleased]: https://github.com/loopholelabs/scale/compare/v0.3.17...HEAD +[v0.3.17]: https://github.com/loopholelabs/scale/compare/v0.3.17 [v0.3.16]: https://github.com/loopholelabs/scale/compare/v0.3.16 [v0.3.15]: https://github.com/loopholelabs/scale/compare/v0.3.15 [v0.3.14]: https://github.com/loopholelabs/scale/compare/v0.3.14 diff --git a/package-lock.json b/package-lock.json index 90959966..d44b2f7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@loopholelabs/scale", - "version": "0.3.16", + "version": "0.3.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@loopholelabs/scale", - "version": "0.3.16", + "version": "0.3.17", "license": "apache-2.0", "dependencies": { "@loopholelabs/polyglot-ts": "^0.4.0", @@ -1973,9 +1973,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001478", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001478.tgz", - "integrity": "sha512-gMhDyXGItTHipJj2ApIvR+iVB5hd0KP3svMWWXDvZOmjzJJassGLMfxRkQCSYgGd2gtdL/ReeiyvMSFD1Ss6Mw==", + "version": "1.0.30001480", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001480.tgz", + "integrity": "sha512-q7cpoPPvZYgtyC4VaBSN0Bt+PJ4c4EYRf0DrduInOz2SkFpHD5p3LnvEpqBp7UnJn+8x1Ogl1s38saUxe+ihQQ==", "funding": [ { "type": "opencollective", @@ -4814,11 +4814,11 @@ "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" }, "node_modules/resolve": { - "version": "1.22.3", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.3.tgz", - "integrity": "sha512-P8ur/gp/AmbEzjr729bZnLjXK5Z+4P0zhIJgBgzqRih7hL7BOukHGtSTA3ACMY467GRFz3duQsi0bDZdR7DKdw==", + "version": "1.22.2", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", + "integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", "dependencies": { - "is-core-module": "^2.12.0", + "is-core-module": "^2.11.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, diff --git a/package.json b/package.json index 2b24599d..baf5abca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@loopholelabs/scale", - "version": "0.3.16", + "version": "0.3.17", "description": "Scale is a highly-performant WebAssembly function runtime that enables composable, language-agnostic software development.", "source": "ts/index.ts", "types": "types.d.ts", diff --git a/ts/wasi.ts b/ts/wasi.ts index f9dc8bcc..b47bbdc9 100644 --- a/ts/wasi.ts +++ b/ts/wasi.ts @@ -34,6 +34,7 @@ export interface RequiredFunctions extends WebAssembly.ModuleImports { proc_exit(rval: number): number path_open(fd: number, dirflags: number, path_ptr: number, path_len: number, oflags: number, fs_rights_base: number, fs_rights_inheriting: number, fd_flags: number, opened_fd_ptr: number): number clock_time_get(id: number, precision: BigInt, time: number): number + random_get(buf: number, buf_len: number): void } export class DisabledWASI { @@ -148,6 +149,13 @@ export class DisabledWASI { return DisabledWASI.ESUCCESS; } + public random_get(buf: number, buf_len: number): void { + let buffer = this.getDataView(); + for (let i = 0; i < buf_len; i++) { + buffer.setInt8(buf+i, (Math.random() * 256) | 0); + } + } + public GetImports(): RequiredFunctions { return { environ_sizes_get: this.environ_sizes_get.bind(this), @@ -166,6 +174,7 @@ export class DisabledWASI { proc_exit: this.proc_exit.bind(this), path_open: this.path_open.bind(this), clock_time_get: this.clock_time_get.bind(this), + random_get: this.random_get.bind(this), } } }