Socket
Socket
Sign inDemoInstall

@lit-protocol/misc

Package Overview
Dependencies
Maintainers
7
Versions
487
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lit-protocol/misc - npm Package Compare versions

Comparing version 6.7.0 to 7.0.0-alpha.0

src/lib/addresses.d.ts

33

package.json

@@ -16,28 +16,31 @@ {

"type": "commonjs",
"publishConfig": {
"access": "public",
"directory": "../../dist/packages/misc"
},
"gitHead": "0d7334c2c55f448e91fe32f29edc5db8f5e09e4b",
"tags": [
"universal"
],
"version": "7.0.0-alpha.0",
"dependencies": {
"@ethersproject/abstract-provider": "5.7.0",
"@ethersproject/contracts": "5.7.0",
"@ethersproject/providers": "5.7.2",
"@ethersproject/providers": "^5.7.2",
"@lit-protocol/accs-schemas": "^0.0.12",
"@lit-protocol/contracts": "^0.0.63",
"@openagenda/verror": "^3.1.4",
"ajv": "^8.12.0",
"bech32": "^2.0.0",
"bs58": "^5.0.0",
"depd": "^2.0.0",
"ethers": "^5.7.1",
"jszip": "^3.10.1",
"siwe": "^2.0.5",
"siwe": "^2.3.2",
"util": "0.12.5",
"@lit-protocol/constants": "6.7.0",
"@lit-protocol/logger": "6.7.0",
"@lit-protocol/types": "6.7.0",
"@lit-protocol/constants": "7.0.0-alpha.0",
"@lit-protocol/logger": "7.0.0-alpha.0",
"@lit-protocol/types": "7.0.0-alpha.0",
"tslib": "1.14.1"
},
"publishConfig": {
"access": "public",
"directory": "../../dist/packages/misc"
},
"gitHead": "0d7334c2c55f448e91fe32f29edc5db8f5e09e4b",
"tags": [
"universal"
],
"version": "6.7.0",
"main": "./src/index.js"
}

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

export * from './lib/addresses';
export * from './lib/misc';
export * from './lib/params-validators';
export * from './lib/utils';
export { validateSessionSig, validateSessionSigs, } from './lib/helper/session-sigs-validator';

@@ -5,3 +5,6 @@ "use strict";

const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./lib/addresses"), exports);
tslib_1.__exportStar(require("./lib/misc"), exports);
tslib_1.__exportStar(require("./lib/params-validators"), exports);
tslib_1.__exportStar(require("./lib/utils"), exports);
var session_sigs_validator_1 = require("./lib/helper/session-sigs-validator");

@@ -8,0 +11,0 @@ Object.defineProperty(exports, "validateSessionSig", { enumerable: true, get: function () { return session_sigs_validator_1.validateSessionSig; } });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateSessionSigs = exports.validateSessionSig = void 0;
exports.validateSessionSig = validateSessionSig;
exports.validateSessionSigs = validateSessionSigs;
// Function to parse a signedMessage string into an object

@@ -144,3 +145,2 @@ function parseSignedMessage(signedMessage) {

}
exports.validateSessionSig = validateSessionSig;
/**

@@ -165,3 +165,2 @@ * Validates the session signatures.

}
exports.validateSessionSigs = validateSessionSigs;
//# sourceMappingURL=session-sigs-validator.js.map

@@ -1,5 +0,4 @@

import { ILitError, LIT_NETWORK_VALUES } from '@lit-protocol/constants';
import { Chain, AuthSig, NodeClientErrorV0, NodeClientErrorV1, MintCallback, RelayClaimProcessor } from '@lit-protocol/types';
import { LogLevel } from '@lit-protocol/logger';
import { JSONSchemaType } from 'ajv';
import { LIT_NETWORK_VALUES, LOG_LEVEL_VALUES } from '@lit-protocol/constants';
import { Chain, AuthSig, MintCallback, RelayClaimProcessor } from '@lit-protocol/types';
/**

@@ -20,25 +19,4 @@ *

*/
export declare const mostCommonString: (arr: Array<any>) => any;
export declare const findMostCommonResponse: (responses: Array<object>) => object;
export declare const throwError: (e: NodeClientErrorV0 | NodeClientErrorV1) => never;
/**
*
* Standardized way to throw error in Lit Protocol projects
*
* @deprecated use throwErrorV1
* @param { ILitError }
* @property { string } message
* @property { string } name
* @property { string } errorCode
*/
export declare const throwErrorV0: ({ message, name, errorCode, error, }: ILitError) => never;
/**
*
* Standardized way to throw error in Lit Protocol projects
*
*/
export declare const throwErrorV1: ({ errorKind, details, status, message, errorCode, requestId, }: NodeClientErrorV1) => never;
export declare const throwGenericError: (e: any) => never;
export declare const isNodeClientErrorV1: (nodeError: NodeClientErrorV0 | NodeClientErrorV1) => nodeError is NodeClientErrorV1;
export declare const isNodeClientErrorV0: (nodeError: NodeClientErrorV0 | NodeClientErrorV1) => nodeError is NodeClientErrorV0;
export declare const mostCommonString: <T>(arr: T[]) => T | undefined;
export declare const findMostCommonResponse: (responses: object[]) => object;
declare global {

@@ -51,4 +29,4 @@ var litConfig: any;

}
export declare const throwRemovedFunctionError: (functionName: string) => void;
export declare const bootstrapLogManager: (id: string, level?: LogLevel) => void;
export declare const throwRemovedFunctionError: (functionName: string) => never;
export declare const bootstrapLogManager: (id: string, level?: LOG_LEVEL_VALUES) => void;
export declare const getLoggerbyId: (id: string) => any;

