Skip to content

Commit

Permalink
Merge pull request #6 from indexnetwork/pkp-session-to-api
Browse files Browse the repository at this point in the history
Pkp session to api
  • Loading branch information
serefyarar authored Jan 17, 2024
2 parents 3a1998f + 4e60141 commit c6c2994
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions api/src/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ export const getIndexById = async (req, res, next) => {
}
}
export const createIndex = async (req, res, next) => {


try {

const pkpSession = getPKPSession(req.session, req.body);
const pkpSession = await getPKPSession(req.session, req.body);

const indexService = new IndexService().setSession(pkpSession); //PKP
const newIndex = await indexService.createIndex(req.body);

Expand Down
5 changes: 3 additions & 2 deletions api/src/libs/lit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const getPKPSession = async (session, index) => {
try{
const litNodeClient = new LitJsSdk.LitNodeClientNodeJs({
litNetwork: 'cayenne',
debug: false,
});
await litNodeClient.connect();
const signerFunctionV0 = CID.parse(index.signerFunction).toV0().toString();
Expand All @@ -178,7 +179,7 @@ export const getPKPSession = async (session, index) => {

const { error } = resp.response; // TODO Handle.
if (error) {
console.log(error)
console.log("LIT Node Client Error", error);
return null;
}

Expand All @@ -195,7 +196,7 @@ export const getPKPSession = async (session, index) => {
const did = await createDIDCacao(didKey, cacao);
const pkpSession = new DIDSession({ cacao, keySeed, did });

await redis.hSet("sessions", sessionCacheKey, session.serialize());
await redis.hSet("sessions", sessionCacheKey, pkpSession.serialize());

await pkpSession.did.authenticate()
return pkpSession
Expand Down
1 change: 0 additions & 1 deletion api/src/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ export class IndexService {

try {
const content = {
...params,
updatedAt: getCurrentDateTime(),
deletedAt: getCurrentDateTime(),
};
Expand Down

0 comments on commit c6c2994

Please sign in to comment.