Global

Members

(constant) COLOR :object

A selection of colors and text effects for console output.

Type:
  • object
Source:

This object provides human-readable names for constants used in ObjectGraphIteratorOptions. The object-graph-iterator has these three options how to treat ID hash links.

  • It can iterate over the ID object itself
  • It can find the latest version for the ID hash and continue iteration with the object the hash points to.
  • It can find all versions for the ID hash and continue iteration with all the object the hashes points to.
  • It can ignore ID references altogether
Type:
  • Object
Source:

The actual numeric values of the ID_LINK_ITERATION enum (object).

Type:
  • Set.<(0|1|2|3)>
Source:

(constant) HashLinkType :Object

Enum for the various reference hash types that can occur in a ONE object. They directly correspond to the reference types in module object-find-link's LinkedObjectsHashList

Type:
  • Object
Source:

Methods

createRandomNonce() → {Nonce}

Create a random nonce that can be used for all functions in this file.

Source:
Returns:

Type: Nonce

createSymmetricKey() → {SymmetricKey}

Create a random symmetric key.

Source:
Returns:

Type: SymmetricKey

createKeyPair() → {KeyPair}

Create a new public/secret keypair.

Source:
Returns:

Type: KeyPair

createRandomSalt(n) → {Salt}

Parameters:
Name Type Description
n number

Length of salt in bytes. The requirement of the salt is to be unique over all usages to prevent certain attacks that rely on precomputed values. The current consensus seems to be that 16 bytes (128 bit) should be enough. Some sources say it shouldn't be less than this value, so as default we use 16 bytes.

Create a suitable salt for the key derivation function in deriveSymmetricKeyFromSecret.

Source:
Returns:

Type: Salt

ensureSymmetricKey(data) → {SymmetricKey}

Parameters:
Name Type Description
data Uint8Array

The Uint8Array with the public key in it.

Ensure that it is a public key by comparing the length of the data.

Note that we cannot really check that it is a public key, we can just check that the single requirement is met - the length. If the length is right we cast it to the right type.

Source:
Returns:

Type: SymmetricKey

ensureSecretKey(data) → {SecretKey}

Parameters:
Name Type Description
data Uint8Array

The Uint8Array with the secret key in it.

Ensure that it is a secret key by comparing the length of the data.

Note that we cannot really check that it is a secret key, we can just check that the single requirement is met - the length. If the length is right we cast it to the right type.

Source:
Returns:

Type: SecretKey

ensurePublicKey(data) → {PublicKey}

Parameters:
Name Type Description
data Uint8Array

The Uint8Array with the public key in it.

Ensure that it is a public key by comparing the length of the data.

Note that we cannot really check that it is a public key, we can just check that the single requirement is met - the length. If the length is right we cast it to the right type.

Source:
Returns:

Type: PublicKey

ensureNonce(data) → {Nonce}

Parameters:
Name Type Description
data Uint8Array

The Uint8Array with the nonce in it.

Ensure that it is a nonce by comparing the length of the data.

Note that we cannot really check that it is a nonce, we can just check that the single requirement is met - the length. If the length is right we cast it to the right type.

Source:
Returns:

Type: Nonce

ensureSalt(data) → {Salt}

Parameters:
Name Type Description
data Uint8Array

The Uint8Array with the nonce in it.

Ensure that it is a suitable salt by ensuring that it is longer than a safe threshold.

Note that we cannot really check that it is a salt, we can just check that the single requirement is met - the length. If the length is right we cast it to the right type.

Source:
Returns:

Type: Salt

deriveSymmetricKeyFromKeypair(mySecretKey, otherPublicKey) → {SymmetricKey}

Parameters:
Name Type Description
mySecretKey SecretKey

My own secret key

otherPublicKey PublicKey

The others public key

Derive a symmetric key pair from the public key of somebody else and your own private key.

Source:
Returns:

Type: SymmetricKey

deriveSymmetricKeyFromSecret(secret, salt) → {Promise.<SymmetricKey>}

Parameters:
Name Type Description
secret string
salt Salt

Derive a symmetric key from a password.

Source:
Returns:

Type: Promise.<SymmetricKey>

symmetricEncrypt(data, symmetricKey, nonce) → {Uint8Array}

Parameters:
Name Type Description
data Uint8Array

The data to encrypt

symmetricKey SymmetricKey

The key used for encryption

nonce Nonce

The nonce to use for encryption

Encrypt data with a symmetric key.

Source:
Returns:
  • Encrypted data

Type: Uint8Array

symmetricEncryptAndEmbedNonce(data, symmetricKey, nonce) → {Uint8Array}

Parameters:
Name Type Description
data Uint8Array

The data to encrypt

symmetricKey SymmetricKey

The key used for encryption

nonce Nonce

The nonce to use for encryption and embedding. If not specified, then create a random nonce.

Encrypt data and store the nonce along the cypher in the result.

Storing the nonce along the cypher has the advantage, that you don't have to remember the nonce for decryption later.

Source:
Returns:
  • Nonce concatenated with the cypher

Type: Uint8Array

symmetricDecrypt(cypher, symmetricKey, nonce) → {Uint8Array}

Parameters:
Name Type Description
cypher Uint8Array

The encrypted data

symmetricKey SymmetricKey

The key used for decryption (must be the same that was used for decryption)

nonce Nonce

The same nonce for decryption (must be the same that was used for decryption)

Decrypt encrypted data.

Source:
Returns:
  • Decrypted data

Type: Uint8Array

symmetricDecryptWithEmbeddedNonce(cypherAndNonce, symmetricKey) → {Uint8Array}

Parameters:
Name Type Description
cypherAndNonce Uint8Array

cypher with embedded nonce that was generated by using '[symmetric]EncryptAndEmbedNonce'

symmetricKey SymmetricKey

The key used for decryption (must be the same that was used for decryption)

Decrypt encrypted data.

Since the nonce is embedded in the cypher there is no need to specify it.

Source:
Returns:
  • Decrypted data

Type: Uint8Array

encrypt(data, mySecretKey, otherPublicKey, nonce) → {Uint8Array}

Parameters:
Name Type Description
data Uint8Array

The data to encrypt

mySecretKey SecretKey

My own secret key

otherPublicKey PublicKey

The others public key

nonce Nonce

The nonce to use for encryption

Encrypt data with a symmetric key derived from a public key of someone else and my own secret key.

When you have two key pairs 'myKeypair' and 'otherKeypair', then the symmetric key used for encryption will be the same for (myKeypair.secretKey, otherKeyPair.publicKey) and (myKeypair.publicKey, otherKeyPair.secretKey). That's how two communication partners can encrypt / decrypt the same steam, because they can derive the same symmetric key, without having the same secret key.

Source:
Returns:
  • Encrypted data

Type: Uint8Array

encryptAndEmbedNonce(data, mySecretKey, otherPublicKey, nonce) → {Uint8Array}

Parameters:
Name Type Description
data Uint8Array

The data to encrypt

mySecretKey SecretKey

My own secret key

otherPublicKey PublicKey

The others public key

nonce Nonce

The nonce to use for encryption and embedding. If not specified, then create a random nonce.

Encrypt data and store the nonce along the cypher in the result.

Storing the nonce along the cypher has the advantage, that you don't have to remember the nonce for decryption later.

Source:
Returns:
  • Nonce concatenated with the cypher

Type: Uint8Array

decrypt(cypher, mySecretKey, otherPublicKey, nonce) → {Uint8Array}

Parameters:
Name Type Description
cypher Uint8Array

The encrypted data

mySecretKey SecretKey

My own secret key

otherPublicKey PublicKey

The others public key

nonce Nonce

The same nonce for decryption (must be the same that was used for decryption)

Decrypt encrypted data.

Source:
Returns:
  • Decrypted data

Type: Uint8Array

decryptWithEmbeddedNonce(cypherAndNonce, mySecretKey, otherPublicKey) → {Uint8Array}

Parameters:
Name Type Description
cypherAndNonce Uint8Array

cypher with embedded nonce that was generated by using '[symmetric]EncryptAndEmbedNonce'

mySecretKey SecretKey

My own secret key

otherPublicKey PublicKey

The others public key

Decrypt encrypted data.

Since the nonce is embedded in the cypher there is no need to specify it.