@@ -93,6 +71,6 @@ /**

value: any;
allowedTypes: Array<string> | any;
allowedTypes: string[] | any;
paramName: string;
functionName: string;
throwOnError?: boolean | undefined;
throwOnError?: boolean;
}) => boolean;

@@ -145,2 +123,3 @@ /**

* @param { string } functionName
* @param { boolean } throwOnError
* @returns { Boolean } true/false

@@ -172,5 +151,5 @@ */

/**
* Checks if the given LitNetwork value is supported.
* @param litNetwork - The LitNetwork value to check.
* @throws {Error} - Throws an error if the LitNetwork value is not supported.
* Checks if the given LIT_NETWORK value is supported.
* @param litNetwork - The Lit Network value to check.
* @throws {Error} - Throws an error if the Lit Network value is not supported.
*/

@@ -177,0 +156,0 @@ export declare function isSupportedLitNetwork(litNetwork: LIT_NETWORK_VALUES): asserts litNetwork is LIT_NETWORK_VALUES;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIpAddress = exports.normalizeAndStringify = exports.sendRequest = exports.getEnv = exports.removeHexPrefix = exports.hexPrefixed = exports.defaultMintClaimCallback = exports.isSupportedLitNetwork = exports.genRandomPath = exports.decimalPlaces = exports.isBrowser = exports.isNode = exports.is = exports.numberToHex = exports.sortedObject = exports.checkIfAuthSigRequiresChainParam = exports.checkSchema = exports.checkType = exports.getVarType = exports.logError = exports.logErrorWithRequestId = exports.logWithRequestId = exports.log = exports.getLoggerbyId = exports.bootstrapLogManager = exports.throwRemovedFunctionError = exports.isNodeClientErrorV0 = exports.isNodeClientErrorV1 = exports.throwGenericError = exports.throwErrorV1 = exports.throwErrorV0 = exports.throwError = exports.findMostCommonResponse = exports.mostCommonString = exports.printError = void 0;
exports.removeHexPrefix = exports.hexPrefixed = exports.defaultMintClaimCallback = exports.genRandomPath = exports.decimalPlaces = exports.isBrowser = exports.isNode = exports.is = exports.numberToHex = exports.sortedObject = exports.checkIfAuthSigRequiresChainParam = exports.checkSchema = exports.checkType = exports.getVarType = exports.logError = exports.logErrorWithRequestId = exports.logWithRequestId = exports.log = exports.getLoggerbyId = exports.bootstrapLogManager = exports.throwRemovedFunctionError = exports.findMostCommonResponse = exports.mostCommonString = exports.printError = void 0;
exports.isSupportedLitNetwork = isSupportedLitNetwork;
exports.getEnv = getEnv;
exports.sendRequest = sendRequest;
exports.normalizeAndStringify = normalizeAndStringify;
exports.getIpAddress = getIpAddress;
const tslib_1 = require("tslib");
const contracts_1 = require("@ethersproject/contracts");
const providers_1 = require("@ethersproject/providers");
const ajv_1 = tslib_1.__importDefault(require("ajv"));
const constants_1 = require("@lit-protocol/constants");
const providers_1 = require("@ethersproject/providers");
const contracts_1 = require("@ethersproject/contracts");
const logger_1 = require("@lit-protocol/logger");
const ajv_1 = require("ajv");
const logBuffer = [];

@@ -62,82 +68,11 @@ const ajv = new ajv_1.default();

