Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e99f4fb
Updating package locks from release
Jun 9, 2020
9cfbf1c
Merging types and adjusting configs
Jun 10, 2020
d1a6271
Fixed linting issues
Jun 10, 2020
d50dfeb
Merged the auth provider types
Jun 10, 2020
6fb981b
Fixing the functions factory types
Jun 10, 2020
62337cf
Fixed integration tests based on updated types
Jun 10, 2020
384a36a
Made options optional when using the HTTP service
Jun 10, 2020
093ba49
Updated types related to auth providers
Jun 10, 2020
dedd8f6
Delete the commented App class declaration
Jun 17, 2020
60777ae
Merge types and update code accordingly
Jun 17, 2020
f237a33
Package-lock got updated
Jun 17, 2020
52e20b9
Fixed logging out a logged out user
Jun 17, 2020
c595141
Commented out the App#logOut method
Jun 17, 2020
66f28d9
Adding removeUser to the tests
Jun 17, 2020
3900e59
Update types/app.d.ts
Jun 18, 2020
5e42271
Removed "| void"
Jun 19, 2020
3d64511
resendConfirmation → resendConfirmationEmail
Jun 19, 2020
211462a
Removed logOut method from the `App`
Jun 19, 2020
17faa28
Fixed App constructor type
Jun 24, 2020
ae2b635
Using unshift instead of splice where applicable
Jun 29, 2020
25698f5
Adopted API to the latest proposal
Jul 1, 2020
9a2919e
Fixed the realm-network-transport types
Jul 1, 2020
de28eb4
Updating integration tests
Jul 1, 2020
9fdb825
ApiKeyAuth renames (#3047)
kraenhansen Jul 10, 2020
615ec13
Merge branch 'v10' into kh/v10-merged-types
Jul 10, 2020
a65b534
Merge branch 'v10' into kh/v10-merged-types
kraenhansen Jul 10, 2020
e267fc6
EmailPasswordAuth renames (#3048)
Jul 10, 2020
25778b4
Moved push service to a seperate interface
Jul 10, 2020
21dcc72
Implemented a throwing push for a user
Jul 10, 2020
28ccaa8
Incorporated feedback
Jul 10, 2020
e98771d
v10 refactoring (#2996)
kneth Jul 10, 2020
4ff57ac
Removed UserProfile from index.d.ts and updated pictureUrl
Jul 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ NOTE: Support for syncing with realm.cloud.io and/or Realm Object Server has bee

NOTE: This version bumps the Realm file format to version 11. It is not possible to downgrade to earlier versions. Older files will automatically be upgraded to the new file format. Files created by Realm JavaScript prior to v1.0.0, might not be upgradeable. Only [Realm Studio 10.0.0](https://github.com/realm/realm-studio/releases/tag/v10.0.0-beta.1) or later will be able to open the new file format.

### Breaking changes
* `Realm.Auth.EmailPassword.registerEmail()` has been renamed to `Realm.Auth.EmailPassword.registerUser()`.
* `Realm.User.identity` has been renamed to `Realm.User.id`.
* `Realm.User.token` has been renamed to `Realm.User.accessToken`.
* Change instance methods `Realm.App.currentUser()` and `Realm.App.allUsers()` to instance properties `Realm.App.currentUser` and `Realm.App.allUsers`.
* `Realm.Auth.UserAPIKeyProvider` has been replaced by `Realm.Auth.ApiKeyProvider`.
* `user.auth.apiKeys` has been replaced by `user.apiKeys`.
* The instance methods on the ApiKeyAuth instance (`user.apiKeys`) have gotten their APIKey(s) suffix removed: Ex. `apiKeys.createAPIKey` has been replaced by `apiKeys.create`.
* `Realm.Auth.EmailPasswordProvider` has been replaced by `Realm.Auth.EmailPasswordAuth`.
* `app.auth.emailPassword` has been replaced by `user.emailPasswordAuth`.

### Enhancements
* None.
* Added RemoteMongoClient functionality to `Realm.User`

### Fixed
* Failed to parse arguments correctly, causing the error `callback must be of type 'function', got (undefined)` when calling `Realm.App.emailPassword.sendResetPasswordEmail()` and `Realm.App.emailPassword.resendConfirmationEmail()`. ([#3037](https://github.com/realm/realm-js/issues/3037), since v10.0.0-beta.1)
Expand Down
2 changes: 1 addition & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"src/js_app_credentials.hpp",
"src/js_user.hpp",
"src/js_network_transport.hpp",
"src/js_email_password_provider.hpp",
"src/js_email_password_auth.hpp",
"src/node/sync_logger.cpp",
"src/node/sync_logger.hpp",
]
Expand Down
66 changes: 42 additions & 24 deletions docs/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@
*
* @returns {Realm.User} The current user, `null` is no current user.
*/
currentUser() { }
get currentUser() { }

/**
* Returns a dictionary of alll users. Users' identity is used as key.
*
* @returns {Array}
*/
allUsers() { }
get allUsers() { }

/**
* Switches the current user.
Expand All @@ -133,18 +133,18 @@
removeUser(user) { }

/**
* Auth providers. Currently only `emailPassword` provider is support
* Client for the email/password authentication provider.
*
* @example
* {
* let app = new Realm.App(config);
* let provider = app.auth.emailPassword;
* // Creating a new user, by registering via email & password
* const app = new Realm.App(config);
* await app.emailPasswordAuth.registerUser('john@example.com', 'some-secure-password');
* }
*
* @see Realm.Auth
* @see Realm.Auth.EmailPassword
* @type {Realm.Auth.EmailPasswordAuth}
*/
get auth() { }
get emailPasswordAuth() { }
}


Expand Down Expand Up @@ -351,8 +351,8 @@ class Credentials {

/**
* A namespace for auth providers
* @see Realm.Auth.EmailPassword
* @see Realm.Auth.UserAPIKey
* @see Realm.Auth.EmailPasswordAuth
* @see Realm.Auth.ApiKeyAuth
* @memberof Realm
*/
class Auth {
Expand All @@ -363,20 +363,20 @@ class Auth {
* Class for managing email/password for users
* @memberof Realm.Auth
*/
class EmailPassword {
class EmailPasswordAuth {

/**
* Registers a new email identity with the username/password provider,
* Registers a new email identity with the email/password provider,
* and sends a confirmation email to the provided address.
*
* @param {string} email - The email address of the user to register.
* @param {string} password - The password that the user created for the new username/password identity.
* @returns {Promise<void>}
*/
registerEmail(email, password) { }
registerUser(email, password) { }

/**
* Confirms an email identity with the username/password provider.
* Confirms an email identity with the email/password provider.
*
* @param {string} token - The confirmation token that was emailed to the user.
* @param {string} id - The confirmation token id that was emailed to the user.
Expand Down Expand Up @@ -408,6 +408,17 @@ class EmailPassword {
* @returns {Promise<void>}
*/
resetPassword(password, token, id) { }

/**
* Resets the password of an email identity using the
* password reset function set up in the application.
*
* @param {string} email - The email address of the user.
* @param {string} password - The desired new password.
* @param {Array<BSON>} args - A bson array of arguments.
* @return {Promose<void>}
*/
callResetPasswordFunction(email, password, args) { }
}

/**
Expand All @@ -416,54 +427,54 @@ class EmailPassword {
* client should only be used by an authenticated user.
* @memberof Realm.Auth
*/
class APIKeys {
class ApiKeyAuth {

/**
* Creates a user API key that can be used to authenticate as the current user.
*
* @param {string} name - The name of the API key to be created.
* @returns {Promise<void>}
*/
createAPIKey(name) { }
create(name) { }

/**
* Fetches a user API key associated with the current user.
*
* @param {string} id - The id of the API key to fetch.
* @returns {Promise<Object>}
*/
fetchAPIKey(id) { }
fetch(id) { }

/**
* Fetches the user API keys associated with the current user.
*
* @returns {Promise<Array>}
*/
allAPIKeys() { }
fetchAll() { }

/**
* Deletes a user API key associated with the current user.
*
* @param {string} id - The id of the API key to delete.
* @returns {Promise<void>}
*/
deleteAPIKey(id) { }
delete(id) { }

/**
* Enables a user API key associated with the current user.
*
* @param {string} id - The id of the API key to enable.
* @returns {Promise<void>}
*/
enableAPIKey(id) { }
enable(id) { }

/**
* Disables a user API key associated with the current user.
*
* @param {string} id - The id of the API key to disable.
* @returns {Promise<void>}
*/
disableAPIKey(id) { }
disable(id) { }
}


Expand All @@ -477,14 +488,21 @@ class User {
* The identity is a guaranteed to be unique among all users on MongoDB Realm Cloud .
* @type {string}
*/
get identity() { }
get id() { }

/**
* Gets this user's access token. This is the user's credential for accessing the MongoDB
* Realm Cloud and should be treated as sensitive data.
* @type {string}
*/
get accessToken() { }

/**
* Gets this user's refresh token. This is the user's credential for accessing the MongoDB
* Realm Cloud and should be treated as sensitive data.
* @type {string}
*/
get token() { }
get refreshToken() { }

/**
* Gets this user's associated custom data. This is application-specific data provided by the server.
Expand Down Expand Up @@ -537,7 +555,7 @@ class User {

/**
* Returns a provider to interact with API keys.
* @return {Realm.Auth.APIKeys} - the provider
* @return {Realm.Auth.ApiKeyAuth} - the provider
*/
apiKeys() { }

Expand Down
24 changes: 12 additions & 12 deletions lib/user_apikey_provider_client.js → lib/api-key-auth-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@
const {promisify} = require("./utils.js");

const instanceMethods = {
createAPIKey(name) {
return promisify(cb => this._createAPIKey(name, cb));
create(name) {
return promisify(cb => this._create(name, cb));
},

fetchAPIKey(id) {
return promisify(cb => this._fetchAPIKey(id, cb));
fetch(id) {
return promisify(cb => this._fetch(id, cb));
},

fetchAPIKeys() {
return promisify(cb => this._fetchAPIKeys(cb));
fetchAll() {
return promisify(cb => this._fetchAll(cb));
},

deleteAPIKey(apiKeyId) {
return promisify(cb => this._deleteAPIKey(apiKeyId, cb));
delete(apiKeyId) {
return promisify(cb => this._delete(apiKeyId, cb));
},

enableAPIKey(apiKeyId) {
return promisify(cb => this._enableAPIKey(apiKeyId, cb));
enable(apiKeyId) {
return promisify(cb => this._enable(apiKeyId, cb));
},

disableAPIKey(apiKeyId) {
return promisify(cb => this._disableAPIKey(apiKeyId, cb));
disable(apiKeyId) {
return promisify(cb => this._disable(apiKeyId, cb));
},
};

Expand Down
11 changes: 0 additions & 11 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ const instanceMethods = {
removeUser() {
return promisify(cb => this._removeUser(cb));
},

get auth() {
const app = this;
return new Proxy({}, {
get(target, name) {
if (name === "emailPassword") {
return app._authEmailPassword;
}
}
});
}
};

const staticMethods = {
Expand Down
6 changes: 4 additions & 2 deletions lib/browser/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ createMethods(User.prototype, objectTypes.USER, [
]);

Object.defineProperties(User.prototype, {
identity: { get: getterForProperty('identity') },
token: { get: getterForProperty('token') },
id: { get: getterForProperty('id') },
accessToken: { get: getterForProperty('accessToken') },
refreshToken: { get: getterForProperty('refreshToken') },
profile: { get: getterForProperty('profile') },
isLoggedIn: { get: getterForProperty('isLoggedIn') },
state: { get: getterForProperty('state') },
customData: { get: getterForProperty('customData') },
apiKeys: { get: getterForProperty('apiKeys') },
});

export function createUser(realmId, info) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
//
////////////////////////////////////////////////////////////////////////////

'use strict';

const {promisify} = require("./utils.js");

const instanceMethods = {
registerEmail(email, password) {
return promisify(cb => this._registerEmail(email, password, cb));
registerUser(email, password) {
return promisify(cb => this._registerUser(email, password, cb));
},

confirmUser(token, token_id) {
Expand All @@ -38,8 +37,12 @@ const instanceMethods = {
},

resetPassword(password, token, token_id) {
return promisify(cb => this._sendResetPasswordEmail(password, token_id, token_id, cb));
}
return promisify(cb => this._resetPassword(password, token, token_id));
},

callResetPasswordFunction(email, password, bsonArgs) {
return promisify(cb => this._callResetPasswordFunction(email, password, bsonArgs));
},
};

const staticMethods = {
Expand Down
8 changes: 4 additions & 4 deletions lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,11 @@ module.exports = function(realmConstructor, context) {
let credentialMethods = require("./credentials");
Object.defineProperties(realmConstructor.Credentials, getOwnPropertyDescriptors(credentialMethods.static))

let emailPasswordProviderMethods = require("./email_password_provider_client_methods");
Object.defineProperties(realmConstructor.Auth.EmailPasswordProvider.prototype, getOwnPropertyDescriptors(emailPasswordProviderMethods.instance));
let emailPasswordAuthMethods = require("./email-password-auth-methods");
Object.defineProperties(realmConstructor.Auth.EmailPasswordAuth.prototype, getOwnPropertyDescriptors(emailPasswordAuthMethods.instance));

let userAPIKeyProviderMethods = require("./user_apikey_provider_client");
Object.defineProperties(realmConstructor.Auth.UserAPIKeyProvider.prototype, getOwnPropertyDescriptors(userAPIKeyProviderMethods.instance));
let apiKeyAuthMethods = require("./api-key-auth-methods");
Object.defineProperties(realmConstructor.Auth.ApiKeyAuth.prototype, getOwnPropertyDescriptors(apiKeyAuthMethods.instance));


realmConstructor.Sync.AuthError = require("./errors").AuthError;
Expand Down
11 changes: 0 additions & 11 deletions lib/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ const instanceMethods = {
get functions() {
return this._functionsOnService(undefined);
},

get auth() {
const user = this;
return new Proxy({}, {
get(target, name) {
if (name === "apiKeys") {
return user._authApiKeys;
}
}
});
}
}

const staticMethods = {
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/realm-network-transport/.eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/dist/
/types/
1 change: 1 addition & 0 deletions packages/realm-network-transport/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export {
Method,
SuccessCallback,
ErrorCallback,
ResponseHandler,
} from "./NetworkTransport";
Loading