Global

Members

CONSTANTS :Object

Properties:
Name Type Description
NFS_FILE_MODE_OVERWRITE Number

1

NFS_FILE_MODE_APPEND Number

2

NFS_FILE_MODE_READ Number

4

NFS_FILE_START Number

0

NFS_FILE_END Number

0

USER_ANYONE Number

0

MD_METADATA_KEY String

'_metadata'

MD_ENTRIES_EMPTY Number

0

MD_PERMISSION_EMPTY Number

0

GET_NEXT_VERSION Number

0

Source:
Example
const safe = require( '@maidsafe/safe-node-app' );
console.log( safe.CONSTANTS );

VERSION :String

NPM package version

Source:
Example
const safe = require( '@maidsafe/safe-node-app' );
console.log( safe.VERSION );

Methods

fromAuthUri(appInfo, authUri, networkStateCallBackopt, optionsopt) → {Promise.<SAFEApp>}

If you have received a response URI (which you are allowed to store securely), you can directly get an authenticated or non-authenticated connection by using this helper function. Just provide said URI as the second value.

Parameters:
Name Type Attributes Default Description
appInfo AppInfo

the app info

authUri String

the URI coming back from the Authenticator

networkStateCallBack function <optional>
null

optional callback function to receive network state updates

options InitOptions <optional>

initialisation options

Source:
Example
const safe = require( '@maidsafe/safe-node-app' );

const appInfo = {
    id     : "net.maidsafe.example",
    name   : 'Example SAFE App',
    vendor : 'MaidSafe.net Ltd'
};

const authUri = 'safe-bmv0lm1hawrzywzllmv4yw1wbgvzlm1hawx0dxrvcmlhba:bAEAAAABFXM
LAYAAAAAAAAAAAAAQAAAAAAAAAAAA3HDT6MW2I2ONLHINSHZ7TEVB5UFR5FTGLRDYHTHOZBLE4VOY4YE
QAAAAAAAAAAAAUKVTAUCVAVRI62LYLDCED6247VDIRBKDKPOU5U7ACCHTBXW5QBMQAAAAAAAAAAABSR3
MIOM7N7RPHMJ77TKJLBMXZEMUJ7NQENDIDR7FUUNRHCEXLUJAAAAAAAAAAAACMUEZ2VZGSW7PHOGXKAO
J2WMDQYO7MTDYCLB53EPMHQEV53GN72MZI5WEHGPW7YXTWE77ZVEVQWL4SGKE7WYCGRUBY7S2KGYTRCL
V2EIAAAAAAAAAAAAHFMV3PPIJ3JRGRDFGQOTEEI3T4O6MDSUWWZD6M362LF32UERHHMIAAAAAAAAAAAB
6BXTI7JPJ7YPUDLF3GJ46TIYE4ZO5PMEU67E4H7P2ZOTX7K25GYAAAAAAAAAAAAAAAAAAAAAAAAAGNKL
O44TF4LNWEPNSFKM2MRO3UGACEFL4HEWU6NMLPKC4K5R54MGMDUAAAAAAAAAAYAAAAAAAAAAADQQ3KZO
AG5NUIDYGYZOKTDMD5HBBBBMVWEG6MOIBAAAAAAAAAAAAMAAAAAAAAAAAF64DVMJWGSY2OMFWWK44TAC
3W4XO3IWKE2BUI5Y5MFBEQNCMCORP7PPVLEUIEI2LU6S3IC6MDUAAAAAAAAAABEAAAAAAAAAAABS6M7T
CINUPY7M3LGYYUTD2U6RAVJIFXHZQ3JB6RY6BHQ3KERGYJDAAAAAAAAAAAAT32X5YMSXEEZEYS43IWVH
Y4VF4PEA6QCFK7OA3QAAQAAAAAAAAAAAAAAAAAAEAAAABHAAAAAAAAAAAGC4DQOMXW4ZLUFZWWC2LEO
NQWMZJOMV4GC3LQNRSXGLTNMFUWY5DVORXXE2LBNS2Z3UNQDNYQEF6AN57ANLTJZHORXGZACTZLKSSCR
R6HEV7BHAWTTGB2AAAAAAAAAAASAAAAAAAAAAAAFLWOZVEC4MW4KEPKPWUJJL6EDUMEEPDQS3RSWCYYF
67N3WIDS5IRQAAAAAAAAAAAGC2JU2Q4WPHO23VKPDSQMZLMHUTVC4C46LZV4HIAAUAAAAAAAAAAAAAAA
AAACAAAAABAAAAAAMAAAAAEAAAAAAI';

const networkStateCallback = (state) => {
    console.log('Network state change event: ', state);
};

const options = {
    log            : true,
    registerScheme : false
};

const asyncFn = async () => {
   const app = await safe.fromAuthUri(appInfo, authUri, networkStateCallBack, options);
};

