@massalabs/wallet-provider 1.2.1-dev.20230816140912 → 1.2.1-dev.20230818073036
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle.js +43 -37
- package/bundle.min.js +1 -1
- package/dist/account/Account.js +9 -13
- package/dist/account/AccountBalance.js +1 -2
- package/dist/account/AccountSign.js +1 -2
- package/dist/account/IAccount.js +1 -2
- package/dist/account/IAccountCallSCRequest.js +1 -2
- package/dist/account/IAccountDetails.js +1 -2
- package/dist/account/IAccountRolls.js +1 -2
- package/dist/account/IAccountSendTransaction.js +1 -2
- package/dist/account/index.js +1 -5
- package/dist/bearbyWallet/BalanceResponse.js +1 -2
- package/dist/bearbyWallet/BearbyAccount.js +22 -26
- package/dist/bearbyWallet/BearbyConnect.js +6 -12
- package/dist/bearbyWallet/BearbyProvider.js +7 -11
- package/dist/bearbyWallet/ICallData.js +1 -2
- package/dist/bearbyWallet/NodeStatus.js +1 -2
- package/dist/bearbyWallet/jsonRpcMethods.js +2 -5
- package/dist/bearbyWallet/jsonRpcResponseData.js +1 -2
- package/dist/cmd/connector/Connector.d.ts.map +1 -1
- package/dist/cmd/connector/Connector.js +29 -24
- package/dist/cmd/connector/Connector.js.map +1 -1
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/index.js +8 -6
- package/dist/cmd/index.js.map +1 -1
- package/dist/cmd/massaStation/MassaStationAccount.d.ts.map +1 -1
- package/dist/cmd/massaStation/MassaStationAccount.js +6 -7
- package/dist/cmd/massaStation/MassaStationAccount.js.map +1 -1
- package/dist/connector/Connector.d.ts.map +1 -1
- package/dist/connector/Connector.js +41 -39
- package/dist/connector/ICustomEventMessageRequest.js +1 -2
- package/dist/connector/ICustomEventMessageResponse.js +1 -2
- package/dist/connector/IRegisterEvent.js +1 -2
- package/dist/connector/index.js +1 -6
- package/dist/esm/connector/Connector.d.ts.map +1 -1
- package/dist/esm/connector/Connector.js +29 -24
- package/dist/esm/connector/Connector.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/massaStation/MassaStationAccount.d.ts.map +1 -1
- package/dist/esm/massaStation/MassaStationAccount.js +6 -7
- package/dist/esm/massaStation/MassaStationAccount.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -42
- package/dist/massaStation/MassaStationAccount.d.ts.map +1 -1
- package/dist/massaStation/MassaStationAccount.js +24 -29
- package/dist/massaStation/MassaStationDiscovery.js +10 -14
- package/dist/massaStation/MassaStationProvider.js +22 -26
- package/dist/massaStation/RequestHandler.js +9 -16
- package/dist/provider/AccountDeletion.js +2 -5
- package/dist/provider/AccountImport.js +2 -5
- package/dist/provider/AccoutGeneration.js +1 -2
- package/dist/provider/IProvider.js +1 -2
- package/dist/provider/Provider.js +10 -14
- package/dist/provider/index.js +3 -9
- package/dist/utils/argsToBase64.js +2 -7
- package/dist/utils/time.js +4 -11
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -5759,14 +5759,16 @@ class Connector {
|
|
|
5759
5759
|
*/
|
|
5760
5760
|
constructor() {
|
|
5761
5761
|
this.registeredProviders = {};
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5762
|
+
if (typeof document !== 'undefined') {
|
|
5763
|
+
this.pendingRequests = new Map();
|
|
5764
|
+
this.massaStationListener = new MassaStationDiscovery_1.MassaStationDiscovery();
|
|
5765
|
+
this.initMassaStationListener();
|
|
5766
|
+
this.register();
|
|
5767
|
+
// start listening to messages from content script
|
|
5768
|
+
document
|
|
5769
|
+
.getElementById(exports.MASSA_WINDOW_OBJECT)
|
|
5770
|
+
.addEventListener('message', this.handleResponseFromContentScript.bind(this));
|
|
5771
|
+
}
|
|
5770
5772
|
}
|
|
5771
5773
|
/**
|
|
5772
5774
|
* This method adds a register listener in the web page.
|
|
@@ -5781,22 +5783,25 @@ class Connector {
|
|
|
5781
5783
|
*/
|
|
5782
5784
|
register() {
|
|
5783
5785
|
// global event target to use for all wallet provider
|
|
5784
|
-
if
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5786
|
+
// check if document exist
|
|
5787
|
+
if (typeof document !== 'undefined') {
|
|
5788
|
+
if (!document.getElementById(exports.MASSA_WINDOW_OBJECT)) {
|
|
5789
|
+
const inv = document.createElement('p');
|
|
5790
|
+
inv.id = exports.MASSA_WINDOW_OBJECT;
|
|
5791
|
+
inv.setAttribute('style', 'display:none');
|
|
5792
|
+
document.body.appendChild(inv);
|
|
5793
|
+
}
|
|
5794
|
+
// add an invisible HTML element and set a listener to it like the following
|
|
5795
|
+
// hook up register handler
|
|
5796
|
+
document
|
|
5797
|
+
.getElementById(exports.MASSA_WINDOW_OBJECT)
|
|
5798
|
+
.addEventListener('register', (evt) => {
|
|
5799
|
+
const payload = evt.detail;
|
|
5800
|
+
const providerEventTargetName = `${exports.MASSA_WINDOW_OBJECT}_${payload.providerName}`;
|
|
5801
|
+
this.registeredProviders[payload.providerName] =
|
|
5802
|
+
providerEventTargetName;
|
|
5803
|
+
});
|
|
5789
5804
|
}
|
|
5790
|
-
// add an invisible HTML element and set a listener to it like the following
|
|
5791
|
-
// hook up register handler
|
|
5792
|
-
document
|
|
5793
|
-
.getElementById(exports.MASSA_WINDOW_OBJECT)
|
|
5794
|
-
.addEventListener('register', (evt) => {
|
|
5795
|
-
const payload = evt.detail;
|
|
5796
|
-
const providerEventTargetName = `${exports.MASSA_WINDOW_OBJECT}_${payload.providerName}`;
|
|
5797
|
-
this.registeredProviders[payload.providerName] =
|
|
5798
|
-
providerEventTargetName;
|
|
5799
|
-
});
|
|
5800
5805
|
}
|
|
5801
5806
|
initMassaStationListener() {
|
|
5802
5807
|
this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCOVERED, () => {
|
|
@@ -5841,7 +5846,7 @@ class Connector {
|
|
|
5841
5846
|
};
|
|
5842
5847
|
this.pendingRequests.set(requestId, responseCallback);
|
|
5843
5848
|
// dispatch an event to the specific provider event target
|
|
5844
|
-
const specificProviderEventTarget = document
|
|
5849
|
+
const specificProviderEventTarget = document?.getElementById(`${this.registeredProviders[providerName]}`);
|
|
5845
5850
|
if (!specificProviderEventTarget) {
|
|
5846
5851
|
throw new Error(`Registered provider with name ${providerName} does not exist`);
|
|
5847
5852
|
}
|
|
@@ -5975,12 +5980,14 @@ function getProviderInstances() {
|
|
|
5975
5980
|
* @param id - The id of the HTML element that is used to communicate with the provider.
|
|
5976
5981
|
*/
|
|
5977
5982
|
function registerProvider(name, id = Connector_1.MASSA_WINDOW_OBJECT) {
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
element
|
|
5983
|
+
if (typeof document !== 'undefined') {
|
|
5984
|
+
const registerEvent = new CustomEvent('register', {
|
|
5985
|
+
detail: { providerName: name },
|
|
5986
|
+
});
|
|
5987
|
+
const element = document?.getElementById(id);
|
|
5988
|
+
if (element) {
|
|
5989
|
+
element.dispatchEvent(registerEvent);
|
|
5990
|
+
}
|
|
5984
5991
|
}
|
|
5985
5992
|
}
|
|
5986
5993
|
exports.registerProvider = registerProvider;
|
|
@@ -6091,12 +6098,6 @@ class MassaStationAccount {
|
|
|
6091
6098
|
* @returns An IAccountSignResponse object. It contains the signature of the message.
|
|
6092
6099
|
*/
|
|
6093
6100
|
async sign(data) {
|
|
6094
|
-
if (data instanceof Buffer) {
|
|
6095
|
-
data = data.toString();
|
|
6096
|
-
}
|
|
6097
|
-
if (data instanceof Uint8Array) {
|
|
6098
|
-
data = new TextDecoder().decode(data);
|
|
6099
|
-
}
|
|
6100
6101
|
let signOpResponse = null;
|
|
6101
6102
|
try {
|
|
6102
6103
|
signOpResponse = await (0, RequestHandler_1.postRequest)(`${MassaStationProvider_1.MASSA_STATION_ACCOUNTS_URL}/${this._name}/sign`, {
|
|
@@ -6111,7 +6112,12 @@ class MassaStationAccount {
|
|
|
6111
6112
|
if (signOpResponse.isError || signOpResponse.error) {
|
|
6112
6113
|
throw signOpResponse.error;
|
|
6113
6114
|
}
|
|
6114
|
-
|
|
6115
|
+
// convert signOpResponse.result.signature to Uint8Array
|
|
6116
|
+
const signature = new Uint8Array(Buffer.from(signOpResponse.result.signature));
|
|
6117
|
+
return {
|
|
6118
|
+
publicKey: signOpResponse.result.publicKey,
|
|
6119
|
+
signature: signature,
|
|
6120
|
+
};
|
|
6115
6121
|
}
|
|
6116
6122
|
/**
|
|
6117
6123
|
* This method aims to buy rolls on behalf of the sender.
|