Initialization
First, the app needs to receive an authorization token from SAFE Launcher. Then, it needs to retrieve your email data (your email ID and your saved emails).
Contents

Authorize the app
The app sends an authorization request to SAFE Launcher.
POST /auth
export const authoriseApplication = (data) => {
return {
type: ACTION_TYPES.AUTHORISE_APP,
payload: {
request: {
method: 'post',
url: '/auth',
data: data
}
}
};
};
The authoriseApplication
function is called using AUTH_PAYLOAD
as an argument:
const AUTH_PAYLOAD = {
app: {
name: pkg.productName,
vendor: pkg.author.name,
version: pkg.version,
id: pkg.identifier
},
permissions: ['LOW_LEVEL_API']
};
The app uses the information contained in its package.json
file for the following fields:
app.name
app.vendor
app.version
app.id
Therefore, the request body looks like this:
{
"app": {
"name": "SafeMailApp",
"id": "safe-mail-app",
"version": "0.0.1",
"vendor": "MaidSafe"
},
"permissions": ["LOW_LEVEL_API"]
}
The LOW_LEVEL_API
permission is requested because the app needs to use the low-level APIs:
info::Why is it necessary to ask for this permission?By providing the
LOW_LEVEL_API
permission, the user should be aware that the app can now store data outside of SAFE Launcher's sandboxing. If the app doesn't properly keep track of the data it creates, the user might be unable to retrieve and delete data stored by the app. For example, it might be possible that some of the data created by the app cannot be deleted by the user. It's the responsibility of the app to keep track of the data it creates using the low-level API.
SAFE Launcher displays a prompt with basic information about the app along with the requested permission (LOW_LEVEL_API
). You can authorize this request by clicking on "ALLOW".

After you authorize the request, the app receives an authorization token.
info::What is an authorization token?Authorization tokens are used to invoke APIs that require authorized access. These tokens are session based and thus will be valid only while SAFE Launcher is running.
Fetch the email data
The app needs a way to store your email data on the SAFE Network. One solution is to create a private structured data that will be used by the app to store your email ID and your saved emails. Let's call it the "root structured data".
Your root structured data is created using a random ID. In order to be able to retrieve your root structured data later, you need to store its ID in a config file. This config file will be stored in the app's root directory.
During the initialization process, the app checks if a config file is present in its root directory. If a config file is not found, the app creates a root structured data and a config file. If a config file is found, the app tries to fetch your root structured data.
Last updated
Was this helpful?