New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@usecapsule/user-management-client

Package Overview
Dependencies
Maintainers
13
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@usecapsule/user-management-client - npm Package Compare versions

Comparing version 0.18.0-dev.2 to 0.18.0-dev.3

6

client.ts

@@ -209,4 +209,6 @@ import axios, { AxiosInstance, AxiosRequestHeaders, AxiosResponseHeaders } from 'axios';

console.log(response)
console.log(JSON.stringify(response))
console.log(JSON.stringify(response.headers))
console.log(JSON.stringify(response.headers.entries()))
for (let [key, value] of response.headers.entries()) {
console.log(key, value);
}
const resText = await response.text();

@@ -213,0 +215,0 @@ console.log(resText)

@@ -11,38 +11,2 @@ "use strict";

};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -53,3 +17,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

exports.KeyType = exports.EncryptorType = exports.Chain = exports.SignatureScheme = exports.PublicKeyType = exports.PublicKeyStatus = exports.USER_NOT_MATCHING_ERROR = exports.USER_NOT_AUTHENTICATED_ERROR = exports.USER_NOT_VERIFIED = void 0;
var axios_1 = __importDefault(require("axios"));
const axios_1 = __importDefault(require("axios"));
exports.USER_NOT_VERIFIED = 'user must verify biometrics';

