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

@usecapsule/core-sdk

Package Overview
Dependencies
Maintainers
6
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@usecapsule/core-sdk - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

41

dist/cjs/CoreCapsule.js

@@ -140,2 +140,9 @@ "use strict";

opts = {};
this.emailPrimaryColor = opts.emailPrimaryColor;
this.emailTheme = opts.emailTheme;
this.homepageUrl = opts.homepageUrl;
this.supportUrl = opts.supportUrl;
this.xUrl = opts.xUrl;
this.githubUrl = opts.githubUrl;
this.linkedinUrl = opts.linkedinUrl;
this.portalBackgroundColor = opts.portalBackgroundColor;

@@ -185,2 +192,24 @@ this.portalPrimaryButtonColor = opts.portalPrimaryButtonColor;

}
getVerificationEmailProps() {
return {
brandColor: this.emailPrimaryColor,
theme: this.emailTheme,
supportUrl: this.supportUrl,
homepageUrl: this.homepageUrl,
xUrl: this.xUrl,
githubUrl: this.githubUrl,
linkedinUrl: this.linkedinUrl,
};
}
getBackupKitEmailProps() {
return {
brandColor: this.emailPrimaryColor,
theme: this.emailTheme,
homepageUrl: this.homepageUrl,
xUrl: this.xUrl,
linkedinUrl: this.linkedinUrl,
githubUrl: this.githubUrl,
supportUrl: this.supportUrl,
};
}
/**

@@ -378,5 +407,3 @@ * Initialize storage relating to a `CoreCapsule` instance.

yield this.setEmail(email);
const { userId } = yield this.ctx.capsuleClient.createUser({
email: this.email,
});
const { userId } = yield this.ctx.capsuleClient.createUser(Object.assign({ email: this.email }, this.getVerificationEmailProps()));
yield this.setUserId(userId);

@@ -452,3 +479,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
yield this.ctx.capsuleClient.resendVerificationCode(this.userId);
yield this.ctx.capsuleClient.resendVerificationCode(Object.assign({ userId: this.userId }, this.getVerificationEmailProps()));
});

@@ -671,3 +698,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
const recoveryShare = yield (0, shareDistribution_1.distributeNewShare)(this.ctx, this.userId, walletId, userShare);
const recoveryShare = yield (0, shareDistribution_1.distributeNewShare)(this.ctx, this.userId, walletId, userShare, false, this.getBackupKitEmailProps());
return recoveryShare;

@@ -711,3 +738,3 @@ });

this.requireApiKey();
const { signer, walletId } = yield this.platformUtils.keygen(this.ctx, this.userId, null, this.retrieveSessionCookie());
const { signer, walletId } = yield this.platformUtils.keygen(this.ctx, this.userId, null, this.retrieveSessionCookie(), this.getBackupKitEmailProps());
this.wallets[walletId] = {

@@ -721,3 +748,3 @@ id: walletId,

if (!skipDistribute) {
recoveryShare = yield (0, shareDistribution_1.distributeNewShare)(this.ctx, this.userId, walletId, signer);
recoveryShare = yield (0, shareDistribution_1.distributeNewShare)(this.ctx, this.userId, walletId, signer, false, this.getBackupKitEmailProps());
}

@@ -724,0 +751,0 @@ yield this.setWallets(this.wallets);

4

dist/cjs/shares/recovery.js

@@ -15,3 +15,3 @@ "use strict";

const KeyContainer_1 = require("./KeyContainer");
function sendRecoveryForShare(ctx, userId, walletId, otherEncryptedShares, userSigner, ignoreRedistributingBackupEncryptedShare = false) {
function sendRecoveryForShare(ctx, userId, walletId, otherEncryptedShares, userSigner, ignoreRedistributingBackupEncryptedShare = false, emailProps) {
return __awaiter(this, void 0, void 0, function* () {

@@ -32,3 +32,3 @@ const recoveryPrivateKeyContainer = new KeyContainer_1.KeyContainer(walletId, '', '');

if (!ignoreRedistributingBackupEncryptedShare) {
yield ctx.capsuleClient.distributeCapsuleShare(userId, walletId, ctx.useDKLS);
yield ctx.capsuleClient.distributeCapsuleShare(Object.assign({ userId, walletId, useDKLS: ctx.useDKLS }, emailProps));
}

@@ -35,0 +35,0 @@ return JSON.stringify(recoveryPrivateKeyContainer);

@@ -17,3 +17,3 @@ "use strict";

// function to call on new user share to perform all necessary distribution
function distributeNewShare(ctx, userId, walletId, userShare, ignoreRedistributingBackupEncryptedShare = false) {
function distributeNewShare(ctx, userId, walletId, userShare, ignoreRedistributingBackupEncryptedShare = false, emailProps) {
return __awaiter(this, void 0, void 0, function* () {

@@ -36,5 +36,5 @@ const publicKeysRes = yield ctx.capsuleClient.getSessionPublicKeys(userId);

.filter(Boolean);
return yield (0, recovery_1.sendRecoveryForShare)(ctx, userId, walletId, biometricEncryptedShares, userShare, ignoreRedistributingBackupEncryptedShare);
return yield (0, recovery_1.sendRecoveryForShare)(ctx, userId, walletId, biometricEncryptedShares, userShare, ignoreRedistributingBackupEncryptedShare, emailProps);
});
}
exports.distributeNewShare = distributeNewShare;

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

opts = {};
this.emailPrimaryColor = opts.emailPrimaryColor;
this.emailTheme = opts.emailTheme;
this.homepageUrl = opts.homepageUrl;
this.supportUrl = opts.supportUrl;
this.xUrl = opts.xUrl;
this.githubUrl = opts.githubUrl;
this.linkedinUrl = opts.linkedinUrl;
this.portalBackgroundColor = opts.portalBackgroundColor;

@@ -159,2 +166,24 @@ this.portalPrimaryButtonColor = opts.portalPrimaryButtonColor;

}
getVerificationEmailProps() {
return {
brandColor: this.emailPrimaryColor,
theme: this.emailTheme,
supportUrl: this.supportUrl,
homepageUrl: this.homepageUrl,
xUrl: this.xUrl,
githubUrl: this.githubUrl,
linkedinUrl: this.linkedinUrl,
};
}
getBackupKitEmailProps() {
return {
brandColor: this.emailPrimaryColor,
theme: this.emailTheme,
homepageUrl: this.homepageUrl,
xUrl: this.xUrl,
linkedinUrl: this.linkedinUrl,
githubUrl: this.githubUrl,
supportUrl: this.supportUrl,
};
}
/**

@@ -352,5 +381,3 @@ * Initialize storage relating to a `CoreCapsule` instance.

yield this.setEmail(email);
const { userId } = yield this.ctx.capsuleClient.createUser({
email: this.email,
});
const { userId } = yield this.ctx.capsuleClient.createUser(Object.assign({ email: this.email }, this.getVerificationEmailProps()));
yield this.setUserId(userId);

@@ -426,3 +453,3 @@ });

return __awaiter(this, void 0, void 0, function* () {
yield this.ctx.capsuleClient.resendVerificationCode(this.userId);
yield this.ctx.capsuleClient.resendVerificationCode(Object.assign({ userId: this.userId }, this.getVerificationEmailProps()));
});

@@ -645,3 +672,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
const recoveryShare = yield distributeNewShare(this.ctx, this.userId, walletId, userShare);
const recoveryShare = yield distributeNewShare(this.ctx, this.userId, walletId, userShare, false, this.getBackupKitEmailProps());
return recoveryShare;

@@ -685,3 +712,3 @@ });

this.requireApiKey();
const { signer, walletId } = yield this.platformUtils.keygen(this.ctx, this.userId, null, this.retrieveSessionCookie());
const { signer, walletId } = yield this.platformUtils.keygen(this.ctx, this.userId, null, this.retrieveSessionCookie(), this.getBackupKitEmailProps());
this.wallets[walletId] = {

@@ -695,3 +722,3 @@ id: walletId,

if (!skipDistribute) {
recoveryShare = yield distributeNewShare(this.ctx, this.userId, walletId, signer);
recoveryShare = yield distributeNewShare(this.ctx, this.userId, walletId, signer, false, this.getBackupKitEmailProps());
}

@@ -698,0 +725,0 @@ yield this.setWallets(this.wallets);

@@ -12,3 +12,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { KeyContainer } from './KeyContainer';
export function sendRecoveryForShare(ctx, userId, walletId, otherEncryptedShares, userSigner, ignoreRedistributingBackupEncryptedShare = false) {
export function sendRecoveryForShare(ctx, userId, walletId, otherEncryptedShares, userSigner, ignoreRedistributingBackupEncryptedShare = false, emailProps) {
return __awaiter(this, void 0, void 0, function* () {

@@ -29,3 +29,3 @@ const recoveryPrivateKeyContainer = new KeyContainer(walletId, '', '');

if (!ignoreRedistributingBackupEncryptedShare) {
yield ctx.capsuleClient.distributeCapsuleShare(userId, walletId, ctx.useDKLS);
yield ctx.capsuleClient.distributeCapsuleShare(Object.assign({ userId, walletId, useDKLS: ctx.useDKLS }, emailProps));
}

@@ -32,0 +32,0 @@ return JSON.stringify(recoveryPrivateKeyContainer);

@@ -14,3 +14,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

// function to call on new user share to perform all necessary distribution
export function distributeNewShare(ctx, userId, walletId, userShare, ignoreRedistributingBackupEncryptedShare = false) {
export function distributeNewShare(ctx, userId, walletId, userShare, ignoreRedistributingBackupEncryptedShare = false, emailProps) {
return __awaiter(this, void 0, void 0, function* () {

@@ -33,4 +33,4 @@ const publicKeysRes = yield ctx.capsuleClient.getSessionPublicKeys(userId);

.filter(Boolean);
return yield sendRecoveryForShare(ctx, userId, walletId, biometricEncryptedShares, userShare, ignoreRedistributingBackupEncryptedShare);
return yield sendRecoveryForShare(ctx, userId, walletId, biometricEncryptedShares, userShare, ignoreRedistributingBackupEncryptedShare, emailProps);
});
}

@@ -0,1 +1,2 @@

import { EmailTheme } from '@usecapsule/user-management-client';
import { pki } from 'node-forge';

@@ -42,2 +43,9 @@ import { Ctx } from './definitions';

wasmOverride?: ArrayBuffer;
emailTheme?: EmailTheme;
emailPrimaryColor?: string;
linkedinUrl?: string;
githubUrl?: string;
xUrl?: string;
supportUrl?: string;
homepageUrl?: string;
}

@@ -52,2 +60,32 @@ export declare const PREFIX = "@CAPSULE/";

/**
* Base theme for the emails sent from this Capsule instance.
* @default - dark
*/
emailTheme?: EmailTheme;
/**
* Hex color to use as the primary color in the emails.
* @default - #FE452B
*/
emailPrimaryColor?: string;
/**
* Linkedin URL to link to in the emails. Should be a secure URL string starting with https://www.linkedin.com/company/.
*/
linkedinUrl?: string;
/**
* Github URL to link to in the emails. Should be a secure URL string starting with https://github.com/.
*/
githubUrl?: string;
/**
* X (Twitter) URL to link to in the emails. Should be a secure URL string starting with https://twitter.com/.
*/
xUrl?: string;
/**
* Support URL to link to in the emails. This can be a secure https URL or a mailto: string. Will default to using the stored application URL is nothing is provided here.
*/
supportUrl?: string;
/**
* URL for your home landing page. Should be a secure URL string starting with https://.
*/
homepageUrl?: string;
/**
* Encryption key pair generated from loginEncryptionKey.

@@ -97,2 +135,4 @@ */

