Add the variables to the syncConfig
This commit is contained in:
parent
b9f90a956b
commit
f6564ca68f
17
docs/sync.js
17
docs/sync.js
|
@ -31,6 +31,9 @@ class Sync {
|
||||||
* _Currently only the 'change' event is supported_
|
* _Currently only the 'change' event is supported_
|
||||||
* @param {function(change_event)} change_callback - called when changes are made to any Realm which
|
* @param {function(change_event)} change_callback - called when changes are made to any Realm which
|
||||||
* match the given regular expression
|
* match the given regular expression
|
||||||
|
* @param {bool} validate_ssl=true - Validate the server's SSL chertificate.
|
||||||
|
* @param {string} ssl_trust_certificate_path=None - Path to a trust/anchor certificate used by the
|
||||||
|
* client to verify the server certificate.
|
||||||
*/
|
*/
|
||||||
static addListener(server_url, admin_user, regex, name, change_callback) {}
|
static addListener(server_url, admin_user, regex, name, change_callback) {}
|
||||||
|
|
||||||
|
@ -86,8 +89,8 @@ class ChangeEvent {
|
||||||
* The change indexes for all added, removed, and modified objects in the changed Realm.
|
* The change indexes for all added, removed, and modified objects in the changed Realm.
|
||||||
* This object is a hashmap of object types to arrays of indexes for all changed objects:
|
* This object is a hashmap of object types to arrays of indexes for all changed objects:
|
||||||
* @example
|
* @example
|
||||||
* {
|
* {
|
||||||
* object_type_1: {
|
* object_type_1: {
|
||||||
* insertions: [indexes...],
|
* insertions: [indexes...],
|
||||||
* deletions: [indexes...],
|
* deletions: [indexes...],
|
||||||
* modifications: [indexes...]
|
* modifications: [indexes...]
|
||||||
|
@ -183,7 +186,7 @@ class User {
|
||||||
* @type {User}
|
* @type {User}
|
||||||
*/
|
*/
|
||||||
static get current() {}
|
static get current() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the server URL that was used for authentication.
|
* Gets the server URL that was used for authentication.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
|
@ -191,14 +194,14 @@ class User {
|
||||||
get server() {}
|
get server() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the identity of this user on the Realm Object Server.
|
* Gets the identity of this user on the Realm Object Server.
|
||||||
* The identity is a guaranteed to be unique among all users on the Realm Object Server.
|
* The identity is a guaranteed to be unique among all users on the Realm Object Server.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
get identity() {}
|
get identity() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this user's refresh token. This is the user's credential for accessing the Realm
|
* Gets this user's refresh token. This is the user's credential for accessing the Realm
|
||||||
* Object Server and should be treated as sensitive data.
|
* Object Server and should be treated as sensitive data.
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
|
@ -225,9 +228,9 @@ class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object encapsulating a Realm Object Server session. Sessions represent the communication between the
|
* An object encapsulating a Realm Object Server session. Sessions represent the communication between the
|
||||||
* client (and a local Realm file on disk), and the server (and a remote Realm at a given URL stored on a Realm Object Server).
|
* client (and a local Realm file on disk), and the server (and a remote Realm at a given URL stored on a Realm Object Server).
|
||||||
* Sessions are always created by the SDK and vended out through various APIs. The lifespans of sessions
|
* Sessions are always created by the SDK and vended out through various APIs. The lifespans of sessions
|
||||||
* associated with Realms are managed automatically.
|
* associated with Realms are managed automatically.
|
||||||
* @memberof Realm.Sync
|
* @memberof Realm.Sync
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -390,8 +390,6 @@ template<typename T>
|
||||||
void SyncClass<T>::populate_sync_config(ContextType ctx, ObjectType realm_constructor, ObjectType config_object, Realm::Config& config)
|
void SyncClass<T>::populate_sync_config(ContextType ctx, ObjectType realm_constructor, ObjectType config_object, Realm::Config& config)
|
||||||
{
|
{
|
||||||
ValueType sync_config_value = Object::get_property(ctx, config_object, "sync");
|
ValueType sync_config_value = Object::get_property(ctx, config_object, "sync");
|
||||||
bool client_validate_ssl = true;
|
|
||||||
util::Optional<std::string> ssl_trust_certificate_path = util::none;
|
|
||||||
if (Value::is_boolean(ctx, sync_config_value)) {
|
if (Value::is_boolean(ctx, sync_config_value)) {
|
||||||
config.force_sync_history = Value::to_boolean(ctx, sync_config_value);
|
config.force_sync_history = Value::to_boolean(ctx, sync_config_value);
|
||||||
} else if (!Value::is_undefined(ctx, sync_config_value)) {
|
} else if (!Value::is_undefined(ctx, sync_config_value)) {
|
||||||
|
@ -439,6 +437,21 @@ void SyncClass<T>::populate_sync_config(ContextType ctx, ObjectType realm_constr
|
||||||
|
|
||||||
std::string raw_realm_url = Object::validated_get_string(ctx, sync_config_object, "url");
|
std::string raw_realm_url = Object::validated_get_string(ctx, sync_config_object, "url");
|
||||||
|
|
||||||
|
bool client_validate_ssl = true;
|
||||||
|
ValueType validate_ssl_temp = Object::get_property(ctx, sync_config_object, "validate_ssl");
|
||||||
|
if (!Value::is_undefined(ctx, validate_ssl_temp)) {
|
||||||
|
client_validate_ssl = Value::validated_to_boolean(ctx, validate_ssl_temp, "validate_ssl");
|
||||||
|
}
|
||||||
|
|
||||||
|
util::Optional<std::string> ssl_trust_certificate_path;
|
||||||
|
ValueType trust_certificate_path_temp = Object::get_property(ctx, sync_config_object, "ssl_trust_certificate_path");
|
||||||
|
if (!Value::is_undefined(ctx, trust_certificate_path_temp)) {
|
||||||
|
ssl_trust_certificate_path = std::string(Value::validated_to_string(ctx, trust_certificate_path_temp, "ssl_trust_certificate_path"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ssl_trust_certificate_path = util::none;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME - use make_shared
|
// FIXME - use make_shared
|
||||||
config.sync_config = std::shared_ptr<SyncConfig>(new SyncConfig{shared_user, raw_realm_url,
|
config.sync_config = std::shared_ptr<SyncConfig>(new SyncConfig{shared_user, raw_realm_url,
|
||||||
SyncSessionStopPolicy::AfterChangesUploaded,
|
SyncSessionStopPolicy::AfterChangesUploaded,
|
||||||
|
|
Loading…
Reference in New Issue