SAFE Browser web app user [session] data API best practice

Rather than persisting user sessions (e.g., UI state) using a traditional method such as cookies, with SAFE all non-volatile data generated by or for a user should be owned by the user and usable in a predictable manner.

For a Rust/wasm web app in the SAFE Browser environment, what workflow and API should be used to persist/restore a user’s session file? The session file would be created by the web app, on behalf of and in response to a request by a user, for the purpose of automatically restoring the user’s web app session state after reopening the web app.

In addition to the write/read primitives, what API should be used for SAFE Browser to prompt the user to allow the session file to be written/updated?

2 Likes

Right now we’ve only got the APIs for pseudo filesystem in place in the exposed APIs (more appropriate data structs are coming, though).

You could use the files container APIs to make a folder in a deterministic location (or via nrs), and store JSON for now: https://github.com/maidsafe/safe-nodejs/blob/master/native/src/lib.rs#L475

Right now, when you prompt for authorised app creation, the user will be prompted to provide permissions for read/write.

@Shane has previously created Phantom, which is open source and may be worth having a look at in terms of safe connectivity and data persistence as things stand.

1 Like

4 posts were split to a new topic: Are there any plans to update safe-nodejs?