Skip to content

Commit

Permalink
fix: Update Node sampled to latest SDK usage (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
janpieterz authored Feb 17, 2023
1 parent 6502c5e commit a708213
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 30 deletions.
6 changes: 3 additions & 3 deletions node/basic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ async function signedInSearch() {
let service = new TrinsicService();
let loginResponse = await service.account().login({
email: "[email protected]",
ecosystemId: "",
invitationCode: "",
ecosystemId: "default"
});
let code =
rlsync.question("Enter the security code sent to your email:") ?? "";
Expand All @@ -22,7 +21,8 @@ async function signedInSearch() {

async function main() {
let service = new TrinsicService();
await service.account().loginAnonymous();
const authenticationToken = await service.account().loginAnonymous("default");
console.log("Authentication token", authenticationToken)

let searchResponse = await service.wallet().searchWallet();
console.log(searchResponse.items);
Expand Down
36 changes: 13 additions & 23 deletions node/express/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,7 @@ import express from "express";
import { Express, Request, Response } from "express";
import "dotenv/config";
import {
CreateCredentialTemplateRequest,
CreateEcosystemRequest,
CreateProofRequest,
FieldType,
InsertItemRequest,
IssueFromTemplateRequest,
TemplateData,
TemplateField,
TrinsicService,
VerifyProofRequest,
ServiceOptions,
EcosystemInfoRequest,
TrinsicService
} from "@trinsic/trinsic";

//-----------------
Expand All @@ -22,17 +11,18 @@ const port = 8000;

//-----------------
async function getEcoSystemId() {
const trinsic = new TrinsicService();

trinsic.setAuthToken(process.env.AUTHTOKEN || "");

const infoResponse = await trinsic
.provider()
.ecosystemInfo(EcosystemInfoRequest.fromPartial({}));

const ecosystem = infoResponse.ecosystem;

return ecosystem?.id;
try {
const trinsic = new TrinsicService();

trinsic.setAuthToken(process.env.AUTHTOKEN || "");

const accountInfo = await trinsic.account().info();
return accountInfo.ecosystemId;
}
catch(e){
console.error(e);
return "ERROR" + e;
}
}

//-----------------
Expand Down
6 changes: 2 additions & 4 deletions node/kubernetes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ async function start() {
})

app.post('/login',async (req, res) => {
systemState.loginResponse = await trinsicService.account().login({email: req.body.emailAddress,
ecosystemId: "default",
invitationCode: undefined
});
systemState.userAccountString = req.body.emailAddress;
systemState.loginResponse = await trinsicService.account().login({email: req.body.emailAddress, ecosystemId: "default"});
res.render('login', systemState)
})

Expand Down

0 comments on commit a708213

Please sign in to comment.