Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@usecapsule/web-sdk

Package Overview
Dependencies
Maintainers
7
Versions
340
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@usecapsule/web-sdk - npm Package Compare versions

Comparing version 1.16.0 to 1.17.0

10

dist/wallet/keygen.d.ts

@@ -13,1 +13,11 @@ import { Ctx } from '@usecapsule/core-sdk';

}>;
export declare function ed25519Keygen(ctx: Ctx, userId: string, sessionCookie?: string, _emailProps?: BackupKitEmailProps): Promise<{
signer: string;
walletId: string;
recoveryShare: string | null;
}>;
export declare function ed25519PreKeygen(ctx: Ctx, email: string, sessionCookie?: string): Promise<{
signer: string;
walletId: string;
recoveryShare: string | null;
}>;

@@ -86,1 +86,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
export function ed25519Keygen(ctx, userId, sessionCookie, _emailProps = {}) {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isKeygenComplete(ctx, userId, res.walletId); }), 15000, 1000);
resolve({
signer: res.signer,
walletId: res.walletId,
recoveryShare: null,
});
worker.terminate();
}));
worker.postMessage({
env: ctx.env,
apiKey: ctx.apiKey,
params: { userId },
functionType: 'ED25519_KEYGEN',
disableWorkers: ctx.disableWorkers,
sessionCookie,
disableWebSockets: ctx.disableWebSockets,
wasmOverride: ctx.wasmOverride,
});
}));
}
export function ed25519PreKeygen(ctx, email, sessionCookie) {
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
const worker = yield setupWorker(ctx, (res) => __awaiter(this, void 0, void 0, function* () {
yield waitUntilTrue(() => __awaiter(this, void 0, void 0, function* () { return isPreKeygenComplete(ctx, email, res.walletId); }), 15000, 1000);
resolve({
signer: res.signer,
walletId: res.walletId,
recoveryShare: null,
});
worker.terminate();
}));
worker.postMessage({
env: ctx.env,
apiKey: ctx.apiKey,
params: { email },
functionType: 'ED25519_PREKEYGEN',
disableWorkers: ctx.disableWorkers,
sessionCookie,
disableWebSockets: ctx.disableWebSockets,
wasmOverride: ctx.wasmOverride,
});
}));
}

1

dist/wallet/signing.d.ts

@@ -5,1 +5,2 @@ import { Ctx, SignatureRes } from '@usecapsule/core-sdk';

export declare function signMessage(ctx: Ctx, userId: string, walletId: string, share: string, message: string, sessionCookie?: string, isDKLS?: boolean): Promise<SignatureRes>;
export declare function ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie: string): Promise<SignatureRes>;

@@ -77,1 +77,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
export function ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
return __awaiter(this, void 0, void 0, function* () {
return yield new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
const worker = yield setupWorker(ctx, (signMessageRes) => __awaiter(this, void 0, void 0, function* () {
resolve(signMessageRes);
worker.terminate();
}));
worker.postMessage({
env: ctx.env,
apiKey: ctx.apiKey,
params: { share, walletId, userId, base64Bytes },
functionType: 'ED25519_SIGN',
disableWorkers: ctx.disableWorkers,
sessionCookie,
disableWebSockets: ctx.disableWebSockets,
wasmOverride: ctx.wasmOverride,
});
}));
});
}

@@ -26,2 +26,11 @@ /// <reference types="node" />

}>;
ed25519Keygen(ctx: Ctx, userId: string, sessionCookie: string, emailProps?: BackupKitEmailProps): Promise<{
signer: string;
walletId: string;
}>;
ed25519PreKeygen(ctx: Ctx, email: string, sessionCookie: string): Promise<{
signer: string;
walletId: string;
}>;
ed25519Sign(ctx: Ctx, userId: string, walletId: string, share: string, base64Bytes: string, sessionCookie: string): Promise<SignatureRes>;
localStorage: LocalStorage;

@@ -28,0 +37,0 @@ sessionStorage: SessionStorage;

import { LocalStorage } from './LocalStorage.js';
import { SessionStorage } from './SessionStorage.js';
import { keygen, preKeygen } from './wallet/keygen.js';
import { signMessage, sendTransaction, signTransaction } from './wallet/signing.js';
import { keygen, preKeygen, ed25519Keygen, ed25519PreKeygen } from './wallet/keygen.js';
import { signMessage, sendTransaction, signTransaction, ed25519Sign } from './wallet/signing.js';
import { getPrivateKey } from './wallet/privateKey.js';

