Closed cre8 closed 1 year ago
I think the third option sounds the best, looking into the agent explorer the json storage seems to be the best option like:
let dataStoreConst: IAgentPlugin;
let keyStore: AbstractKeyStore;
let privateKeyStore: AbstractPrivateKeyStore;
let didStore: AbstractDIDStore;
if (Platform.OS === 'web') {
const dataStore = BrowserLocalStorageStore.fromLocalStorage('veramo-state');
const identifierDataStore =
BrowserLocalStorageStore.fromLocalStorage('veramo-id-state');
dataStoreConst = new DataStoreJson(dataStore);
keyStore = new KeyStoreJson(dataStore);
privateKeyStore = new PrivateKeyStoreJson(dataStore);
didStore = new DIDStoreJson(identifierDataStore);
} else {
// DB setup:
const dbConnection = new DataSource({
type: 'sqlite',
driver: require('expo-sqlite'),
database: 'veramo.sqlite',
migrations: migrations,
migrationsRun: true,
logging: ['error', 'info', 'warn'],
entities: Entities,
}).initialize();
dataStoreConst = new DataStore(dbConnection);
keyStore = new KeyStore(dbConnection);
privateKeyStore = new PrivateKeyStore(dbConnection);
didStore = new DIDStore(dbConnection);
}
// Veramo agent setup
export const agent = createAgent<
IDIDManager & IKeyManager & IDataStore & IDataStoreORM
>({
plugins: [
new KeyManager({
store: keyStore,
kms: {
local: new KeyManagementSystem(privateKeyStore),
},
}),
new DIDManager({
store: didStore,
defaultProvider: 'did:ethr:goerli',
providers: {
'did:ethr:goerli': new EthrDIDProvider({
defaultKms: 'local',
network: 'goerli',
rpcUrl: 'https://goerli.infura.io/v3/' + INFURA_PROJECT_ID,
}),
},
}),
dataStoreConst,
new DIDResolverPlugin({
resolver: new Resolver({
...ethrDidResolver({ infuraProjectId: INFURA_PROJECT_ID }),
...webDidResolver(),
}),
}),
new CredentialPlugin(),
],
});
Indeed we did not consider react-native-web when writing the react-native tutorial.
If you want to propose changes to the tutorial, you will find it in the veramo-website repo, or click the "Edit this page" button when browsing veramo.io
We appreciate all contributions
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Bug severity 5
Describe the bug Following the tutorial I am getting an sql error:
To Reproduce Steps to reproduce the behaviour: Follow the tutorial here https://veramo.io/docs/react_native_tutorials/react_native_1_setup_identifiers and run the project in the web
Observed behaviour The error is thrown when the agent tries to connect with the database (either for the reading of identifiers and the writing)
Expected behaviour A successful connection.
Details It seems that the problem is the dbConnection is the problem. Running
Digging deeper it seems that the driver is not supported for the web, see https://docs.expo.dev/versions/latest/sdk/sqlite/
Therefore the tutorial should:
Versions (please complete the following information):