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

@fileverse/fileverse-agent

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fileverse/fileverse-agent - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

6

dist/agent.d.ts

@@ -8,3 +8,3 @@ import { Wallet } from 'ethers';

*/
hasAgent(walletAddress: string): boolean;
hasAgent(address: string): boolean;
/**

@@ -14,3 +14,3 @@ * @dev createAgent - this creates an agent if no agent is associated with the provided wallet address

*/
createAgent({ walletAddress, password }: ICreateAgent): Promise<AgentCreationResult>;
createAgent({ address, password }: ICreateAgent): Promise<AgentCreationResult>;
/**

@@ -20,4 +20,4 @@ * @dev getAgent - retrieves an agent associated with a wallet address from storage

*/
getAgent({ password, walletAddress }: ICreateAgent): Promise<Wallet>;
getAgent({ password, address }: ICreateAgent): Promise<Wallet>;
}
export default Agent;

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

*/
hasAgent(walletAddress) {
const wallet = retrieveAgentFromStore(walletAddress);
hasAgent(address) {
const wallet = retrieveAgentFromStore(address);
return !!wallet;

@@ -26,6 +26,6 @@ }

*/
createAgent({ walletAddress, password }) {
createAgent({ address, password }) {
return __awaiter(this, void 0, void 0, function* () {
if (this.hasAgent(walletAddress)) {
throw new Error(`an agent is already associated with wallet address: ${walletAddress}`);
if (this.hasAgent(address)) {
throw new Error(`an agent is already associated with wallet address: ${address}`);
}

@@ -35,3 +35,3 @@ else {

const encryptedWallet = yield encryptWallet(password, wallet);
storeAgent(walletAddress, encryptedWallet);
storeAgent(address, encryptedWallet);
const agentWalletAddress = yield wallet.getAddress();

@@ -50,5 +50,5 @@ return {

*/
getAgent({ password, walletAddress }) {
getAgent({ password, address }) {
return __awaiter(this, void 0, void 0, function* () {
const wallet = yield getWallet(walletAddress, password);
const wallet = yield getWallet(address, password);
return wallet;

@@ -55,0 +55,0 @@ });

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

export declare const storeAgent: (walletAddress: string, encryptedWallet: string) => void;
export declare const retrieveAgentFromStore: (walletAddress: string) => string | undefined;
export declare const storeAgent: (address: string, encryptedWallet: string) => Promise<void>;
export declare const retrieveAgentFromStore: (address: string) => string;

@@ -1,22 +0,34 @@

export const storeAgent = (walletAddress, encryptedWallet) => {
const state = localStorage.getItem('agent');
if (state) {
const stateObject = JSON.parse(state);
stateObject[walletAddress] = encryptedWallet;
localStorage.setItem('agent', JSON.stringify(stateObject));
}
else {
const newState = {
[walletAddress]: encryptedWallet,
};
localStorage.setItem('agent', JSON.stringify(newState));
}
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
export const retrieveAgentFromStore = (walletAddress) => {
import { SEA } from "gun";
import { gunInstance } from "../utils";
export const storeAgent = (address, encryptedWallet) => __awaiter(void 0, void 0, void 0, function* () {
const agentGunNode = gunInstance.get(`#agent/${address}`);
const state = localStorage.getItem('agent');
if (state) {
const stateObject = JSON.parse(state);
return stateObject[walletAddress];
}
const serializedAgentInfo = JSON.stringify({
agent: encryptedWallet,
createdAt: Date.now(),
});
const hash = yield SEA.work(serializedAgentInfo, null, null, {
name: 'SHA-256',
});
agentGunNode.get(hash).put(serializedAgentInfo);
});
export const retrieveAgentFromStore = (address) => {
const agentGunNode = gunInstance.get(`#agent/${address}`);
let agentWallet;
agentGunNode.map().once((data) => {
var _a;
const agent = (_a = JSON.parse(data)) === null || _a === void 0 ? void 0 : _a.agent;
agentWallet = agent;
}, { wait: 5 });
return agentWallet;
};
//# sourceMappingURL=storage.js.map

@@ -7,4 +7,4 @@ export interface AgentCreationResult {

export interface ICreateAgent {
walletAddress: string;
address: string;
password: string;
}

@@ -6,1 +6,3 @@ import { ethers } from 'ethers';

export declare const getWallet: (walletAddress: string, key: string) => Promise<ethers.Wallet>;
export declare const instantiateGun: () => import("gun").IGunInstance<any>;
export declare const gunInstance: import("gun").IGunInstance<any>;

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

});
import Gun from 'gun';
export const instantiateGun = () => {
return Gun({
peers: [process.env.REACT_APP_GUN_URL],
});
};
export const gunInstance = instantiateGun();
//# sourceMappingURL=utils.js.map
{
"name": "@fileverse/fileverse-agent",
"version": "3.0.2",
"version": "3.0.3",
"description": "signless agent for wallet addresses",

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

"scripts": {
"test": "jest --coverage",
"test": "jest --coverage --forceExit",
"build": "rm -rf dist && npx tsc",

@@ -26,3 +26,4 @@ "release": "node scripts/release.js"

"dependencies": {
"ethers": "^5.7.2"
"ethers": "^5.7.2",
"gun": "^0.2020.1239"
},

@@ -29,0 +30,0 @@ "devDependencies": {

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