New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

realm-web

Package Overview
Dependencies
Maintainers
4
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

realm-web - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

dist/bundle.cjs.js.map

389

dist/bundle.d.ts

@@ -10,3 +10,3 @@ /// <reference path="../types/realm/app.d.ts" />

*/
declare type StorageChangeListener = () => void;
type StorageChangeListener = () => void;
/**

@@ -34,3 +34,2 @@ * Implementors of this provide a simple key-value store.

* Clears all values stored in the storage.
*
* @param prefix Clear only values starting with this prefix.

@@ -41,3 +40,2 @@ */

* Add a callback function which will be called when the store updates.
*
* @param listener The listener callback to add.

@@ -48,3 +46,2 @@ */

* Remove a callback function which was previously added.
*
* @param listener The listener callback to remove.

@@ -73,3 +70,2 @@ */

* Construct a `Storage` which will prefix a key part to every operation.
*
* @param storage The underlying storage to use for operations.

@@ -95,103 +91,13 @@ * @param keyPart The part of the key to prefix when performing operations.

declare type Method = "GET" | "POST" | "DELETE" | "PUT";
declare type Headers = {
[name: string]: string;
};
interface Request<RequestBody = unknown> extends FetchRequestInit<RequestBody> {
method: Method;
url: string;
timeoutMs?: number;
}
interface CallbackResponse {
statusCode: number;
headers: Headers;
body: string;
}
declare type SuccessCallback = (response: CallbackResponse) => void;
declare type ErrorCallback = (err: Error) => void;
interface ResponseHandler {
onSuccess: SuccessCallback;
onError: ErrorCallback;
}
interface NetworkTransport {
fetch<RequestBody>(request: Request<RequestBody>): Promise<FetchResponse>;
fetchWithCallbacks<RequestBody>(request: Request<RequestBody>, handler: ResponseHandler): void;
}
declare type AbortSignal = unknown;
declare type FetchHeadersInit = FetchHeaders | string[][] | Record<string, string>;
declare type FetchRequestCredentials = "include" | "omit" | "same-origin";
declare type FetchRequestMode = "cors" | "navigate" | "no-cors" | "same-origin";
declare type FetchReadableStream = unknown;
interface FetchBody {
readonly body: FetchReadableStream | null;
readonly bodyUsed: boolean;
arrayBuffer(): Promise<ArrayBuffer>;
blob(): Promise<unknown>;
json<ResponseBody = unknown>(): Promise<ResponseBody>;
text(): Promise<string>;
}
interface FetchHeaders {
append(name: string, value: string): void;
delete(name: string): void;
get(name: string): string | null;
has(name: string): boolean;
set(name: string, value: string): void;
forEach(callback: (value: string, name: string) => void): void;
}
interface FetchResponse extends FetchBody {
readonly headers: FetchHeaders;
readonly ok: boolean;
readonly redirected: boolean;
readonly status: number;
readonly statusText: string;
readonly type: unknown;
readonly url: string;
clone(): FetchResponse;
}
interface FetchRequestInit<RequestBody = unknown> {
/**
* A BodyInit object or null to set request's body.
*/
body?: RequestBody;
/**
* A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.
*/
credentials?: FetchRequestCredentials;
/**
* A Headers object, an object literal, or an array of two-item arrays to set request's headers.
*/
headers?: FetchHeadersInit;
/**
* A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
*/
integrity?: string;
/**
* A boolean to set request's keepalive.
*/
keepalive?: boolean;
/**
* A string to set request's method.
*/
method?: string;
/**
* A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
*/
mode?: FetchRequestMode;
/**
* An AbortSignal to set request's signal.
*/
signal?: AbortSignal | null;
}
declare type AnonymousPayload = Realm.Credentials.AnonymousPayload;
declare type ApiKeyPayload = Realm.Credentials.ApiKeyPayload;
declare type EmailPasswordPayload = Realm.Credentials.EmailPasswordPayload;
declare type OAuth2RedirectPayload = Realm.Credentials.OAuth2RedirectPayload;
declare type GoogleAuthCodePayload = Realm.Credentials.GoogleAuthCodePayload;
declare type GooglePayload = Realm.Credentials.GooglePayload;
declare type FacebookPayload = Realm.Credentials.FacebookPayload;
declare type FunctionPayload = Realm.Credentials.FunctionPayload;
declare type JWTPayload = Realm.Credentials.JWTPayload;
declare type ApplePayload = Realm.Credentials.ApplePayload;
declare type GoogleOptions = OAuth2RedirectPayload | GoogleAuthCodePayload | {
type AnonymousPayload = Realm.Credentials.AnonymousPayload;
type ApiKeyPayload = Realm.Credentials.ApiKeyPayload;
type EmailPasswordPayload = Realm.Credentials.EmailPasswordPayload;
type OAuth2RedirectPayload = Realm.Credentials.OAuth2RedirectPayload;
type GoogleAuthCodePayload = Realm.Credentials.GoogleAuthCodePayload;
type GooglePayload = Realm.Credentials.GooglePayload;
type FacebookPayload = Realm.Credentials.FacebookPayload;
type FunctionPayload = Realm.Credentials.FunctionPayload;
type JWTPayload = Realm.Credentials.JWTPayload;
type ApplePayload = Realm.Credentials.ApplePayload;
type GoogleOptions = OAuth2RedirectPayload | GoogleAuthCodePayload | {
idToken: string;

@@ -202,17 +108,16 @@ };

*/
declare type ProviderType = "anon-user" | "api-key" | "local-userpass" | "custom-function" | "custom-token" | "oauth2-google" | "oauth2-facebook" | "oauth2-apple";
declare type SimpleObject = Record<string, unknown>;
type ProviderType = "anon-user" | "api-key" | "local-userpass" | "custom-function" | "custom-token" | "oauth2-google" | "oauth2-facebook" | "oauth2-apple";
type SimpleObject$2 = Record<string, unknown>;
/**
* Instances of this class can be passed to the `app.logIn` method to authenticate an end-user.
*/
declare class Credentials<PayloadType extends SimpleObject = SimpleObject> implements Realm.Credentials<PayloadType> {
declare class Credentials<PayloadType extends SimpleObject$2 = SimpleObject$2> implements Realm.Credentials<PayloadType> {
/**
* Creates credentials that logs in using the [Anonymous Provider](https://docs.mongodb.com/realm/authentication/anonymous/).
*
* @param reuse - Reuse any existing anonymous user already logged in.
* @returns The credentials instance, which can be passed to `app.logIn`.
*/
static anonymous(): Credentials<AnonymousPayload>;
static anonymous(reuse?: boolean): Credentials<AnonymousPayload>;
/**
* Creates credentials that logs in using the [API Key Provider](https://docs.mongodb.com/realm/authentication/api-key/).
*
* @param key The secret content of the API key.

@@ -225,3 +130,2 @@ * @returns The credentials instance, which can be passed to `app.logIn`.

* Note: This was formerly known as the "Username/Password" provider.
*
* @param email The end-users email address.

@@ -234,3 +138,2 @@ * @param password The end-users password.

* Creates credentials that logs in using the [Custom Function Provider](https://docs.mongodb.com/realm/authentication/custom-function/).
*
* @param payload The custom payload as expected by the server.

@@ -242,3 +145,2 @@ * @returns The credentials instance, which can be passed to `app.logIn`.

* Creates credentials that logs in using the [Custom JWT Provider](https://docs.mongodb.com/realm/authentication/custom-jwt/).
*
* @param token The JSON Web Token (JWT).

@@ -250,3 +152,2 @@ * @returns The credentials instance, which can be passed to `app.logIn`.

* Creates credentials that logs in using the [Google Provider](https://docs.mongodb.com/realm/authentication/google/).
*
* @param payload The URL that users should be redirected to, the auth code or id token from Google.

@@ -263,3 +164,2 @@ * @returns The credentials instance, which can be passed to `app.logIn`.

* Creates credentials that logs in using the [Facebook Provider](https://docs.mongodb.com/realm/authentication/facebook/).
*
* @param redirectUrlOrAccessToken The URL that users should be redirected to or the auth code returned from Facebook.

@@ -271,3 +171,2 @@ * @returns The credentials instance, which can be passed to `app.logIn`.

* Creates credentials that logs in using the [Apple ID Provider](https://docs.mongodb.com/realm/authentication/apple/).
*
* @param redirectUrlOrIdToken The URL that users should be redirected to or the id_token returned from Apple.

@@ -287,19 +186,162 @@ * @returns The credentials instance, which can be passed to `app.logIn`.

/**
* Reuse any user already authenticated with this provider.
*/
readonly reuse: boolean;
/**
* The data being sent to the service when authenticating.
*/
readonly payload: PayloadType;
constructor(name: string, type: "anon-user", payload: AnonymousPayload);
constructor(name: string, type: "api-key", payload: ApiKeyPayload);
constructor(name: string, type: "local-userpass", payload: EmailPasswordPayload);
constructor(name: string, type: "custom-function", payload: FunctionPayload);
constructor(name: string, type: "custom-token", payload: JWTPayload);
constructor(name: string, type: "oauth2-google", payload: OAuth2RedirectPayload | GooglePayload);
constructor(name: string, type: "oauth2-facebook", payload: OAuth2RedirectPayload | FacebookPayload);
constructor(name: string, type: "oauth2-apple", payload: OAuth2RedirectPayload | ApplePayload);
constructor(name: string, type: "anon-user", reuse: boolean, payload: AnonymousPayload);
constructor(name: string, type: "api-key", reuse: false, payload: ApiKeyPayload);
constructor(name: string, type: "local-userpass", reuse: false, payload: EmailPasswordPayload);
constructor(name: string, type: "custom-function", reuse: false, payload: FunctionPayload);
constructor(name: string, type: "custom-token", reuse: false, payload: JWTPayload);
constructor(name: string, type: "oauth2-google", reuse: false, payload: OAuth2RedirectPayload | GooglePayload);
constructor(name: string, type: "oauth2-facebook", reuse: false, payload: OAuth2RedirectPayload | FacebookPayload);
constructor(name: string, type: "oauth2-apple", reuse: false, payload: OAuth2RedirectPayload | ApplePayload);
}
type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect";
type RequestCredentials = "include" | "omit" | "same-origin";
type RequestMode = "cors" | "navigate" | "no-cors" | "same-origin";
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
type RequestBody = ArrayBuffer | TypedArray | string;
declare class AbortSignal {
static timeout(time: number): AbortSignal;
/**
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
*/
readonly aborted: boolean;
readonly reason?: unknown;
throwIfAborted?(): void;
}
declare class Headers {
append(name: string, value: string): void;
delete(name: string): void;
get(name: string): string | null;
has(name: string): boolean;
set(name: string, value: string): void;
forEach(callbackfn: (value: string, key: string, parent: this) => void): void;
getSetCookie?(): string[];
keys?(): IterableIterator<string>;
values?(): IterableIterator<string>;
entries?(): IterableIterator<[string, string]>;
[Symbol.iterator]?(): Iterator<[string, string]>;
}
type Blob = unknown;
type FormData = unknown;
declare class Response<PlatformHeaders extends Headers = Headers, PlatformResponseBody = ReadableStream | null> {
readonly headers: PlatformHeaders;
readonly ok: boolean;
readonly status: number;
readonly statusText: string;
readonly type: ResponseType;
readonly url: string;
readonly redirected: boolean;
readonly body?: PlatformResponseBody;
readonly bodyUsed: boolean;
readonly arrayBuffer: () => Promise<ArrayBuffer>;
readonly blob: () => Promise<Blob>;
readonly formData: () => Promise<FormData>;
readonly json: () => Promise<unknown>;
readonly text: () => Promise<string>;
readonly clone: () => this;
}
/**
* Minimal types for a ReadableStream.
* @todo Missing declarations for `constructor`, `pipeThrough`, `pipeTo` and `tee`.
*/
type ReadableStream<T = unknown> = {
/**
* Creates a reader and locks the stream to it.
* While the stream is locked, no other reader can be acquired until this one is released.
* @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/getReader
*/
getReader(): ReadableStreamDefaultReader<T>;
getReader(options: {
mode: "byob";
}): unknown;
/**
* Cancel is used when you've completely finished with the stream and don't need any more data from it, even if there are chunks enqueued waiting to be read.
* @return a Promise that resolves when the stream is canceled.
* @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/cancel
*/
cancel: (reason?: string) => Promise<void>;
};
type ReadableStreamReadDoneResult = {
done: true;
value?: unknown;
};
type ReadableStreamReadValueResult<T> = {
done: false;
value: T;
};
type ReadableStreamReadResult<TValue = unknown> = ReadableStreamReadValueResult<TValue> | ReadableStreamReadDoneResult;
type ReadableStreamDefaultReader<T = unknown> = {
/**
* a Promise that fulfills when the stream closes, or rejects if the stream throws an error or the reader's lock is released.
*/
closed: Promise<void>;
/**
* Cancel is used when you've completely finished with the stream and don't need any more data from it, even if there are chunks enqueued waiting to be read.
* @param reason A human-readable reason for the cancellation.
* @returns a Promise that resolves when the stream is canceled. Calling this method signals a loss of interest in the stream by a consumer.
* @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader/cancel
*/
cancel(reason?: string): Promise<void>;
/**
* @returns a Promise providing access to the next chunk in the stream's internal queue.
* @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader/read
*/
read(): Promise<ReadableStreamReadResult<T>>;
/**
* Releases the reader's lock on the stream.
* @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader/releaseLock
*/
releaseLock(): void;
};
declare function fetch<PlatformRequestBody = RequestBody, PlatformHeaders extends Headers = Headers, PlatformAbortSignal extends AbortSignal = AbortSignal, PlatformResponseBody = ReadableStream | null>(input: string, init?: RequestInit<PlatformRequestBody, PlatformHeaders, PlatformAbortSignal>): Promise<Response<PlatformHeaders, PlatformResponseBody>>;
interface RequestInit<PlatformRequestBody = RequestBody, PlatformHeaders = Headers, PlatformAbortSignal = AbortSignal> {
/**
* The request's body.
*/
body?: PlatformRequestBody;
/**
* A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials.
*/
credentials?: RequestCredentials;
/**
* The request's headers.
*/
headers?: PlatformHeaders | Record<string, string>;
/**
* A cryptographic hash of the resource to be fetched by request. Sets request's integrity.
*/
integrity?: string;
/**
* A boolean to set request's keepalive.
*/
keepalive?: boolean;
/**
* A string to set request's method.
*/
method?: string;
/**
* A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode.
*/
mode?: RequestMode;
/**
* An AbortSignal to set request's signal.
*/
signal?: PlatformAbortSignal;
}
/**
* Some fetch function
*/
type FetchFunction = typeof fetch<unknown>;
/**
* Used to control which user is currently active - this would most likely be the {App} instance.
*/
declare type UserContext = {
type UserContext = {
/**

@@ -313,11 +355,12 @@ * The currently active user.

*/
declare type LocationUrlContext = {
type LocationUrlContext = {
/** The location URL of the app, used instead of the base url. */
locationUrl: Promise<string>;
};
declare type TokenType = "access" | "refresh" | "none";
interface RequestWithUrl<RequestBody> extends Request<RequestBody> {
type TokenType = "access" | "refresh" | "none";
interface RequestWithUrl<RequestBody> extends RequestInit<RequestBody> {
path?: never;
url: string;
}
interface RequestWithPath<RequestBody> extends Omit<Request<RequestBody>, "url"> {
interface RequestWithPath<RequestBody> extends Omit<RequestInit<RequestBody>, "url"> {
/** Construct a URL from the location URL prepended is path */

@@ -330,6 +373,5 @@ path: string;

*/
declare type AuthenticatedRequest<RequestBody = unknown> = {
type AuthenticatedRequest<RequestBody = unknown> = {
/**
* Which token should be used when requesting?
*
* @default "access"

@@ -346,3 +388,3 @@ */

*/
declare type FetcherConfig = {
type FetcherConfig = {
/**

@@ -353,5 +395,5 @@ * The id of the app.

/**
* The underlying network transport.
* The underlying fetch function.
*/
transport: NetworkTransport;
fetch: FetchFunction;
/**

@@ -367,3 +409,3 @@ * An object which can be used to determine the currently active user.

/**
* Wraps a NetworkTransport from the "@realm/network-transport" package.
* Wraps the fetch from the "@realm/fetch" package.
* Extracts error messages and throws `MongoDBRealmError` objects upon failures.

@@ -392,28 +434,20 @@ * Injects access or refresh tokens for a current or specific user.

private static buildJsonHeader;
private readonly config;
/**
* The id of the app, which this Fetcher was created for.
*/
private readonly appId;
private readonly transport;
private readonly userContext;
private readonly locationUrlContext;
/**
* @param config A configuration of the fetcher.
* @param config.appId The application id.
* @param config.transport The transport used when fetching.
* @param config.fetch The fetch function used when fetching.
* @param config.userContext An object used to determine the requesting user.
* @param config.locationUrlContext An object used to determine the location / base URL.
*/
constructor({ appId, transport, userContext, locationUrlContext }: FetcherConfig);
constructor(config: FetcherConfig);
clone(config: Partial<FetcherConfig>): Fetcher;
/**
* Fetch a network resource as an authenticated user.
*
* @param request The request which should be sent to the server.
* @returns The response from the server.
*/
fetch<RequestBody = unknown>(request: AuthenticatedRequest<RequestBody>): Promise<FetchResponse>;
fetch<RequestBody = unknown>(request: AuthenticatedRequest<RequestBody>): Promise<Response>;
/**
* Fetch a network resource as an authenticated user and parse the result as extended JSON.
*
* @param request The request which should be sent to the server.

@@ -425,3 +459,2 @@ * @returns The response from the server, parsed as extended JSON.

* Fetch an "event-stream" resource as an authenticated user.
*
* @param request The request which should be sent to the server.

@@ -435,2 +468,5 @@ * @returns An async iterator over the response body.

get appRoute(): {
/**
* Some fetch function
*/
path: string;

@@ -489,3 +525,2 @@ location(): {

* Construct an interface to the email / password authentication provider.
*
* @param fetcher The underlying fetcher used to request the services.

@@ -519,3 +554,2 @@ * @param providerName Optional custom name of the authentication provider.

* Construct an interface to the API-key authentication provider.
*
* @param fetcher The fetcher used to send requests to services.

@@ -538,3 +572,3 @@ */

declare type SimpleObject$1 = Record<string, unknown>;
type SimpleObject$1 = Record<string, unknown>;
interface HydratableUserParameters {

@@ -679,3 +713,2 @@ app: App;

* Reads out the list of user ids from storage.
*
* @returns A list of user ids.

@@ -687,3 +720,2 @@ */

* Optionally merging with existing ids stored in the storage, by prepending these while voiding duplicates.
*
* @param userIds The list of ids to store.

@@ -695,3 +727,2 @@ * @param mergeWithExisting Prepend existing ids to avoid data-races with other apps using this storage.

* Remove an id from the list of ids.
*
* @param userId The id of a User to be removed.

@@ -718,3 +749,3 @@ */

}
declare type DeviceInformationValues = {
type DeviceInformationValues = {
[DeviceFields.PLATFORM]: string;

@@ -727,3 +758,3 @@ [DeviceFields.PLATFORM_VERSION]: string;

};
declare type DeviceInformationParams = {
type DeviceInformationParams = {
appId?: string;

@@ -781,3 +812,3 @@ appVersion?: string;

*/
declare type AuthResponse = {
type AuthResponse = {
/**

@@ -800,3 +831,3 @@ * The id of the user.

};
declare type DeviceInformationGetter = () => DeviceInformation;
type DeviceInformationGetter = () => DeviceInformation;
/**

@@ -831,7 +862,7 @@ * Handles authentication and linking of users.

declare type SimpleObject$2 = Record<string, unknown>;
type SimpleObject = Record<string, unknown>;
/**
* Default base url to prefix all requests if no baseUrl is specified in the configuration.
*/
declare const DEFAULT_BASE_URL = "https://realm.mongodb.com";
declare const DEFAULT_BASE_URL = "https://services.cloud.mongodb.com";
/**

@@ -844,3 +875,3 @@ * Configuration to pass as an argument when constructing an app.

*/
transport?: NetworkTransport;
fetch?: FetchFunction;
/**

@@ -859,3 +890,3 @@ * Used when persisting app state, such as tokens of authenticated users.

*/
declare class App<FunctionsFactoryType = Realm.DefaultFunctionsFactory & Realm.BaseFunctionsFactory, CustomDataType = SimpleObject$2> implements Realm.App<FunctionsFactoryType, CustomDataType> {
declare class App<FunctionsFactoryType = Realm.DefaultFunctionsFactory & Realm.BaseFunctionsFactory, CustomDataType = SimpleObject> implements Realm.App<FunctionsFactoryType, CustomDataType> {
/**

@@ -868,3 +899,2 @@ * A map of app instances returned from calling getApp.

* Calling this function multiple times with the same id will return the same instance.
*
* @param id The Realm App id visible from the Atlas App Services UI or a configuration.

@@ -914,3 +944,2 @@ * @returns The Realm App instance.

* Construct a Realm App, either from the Realm App id visible from the Atlas App Services UI or a configuration.
*
* @param idOrConfiguration The Realm App id or a configuration to use for this app.

@@ -921,3 +950,2 @@ */

* Switch user.
*
* @param nextUser The user or id of the user to switch to.

@@ -928,3 +956,2 @@ */

* Log in a user.
*
* @param credentials Credentials to use when logging in.

@@ -957,3 +984,2 @@ * @param fetchProfile Should the users profile be fetched? (default: true)

* The currently active user (or null if no active users exists).
*
* @returns the currently active user or null.

@@ -964,5 +990,4 @@ */

* All active and logged-out users:
* - First in the list are active users (ordered by most recent call to switchUser or login)
* - Followed by logged out users (also ordered by most recent call to switchUser or login).
*
* - First in the list are active users (ordered by most recent call to switchUser or login)
* - Followed by logged out users (also ordered by most recent call to switchUser or login).
* @returns An array of users active or logged out users (current user being the first).

@@ -982,3 +1007,2 @@ */

* This helps de-duplicating users in the list of users known to the app.
*
* @param response A response from the Authenticator.

@@ -1002,3 +1026,3 @@ * @param providerType The type of the authentication provider used.

*/
readonly method: Method;
readonly method: string;
/**

@@ -1031,3 +1055,3 @@ * The URL of the resource which got fetched.

* Note: The caller must throw this error themselves.
*
* @param url The url of the requested resource.
* @param request The request sent to the server.

@@ -1037,4 +1061,4 @@ * @param response A raw response, as returned from the server.

*/
static fromRequestAndResponse(request: Request<unknown>, response: FetchResponse): Promise<MongoDBRealmError>;
constructor(method: Method, url: string, statusCode: number, statusText: string, error?: string, errorCode?: string, link?: string);
static fromRequestAndResponse(url: string, request: RequestInit<unknown>, response: Response): Promise<MongoDBRealmError>;
constructor(method: string, url: string, statusCode: number, statusText: string, error?: string, errorCode?: string, link?: string);
}

@@ -1045,3 +1069,3 @@

*/
declare type Window = {
type Window = {
/**

@@ -1066,3 +1090,3 @@ * Attempt to close the window.

/** An object with values specific to the runtime environment. */
declare type Environment = {
type Environment = {
/**

@@ -1092,3 +1116,2 @@ * The default storage instance on the environment.

* Note: This should be called as the first thing before executing any code which calls getEnvironment()
*
* @param e An object containing environment specific implementations.

@@ -1099,3 +1122,2 @@ */

* Get the environment of execution.
*
* @returns An object containing environment specific implementations.

@@ -1108,3 +1130,2 @@ */

* Calling this function multiple times with the same id will return the same instance.
*
* @param id The Realm App id visible from the Atlas App Services UI or a configuration.

@@ -1146,5 +1167,5 @@ * @returns The Realm App instance.

}
/**
* Handle an OAuth 2.0 redirect.
*
* @param location An optional location to use (defaults to the windows current location).

@@ -1155,2 +1176,2 @@ * @param storage Optional storage used to save any results from the location.

export { App, AppConfiguration, Credentials, DEFAULT_BASE_URL, LocalStorage, MongoDBRealmError, ProviderType, User, UserState, UserType, getApp, getEnvironment, handleAuthRedirect, setEnvironment };
export { App, type AppConfiguration, Credentials, DEFAULT_BASE_URL, LocalStorage, MongoDBRealmError, type ProviderType, User, UserState, UserType, getApp, getEnvironment, handleAuthRedirect, setEnvironment };
{
"name": "realm-web",
"version": "2.0.0",
"version": "2.0.1",
"description": "Authenticate and communicate with the Atlas App Services, from your web-browser",

@@ -14,12 +14,47 @@ "main": "./dist/bundle.cjs.js",

"scripts": {
"prepack": "npm run build",
"prepare": "npm run update-types",
"update-types": "ts-node --project scripts/tsconfig.json scripts/update-types.ts",
"generate-types": "tsc --project src/dom/tsconfig.json --declaration --emitDeclarationOnly --declarationDir types/generated",
"build": "npm run generate-types && rollup --config",
"start": "npm run build -- --watch",
"bundle": "wireit",
"start": "npm run bundle -- --watch",
"lint": "eslint --ext .js,.ts .",
"test": "mocha 'src/tests/**/*.test.ts'",
"postversion": "ts-node --project scripts/tsconfig.json scripts/postversion.ts"
"test": "mocha",
"docs": "wireit"
},
"wireit": {
"bundle": {
"command": "rollup --config",
"dependencies": [
"generate-types",
"../fetch:build"
],
"files": [
"rollup.config.mjs",
"src/**/*.ts",
"src/**/tsconfig.json",
"tsconfig.json",
"types"
],
"output": [
"dist"
]
},
"generate-types": {
"command": "tsc --project src/dom/tsconfig.json --declaration --emitDeclarationOnly --declarationDir types/generated",
"dependencies": [
"../realm-common:bundle"
],
"files": [
"src/**/*.ts",
"src/**/tsconfig.json",
"tsconfig.json"
],
"output": [
"types/generated"
]
},
"docs": {
"command": "typedoc",
"dependencies": [
"bundle"
]
}
},
"files": [

@@ -35,5 +70,5 @@ "dist",

"author": {
"name": "Realm",
"name": "MongoDB",
"email": "help@realm.io",
"url": "https://realm.io"
"url": "https://www.mongodb.com/docs/realm/"
},

@@ -45,3 +80,3 @@ "repository": {

},
"homepage": "https://github.com/realm/realm-js/tree/master/packages/realm-web#readme",
"homepage": "https://github.com/realm/realm-js/tree/main/packages/realm-web#readme",
"bugs": {

@@ -55,28 +90,17 @@ "url": "https://github.com/realm/realm-js/issues"

"detect-browser": "^5.2.1",
"js-base64": "^3.7.2"
"js-base64": "^3.7.6"
},
"optionalDependencies": {
"abort-controller": "^3.0.0",
"node-fetch": "^2.6.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^13.0.1",
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-replace": "^2.3.3",
"@rollup/plugin-typescript": "^4.1.1",
"@realm/fetch": "^0.1.0",
"@types/chai": "^4.2.9",
"@types/fs-extra": "^8.1.0",
"@types/fs-extra": "^11.0.4",
"@types/js-base64": "^3.3.1",
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.6",
"abort-controller": "^3.0.0",
"chai": "^4.2.0",
"fs-extra": "^10.0.0",
"mocha": "^5.2.0",
"node-fetch": "^3.2.10",
"@realm/network-transport": "^0.7.2",
"rollup": "^2.6.1",
"rollup-plugin-dts": "^1.4.0",
"rollup-plugin-node-builtins": "^2.1.2"
"@types/mocha": "^10.0.6",
"chai": "4.3.6",
"fs-extra": "^11.2.0",
"mocha": "^10.2.0"
},
"engines": {
"node": ">=18"
}
}

@@ -7,5 +7,5 @@ # Realm Web

Visit https://docs.mongodb.com/realm/web/ for quick guides on getting started and examples on how to use it.
Visit [mongodb.com/docs/atlas/device-sdks/web/](https://www.mongodb.com/docs/atlas/device-sdks/web/) for quick guides on getting started and examples on how to use it.
We're not publishing documentation explicitly for this SDK, but we aim to align names and method signatures identical for the subset of functionality in Realm Web which is also available in the Realm JS SDK. For this reason, the [Realm JS reference manual](https://docs.mongodb.com/realm-sdks/js/latest/) is a great start to learn about the classes and methods provided by the Realm Web SDK.
We're not publishing documentation explicitly for this SDK, but we aim to align names and method signatures identical for the subset of functionality in Realm Web which is also available in the Realm JS SDK. For this reason, the [mongodb.com/docs/realm-sdks/js/latest/](https://www.mongodb.com/docs/realm-sdks/js/latest/) is a great start to learn about the classes and methods provided by the Realm Web SDK.

@@ -29,8 +29,9 @@ ## Installation

- The Realm Web project *will not* include a Realm Sync client in any foreseeable future. Use the `realm` package to use Realm Sync from a Node.js, ReactNative or Electron environment.
- A limited selection of [services](https://docs.mongodb.com/stitch/services/) are implemented at the moment:
- A limited selection of [app services](https://www.mongodb.com/docs/atlas/app-services/mongodb/) are implemented at the moment:
- MongoDB: Read, write and watch MongoDB documents.
<!--
## Using Realm Web in a Node.js environment
You must install two additional peer dependencies when importing this package from Node.js:
You must install two additional dependencies when importing this package from Node.js:

@@ -40,1 +41,2 @@ ```

```
-->

@@ -389,3 +389,3 @@ ////////////////////////////////////////////////////////////////////////////

CustomDataType = SimpleObject,
UserProfileDataType = DefaultUserProfileData
UserProfileDataType = DefaultUserProfileData,
> {

@@ -392,0 +392,0 @@ /**

@@ -24,2 +24,4 @@ ////////////////////////////////////////////////////////////////////////////

/// <reference path="./app.d.ts"/>
/// <reference path="./decorators.d.ts"/>
/// <reference path="./types.d.ts"/>

@@ -148,14 +150,38 @@ declare namespace Realm {

enum ClientResetMode {
Manual = "manual",
DiscardLocal = "discardLocal",
Manual = 'manual',
DiscardLocal = 'discardLocal', // for backward compatibility
DiscardUnsyncedChanges = 'discardUnsyncedChanges',
RecoverUnsyncedChanges = 'recoverUnsyncedChanges',
RecoverOrDiscardUnsyncedChanges = 'recoverOrDiscardUnsyncedChanges'
}
type ClientResetFallbackCallback = (session: Realm.App.Sync.Session, path: string) => void;
type ClientResetBeforeCallback = (localRealm: Realm) => void;
type ClientResetAfterCallback = (localRealm: Realm, remoteRealm: Realm) => void;
interface ClientResetConfiguration<ClientResetModeT = ClientResetMode> {
mode: ClientResetModeT;
onBefore?: ClientResetBeforeCallback;
onAfter?: ClientResetAfterCallback;
interface ClientResetManualConfiguration {
mode: ClientResetMode.Manual;
onManual?: ClientResetFallbackCallback;
}
interface ClientResetDiscardUnsyncedChangesConfiguration {
mode: ClientResetMode.DiscardLocal | ClientResetMode.DiscardUnsyncedChanges;
onBefore?: ClientResetBeforeCallback;
onAfter?: ClientResetAfterCallback;
}
interface ClientResetRecoveryConfiguration {
mode: ClientResetMode.RecoverUnsyncedChanges;
onBefore?: ClientResetBeforeCallback;
onAfter?: ClientResetAfterCallback;
onFallback?: ClientResetFallbackCallback;
}
interface ClientResetRecoveryOrDiscardConfiguration {
mode: ClientResetMode.RecoverOrDiscardUnsyncedChanges;
onBefore?: ClientResetBeforeCallback;
onRecovery?: ClientResetAfterCallback;
onDiscard?: ClientResetAfterCallback;
onFallback?: ClientResetFallbackCallback;
}
type ClientResetConfiguration = ClientResetManualConfiguration | ClientResetDiscardUnsyncedChangesConfiguration | ClientResetRecoveryConfiguration | ClientResetRecoveryOrDiscardConfiguration;
interface BaseSyncConfiguration{

@@ -169,2 +195,3 @@ user: User;

onError?: ErrorCallback;
clientReset?: ClientResetConfiguration;
}

@@ -179,3 +206,2 @@

partitionValue?: never;
clientReset?: ClientResetConfiguration<ClientResetMode.Manual>;
/**

@@ -227,3 +253,2 @@ * Optional object to configure the setup of an initial set of flexible

partitionValue: Realm.App.Sync.PartitionValue;
clientReset?: ClientResetConfiguration<ClientResetMode>;
}

@@ -284,10 +309,32 @@

/**
* Object
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Object.html }
* Base class for a Realm Object.
* @see
* {@link https://realm.io/docs/javascript/latest/api/Realm.Object.html}
*
* @example
* To define a class `Person` which requires the `name` and `age` properties to be
* specified when it is being constructed, using the Realm Babel plugin to allow
* Typescript-only model definitions (otherwise it would require a `static` schema):
* ```
* class Person extends Realm.Object<Person, "name" | "age"> {
* _id = new Realm.Types.ObjectId();
* name: string;
* age: Realm.Types.Int;
* }
* ```
*
* @typeParam `T` - The type of this class (e.g. if your class is `Person`,
* `T` should also be `Person` - this duplication is required due to how
* TypeScript works)
*
* @typeParam `RequiredProperties` - The names of any properties of this
* class which are required when an instance is constructed with `new`. Any
* properties not specified will be optional, and will default to a sensible
* null value if no default is specified elsewhere.
*/
abstract class Object<T = unknown> {
abstract class Object<T = unknown, RequiredProperties extends keyof OmittedRealmTypes<T> = never> {
/**
* Creates a new object in the database.
*/
constructor(realm: Realm, values: Unmanaged<T>);
constructor(realm: Realm, values: Unmanaged<T, RequiredProperties>);

@@ -344,2 +391,22 @@ /**

getPropertyType(propertyName: string): string;
/**
* Optionally specify the name of the schema when using @realm/babel-plugin
*/
static name?: string;
/**
* Optionally specify the primary key of the schema when using @realm/babel-plugin
*/
static primaryKey?: string;
/**
* Optionally specify that the schema is an embedded schema when using @realm/babel-plugin
*/
static embedded?: boolean;
/**
* Optionally specify that the schema should sync unidirectionally if using flexible sync when using @realm/babel-plugin
*/
static asymmetric?: boolean;
}

@@ -593,3 +660,3 @@ /**

const enum SessionStopPolicy {
enum SessionStopPolicy {
AfterUpload = "after-upload",

@@ -606,3 +673,3 @@ Immediately = "immediately",

const enum OpenRealmBehaviorType {
enum OpenRealmBehaviorType {
DownloadBeforeOpen = 'downloadBeforeOpen',

@@ -612,3 +679,3 @@ OpenImmediately = "openImmediately"

const enum OpenRealmTimeOutBehavior {
enum OpenRealmTimeOutBehavior {
OpenLocalRealm = 'openLocalRealm',

@@ -815,7 +882,10 @@ ThrowException = 'throwException'

*
* The {@link Subscription}s in a SubscriptionSet can be accessed as an array, e.g.
* `realm.subscriptions[0]`. This array is readonly – SubscriptionSets can only be
* modified inside a {@link SubscriptionSet.update} callback.
* SubscriptionSets can only be modified inside a {@link SubscriptionSet.update} callback.
*
* The SubscriptionSet is an iterable; thus, if absolutely needed, the contained
* {@link Subscription}s can be accessed in `for-of` loops or spread into an `Array`
* for access to the ECMAScript Array API, e.g. `[...realm.subscriptions][0]`. Directly
* accessing the SubscriptionSet as an array is deprecated.
*/
interface BaseSubscriptionSet extends ReadonlyArray<Subscription> {
interface BaseSubscriptionSet extends DeprecatedReadonlyArray<Subscription> {
new(): never; // This type isn't supposed to be constructed manually by end users.

@@ -836,2 +906,7 @@

/**
* @returns The number of subscriptions in the set.
*/
readonly length: number;
/**
* @returns The version of the SubscriptionSet. This is incremented every time an

@@ -1046,2 +1121,12 @@ * {@link update} is applied.

/** Make all fields optional except those specified in K */
type OptionalExcept<T, K extends keyof T> = Partial<T> & Pick<T, K>;
/**
* Omits all properties of a model which are not defined by the schema,
* making all properties optional except those specified in RequiredProperties.
*/
type OmittedRealmTypesWithRequired<T, RequiredProperties extends keyof OmittedRealmTypes<T>> =
OptionalExcept<OmittedRealmTypes<T>, RequiredProperties>;
/** Remaps realm types to "simpler" types (arrays and objects) */

@@ -1054,5 +1139,59 @@ type RemappedRealmTypes<T> =

* Joins T stripped of all keys which value extends Realm.Collection and all inherited from Realm.Object,
* with only the keys which value extends Realm.List, remapped as Arrays.
* with only the keys which value extends Realm.List, remapped as Arrays. All properties are optional
* except those specified in RequiredProperties.
*/
type Unmanaged<T> = OmittedRealmTypes<T> & RemappedRealmTypes<T>;
type Unmanaged<T, RequiredProperties extends keyof OmittedRealmTypes<T> = never> =
OmittedRealmTypesWithRequired<T, RequiredProperties> & RemappedRealmTypes<T>;
/**
* ReadonlyArray with members marked as deprecated.
*/
interface DeprecatedReadonlyArray<T> extends ReadonlyArray<T> {
/**@deprecated */
toString(): string;
/**@deprecated */
toLocaleString(): string;
/**@deprecated */
concat(...items: ConcatArray<T>[]): T[];
/**@deprecated */
concat(...items: (T | ConcatArray<T>)[]): T[];
/**@deprecated */
join(separator?: string): string;
/**@deprecated */
slice(start?: number, end?: number): T[];
/**@deprecated */
indexOf(searchElement: T, fromIndex?: number): number;
/**@deprecated */
lastIndexOf(searchElement: T, fromIndex?: number): number;
/**@deprecated */
every<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): this is readonly S[];
/**@deprecated */
every(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
/**@deprecated */
some(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
/**@deprecated */
forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void;
/**@deprecated */
map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[];
/**@deprecated */
filter<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[];
/**@deprecated */
filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[];
/**@deprecated */
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
/**@deprecated */
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
/**@deprecated */
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
/**@deprecated */
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
/**@deprecated */
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
/**@deprecated */
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
/**@deprecated */
readonly [n: number]: T;
}
declare class Realm {

@@ -1059,0 +1198,0 @@ static defaultPath: string;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc