@bunq-community/bunq-js-client
Version:
[ ](https://www.npmjs.com/package/@bunq-community/bunq-js-client) [ ](https://www.npmjs.com/p
45 lines (44 loc) • 1.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class Installation {
/**
* @param {ApiAdapter} ApiAdapter
*/
constructor(ApiAdapter) {
this.ApiAdapter = ApiAdapter;
this.Session = ApiAdapter.Session;
}
/**
* @param options
* @returns {Promise<{id; token: any; serverPublicKey: any}>}
*/
async add(options = {}) {
const limiter = this.ApiAdapter.RequestLimitFactory.create("/installation", "POST");
const result = await limiter.run(async (axiosClient) => this.ApiAdapter.post("/v1/installation", {
client_public_key: this.Session.publicKeyPem
}, {}, {
disableVerification: true,
disableSigning: true,
disableAuthentication: true,
skipSessionCheck: true
}, axiosClient));
return {
id: result.Response[0].Id.id,
token: result.Response[1].Token,
serverPublicKey: result.Response[2].ServerPublicKey.server_public_key
};
}
/**
* @param options
* @returns {Promise<{id; token: any; serverPublicKey: any}>}
*/
async get(installationId, options = {}) {
const result = await this.ApiAdapter.get(`/v1/installation/${installationId}`);
return {
id: result.Response[0].Id.id,
token: result.Response[1].Token,
serverPublicKey: result.Response[2].ServerPublicKey.server_public_key
};
}
}
exports.default = Installation;