(async) initialiseApp(appInfo, networkStateCallBackopt, optionsopt) → {Promise.<SAFEApp>}

The entry point to create a new app interface; your gateway to the SAFE Network.

Parameters:
Name Type Attributes Default Description
appInfo AppInfo
networkStateCallBack function <optional>
null

callback function to receive network state updates

options InitOptions <optional>

initialisation options

Source:
Throws:
Example
const safe = require( '@maidsafe/safe-node-app' );

const appInfo = {
    id     : 'net.maidsafe.example',
    name   : 'Example SAFE app',
    vendor : 'MaidSafe.net Ltd'
};

const networkStateCallback = (state) => {
    console.log('Network state change event: ', state);
};

const initialisationOptions = {
    log            : true,
    registerScheme : false
};

const asyncFn = async () => {
    const app = await safe.initialiseApp(appInfo, networkStateCallBack, initialisationOptions);
};

Type Definitions

AccountInfo :Object

Holds the information about the account.

Properties:
Name Type Description
mutations_done Number

number of mutations performed with this account

mutations_available Number

number of remaining mutations allowed for this account

Source:

AppInfo :Object

holds the information about this app, needed for authentication.

Properties:
Name Type Attributes Description
id String

unique identifier for the app (e.g. 'net.maidsafe.examples.mail-app')

name String

human readable name of the app (e.g. "Mail App")

vendor String

human readable name of the vendor (e.g. "MaidSafe Ltd.")

scope String <optional>

an optional scope of this instance

customExecPath String <optional>

an optional customised execution path to use when registering the URI with the system.

Source:

BlankNode :Object

