Skip to main content
Deno 2 is finally here 🎉️
Learn more

eas-deno

GitHub issues GitHub

This Deno SDK is intended to be used in conjunction with making a user account at Encryption API Service and uptaining a API key to generate a token. The SDK makes authenticated API calls to the main EAS API. We have done ton’s of work for you on the API side of things organizing and researching some of the most popular and performant crytographic packages and implementing them in the systems level language Rust. We have also saved you the time of learning to work with Rust FFI in our performant_encryption crate which is what the API calls in this SDK are utilizing.

Home page for the Deno Third Party Module can here found here.

Examples

Getting a token

import * as EAS from "https://deno.land/x/eas_deno@v0.0.7/deps.ts?source";

// Insert API Key here
EAS.EASConfiguration.apiKey = "";

const tokenService = new EAS.TokenCache();
const token = await tokenService.getToken();
console.log(token);

ED25519-Dalek (Signatures)

import { EASConfiguration, TokenCache, ED25519DalekService, ED25519DalekKeyPairResponse, ED25519DalekSignResponse, ED25519DalekVerifyResponse } from "https://deno.land/x/eas_deno@v0.0.7/deps.ts?source";

// Insert API Key here
EASConfiguration.apiKey = "";

const tokenService = new TokenCache();
const token = await tokenService.getToken();

const ed25519Service = new ED25519DalekService();
const keyPair: ED25519DalekKeyPairResponse = await ed25519Service.generateKeyPair(token);
const signature: ED25519DalekSignResponse = await ed25519Service.sign(token, keyPair.keyPair, "Hello World!");
const isValid: ED25519DalekVerifyResponse = await ed25519Service.verify(token, signature.publicKey, signature.signature, "Hello World!");
console.log(isValid);

AES256 Encrypt / Decrypt

import { EASConfiguration, TokenCache, Aes256DecryptResponse, Aes256EncryptResponse, SymmetricEncryptionService } from "https://deno.land/x/eas_deno@v0.0.7/deps.ts?source";

// Insert API Key here
EASConfiguration.apiKey = "";

const tokenService = new TokenCache();
const symmetricService = new SymmetricEncryptionService();
const token = await tokenService.getToken();
const encryptedResult = await symmetricService.aes256Encrypt(token, "Hello World!");
const decrypted = await symmetricService.aes256Decrypt(token, encryptedResult.encrypted, encryptedResult.key, encryptedResult.nonce);
console.log(decrypted);

Password Hashing / Verify (Argon2)

import { EASConfiguration, TokenCache, Argon2HashPasswordResponse, PasswordService, Argon2VerifyResponse } from "https://deno.land/x/eas_deno@v0.0.7/deps.ts?source";

// Insert API Key here
EASConfiguration.apiKey = "";

const tokenService = new TokenCache();
const token = await tokenService.getToken();
const passwordService = new PasswordService();
const password: string = "Hello World!";
const hashed: Argon2HashPasswordResponse = await passwordService.argon2HashPassword(token, password);
const verified: Argon2VerifyResponse = await passwordService.argon2Verify(token, hashed.hashedPassword, password);
console.log(verified);

RSA Key Pair Generation, Encrypt, and Decrypt

import { EASConfiguration, TokenCache, RsaGetKeyPairResponse, RsaEncryptWithPublicResponse, RsaDecryptResponse, RsaService} from "https://deno.land/x/eas_deno@v0.0.7/deps.ts?source";

// Insert API Key here
EASConfiguration.apiKey = "";

const tokenService = new TokenCache();
const token = await tokenService.getToken();
const rsaService = new RsaService();

const keyPair: RsaGetKeyPairResponse = await rsaService.getRsaKeys(token, 4096);
const encrypted: RsaEncryptWithPublicResponse = await rsaService.encryptWithPublicKey(token, keyPair.publicKey, "Hello World");
const decrypted: RsaDecryptResponse = await rsaService.decryptWithPrivateKey(token, keyPair.privateKey, encrypted.encryptedData);
console.log(decrypted);

Supporters / Dontations

Microsoft For Startups

Buy Me A Coffee

This project is maintained using Apache 2.0.