@@ -37,2 +37,11 @@ export class WebUtils {

}
ed25519Keygen(ctx, userId, sessionCookie, emailProps) {
return ed25519Keygen(ctx, userId, sessionCookie, emailProps);
}
ed25519PreKeygen(ctx, email, sessionCookie) {
return ed25519PreKeygen(ctx, email, sessionCookie);
}
ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie) {
return ed25519Sign(ctx, userId, walletId, share, base64Bytes, sessionCookie);
}
openPopup(popupUrl) {

@@ -39,0 +48,0 @@ const popupWindow = window.open(popupUrl, 'popup', 'popup=true,width=400,height=500');

import { Ctx, SignatureRes } from '@usecapsule/core-sdk';
export declare function ed25519Keygen(ctx: Ctx, userId: string): Promise<{
signer: string;
walletId: string;
}>;
export declare function ed25519PreKeygen(ctx: Ctx, email: string): Promise<{
signer: string;
walletId: string;
}>;
export declare function ed25519Sign(ctx: Ctx, share: string, userId: string, walletId: string, base64Bytes: string): Promise<{
signature: string;
}>;
export declare function keygen(ctx: Ctx, userId: string, secretKey: string | null): Promise<{

@@ -3,0 +14,0 @@ signer: string;

@@ -47,2 +47,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
export function ed25519Keygen(ctx, userId) {
return __awaiter(this, void 0, void 0, function* () {
const { walletId, protocolId } = yield ctx.capsuleClient.createWallet(userId, {
scheme: SignatureScheme.ED25519,
});
const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
const newSigner = (yield new Promise((resolve, reject) => global.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
if (err) {
reject(err);
}
resolve(result);
})));
return { signer: newSigner, walletId };
});
}
export function ed25519PreKeygen(ctx, email) {
return __awaiter(this, void 0, void 0, function* () {
const { walletId, protocolId } = yield ctx.capsuleClient.createPregenWallet({ email, scheme: SignatureScheme.ED25519 });
const serverUrl = getBaseMPCNetworkUrl(ctx.env, !ctx.disableWebSockets);
const newSigner = (yield new Promise((resolve, reject) => global.ed25519CreateAccount(serverUrl, walletId, protocolId, (err, result) => {
if (err) {
reject(err);
}
resolve(result);
})));
return { signer: newSigner, walletId };
});
}
export function ed25519Sign(ctx, share, userId, walletId, base64Bytes) {
return __awaiter(this, void 0, void 0, function* () {
const { protocolId } = yield ctx.capsuleClient.preSignMessage(userId, walletId, base64Bytes, SignatureScheme.ED25519);
const base64Sig = (yield new Promise((resolve, reject) => global.ed25519Sign(share, protocolId, base64Bytes, (err, result) => {
if (err) {
reject(err);
}
resolve(result);
})));
return { signature: base64Sig };
});
}
export function keygen(ctx, userId, secretKey) {

@@ -49,0 +89,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -66,2 +66,14 @@ // ANY CHANGES TO THIS FILE REQUIRE A REBUILD OF THE WORKER

}
case 'ED25519_KEYGEN': {
const { userId } = params;
return walletUtils.ed25519Keygen(ctx, userId);
}
case 'ED25519_SIGN': {
const { share, walletId, userId, base64Bytes } = params;
return walletUtils.ed25519Sign(ctx, share, userId, walletId, base64Bytes);
}
case 'ED25519_PREKEYGEN': {
const { email } = params;
return walletUtils.ed25519PreKeygen(ctx, email);
}
default: {

@@ -68,0 +80,0 @@ throw new Error(`functionType: ${functionType} not supported`);

8

package.json
{
"name": "@usecapsule/web-sdk",
"version": "1.16.0",
"version": "1.17.0",
"type": "module",

@@ -11,4 +11,4 @@ "main": "dist/index.js",

"dependencies": {
"@usecapsule/core-sdk": "1.14.0",
"@usecapsule/user-management-client": "1.11.0",
"@usecapsule/core-sdk": "1.15.0",
"@usecapsule/user-management-client": "1.12.0",
"assert": "^2.1.0",

@@ -36,3 +36,3 @@ "base64url": "3.0.1",

],
"gitHead": "54583552fc3189bc0a05118322188971ad79fc7a"
"gitHead": "41dd49a5be1ebb9a723a52a40b2b65c15acc2379"
}
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