Represents a [blank node](https://en.wikipedia.org/wiki/Blank_node} RDF resource

Properties:
Name Type Default Description
termType String BlankNode

BlankNode

value String n0

n0

id String n0

n0

Source:

CONFIG_PATH_ERROR :object

Informs you when config search path has failed to set, with specific reason.

Properties:
Name Type Description
code number

1016

msg function
Source:

Emulation :NFS

Emulations are abstraction helpers on top of MData

Source:

ERR_CONTENT_NOT_FOUND :Object

the content was not found at the address provided

Properties:
Name Type Description
code number

1023

msg function
Source:

ERR_DATA_GIVEN_ALREADY_EXISTS :object

Thrown natively when data already exists at the target address on network.

Properties:
Name Type Description
code number

104

msg string
Source:

ERR_FILE_NOT_FOUND :object

Thrown natively when NFS-style file not found.

Properties:
Name Type Description
code number

301

msg string
Source:

ERR_NO_SUCH_DATA :object

Thrown natively when data not found on network.

Properties:
Name Type Description
code number

103

msg string
Source:

ERR_NO_SUCH_ENTRY :object

Thrown natively when entry on found in MutableData.

Properties:
Name Type Description
code number

106

msg string
Source:

ERR_SERIALISING_DESERIALISING :object

Thrown natively when failing to encrypt/decrypt a MD entry

Properties:
Name Type Description
code number

1

msg string
Source:

ERR_SERVICE_NOT_FOUND :Object

the service/subname was not found

Properties:
Name Type Description
code number

1022

msg function
Source:

EXPERIMENTAL_API_DISABLED :object

Thrown when functions that are experimental APIs were not enabled but attempted to be used

Properties:
Name Type Description
code number

1021

msg string
Source:

FAILED_TO_LOAD_LIB :object

Thrown when a native library fails to load and which library.

Properties:
Name Type Description
code number

1000

msg function
Source:

InitOptions :Object

holds the additional intialisation options for the SAFEApp.

Properties:
Name Type Attributes Description
registerScheme Boolean <optional>

to register auth scheme with the OS. Defaults to true.

joinSchemes Array <optional>

to additionally register custom protocol schemes

log Boolean <optional>

to enable or disable back end logging. Defaults to true.

libPath String <optional>

path to the folder where the native libs can be found. Defaults to current folder path.

configPath String <optional>

set additional search path for the config files. E.g. log.toml and crust.config files will be also searched not only in the same folder where the native library is, but also in this additional search path.

forceUseMock Boolean <optional>

to force the use of mock routing regardless the NODE_ENV environment variable value. Defaults to false.

enableExperimentalApis Boolean <optional>

to enable the experimental APIs regardless if the --enable-experimental-apis flag was passed as argument to the application. Defaults to false.

Source:

INVALID_BYTE_RANGE :object

Thrown natively when attempting to fetch partial byte range of NFS-style file that is not within the total byte range. For example, this error is thrown if a file is 10 bytes long, however a byte range of 20 is requested.

Properties:
Name Type Description
code number

302

msg string
Source:

INVALID_PERM :object

Thrown when invalid permission is requested on container.

Properties:
Name Type Description
code number

1010

msg function
Source:

INVALID_PERMS_ARRAY :object

Thrown when share MD permissions is not an array.

Properties:
Name Type Description
code number

1005

msg string
Source:

INVALID_PUBNAME :Object

public name provided is not valid

Properties:
Name Type Description
code number

1025

msg function
Source:

INVALID_RDF_LOCATION :Object

RDF Location provided is not and object with name/typeTag

Properties:
Name Type Description
code number

1024

msg function
Source:

INVALID_SEC_KEY :object

Secret encryption key of improper length is provided to custom private MutableData

Properties:
Name Type Description
code number

1020

msg function
Source:

INVALID_SHARE_MD_PERMISSION :object

Informs of a specific object in a share MData permissions array that is malformed.

Properties:
Name Type Description
code number

1004

msg function
Source:

INVALID_SUBNAME :Object

RDF Location provided is not and object with name/typeTag

Properties:
Name Type Description
code number

1026

msg function
Source:

INVALID_URL :object

Please provide URL in string format.

Properties:
Name Type Description
code number

1007

msg string
Source:

LiteralNode :Object

Represents an literal RDF node resource such as a noun or date-time

Properties:
Name Type Attributes Default Description
termType String LiteralNode

LiteralNode

value String

Either string or XSD datatype

lang String <optional>

Optional i18n language tag

datatype NamedNode <optional>
Source:

LOGGER_INIT_ERROR :object

Logger initialisation failed.

Properties:
Name Type Description
code number

1015

msg function
Source:

MALFORMED_APP_INFO :object

Informs when AppInfo provided during initialisation is invalid.

Properties:
Name Type Description
code number

1002

msg string
Source:

MISSING_AUTH_URI :object

Thrown when attempting to connect without authorisation URI.

Properties:
Name Type Description
code number

1008

msg string
Source:

MISSING_CONTAINER_STRING :object

Thrown when attempting to get a container without specifying name with a string.

Properties:
Name Type Description
code number

1011

msg string
Source:

MISSING_PERMS_ARRAY :object

Argument should be an array object.

Properties:
Name Type Description
code number

1003

msg string
Source:

MISSING_PUB_ENC_KEY :object

Thrown when public encryption key is not provided as necessary function argument.

Properties:
Name Type Description
code number

1013

msg string
Source:

MISSING_RDF_ID :Object

RDF object does not have an ID.

Properties:
Name Type Description
code number

1027

msg function
Source:

MISSING_SEC_ENC_KEY :object

Thrown when secret encryption key is not provided as necessary function argument.

Properties:
Name Type Description
code number

1014

msg function
Source:

MISSING_URL :object

Please provide URL

Properties:
Name Type Description
code number

1006

msg string
Source:

NameAndTag :Object

Properties:
Name Type Description
name Buffer

the XoR-name/address on the network

typeTag Number

the type tag

xorUrl String

safe:// URL representing XOR address of MutableData, hashed with SHA3-256, and encoded as base32

Source:

NamedNode :Object

Represents an RDF node resource named by an absolute URI property

Properties:
Name Type Default Description
termType String NamedNode

NamedNode

value String

Absolute URI

uri String

Absolute URI

Source:

NetworkResource :Object

holds information about a network resource fetched from a safe://-URL

Properties:
Name Type Description
content Object

the network resource object

resourceType Object

the type of the resource fetched, e.g. 'NFS'

parsedPath Object

the parsed path from the provided URL

Source:

NON_AUTH_GRANTED_URI :object

Thrown when attempting extract granted access permissions from a URI which doesn't contain such information.

Properties:
Name Type Description
code number

1009

msg string
Source:

NON_DEV :object

Thrown when functions unique to testing environment are attempted to be used.

Properties:
Name Type Description
code number

1012

msg string
Source:

NONCE :object

Any string or buffer provided to private MutableData that is not 24 bytes in length will throw error.

Properties:
Name Type Description
code number

1018

msg function
Source:

SETUP_INCOMPLETE :object

Informs that app is not yet connected to network.

Properties:
Name Type Description
code number

1001

msg string
Source:

TYPE_TAG_NAN :object

Tag argument when creating private or public MutableData must be a number.

Properties:
Name Type Description
code number

1019

msg string
Source:

ValueVersion :Object

Properties:
Name Type Description
buf Buffer

the buffer with the value

version Number

the version Holds the informatation of a value of a MutableData

Source:

WebFetchOptions :Object

holds additional options for the webFetch function.

Properties:
Name Type Description
range Object

range of bytes to be retrieved. The start attribute is expected to be the start offset, while the end attribute of the range object the end position (both inclusive) to be retrieved, e.g. with range: { start: 2, end: 3 } the 3rd and 4th bytes of data will be retrieved. If end is not specified, the bytes retrived will be from the start offset untill the end of the file. The ranges values are also used to populate the Content-Range and Content-Length headers in the response.

Source:

XOR_NAME :object

Custom name used to create public or private MutableData must be 32 bytes in length.

Properties:
Name Type Description
code number

1017

msg function
Source: