Skip to content

Commit

Permalink
Merge pull request #14 from openfort-xyz/feat/encryption-sessions
Browse files Browse the repository at this point in the history
feat: encryption sessions
  • Loading branch information
gllm-dev authored Jul 15, 2024
2 parents db54f0e + 61bd2f4 commit 0668ee5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfort/openfort-node",
"version": "0.6.61",
"version": "0.6.62",
"description": "OpenAPI client for Openfort API",
"author": "Openfort",
"repository": {
Expand Down
22 changes: 22 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { EventsApiWrapper } from "./apis/eventsApiWrapper";
import { SubscriptionsApiWrapper } from "./apis/subscriptionsApiWrapper";
import { ExchangeApiWrapper } from "./apis/exchangeApiWrapper";
import { sign } from "./utilities/signer";
import fetch from "node-fetch";

export default class Openfort {
private readonly apiWrappers: { [name: string]: Observable } = {};
Expand Down Expand Up @@ -124,6 +125,27 @@ export default class Openfort {
public async signNonce(nonce: string): Promise<string> {
return await sign(this.apiKey, nonce);
}

public async registerRecoverySession(apiKey: string, secretKey: string, encryptionPart: string): Promise<string> {
const response = await fetch('https://shield.openfort.xyz/project/encryption-session', {
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
'x-api-secret': secretKey
},
method: 'POST',
body: JSON.stringify({
encryption_part: encryptionPart
}),
});

if (!response.ok) {
throw new Error("Failed to authorize user")
}

const jsonResponse = await response.json();
return jsonResponse.session_id;
}
}

export * from "./models";
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const VERSION = "0.6.61";
export const VERSION = "0.6.62";
export const PACKAGE = "@openfort/openfort-node";

0 comments on commit 0668ee5

Please sign in to comment.