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

@lit-protocol/wrapped-keys

Package Overview
Dependencies
Maintainers
0
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lit-protocol/wrapped-keys - npm Package Compare versions

Comparing version 6.5.2 to 6.5.3-alpha.0

src/lib/lit-actions-client/code-repository.d.ts

31

package.json

@@ -26,7 +26,3 @@ {

},
"version": "6.5.2",
"scripts": {
"bundle": "yarn node ./esbuild.config.js",
"build-bc": "sh ./build-bc.sh"
},
"version": "6.5.3-alpha.0",
"dependencies": {

@@ -36,6 +32,4 @@ "@ethersproject/abstract-provider": "5.7.0",

"@ethersproject/providers": "5.7.2",
"@lit-protocol/accs-schemas": "^0.0.12",
"@lit-protocol/contracts": "^0.0.63",
"ajv": "^8.12.0",
"bs58": "^5.0.0",
"cross-fetch": "3.1.4",

@@ -47,16 +41,15 @@ "ethers": "^5.7.1",

"siwe": "^2.0.5",
"tweetnacl": "^1.0.3",
"uint8arrays": "^4.0.3",
"util": "0.12.5",
"@lit-protocol/bls-sdk": "6.5.2",
"@lit-protocol/constants": "6.5.2",
"@lit-protocol/crypto": "6.5.2",
"@lit-protocol/ecdsa-sdk": "6.5.2",
"@lit-protocol/encryption": "6.5.2",
"@lit-protocol/logger": "6.5.2",
"@lit-protocol/misc": "6.5.2",
"@lit-protocol/nacl": "6.5.2",
"@lit-protocol/sev-snp-utils-sdk": "6.5.2",
"@lit-protocol/types": "6.5.2",
"@lit-protocol/uint8arrays": "6.5.2",
"@lit-protocol/bls-sdk": "6.5.3-alpha.0",
"@lit-protocol/constants": "6.5.3-alpha.0",
"@lit-protocol/crypto": "6.5.3-alpha.0",
"@lit-protocol/ecdsa-sdk": "6.5.3-alpha.0",
"@lit-protocol/encryption": "6.5.3-alpha.0",
"@lit-protocol/logger": "6.5.3-alpha.0",
"@lit-protocol/misc": "6.5.3-alpha.0",
"@lit-protocol/nacl": "6.5.3-alpha.0",
"@lit-protocol/sev-snp-utils-sdk": "6.5.3-alpha.0",
"@lit-protocol/types": "6.5.3-alpha.0",
"@lit-protocol/uint8arrays": "6.5.3-alpha.0",
"tslib": "1.14.1"

@@ -63,0 +56,0 @@ },

@@ -9,16 +9,23 @@ # Quick Start

