Skip to content

Instantly share code, notes, and snippets.

View ThisIsMissEm's full-sized avatar

Emelia Smith ThisIsMissEm

View GitHub Profile
@ThisIsMissEm
ThisIsMissEm / Schema.graphql
Created October 2, 2019 05:15
Form Validation as a Result Union
mutation updateUser(
details: UpdateUserInput!
): UpdateUserResult
union UpdateUserResult =
UpdateUserSuccess |
FormValidationError
type UpdateUserSuccess {}
import { Kafka, logLevel, KafkaConfig, SASLOptions } from "kafkajs";
const options: KafkaConfig = {
clientId: "my-client",
brokers: (process.env.KAFKA_BROKERS &&
process.env.KAFKA_BROKERS.split(",")) || ["localhost:9092"]
};
if (
process.env.KAFKA_AUTH_MECHANISM &&
import { Kafka, Consumer, Producer, KafkaMessage } from "kafkajs";
import { Logger } from "pino";
import { EventEmitter } from "events";
import uuidv4 from "uuid/v4";
type Options = {
groupId: string;
topicPrefix: string;
logger: Logger;
};
type Key {
constructor(identifier)
unlock(): Promise<void>
lock(): Promise()<void>
decrypt(value: ArrayBuffer): Promise<ArrayBuffer>
}
type Key {
constructor(identifier)
unlock(): Promise<void>
lock(): Promise()<void>
decrypt(value: ArrayBuffer): Promise<ArrayBuffer>
}
@ThisIsMissEm
ThisIsMissEm / gist:13d37d8745f39656ed52e88031d69bf6
Created July 24, 2019 19:28
Securely(?) sharing private keys using DHTs & one-time tokens
‪From the initiating client (owner)‬
1. create a short-code (say 12 lowercase hex characters)‬
2. Using the dat archives public key, encrypt that value, let that be token‬
3. poll a DHT for token's value‬
4. Once we receive a value for that token, encrypt the archive private key with the received public key & save as a file
‪From the new client:‬
1. Ask the user to input the short-code from the same dat archive
2. Using the archives public-key, encrypt that value
3. Create a new public/private key pair
const fs = require("fs").promises;
const createReadStream = require("fs").createReadStream;
const debug = require("debug");
class MessageLogDB {
constructor(filename, separator) {
this.separator = separator || "\r\n";
this.separator_length = Buffer.byteLength(this.separator, "utf8");
this.filename = filename;
const fs = require("fs").promises;
const path = require("path");
const execa = require("execa");
const assert = require("assert");
const gitUrlParse = require("git-url-parse");
const fse = require("fs-extra");
async function findRepos(workingDirectory) {
const nodes = await fs.readdir(workingDirectory, { withFileTypes: true });
const directories = nodes.filter(node => node.isDirectory());
@ThisIsMissEm
ThisIsMissEm / package.json
Last active April 6, 2019 22:14
Concept for multi-registry support in package.json
{
"name": "my-app",
"version": "1.0.0",
"registries": {
"npm": { "url": "registry.npmjs.org", "default": true },
"tidelift": { "url": "registry.tidelift.org" },
"acme-corp": { "url": "verdaccio.acme.corp" }
},
"dependencies": {
"express": "^4.0.x",
$ npm run test
> node-fetch@2.2.0 test /Users/emelia/Work/HighSnobiety/repos/node-fetch
> cross-env BABEL_ENV=test mocha --require babel-register test/test.js
node-fetch
✓ should return a promise
✓ should allow custom promise