A shot in the dark, but at least it builds.
It’s not without errors in the console though.
peruse console
:5000/#/:1 Uncaught (in promise) E {message: "Setup Incomplete. Connection not available yet.", stack: "1001↵ at module.exports (/opt/Maidsafe/Peruse/r…alhost:5000/index.js:19682:83)↵ at <anonymous>"}message: "Setup Incomplete. Connection not available yet."stack: "1001↵ at module.exports (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/native/_error.js:32:10)↵ at SAFEApp.get connection [as connection] (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/app.js:189:13)↵ at MutableDataInterface.newEntries (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/api/mutable.js:640:42)↵ at MutableData.quickSetup (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/api/mutable.js:283:33)↵ at app.mutableData.newRandomPublic.then.mData (http://localhost:5000/index.js:19682:83)↵ at <anonymous>"__proto__: Error
at makeError (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/native/_error.js:23:17)
at module.exports (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/native/_error.js:31:13)
at SAFEApp.get connection [as connection] (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/app.js:189:13)
at MutableDataInterface.newEntries (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/api/mutable.js:640:42)
at MutableData.quickSetup (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/api/mutable.js:283:33)
at app.mutableData.newRandomPublic.then.mData (http://localhost:5000/index.js:19682:83)
at <anonymous>code: 1001constructor: function E(message)arguments: nullcaller: nulllength: 1name: "E"prototype: Error
at makeError (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/native/_error.js:23:17)
at module.exports (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/native/_error.js:31:13)
at SAFEApp.get connection [as connection] (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/app.js:189:13)
at MutableDataInterface.newEntries (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/api/mutable.js:640:42)
at MutableData.quickSetup (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/api/mutable.js:283:33)
at app.mutableData.newRandomPublic.then.mData (http://localhost:5000/index.js:19682:83)
at <anonymous>__proto__: function ()[[FunctionLocation]]: /opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/native/_error.js:15[[Scopes]]: Scopes[4]name: 1001stack: "1001↵ at makeError (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/native/_error.js:23:17)↵ at module.exports (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/native/_error.js:31:13)↵ at SAFEApp.get connection [as connection] (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/app.js:189:13)↵ at MutableDataInterface.newEntries (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/api/mutable.js:640:42)↵ at MutableData.quickSetup (/opt/Maidsafe/Peruse/resources/app.asar/node_modules/@maidsafe/safe-node-app/src/api/mutable.js:283:33)↵ at app.mutableData.newRandomPublic.then.mData (http://localhost:5000/index.js:19682:83)↵ at <anonymous>"__proto__: Objectconstructor: function Error()message: ""name: "Error"toString: function toString()__proto__: Objectconstructor: function Object()hasOwnProperty: function hasOwnProperty()isPrototypeOf: function isPrototypeOf()propertyIsEnumerable: function propertyIsEnumerable()toLocaleString: function toLocaleString()toString: function toString()valueOf: function valueOf()arguments: nullcaller: nulllength: 0name: "valueOf"__proto__: function ()__defineGetter__: function __defineGetter__()arguments: nullcaller: nulllength: 2name: "__defineGetter__"__proto__: function ()__defineSetter__: function __defineSetter__()arguments: nullcaller: nulllength: 2name: "__defineSetter__"__proto__: function ()__lookupGetter__: function __lookupGetter__()__lookupSetter__: function __lookupSetter__()get __proto__: function __proto__()set __proto__: function __proto__()
It seems you are taking the code that the tutorial shows for developing a desktop app (https://hub.safedev.org/platform/nodejs/) but trying to run it as a web app within the browser.
FYI I’m working on a library SafenetworkJs that provides a simplified version of the SAFE API which can be used in either desktop or Web apps.
It started as a Web library (eg used in my RemoteStorage.js demo apps and Solid/SAFE Plume), and is currently working in a desktop app (SAFE FUSE) although it is work in progress.
This means some of the code has not yet been ported to the 0.9 API, or is ported but not tested, while there is a lot of code which is ported and working.
So the auth code works and there are a set of classes for working with mutable data, in particular for querying the standard containers (not tested in Web API, but it should manly 'just work ).
Porting is pretty simple, so any areas that haven’t been ported mainly just need minor changes and some testing.
Yes, Aug 6, a month ago, and safe-node-app v0.9.0 was published on Jul 31.
Can you reference to which docs you are referring to please? the docs at http://docs.maidsafe.net/beaker-plugin-safe-app/ are the old DOM API which is still available in Beaker Browser v0.10.2, whilst the docs at Home - Documentation correspond to v0.9.x, and the new DOM API in Peruse v0.6 has only a couple of differences to that safe_app_nodejs v0.9 API
If you follow the web tutorial and use Beaker Browser v0.10.2 you shouldn’t face any problems, the code you are using seems to be from the desktop app tutorial, so that’s your first issue.
Now, whenever we make Peruse the official browser and finally officially deprecate Beaker Browser (hopefully soon) we will definitely need to change the web tutorial as the DOM API is different. I agree though that perhaps the web tutorial now can be more explicit about beaker browser being the official and the browser to be used for the purpose, I’ll look into enhancing that.
bindings.js:158 Uncaught TypeError: exists is not a function
at Function.getRoot (bindings.js:158)
at bindings (bindings.js:60)
at Object../node_modules/weak/lib/weak.js (weak.js:7)
at __webpack_require__ (bootstrap 87a193eb7d582ce2634b:678)
at fn (bootstrap 87a193eb7d582ce2634b:88)
at Object.<anonymous> (helpers.js:14)
at Object../node_modules/@maidsafe/safe-node-app/src/helpers.js (helpers.js:158)
at __webpack_require__ (bootstrap 87a193eb7d582ce2634b:678)
at fn (bootstrap 87a193eb7d582ce2634b:88)
at Object../node_modules/@maidsafe/safe-node-app/src/app.js (app.js:15)
When doing a web app you cannot require any package like that, and you don’t need to require anything for having the DOM API available, so that line has to go away if you are coding a webapp.
In Peruse, for authorising the application, try the following as your authoriseAndConnect function within the safenetwork.js file:
let safeApp;
async function authoriseAndConnect() {
let appInfo = {
name: 'Hello SAFE Network',
id: 'net.maidsafe.tutorials.web-app',
version: '0.2.0',
vendor: 'MaidSafe.net Ltd.'
};
safeApp = await window.safe.initialiseApp(appInfo);
console.log('Authorising SAFE application...');
const authReqUri = await safeApp.auth.genAuthUri();
const authUri = await window.safe.authorise(authReqUri);
console.log('SAFE application authorised by user');
await safeApp.auth.loginFromUri(authUri);
console.log("Application connected to the network");
};
You should get the authorisation popup in Peruse and see that the app gets connected after you authorise it. I’ll try to get the complete safenetwork.js code for Peruse now for you, so please let me know how you get along with this.
@folaht , this is the complete code for the safenetwork.js file for the web app tutorial to work on Peruse v0.6, please note that I renamed the removeItems function to deleteItems:
It does not seem to get past const authUri = await window.safe.authorise(authReqUri)
And I don’t know how to look at this in the console as the console sees await as an unexpected identifier.
Hi @folaht, I’m glad you keep plugging away at this. I often read your posts and would like to help, but find they lack information to help me understand what to suggest so it might help you get more responses to spell things out at each point.
So with regard to your last post, what steps are you taking?
Have you set anything in the environment, is Peruse running, have you logged into an account, does anything happen when you reach that authorise() statement?
Just open the Peruse browser using --args --mock --preload. (I tested using the 0.7.0-rc.2 version.) Open a new tab, open the console in there, paste the snippet and press enter:
You’ll see the authorization window pop-up. The console.info will log the {name: ..., typeTag: ...} object in this case.
The console also autocompletes whenever you type something, use it to your advantage! Your result (‘Cannot read property … of undefined’) can be debugged quite easily this way. Type in window.safeApp and you see it’s indeed undefined.