Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Uber plugin #8

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/uber/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare module 'main' {
// Extism exports take no params and return an I32
export function start(): I32;
export function two(): I32;
export function three(): I32;
export function config(): I32;
}

declare module 'extism:host' {
interface user {
redirect(ptr: I64): void;
notarize(ptr: I64): I64;
}
}
109 changes: 109 additions & 0 deletions examples/uber/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
function isValidHost(urlString) {
const url = new URL(urlString);
return url.hostname === 'riders.uber.com';
}

function gotoUber() {
const { redirect } = Host.getFunctions();
const mem = Memory.fromString('https://riders.uber.com');
redirect(mem.offset);
}

function start() {
console.log(JSON.stringify('TLSN start'));
if (!isValidHost(Config.get('tabUrl'))) {
gotoUber();
Host.outputString(JSON.stringify(false));
return;
}
Host.outputString(JSON.stringify(true));
}

function two() {
const cookies = JSON.parse(Config.get('cookies'))['riders.uber.com'];
const headers = JSON.parse(Config.get('headers'))['riders.uber.com'];
console.log("TLSN cookies");
console.log(JSON.stringify(cookies));
console.log("TLSN headers");
console.log(JSON.stringify(headers));

const sid = cookies.sid
const csid = cookies.csid
const jwt_session = cookies["jwt-session"]
console.log("JWT")
console.log(JSON.stringify(cookies["jwt-session"]))

const query = '{ "query": "{ currentUser { email firstName lastName uuid formattedNumber signupCountry } }" }'

Host.outputString(
JSON.stringify({
url: 'https://riders.uber.com/graphql',
method: 'POST',
headers: {
'content-type': 'application/json',
'Accept': '*/*',
Cookie: `sid=${sid}; csid=${csid}; jwt-session=${jwt_session}`,
'x-csrf-token': 'x',
Host: 'riders.uber.com',
'Accept-Encoding': 'identity',
Connection: 'close',
},
body: query
}),
);
}

function three() {
const params = JSON.parse(Host.inputString());
const { notarize } = Host.getFunctions();

if (!params) {
Host.outputString(JSON.stringify(false));
} else {
const mem = Memory.fromString(JSON.stringify(params));
console.log("notarize", JSON.stringify(mem))
const idOffset = notarize(mem.offset);
const id = Memory.find(idOffset).readString();
Host.outputString(JSON.stringify(id));
}
}

function config() {
Host.outputString(
JSON.stringify({
title: 'Uber Profile',
description: 'Notarize ownership of an Uber profile',
icon: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUAAAAFACAAAAADo+/p2AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAACYktHRAD/h4/MvwAAAAd0SU1FB+gGCwkvAQRIcpoAABSvSURBVHja7Z35d9tWdscvABIguFOkRImUKGqxtVm2Iku2Y1uJPUkmycyc6bSn6elv8y+1f0HbM9OetulM52TSZrGTTGzHlrzGsrVL1kaJlMR9BUkArz9oIShxAUXPodvez28AHq/e+77tvvseIAAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQZA3FKrcA3On08KQgwsmNuvPE7UmnR6HgSKH9v2zUQkAAGjD2S5GPrhNhZb3MnKjS/8a0JR74PzZO328dHChW/i725Kk0iTV9xeXPdSBOAx16+9TMgEA0DT/9d/q8vu3aebpP0xm/08LyDo8PYWrnJmh1JgDAKAMrV1thUs3f/BLinV6C7c7zVrVFt9k6HIPSD6bLVwJotoODABSTlBcZQ9bLiE5RSMWpBosvsHQ9Zv4/w0KWCcoYJ2ggHWCAtYJClgnKGCdoIB1ggLWCQpYJyhgnaCAdYIC1gkKWCcoYJ2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y3JlYXRlADIwMjQtMDYtMTFUMDk6NDU6NTArMDA6MDB9qhh5AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDI0LTA2LTExVDA5OjQ1OjQ2KzAwOjAwo42VYQAAACh0RVh0ZGF0ZTp0aW1lc3RhbXAAMjAyNC0wNi0xMVQwOTo0NzowMSswMDowMLGAVPcAAAAASUVORK5CYII=',
steps: [
{
title: 'Visit Uber website',
cta: 'Go to uber.com',
action: 'start',
},
{
title: 'Collect credentials',
description: "Login to your account if you haven't already",
cta: 'Checking cookies',
action: 'two',
},
{
title: 'Notarize Uber profile',
cta: 'Notarize',
action: 'three',
prover: true,
},
],
hostFunctions: ['redirect', 'notarize'],
cookies: ['riders.uber.com'],
headers: ['riders.uber.com'],
requests: [
{
url: 'https://riders.uber.com/graphql',
method: 'POST',
},
],
}),
);
}

module.exports = { start, config, two, three };