Skip to content

Commit

Permalink
Merge branch 'master' into st/chore/fuel-core-0.34.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf authored Aug 22, 2024
2 parents c424f4e + 9bba305 commit b49d0dd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-ducks-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-ts/utils": patch
---

fix: made bytecode compression browser compatible
32 changes: 24 additions & 8 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
# Security Policy
# Fuel Security Policy

The Fuel Typescript SDK is still in development, and we take security very seriously.
Thank you for helping make the Fuel ecosystem safe for everyone. The Fuel team take security bugs very seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.

## Security Issues
## Reporting Security Issues

If you find a vulnerability or exploit, please report it immediately and privately:
- https://github.com/FuelLabs/fuels-ts/security/advisories/new
If you believe you have found a security vulnerability in any Fuel-owned repository, please report it to us through coordinated disclosure.

> Please **DO NOT** file a public issue.
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**

Instead, please use the GitHub Security Advisory ["Report a Vulnerability"](https://github.com/FuelLabs/fuels-ts/security/advisories/new) tab.

The Fuel team will send a response indicating the next steps in handling your report. After the initial reply to your report, the team will keep you informed of the progress towards a fix and full announcement, and may ask for additional information or guidance.

Please include as much of the information listed below as you can to help us better understand and resolve the issue:

* The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

Report security bugs in third-party modules to the person or team maintaining the module.

## Non-Security Issues

If the issue is not security-related, please report it publicly:
- https://github.com/FuelLabs/fuels-ts/issues/new
If the issue is not security-related, please report it publicly by opening a [GitHub Issue](https://github.com/FuelLabs/fuels-ts/issues/new).
28 changes: 17 additions & 11 deletions packages/utils/src/utils/bytecode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@ import { gzipSync, gunzipSync } from 'fflate';

import { arrayify } from './arrayify';

export const compressBytecode = (bytecode?: BytesLike) => {
if (!bytecode) {
export const compressBytecode = (bytecodeAsBinary?: BytesLike) => {
if (!bytecodeAsBinary) {
return '';
}

const bytecodeBytes = arrayify(bytecode);
const bytecodeGzipped = gzipSync(bytecodeBytes);
const bytecodeEncoded = Buffer.from(bytecodeGzipped).toString('base64');
const bytecodeCompressBytes = arrayify(bytecodeAsBinary);
const bytecodeCompressGzipped = gzipSync(bytecodeCompressBytes);
const bytecodeCompressBinary = String.fromCharCode.apply(
null,
new Uint8Array(bytecodeCompressGzipped) as unknown as number[]
);
const bytecodeCompressEncoded = btoa(bytecodeCompressBinary);

return bytecodeEncoded;
return bytecodeCompressEncoded;
};

export const decompressBytecode = (bytecode: string) => {
const bytecodeDecoded = Buffer.from(bytecode, 'base64').toString('binary');
const bytecodeGzipped = Buffer.from(bytecodeDecoded, 'binary');
const bytecodeBytes = gunzipSync(bytecodeGzipped);
export const decompressBytecode = (bytecodeAsBase64: string) => {
const bytecodeDecompressBinary = atob(bytecodeAsBase64);
const bytecodeDecompressDecoded = new Uint8Array(bytecodeDecompressBinary.length).map((_, i) =>
bytecodeDecompressBinary.charCodeAt(i)
);
const bytecodeDecompressBytes = gunzipSync(bytecodeDecompressDecoded);

return bytecodeBytes;
return bytecodeDecompressBytes;
};

0 comments on commit b49d0dd

Please sign in to comment.