constructor(env: Environment, apiKey?: string, opts?: ConstructorOpts);
private getVerificationEmailProps;
private getBackupKitEmailProps;
/**

@@ -99,0 +139,0 @@ * Initialize storage relating to a `CoreCapsule` instance.

/// <reference types="node" />
import { BackupKitEmailProps } from '@usecapsule/user-management-client';
import { Ctx } from './definitions';

@@ -7,3 +8,3 @@ import { SignatureRes } from './types/walletTypes';

keygen(ctx: Ctx, userId: string, secretKey: string | null, // should be acceptable as null in RN as we don't pre-gen them
sessionCookie: string): Promise<{
sessionCookie: string, emailProps?: BackupKitEmailProps): Promise<{
signer: string;

@@ -10,0 +11,0 @@ walletId: string;

@@ -1,3 +0,3 @@

import { encryptedKeyshare } from '@usecapsule/user-management-client';
import { BackupKitEmailProps, encryptedKeyshare } from '@usecapsule/user-management-client';
import { Ctx } from '../definitions';
export declare function sendRecoveryForShare(ctx: Ctx, userId: string, walletId: string, otherEncryptedShares: encryptedKeyshare[], userSigner: string, ignoreRedistributingBackupEncryptedShare?: boolean): Promise<string>;
export declare function sendRecoveryForShare(ctx: Ctx, userId: string, walletId: string, otherEncryptedShares: encryptedKeyshare[], userSigner: string, ignoreRedistributingBackupEncryptedShare: boolean, emailProps: BackupKitEmailProps): Promise<string>;

@@ -0,2 +1,3 @@

import { BackupKitEmailProps } from '@usecapsule/user-management-client';
import { Ctx } from '../definitions';
export declare function distributeNewShare(ctx: Ctx, userId: string, walletId: string, userShare: string, ignoreRedistributingBackupEncryptedShare?: boolean): Promise<string>;
export declare function distributeNewShare(ctx: Ctx, userId: string, walletId: string, userShare: string, ignoreRedistributingBackupEncryptedShare: boolean, emailProps: BackupKitEmailProps): Promise<string>;
{
"name": "@usecapsule/core-sdk",
"version": "0.4.0",
"version": "0.5.0",
"main": "dist/cjs/index.js",

@@ -11,3 +11,3 @@ "module": "dist/esm/index.js",

"@celo/utils": "^3.2.0",
"@usecapsule/user-management-client": "0.23.0",
"@usecapsule/user-management-client": "^0.25.0",
"base64url": "^3.0.1",

@@ -38,3 +38,3 @@ "buffer": "6.0.3",

},
"gitHead": "071e4bd9069e8cfce731be3b2b5caa470b1fbbba"
"gitHead": "108a2ae5318fa6b3964ff07994df4fa9d377b50c"
}
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