@@ -89,315 +53,140 @@ exports.USER_NOT_AUTHENTICATED_ERROR = 'user must be authenticated';

};
var SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid';
var Client = /** @class */ (function () {
function Client(_a) {
var userManagementHost = _a.userManagementHost, apiKey = _a.apiKey, opts = _a.opts, retrieveSessionCookie = _a.retrieveSessionCookie, persistSessionCookie = _a.persistSessionCookie;
var _this = this;
this.createUser = function (body) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users", body)];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); };
this.checkUserExists = function (email) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/exists?email=".concat(encodeURIComponent(email)))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
const SESSION_COOKIE_HEADER_NAME = 'x-capsule-sid';
class Client {
constructor({ userManagementHost, apiKey, opts, retrieveSessionCookie, persistSessionCookie }) {
this.createUser = (body) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users`, body);
return res.data;
});
this.checkUserExists = (email) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/exists?email=${encodeURIComponent(email)}`);
return res;
});
// POST /users/:userId/verify-email
this.verifyEmail = function (userId, body) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/verify-email"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.verifyEmail = (userId, body) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/verify-email`, body);
return res;
});
// POST /users/:userId/biometrics/key
this.addSessionPublicKey = function (userId, body) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/biometrics/key"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.addSessionPublicKey = (userId, body) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/biometrics/key`, body);
return res;
});
// GET /users/:userId/biometrics/keys
this.getSessionPublicKeys = function (userId) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/biometrics/keys"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.getSessionPublicKeys = (userId) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/biometrics/keys`);
return res;
});
// GET /users/:userId/biometrics/:biometricId
this.getSessionPublicKey = function (userId, biometricId) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/biometrics/").concat(biometricId))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.getSessionPublicKey = (userId, biometricId) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/biometrics/${biometricId}`);
return res;
});
// PATCH /users/:userId/biometrics/:biometricId
this.patchSessionPublicKey = function (userId, biometricId, body) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.patch("/users/".concat(userId, "/biometrics/").concat(biometricId), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.patchSessionPublicKey = (userId, biometricId, body) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.patch(`/users/${userId}/biometrics/${biometricId}`, body);
return res;
});
// GET /biometrics/challenge?email&publicKey
this.getWebChallenge = function (email, publicKey) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/biometrics/challenge?email=".concat(email).concat(publicKey ? "&publicKey=".concat(publicKey) : ''))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.getWebChallenge = (email, publicKey) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/biometrics/challenge?email=${email}${publicKey ? `&publicKey=${publicKey}` : ''}`);
return res;
});
// POST /touch
this.touchSession = function (regenerate) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/touch?regenerate=".concat(!!regenerate))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.touchSession = (regenerate) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/touch?regenerate=${!!regenerate}`);
return res;
});
// POST /biometrics/verify
this.verifyWebChallenge = function (body) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/biometrics/verify", body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.verifyWebChallenge = (body) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/biometrics/verify`, body);
return res;
});
// GET /users/:userId/biometrics/challenge
this.getSessionChallenge = function (userId) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/biometrics/challenge"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.getSessionChallenge = (userId) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/biometrics/challenge`);
return res;
});
// POST /users/:userId/biometrics/verify
this.verifySessionChallenge = function (userId, body) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/biometrics/verify"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.verifySessionChallenge = (userId, body) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/biometrics/verify`, body);
return res;
});
// POST /users/:userId/wallets
this.createWallet = function (userId, body) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/wallets"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); };
this.createWallet = (userId, body) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/wallets`, body);
return res.data;
});
// POST /users/:userId/wallets/:walletId/transactions/send
this.sendTransaction = function (userId, walletId, body) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/wallets/").concat(walletId, "/transactions/send"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.sendTransaction = (userId, walletId, body) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/send`, body);
return res;
});
// functionality changed to only sign transactions and not send them
// POST /users/:userId/wallets/:walletId/transactions/sign
this.signTransaction = function (userId, walletId, body) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/wallets/").concat(walletId, "/transactions/sign"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.signTransaction = (userId, walletId, body) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/transactions/sign`, body);
return res;
});
// POST /users/:userId/wallets/:walletId/refresh
this.refreshKeys = function (userId, walletId) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/wallets/").concat(walletId, "/refresh"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.refreshKeys = (userId, walletId) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/refresh`);
return res;
});
// PATCH /users/:userId/wallets/:walletId
this.updateWallet = function (userId, walletId) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/wallets/").concat(walletId))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.updateWallet = (userId, walletId) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}`);
return res;
});
// GET /users/:userId/wallets
this.getWallets = function (userId) { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/wallets"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.getWallets = (userId) => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/wallets`);
return res;
});
// POST /login
this.login = function (email) { return __awaiter(_this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { email: email };
return [4 /*yield*/, this.baseRequest.post('/login', body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.login = (email) => __awaiter(this, void 0, void 0, function* () {
const body = { email };
const res = yield this.baseRequest.post('/login', body);
return res;
});
// POST /login
this.verifyLogin = function (verificationCode) { return __awaiter(_this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { verificationCode: verificationCode };
return [4 /*yield*/, this.baseRequest.post('/login/verify-email', body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.verifyLogin = (verificationCode) => __awaiter(this, void 0, void 0, function* () {
const body = { verificationCode };
const res = yield this.baseRequest.post('/login/verify-email', body);
return res;
});
// GET /logout
this.logout = function () { return __awaiter(_this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get('/logout')];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.logout = () => __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get('/logout');
return res;
});
// POST /recovery/verification
this.recoveryVerification = function (email, verificationCode) { return __awaiter(_this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { email: email, verificationCode: verificationCode };
return [4 /*yield*/, this.baseRequest.post('/recovery/verification', body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.recoveryVerification = (email, verificationCode) => __awaiter(this, void 0, void 0, function* () {
const body = { email, verificationCode };
const res = yield this.baseRequest.post('/recovery/verification', body);
return res;
});
// POST /recovery
this.recoveryInit = function (email) { return __awaiter(_this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { email: email };
return [4 /*yield*/, this.baseRequest.post('/recovery', body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}); };
this.preSignMessage = function (userId, walletId, tx) { return __awaiter(_this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { message: tx };
return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/wallets/").concat(walletId, "/messages/sign"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res.data];
}
});
}); };
this.recoveryInit = (email) => __awaiter(this, void 0, void 0, function* () {
const body = { email };
const res = yield this.baseRequest.post('/recovery', body);
return res;
});
this.preSignMessage = (userId, walletId, tx) => __awaiter(this, void 0, void 0, function* () {
const body = { message: tx };
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/messages/sign`, body);
return res.data;
});
// TODO remove after this is not optional anymore
var headers = apiKey ? { "X-External-API-Key": apiKey } : undefined;
var axiosConfig = {
const headers = apiKey ? { "X-External-API-Key": apiKey } : undefined;
const axiosConfig = {
baseURL: userManagementHost,
withCredentials: true,
headers: headers,
headers,
};
if (retrieveSessionCookie) {
var defaultTransformRequest = Array.isArray(axios_1.default.defaults.transformRequest) ?
const defaultTransformRequest = Array.isArray(axios_1.default.defaults.transformRequest) ?
axios_1.default.defaults.transformRequest :
[axios_1.default.defaults.transformRequest];
axiosConfig.transformRequest = __spreadArray([
axiosConfig.transformRequest = [
function (data, headers) {

@@ -410,3 +199,3 @@ console.log('user-management-client: transform request');

}
var currentSessionCookie = retrieveSessionCookie();
const currentSessionCookie = retrieveSessionCookie();
if (currentSessionCookie) {

@@ -416,10 +205,12 @@ headers[SESSION_COOKIE_HEADER_NAME] = currentSessionCookie;

return data;
}
], defaultTransformRequest, true);
},
...defaultTransformRequest,
];
}
if (persistSessionCookie) {
var defaultTransformResponse = Array.isArray(axios_1.default.defaults.transformResponse) ?
const defaultTransformResponse = Array.isArray(axios_1.default.defaults.transformResponse) ?
axios_1.default.defaults.transformResponse :
[axios_1.default.defaults.transformResponse];
axiosConfig.transformResponse = __spreadArray(__spreadArray([], defaultTransformResponse, true), [
axiosConfig.transformResponse = [
...defaultTransformResponse,
function (data, headers) {

@@ -434,3 +225,3 @@ console.log('user-management-client: transform response');

},
], false);
];
}

@@ -440,34 +231,27 @@ this.baseRequest = axios_1.default.create(axiosConfig);

axios_1.default.defaults.adapter = function (config) {
return __awaiter(this, void 0, void 0, function () {
var response, resText, resToReturn;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, fetch(config.baseURL + config.url.substring(1), {
method: config.method,
headers: config.headers,
body: config.data,
credentials: config.withCredentials ? 'include' : undefined
})];
case 1:
response = _a.sent();
console.log('fetch response:');
console.log(response);
console.log(JSON.stringify(response));
console.log(JSON.stringify(response.headers));
return [4 /*yield*/, response.text()];
case 2:
resText = _a.sent();
console.log(resText);
console.log(JSON.stringify(resText));
resToReturn = {
data: resText,
status: response.status,
statusText: response.statusText,
headers: response.headers,
config: config,
request: fetch
};
return [2 /*return*/, resToReturn];
}
return __awaiter(this, void 0, void 0, function* () {
const response = yield fetch(config.baseURL + config.url.substring(1), {
method: config.method,
headers: config.headers,
body: config.data,
credentials: config.withCredentials ? 'include' : undefined
});
console.log('fetch response:');
console.log(response);
console.log(JSON.stringify(response.headers.entries()));
for (let [key, value] of response.headers.entries()) {
console.log(key, value);
}
const resText = yield response.text();
console.log(resText);
console.log(JSON.stringify(resText));
const resToReturn = {
data: resText,
status: response.status,
statusText: response.statusText,
headers: response.headers,
config: config,
request: fetch
};
return resToReturn;
});

@@ -479,359 +263,176 @@ };

// POST /users/:userId/wallets/:walletId/key-shares
Client.prototype.uploadKeyshares = function (userId, walletId, encryptedKeyshares) {
return __awaiter(this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { keyShares: encryptedKeyshares };
return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/wallets/").concat(walletId, "/key-shares"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
uploadKeyshares(userId, walletId, encryptedKeyshares) {
return __awaiter(this, void 0, void 0, function* () {
const body = { keyShares: encryptedKeyshares };
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/key-shares`, body);
return res;
});
};
}
// POST /users/:userId/wallets/:walletId/key-shares
Client.prototype.uploadUserKeyShares = function (userId, encryptedKeyshares) {
return __awaiter(this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { keyShares: encryptedKeyshares };
return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/key-shares"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
uploadUserKeyShares(userId, encryptedKeyshares) {
return __awaiter(this, void 0, void 0, function* () {
const body = { keyShares: encryptedKeyshares };
const res = yield this.baseRequest.post(`/users/${userId}/key-shares`, body);
return res;
});
};
}
// GET /users/:userId/wallets/:walletId/key-shares
Client.prototype.getKeyshare = function (userId, walletId, type, encryptor) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/wallets/").concat(walletId, "/key-shares?type=").concat(type).concat(encryptor ? "&encryptor=".concat(encryptor) : ''))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
getKeyshare(userId, walletId, type, encryptor) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/key-shares?type=${type}${encryptor ? `&encryptor=${encryptor}` : ''}`);
return res;
});
};
}
// GET /users/:userId/biometrics/key-shares
Client.prototype.getBiometricKeyshares = function (userId, biometricPublicKey) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/biometrics/key-shares?publicKey=").concat(biometricPublicKey))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
getBiometricKeyshares(userId, biometricPublicKey) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/biometrics/key-shares?publicKey=${biometricPublicKey}`);
return res;
});
};
}
// POST '/users/:userId/temporary-shares',
Client.prototype.uploadTransmissionKeyshares = function (userId, shares) {
return __awaiter(this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { shares: shares };
return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/temporary-shares"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
uploadTransmissionKeyshares(userId, shares) {
return __awaiter(this, void 0, void 0, function* () {
const body = { shares };
const res = yield this.baseRequest.post(`/users/${userId}/temporary-shares`, body);
return res;
});
};
}
// GET /users/:userId/temporary-shares returns { temporaryShares: { userId: string, walletId: string, encryptedShare: string, encryptedKey?: string }[] }
Client.prototype.getTransmissionKeyshares = function (userId, sessionLookupId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/temporary-shares?sessionLookupId=").concat(sessionLookupId))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
getTransmissionKeyshares(userId, sessionLookupId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/temporary-shares?sessionLookupId=${sessionLookupId}`);
return res;
});
};
}
// get /users/:userId/wallets/:walletId/capsule-share
Client.prototype.getCapsuleShare = function (userId, walletId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/wallets/").concat(walletId, "/capsule-share"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
getCapsuleShare(userId, walletId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/wallets/${walletId}/capsule-share`);
return res;
});
};
}
// POST '/users/:userId/resend-verification-code
Client.prototype.resendVerificationCode = function (userId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/resend-verification-code"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
resendVerificationCode(userId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/resend-verification-code`);
return res;
});
};
}
// POST recovery/cancel
Client.prototype.cancelRecoveryAttempt = function (email) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("recovery/cancel", { email: email })];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
cancelRecoveryAttempt(email) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`recovery/cancel`, { email });
return res;
});
};
}
// GET '/2fa/users/:userId/check-status'
Client.prototype.check2FAStatus = function (userId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/2fa/users/".concat(userId, "/check-status"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
check2FAStatus(userId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/2fa/users/${userId}/check-status`);
return res;
});
};
}
// POST '/2fa/users/:userId/enable'
Client.prototype.enable2FA = function (userId, verificationCode) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/2fa/users/".concat(userId, "/enable"), { verificationCode: verificationCode })];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
enable2FA(userId, verificationCode) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/2fa/users/${userId}/enable`, { verificationCode });
return res;
});
};
}
// POST '/2fa/users/:userId/setup'
Client.prototype.setup2FA = function (userId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/2fa/users/".concat(userId, "/setup"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
setup2FA(userId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/2fa/users/${userId}/setup`);
return res;
});
};
}
// POST /recovery/init
Client.prototype.initializeRecovery = function (email) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/recovery/init", { email: email })];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
initializeRecovery(email) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/recovery/init`, { email });
return res;
});
};
}
// POST /recovery/users/:userId/wallets/:walletId/finish
Client.prototype.finalizeRecovery = function (userId, walletId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/recovery/users/".concat(userId, "/wallets/").concat(walletId, "/finish"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
finalizeRecovery(userId, walletId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/recovery/users/${userId}/wallets/${walletId}/finish`);
return res;
});
};
}
// GET /recovery/users/:userId/wallets/:walletId/key-shares
Client.prototype.recoverUserShare = function (userId, walletId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/recovery/users/".concat(userId, "/wallets/").concat(walletId, "/key-shares?type=USER&encryptor=RECOVERY"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
recoverUserShare(userId, walletId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/recovery/users/${userId}/wallets/${walletId}/key-shares?type=USER&encryptor=RECOVERY`);
return res;
});
};
}
// POST /recovery/verify-email
Client.prototype.verifyEmailForRecovery = function (email, verificationCode) {
return __awaiter(this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { email: email, verificationCode: verificationCode };
return [4 /*yield*/, this.baseRequest.post("/recovery/verify-email", body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
verifyEmailForRecovery(email, verificationCode) {
return __awaiter(this, void 0, void 0, function* () {
const body = { email, verificationCode };
const res = yield this.baseRequest.post(`/recovery/verify-email`, body);
return res;
});
};
}
// POST /2fa/verify
Client.prototype.verify2FA = function (email, verificationCode) {
return __awaiter(this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { email: email, verificationCode: verificationCode };
return [4 /*yield*/, this.baseRequest.post('/2fa/verify', body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
verify2FA(email, verificationCode) {
return __awaiter(this, void 0, void 0, function* () {
const body = { email, verificationCode };
const res = yield this.baseRequest.post('/2fa/verify', body);
return res;
});
};
Client.prototype.tempTrasmissionInit = function (message, userId) {
return __awaiter(this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { message: message, userId: userId };
return [4 /*yield*/, this.baseRequest.post('/temporary-transmissions', body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}
tempTrasmissionInit(message, userId) {
return __awaiter(this, void 0, void 0, function* () {
const body = { message, userId };
const res = yield this.baseRequest.post('/temporary-transmissions', body);
return res;
});
};
Client.prototype.tempTrasmission = function (id) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/temporary-transmissions/".concat(id))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}
tempTrasmission(id) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/temporary-transmissions/${id}`);
return res;
});
};
Client.prototype.getPartner = function (partnerId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/partners/".concat(partnerId))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}
getPartner(partnerId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/partners/${partnerId}`);
return res;
});
};
Client.prototype.acceptScopes = function (userId, body) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/scopes/accept"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}
acceptScopes(userId, body) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/scopes/accept`, body);
return res;
});
};
Client.prototype.getPendingTransaction = function (userId, pendingTransactionid) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/pending-transactions/").concat(pendingTransactionid))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}
getPendingTransaction(userId, pendingTransactionid) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/pending-transactions/${pendingTransactionid}`);
return res;
});
};
Client.prototype.acceptPendingTransaction = function (userId, pendingTransactionId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/pending-transactions/").concat(pendingTransactionId, "/accept"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}
acceptPendingTransaction(userId, pendingTransactionId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.post(`/users/${userId}/pending-transactions/${pendingTransactionId}/accept`);
return res;
});
};
Client.prototype.getPolicyPermissions = function (userId, policyId) {
return __awaiter(this, void 0, void 0, function () {
var res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseRequest.get("/users/".concat(userId, "/policies/").concat(policyId, "/permissions"))];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}
getPolicyPermissions(userId, policyId) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield this.baseRequest.get(`/users/${userId}/policies/${policyId}/permissions`);
return res;
});
};
Client.prototype.distributeCapsuleShare = function (userId, walletId, useDKLS) {
return __awaiter(this, void 0, void 0, function () {
var body, res;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
body = { useDKLS: useDKLS };
return [4 /*yield*/, this.baseRequest.post("/users/".concat(userId, "/wallets/").concat(walletId, "/capsule-share/distribute"), body)];
case 1:
res = _a.sent();
return [2 /*return*/, res];
}
});
}
distributeCapsuleShare(userId, walletId, useDKLS) {
return __awaiter(this, void 0, void 0, function* () {
const body = { useDKLS };
const res = yield this.baseRequest.post(`/users/${userId}/wallets/${walletId}/capsule-share/distribute`, body);
return res;
});
};
return Client;
}());
}
}
exports.default = Client;

@@ -838,0 +439,0 @@ // GET /users/:userId/wallets/:walletId/send (NOTE: endpoint not found in server)

{
"name": "@usecapsule/user-management-client",
"version": "0.18.0-dev.2",
"version": "0.18.0-dev.3",
"main": "dist/client.js",

@@ -5,0 +5,0 @@ "types": "dist/client.d.ts",

@@ -5,3 +5,3 @@ {

"declaration": true,
"target": "es5",
"target": "es6",
"lib": [

@@ -8,0 +8,0 @@ "dom",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc