@lit-protocol/wrapped-keys
Advanced tools
Comparing version 6.5.2 to 6.5.3-alpha.0
@@ -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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
25
31
98946
83
1432
1
+ Added@lit-protocol/bls-sdk@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/constants@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/crypto@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/ecdsa-sdk@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/encryption@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/logger@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/misc@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/nacl@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/sev-snp-utils-sdk@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/types@6.5.3-alpha.0(transitive)
+ Added@lit-protocol/uint8arrays@6.5.3-alpha.0(transitive)
- Removed@lit-protocol/accs-schemas@^0.0.12
- Removedbs58@^5.0.0
- Removedtweetnacl@^1.0.3
- Removed@lit-protocol/accs-schemas@0.0.12(transitive)
- Removed@lit-protocol/bls-sdk@6.5.2(transitive)
- Removed@lit-protocol/constants@6.5.2(transitive)
- Removed@lit-protocol/crypto@6.5.2(transitive)
- Removed@lit-protocol/ecdsa-sdk@6.5.2(transitive)
- Removed@lit-protocol/encryption@6.5.2(transitive)
- Removed@lit-protocol/logger@6.5.2(transitive)
- Removed@lit-protocol/misc@6.5.2(transitive)
- Removed@lit-protocol/nacl@6.5.2(transitive)
- Removed@lit-protocol/sev-snp-utils-sdk@6.5.2(transitive)
- Removed@lit-protocol/types@6.5.2(transitive)
- Removed@lit-protocol/uint8arrays@6.5.2(transitive)
- Removedbase-x@4.0.0(transitive)
- Removedbs58@5.0.0(transitive)
- Removedtweetnacl@1.0.3(transitive)