Skip to content

Commit

Permalink
Merge pull request #36 from LoremLabs/chore/remove-unused
Browse files Browse the repository at this point in the history
chore(setler-cli): remove unused code
  • Loading branch information
mankins authored Jul 28, 2023
2 parents af4f930 + d5a7861 commit 7e29352
Showing 1 changed file with 0 additions and 132 deletions.
132 changes: 0 additions & 132 deletions identity-wallet/setler-cli/src/lib/auth-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,135 +729,3 @@ AuthAgent.prototype.sendToPool = async function ({ request }) {
return { response, status };
};

export const expandDid = async ({ did, network, identResolver }) => {
// TODO: use a general purpose did resolver, this is hard-coded to kudos dids

const identityResolver = identResolver || DEFAULTS.IDENTITY.RESOLVER;

const gqlQuery = {
query: `query SocialPay($identifier: String!) {
socialPay(identifier: $identifier) {
paymentMethods {
type
value
}
escrowMethods {
type
address
time
fee
terms
onExpiration
}
status {
message
code
}
}
}`,

variables: {
identifier: did,
},
operationName: "SocialPay",
extensions: {},
};
// console.log('gqlQuery', gqlQuery);
let results = {};

if (!identityResolver) {
throw new Error("identResolver is required");
}

// TODO: it would be better to batch these rather than one at a time...
try {
const headers = {
accept: "application/json",
"content-type": "application/json",
};

const options = {
headers,
method: "POST",
body: JSON.stringify(gqlQuery),
};

if (this.context.debug) {
console.log(fetchToCurl(`${identityResolver}/api/v1/gql`, options));
}

results = await fetch(`${identityResolver}/api/v1/gql`, options).then(
async (r) => {
// check status code
if (r.status !== 200) {
log(`\nError submitting did lookup: ${r.status} ${r.statusText}\n`);
const json = await r.json(); // not guaranteed to be json :(
if (json) {
const errMsg = json.data?.SocialPay?.status?.message || "";
throw new Error(errMsg);
}
throw new Error("Error submitting did lookup");
}

const out = await r.json();
// console.log('out', JSON.stringify(out,null,2));
return out;
}
);
} catch (e) {
console.log("error fetching gql", e);
// addToast({
// msg: 'Error submitting Kudos for Fame. Check your network connection and try again.',
// type: 'error',
// duration: 3000,
// });
results.status = {
message: "Error fetching did: " + e.message,
code: 500,
};

return results;
}

const payVias = results?.data?.socialPay?.paymentMethods || [];
// search for our network
const payVia = payVias.find((p) => p.type === network);
if (payVia) {
return { directPaymentVia: payVia.value, escrowMethod: null };
}

// otherwise we search for an escrow that matches
const escrowMethods = results?.data?.socialPay?.escrowMethods || [];
// search for our network
const escrowMethod = escrowMethods.find((p) => p.type === network);
if (escrowMethod) {
const e = new Error("Escrow only");
e.extra = { directPaymentVia: null, escrowMethod };
throw e;
}

return { directPaymentVia: null, escrowMethod: null };
};

// // get auth url
// const authUrl = await this.context.coins.getAuthUrl({ email });
// // open auth url
// const open = require("open");
// open(authUrl);
// // ask user to enter code
// const prompts = require("prompts");
// const response = await prompts({
// type: "text",
// name: "code",
// message: "Enter code:",
// });
// const code = response.code;
// if (!code) {
// throw new Error("Please provide a code");
// }
// // get auth token
// const authToken = await this.context.coins.getAuthToken({ email, code });
// // save auth token
// this.context.config.set("authToken", authToken);
// // return auth token
// return authToken;

2 comments on commit 7e29352

@vercel
Copy link

@vercel vercel bot commented on 7e29352 Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 7e29352 Jul 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ident-agency-net-enola – ./ident-agency/packages/enola

ident-agency-net-enola-git-main-loremlabs.vercel.app
ident-agency-net-enola-loremlabs.vercel.app
ident-agency-net-enola.vercel.app

Please sign in to comment.