mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 14:54:33 +00:00
Adding _getExitingUser to Chrome debugger support library. (#1628)
* Adding _getExitingUser to Chrome debugger support library.
This commit is contained in:
parent
0c6e254494
commit
a996a1a8b8
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,3 +1,17 @@
|
|||||||
|
X.Y.Z Release notes
|
||||||
|
=============================================================
|
||||||
|
### Breaking changes
|
||||||
|
* None.
|
||||||
|
|
||||||
|
### Enhancements
|
||||||
|
* None.
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
* [Object Server] Added `_getExitingUser` to the Chrome debugging support library.
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
* None.
|
||||||
|
|
||||||
2.2.3 Release notes (2018-1-17)
|
2.2.3 Release notes (2018-1-17)
|
||||||
=============================================================
|
=============================================================
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
|
@ -77,6 +77,12 @@ export function _adminUser(args) {
|
|||||||
return deserialize(undefined, result);
|
return deserialize(undefined, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function _getExistingUser(args) {
|
||||||
|
args = args.map((arg) => serialize(null, arg));
|
||||||
|
const result = sendRequest('_getExistingUser', { arguments: args });
|
||||||
|
return deserialize(undefined, result);
|
||||||
|
}
|
||||||
|
|
||||||
export function callMethod(realmId, id, name, args) {
|
export function callMethod(realmId, id, name, args) {
|
||||||
if (args) {
|
if (args) {
|
||||||
args = args.map((arg) => serialize(realmId, arg));
|
args = args.map((arg) => serialize(realmId, arg));
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { createUser as createUserRPC, _adminUser as _adminUserRPC, getAllUsers as getAllUsersRPC } from './rpc';
|
import { createUser as createUserRPC, _adminUser as _adminUserRPC, getAllUsers as getAllUsersRPC, _getExistingUser as _getExistingUserRPC } from './rpc';
|
||||||
import { keys, objectTypes } from './constants';
|
import { keys, objectTypes } from './constants';
|
||||||
import { createMethods } from './util';
|
import { createMethods } from './util';
|
||||||
|
|
||||||
@ -35,6 +35,10 @@ export default class User {
|
|||||||
static get all() {
|
static get all() {
|
||||||
return getAllUsersRPC();
|
return getAllUsersRPC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static _getExistinguser() {
|
||||||
|
return _getExistingUserRPC();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createMethods(User.prototype, objectTypes.USER, [
|
createMethods(User.prototype, objectTypes.USER, [
|
||||||
@ -45,13 +49,13 @@ createMethods(User.prototype, objectTypes.USER, [
|
|||||||
export function createUser(realmId, info) {
|
export function createUser(realmId, info) {
|
||||||
const userProxy = Object.create(User.prototype);
|
const userProxy = Object.create(User.prototype);
|
||||||
|
|
||||||
// FIXME: This is currently necessary because util/createMethod expects
|
// FIXME: This is currently necessary because util/createMethod expects
|
||||||
// the realm id to be present on any object that is used over rpc
|
// the realm id to be present on any object that is used over rpc
|
||||||
userProxy[keys.realm] = "(User object)";
|
userProxy[keys.realm] = "(User object)";
|
||||||
|
|
||||||
userProxy[keys.id] = info.id;
|
userProxy[keys.id] = info.id;
|
||||||
userProxy[keys.type] = objectTypes.USER;
|
userProxy[keys.type] = objectTypes.USER;
|
||||||
Object.assign(userProxy, info.data);
|
Object.assign(userProxy, info.data);
|
||||||
|
|
||||||
return userProxy;
|
return userProxy;
|
||||||
}
|
}
|
||||||
|
30
src/rpc.cpp
30
src/rpc.cpp
@ -163,7 +163,7 @@ void RPCWorker::stop() {
|
|||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
m_thread.join();
|
m_thread.join();
|
||||||
m_loop = nullptr;
|
m_loop = nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,15 +237,15 @@ RPCServer::RPCServer() {
|
|||||||
if (!realm_constructor) {
|
if (!realm_constructor) {
|
||||||
throw std::runtime_error("Realm constructor not found!");
|
throw std::runtime_error("Realm constructor not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObjectRef sync_constructor = (JSObjectRef)jsc::Object::get_property(m_context, realm_constructor, "Sync");
|
JSObjectRef sync_constructor = (JSObjectRef)jsc::Object::get_property(m_context, realm_constructor, "Sync");
|
||||||
JSObjectRef user_constructor = (JSObjectRef)jsc::Object::get_property(m_context, sync_constructor, "User");
|
JSObjectRef user_constructor = (JSObjectRef)jsc::Object::get_property(m_context, sync_constructor, "User");
|
||||||
JSObjectRef create_user_method = (JSObjectRef)jsc::Object::get_property(m_context, user_constructor, "_adminUser");
|
JSObjectRef create_user_method = (JSObjectRef)jsc::Object::get_property(m_context, user_constructor, "_adminUser");
|
||||||
|
|
||||||
json::array_t args = dict["arguments"];
|
json::array_t args = dict["arguments"];
|
||||||
size_t arg_count = args.size();
|
size_t arg_count = args.size();
|
||||||
JSValueRef arg_values[arg_count];
|
JSValueRef arg_values[arg_count];
|
||||||
|
|
||||||
for (size_t i = 0; i < arg_count; i++) {
|
for (size_t i = 0; i < arg_count; i++) {
|
||||||
arg_values[i] = deserialize_json_value(args[i]);
|
arg_values[i] = deserialize_json_value(args[i]);
|
||||||
}
|
}
|
||||||
@ -253,6 +253,28 @@ RPCServer::RPCServer() {
|
|||||||
JSObjectRef user_object = (JSObjectRef)jsc::Function::call(m_context, create_user_method, arg_count, arg_values);
|
JSObjectRef user_object = (JSObjectRef)jsc::Function::call(m_context, create_user_method, arg_count, arg_values);
|
||||||
return (json){{"result", serialize_json_value(user_object)}};
|
return (json){{"result", serialize_json_value(user_object)}};
|
||||||
};
|
};
|
||||||
|
m_requests["/_getExistingUser"] = [this](const json dict) {
|
||||||
|
JSObjectRef realm_constructor = m_session_id ? JSObjectRef(m_objects[m_session_id]) : NULL;
|
||||||
|
if (!realm_constructor) {
|
||||||
|
throw std::runtime_error("Realm constructor not found!");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSObjectRef sync_constructor = (JSObjectRef)jsc::Object::get_property(m_context, realm_constructor, "Sync");
|
||||||
|
JSObjectRef user_constructor = (JSObjectRef)jsc::Object::get_property(m_context, sync_constructor, "User");
|
||||||
|
JSObjectRef create_user_method = (JSObjectRef)jsc::Object::get_property(m_context, user_constructor, "_getExistingUser");
|
||||||
|
|
||||||
|
json::array_t args = dict["arguments"];
|
||||||
|
size_t arg_count = args.size();
|
||||||
|
JSValueRef arg_values[arg_count];
|
||||||
|
|
||||||
|
for (size_t i = 0; i < arg_count; i++) {
|
||||||
|
arg_values[i] = deserialize_json_value(args[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSObjectRef user_object = (JSObjectRef)jsc::Function::call(m_context, create_user_method, arg_count, arg_values);
|
||||||
|
return (json){{"result", serialize_json_value(user_object)}};
|
||||||
|
|
||||||
|
};
|
||||||
m_requests["/call_method"] = [this](const json dict) {
|
m_requests["/call_method"] = [this](const json dict) {
|
||||||
JSObjectRef object = m_objects[dict["id"].get<RPCObjectID>()];
|
JSObjectRef object = m_objects[dict["id"].get<RPCObjectID>()];
|
||||||
std::string method_string = dict["name"].get<std::string>();
|
std::string method_string = dict["name"].get<std::string>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user