Skip to content

Commit

Permalink
fix: signatures on regresh
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalavedra committed Apr 16, 2024
1 parent 8410bc5 commit cc0ad0f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 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-js",
"version": "0.6.8",
"version": "0.6.9",
"description": "",
"author": "Openfort",
"repository": {
Expand Down
12 changes: 10 additions & 2 deletions src/clients/iframe-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
IEventResponse,
LogoutRequest,
LogoutResponse,
OpenfortConfiguration,
ShieldAuthentication,
SignRequest,
SignResponse,
Expand Down Expand Up @@ -152,9 +153,16 @@ export class IframeClient {
async sign(message: string, requireArrayify?: boolean, requireHash?: boolean): Promise<string> {
await this.waitForIframeLoad();
const uuid = this.generateShortUUID();
const request = new SignRequest(uuid, message, requireArrayify, requireHash);
const openfortConfiguration: OpenfortConfiguration = {
openfortURL: this._configuration.openfortURL,
publishableKey: this._configuration.publishableKey,
thirdPartyProvider: this._configuration.thirdPartyProvider,
thirdPartyTokenType: this._configuration.thirdPartyTokenType,
token: this._configuration.accessToken,
};
const request = new SignRequest(uuid, message, requireArrayify, requireHash, openfortConfiguration);
this._iframe.contentWindow?.postMessage(request, "*");

let response: SignResponse;
try {
response = await this.waitForResponse<SignResponse>(uuid);
Expand Down
13 changes: 11 additions & 2 deletions src/clients/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,16 @@ export class SignRequest implements IEventRequest {
message: string;
requireArrayify?: boolean;
requireHash?: boolean;
openfortConfiguration?: OpenfortConfiguration;

constructor(uuid: string, message: string, requireArrayify?: boolean, requireHash?: boolean) {
constructor(uuid: string, message: string, requireArrayify?:boolean, requireHash?:boolean, openfortConfiguration?: OpenfortConfiguration) {
this.uuid = uuid;
this.message = message;
this.requireArrayify = requireArrayify;
this.requireHash = requireHash;
this.openfortConfiguration = openfortConfiguration;
}
}

export interface IEventResponse extends IEvent {
success: boolean;
action: Event;
Expand Down Expand Up @@ -218,3 +219,11 @@ export enum AuthType {
OPENFORT = "openfort",
CUSTOM = "custom",
}

export interface OpenfortConfiguration {
token: string;
thirdPartyProvider?: string;
thirdPartyTokenType?: string;
publishableKey: string;
openfortURL?: string;
}
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.8";
export const VERSION = "0.6.9";
export const PACKAGE = "@openfort/openfort-js";

0 comments on commit cc0ad0f

Please sign in to comment.