Source:
Returns:
  • Decrypted data

Type: Uint8Array

createSignKeyPair() → {SignKeyPair}

Create a new public/secret keypair for signing.

Source:
Returns:

Type: SignKeyPair

ensureSecretSignKey(data) → {SecretSignKey}

Parameters:
Name Type Description
data Uint8Array

The Uint8Array with the secret key in it.

Ensure that it is a secret sign key by comparing the length of the data.

Note that we cannot really check that it is a secret key, we can just check that the single requirement is met - the length. If the length is right we cast it to the right type.

Source:
Returns:

Type: SecretSignKey

ensurePublicSignKey(data) → {PublicSignKey}

Parameters:
Name Type Description
data Uint8Array

The Uint8Array with the public key in it.

Ensure that it is a public sign key by comparing the length of the data.

Note that we cannot really check that it is a public key, we can just check that the single requirement is met - the length. If the length is right we cast it to the right type.

Source:
Returns:

Type: PublicSignKey

sign(data, mySecretKey) → {Uint8Array}

Parameters:
Name Type Description
data Uint8Array

The data to sign

mySecretKey SecretSignKey

The secret key used to sign the data

Sign data.

Source:
Returns:

Type: Uint8Array

signatureVerify(data, signature, otherPublicKey) → {boolean}

Parameters:
Name Type Description
data Uint8Array

The data on which the signature was created.

signature Uint8Array

The signature that was created with the sign function

otherPublicKey PublicSignKey

The public key corresponding to the private key used to create the signature

Verify a signature.

Source:
Returns:

Type: boolean