yarn add @lit-protocol/wrapped-keys
yarn add @lit-protocol/wrapped-keys-bc # version with lit actions code in the bundle
```
### Vanilla JS (UMD)
### Lit Actions Code
```js
<script src="https://cdn.jsdelivr.net/npm/@lit-protocol/wrapped-keys-vanilla/wrapped-keys.js"></script>
<script>
console.log(LitJsSdk_wrappedKeys);
</script>
```
By default, this package uses IPFS CIDs to indicate the Lit Actions involved, which tells LIT nodes to fetch our internally managed and IPFS-published LIT action source code from IPFS internally, when they receive requests from your users.
### Lit Actions Code
This behaviour can be modified by calling `config.setLitActionsCode({ litActionRepository })` and providing your own source code for LIT actions, which allows you to either embed your LIT action source code into your app bundle or even fetch it dynamically during app load.
This package outputs two bundles. The light-one one that uses IPFS CIDs to indicate the Lit Actions involved and another one that includes their code and sends that to the nodes instead of the CID.
When setting an explicit Lit Action source code repository, Lit Action source code will be sent to the LIT nodes in each request from your users, instead of relying on the nodes fetching the code from IPFS.
This can provide performance improvements in some circumstances due to the variable nature of IPFS performance, but with an added overhead in bandwidth used for each request your users make, bundle size and/or app load time depending on your use case.
To use LIT-provided Lit Actions and bundle their source code into your app, use `@lit-protocol/wrapped-keys-lit-actions` or define your own LIT action source code dictionary,
Example using LIT-provided action source code:
```javascript
import { litActionRepository } from '@lit-protocol/wrapped-keys-lit-actions';
import { config, api } from '@lit-protocol/wrapped-keys';
config.setLitActionsCode({ litActionRepository });
```
import { signMessageWithEncryptedKey, getEncryptedKey, exportPrivateKey, generatePrivateKey, importPrivateKey, signTransactionWithEncryptedKey, storeEncryptedKey, listEncryptedKeyMetadata } from './lib/api';
import { setLitActionsCode } from './lib/lit-actions-client/code-repository';
import { LitActionCodeRepository, LitActionCodeRepositoryEntry } from './lib/lit-actions-client/types';
import type { SupportedNetworks } from './lib/service-client/types';

@@ -22,2 +24,5 @@ import type { SignMessageWithEncryptedKeyParams, GetEncryptedKeyDataParams, ExportPrivateKeyParams, GeneratePrivateKeyParams, ImportPrivateKeyParams, SignTransactionWithEncryptedKeyParams, ExportPrivateKeyResult, GeneratePrivateKeyResult, EthereumLitTransaction, SerializedTransaction, BaseApiParams, ApiParamsSupportedNetworks, SignTransactionParams, SignTransactionParamsSupportedEvm, SignTransactionParamsSupportedSolana, StoreEncryptedKeyParams, StoredKeyData, StoredKeyMetadata, ListEncryptedKeyMetadataParams, StoreEncryptedKeyResult, ImportPrivateKeyResult } from './lib/types';

};
export { ApiParamsSupportedNetworks, BaseApiParams, EthereumLitTransaction, ExportPrivateKeyParams, ExportPrivateKeyResult, GetEncryptedKeyDataParams, GeneratePrivateKeyParams, GeneratePrivateKeyResult, ImportPrivateKeyParams, ImportPrivateKeyResult, ListEncryptedKeyMetadataParams, SerializedTransaction, SignTransactionParams, SignTransactionParamsSupportedEvm, SignTransactionParamsSupportedSolana, SignMessageWithEncryptedKeyParams, SignTransactionWithEncryptedKeyParams, StoreEncryptedKeyParams, StoreEncryptedKeyResult, StoredKeyData, StoredKeyMetadata, SupportedNetworks, };
export declare const config: {
setLitActionsCode: typeof setLitActionsCode;
};
export { ApiParamsSupportedNetworks, BaseApiParams, EthereumLitTransaction, ExportPrivateKeyParams, ExportPrivateKeyResult, GetEncryptedKeyDataParams, GeneratePrivateKeyParams, GeneratePrivateKeyResult, ImportPrivateKeyParams, ImportPrivateKeyResult, ListEncryptedKeyMetadataParams, LitActionCodeRepository, LitActionCodeRepositoryEntry, SerializedTransaction, SignTransactionParams, SignTransactionParamsSupportedEvm, SignTransactionParamsSupportedSolana, SignMessageWithEncryptedKeyParams, SignTransactionWithEncryptedKeyParams, StoreEncryptedKeyParams, StoreEncryptedKeyResult, StoredKeyData, StoredKeyMetadata, SupportedNetworks, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.api = exports.constants = void 0;
exports.config = exports.api = exports.constants = void 0;
const api_1 = require("./lib/api");
const constants_1 = require("./lib/constants");
const code_repository_1 = require("./lib/lit-actions-client/code-repository");
exports.constants = {

@@ -24,2 +25,5 @@ CHAIN_ETHEREUM: constants_1.CHAIN_ETHEREUM,

};
exports.config = {
setLitActionsCode: code_repository_1.setLitActionsCode,
};
//# sourceMappingURL=index.js.map

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

import { LitActionRepository, LitCidRepository } from './types';
import { LitCidRepository } from './types';
declare const LIT_ACTION_CID_REPOSITORY: LitCidRepository;
declare const LIT_ACTION_CODE_REPOSITORY: LitActionRepository;
export { LIT_ACTION_CODE_REPOSITORY, LIT_ACTION_CID_REPOSITORY };
export { LIT_ACTION_CID_REPOSITORY };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LIT_ACTION_CID_REPOSITORY = exports.LIT_ACTION_CODE_REPOSITORY = void 0;
const exportPrivateKey = require("../generated/litActions/common/exportPrivateKey");
const generateEncryptedEthereumPrivateKey = require("../generated/litActions/ethereum/generateEncryptedEthereumPrivateKey");
const signMessageWithEthereumEncryptedKey = require("../generated/litActions/ethereum/signMessageWithEthereumEncryptedKey");
const signTransactionWithEthereumEncryptedKey = require("../generated/litActions/ethereum/signTransactionWithEthereumEncryptedKey");
const generateEncryptedSolanaPrivateKey = require("../generated/litActions/solana/generateEncryptedSolanaPrivateKey");
const signMessageWithSolanaEncryptedKey = require("../generated/litActions/solana/signMessageWithSolanaEncryptedKey");
const signTransactionWithSolanaEncryptedKey = require("../generated/litActions/solana/signTransactionWithSolanaEncryptedKey");
exports.LIT_ACTION_CID_REPOSITORY = void 0;
const LIT_ACTION_CID_REPOSITORY = Object.freeze({

@@ -30,21 +23,2 @@ signTransaction: Object.freeze({

exports.LIT_ACTION_CID_REPOSITORY = LIT_ACTION_CID_REPOSITORY;
const LIT_ACTION_CODE_REPOSITORY = Object.freeze({
signTransaction: Object.freeze({
evm: signTransactionWithEthereumEncryptedKey.code,
solana: signTransactionWithSolanaEncryptedKey.code,
}),
signMessage: Object.freeze({
evm: signMessageWithEthereumEncryptedKey.code,
solana: signMessageWithSolanaEncryptedKey.code,
}),
generateEncryptedKey: Object.freeze({
evm: generateEncryptedEthereumPrivateKey.code,
solana: generateEncryptedSolanaPrivateKey.code,
}),
exportPrivateKey: Object.freeze({
evm: exportPrivateKey.code,
solana: exportPrivateKey.code,
}),
});
exports.LIT_ACTION_CODE_REPOSITORY = LIT_ACTION_CODE_REPOSITORY;
//# sourceMappingURL=constants.js.map

@@ -5,3 +5,19 @@ import { Network } from '../types';

export declare type LitCidRepository = Readonly<Record<LitActionType, LitCidRepositoryEntry>>;
export declare type LitActionRepositoryEntry = Readonly<Record<Network, string>>;
export declare type LitActionRepository = Readonly<Record<LitActionType, LitActionRepositoryEntry>>;
/**
* A type that represents an entry in a Lit Action Code repository.
*
* LitActionCodeRepositoryEntry is a record that maps a Network (evm, solana) to a string that is valid LIT action source code
*
* @typedef {Record<Network, string>} LitActionCodeRepositoryEntry
*/
export declare type LitActionCodeRepositoryEntry = Record<Network, string>;
export declare type LitActionCodeRepositoryEntryInput = Partial<LitActionCodeRepositoryEntry>;
/**
* @typedef {Record<LitActionType, LitActionCodeRepositoryEntry>} LitActionCodeRepository
* @property {LitActionCodeRepositoryEntry} signTransaction - Ethereum and Solana transaction signing actions.
* @property {LitActionCodeRepositoryEntry} signMessage - Ethereum and Solana message signing actions.
* @property {LitActionCodeRepositoryEntry} generateEncryptedKey - Ethereum and Solana encrypted key generation actions.
* @property {LitActionCodeRepositoryEntry} exportPrivateKey - Ethereum and Solana private key export actions.
*/
export declare type LitActionCodeRepository = Readonly<Record<LitActionType, LitActionCodeRepositoryEntry>>;
export declare type LitActionCodeRepositoryInput = Partial<Record<LitActionType, LitActionCodeRepositoryEntryInput>>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLitActionCodeOrCid = exports.getLitActionCode = exports.getLitActionCid = exports.postLitActionValidation = void 0;
const code_repository_1 = require("./code-repository");
const constants_1 = require("./constants");

@@ -36,2 +37,4 @@ /**

function getLitActionCid(network, actionType) {
// We already have guarantees that `actionType` is valid; it is not user provided and type-safe
assertNetworkIsValid(network);
return constants_1.LIT_ACTION_CID_REPOSITORY[actionType][network];

@@ -41,9 +44,15 @@ }

function getLitActionCode(network, actionType) {
const litActionCode = constants_1.LIT_ACTION_CODE_REPOSITORY[actionType][network];
if (!litActionCode) {
throw new Error(`Could not find Lit Action code for action type: ${actionType}`);
// We already have guarantees that `actionType` is valid; it is not user provided and type-safe
assertNetworkIsValid(network);
// No fuzzy validation needed here, because `setLitActionsCode()` validates its input
return code_repository_1.litActionCodeRepository[actionType][network];
}
exports.getLitActionCode = getLitActionCode;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function assertNetworkIsValid(network) {
const validNetworks = ['evm', 'solana'];
if (!validNetworks.includes(network)) {
throw new Error(`Invalid network: ${network}. Must be one of ${validNetworks.join(', ')}.`);
}
return litActionCode;
}
exports.getLitActionCode = getLitActionCode;
/**

@@ -57,17 +66,10 @@ * Fetch the Lit action code or its IPFS CID for a given network and action type.

function getLitActionCodeOrCid(network, actionType) {
let litActionCode;
let litActionIpfsCid;
try {
litActionCode = getLitActionCode(network, actionType);
// Default state is that litActionCode will be falsy, unless someone has injected to it using `setLitActionsCode();
const litActionCode = getLitActionCode(network, actionType);
if (litActionCode) {
return { litActionCode };
}
catch (e) {
console.warn(`Missing bundled code or could not get it for action type: ${actionType} and network: ${network}. Using IPFS CID instead.`, e);
litActionIpfsCid = getLitActionCid(network, actionType);
}
if (!litActionCode && !litActionIpfsCid) {
throw new Error(`Could not get Lit Action code nor IPFS CID for action type: ${actionType} and network: ${network}`);
}
return { litActionCode, litActionIpfsCid };
return { litActionIpfsCid: getLitActionCid(network, actionType) };
}
exports.getLitActionCodeOrCid = getLitActionCodeOrCid;
//# sourceMappingURL=utils.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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