
Research
Using Trusted Protocols Against You: Gmail as a C2 Mechanism
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.
@deepzs/trustscript
Advanced tools
The package implements some of the features present in the Rust programming language, which are:
TRustScript
The package implements some of the features present in the Rust programming language, which are:
Option
: The Option type provides a way to express the presence or absence of a value. It is used to handle situations where a value may or may not exist.
Result
: The Result is used to handle operations that can either succeed or fail. It allows for more explicit error handling and propagation of errors throughout the code, similar to Rust's Result type.
These features aim to bring some of the functional error handling and optional value handling capabilities from Rust to the Node.js and TypeScript environment.
import { Option } from '@deepzs/trustscript'
// Initializing option
const option = new Option('Hello!')
// OR
const option = Option.from('Hello!')
const someOption = Option.from('Hello!')
console.log(someOption.isSome()) // true
console.log(someOption.isNone()) // false
console.log(someOption.unwrap()) // "Hello!"
console.log(someOption.unwrapOr("default")) // "Hello!"
console.log(someOption.expect("What happened?")) // "Hello!"
console.log(someOption.map((str) => `${str} World!`)) // Option { _value: "Hello World!" }
const noneOption = Option.from<string>(undefined)
console.log(noneOption.isSome()) // false
console.log(noneOption.isNone()) // true
console.log(noneOption.unwrap()) // Error: Unwrapped value is None
console.log(noneOption.unwrapOr("default")) // "default"
console.log(noneOption.expect("What happened?")) // Error: What happened?
console.log(noneOption.map((str) => `${str} World!`)) // Option { _value: undefined }
import { Result } from '@deepzs/trustscript'
// Initializing option
const result = new Result<string, Error>('Hello!', null)
// OR
const result = Result.fromFunction<string, Error>(() => 'Hello!')
// OR
const result = Result.fromAsyncFunction<string, Error>(() => new Promise((resolve) => resolve('Hello!')))
// OR
const myFunction = (arg1: boolean): Result<string, Error> => {
if (arg1) {
return Result.ok('Hello!')
} else {
return Result.error(new Error('Falsy...'))
}
}
const successResult = new Result<string, Error>('Hello!', null)
console.log(successResult.isOk()) // true
console.log(successResult.isError()) // false
console.log(successResult.unwrap()) // "Hello!"
console.log(successResult.unwrapOr("default")) // "Hello!"
console.log(successResult.expect("What happened?")) // "Hello!"
console.log(successResult.expectErr("Should be an error")) // Error: Should be an error
console.log(successResult.map((str) => `${str} World!`)) // Result { value: "Hello World!", error: undefined }
console.log(successResult.mapErr((e) => new Error(e.message.toUpperCase())).unwrap()) // Result { value: "Hello!", error: undefined }
const errorResult = new Result<string, Error>(undefined, new Error('MyCustomError'))
console.log(options.isOk()) // false
console.log(options.isError()) // true
console.log(options.unwrap()) // Error: Unwrapped value is Error
console.log(options.unwrapOr("default")) // "default"
console.log(options.expect("What happened?")) // Error: What happened?
console.log(options.expectErr("Should be an error")) // Error { message: "MyCustomError" }
console.log(options.map((str) => `${str} World!`)) // Result { value: undefined, error: Error { message: "MyCustomError" } }
console.log(options.mapErr((e) => new Error(e.message.toUpperCase()))) // Result { value: undefined, error: Error { message: "MYCUSTOMERROR" } }
FAQs
The package implements some of the features present in the Rust programming language, which are:
The npm package @deepzs/trustscript receives a total of 6 weekly downloads. As such, @deepzs/trustscript popularity was classified as not popular.
We found that @deepzs/trustscript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.