@simplito/privmx-webendpoint
Version:
PrivMX Web Endpoint library
88 lines (85 loc) • 3.74 kB
JavaScript
"use strict";
/*!
PrivMX Web Endpoint.
Copyright © 2024 Simplito sp. z o.o.
This file is part of the PrivMX Platform (https://privmx.dev).
This software is Licensed under the PrivMX Free License.
See the License for the specific language governing permissions and
limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CryptoApiNative = void 0;
const ExtKey_1 = require("../service/ExtKey");
const BaseNative_1 = require("./BaseNative");
;
class CryptoApiNative extends BaseNative_1.BaseNative {
async newApi() {
return this.runAsync((taskId) => this.api.lib.CryptoApi_newCryptoApi(taskId));
}
async deleteApi(ptr) {
await this.runAsync((taskId) => this.api.lib.CryptoApi_deleteCryptoApi(taskId, ptr));
this.deleteApiRef();
}
async create(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_create(taskId, ptr, args));
}
async signData(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_signData(taskId, ptr, args));
}
async verifySignature(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_verifySignature(taskId, ptr, args));
}
async generatePrivateKey(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_generatePrivateKey(taskId, ptr, args));
}
async derivePrivateKey(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_derivePrivateKey(taskId, ptr, args));
}
async derivePrivateKey2(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_derivePrivateKey2(taskId, ptr, args));
}
async derivePublicKey(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_derivePublicKey(taskId, ptr, args));
}
async generateKeySymmetric(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_generateKeySymmetric(taskId, ptr, args));
}
async encryptDataSymmetric(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_encryptDataSymmetric(taskId, ptr, args));
}
async decryptDataSymmetric(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_decryptDataSymmetric(taskId, ptr, args));
}
async convertPEMKeytoWIFKey(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_convertPEMKeytoWIFKey(taskId, ptr, args));
}
async generateBip39(ptr, args) {
const bipNative = await this.runAsync((taskId) => this.api.lib.CryptoApi_generateBip39(taskId, ptr, args));
return this.convertBIP(bipNative);
}
async fromMnemonic(ptr, args) {
const bipNative = await this.runAsync((taskId) => this.api.lib.CryptoApi_fromMnemonic(taskId, ptr, args));
return this.convertBIP(bipNative);
}
async fromEntropy(ptr, args) {
const bipNative = await this.runAsync((taskId) => this.api.lib.CryptoApi_fromEntropy(taskId, ptr, args));
return this.convertBIP(bipNative);
}
async entropyToMnemonic(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_entropyToMnemonic(taskId, ptr, args));
}
async mnemonicToEntropy(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_mnemonicToEntropy(taskId, ptr, args));
}
async mnemonicToSeed(ptr, args) {
return this.runAsync((taskId) => this.api.lib.CryptoApi_mnemonicToSeed(taskId, ptr, args));
}
convertBIP(bipNative) {
return {
mnemonic: bipNative.mnemonic,
entropy: bipNative.entropy,
extKey: ExtKey_1.ExtKey.fromPtr(bipNative.extKey)
};
}
}
exports.CryptoApiNative = CryptoApiNative;