@veramo-community/veramo-react
Advanced tools
Comparing version 1.0.80 to 1.0.81
@@ -1,25 +0,11 @@ | ||
"use strict"; | ||
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()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = __importDefault(require("react")); | ||
const react_hooks_1 = require("@testing-library/react-hooks"); | ||
const core_1 = require("@veramo/core"); | ||
const VeramoProvider_1 = require("../VeramoProvider"); | ||
import React from 'react'; | ||
import { renderHook, act } from '@testing-library/react-hooks'; | ||
import { createAgent } from '@veramo/core'; | ||
import { VeramoProvider, useVeramo } from '../VeramoProvider'; | ||
beforeEach(() => { | ||
window.localStorage.clear(); | ||
}); | ||
const wrapper = (props) => (react_1.default.createElement(VeramoProvider_1.VeramoProvider, null, props.children)); | ||
test('agent list should be empty by default', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
const wrapper = (props) => (React.createElement(VeramoProvider, null, props.children)); | ||
test('agent list should be empty by default', async () => { | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
expect(result.current.agent).toBeUndefined(); | ||
@@ -33,7 +19,6 @@ expect(result.current.agents).toHaveLength(0); | ||
expect(typeof result.current.getAgentConfig).toBe('function'); | ||
})); | ||
}); | ||
test('should be able to add local agent', () => { | ||
var _a; | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
const agent = (0, core_1.createAgent)({ | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
const agent = createAgent({ | ||
context: { | ||
@@ -43,9 +28,8 @@ id: 'foo', | ||
}); | ||
(0, react_hooks_1.act)(() => result.current.addAgent(agent)); | ||
expect((_a = result.current.agent) === null || _a === void 0 ? void 0 : _a.context.id).toEqual('foo'); | ||
act(() => result.current.addAgent(agent)); | ||
expect(result.current.agent?.context.id).toEqual('foo'); | ||
}); | ||
test('should be able to add agent config', () => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a, _b; | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
test('should be able to add agent config', async () => { | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -70,4 +54,4 @@ id: 'foo', | ||
expect(result.current.agents[0]).toEqual(result.current.agent); | ||
expect((_a = result.current.agents[0].context) === null || _a === void 0 ? void 0 : _a.id).toEqual('foo'); | ||
expect((_b = result.current.agents[0].context) === null || _b === void 0 ? void 0 : _b.name).toEqual('bar'); | ||
expect(result.current.agents[0].context?.id).toEqual('foo'); | ||
expect(result.current.agents[0].context?.name).toEqual('bar'); | ||
expect(result.current.agents[0].availableMethods()).toEqual([ | ||
@@ -79,6 +63,6 @@ 'resolveDid', | ||
expect(typeof result.current.agents[0].didManagerCreate).toBe('function'); | ||
})); | ||
}); | ||
test('addAgentConfig should generate UUID for context.id', () => { | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -92,4 +76,4 @@ name: 'bar', | ||
test('should be able to remove agent config', () => { | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -100,4 +84,4 @@ name: 'foo', | ||
})); | ||
(0, react_hooks_1.act)(() => { | ||
const agent = (0, core_1.createAgent)({ | ||
act(() => { | ||
const agent = createAgent({ | ||
context: { id: 'baz' }, | ||
@@ -107,3 +91,3 @@ }); | ||
}); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -116,3 +100,3 @@ name: 'bar', | ||
const originalActive = result.current.activeAgentId; | ||
(0, react_hooks_1.act)(() => { | ||
act(() => { | ||
if (result.current.agents[2].context.id) | ||
@@ -125,5 +109,5 @@ result.current.removeAgent(result.current.agents[2].context.id); | ||
test('should reset active agent id if removing active agent', () => { | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
(0, react_hooks_1.act)(() => { | ||
const agent = (0, core_1.createAgent)({ | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
act(() => { | ||
const agent = createAgent({ | ||
context: { id: 'baz' }, | ||
@@ -133,3 +117,3 @@ }); | ||
}); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -140,3 +124,3 @@ name: 'foo', | ||
})); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -149,3 +133,3 @@ name: 'bar', | ||
const secondAgentId = result.current.agents[1].context.id; | ||
(0, react_hooks_1.act)(() => result.current.removeAgent(result.current.activeAgentId)); | ||
act(() => result.current.removeAgent(result.current.activeAgentId)); | ||
expect(result.current.agents).toHaveLength(2); | ||
@@ -156,4 +140,4 @@ expect(result.current.activeAgentId).toEqual(secondAgentId); | ||
test('should be able to update agent config', () => { | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -164,3 +148,3 @@ name: 'foo', | ||
})); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -171,4 +155,4 @@ name: 'bar', | ||
})); | ||
(0, react_hooks_1.act)(() => { | ||
const agent = (0, core_1.createAgent)({ | ||
act(() => { | ||
const agent = createAgent({ | ||
context: { id: 'lorem' }, | ||
@@ -180,3 +164,3 @@ }); | ||
const secondAgentId = result.current.agents[1].context.id; | ||
(0, react_hooks_1.act)(() => { | ||
act(() => { | ||
const config = result.current.getAgentConfig(secondAgentId); | ||
@@ -190,5 +174,4 @@ config.context.name = 'baz'; | ||
test('should be able to set active agent', () => { | ||
var _a, _b; | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -200,3 +183,3 @@ id: 'foo', | ||
})); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -208,10 +191,10 @@ id: 'bar', | ||
})); | ||
expect((_a = result.current.agent) === null || _a === void 0 ? void 0 : _a.context.name).toEqual('foo'); | ||
(0, react_hooks_1.act)(() => result.current.setActiveAgentId('bar')); | ||
expect((_b = result.current.agent) === null || _b === void 0 ? void 0 : _b.context.name).toEqual('bar'); | ||
expect(result.current.agent?.context.name).toEqual('foo'); | ||
act(() => result.current.setActiveAgentId('bar')); | ||
expect(result.current.agent?.context.name).toEqual('bar'); | ||
}); | ||
test('addAgent should throw error if context.id is missing', () => { | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
try { | ||
(0, react_hooks_1.act)(() => result.current.addAgent((0, core_1.createAgent)({}))); | ||
act(() => result.current.addAgent(createAgent({}))); | ||
} | ||
@@ -223,3 +206,3 @@ catch (e) { | ||
test('should be possible to pass initial values as props', () => { | ||
const localAgent1 = (0, core_1.createAgent)({ | ||
const localAgent1 = createAgent({ | ||
context: { | ||
@@ -229,3 +212,3 @@ id: 'foo', | ||
}); | ||
const localAgent2 = (0, core_1.createAgent)({ | ||
const localAgent2 = createAgent({ | ||
context: { | ||
@@ -235,6 +218,6 @@ id: 'bar', | ||
}); | ||
const wrapper = (props) => (react_1.default.createElement(VeramoProvider_1.VeramoProvider, { agents: [localAgent1, localAgent2] }, props.children)); | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
const wrapper = (props) => (React.createElement(VeramoProvider, { agents: [localAgent1, localAgent2] }, props.children)); | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
expect(result.current.agents).toHaveLength(2); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -245,4 +228,4 @@ name: 'foo', | ||
})); | ||
(0, react_hooks_1.act)(() => { | ||
const agent = (0, core_1.createAgent)({ | ||
act(() => { | ||
const agent = createAgent({ | ||
context: { id: 'baz123' }, | ||
@@ -253,3 +236,3 @@ }); | ||
expect(result.current.agents).toHaveLength(4); | ||
(0, react_hooks_1.act)(() => { | ||
act(() => { | ||
result.current.removeAgent(result.current.activeAgentId); | ||
@@ -261,5 +244,5 @@ }); | ||
test('should return correct agent by id', () => { | ||
const { result } = (0, react_hooks_1.renderHook)(() => (0, VeramoProvider_1.useVeramo)(), { wrapper }); | ||
(0, react_hooks_1.act)(() => { | ||
const agent = (0, core_1.createAgent)({ | ||
const { result } = renderHook(() => useVeramo(), { wrapper }); | ||
act(() => { | ||
const agent = createAgent({ | ||
context: { id: 'baz' }, | ||
@@ -269,3 +252,3 @@ }); | ||
}); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -277,3 +260,3 @@ name: 'foo', | ||
})); | ||
(0, react_hooks_1.act)(() => result.current.addAgentConfig({ | ||
act(() => result.current.addAgentConfig({ | ||
context: { | ||
@@ -285,3 +268,3 @@ name: 'bar', | ||
})); | ||
(0, react_hooks_1.act)(() => { | ||
act(() => { | ||
const agent = result.current.getAgent('bar'); | ||
@@ -288,0 +271,0 @@ expect(agent.context.id).toEqual('bar'); |
@@ -1,22 +0,3 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VeramoProvider = exports.useVeramo = void 0; | ||
var VeramoProvider_1 = require("./VeramoProvider"); | ||
Object.defineProperty(exports, "useVeramo", { enumerable: true, get: function () { return VeramoProvider_1.useVeramo; } }); | ||
Object.defineProperty(exports, "VeramoProvider", { enumerable: true, get: function () { return VeramoProvider_1.VeramoProvider; } }); | ||
__exportStar(require("./types"), exports); | ||
export { useVeramo, VeramoProvider } from './VeramoProvider'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getStoredActiveAgentId = exports.storeActiveAgentId = exports.storeAgentConfigs = exports.getStoredAgentConfigs = exports.createAgentFromConfig = void 0; | ||
const core_1 = require("@veramo/core"); | ||
const remote_client_1 = require("@veramo/remote-client"); | ||
function createAgentFromConfig(config, plugins) { | ||
const restClients = config.remoteAgents.map((remote) => new remote_client_1.AgentRestClient({ | ||
import { createAgent } from '@veramo/core'; | ||
import { AgentRestClient } from '@veramo/remote-client'; | ||
export function createAgentFromConfig(config, plugins) { | ||
const restClients = config.remoteAgents.map((remote) => new AgentRestClient({ | ||
url: remote.url, | ||
@@ -15,3 +12,3 @@ headers: remote.token | ||
})); | ||
return (0, core_1.createAgent)({ | ||
return createAgent({ | ||
context: config.context, | ||
@@ -21,4 +18,3 @@ plugins: restClients.concat(plugins || []), | ||
} | ||
exports.createAgentFromConfig = createAgentFromConfig; | ||
function getStoredAgentConfigs() { | ||
export function getStoredAgentConfigs() { | ||
if (typeof localStorage == 'undefined') { | ||
@@ -29,4 +25,3 @@ return []; | ||
} | ||
exports.getStoredAgentConfigs = getStoredAgentConfigs; | ||
function storeAgentConfigs(configs) { | ||
export function storeAgentConfigs(configs) { | ||
if (typeof localStorage !== 'undefined') { | ||
@@ -36,4 +31,3 @@ return localStorage.setItem('serializedAgentConfigs', JSON.stringify(configs)); | ||
} | ||
exports.storeAgentConfigs = storeAgentConfigs; | ||
function storeActiveAgentId(id) { | ||
export function storeActiveAgentId(id) { | ||
if (typeof localStorage !== 'undefined') { | ||
@@ -43,4 +37,3 @@ return localStorage.setItem('activeAgentId', JSON.stringify(id)); | ||
} | ||
exports.storeActiveAgentId = storeActiveAgentId; | ||
function getStoredActiveAgentId() { | ||
export function getStoredActiveAgentId() { | ||
if (typeof localStorage !== 'undefined') { | ||
@@ -53,3 +46,2 @@ const storedId = localStorage.getItem('activeAgentId'); | ||
} | ||
exports.getStoredActiveAgentId = getStoredActiveAgentId; | ||
//# sourceMappingURL=utils.js.map |
@@ -1,39 +0,12 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useVeramo = exports.VeramoProvider = void 0; | ||
const react_1 = __importStar(require("react")); | ||
const utils_1 = require("./utils"); | ||
const uuid_1 = require("uuid"); | ||
const VeramoReactContext = react_1.default.createContext({}); | ||
function VeramoProvider(props) { | ||
var _a; | ||
const initialAgents = (props.agents || []).concat((0, utils_1.getStoredAgentConfigs)().map((c) => (0, utils_1.createAgentFromConfig)(c, props.plugins))); | ||
const initialActiveAgentId = (0, utils_1.getStoredActiveAgentId)() || | ||
(initialAgents.length > 0 ? (_a = initialAgents[0].context) === null || _a === void 0 ? void 0 : _a.id : undefined); | ||
const [agents, setAgents] = (0, react_1.useState)(initialAgents); | ||
const [activeAgentId, setActiveAgentIdInState] = (0, react_1.useState)(initialActiveAgentId); | ||
(0, react_1.useEffect)(() => { | ||
import React, { useContext, useState, useEffect } from 'react'; | ||
import { createAgentFromConfig, getStoredAgentConfigs, storeAgentConfigs, storeActiveAgentId, getStoredActiveAgentId, } from './utils'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
const VeramoReactContext = React.createContext({}); | ||
export function VeramoProvider(props) { | ||
const initialAgents = (props.agents || []).concat(getStoredAgentConfigs().map((c) => createAgentFromConfig(c, props.plugins))); | ||
const initialActiveAgentId = getStoredActiveAgentId() || | ||
(initialAgents.length > 0 ? initialAgents[0].context?.id : undefined); | ||
const [agents, setAgents] = useState(initialAgents); | ||
const [activeAgentId, setActiveAgentIdInState] = useState(initialActiveAgentId); | ||
useEffect(() => { | ||
setAgents(initialAgents); | ||
@@ -43,7 +16,7 @@ setActiveAgentId(initialActiveAgentId); | ||
const setActiveAgentId = (id) => { | ||
(0, utils_1.storeActiveAgentId)(id); | ||
storeActiveAgentId(id); | ||
setActiveAgentIdInState(id); | ||
}; | ||
const validateContext = (context) => { | ||
if (!(context === null || context === void 0 ? void 0 : context.id)) | ||
if (!context?.id) | ||
throw Error('Missing context.id'); | ||
@@ -60,20 +33,19 @@ }; | ||
if (!config.context.id) { | ||
config.context.id = (0, uuid_1.v4)(); | ||
config.context.id = uuidv4(); | ||
} | ||
const configs = (0, utils_1.getStoredAgentConfigs)().concat(config); | ||
(0, utils_1.storeAgentConfigs)(configs); | ||
addAgent((0, utils_1.createAgentFromConfig)(config, props.plugins)); | ||
const configs = getStoredAgentConfigs().concat(config); | ||
storeAgentConfigs(configs); | ||
addAgent(createAgentFromConfig(config, props.plugins)); | ||
} | ||
const removeAgent = (id) => { | ||
var _a, _b; | ||
(0, utils_1.storeAgentConfigs)((0, utils_1.getStoredAgentConfigs)().filter((c) => c.context.id !== id)); | ||
const filtered = agents.filter((a) => { var _a; return ((_a = a.context) === null || _a === void 0 ? void 0 : _a.id) !== id; }); | ||
storeAgentConfigs(getStoredAgentConfigs().filter((c) => c.context.id !== id)); | ||
const filtered = agents.filter((a) => a.context?.id !== id); | ||
setAgents(filtered); | ||
if (activeAgentId === id) { | ||
setActiveAgentId((_b = (_a = filtered[0]) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.id); | ||
setActiveAgentId(filtered[0]?.context?.id); | ||
} | ||
}; | ||
const getAgentConfig = (id) => { | ||
const configs = (0, utils_1.getStoredAgentConfigs)(); | ||
const config = configs.find((c) => { var _a; return ((_a = c.context) === null || _a === void 0 ? void 0 : _a.id) === id; }); | ||
const configs = getStoredAgentConfigs(); | ||
const config = configs.find((c) => c.context?.id === id); | ||
if (!config) | ||
@@ -84,3 +56,3 @@ throw Error('Config not found'); | ||
function getAgent(id) { | ||
const agent = agents.find((a) => { var _a; return ((_a = a.context) === null || _a === void 0 ? void 0 : _a.id) === id; }); | ||
const agent = agents.find((a) => a.context?.id === id); | ||
if (!agent) | ||
@@ -92,18 +64,18 @@ throw Error('Agent not found'); | ||
validateContext(config.context); | ||
const configs = (0, utils_1.getStoredAgentConfigs)(); | ||
const existingConfig = configs.find((c) => { var _a; return ((_a = c.context) === null || _a === void 0 ? void 0 : _a.id) === id; }); | ||
const configs = getStoredAgentConfigs(); | ||
const existingConfig = configs.find((c) => c.context?.id === id); | ||
if (!existingConfig) | ||
throw Error('Config not found'); | ||
configs[configs.indexOf(existingConfig)] = config; | ||
(0, utils_1.storeAgentConfigs)(configs); | ||
const oldAgent = agents.find((a) => { var _a; return ((_a = a.context) === null || _a === void 0 ? void 0 : _a.id) === id; }); | ||
storeAgentConfigs(configs); | ||
const oldAgent = agents.find((a) => a.context?.id === id); | ||
if (oldAgent) { | ||
const agentIndex = agents.indexOf(oldAgent); | ||
const newAgents = [...agents]; | ||
newAgents[agentIndex] = (0, utils_1.createAgentFromConfig)(config, props.plugins); | ||
newAgents[agentIndex] = createAgentFromConfig(config, props.plugins); | ||
setAgents(newAgents); | ||
} | ||
}; | ||
return (react_1.default.createElement(VeramoReactContext.Provider, { value: { | ||
agent: agents.find((a) => { var _a; return ((_a = a.context) === null || _a === void 0 ? void 0 : _a.id) === activeAgentId; }), | ||
return (React.createElement(VeramoReactContext.Provider, { value: { | ||
agent: agents.find((a) => a.context?.id === activeAgentId), | ||
agents, | ||
@@ -120,7 +92,5 @@ activeAgentId, | ||
} | ||
exports.VeramoProvider = VeramoProvider; | ||
function useVeramo() { | ||
return (0, react_1.useContext)(VeramoReactContext); | ||
export function useVeramo() { | ||
return useContext(VeramoReactContext); | ||
} | ||
exports.useVeramo = useVeramo; | ||
//# sourceMappingURL=VeramoProvider.js.map |
{ | ||
"name": "@veramo-community/veramo-react", | ||
"version": "1.0.80", | ||
"version": "1.0.81", | ||
"main": "./lib/index.js", | ||
"types": "./lib/index.d.ts", | ||
"type": "module", | ||
"publishConfig": { | ||
@@ -11,4 +12,4 @@ "access": "public" | ||
"peerDependencies": { | ||
"@veramo/core": "^3.1.6-next", | ||
"@veramo/remote-client": "^3.1.6-next", | ||
"@veramo/core": "5.1.5-next.13", | ||
"@veramo/remote-client": "5.1.5-next.13", | ||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0" | ||
@@ -20,26 +21,26 @@ }, | ||
"devDependencies": { | ||
"@babel/preset-env": "7.18.6", | ||
"@babel/preset-env": "7.20.2", | ||
"@babel/preset-react": "7.18.6", | ||
"@semantic-release/commit-analyzer": "9.0.2", | ||
"@semantic-release/git": "10.0.1", | ||
"@semantic-release/npm": "9.0.1", | ||
"@semantic-release/npm": "10.0.3", | ||
"@semantic-release/release-notes-generator": "10.0.3", | ||
"@testing-library/jest-dom": "5.16.4", | ||
"@testing-library/jest-dom": "5.16.5", | ||
"@testing-library/react-hooks": "8.0.1", | ||
"@types/jest": "28.1.6", | ||
"@types/react": "18.0.15", | ||
"@types/jest": "29.5.0", | ||
"@types/react": "18.0.29", | ||
"@types/react-test-renderer": "18.0.0", | ||
"@types/uuid": "8.3.4", | ||
"@veramo/core": "3.1.6-next.148", | ||
"@veramo/remote-client": "3.1.6-next.148", | ||
"babel-jest": "28.1.3", | ||
"jest": "28.1.3", | ||
"jest-environment-jsdom": "28.1.3", | ||
"prettier": "2.7.1", | ||
"@types/uuid": "9.0.1", | ||
"@veramo/core": "5.1.5-next.13", | ||
"@veramo/remote-client": "5.1.5-next.13", | ||
"babel-jest": "29.5.0", | ||
"jest": "29.5.0", | ||
"jest-environment-jsdom": "29.5.0", | ||
"prettier": "2.8.7", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"react-test-renderer": "18.2.0", | ||
"semantic-release": "19.0.3", | ||
"ts-jest": "28.0.7", | ||
"typescript": "4.7.4" | ||
"semantic-release": "21.0.1", | ||
"ts-jest": "29.1.0", | ||
"typescript": "5.0.4" | ||
}, | ||
@@ -50,4 +51,4 @@ "scripts": { | ||
"format": "prettier --write \"src/**/*.*[jt]s*\"", | ||
"test": "jest --config=jest.cjs --coverage=false", | ||
"test:watch": "yarn test --watch --verbose", | ||
"test": "NODE_OPTIONS=\"--experimental-vm-modules --experimental-import-meta-resolve\" jest --config=jest.cjs --coverage=false", | ||
"test:watch": "NODE_OPTIONS=\"--experimental-vm-modules --experimental-import-meta-resolve\" yarn test --watch --verbose", | ||
"upgrade-veramo": "yarn add -D @veramo/core@next @veramo/remote-client@next", | ||
@@ -54,0 +55,0 @@ "release": "semantic-release" |
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
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
Sorry, the diff of this file is not supported yet
24
Yes
53999
473