exports.findMostCommonResponse = findMostCommonResponse;
const throwError = (e) => {
if ((0, exports.isNodeClientErrorV1)(e)) {
return (0, exports.throwErrorV1)(e);
}
else if ((0, exports.isNodeClientErrorV0)(e)) {
return (0, exports.throwErrorV0)(e);
}
return (0, exports.throwGenericError)(e);
};
exports.throwError = throwError;
/**
*
* Standardized way to throw error in Lit Protocol projects
*
* @deprecated use throwErrorV1
* @param { ILitError }
* @property { string } message
* @property { string } name
* @property { string } errorCode
*/
const throwErrorV0 = ({ message, name, errorCode, error, }) => {
const errConstructorFunc = function (message, name, errorCode) {
this.message = message;
this.name = name;
// Map old error codes to new ones if possible.
this.errorCode = oldErrorToNewErrorMap[errorCode] ?? errorCode;
};
throw new errConstructorFunc(message, (name = error?.name ?? name), (errorCode = error?.code ?? errorCode));
};
exports.throwErrorV0 = throwErrorV0;
// Map for old error codes to new ones
const oldErrorToNewErrorMap = {
not_authorized: 'NodeNotAuthorized',
storage_error: 'NodeStorageError',
};
/**
*
* Standardized way to throw error in Lit Protocol projects
*
*/
const throwErrorV1 = ({ errorKind, details, status, message, errorCode, requestId, }) => {
const errConstructorFunc = function (errorKind, status, details, message, errorCode, requestId) {
this.message = message;
this.errorCode = errorCode;
this.errorKind = errorKind;
this.status = status;
this.details = details;
this.requestId = requestId;
};
throw new errConstructorFunc(errorKind, status, details, message, errorCode, requestId);
};
exports.throwErrorV1 = throwErrorV1;
const throwGenericError = (e) => {
const errConstructorFunc = function (message, requestId) {
this.message = message;
this.errorKind = constants_1.LIT_ERROR.UNKNOWN_ERROR.name;
this.errorCode = constants_1.LIT_ERROR.UNKNOWN_ERROR.code;
this.requestId = requestId;
};
throw new errConstructorFunc(e.message ?? 'Generic Error', e.requestId ?? 'No request ID found');
};
exports.throwGenericError = throwGenericError;
const isNodeClientErrorV1 = (nodeError) => {
return (nodeError.hasOwnProperty('errorCode') &&
nodeError.hasOwnProperty('errorKind'));
};
exports.isNodeClientErrorV1 = isNodeClientErrorV1;
const isNodeClientErrorV0 = (nodeError) => {
return nodeError.hasOwnProperty('errorCode');
};
exports.isNodeClientErrorV0 = isNodeClientErrorV0;
const throwRemovedFunctionError = (functionName) => {
(0, exports.throwError)({
message: `This function "${functionName}" has been removed. Please use the old SDK.`,
errorKind: constants_1.LIT_ERROR.REMOVED_FUNCTION_ERROR.kind,
errorCode: constants_1.LIT_ERROR.REMOVED_FUNCTION_ERROR.name,
});
throw new constants_1.RemovedFunctionError({
info: {
functionName,
},
}, `This function "${functionName}" has been removed. Please use the old SDK.`);
};
exports.throwRemovedFunctionError = throwRemovedFunctionError;
const bootstrapLogManager = (id, level = logger_1.LogLevel.DEBUG) => {
const bootstrapLogManager = (id, level = constants_1.LOG_LEVEL.DEBUG) => {
if (!globalThis.logManager) {

@@ -299,7 +234,10 @@ globalThis.logManager = logger_1.LogManager.Instance;

if (throwOnError) {
(0, exports.throwError)({
message,
errorKind: constants_1.LIT_ERROR.INVALID_PARAM_TYPE.kind,
errorCode: constants_1.LIT_ERROR.INVALID_PARAM_TYPE.name,
});
throw new constants_1.InvalidParamType({
info: {
allowedTypes,
value,
paramName,
functionName,
},
}, message);
}

@@ -333,7 +271,9 @@ return false;

if (throwOnError) {
(0, exports.throwError)({
message,
errorKind: constants_1.LIT_ERROR.INVALID_PARAM_TYPE.kind,
errorCode: constants_1.LIT_ERROR.INVALID_PARAM_TYPE.name,
});
throw new constants_1.InvalidParamType({
info: {
value,
paramName,
functionName,
},
}, message);
}

@@ -414,2 +354,3 @@ return false;

* @param { string } functionName
* @param { boolean } throwOnError
* @returns { Boolean } true/false

@@ -419,9 +360,11 @@ */

if ((0, exports.getVarType)(value) !== type) {
let message = `Expecting "${type}" type for parameter named ${paramName} in Lit-JS-SDK function ${functionName}(), but received "${(0, exports.getVarType)(value)}" type instead. value: ${value instanceof Object ? JSON.stringify(value) : value}`;
const message = `Expecting "${type}" type for parameter named ${paramName} in Lit-JS-SDK function ${functionName}(), but received "${(0, exports.getVarType)(value)}" type instead. value: ${value instanceof Object ? JSON.stringify(value) : value}`;
if (throwOnError) {
(0, exports.throwError)({
message,
errorKind: constants_1.LIT_ERROR.INVALID_PARAM_TYPE.kind,
errorCode: constants_1.LIT_ERROR.INVALID_PARAM_TYPE.name,
});
throw new constants_1.InvalidParamType({
info: {
value,
paramName,
functionName,
},
}, message);
}

@@ -434,3 +377,3 @@ return false;

const isNode = () => {
var isNode = false;
let isNode = false;
// @ts-ignore

@@ -485,5 +428,5 @@ if (typeof process === 'object') {

/**
* Checks if the given LitNetwork value is supported.
* @param litNetwork - The LitNetwork value to check.
* @throws {Error} - Throws an error if the LitNetwork value is not supported.
* Checks if the given LIT_NETWORK value is supported.
* @param litNetwork - The Lit Network value to check.
* @throws {Error} - Throws an error if the Lit Network value is not supported.
*/

@@ -493,38 +436,46 @@ function isSupportedLitNetwork(litNetwork) {

if (!supportedNetworks.includes(litNetwork)) {
throw new Error(`Unsupported LitNetwork! (${supportedNetworks.join('|')}) are supported.`);
throw new constants_1.WrongNetworkException({
info: {
litNetwork,
supportedNetworks,
},
}, `Unsupported LitNetwork! (${supportedNetworks.join('|')}) are supported.`);
}
}
exports.isSupportedLitNetwork = isSupportedLitNetwork;
const defaultMintClaimCallback = async (params, network = 'cayenne') => {
const defaultMintClaimCallback = async (params, network = constants_1.LIT_NETWORK.DatilDev) => {
isSupportedLitNetwork(network);
try {
const AUTH_CLAIM_PATH = '/auth/claim';
const relayUrl = params.relayUrl || constants_1.RELAYER_URL_BY_NETWORK[network];
if (!relayUrl) {
throw new Error('No relayUrl provided and no default relayUrl found for network');
}
const relayUrlWithPath = relayUrl + AUTH_CLAIM_PATH;
const response = await fetch(relayUrlWithPath, {
method: 'POST',
body: JSON.stringify(params),
headers: {
'api-key': params.relayApiKey
? params.relayApiKey
: '67e55044-10b1-426f-9247-bb680e5fe0c8_relayer',
'Content-Type': 'application/json',
const AUTH_CLAIM_PATH = '/auth/claim';
const relayUrl = params.relayUrl || constants_1.RELAYER_URL_BY_NETWORK[network];
if (!relayUrl) {
throw new constants_1.InvalidArgumentException({
info: {
network,
relayUrl,
},
});
if (response.status < 200 || response.status >= 400) {
let errResp = (await response.json()) ?? '';
let errStmt = `An error occured requesting "/auth/claim" endpoint ${JSON.stringify(errResp)}`;
console.warn(errStmt);
throw new Error(errStmt);
}
let body = await response.json();
return body.requestId;
}, 'No relayUrl provided and no default relayUrl found for network');
}
catch (e) {
console.error(e.message);
throw e;
const relayUrlWithPath = relayUrl + AUTH_CLAIM_PATH;
const response = await fetch(relayUrlWithPath, {
method: 'POST',
body: JSON.stringify(params),
headers: {
'api-key': params.relayApiKey
? params.relayApiKey
: '67e55044-10b1-426f-9247-bb680e5fe0c8_relayer',
'Content-Type': 'application/json',
},
});
if (response.status < 200 || response.status >= 400) {
const errResp = (await response.json()) ?? '';
const errStmt = `An error occurred requesting "/auth/claim" endpoint ${JSON.stringify(errResp)}`;
console.warn(errStmt);
throw new constants_1.NetworkError({
info: {
response,
errResp,
},
}, `An error occurred requesting "/auth/claim" endpoint`);
}
const body = await response.json();
return body.requestId;
};

@@ -591,3 +542,2 @@ exports.defaultMintClaimCallback = defaultMintClaimCallback;

}
exports.getEnv = getEnv;
function sendRequest(url, req, requestId) {

@@ -614,3 +564,2 @@ return fetch(url, req)

}
exports.sendRequest = sendRequest;
/**

@@ -650,3 +599,2 @@ * Attempts to normalize a string by unescaping it until it can be parsed as a JSON object,

}
exports.normalizeAndStringify = normalizeAndStringify;
/**

@@ -667,10 +615,20 @@ * Retrieves the IP address associated with a given domain.

else {
throw new Error('No IP Address found or bad domain name');
throw new constants_1.UnknownError({
info: {
domain,
apiURL,
},
}, 'No IP Address found or bad domain name');
}
}
catch (error) {
throw new Error(error);
throw new constants_1.UnknownError({
info: {
domain,
apiURL,
},
cause: error,
}, 'message' in error ? error.message : String(error));
}
}
exports.getIpAddress = getIpAddress;
//# sourceMappingURL=misc.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