@airgap/beacon-sdk
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -7,3 +7,3 @@ import { Storage } from '../..'; | ||
eventHandlers?: { | ||
[key in BeaconEvent]: { | ||
[key in BeaconEvent]?: { | ||
handler: BeaconEventHandlerFunction; | ||
@@ -10,0 +10,0 @@ }; |
import { ExposedPromise } from '../../utils/exposed-promise'; | ||
import { BeaconEvent, BeaconEventHandlerFunction } from '../../events'; | ||
import { BeaconEvent, BeaconEventHandlerFunction, BeaconEventType } from '../../events'; | ||
import { ConnectionContext } from '../../types/ConnectionContext'; | ||
@@ -21,3 +21,3 @@ import { AccountInfo, Client, TransportType, Transport, BeaconMessageType, BeaconErrorMessage, BeaconMessage, RequestPermissionInput, RequestSignPayloadInput, RequestOperationInput, RequestBroadcastInput, AppMetadata, PermissionResponseOutput, SignPayloadResponseOutput, OperationResponseOutput, BroadcastResponseOutput } from '../..'; | ||
connect(): Promise<boolean>; | ||
subscribeToEvent(internalEvent: BeaconEvent, eventCallback: BeaconEventHandlerFunction): Promise<void>; | ||
subscribeToEvent<K extends BeaconEvent>(internalEvent: K, eventCallback: BeaconEventHandlerFunction<BeaconEventType[K]>): Promise<void>; | ||
checkPermissions(type: BeaconMessageType): Promise<boolean>; | ||
@@ -24,0 +24,0 @@ requestPermissions(input?: RequestPermissionInput): Promise<PermissionResponseOutput>; |
@@ -8,3 +8,3 @@ import { Storage } from '../..'; | ||
eventHandlers?: { | ||
[key in BeaconEvent]: { | ||
[key in BeaconEvent]?: { | ||
handler: BeaconEventHandlerFunction; | ||
@@ -11,0 +11,0 @@ }; |
@@ -44,3 +44,3 @@ import { P2PPairInfo, AccountInfo } from '.'; | ||
overrideDefaults(eventsToOverride: { | ||
[key in BeaconEvent]: { | ||
[key in BeaconEvent]?: { | ||
handler: BeaconEventHandlerFunction; | ||
@@ -47,0 +47,0 @@ }; |
@@ -6,2 +6,4 @@ "use strict"; | ||
const qr_1 = require("./utils/qr"); | ||
const Logger_1 = require("./utils/Logger"); | ||
const logger = new Logger_1.Logger('BeaconEvents'); | ||
var BeaconEvent; | ||
@@ -50,3 +52,3 @@ (function (BeaconEvent) { | ||
confirmButtonText: 'Ok!', | ||
body: qr_1.getQrData(JSON.stringify(data)), | ||
body: qr_1.getQrData(JSON.stringify(data), 'svg'), | ||
successCallback: () => { | ||
@@ -59,3 +61,3 @@ console.log('CALLBACK'); | ||
const emptyHandler = async (data) => { | ||
console.error(`no default listener for event ${event}`, data); | ||
logger.warn('emptyHandler', `no default listener for event ${event}`, data); | ||
}; | ||
@@ -112,4 +114,7 @@ exports.defaultEventCallbacks = { | ||
Object.keys(eventsToOverride).forEach((untypedEvent) => { | ||
const event = untypedEvent; | ||
this.callbackMap[event] = [eventsToOverride[event].handler]; | ||
const eventType = untypedEvent; | ||
const event = eventsToOverride[eventType]; | ||
if (event) { | ||
this.callbackMap[eventType] = [event.handler]; | ||
} | ||
}); | ||
@@ -116,0 +121,0 @@ } |
@@ -41,3 +41,3 @@ "use strict"; | ||
const data = message.data; | ||
if (data.message.target === __1.ExtensionMessageTarget.PAGE) { | ||
if (data.message && data.message.target === __1.ExtensionMessageTarget.PAGE) { | ||
this.notifyListeners(data.message.payload, { | ||
@@ -44,0 +44,0 @@ origin: Origin_1.Origin.EXTENSION, |
{ | ||
"name": "@airgap/beacon-sdk", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "The beacon-sdk is setup in a way to allow for p2p communication between wallets and dapps", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
238479
3569