storePublicKeys(owner, publicEncryptionKey, publicSignKey) → {Promise.<UnversionedObjectResult.<Keys>>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>
publicEncryptionKey PublicKey
publicSignKey PublicSignKey

Stores the public part of the keys.

Source:
Returns:

Type: Promise.<UnversionedObjectResult.<Keys>>

getPublicKeys(keysObjHash) → {Promise.<{publicEncryptionKey: PublicKey, publicSignKey: PublicSignKey}>}

Parameters:
Name Type Description
keysObjHash SHA256Hash.<Keys>

Get the public keys from the Keys object.

Source:
Returns:

Type: Promise.<{publicEncryptionKey: PublicKey, publicSignKey: PublicSignKey}>

storeKeys(owner, encryptionKeyPair, signKeyPair, masterKeyManager) → {Promise.<void>}

Parameters:
Name Type Description
owner SHA256IdHash.<Person>
encryptionKeyPair KeyPair
signKeyPair KeyPair
masterKeyManager MasterKeyManager

Store the passed key pairs in the key storage.

The public keys will be stores as 'Keys' object, the secret keys will be stored in the 'private' section of the OneDb.

Source:
Returns:

Type: Promise.<void>

storeNewRandomKeys(owner, masterKeyManager) → {Promise.<UnversionedObjectResult.<Keys>>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>
masterKeyManager MasterKeyManager

Create a new random set of keys for the specified owner.

Source:
Returns:

Type: Promise.<UnversionedObjectResult.<Keys>>

getKeyPairs(keysObjHash, masterKeyManager) → {Promise.<{encryptionKeyPair: KeyPair, signKeyPair: SignKeyPair}>}

Parameters:
Name Type Description
keysObjHash SHA256Hash.<Keys>
masterKeyManager MasterKeyManager

Get the person encryption and sign key-pairs.

Source:
Returns:

Type: Promise.<{encryptionKeyPair: KeyPair, signKeyPair: SignKeyPair}>

createCryptoApi(keys, masterKeyManager) → {Promise.<CryptoApi>}

Parameters:
Name Type Description
keys SHA256Hash.<Keys>
masterKeyManager MasterKeyManager
Source:
Returns:

Type: Promise.<CryptoApi>

unlockOrCreateKeyChain(secret) → {Promise.<void>}

Parameters:
Name Type Description
secret string

Unlock the keychain.

This will derive a key from the secret and store the master key in memory.

Source:
Returns:

Type: Promise.<void>

lockKeyChain()

Lock the keychain.

The master key is purged from memory and all other keychain functions won't work anymore.

Source:

changeKeyChainSecret(oldSecret, newSecret)

Parameters:
Name Type Description
oldSecret string
newSecret string

Changes the secret used to unlock the keychain.

Source:

createCryptoApiFromDefaultKeys(owner) → {Promise.<CryptoApi>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>

Create a crypto functions for a person or instance.

Source:
Returns:

Type: Promise.<CryptoApi>

getListOfKeys(owner) → {Promise.<Array.<{keys: SHA256Hash.<Keys>, complete: boolean, default: boolean}>>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>

Get a list of all keys associated with this owner.

Note: Incomplete keys are not trustworthy. The Keys object could have been sent from anyone.

Source:
Returns:

Type: Promise.<Array.<{keys: SHA256Hash.<Keys>, complete: boolean, default: boolean}>>

getListOfIncompleteKeys(owner) → {Promise.<Array.<SHA256Hash.<Keys>>>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>

Get incomplete keys associated with a person.

Incomplete means, that you do not possess secret keys for this keys object.

Note: The keys are not trustworthy. The Keys object could have been sent from anyone.

Source:
Returns:

Type: Promise.<Array.<SHA256Hash.<Keys>>>

getListOfCompleteKeys(owner) → {Promise.<Array.<{keys: SHA256Hash.<Keys>, default: boolean}>>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>

Get a list of complete keys associated with a person.

Note: You can trust complete keys, because the secret part can only be written by yourself.

Source:
Returns:

Type: Promise.<Array.<{keys: SHA256Hash.<Keys>, default: boolean}>>

getDefaultKeys(owner) → {Promise.<SHA256Hash.<Keys>>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>

Get the person keys for which we have the secret part (hence complete)

Source:
Returns:

Type: Promise.<SHA256Hash.<Keys>>

hasDefaultKeys(owner) → {Promise.<boolean>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>

Returns whether we have a complete keypair for a person.

'Complete' means that we have public and secret keys.

Source:
Returns:

Type: Promise.<boolean>

createDefaultKeys(owner, encryptionKeyPair, signKeyPair) → {Promise.<SHA256Hash.<Keys>>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>
encryptionKeyPair KeyPair

If keypair is omitted, create a random keypair

signKeyPair SignKeyPair

If keypair is omitted, create a random keypair

Create new default encryption and sign key pairs for a person.

If a default keypair already exists, this function will fail. At the moment this is to ensure, that we only have a single private key for a person (will change in the future - but makes things easier right now).

Source:
Returns:

Type: Promise.<SHA256Hash.<Keys>>

createDefaultKeysIfNotExist(owner, encryptionKeyPair, signKeyPair) → {Promise.<SHA256Hash.<Keys>>}

Parameters:
Name Type Description
owner SHA256IdHash.<(Person|Instance)>
encryptionKeyPair KeyPair
signKeyPair SignKeyPair

Same as createDefaultKeys() but skip if default keys already exist.

Source:
Returns:

Type: Promise.<SHA256Hash.<Keys>>

Type Definitions

Access

There are two Access objects that are identical in structure and purpose except for in name: 'Access' points to immutable graphs.

Example

Javascript representation:

const obj = {
    $type$: 'Access',
    object: hash,
    person: [personIdHash]
};

HTML microdata representation:

<div itemscope itemtype="//refin.io/Access">
  <a itemprop="object" href="${hash}">${hash}</a>
  <a itemprop="person" href="${personIdHash}">${personIdHash}</a>
</span>
Type:
  • object
Properties:
Name Type Attributes Description
type 'Access'

Fixed string 'Access'

object SHA256Hash

A versioned or unversioned object link to a concrete versioned or unversioned object that the access rights are being set for.

person Array.<SHA256IdHash> <optional>

An array of ID references to Person objects.

group Array.<SHA256IdHash> <optional>

An array of ID references to Group objects. Only the latest version of a group is granted access!

Source:

AccessibleObjectsRequestOptions

Options object for Chum importer function chum-base.sendAccessibleObjectsEventsRequest

Type:
  • object
Properties:
Name Type Attributes Default Description
lastChumTimestamp number <optional>

Numeric millisecond timestamp (since 1/1/1970) to only list accessible objects created later than this

keepRunning boolean <optional>
false

Triggers the sending of update events while the websocket connection and the Chum exchange remain active, informing the Chum importer of any newly created objects that it has access to (may overlap with the initial list of accessible objects depending on millisecond timing - but the Chum importer has double-download prevention)

maxNotificationDelay number

When keepRunning is true and the full synchronization is over, what should be the maximum delay between new accessible objects being created and notification events sent to us? The remote instance is going to collect all new accessible hashes and only sends them after waiting for this amount of milliseconds. If there are a lot of new hashes, exceeding a hard-coded threshold, it sends them right away though. If you require fast notifications about rare new-accessible-object events you can set the delay low (1 ms is the minimum), if it is not urgent you can set the delay higher and let the remote exporter accumulate more hashes. The delay does not have to be higher than a few seconds, because it will make less and less of a difference very quickly with increasing values.

Source:

AllSettled

Return value of promises passed through Promise.allSettled The status is 'fulfilled' and there is value with the value the promise resolved with, or the status is 'rejected' and there is a reason with the value of the promise's rejection, usually an Error object.

Type:
  • object
Properties:
Name Type Attributes Description
value * <optional>

The value of the individual settled promise if it was fulfilled

reason Error <optional>

Should be an Error object as a best practice, but not mandatory

status 'fulfilled' | 'rejected'
Source:

AllSettledStatus

The possible string constant values of Promise.allSettled results. It is made available as export from util/promise to avoid inline repetition of these constants.

Type:
  • object
Properties:
Name Type Description
FULFILLED 'fulfilled'
REJECTED 'rejected'
Source:

AnyObjectCreation

A union type of versioned and unversioned object creation result objects, for any ONE object type.

Type:
Source:

ArrayValue

This object is part of ValueType and describes the value-type of an Array Object.

Type:
  • object
Properties:
Name Type Description
type 'array'
item ValueType
Source:

ArrayValueMap

An API-object interface to a Map<K, V[]> object created by util/function.createArrayValueMap (also see the description there) whose values are arrays of values of type <V>. Provides a function to add values to the array identified by a given key. The purpose is to serve as an accumulator of values under a set of keys, with 1...n values per key (0 values means no entry, i.e. no key, there is no key with no value).

Type:
  • object
Properties:
Name Type Description
mapObj Map.<K, Array.<V>>

The underlying Map object exposed - the ArrayValueMap is not meant to be an encapsulating abstraction but a convenience function layer providing two additional functions for Map objects

add function

Add a new value for a given key. If there is no entry in the Map for this key yet, a new Array with the new value in it is created for the key. If there already is an entry - which is an Array - the value is added to it.

map function

A function of type <U> (fn: (K, V[]) => U): Map<K, U> that creates a Map object with the same keys by applying the given callback function to each value in the map. The callback function receives the key and the array of values as arguments. The key and the value returned by the callback are used to build the new Map object (not wrapped as ArrayValueMap, just the plain Map).

mapAsync function

Same as the map function but for callback functions that return a promise. The new (plain) Map object is available through the returned promise.

Source:

BLOB

This is a virtual type representing BLOB files. It is used as a generic parameter type for SHA256Hash and SHA256IdHash.

Type:
  • object
Source:

BagValue

This object is part of ValueType and describes the value-type of a Bag Object. A "bag" is a data-structure that implements a multiset, which is a set that allows multiple (duplicates). In the microdata the sequence of items is ordered by ONE.

Type:
  • object
Properties:
Name Type Description
type 'bag'
item ValueType
Source:

BooleanValue

This object is part of ValueType and describes the value-type of a Boolean.

Type:
  • object
Properties:
Name Type Description
type 'boolean'
Source:

CLOB

This is a virtual type representing CLOB (UTF-8 text) files. It is used as a generic parameter type for SHA256Hash and SHA256IdHash.

Type:
  • object
Source:

Chum

A Chum object defines a filter for exchanging data with other instances. Initially it only filters by persons.

Example

<div itemscope itemtype="//refin.io/Chum">
  <span itemprop="name">ThisChumsName</span>
  <span itemprop="instance">${name1}</span>
  <span itemprop="instance">${name2}</span>
  <span itemprop="person">${hash1}</span>
  <span itemprop="person">${hash2}</span>
  <span itemprop="highestRemoteTimestamp">${timestamp1}</span>
  ...
</span>
Type:
  • object
Properties:
Name Type Attributes Description
$type$ 'Chum'

Fixed string 'Chum'

name string
instance Array.<string>

A pair of instance names

person Array.<SHA256IdHash>

A pair of Person ID hashes. The first one is the one the local instance (owner of the Chum object) used for authentication to the remote instance, the second one is the one the remote instance used to do the same for the local instance.

highestRemoteTimestamp number

A numeric timestamp specifying a date-time on the remote system. We can be sure to have all objects accessible to us created or made accessible to us before that time. NOTE: If older objects are made accessible it will be through an object created at a later time. Since this cutoff date-time specifies the root node of an accessible directed graph, which by necessity (hash links!) has to be created after all others, we get older objects linked from such a root node in any case. This timestamp is only used to filter root nodes.

AtoBObjects Array.<SHA256Hash>

Record of all transfers from A to B

AtoBIdObjects Array.<SHA256IdHash>

Record of all ID transfers from A to B

AtoBBlob Array.<SHA256Hash>

Record of all BLOB transfers from A to B

AtoBClob Array.<SHA256Hash>

Record of all CLOB transfers from A to B

BtoAObjects Array.<SHA256Hash>

Record of all transfers from B to A

BtoAIdObjects Array.<SHA256IdHash>

Record of all ID transfers from B to A

BtoABlob Array.<SHA256Hash>

Record of all BLOB transfers from B to A

BtoAClob Array.<SHA256Hash>

Record of all CLOB transfers from B to A

BtoAExists number

How many hashes we already had and did not need to import

errors Array.<Error>

Record of exceptions encountered while running

unacknowledged Set.<SHA256Hash> <optional>

List of hashes of files sent for which we did not receive an acknowledgement that it was successfully stored by the importer. NOTE: These hashes don't cause any reverse map entries to be created - this field is somewhat optional and "FYI". The main fields are the other transfers-recording fields.

statistics WebsocketStatistics <optional>

Data about the exchange such as bytes sent/received

Source:

EXPORTER_EVENT_TYPES

The chum-exporter may send event notifications of this type to the chum-importer through the websocket connection.

Type:
  • object
Properties:
Name Type Description
FULL_SYNC 1
ERROR 2
Source:

ElementType

This is a TypeScript helper type that extracts the type of the elements of certain container types. If the container is read-only and its elements are known this results in a union type of those elements.

Examples:

const set = new Set(['a', 'b', 'c'] as const);
// "a" | "b" | "c"
type SSS = ElementType<typeof set>;

const arr = ['aa', 'bb', 'cc'] as const;
// // "aa" | "bb" | "cc"
type AAA = ElementType<typeof arr>;

const map = new Map([['a', 1], ['b', 2], ['c', 42]] as const);
// 1 | 2 | 42
type MMM = ElementType<typeof map>;
Type:
  • *
Source:

EventHandlerCb(data) → {undefined|Promise.<undefined>}

Parameters:
Name Type Description
data T

Event handler callback functions

Source:
Returns:

Type: undefined | Promise.<undefined>

ExporterEvent

The union of all event types that the chum-exporter can send to the chum-importer.

Type:
  • object
Source:

ExporterEventError

Type:
  • object
Properties:
Name Type Description
type 2
code string
message string
Source:

ExporterEventFullSync

This event is sent when the chum-exporter has iterated through all accessible objects found in the initial full scan. It is mostly useful for non-ending keepRunning:true chums, although if the receiving importer's ONE instance still is not done with its own chum-exporter task of sending accessible objects this event still appears before the chum exchange is over. When both sides' chum-exporter sent this event a full-sync chum without keepRunning:true will be over.

Type:
  • object
Properties:
Name Type Description
type 1
Source:

FileCreation

Return result object of creating CLOB and BLOB file objects.

Type:
  • object
Properties:
Name Type Description
hash SHA256Hash

The SHA-256 hash of the contents of a versioned ONE object

status FileCreationStatus

A string constant showing whether the file already existed or if it had to be created.

Source:

FileCreationStatus

This defines the creation status string constants for files such as ONE microdata files, CLOBs and BLOBs. This overlaps with the status for unversioned ONE objects because those are simple text files for the low-level storage API that does not deal with ONE objects but simple with "files" in the most general sense.

To check a status don't use the string constants directly (they could be changed!). Use storage module's exported CREATION_STATUS enum (static frozen object) with the properties NEW and EXISTS.

Usage

Instead of using these strings directly please use the storage-base-common.CREATION_STATUS export of

import {StorageBaseCommon} from 'storage-base-common');

// StorageBaseCommon.CREATION_STATUS.NEW
// StorageBaseCommon.CREATION_STATUS.EXISTS
Type:
  • "new" | "exists"
Source:

Group

Access objects link to Group objects to grant access rights.

Example

Javascript representation:

const obj = {
    $type$: 'Group',
    name: name,
    person: [Person1-idHash, Person2-idHash]
};

HTML microdata representation:

<span itemprop="item" itemscope itemtype="//refin.io/Group">
  <span itemprop="name">${name}</span>
  <span itemprop="person">${Person1-ID-hash}</span>
  <span itemprop="person">${Person2-ID-hash}</span>
</span>
Type:
  • object
Properties:
Name Type Description
$type$ 'Group'

Fixed string 'Group'

name string
person Array.<SHA256IdHash>
Source:

HashTypes

The union of all "name" property values of all Recipes used by one.core and the application plus 'BLOB' for binary objects and 'CLOB' for UTF-8 objects.

Type:
Source:

HexString

This type represents a hexadecimal string.

This hexadecimal string is expected to have an even number of elements, so that it can be converted to binary representation: Two hexadecimal bytes result in one byte in binary representation.

Note that this is a type that cannot be constructed, just cast to. This is a Typescript trick to have a special kind of string.

Type:
  • string
Source:

IdAccess

Same as Access object but instead of a reference to a concrete object it has a reference to an ID object of a versioned object and grants access to all current and future versions of the object.

Type:
  • object
Properties:
Name Type Attributes Description
$type$ 'IdAccess'

Fixed string 'IdAccess' (which is mutable, since the ID reference also points to any future versions of the object) depending on if the directed graph of ONE objects it points to an ID object.

id SHA256IdHash

A reference to all versions of an ID object that the access rights are being set for.

person Array.<SHA256IdHash> <optional>

An array of ID references to Person objects.

group Array.<SHA256IdHash> <optional>

An array of ID references to Group objects. Only the latest version of a group is granted access!

Source:

IdFileCreation

Return result object of creating ID objects with function storeIdObject(obj: OneVersionedObjectTypes | OneIdObjectTypes).

Type:
  • object
Properties:
Name Type Description
idHash SHA256IdHash

The SHA-256 hash of the ID ONE object

status FileCreationStatus

A string constant showing whether the file already existed or if it had to be created.

Source:

InitStorageOptions

Options for the initStorage function in module system/storage-base. The function is called by initInstance.

Type:
  • object
Source:

Instance

An Instance object describes one instance of the app. Multiple instances can co-exist on one, and even in the same disk space. Both instances would share the same directory and much of their respective data.

The encryption key pair is generated by TweetNaCl.js and is stored in two Base 64 encoded strings:

Example

Javascript representation:

const obj = {
    $type$: 'Instance',
    name: 'InstanceName',
    owner: personIdHash,
    publicKey: blobHash,
    secretKey: blobHash,
    module: [moduleHash]
};

HTML microdata representation:

<div itemscope itemtype="//refin.io/Instance">
  <div itemscope="name">InstanceName</span>
  <span itemprop="owner">${personIdHash}</span>
  <span itemprop="publicKey">${publicKey}</span>
  <a itemprop="module" href="${moduleHash}">${module1-hash}</a>
</span>
Type:
  • object
Properties:
Name Type Description
$type$ 'Instance'
name string

The name of the instance chosen by the user

owner SHA256IdHash

A reference to a Person ID object

recipe Array.<SHA256Hash>

A list of ONE object recipes

module Array.<SHA256Hash>

A list of code modules

enabledReverseMapTypes Map.<OneObjectTypeNames, (null|Set.<string>)>

A Map object with ONE object type names as keys and an array of "itemprop" properties from the recipe for that particular ONE object type for which reverse maps should be written. For all other types and/or properties not mentioned in this Map reverse map entries are not created.

enabledReverseMapTypesForIdObjects Map.<OneObjectTypeNamesForIdObjects, (null|Set.<string>)>

A Map object with ONE object type names as keys and an array of "itemprop" properties from the recipe for that particular ONE object type for which ID object reverse maps should be written. For all other types and/or properties not mentioned in this Map reverse map entries are not created.

Source:

InstanceOptions

Type:
  • object
Properties:
Name Type Attributes Description
name string

A name given to the instance by the user

email string

The email address of the user owning this ONE application instance

secret string

A secret used to authenticate the given email ID. The string will be normalized.

ownerName string <optional>

The name of the owner (optional)

personEncryptionKeyPair KeyPair <optional>

Encryption keypair used for instance owner. If provided, all four keys must be provided together. In that case no new keys will be created upon instance creation, instead these keys will be used. The keys are only used for a new instance. If they are provided but an instance already exists nothing will happen.

personSignKeyPair SignKeyPair <optional>

Sign keypair used for instance owner. Also see the description for personEncryptionKeyPair.

instanceEncryptionKeyPair KeyPair <optional>

Encryption keypair used for instance. Also see the description for personEncryptionKeyPair.

instanceSignKeyPair SignKeyPair <optional>

Sign keypair used for instance. Also see the description for personEncryptionKeyPair.

wipeStorage boolean <optional>

If true all files in storage will be deleted when the instance is initialized. All files means every single file. Storage is wiped clean.

encryptStorage boolean <optional>

On supporting platforms (browser) filenames and file contents can be encrypted. secret must be a string and not null.

directory string <optional>

For filesystem based storage (node.js) the directory where this ONE instances can store and read its objects. On browsers the name of the IndexedDB database, if this is not set a default of "OneDB" is used. This option is unused on mobile (react-native).

nHashCharsForSubDirs number <optional>

In "object" storage, the first n characters of o files name - a hexadecimal SHA-256 hash string - are used to locate the file in a subdirectory of that name. For example, if a file name (hash) starts with "0fe123...." and n=2, then the file will be located not in directory objects/ but in directory objects/0f/. This hierarchical storage option is only offered on some platforms. When this option has a number higher than 0 on a platform that does not support it an Error is thrown.

storageInitTimeout number <optional>

The browser platform accepts this parameter to time out the indexedDB.open() attempt in case the request blocks (found on Safari). Default is 1000ms. This can or should be used together with one.core/util/promise method retry. On other platforms this parameter is ignored.

initialRecipes Array.<Recipe> <optional>

An optional array of Recipe ONE objects. This option is only used for initial Instance object creation. If there is an existing Instance it is simply ignored. You can use registerRecipes to add recipes to an existing instance.

initiallyEnabledReverseMapTypes Map.<OneObjectTypeNames, (null|Set.<string>)> <optional>

A Map object with ONE object type names as keys and an array of "itemprop" properties from the recipe for that particular ONE object type for which reverse maps should be written. For all other types and/or properties not mentioned in this Map reverse map entries are not created. This option is only used for initial Instance object creation. If there is an existing Instance it is simply ignored. Right now this option cannot be changed after instance creation. This is a feature to be added later, when this is changed the whole storage has to be iterated over to create any missing reverse maps if they are added later.

initiallyEnabledReverseMapTypesForIdObjects Map.<OneObjectTypeNamesForIdObjects, (null|Set.<string>)> <optional>

A Map object with ONE object type names as keys and an array of "itemprop" properties from the recipe for that particular ONE object type for which ID object reverse maps should be written. For all other types and/or properties not mentioned in this Map reverse map entries are not created. This option is only used for initial Instance object creation. If there is an existing Instance it is simply ignored. Right now this option cannot be changed after instance creation. This is a feature to be added later, when this is changed the whole storage has to be iterated over to create any missing reverse maps if they are added later.

Source:

InstanceUpdateOptions

Options object for instance-updater, which updates the currently active instance.

Type:
  • object
Properties:
Name Type Attributes Default Description
recipes Array.<Recipe> <optional>
[]
modules Array.<Module> <optional>
[]
Source:

IntegerValue

This object is part of ValueType and describes the value-type of an Integer.

Type:
  • object
Properties:
Name Type Attributes Description
type 'integer'
max number <optional>
min number <optional>
Source:

Keys

This object stores the public encryption and sign keys for a given Instance or Person ID. The secret keys are stored in a special non-shared private storage area.

Type:
  • object
Properties:
Name Type Description
$type$ 'Keys'
owner SHA256IdHash
publicKey HexString
publicSignKey HexString
Source:

LinkedObjectsHashAndItempropList

This type is for an object that lists the collected links of one or more ONE objects, separated into ONE object references (versioned, unversioned or ID-references) and BLOB or CLOB links (only a hash, links to files that are not ONE microdata objects).

The way this type is used the lists may include all or only a subset of the links found in a ONE object. All links are present in the lists returned by findLinkedHashesInObject, the Chum-sync modules using this type list only those links that had to be transferred from the remote instance.

Note that if a hash is referenced more than once it will also be included in the array for its type more than once. We decided not to filter duplicates because that would mean hiding information (how many links to the same hash there are).

Type:
  • object
Properties:
Name Type Description
references Array.<{itemprop:string, hash:SHA256Hash}>
idReferences Array.<{itemprop:string, hash:SHA256IdHash}>
blobs Array.<{itemprop:string, hash:SHA256Hash.<'BLOB'>}>
clobs Array.<{itemprop:string, hash:SHA256Hash.<'CLOB'>}>
Source:

LinkedObjectsHashList

This type is for an object that lists the collected links of one or more ONE objects, separated into ONE object references (versioned, unversioned or ID-references) and BLOB or CLOB links (only a hash, links to files that are not ONE microdata objects).

The way this type is used the lists may include all or only a subset of the links found in a ONE object. All links are present in the lists returned by findLinkedHashesInObject, the Chum-sync modules using this type list only those links that had to be transferred from the remote instance.

Note that if a hash is referenced more than once it will also be included in the array for its type more than once. We decided not to filter duplicates because that would mean hiding information (how many links to the same hash there are).

Type:
  • object
Properties:
Name Type Description
references Array.<SHA256Hash.<OneObjectTypeNames>>

Array of SHA-256 hashes collected from Reference objects

idReferences Array.<SHA256IdHash.<OneVersionedObjectTypeNames>>

Array of SHA-256 hashes collected from ID hash links

blobs Array.<SHA256Hash.<'BLOB'>>

Array of SHA-256 hashes of binary files collected from hash links to BLOB files

clobs Array.<SHA256Hash.<'CLOB'>>

Array of SHA-256 hashes of UTF-8 text files collected from hash links to CLOB files

Source:

LruMapObj

Implementation of an LRU collection with a given maximum size. Internally it uses a Map object and uses the fact that that object's iterator uses insertion order. Each time a key is accessed - get or set - it is removed and reinserted. That means that at the beginning of the Map iterator there will always be the least recently used item. See util/lru-map

Type:
  • object
Properties:
Name Type Description
$Iterator function

The iterator [Symbol.iterator] of the underlying Map object so that this object can be used e.g. in a for...of loop. The iterator is obtained by calling entries() on the underlying Map object.

get function

(K) => void | V>

set function

(K, V) => void

clear function

() => void

Source:

MapValue

This object is part of ValueType and describes the value-type of a Map Object.

Type:
  • object
Properties:
Name Type Description
type 'map'
key PrimitiveValueTypes | ReferenceValueTypes
value ValueType
Source:

MessageBusObj

An API-object that provides several functions bound to a context established by the function that created the API-object.

Example

// Result is a MessageBusObj
import {create} from './message-bus';
const MessageBus = create('some-id-string');
Type:
  • object
Properties:
Name Type Description
id string

The ID used on the message bus to identify messages sent through this MessageBus object.

on function

(type: string, fn: MessageHandlerCb) => void — Register a callback for a given type of message

once function

(type: string, fn: MessageHandlerCb) => void — Like on but the callback is removed after it is called

remove function

(type: string, fn: MessageHandlerCb) => void — Remove the given callback function

send function

(type: string, ...messages: unknown[]) => void — Send a message of the given type. The arguments must match what potential recipients of that type would expect.

Source:

Module

Example

Javascript representation:

const obj = {
    $type$: 'Module',
    name: '@module/imap-mailbox-handler',
    version: '1.0',
    requires: [
        '@module/imap-promisifier.js',
        '@one/message-bus.js',
        '@one/storage.js'
    ],
    code: clobHash
};

HTML microdata representation:

<div itemscope itemtype="//refin.io/Module">
  <span itemprop="name">@module/imap-mailbox-handler</span>
  <span itemprop="version">1.0</span>
  <span itemprop="requires">@module/imap-promisifier.js</span>
  <span itemprop="requires">lib/message-bus.js</span>
  <span itemprop="requires">lib/storage.js</span>
  <span itemprop="code">${CLOB-hash}</span>
</span>
Type:
  • object
Properties:
Name Type Attributes Description
$type$ 'Module'
name string

The name that will be used by other modules to request this module

provides Array.<string> <optional>
requires Array.<string> <optional>

The modules called from this module, extracted from require() or import calls from its code

version string <optional>

An optional version string

code SHA256Hash <optional>

Link to a UTF-8 CLOB with the Javascript code for this module

Source:

NeverFailAsyncErrorWrappedFn() → {Promise.<undefined>}

The function returned by calling the NeverFailAsyncErrorWrapper function returned by util/function.createNeverFailAsyncErrorWrapper. For an in-depth explanation see util/function.createNeverFailAsyncErrorWrapper

Source:
Returns:

Returns a promise that always resolves with undefined and never rejects.

Type: Promise.<undefined>

NeverFailAsyncErrorWrapper(fn) → {NeverFailAsyncErrorWrappedFn}

Parameters:
Name Type Description
fn function

The function returned by util/function.createNeverFailAsyncErrorWrapper For an in-depth explanation see util/function.createNeverFailAsyncErrorWrapper

Source:
Returns:

Returns a NeverFailAsyncErrorWrappedFn function that takes a function and wraps it

Type: NeverFailAsyncErrorWrappedFn

NumberValue

This object is part of ValueType and describes the value-type of a Number.

Type:
  • object
Properties:
Name Type Attributes Description
type 'number'
max number <optional>
min number <optional>
Source:

ObjectValue

This object is part of ValueType and describes the value-type of an ONE Object.

Type:
  • object
Properties:
Name Type Description
type 'object'
rules Array.<RecipeRule>
Source:

OneEventSource

Object type created by the util/event-source.createEventSource method.

Type:
  • object
Properties:
Name Type Description
consumer OneEventSourceConsumer

Object with functions for the intended consumer of events. This object can be exposed on API-object property appropriately named to reflect the event type, e.g. "onData", "onError".

onListenerChange null | function

WRITABLE — Default is null. Assign an event handler function that gets called every time a listener function is added or removed. The event handler receives the old and the new number of listeners as arguments, as well as the event handler function that was added or removed (in that order).

dispatch function

A non-public function to send an event to all subscribed listeners. Any arguments given to the function are given as-is to all event handler functions.

dispatchAsync function

A non-public function to send an event to all subscribed listeners and await and return the possibly Promise-based return values. Any arguments given to the function are given as-is to all event handler functions.

Source:

OneEventSourceConsumer

Object with functions for the intended consumer of events. This object is part of the OneEventSource object type created by the util/event-source.createEventSource method.

Type:
  • object
Properties:
Name Type Description
OneEventSource.consumer.addListener function

Add an event handler function, unless this exact function is already subscribed, in which case an error is thrown. The function returns a function that removes this listener function.

OneEventSource.consumer.removeListener function

Remove an event handler function, unless the given function is not subscribed, in which case an error is thrown

Source:

OneIdObjectInterfaces

A meta-type defined in one.core/@OneObjectInterfaces.d.ts in module namespace "@OneObjectInterfaces" that can be extended through TypeScript's declaration merging feature to include ONE object definitions defined through recipes of the application.

In order to add your own project's ID ONE object types create similar .d.ts file, declare a module namespace @OneObjectInterfaces and export an interface declaration for OneIdObjectInterfaces just as in the one.core file. If you tell tsc (TypeScript server) via your tsconfig.json to include both one.core's and your own definition files it will merge the declarations into one.

This interface contains the names (as keys) and TypeScript interface types (as values) of all ID objects. Unless you need to refer to the ID object types by name it probably is best to use TypeScript's built-in Pick<T, K> helper to pick the ID object properties from the full versioned object types. Usually only the latter will have named interfaces. If necessary, in .ts code files you can always refer to ID object interfaces using OneIdObjectInterfaces[TypeId], where TypeId is the appropriate string key. For key names one.core follows the rule to take the name of the versioned object type and append, for example, 'Id'.

Note that ID object interfaces are special and must be used explicitly, they are not part in any of the unions or merged definitions of ONE object types. Except for in rare places ID object types are not to be permitted even when the respective versioned object types are, because the ID object types may miss properties that are not ID properties but still non-optional. ID objects are only used to calculate ID hashes and never written, nor should they be used for processing.

That is why the name (key) you choose for the ID object type may be arbitrary, it is not used as type name. Only the values are used, i.e. the ID object declarations.

This key/value interface still is necessary, the declarations cannot just be written directly to OneIdObjectTypes: Declaration merging of ID object types declared for the application requires this key/value structure.

Type:
  • object
Properties:
Name Type Description
type-name ONE-object-interface-type

Use the same string literal as used for the "$type$" property in your ONE object(s) as key and the TypeScript interface definition name as the value

Source:

OneIdObjectTypes

This union is obtained by extracting all values from OneIdObjectInterfaces.

Type:
  • AccessId | ChumId | GroupId | InstanceId | ModuleId | PersonId | RecipeId | AllYourIdObjectTypes
Source:

OneObjectInterfaces

Defined in one.core's @OneObjectInterfaces.d.ts file, this is the result of merging the declarations of OneUnversionedObjectInterfaces, OneVersionedObjectInterfaces.

This is a key/value map object where the keys are all valid ONE object type names, and the values are the interface type (i.e. ONE object) definitions.

ID object interface definitions are not included in this map because except for in rare places ID object types are not to be permitted even when the respective versioned object types are, because the ID object types may miss properties that are not ID properties but still non-optional. ID objects are only used to calculate ID hashes and never written, nor should they be used for processing.

Type:
  • object
Source:

OneObjectTypeNames

The union of all "name" property values of all Recipes used by one.core and the application. The type is created as union of OneUnversionedObjectTypeNames and OneVersionedObjectTypeNames.

Type:
Source:

OneObjectTypes

The union of all interfaces of ONE object types used by one.core and the application. The type is created as union of OneUnversionedObjectTypes and OneVersionedObjectTypes.

Type:
Source:

OneUnversionedObjectInterfaces

A meta-type defined in one.core/[src|lib]/@OneObjectInterfaces.d.ts in module namespace "@OneObjectInterfaces" that can be extended through TypeScript's declaration merging feature to include ONE object definitions defined through recipes of the application.

In order to add your own project's unversioned ONE object types create similar .d.ts file, declare a module namespace @OneObjectInterfaces and export an interface declaration for OneUnversionedObjectInterfaces just as in the one.core file. If you tell tsc (TypeScript server) via your tsconfig.json to include both one.core's and your own definition files it will merge the declarations into one.

To extend this structure have a look at file one.core/@OneObjectInterfaces.d.ts and do what was one there to add ONE object types defined for the one.core tests for your own application types.

This interface contains the names (as keys) and TypeScript interface types (as values) of all unversioned objects.

Important: The string keys for each entry must be exactly the ONE object type name as used in the "name" property of the recipe for that type.

Type:
  • object
Properties:
Name Type Description
type-name ONE-object-interface-type

Use the same string literal as used for the "type" property in your ONE object(s) as key and the TypeScript interface definition name as the value

Source:

OneUnversionedObjectTypeNames

This union is obtained by extracting all keys from OneUnversionedObjectInterfaces.

Type:
  • "Keys" | AllYourUnversionedTypeNames
Source:

OneUnversionedObjectTypes

This union is obtained by extracting all values from OneUnversionedObjectInterfaces.

Type:
  • Keys | AllYourUnversionedTypes
Source:

OneVersionedObjectInterfaces

A meta-type defined in one.core/@OneObjectInterfaces.d.ts in module namespace "@OneObjectInterfaces" that can be extended through TypeScript's declaration merging feature to include ONE object definitions defined through recipes of the application.

In order to add your own project's versioned ONE object types create similar .d.ts file, declare a module namespace @OneObjectInterfaces and export an interface declaration for OneVersionedObjectInterfaces just as in the one.core file. If you tell tsc (TypeScript server) via your tsconfig.json to include both one.core's and your own definition files it will merge the declarations into one.

This interface contains the names (as keys) and TypeScript interface types (as values) of all versioned objects.

Important: The string keys for each entry must be exactly the ONE object type name as used in the "name" property of the recipe for that type.

Type:
  • object
Properties:
Name Type Description
type-name ONE-object-interface-type

Use the same string literal as used for the "$type$" property in your ONE object(s) as key and the TypeScript interface definition name as the value

Source:

OneVersionedObjectTypeNames

This union is obtained by extracting all keys from OneVersionedObjectInterfaces.

Type:
  • "Access" | "Chum" | "Group" | "Instance" | "Module" | "Person" | "Recipe" | AllYourVersionedTypeNames
Source:

OneVersionedObjectTypes

This union is obtained by extracting all values from OneVersionedObjectInterfaces.

Type:
Source:

ParseContext

This type is used in the ONE microdata parsing modules, first of all in microdata-to-object.

It is used to store the last value that a particular parser sub-function successfully parsed (if any) as well as the position in the microdata string up to which parsing has advanced.

Programming style notes:

The context object makes the parse functions impure, since the parsing position is stored on the outside. The reason is that we wanted to avoid a complex return type for the parse functions: The parsed value plus the position would both have to be returned, which means an object or array-object (tuple) would have to be created to box the return values. As an optimization, to save on object creations (especially with embedded platform JS runtimes in mind), we create an external object which gets passed into the parse functions as a pointer and whose position property is mutated.

Most people would make the whole parser a class and use this as the context object. We chose to be explicit throughout one.core, which avoids this binding issues if an individual parsing function is to be used standalone (since we export a number of those individual partial parser functions that parse only a small section).

Type:
  • object
Properties:
Name Type Attributes Description
html string

Read-only property pointing to the microdata string being parsed

isIdObj boolean <optional>

If true expect ID object microdata (with its additional special outer header attribute of data-id-object="true")

position number

MUTATED - The position in the microdata string up to which parsing got so far

Source:

Person

Example

Javascript representation:

const obj = {
    $type$: 'Person',
    email: 'members@gmx.net',
    name: 'Foo Test'
};

HTML microdata representation:

<div itemscope itemtype="//refin.io/Person">
  <span itemprop="email">members@gmx.net</span>
</span>
Type:
  • object
Properties:
Name Type Attributes Description
$type$ 'Person'
email string

A person-identifying unique email address

name string <optional>
Source:

PrimitiveValueTypes

Type:
Source:

PrimitiveValueTypes

Type:
Source:

Recipe

The array of rules determines the properties of the ONE object and their order (in the written microdata representation).

Example

Javascript representation:

const obj = {
    $type$: 'Recipe',
    name: ONE-object-type-name,
    version: 1,
    rule: [
        {
            itemprop: property1-name
            isId: true
            valueType: 'number'
        },
        {
            itemprop: property2-name,
            regexp: /^[\w]*+$/
        },
        {
            itemprop: property3-name
            valueType: 'map'
        },
        {
            itemprop: property4-name
            referenceToObj: new Set(['*'])
        }
    ]
};

HTML microdata representation:

<div itemscope itemtype="//refin.io/Recipe">
  <span itemprop="name">${ONE-object-type-name}</span>
  <span itemprop="rule">
    <span itemprop="itemprop">${property1-name}</span>
    <span itemprop="isId">true</span>
    <span itemprop="valueType">number</span>
  </span>
  <span itemprop="rule">
    <span itemprop="itemprop">${property2-name}</span>
  </span>
  <span itemprop="rule">
    <span itemprop="itemprop">${property3-name}</span>
    <span itemprop="valueType">Map</span>
  </span>
  <span itemprop="rule">
    <span itemprop="itemprop">${property4-name}</span>
    <span itemprop="referenceToObj">['*']</span>
  </span>
</span>
Type:
  • object
Properties:
Name Type Description
$type$ 'Recipe'

easily load a specific version of this versioned Recipe object.

name string

The type-string constant identifying this ONE object type

rule Array.<RecipeRule>

Array of rules

Source:

RecipeRule

This object is part of Recipe but has an extra type because the rule objects appear on their own in parts of the code, where those rules are given to functions to process parts of ONE objects.

NOTE: If this type is updated don't forget to also update function ensureRecipeRule() in <PROJECT_HOME>/src/util/recipe-checks.js

Type:
  • object
Properties:
Name Type Attributes Default Description
itemprop string

Create a microdata span tag with attribute "itemprop". Equivalent to the "key" in a Javascript object literal. The equivalent of the "value" is, again similar to a JS object, either another object (recursion: see "referenceToObj" below) or an actual value (string).

isId boolean <optional>
false

Whether this is an ID field for this type. If not present "false" is assumed.

type ValueType <optional>

The Javascript type of this property: After reading microdata everything is a "string". Setting this to ValueType lets the Microdata => (JS) Object converter know that it has to convert the strings to these types. The default is "string", because everything already is a string anyway when stored as HTML microdata.

object Array.<RecipeRule> <optional>

An array of RecipeRule rules for a nested data property. It works just like including a full ONE object on a referenceToObj enabled property but without using an actual ONE object, only the data.

inheritFrom string | RuleInheritanceWithOptions <optional>

Inherit properties from the given rule. The current rule inherits all properties of the linked rule and can override them or add to them with its own properties. In the simple case it is a string of the for Recipe[.itemprop].itemprop pointing to an itemprop in any known recipe. Recipe resolution happens at runtime, when "inheritFrom" is encountered for the first time in a recipe rule. The second case with options requires an object of the form RuleInheritanceWithOptions.

Example

Javascript representation:

const obj = {
    itemprop: propertyValue,
    isId: true,
    list: 'array',
    valueType: {number: {max: 1000}}
};

HTML microdata representation:

// Part of a "Recipe" object: Array of RecipeRule in property "rule"
...
  <span itemprop="rule">
    <span itemprop="itemprop">${propertyValue}</span>
    <span itemprop="isId">true</span>
    <span itemprop="valueType">"{\"number\":{\"max\":1000}}"</span>
  </span>
...
Source:

ReferenceToBlobValue

This object is part of ValueType and describes the value-type of a SHA256Hash of a BLOB.

Type:
  • object
Properties:
Name Type Description
type 'referenceToBlob'

Same as referenceToObj but the hash link points to a BLOB hash. It also is just a boolean value.

Source:

ReferenceToClobValue

This object is part of ValueType and describes the value-type of a SHA256Hash of a CLOB.

Type:
  • object
Properties:
Name Type Description
type 'referenceToClob'

Same as referenceToObj but the hash link points to a CLOB (UTF-8) hash. It also is just a boolean value.

Source:

ReferenceToIdValue

This object is part of ValueType and describes the value-type of a SHA256IdHash of an object.

Type:
  • object
Properties:
Name Type Description
type 'referenceToId'
allowedTypes Set.<(OneVersionedObjectTypeNames|'*')>

Same as referenceToObj but the hash link points to an ID hash.

Source:

ReferenceToObjValue

This object is part of ValueType and describes the value-type of a SHA256Hash of an object.

Type:
  • object
Properties:
Name Type Description
type 'referenceToObj'
allowedTypes Set.<(OneObjectTypeNames|'*')>

Includes another recipe as a sub-item. Create microdata span tag for complex data with attributes itemscope and itemtype="//refin.io/{THIS TYPE}". The actual values are placed in inner span tags with an itemprop attributeSHA256IdHash. This is a list of acceptable types to include. The itemprop` either is a hash link, or in imploded microdata those objects themselves are included. If the list includes the type string '*' the meaning is "any type".

Source:

RethrowingAsyncErrorWrappedFn() → {Promise.<*>}

The function returned by calling the RethrowingAsyncErrorWrapper function returned by util/function.createRethrowingAsyncErrorWrapper. For an in-depth explanation see util/function.createRethrowingAsyncErrorWrapper

Source:
Returns:

Returns a promise that resolves either with the return value of the wrapped function, or it resolves with undefined if an error was thrown.

Type: Promise.<*>

RethrowingAsyncErrorWrapper(fn) → {RethrowingAsyncErrorWrappedFn}

Parameters:
Name Type Description
fn function

The function returned by util/function.createRethrowingAsyncErrorWrapper For an in-depth explanation see util/function.createRethrowingAsyncErrorWrapper

Source:
Returns:

Returns a RethrowingAsyncErrorWrappedFn function that takes a function and wraps it

Type: RethrowingAsyncErrorWrappedFn

RuleInheritanceWithOptions

Important note (from @sebastian). I decided to keep exclude 'list' even if we don't have the list field anymore in RecipeRule. It will remove 'array','bag' or 'set' field in the RecipeRule.itemtype and keep only the item type.

The recipe-rule property "inheritFrom" can be either a string (common inheritance) or an object (inheritance with additional options). This is the type of the object in the latter case.

Type:
  • object
Properties:
Name Type Description
rule string

The rule to inherit from as "." separated path Recipe.itemprop

extract 'CollectionItemType' | 'MapItemType'

Extracts the item type inside a collection or map.

Source:

SHA256Hash

(Simulated) opaque type name alias for strings that are SHA-256 hashes pointing to concrete objects.

This type has a generic parameter: A member or a union of OneObjectTypes as well as the virtual types BLOB and CLOB.

This generic parameter is used by and passed through all major one.core functions' type definitions. For example, after storing an object the hashes in the object creation result object will be tagged with the typed of the object.

Type:
  • string
Source:

SHA256IdHash

(Simulated) opaque type name alias for strings that are SHA-256 hashes pointing to ID objects, i.e. to all past, present and future versions of a versioned object.

This type has a generic parameter: A member or a union of OneObjectTypes as well as the virtual types BLOB and CLOB.

Type:
  • string
Source:

SetAccessMode

An enum to be used when calling the access.module:ts access module to set access rights and create IdAccess or Access ONE objects.

Type:
  • 'replace' | 'add'
Source:

SetAccessParam

An array of SetAccessParam objects is expected by the "Lib/access" module.

Type:
  • object
Properties:
Name Type Attributes Description
object Reference <optional>

A reference to the unversioned or versioned object for which access rights are set

id SHA256IdHash <optional>

An ID reference to the ID object of a versioned object for which access rights are set for all current and future versions

mode 'replace' | 'add'

If there already is an Access object, add to its list of grant hashes or ignore its contents and let the new Access object exclusively use the data from this new set-access request? The parameter is mandatory to force developers to add this piece of information each time access is set. This is to prevent errors when the code makes an assumption but during runtime the actual behavior depends on if there is a previous Access object or not.

person Array.<SHA256IdHash>

An array of references to Person ID objects to whom access is granted. All versions of A reference Person ID object are granted access - versions in space (Person) vs. versions in time (Group) access.

group Array.<SHA256IdHash>

An array of references to Group ID objects to whom access is granted. Only the latest version (at the time of actual access attempt) is granted access - versions in space (Person) vs. versions in time (Group) access.

Source:

SetValue

This object is part of ValueType and describes the value-type of a Set Object.

Type:
  • object
Properties:
Name Type Description
type 'set'
item ValueType
Source:

SettingStoreApi

The settings store is a key-value store used to store instance settings that cannot or should not be stored in the usual ONE storage places. The browser implementation uses localStorage and the node.js version stores a file with the settings ina JSON.stringified object in the "private" storage space.

Type:
  • object
Properties:
Name Type Description
getItem function
setItem function
removeItem function
clear function
Source:

SimpleReadStream

SystemReadStream objects are created by factory function system/storage-streams.createFileReadStream.

This type has a generic parameter for the encoding setting: undefined | 'utf8' | 'base64'. Depending on the encoding the ondData function yields string or ArrayBuffer data.

It provides a platform independent interface to streams: filesystem streams on node.js, RNFetchBlob on React Native, and a custom minimal implementation on browsers.

The event system is modeled after the one found for IndexedDB and for WebSockets, among others: You simply assign a function to the appropriately named property on the SimpleReadStream object.

Type:
  • object
Properties:
Name Type Attributes Description
encoding 'base64' | 'utf8' <optional>

undefined for ArrayBuffer based binary streams, "base64" for string based binary streams, "utf8" for UTF-8 string based text streams. In the ONE library context: Requests for BLOBs: undefined (normal case) or base64 (React Native client) Requests for CLOBs and ONE objects: utf8

onData OneEventSourceConsumer.<(string|ArrayBuffer)>

Event source property with its public methods to subscribe to events

pause function

Pause the read stream; () => void

resume function

Resume the read stream; () => void

cancel function

Cancel the read stream; () => void

promise Promise.<void>

A tracking promise for 3rd parties to get the result when the stream ends (stream completed or error)

Source:

SimpleWriteStream

SimpleWriteStream objects are created by factory function storage-streams.createFileWriteStream.

This type has a generic parameter for the encoding setting: undefined | 'utf8' | 'base64'. Depending on the encoding the write function expects (only) string or ArrayBuffer data.

It provides a platform independent interface to streams: filesystem streams on node.js, RNFetchBlob on React Native, and a custom minimal implementation on browsers.

Instead of events for "error" and "finish" there is a promise, which allows for easier integration with promise based code in general and async/await based code in particular.

Style

This write-stream object assumes two different kinds of clients:

  • A single instance of code that actually uses and manages the stream

  • An arbitrary number of instances of code not involved with the stream but interested in its final result.

The active code gets functions to control the stream.

Passively involved code gets a promise that will resolve or reject when the final result of the stream becomes available. That promise does not control any of the code used to run the stream, it is only used to communicate the official result.

The code actually using the stream would have no use for a promise though: Streams and promises are fundamentally different in their aims. The code that does end up using the promise, however, a promise is the perfect abstraction - it only wants to know the final result.

Type:
  • object
Properties:
Name Type Description
write function

(data: E extends undefined ? ArrayBuffer : string) => void - If the write-stream was created without an encoding the parameter must be an ArrayBuffer. If it was created with an encoding there must be a string, either UTF-8 or a Base64 encoded binary, depending on the encoding.

cancel function

() => Promise<void> - Cancel stream and remove temporary file

end function

() => Promise<FileCreation<E extends 'utf8' ? CLOB : BLOB>> - Finish the stream, return final result

promise Promise.<FileCreation.<'BLOB'>>

A tracking promise for 3rd parties to get the result when the stream ends (stream completed or error)

Source:

StopIteratorError

A StopIteratorError is a type of Error with a fixed name property string value. You can stop the object graph iteration without the iterator promise rejecting by throwing an Error whose name property is "StopIteratorError" from within the callback function. Any other error causes the iterator promise to reject with that error.

Note that this is not a special class, i.e. you cannot use instanceof. The object is created by decorating a given Error object. To check for this error check the "name" property!

Type:
  • object
Properties:
Name Type Description
name 'StopIteratorError'

Fixed string 'StopIteratorError'

message string

An error message - but only the name property is important

Source:

StorageDirTypes

One of these fixed strings: 'objects' | 'tmp' | rmaps | vmaps | 'acache', 'private'

Type:
  • 'objects' | 'tmp' | 'rmaps' | 'vmaps' | 'acache' | 'private'
Source:

StorageMonitorOptions

Type:
  • object
Properties:
Name Type Description
keepRunning boolean
onError function
remotePersonIdHash SHA256IdHash
isMonitoredIdHash function
processAccessObjData ProcessAccessObjsDataFn
onIteratorObject HashesCollectorFn
connId number
Source:

StringValue

This object is part of ValueType and describes the value-type of a String.

Type:
  • object
Properties:
Name Type Attributes Description
type 'string'
regexp RegExp <optional>
Source:

StringifiableValue

Type:
  • object
Properties:
Name Type Description
type 'stringifiable'
Source:

ThrottledFunction

Function helper util/function.throttleWithFixedDelay returns a function to cancel a timer and prevent queued delayed execution of a throttled function, and the throttled function wrapper function itself.

Type:
  • object
Properties:
Name Type Description
cancel function

Cancel any active timers that will run the throttled function.

throttled function

The original function wrapped into a throttled function.

Source:

TrackingPromiseObj

Type:
  • object
Properties:
Name Type Description
promise Promise.<T>

The tracking promise

resolve PromiseResolveCb.<T>

The method that resolves the tracking promise

reject PromiseRejectCb

The method that rejects the tracking promise

Source:

UnversionedObjectResult

The type returned by SET operation(s) for ONE objects written without version history mechanism. Exactly one file is created. This type is only used for write operations because read operations of objects directly return the object.

Type:
  • object
Properties:
Name Type Attributes Description
obj OneObjectTypes <optional>

The ONE object that was stored. This is only set for ONE objects representable as Javascript objects. It is undefined for CLOBs and BLOBs. This link to the original object is included for easier chaining of promises when the next one in the chain also needs access to the object and not just the result of storing it.

hash SHA256Hash

The crypto hash of the microdata representation of the object and also the filename.

status FileCreationStatus

A string constant showing whether the file already existed or if it had to be created.

Source:

ValueType

ONE microdata object properties can store one of these types:

  • NumberValue
  • BooleanValue
  • StringifiableValue
  • ReferenceToObjValue
  • ReferenceToIdValue
  • ReferenceToClobValue
  • ReferenceToBlobValue
  • MapValue
  • BagValue
  • ArrayValue
  • SetValue
  • ObjectValue;

Conversion from and to the types is performed upon writing and reading ONE microdata objects:

When reading microdata and creating a Javascript object representation of the ONE object the strings will be converted to these types if the respective rule for the item has type information. By default, everything remains a string.

Type:
Source:

VersionMapEntry

Result of listing all versions of a versioned ONE object. The version map that describes all versions of a ONE object contains the millisecond timestamp of when the version map was updated, and the hash of the actual object. Using the position index you can then ask for a particular version of the versioned ONE object.

Type:
  • object
Properties:
Name Type Description
timestamp number
hash SHA256Hash
Source:

VersionUpdatePolicyValues

These are the internal values for the enum VERSION_UPDATES defined in and exported by storage-base-common. Never use the numeric values, always use the symbols in VERSION_UPDATES exported by module storage-base-common and re-exported by the public storage API module storage.

Type:
  • 1 | 2 | 3 | 4 | 5
Source:
See:
  • VERSION_UPDATES

VersionedObjectResult

The type returned by write operation(s) for versioned ONE objects as well as by getObjectByIdHash and getObjectByIdObject. This is similar to UnversionedObjectResult except that it also includes the idHash property which identifies all versions of a versioned object as well as the timestamp written into the version map.

Type:
  • object
Properties:
Name Type Attributes Description
obj OneVersionedObjectTypes

The versioned ONE object that was stored. This is only set for ONE objects representable as Javascript objects.

hash SHA256Hash

The crypto hash of the microdata representation of the object and also the filename.

idHash SHA256IdHash

The crypto hash of the ID-object of the ONE object.

timestamp number <optional>

Creation date-time of the version-map entry for the object. This is not the creation date-time of the object! The timestamp is only provided if a version map entry was made. Version map entries can be made repeatedly for already existing objects to make an already existing object the most current version without creating it (since it already exists...)

status FileCreationStatus

A string constant showing whether the file already existed or if it had to be created or if a new version was added.

Source:

WebsocketStatistics

This type is included in Chum objects as well as used internally. The numbers are without network overhead. The number of sent requests always includes the connect request, so after communication finished both parties will have sent one more request than they themselves received, since the connect request is to the communication server!

Type:
  • object
Properties:
Name Type Description
requestsSentTotal number

Total number of requests made thus far

requestsReceivedTotal number

Total number of requests received thus far

requestsReceivedInvalid number

Total number of requests received that had to be ignored because they were either unparsable (invalid JSON) or otherwise unusable

Source: