Skip to content

Commit

Permalink
addded a simple check to ensure that the url being navigated to via a…
Browse files Browse the repository at this point in the history
… tkn request is available
  • Loading branch information
Nick Taras authored and Nick Taras committed Sep 20, 2023
1 parent bbf33a3 commit aa1ef5b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
tokenIdName: "id",
image:
"https://raw.githubusercontent.com/TokenScript/token-negotiator/main/mock-images/devcon.svg",
tokenOrigin: "http://localhost:3002/",
tokenOrigin: "http://localhost:3000/",
attestationOrigin: "https://test.attestation.id/",
base64senderPublicKeys: {
6: "MIIBMzCB7AYHKoZIzj0CATCB4AIBATAsBgcqhkjOPQEBAiEA/////////////////////////////////////v///C8wRAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHBEEEeb5mfvncu6xVoGKVzocLBwKb/NstzijZWfKBWxb4F5hIOtp3JqPEZV2k+/wOEQio/Re0SKaFVBmcR9CP+xDUuAIhAP////////////////////66rtzmr0igO7/SXozQNkFBAgEBA0IABGMxHraqggr2keTXszIcchTjYjH5WXpDaBOYgXva82mKcGnKgGRORXSmcjWN2suUCMkLQj3UNlZCFWF10wIrrlw=",
Expand Down
2 changes: 2 additions & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ export const enum UIUpdateEventType {
export enum ClientError {
POPUP_BLOCKED = 'POPUP_BLOCKED',
USER_ABORT = 'USER_ABORT',
ISSUER_UNAVAILABLE = 'ISSUER_UNAVAILABLE',
}

export enum ClientErrorMessage {
POPUP_BLOCKED = 'Please add an exception to your popup blocker before continuing.',
USER_ABORT = 'The user aborted the process.',
ISSUER_UNAVAILABLE = 'The issuer is unavailable.',
}

export class Client {
Expand Down
16 changes: 15 additions & 1 deletion src/core/messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,29 @@ export class Messaging {
iframe: any = null
listenerSet = false

async isWebsiteAvailable(url) {
return fetch(url, {
method: 'HEAD',
cache: 'no-store',
})
.then((response) => {
console.log('response', response)
return response.status === 200
})
.catch((error) => {
throw error
})
}

async sendMessage(
request: RequestInterfaceBase,
forceTab = false,
redirectUrl: false | string = false,
): Promise<ResponseInterfaceBase | void> {
logger(2, 'Send request: ')
logger(2, request)

if (redirectUrl) {
await this.isWebsiteAvailable(request.origin)
this.sendRedirect(request, redirectUrl)
return
}
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// modified by build process.
export const VERSION = '3.0.2'
export const VERSION = '3.1.0'

0 comments on commit aa1ef5b

Please sign in to comment.