Skip to content

Instantly share code, notes, and snippets.

View apowers313's full-sized avatar

Adam Powers apowers313

View GitHub Profile
@apowers313
apowers313 / test.ts
Created December 8, 2021 17:52
Deno Redis TCP setNoDelay Issue
// run with:
// deno run --allow-all --unstable test.ts
import { Graph as RedisGraph } from "https://esm.sh/redisgraph.js";
let graph = new RedisGraph("social");
// fails with error:
/*
error: Uncaught Error: Not implemented
throw new Error(message);
@apowers313
apowers313 / test.ts
Created December 8, 2021 17:49
Deno Redis Compat
// setup:
// npm init -y
// npm install --save redisgraph.js
// run with:
// deno run --allow-all --unstable --compat test.ts
const RedisGraph = require("redisgraph.js").Graph;
let graph = new RedisGraph("social");
@apowers313
apowers313 / Makefile
Created November 9, 2020 03:54
Emscripten Memory Leak on node.js
CC=emcc
CFLAGS =
CFLAGS += -Wall
CFLAGS += -Werror
CFLAGS += -s MODULARIZE
CFLAGS += -s EXIT_RUNTIME
all:
emcc leak.c $(CFLAGS) -o build/test.js
@apowers313
apowers313 / mds-collections.json
Created July 9, 2018 17:34
A collection of FIDO MDS data
This file has been truncated, but you can view the full file.
{
"mdsCollections": [
{
"fido-mds1": {
"toc": {
"nextUpdate": "2018-07-06",
"no": 63
},
"entries": {
"0013#0061": {
@apowers313
apowers313 / client.js
Created June 27, 2018 05:59
OpenID Connect Client and Provider
"use strict";
const { Issuer, Strategy } = require("openid-client");
const passport = require("passport");
const express = require("express");
const session = require("express-session");
const app = express();
// passport setup
passport.serializeUser(function(user, done) {
@apowers313
apowers313 / packed-attestation-data-example.js
Last active June 3, 2018 14:49
Parsing packed attestation object
const attestationObjectCbor = [
0xA3, 0x63, 0x66, 0x6D, 0x74, 0x66, 0x70, 0x61, 0x63, 0x6B, 0x65, 0x64, 0x67, 0x61, 0x74, 0x74,
0x53, 0x74, 0x6D, 0x74, 0xA3, 0x63, 0x61, 0x6C, 0x67, 0x26, 0x63, 0x73, 0x69, 0x67, 0x58, 0x48,
0x30, 0x46, 0x02, 0x21, 0x00, 0x8B, 0x0A, 0xD1, 0x6A, 0xFD, 0xB6, 0x6B, 0x9D, 0xFB, 0x06, 0x88,
0x62, 0x84, 0x30, 0xDB, 0x45, 0x16, 0x8B, 0xB0, 0xCB, 0xFE, 0x00, 0xF1, 0xFC, 0xF3, 0x46, 0xDC,
0xF0, 0x79, 0xED, 0xE1, 0xCB, 0x02, 0x21, 0x00, 0xB5, 0x1C, 0x9D, 0xFB, 0x82, 0x48, 0xDA, 0x90,
0x95, 0x5F, 0xE7, 0x43, 0xCF, 0x89, 0x9B, 0x1D, 0xCF, 0xC0, 0x92, 0xF0, 0xB7, 0x77, 0xFE, 0x2A,
0x9C, 0x10, 0x5A, 0xDE, 0x7D, 0x88, 0xFE, 0x15, 0x63, 0x78, 0x35, 0x63, 0x83, 0x59, 0x02, 0x45,
0x30, 0x82, 0x02, 0x41, 0x30, 0x82, 0x01, 0xE8, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0x15,
0x9F, 0x7B, 0xC2, 0xCD, 0x89, 0x18, 0xF1, 0x28, 0x6B, 0x93, 0x48, 0xFA, 0x9F, 0x33, 0xE2, 0x30,
var challengeResponseAttestationTpmB64UrlMsg = {
"fmt": "tpm",
"authData": "ACH1_AuFzSLmBiO819HKSJSJCSSbR3brUVFU5XtmrhJFAAAAAAiYcFjK3EuBtuEw3lDcvpYAICichPudWAHSGBGutbra6sponHJq46QSqYSTvuECv9TypAEDAzkBACBZAQDIy_NkHfALX9bo4IcTFhfTYqiN5oTA6fLeYWSdYuRDl0Kc36xJlsmUn7684N-H1LiUjc2ikyVKQOEvcXWt_M_8m3hf9hnPF5srGVb9PJy7Hu_Al5c0AKvDW8MvuWQtLdoyqyjc_K2zufHb-p3JAwas-ASJmBNTKC5N5I372SUk4h_POnUIBcS2ILeANcrz1IMKwkMpPVbWviOoZBOmJlpHW-gmGStCgXNZkipAwIf_iyf3O9psN8aNY-2xq6iwBBkoK5RejNcJu29Hd5boCIpWN2eGrYb77EVI_tdpmgftwqdUkeF4f8eUIIB9EIF8bsCAAHQETDVoWaMVezcfwmsDIUMBAAE",
"attStmt": {
"ver": "2.0",
"alg": -262,
"sig": "ZJhH97wfhLNjAspXDakD_cW5ciDRPmKQf58PBSCAusj02nD49gRdDJVCk0-oDZ-z0yYSXL0Odyl2pTsAaIPyobFuN4LX4-WzoZzp1P93xQhE5IsRSTuk4R2K7FBu6VRQ10oc0GkEk_vniHtDkfssxjcolicVxHTrB2Ozs4GkJeiyz2I6H1apfZaUFJRJS8PbUTdEtSTEbKUGV9ZoxOgwTj0yeP0MxlZaA_xnrZEF3LH4XeOgTge1T4HRjkb0_68nFmnI7icqVe9YTdb2ItV2C2-FDBdyfhPPsQ95MAciDcNOe9JSjG3Mb9Wkkl6u-9YGfXUwA8rioISXGyuS1kCXVA",
"x5c": ["MIIEsjCCA5qgAwIBAgIQ
@apowers313
apowers313 / pkijs_fido_u2f.js
Created March 16, 2018 19:23
Attempting to validate U2F attestation against Yubico root cert
require("babel-polyfill");
var asn1js = require("asn1js");
var pkijs = require("pkijs");
const WebCrypto = require("node-webcrypto-ossl");
const webcrypto = new WebCrypto();
const {
CryptoEngine,
Certificate
} = pkijs;
pkijs.setEngine("newEngine", webcrypto, new CryptoEngine({
@apowers313
apowers313 / WebAuthnPrintOutput.js
Last active March 9, 2018 23:31
Prints output from WebAuthn calls
function printHex(msg, buf) {
// if the buffer was a TypedArray (e.g. Uint8Array), grab its buffer and use that
if (ArrayBuffer.isView(buf) && buf.buffer instanceof ArrayBuffer) {
buf = buf.buffer;
}
// check the arguments
if ((typeof msg != "string") ||
(typeof buf != "object")) {
console.log("Bad args to printHex");
@apowers313
apowers313 / .deploy-output.sh
Created June 23, 2017 20:20
Deploy Pull Requests
#!/bin/bash
## Copyright 2016, W3C
set -ev
STATUS=`git log -1 --pretty=oneline`
# build output path
rm -rf "" out
OUTPUT_PATH=out
if [ "$TRAVIS_PULL_REQUEST" != "" ]; then
echo "Adding $TRAVIS_PULL_REQUEST to output path"